diff --git a/ios/Wonderous Widget/Assets.xcassets/AccentColor.colorset/Contents.json b/ios/Wonderous Widget/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 00000000..eb878970 --- /dev/null +++ b/ios/Wonderous Widget/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/ios/Wonderous Widget/Assets.xcassets/AppIcon.appiconset/Contents.json b/ios/Wonderous Widget/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000..13613e3e --- /dev/null +++ b/ios/Wonderous Widget/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,13 @@ +{ + "images" : [ + { + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/ios/Wonderous Widget/Assets.xcassets/Contents.json b/ios/Wonderous Widget/Assets.xcassets/Contents.json new file mode 100644 index 00000000..73c00596 --- /dev/null +++ b/ios/Wonderous Widget/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/ios/Wonderous Widget/Assets.xcassets/WidgetBackground.colorset/Contents.json b/ios/Wonderous Widget/Assets.xcassets/WidgetBackground.colorset/Contents.json new file mode 100644 index 00000000..eb878970 --- /dev/null +++ b/ios/Wonderous Widget/Assets.xcassets/WidgetBackground.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/ios/Wonderous Widget/Info.plist b/ios/Wonderous Widget/Info.plist new file mode 100644 index 00000000..0f118fb7 --- /dev/null +++ b/ios/Wonderous Widget/Info.plist @@ -0,0 +1,11 @@ + + + + + NSExtension + + NSExtensionPointIdentifier + com.apple.widgetkit-extension + + + diff --git a/ios/Wonderous Widget/Wonderous_Widget.swift b/ios/Wonderous Widget/Wonderous_Widget.swift new file mode 100644 index 00000000..a24f98f5 --- /dev/null +++ b/ios/Wonderous Widget/Wonderous_Widget.swift @@ -0,0 +1,66 @@ +// +// Wonderous_Widget.swift +// Wonderous Widget +// +// Created by Shawn on 2023-06-08. +// + +import WidgetKit +import SwiftUI + +struct Provider: TimelineProvider { + func placeholder(in context: Context) -> SimpleEntry { + SimpleEntry(date: Date()) + } + + func getSnapshot(in context: Context, completion: @escaping (SimpleEntry) -> ()) { + let entry = SimpleEntry(date: Date()) + completion(entry) + } + + func getTimeline(in context: Context, completion: @escaping (Timeline) -> ()) { + var entries: [SimpleEntry] = [] + + // Generate a timeline consisting of five entries an hour apart, starting from the current date. + let currentDate = Date() + for hourOffset in 0 ..< 5 { + let entryDate = Calendar.current.date(byAdding: .hour, value: hourOffset, to: currentDate)! + let entry = SimpleEntry(date: entryDate) + entries.append(entry) + } + + let timeline = Timeline(entries: entries, policy: .atEnd) + completion(timeline) + } +} + +struct SimpleEntry: TimelineEntry { + let date: Date +} + +struct Wonderous_WidgetEntryView : View { + var entry: Provider.Entry + + var body: some View { + Text(entry.date, style: .time) + } +} + +struct Wonderous_Widget: Widget { + let kind: String = "Wonderous_Widget" + + var body: some WidgetConfiguration { + StaticConfiguration(kind: kind, provider: Provider()) { entry in + Wonderous_WidgetEntryView(entry: entry) + } + .configurationDisplayName("My Widget") + .description("This is an example widget.") + } +} + +struct Wonderous_Widget_Previews: PreviewProvider { + static var previews: some View { + Wonderous_WidgetEntryView(entry: SimpleEntry(date: Date())) + .previewContext(WidgetPreviewContext(family: .systemSmall)) + } +} diff --git a/ios/Wonderous Widget/Wonderous_WidgetBundle.swift b/ios/Wonderous Widget/Wonderous_WidgetBundle.swift new file mode 100644 index 00000000..19af92f9 --- /dev/null +++ b/ios/Wonderous Widget/Wonderous_WidgetBundle.swift @@ -0,0 +1,16 @@ +// +// Wonderous_WidgetBundle.swift +// Wonderous Widget +// +// Created by Shawn on 2023-06-08. +// + +import WidgetKit +import SwiftUI + +@main +struct Wonderous_WidgetBundle: WidgetBundle { + var body: some Widget { + Wonderous_Widget() + } +}