mirror of
https://github.com/neon443/NearFuture.git
synced 2026-03-11 06:49:12 +00:00
improved app icon getting - now gets the actual app icon
This commit is contained in:
@@ -5,76 +5,76 @@
|
||||
// Created by Nihaal Sharma on 02/01/2025.
|
||||
//
|
||||
|
||||
import ActivityKit
|
||||
//import ActivityKit
|
||||
import WidgetKit
|
||||
import SwiftUI
|
||||
|
||||
struct NearFutureWidgetsAttributes: ActivityAttributes {
|
||||
public struct ContentState: Codable, Hashable {
|
||||
// Dynamic stateful properties about your activity go here!
|
||||
var emoji: String
|
||||
}
|
||||
//struct NearFutureWidgetsAttributes: ActivityAttributes {
|
||||
// public struct ContentState: Codable, Hashable {
|
||||
// // Dynamic stateful properties about your activity go here!
|
||||
// var emoji: String
|
||||
// }
|
||||
//
|
||||
// // Fixed non-changing properties about your activity go here!
|
||||
// var name: String
|
||||
//}
|
||||
|
||||
// Fixed non-changing properties about your activity go here!
|
||||
var name: String
|
||||
}
|
||||
//struct NearFutureWidgetsLiveActivity: Widget {
|
||||
// var body: some WidgetConfiguration {
|
||||
// ActivityConfiguration(for: NearFutureWidgetsAttributes.self) { context in
|
||||
// // Lock screen/banner UI goes here
|
||||
// VStack {
|
||||
// Text("Hello \(context.state.emoji)")
|
||||
// }
|
||||
// .activityBackgroundTint(Color.cyan)
|
||||
// .activitySystemActionForegroundColor(Color.black)
|
||||
//
|
||||
// } dynamicIsland: { context in
|
||||
// DynamicIsland {
|
||||
// // Expanded UI goes here. Compose the expanded UI through
|
||||
// // various regions, like leading/trailing/center/bottom
|
||||
// DynamicIslandExpandedRegion(.leading) {
|
||||
// Text("Leading")
|
||||
// }
|
||||
// DynamicIslandExpandedRegion(.trailing) {
|
||||
// Text("Trailing")
|
||||
// }
|
||||
// DynamicIslandExpandedRegion(.bottom) {
|
||||
// Text("Bottom \(context.state.emoji)")
|
||||
// // more content
|
||||
// }
|
||||
// } compactLeading: {
|
||||
// Text("L")
|
||||
// } compactTrailing: {
|
||||
// Text("T \(context.state.emoji)")
|
||||
// } minimal: {
|
||||
// Text(context.state.emoji)
|
||||
// }
|
||||
// .widgetURL(URL(string: "http://www.apple.com"))
|
||||
// .keylineTint(Color.red)
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//extension NearFutureWidgetsAttributes {
|
||||
// fileprivate static var preview: NearFutureWidgetsAttributes {
|
||||
// NearFutureWidgetsAttributes(name: "World")
|
||||
// }
|
||||
//}
|
||||
|
||||
struct NearFutureWidgetsLiveActivity: Widget {
|
||||
var body: some WidgetConfiguration {
|
||||
ActivityConfiguration(for: NearFutureWidgetsAttributes.self) { context in
|
||||
// Lock screen/banner UI goes here
|
||||
VStack {
|
||||
Text("Hello \(context.state.emoji)")
|
||||
}
|
||||
.activityBackgroundTint(Color.cyan)
|
||||
.activitySystemActionForegroundColor(Color.black)
|
||||
|
||||
} dynamicIsland: { context in
|
||||
DynamicIsland {
|
||||
// Expanded UI goes here. Compose the expanded UI through
|
||||
// various regions, like leading/trailing/center/bottom
|
||||
DynamicIslandExpandedRegion(.leading) {
|
||||
Text("Leading")
|
||||
}
|
||||
DynamicIslandExpandedRegion(.trailing) {
|
||||
Text("Trailing")
|
||||
}
|
||||
DynamicIslandExpandedRegion(.bottom) {
|
||||
Text("Bottom \(context.state.emoji)")
|
||||
// more content
|
||||
}
|
||||
} compactLeading: {
|
||||
Text("L")
|
||||
} compactTrailing: {
|
||||
Text("T \(context.state.emoji)")
|
||||
} minimal: {
|
||||
Text(context.state.emoji)
|
||||
}
|
||||
.widgetURL(URL(string: "http://www.apple.com"))
|
||||
.keylineTint(Color.red)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension NearFutureWidgetsAttributes {
|
||||
fileprivate static var preview: NearFutureWidgetsAttributes {
|
||||
NearFutureWidgetsAttributes(name: "World")
|
||||
}
|
||||
}
|
||||
|
||||
extension NearFutureWidgetsAttributes.ContentState {
|
||||
fileprivate static var smiley: NearFutureWidgetsAttributes.ContentState {
|
||||
NearFutureWidgetsAttributes.ContentState(emoji: "😀")
|
||||
}
|
||||
|
||||
fileprivate static var starEyes: NearFutureWidgetsAttributes.ContentState {
|
||||
NearFutureWidgetsAttributes.ContentState(emoji: "🤩")
|
||||
}
|
||||
}
|
||||
|
||||
#Preview("Notification", as: .content, using: NearFutureWidgetsAttributes.preview) {
|
||||
NearFutureWidgetsLiveActivity()
|
||||
} contentStates: {
|
||||
NearFutureWidgetsAttributes.ContentState.smiley
|
||||
NearFutureWidgetsAttributes.ContentState.starEyes
|
||||
}
|
||||
//extension NearFutureWidgetsAttributes.ContentState {
|
||||
// fileprivate static var smiley: NearFutureWidgetsAttributes.ContentState {
|
||||
// NearFutureWidgetsAttributes.ContentState(emoji: "😀")
|
||||
// }
|
||||
//
|
||||
// fileprivate static var starEyes: NearFutureWidgetsAttributes.ContentState {
|
||||
// NearFutureWidgetsAttributes.ContentState(emoji: "🤩")
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//#Preview("Notification", as: .content, using: NearFutureWidgetsAttributes.preview) {
|
||||
// NearFutureWidgetsLiveActivity()
|
||||
//} contentStates: {
|
||||
// NearFutureWidgetsAttributes.ContentState.smiley
|
||||
// NearFutureWidgetsAttributes.ContentState.starEyes
|
||||
//}
|
||||
|
||||
Reference in New Issue
Block a user