diff --git a/LaunchWidget/LaunchWidget.intentdefinition b/LaunchWidget/LaunchWidget.intentdefinition
index bdb4045..239e495 100644
--- a/LaunchWidget/LaunchWidget.intentdefinition
+++ b/LaunchWidget/LaunchWidget.intentdefinition
@@ -9,24 +9,90 @@
INIntentDefinitionNamespace
88xZPY
INIntentDefinitionSystemVersion
- 20A294
+ 22A400
INIntentDefinitionToolsBuildVersion
- 12A6144
+ 14C18
INIntentDefinitionToolsVersion
- 12.0
+ 14.2
INIntents
INIntentCategory
- information
+ start
INIntentDescriptionID
- tVvJ9c
+ dIYBJB
INIntentEligibleForWidgets
INIntentIneligibleForSuggestions
+ INIntentLastParameterTag
+ 2
INIntentName
- Configuration
+ SelectCountdown
+ INIntentParameters
+
+
+ INIntentParameterConfigurable
+
+ INIntentParameterCustomDisambiguation
+
+ INIntentParameterDisplayName
+ Countdown
+ INIntentParameterDisplayNameID
+ lE8mOk
+ INIntentParameterDisplayPriority
+ 1
+ INIntentParameterName
+ countdown
+ INIntentParameterObjectType
+ Countdown
+ INIntentParameterObjectTypeNamespace
+ 88xZPY
+ INIntentParameterPromptDialogs
+
+
+ INIntentParameterPromptDialogCustom
+
+ INIntentParameterPromptDialogType
+ Configuration
+
+
+ INIntentParameterPromptDialogCustom
+
+ INIntentParameterPromptDialogType
+ Primary
+
+
+ INIntentParameterPromptDialogCustom
+
+ INIntentParameterPromptDialogFormatString
+ There are ${count} options matching ‘${countdown}’.
+ INIntentParameterPromptDialogFormatStringID
+ gtJyOP
+ INIntentParameterPromptDialogType
+ DisambiguationIntroduction
+
+
+ INIntentParameterPromptDialogCustom
+
+ INIntentParameterPromptDialogFormatString
+ Just to confirm, you wanted ‘${countdown}’?
+ INIntentParameterPromptDialogFormatStringID
+ nntWsg
+ INIntentParameterPromptDialogType
+ Confirmation
+
+
+ INIntentParameterSupportsDynamicEnumeration
+
+ INIntentParameterSupportsResolution
+
+ INIntentParameterTag
+ 2
+ INIntentParameterType
+ Object
+
+
INIntentResponse
INIntentResponseCodes
@@ -44,16 +110,108 @@
INIntentTitle
- Configuration
+ Select Countdown
INIntentTitleID
- gpCwrM
+ Dm6sPw
INIntentType
Custom
INIntentVerb
- View
+ Start
INTypes
-
+
+
+ INTypeDisplayName
+ Countdown
+ INTypeDisplayNameID
+ ZTfW1g
+ INTypeLastPropertyTag
+ 102
+ INTypeName
+ Countdown
+ INTypeProperties
+
+
+ INTypePropertyDefault
+
+ INTypePropertyDisplayPriority
+ 1
+ INTypePropertyName
+ identifier
+ INTypePropertyTag
+ 1
+ INTypePropertyType
+ String
+
+
+ INTypePropertyDefault
+
+ INTypePropertyDisplayPriority
+ 2
+ INTypePropertyName
+ displayString
+ INTypePropertyTag
+ 2
+ INTypePropertyType
+ String
+
+
+ INTypePropertyDefault
+
+ INTypePropertyDisplayPriority
+ 3
+ INTypePropertyName
+ pronunciationHint
+ INTypePropertyTag
+ 3
+ INTypePropertyType
+ String
+
+
+ INTypePropertyDefault
+
+ INTypePropertyDisplayPriority
+ 4
+ INTypePropertyName
+ alternativeSpeakableMatches
+ INTypePropertySupportsMultipleValues
+
+ INTypePropertyTag
+ 4
+ INTypePropertyType
+ SpeakableString
+
+
+ INTypePropertyDisplayName
+ Name
+ INTypePropertyDisplayNameID
+ 1g3sqi
+ INTypePropertyDisplayPriority
+ 5
+ INTypePropertyName
+ name
+ INTypePropertyTag
+ 100
+ INTypePropertyType
+ String
+
+
+ INTypePropertyDisplayName
+ Duration
+ INTypePropertyDisplayNameID
+ NjMwkO
+ INTypePropertyDisplayPriority
+ 6
+ INTypePropertyName
+ duration
+ INTypePropertyTag
+ 102
+ INTypePropertyType
+ Decimal
+
+
+
+
diff --git a/LaunchWidget/LaunchWidget.swift b/LaunchWidget/LaunchWidget.swift
index fab3040..3369c88 100644
--- a/LaunchWidget/LaunchWidget.swift
+++ b/LaunchWidget/LaunchWidget.swift
@@ -11,11 +11,11 @@ import Intents
struct Provider: IntentTimelineProvider {
func placeholder(in context: Context) -> SimpleEntry {
- SimpleEntry(date: Date(), configuration: ConfigurationIntent())
+ SimpleEntry(id: "", name: "Tea", duration: 4 * 60.0, date: Date(), configuration: ConfigurationIntent())
}
func getSnapshot(for configuration: ConfigurationIntent, in context: Context, completion: @escaping (SimpleEntry) -> ()) {
- let entry = SimpleEntry(date: Date(), configuration: configuration)
+ let entry = SimpleEntry(id: "", name: "Tea", duration: 4 * 60.0, date: Date(), configuration: configuration)
completion(entry)
}
@@ -26,7 +26,7 @@ struct Provider: IntentTimelineProvider {
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)
+ let entry = SimpleEntry(id: "", name: "Tea", duration: 4 * 60.0, date: entryDate, configuration: configuration)
entries.append(entry)
}
@@ -36,33 +36,67 @@ struct Provider: IntentTimelineProvider {
}
struct SimpleEntry: TimelineEntry {
+ let id: String
+ let name: String?
+ let duration: Double
+
let date: Date
let configuration: ConfigurationIntent
}
+struct CountdownWidgetView: View {
+
+ let id: String
+ let name: String?
+ let duration: Double
+
+ var body: some View {
+ CountdownView(name: name, duration: duration).widgetURL(URL(string: id))
+ }
+
+}
+
struct LaunchWidgetEntryView : View {
+
+ @Environment(\.widgetFamily) var family: WidgetFamily
+
var entry: Provider.Entry
+ @ViewBuilder
var body: some View {
- Text(entry.date, style: .time)
+ switch family {
+ case .systemSmall: CountdownWidgetView(id: entry.id, name: entry.name, duration: entry.duration)
+// case .systemMedium: GameStatusWithLastTurnResult(gameStatus)
+// case .systemLarge: GameStatusWithStatistics(gameStatus)
+// case .systemExtraLarge: GameStatusWithStatisticsExtraLarge(gameStatus)
+// case .accessoryCircular: HealthLevelCircular(selectedCharacter)
+// case .accessoryRectangular: HealthLevelRectangular(selectedCharacter)
+// case .accessoryInline: HealthLevelInline(selectedCharacter)
+ default: CountdownWidgetView(id: entry.id, name: entry.name, duration: entry.duration)
+ }
}
+
+
}
struct LaunchWidget: Widget {
- let kind: String = "LaunchWidget"
+ let kind: String = "com.staxriver.launch-widget"
var body: some WidgetConfiguration {
- IntentConfiguration(kind: kind, intent: ConfigurationIntent.self, provider: Provider()) { entry in
+ IntentConfiguration(kind: kind,
+ intent: ConfigurationIntent.self,
+ provider: Provider()) { entry in
LaunchWidgetEntryView(entry: entry)
}
- .configurationDisplayName("My Widget")
- .description("This is an example widget.")
+ .configurationDisplayName("Launch Widget")
+ .description("Select and launch your countdowns")
+ .supportedFamilies([.systemSmall, .accessoryCircular])
}
}
struct LaunchWidget_Previews: PreviewProvider {
static var previews: some View {
- LaunchWidgetEntryView(entry: SimpleEntry(date: Date(), configuration: ConfigurationIntent()))
+ LaunchWidgetEntryView(entry: SimpleEntry(id: "", name: "Tea", duration: 3 * 60.0, date: Date(), configuration: ConfigurationIntent()))
.previewContext(WidgetPreviewContext(family: .systemSmall))
}
}
diff --git a/LeCountdown.xcodeproj/project.pbxproj b/LeCountdown.xcodeproj/project.pbxproj
index 578700d..2b6f338 100644
--- a/LeCountdown.xcodeproj/project.pbxproj
+++ b/LeCountdown.xcodeproj/project.pbxproj
@@ -30,6 +30,9 @@
C438C7DF2981216300BF3EF9 /* LaunchWidget.intentdefinition in Sources */ = {isa = PBXBuildFile; fileRef = C438C7DB2981216200BF3EF9 /* LaunchWidget.intentdefinition */; };
C438C7E02981216300BF3EF9 /* LaunchWidget.intentdefinition in Sources */ = {isa = PBXBuildFile; fileRef = C438C7DB2981216200BF3EF9 /* LaunchWidget.intentdefinition */; };
C438C7E32981216300BF3EF9 /* LaunchWidgetExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = C438C7CE2981216200BF3EF9 /* LaunchWidgetExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
+ C438C7E82981255D00BF3EF9 /* TimeInterval+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4060DF4297AE9A7003FAB80 /* TimeInterval+Extensions.swift */; };
+ C438C7EA2981260D00BF3EF9 /* CountdownView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C438C7E92981260D00BF3EF9 /* CountdownView.swift */; };
+ C438C7EB2981266F00BF3EF9 /* CountdownView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C438C7E92981260D00BF3EF9 /* CountdownView.swift */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -98,6 +101,7 @@
C438C7DB2981216200BF3EF9 /* LaunchWidget.intentdefinition */ = {isa = PBXFileReference; lastKnownFileType = file.intentdefinition; path = LaunchWidget.intentdefinition; sourceTree = ""; };
C438C7DC2981216300BF3EF9 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
C438C7DE2981216300BF3EF9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
+ C438C7E92981260D00BF3EF9 /* CountdownView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CountdownView.swift; sourceTree = ""; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -162,6 +166,7 @@
children = (
C4060DBF297AE73B003FAB80 /* LeCountdownApp.swift */,
C4060DC1297AE73B003FAB80 /* ContentView.swift */,
+ C438C7E92981260D00BF3EF9 /* CountdownView.swift */,
C4060DF6297AFEF2003FAB80 /* NewCountdownView.swift */,
C438C7C02980228B00BF3EF9 /* CountdownScheduler.swift */,
C4060DC3297AE73D003FAB80 /* Assets.xcassets */,
@@ -384,6 +389,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
+ C438C7EA2981260D00BF3EF9 /* CountdownView.swift in Sources */,
C4060DC9297AE73D003FAB80 /* Persistence.swift in Sources */,
C4060DC2297AE73B003FAB80 /* ContentView.swift in Sources */,
C438C7C12980228B00BF3EF9 /* CountdownScheduler.swift in Sources */,
@@ -418,8 +424,10 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
+ C438C7EB2981266F00BF3EF9 /* CountdownView.swift in Sources */,
C438C7D62981216200BF3EF9 /* LaunchWidgetBundle.swift in Sources */,
C438C7DF2981216300BF3EF9 /* LaunchWidget.intentdefinition in Sources */,
+ C438C7E82981255D00BF3EF9 /* TimeInterval+Extensions.swift in Sources */,
C438C7D82981216200BF3EF9 /* LaunchWidgetLiveActivity.swift in Sources */,
C438C7DA2981216200BF3EF9 /* LaunchWidget.swift in Sources */,
);
@@ -572,6 +580,7 @@
DEVELOPMENT_TEAM = 526E96RFNP;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
+ INFOPLIST_FILE = LeCountdown/Info.plist;
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
@@ -602,6 +611,7 @@
DEVELOPMENT_TEAM = 526E96RFNP;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
+ INFOPLIST_FILE = LeCountdown/Info.plist;
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
diff --git a/LeCountdown/ContentView.swift b/LeCountdown/ContentView.swift
index 68b4b05..19a4393 100644
--- a/LeCountdown/ContentView.swift
+++ b/LeCountdown/ContentView.swift
@@ -43,11 +43,7 @@ struct ContentView: View {
Button {
self._launchCountdown(countdown)
} label: {
- VStack {
- Text(countdown.name ?? "")
- Text(countdown.duration.minuteSecond)
- }
- .font(.title2)
+ CountdownView(name: countdown.name, duration: countdown.duration)
.aspectRatio(contentMode: .fill)
.frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity)
.aspectRatio(1, contentMode: .fit)
diff --git a/LeCountdown/CountdownView.swift b/LeCountdown/CountdownView.swift
new file mode 100644
index 0000000..396219f
--- /dev/null
+++ b/LeCountdown/CountdownView.swift
@@ -0,0 +1,29 @@
+//
+// CountdownView.swift
+// LeCountdown
+//
+// Created by Laurent Morvillier on 25/01/2023.
+//
+
+import SwiftUI
+
+struct CountdownView: View {
+
+ var name: String?
+ var duration: Double
+
+ var body: some View {
+ VStack {
+ Text(name ?? "")
+ Text(duration.minuteSecond)
+ }
+ .font(.title2)
+ }
+
+}
+
+struct CountdownView_Previews: PreviewProvider {
+ static var previews: some View {
+ CountdownView(name: "Tea", duration: 3 * 60.0)
+ }
+}
diff --git a/LeCountdown/Info.plist b/LeCountdown/Info.plist
index ca9a074..0352adb 100644
--- a/LeCountdown/Info.plist
+++ b/LeCountdown/Info.plist
@@ -2,9 +2,9 @@
- UIBackgroundModes
+ NSUserActivityTypes
- remote-notification
+ SelectCountdownIntent