diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 3fc2c971..7662fb4a 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -77,9 +77,9 @@ SPEC CHECKSUMS: GoogleMaps: 20d7b12be49a14287f797e88e0e31bc4156aaeb4 home_widget: 0434835a4c9a75704264feff6be17ea40e0f0d57 image_gallery_saver: cb43cc43141711190510e92c460eb1655cd343cb - package_info_plus: 6c92f08e1f853dc01228d6f553146438dafcd14e + package_info_plus: 115f4ad11e0698c8c1c5d8a689390df880f47e85 path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943 - share_plus: 056a1e8ac890df3e33cb503afffaf1e9b4fbae68 + share_plus: c3fef564749587fc939ef86ffb283ceac0baf9f5 shared_preferences_foundation: 5b919d13b803cadd15ed2dc053125c68730e5126 url_launcher_ios: 08a3dfac5fb39e8759aeb0abbd5d9480f30fc8b4 webview_flutter_wkwebview: 2e2d318f21a5e036e2c3f26171342e95908bd60a diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index f47fa968..7454c11b 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -10,12 +10,15 @@ 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 297F6FC72AD06E0D00FF159E /* WidgetKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 297F6FC62AD06E0D00FF159E /* WidgetKit.framework */; }; 297F6FC92AD06E0D00FF159E /* SwiftUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 297F6FC82AD06E0D00FF159E /* SwiftUI.framework */; }; - 297F6FCC2AD06E0D00FF159E /* Wonderous_WidgetBundle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 297F6FCB2AD06E0D00FF159E /* Wonderous_WidgetBundle.swift */; }; - 297F6FCE2AD06E0D00FF159E /* Wonderous_Widget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 297F6FCD2AD06E0D00FF159E /* Wonderous_Widget.swift */; }; + 297F6FCC2AD06E0D00FF159E /* WonderousWidgetBundle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 297F6FCB2AD06E0D00FF159E /* WonderousWidgetBundle.swift */; }; + 297F6FCE2AD06E0D00FF159E /* WonderousWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 297F6FCD2AD06E0D00FF159E /* WonderousWidget.swift */; }; 297F6FD12AD06E0F00FF159E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 297F6FD02AD06E0F00FF159E /* Assets.xcassets */; }; - 297F6FD32AD06E0F00FF159E /* Wonderous_Widget.intentdefinition in Sources */ = {isa = PBXBuildFile; fileRef = 297F6FCF2AD06E0D00FF159E /* Wonderous_Widget.intentdefinition */; }; - 297F6FD42AD06E0F00FF159E /* Wonderous_Widget.intentdefinition in Sources */ = {isa = PBXBuildFile; fileRef = 297F6FCF2AD06E0D00FF159E /* Wonderous_Widget.intentdefinition */; }; + 297F6FD32AD06E0F00FF159E /* WonderousWidget.intentdefinition in Sources */ = {isa = PBXBuildFile; fileRef = 297F6FCF2AD06E0D00FF159E /* WonderousWidget.intentdefinition */; }; + 297F6FD42AD06E0F00FF159E /* WonderousWidget.intentdefinition in Sources */ = {isa = PBXBuildFile; fileRef = 297F6FCF2AD06E0D00FF159E /* WonderousWidget.intentdefinition */; }; 297F6FD72AD06E0F00FF159E /* Wonderous WidgetExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 297F6FC52AD06E0D00FF159E /* Wonderous WidgetExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; + 297FD5742AE18011008D8BFE /* WonderousWidgetView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 297FD5732AE18011008D8BFE /* WonderousWidgetView.swift */; }; + 297FD5762AE19BD9008D8BFE /* WonderWidgetViewComponents.swift in Sources */ = {isa = PBXBuildFile; fileRef = 297FD5752AE19BD9008D8BFE /* WonderWidgetViewComponents.swift */; }; + 297FD5782AE19C25008D8BFE /* FlutterUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 297FD5772AE19C25008D8BFE /* FlutterUtils.swift */; }; 323DE3CFA8490EAB3C4E249C /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4A44ACC5DE81A9C3E5BDA151 /* Pods_Runner.framework */; }; 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; @@ -72,11 +75,15 @@ 297F6FC52AD06E0D00FF159E /* Wonderous WidgetExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = "Wonderous WidgetExtension.appex"; sourceTree = BUILT_PRODUCTS_DIR; }; 297F6FC62AD06E0D00FF159E /* WidgetKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WidgetKit.framework; path = System/Library/Frameworks/WidgetKit.framework; sourceTree = SDKROOT; }; 297F6FC82AD06E0D00FF159E /* SwiftUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftUI.framework; path = System/Library/Frameworks/SwiftUI.framework; sourceTree = SDKROOT; }; - 297F6FCB2AD06E0D00FF159E /* Wonderous_WidgetBundle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Wonderous_WidgetBundle.swift; sourceTree = ""; }; - 297F6FCD2AD06E0D00FF159E /* Wonderous_Widget.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Wonderous_Widget.swift; sourceTree = ""; }; - 297F6FCF2AD06E0D00FF159E /* Wonderous_Widget.intentdefinition */ = {isa = PBXFileReference; lastKnownFileType = file.intentdefinition; path = Wonderous_Widget.intentdefinition; sourceTree = ""; }; + 297F6FCB2AD06E0D00FF159E /* WonderousWidgetBundle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WonderousWidgetBundle.swift; sourceTree = ""; }; + 297F6FCD2AD06E0D00FF159E /* WonderousWidget.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WonderousWidget.swift; sourceTree = ""; }; + 297F6FCF2AD06E0D00FF159E /* WonderousWidget.intentdefinition */ = {isa = PBXFileReference; lastKnownFileType = file.intentdefinition; path = WonderousWidget.intentdefinition; sourceTree = ""; }; 297F6FD02AD06E0F00FF159E /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 297F6FD22AD06E0F00FF159E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 297FD56C2ADF0DAB008D8BFE /* Wonderous WidgetExtension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "Wonderous WidgetExtension.entitlements"; sourceTree = ""; }; + 297FD5732AE18011008D8BFE /* WonderousWidgetView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WonderousWidgetView.swift; sourceTree = ""; }; + 297FD5752AE19BD9008D8BFE /* WonderWidgetViewComponents.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WonderWidgetViewComponents.swift; sourceTree = ""; }; + 297FD5772AE19C25008D8BFE /* FlutterUtils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FlutterUtils.swift; sourceTree = ""; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 4A44ACC5DE81A9C3E5BDA151 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; @@ -126,11 +133,14 @@ 297F6FCA2AD06E0D00FF159E /* Wonderous Widget */ = { isa = PBXGroup; children = ( - 297F6FCB2AD06E0D00FF159E /* Wonderous_WidgetBundle.swift */, - 297F6FCD2AD06E0D00FF159E /* Wonderous_Widget.swift */, - 297F6FCF2AD06E0D00FF159E /* Wonderous_Widget.intentdefinition */, + 297F6FCB2AD06E0D00FF159E /* WonderousWidgetBundle.swift */, + 297F6FCD2AD06E0D00FF159E /* WonderousWidget.swift */, + 297F6FCF2AD06E0D00FF159E /* WonderousWidget.intentdefinition */, 297F6FD02AD06E0F00FF159E /* Assets.xcassets */, 297F6FD22AD06E0F00FF159E /* Info.plist */, + 297FD5732AE18011008D8BFE /* WonderousWidgetView.swift */, + 297FD5752AE19BD9008D8BFE /* WonderWidgetViewComponents.swift */, + 297FD5772AE19C25008D8BFE /* FlutterUtils.swift */, ); path = "Wonderous Widget"; sourceTree = ""; @@ -159,6 +169,7 @@ 97C146E51CF9000F007C117D = { isa = PBXGroup; children = ( + 297FD56C2ADF0DAB008D8BFE /* Wonderous WidgetExtension.entitlements */, 9740EEB11CF90186004384FC /* Flutter */, 97C146F01CF9000F007C117D /* Runner */, 297F6FCA2AD06E0D00FF159E /* Wonderous Widget */, @@ -437,9 +448,12 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 297F6FD32AD06E0F00FF159E /* Wonderous_Widget.intentdefinition in Sources */, - 297F6FCE2AD06E0D00FF159E /* Wonderous_Widget.swift in Sources */, - 297F6FCC2AD06E0D00FF159E /* Wonderous_WidgetBundle.swift in Sources */, + 297FD5762AE19BD9008D8BFE /* WonderWidgetViewComponents.swift in Sources */, + 297F6FD32AD06E0F00FF159E /* WonderousWidget.intentdefinition in Sources */, + 297FD5742AE18011008D8BFE /* WonderousWidgetView.swift in Sources */, + 297F6FCE2AD06E0D00FF159E /* WonderousWidget.swift in Sources */, + 297FD5782AE19C25008D8BFE /* FlutterUtils.swift in Sources */, + 297F6FCC2AD06E0D00FF159E /* WonderousWidgetBundle.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -447,7 +461,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 297F6FD42AD06E0F00FF159E /* Wonderous_Widget.intentdefinition in Sources */, + 297F6FD42AD06E0F00FF159E /* WonderousWidget.intentdefinition in Sources */, 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, ); @@ -586,6 +600,7 @@ CLANG_ENABLE_OBJC_WEAK = YES; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_ENTITLEMENTS = "Wonderous WidgetExtension.entitlements"; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; @@ -625,6 +640,7 @@ CLANG_ENABLE_OBJC_WEAK = YES; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_ENTITLEMENTS = "Wonderous WidgetExtension.entitlements"; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; @@ -661,6 +677,7 @@ CLANG_ENABLE_OBJC_WEAK = YES; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_ENTITLEMENTS = "Wonderous WidgetExtension.entitlements"; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; diff --git a/ios/Runner/Runner.entitlements b/ios/Runner/Runner.entitlements index 903def2a..25cd9eb5 100644 --- a/ios/Runner/Runner.entitlements +++ b/ios/Runner/Runner.entitlements @@ -4,5 +4,9 @@ aps-environment development + com.apple.security.application-groups + + group.com.gskinner.flutter.wonders.widget + diff --git a/ios/Wonderous Widget/Assets.xcassets/AccentColor.colorset/Contents.json b/ios/Wonderous Widget/Assets.xcassets/AccentColor.colorset/Contents.json index eb878970..2bc2d6bf 100644 --- a/ios/Wonderous Widget/Assets.xcassets/AccentColor.colorset/Contents.json +++ b/ios/Wonderous Widget/Assets.xcassets/AccentColor.colorset/Contents.json @@ -1,6 +1,15 @@ { "colors" : [ { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0.360", + "green" : "0.580", + "red" : "0.890" + } + }, "idiom" : "universal" } ], diff --git a/ios/Wonderous Widget/Assets.xcassets/GreyMediumColor.colorset/Contents.json b/ios/Wonderous Widget/Assets.xcassets/GreyMediumColor.colorset/Contents.json new file mode 100644 index 00000000..574414aa --- /dev/null +++ b/ios/Wonderous Widget/Assets.xcassets/GreyMediumColor.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0.580", + "green" : "0.600", + "red" : "0.620" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/ios/Wonderous Widget/FlutterUtils.swift b/ios/Wonderous Widget/FlutterUtils.swift new file mode 100644 index 00000000..ab2011d2 --- /dev/null +++ b/ios/Wonderous Widget/FlutterUtils.swift @@ -0,0 +1,20 @@ +// +// FlutterUtils.swift +// Wonderous WidgetExtension +// +// Created by Shawn on 2023-10-19. +// + +import Foundation + + +var bundle: URL { + let bundle = Bundle.main + if bundle.bundleURL.pathExtension == "appex" { + // Peel off two directory levels - MY_APP.app/PlugIns/MY_APP_EXTENSION.appex + var url = bundle.bundleURL.deletingLastPathComponent().deletingLastPathComponent() + url.append(component: "Frameworks/App.framework/flutter_assets") + return url + } + return bundle.bundleURL +} diff --git a/ios/Wonderous Widget/WonderWidgetViewComponents.swift b/ios/Wonderous Widget/WonderWidgetViewComponents.swift new file mode 100644 index 00000000..6b71368d --- /dev/null +++ b/ios/Wonderous Widget/WonderWidgetViewComponents.swift @@ -0,0 +1,64 @@ +// +// File.swift +// Wonderous WidgetExtension +// +// Created by Shawn on 2023-10-19. +// + +import Foundation +import SwiftUI + + +// TODO: Add support for showing the last-found artifact from the app +// Load an image from the flutter assets bundle +struct BgImage : View { + var entry: WonderousEntry + var body: some View { + let image = bundle.appending(path: "/assets/images/widget/background-empty.jpg").path(); + print(image) + if let uiImage = UIImage(contentsOfFile: image) { + let image = Image(uiImage: uiImage) + .resizable() + .aspectRatio(contentMode: .fill) // Fill the entire view + // .edgesIgnoringSafeArea(.all) // Ignore the safe area + return AnyView(image) + } + print("The image file could not be loaded") + return AnyView(EmptyView()) + } + +} + +// Display a previously loaded remote image +struct NetImage : View { + var imageData: Data? + var body: some View { + if imageData != nil, let uiImage = UIImage(data: imageData!) { + return Image(uiImage: uiImage) + .resizable() + .aspectRatio(contentMode: .fit) + .frame(width: 80, height: 26.0) + } else { + return Image("EmptyChart") + .resizable() + .aspectRatio(contentMode: .fit) + .frame(width: 80, height: 26.0) + } + } +} + +struct GaugeProgressStyle: ProgressViewStyle { + + func makeBody(configuration: Configuration) -> some View { + let fractionCompleted = configuration.fractionCompleted ?? 0 + + return ZStack { + Circle() + .stroke(.gray, style: StrokeStyle(lineWidth: 2)) + Circle() + .trim(from: 0, to: fractionCompleted) + .stroke(.red, style: StrokeStyle(lineWidth: 4, lineCap: .round)) + .rotationEffect(.degrees(90)) + } + } +} diff --git a/ios/Wonderous Widget/Wonderous_Widget.intentdefinition b/ios/Wonderous Widget/WonderousWidget.intentdefinition similarity index 100% rename from ios/Wonderous Widget/Wonderous_Widget.intentdefinition rename to ios/Wonderous Widget/WonderousWidget.intentdefinition diff --git a/ios/Wonderous Widget/WonderousWidget.swift b/ios/Wonderous Widget/WonderousWidget.swift new file mode 100644 index 00000000..843e14ca --- /dev/null +++ b/ios/Wonderous Widget/WonderousWidget.swift @@ -0,0 +1,76 @@ +// +// CounterWidget.swift +// CounterWidget +// +// Created by Shawn on 2023-09-11. +// + +import WidgetKit +import SwiftUI +import Intents + +var netImgData: Data? = nil + + +// Widget, defines the display name and description, and also wraps the View +struct WonderousWidget: Widget { + let kind: String = "WonderousWidget" + + var body: some WidgetConfiguration { + StaticConfiguration(kind: kind, provider: Provider()) { entry in + WonderousWidgetView(entry: entry) + } + .configurationDisplayName("Wonderous Widget") + .description("Track your collected artifacts!") + .supportedFamilies([.systemSmall, .systemMedium, .systemLarge]) + } +} + +// Provider,returns various WonderousEntry configs based on current context +struct Provider: TimelineProvider { + // Provide an entry for a placeholder version of the widget + func placeholder(in context: Context) -> WonderousEntry { + WonderousEntry(date: Date(), count: 0, displaySize: context.displaySize, imageData: netImgData) + } + + // Provide an entry for the current time and state of the widget + func getSnapshot(in context: Context, completion: @escaping (WonderousEntry) -> ()) { + let entry:WonderousEntry + if(context.isPreview){ + // entry = placeholder(in: context) + entry = WonderousEntry(date: Date(), count: 0, displaySize: context.displaySize, imageData: netImgData) + } else { + let userDefaults = UserDefaults(suiteName: "group.com.gskinner.homewidget") + let count = userDefaults?.integer(forKey: "counter") ?? 0; + entry = WonderousEntry(date: Date(), count: count, displaySize: context.displaySize, imageData: netImgData) + } + completion(entry); + } + + // Provide an array of entries for the current time and, optionally, any future times + func getTimeline(in context: Context, completion: @escaping (Timeline) -> ()) { + // Load a remote image so it can be shown later + netImgData = try? Data( + contentsOf: URL(string: "https://www.wonderous.info/unsplash/-e0u9SAFeP4-32.jpg")! + ) + + getSnapshot(in: context) { (entry) in + let timeline = Timeline(entries: [entry], policy: .atEnd) + completion(timeline) + } + } +} + + +/// Entry, is passed into the view and defines the data it needs +struct WonderousEntry : TimelineEntry { + let date: Date + let count:Int; + let displaySize: CGSize + let imageData: Data? +} + + + + + diff --git a/ios/Wonderous Widget/Wonderous_WidgetBundle.swift b/ios/Wonderous Widget/WonderousWidgetBundle.swift similarity index 57% rename from ios/Wonderous Widget/Wonderous_WidgetBundle.swift rename to ios/Wonderous Widget/WonderousWidgetBundle.swift index 0e519485..09a92c69 100644 --- a/ios/Wonderous Widget/Wonderous_WidgetBundle.swift +++ b/ios/Wonderous Widget/WonderousWidgetBundle.swift @@ -1,5 +1,5 @@ // -// Wonderous_WidgetBundle.swift +// WonderousWidgetBundle.swift // Wonderous Widget // // Created by Shawn on 2023-10-06. @@ -9,8 +9,8 @@ import WidgetKit import SwiftUI @main -struct Wonderous_WidgetBundle: WidgetBundle { +struct WonderousWidgetBundle: WidgetBundle { var body: some Widget { - Wonderous_Widget() + WonderousWidget() } } diff --git a/ios/Wonderous Widget/WonderousWidgetView.swift b/ios/Wonderous Widget/WonderousWidgetView.swift new file mode 100644 index 00000000..1413320d --- /dev/null +++ b/ios/Wonderous Widget/WonderousWidgetView.swift @@ -0,0 +1,66 @@ +import WidgetKit +import SwiftUI +import Intents + +// Defines the view / layout of the widget +struct WonderousWidgetView : View { + @Environment(\.widgetFamily) var family: WidgetFamily + var entry: Provider.Entry + var body: some View { + let showTitle = family == .systemLarge + let showIcon = family != .systemSmall + let showTitleAndDesc = family != .systemSmall + let textColor:Color = .pink + let progress = 7.0 / 32.0; + let content = VStack{ + HStack { + if(showTitle) { + Text("Collection").foregroundColor(textColor) + } + Spacer(); + if(showIcon) { + Text("1").foregroundColor(textColor) + } + } + Spacer(); + HStack { + if(showTitleAndDesc) { + VStack(alignment: .leading){ + Text("Wonderous") + .font(.system(size: 22)) + .foregroundColor(textColor); + Text("Search for hidden artifacts") + .font(.system(size: 15)) + .foregroundColor(Color("GreyMediumColor")); + } + } + Spacer(); + ZStack{ + ProgressView(value: progress) + .progressViewStyle( + GaugeProgressStyle() + ) + .frame(width: 48, height: 48) + Text("\(Int(progress * 100))%").font(.system(size: 12)).foregroundColor(textColor) + } + } + //NetImage(imageData: netImgData) + }.widgetURL(URL(string: "wonderous://collections")) + + ZStack{ + BgImage(entry: entry) + LinearGradient( + gradient: Gradient(colors: [.black.opacity(0), .black]), + startPoint: .center, + endPoint: .bottom) + switch(family) { + case .systemSmall: + content.padding(16) + default: + content.padding(32) + } + + } + + } +} diff --git a/ios/Wonderous Widget/Wonderous_Widget.swift b/ios/Wonderous Widget/Wonderous_Widget.swift deleted file mode 100644 index 0c71aad5..00000000 --- a/ios/Wonderous Widget/Wonderous_Widget.swift +++ /dev/null @@ -1,68 +0,0 @@ -// -// Wonderous_Widget.swift -// Wonderous Widget -// -// Created by Shawn on 2023-10-06. -// - -import WidgetKit -import SwiftUI -import Intents - -struct Provider: IntentTimelineProvider { - func placeholder(in context: Context) -> SimpleEntry { - SimpleEntry(date: Date(), configuration: ConfigurationIntent()) - } - - func getSnapshot(for configuration: ConfigurationIntent, in context: Context, completion: @escaping (SimpleEntry) -> ()) { - let entry = SimpleEntry(date: Date(), configuration: configuration) - completion(entry) - } - - func getTimeline(for configuration: ConfigurationIntent, 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, configuration: configuration) - entries.append(entry) - } - - let timeline = Timeline(entries: entries, policy: .atEnd) - completion(timeline) - } -} - -struct SimpleEntry: TimelineEntry { - let date: Date - let configuration: ConfigurationIntent -} - -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 { - IntentConfiguration(kind: kind, intent: ConfigurationIntent.self, 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(), configuration: ConfigurationIntent())) - .previewContext(WidgetPreviewContext(family: .systemSmall)) - } -} diff --git a/ios/Wonderous WidgetExtension.entitlements b/ios/Wonderous WidgetExtension.entitlements new file mode 100644 index 00000000..3deb71a4 --- /dev/null +++ b/ios/Wonderous WidgetExtension.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.security.application-groups + + group.com.gskinner.flutter.wonders.widget + + + diff --git a/pubspec.yaml b/pubspec.yaml index eb806358..c866bbe9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -96,6 +96,7 @@ flutter: - assets/images/pyramids/ - assets/images/taj_mahal/ - assets/images/collectibles/ + - assets/images/widget/ fonts: - family: Cinzel