diff --git a/ios/Daily Widget/Daily_Widget.swift b/ios/Daily Widget/Daily_Widget.swift index f9d8f5d8e..79f2ef020 100644 --- a/ios/Daily Widget/Daily_Widget.swift +++ b/ios/Daily Widget/Daily_Widget.swift @@ -96,8 +96,11 @@ struct Daily_WidgetEntryView : View { private var heightReader: some View { GeometryReader { reader in Color.clear - .onChange(of: reader.size.height, initial: true) { oldVal, newVal in - infoViewHeight = newVal + .onAppear() { + infoViewHeight = reader.size.height + } + .onChange(of: reader.size.height) { val in + infoViewHeight = val } } } @@ -182,6 +185,16 @@ struct Daily_WidgetEntryView : View { } } +extension WidgetConfiguration { + func disableContentMarginsIfNeeded() -> some WidgetConfiguration { + if #available(iOSApplicationExtension 17.0, *) { + return self.contentMarginsDisabled() + } else { + return self + } + } +} + struct Daily_Widget: Widget { let kind: String = "Daily_Widget" @@ -192,16 +205,17 @@ struct Daily_Widget: Widget { .containerBackground(.fill.tertiary, for: .widget) } else { Daily_WidgetEntryView(entry: entry) - .padding() - .background() } } - .contentMarginsDisabled() + .disableContentMarginsIfNeeded() } } -#Preview(as: .systemSmall) { - Daily_Widget() -} timeline: { - SimpleEntry(date: .now, dailyInfo: nil) +struct Daily_Widget_Previews: PreviewProvider { + static var previews: some View { + Daily_WidgetEntryView( + entry: SimpleEntry(date: .now, dailyInfo: nil) + ) + .previewContext(WidgetPreviewContext(family: .systemSmall)) + } } diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index a8eb1fed8..bdd4f657b 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -2082,7 +2082,7 @@ INFOPLIST_FILE = "Daily Widget/Info.plist"; INFOPLIST_KEY_CFBundleDisplayName = "Daily Widget"; INFOPLIST_KEY_NSHumanReadableCopyright = ""; - IPHONEOS_DEPLOYMENT_TARGET = 18.0; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -2167,7 +2167,7 @@ INFOPLIST_FILE = "Daily Widget/Info.plist"; INFOPLIST_KEY_CFBundleDisplayName = "Daily Widget"; INFOPLIST_KEY_NSHumanReadableCopyright = ""; - IPHONEOS_DEPLOYMENT_TARGET = 18.0; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -2248,7 +2248,7 @@ INFOPLIST_FILE = "Daily Widget/Info.plist"; INFOPLIST_KEY_CFBundleDisplayName = "Daily Widget"; INFOPLIST_KEY_NSHumanReadableCopyright = ""; - IPHONEOS_DEPLOYMENT_TARGET = 18.0; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -2330,7 +2330,7 @@ INFOPLIST_FILE = "Daily Widget/Info.plist"; INFOPLIST_KEY_CFBundleDisplayName = "Daily Widget"; INFOPLIST_KEY_NSHumanReadableCopyright = ""; - IPHONEOS_DEPLOYMENT_TARGET = 18.0; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -2411,7 +2411,7 @@ INFOPLIST_FILE = "Daily Widget/Info.plist"; INFOPLIST_KEY_CFBundleDisplayName = "Daily Widget"; INFOPLIST_KEY_NSHumanReadableCopyright = ""; - IPHONEOS_DEPLOYMENT_TARGET = 18.0; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", diff --git a/ios/Runner.xcodeproj/xcshareddata/xcschemes/Daily Widget InhouseExtension.xcscheme b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Daily Widget InhouseExtension.xcscheme index eddd26333..c26f48279 100644 --- a/ios/Runner.xcodeproj/xcshareddata/xcschemes/Daily Widget InhouseExtension.xcscheme +++ b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Daily Widget InhouseExtension.xcscheme @@ -16,7 +16,7 @@ buildForAnalyzing = "YES"> diff --git a/ios/Runner/AppDelegate.swift b/ios/Runner/AppDelegate.swift index d013727c1..947edbe36 100644 --- a/ios/Runner/AppDelegate.swift +++ b/ios/Runner/AppDelegate.swift @@ -267,7 +267,8 @@ import workmanager WorkmanagerPlugin.setPluginRegistrantCallback { registry in GeneratedPluginRegistrant.register(with: registry) } - WorkmanagerPlugin.registerPeriodicTask(withIdentifier: "feralfile.workmanager.iOSBackgroundAppRefresh", frequency: NSNumber(value: 15 * 60)) + // Register a periodic task with 4 hours frequency. The frequency is in seconds. + WorkmanagerPlugin.registerPeriodicTask(withIdentifier: "feralfile.workmanager.iOSBackgroundAppRefresh", frequency: NSNumber(value: 4 * 60 * 60)) return super.application(application, didFinishLaunchingWithOptions: launchOptions) }