From 038107cd802a284e5f2e6866ad73ff43357b8428 Mon Sep 17 00:00:00 2001 From: Laurent Date: Thu, 26 Jan 2023 17:57:02 +0100 Subject: [PATCH] Configure larger widgets --- LaunchWidget/CountdownView.swift | 15 ++- LaunchWidget/LaunchWidget.swift | 2 +- .../xcschemes/LaunchIntents.xcscheme | 97 +++++++++++++++ .../xcschemes/LaunchWidgetExtension.xcscheme | 114 ++++++++++++++++++ .../xcschemes/LeCountdown.xcscheme | 78 ++++++++++++ LeCountdown/CountdownScheduler.swift | 2 - LeCountdown/Model/Model+Extensions.swift | 8 +- LeCountdown/Views/ContentView.swift | 3 + 8 files changed, 308 insertions(+), 11 deletions(-) create mode 100644 LeCountdown.xcodeproj/xcshareddata/xcschemes/LaunchIntents.xcscheme create mode 100644 LeCountdown.xcodeproj/xcshareddata/xcschemes/LaunchWidgetExtension.xcscheme create mode 100644 LeCountdown.xcodeproj/xcshareddata/xcschemes/LeCountdown.xcscheme diff --git a/LaunchWidget/CountdownView.swift b/LaunchWidget/CountdownView.swift index 0b186f9..abaa0dd 100644 --- a/LaunchWidget/CountdownView.swift +++ b/LaunchWidget/CountdownView.swift @@ -44,13 +44,16 @@ struct CountdownMultiView: View { HStack { ForEach(countdowns) { countdown in - VStack { - Text(countdown.name ?? "") - Text(countdown.duration.minuteSecond) + + Link(destination: countdown.url) { + VStack { + Text(countdown.name ?? "") + Text(countdown.duration.minuteSecond) + } + .font(self.font) + .frame(maxWidth: .infinity, maxHeight: .infinity) } - .font(self.font) - .widgetURL(countdown.url) - .frame(maxWidth: .infinity, maxHeight: .infinity) + } }.frame(maxWidth: .infinity) diff --git a/LaunchWidget/LaunchWidget.swift b/LaunchWidget/LaunchWidget.swift index 9a741bc..60e6c6a 100644 --- a/LaunchWidget/LaunchWidget.swift +++ b/LaunchWidget/LaunchWidget.swift @@ -127,7 +127,7 @@ struct LaunchWidget: Widget { } .configurationDisplayName("Launch Widget") .description("Select and launch your countdowns") - .supportedFamilies([.systemSmall, .accessoryCircular]) + .supportedFamilies([.systemSmall, .systemMedium, .systemLarge, .accessoryRectangular]) } } diff --git a/LeCountdown.xcodeproj/xcshareddata/xcschemes/LaunchIntents.xcscheme b/LeCountdown.xcodeproj/xcshareddata/xcschemes/LaunchIntents.xcscheme new file mode 100644 index 0000000..32b3768 --- /dev/null +++ b/LeCountdown.xcodeproj/xcshareddata/xcschemes/LaunchIntents.xcscheme @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/LeCountdown.xcodeproj/xcshareddata/xcschemes/LaunchWidgetExtension.xcscheme b/LeCountdown.xcodeproj/xcshareddata/xcschemes/LaunchWidgetExtension.xcscheme new file mode 100644 index 0000000..4bfbcec --- /dev/null +++ b/LeCountdown.xcodeproj/xcshareddata/xcschemes/LaunchWidgetExtension.xcscheme @@ -0,0 +1,114 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/LeCountdown.xcodeproj/xcshareddata/xcschemes/LeCountdown.xcscheme b/LeCountdown.xcodeproj/xcshareddata/xcschemes/LeCountdown.xcscheme new file mode 100644 index 0000000..c47ab63 --- /dev/null +++ b/LeCountdown.xcodeproj/xcshareddata/xcschemes/LeCountdown.xcscheme @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/LeCountdown/CountdownScheduler.swift b/LeCountdown/CountdownScheduler.swift index 071b43b..c525d8d 100644 --- a/LeCountdown/CountdownScheduler.swift +++ b/LeCountdown/CountdownScheduler.swift @@ -56,8 +56,6 @@ class CountdownScheduler { } } - print("SCHEDULED @ \(Date())") - } } diff --git a/LeCountdown/Model/Model+Extensions.swift b/LeCountdown/Model/Model+Extensions.swift index fdcf783..4b22693 100644 --- a/LeCountdown/Model/Model+Extensions.swift +++ b/LeCountdown/Model/Model+Extensions.swift @@ -15,8 +15,12 @@ extension Countdown { return self.activity?.name } - var url: URL? { - return URL(string: self.stringId) + var url: URL { + if let url = URL(string: self.stringId) { + return url + } else { + return URL(fileURLWithPath: self.stringId) // stupid fallthrough + } } static func fake(context: NSManagedObjectContext) -> Countdown { diff --git a/LeCountdown/Views/ContentView.swift b/LeCountdown/Views/ContentView.swift index 7e8b16a..36af678 100644 --- a/LeCountdown/Views/ContentView.swift +++ b/LeCountdown/Views/ContentView.swift @@ -140,6 +140,9 @@ struct ContentView: View { let urlString = url.absoluteString if let countdown = viewContext.object(stringId: urlString) as? Countdown { + + print("Start countdown: \(countdown.name ?? ""), \(countdown.duration)") + self._launchCountdown(countdown) } else { print("countdown not found with id = \(urlString)")