diff --git a/JustOneThing.xcodeproj/project.pbxproj b/JustOneThing.xcodeproj/project.pbxproj index 078b9b7..27272db 100644 --- a/JustOneThing.xcodeproj/project.pbxproj +++ b/JustOneThing.xcodeproj/project.pbxproj @@ -10,7 +10,7 @@ 5407E5022A2A8AE200EF00B8 /* JustOneThingApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5483903A2A2A773900BF5624 /* JustOneThingApp.swift */; }; 5407E5032A2A8AE700EF00B8 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5483903C2A2A773900BF5624 /* ContentView.swift */; }; 5407E5042A2A8AEA00EF00B8 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 5483903E2A2A773A00BF5624 /* Assets.xcassets */; }; - 5431ED7A2A2A77CA00515680 /* JustOneThingWatch Watch App.app in Embed Watch Content */ = {isa = PBXBuildFile; fileRef = 5431ED6D2A2A77C900515680 /* JustOneThingWatch Watch App.app */; platformFilter = ios; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; + 5431ED7A2A2A77CA00515680 /* JustOneThingWatch.app in Embed Watch Content */ = {isa = PBXBuildFile; fileRef = 5431ED6D2A2A77C900515680 /* JustOneThingWatch.app */; platformFilter = ios; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; 5472018C2A36563A005B2FCC /* WidgetAssets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 54928C372A35F8B800095445 /* WidgetAssets.xcassets */; }; 5472018E2A36563B005B2FCC /* Widget.intentdefinition in Sources */ = {isa = PBXBuildFile; fileRef = 54928C1C2A35F89900095445 /* Widget.intentdefinition */; }; 547201902A36563C005B2FCC /* Widget.intentdefinition in Sources */ = {isa = PBXBuildFile; fileRef = 54928C1C2A35F89900095445 /* Widget.intentdefinition */; }; @@ -34,6 +34,9 @@ 54928C482A35F8CB00095445 /* SwiftUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 54928C172A35F89900095445 /* SwiftUI.framework */; }; 54928C4B2A35F8CB00095445 /* JustOneThingWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 54928C4A2A35F8CB00095445 /* JustOneThingWidget.swift */; }; 54928C542A35F8CC00095445 /* WatchWidgetExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 54928C462A35F8CB00095445 /* WatchWidgetExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; + 5493A81B2A471E37001EBA08 /* JustOneThingProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5493A81A2A471E36001EBA08 /* JustOneThingProvider.swift */; }; + 5493A81C2A471E37001EBA08 /* JustOneThingProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5493A81A2A471E36001EBA08 /* JustOneThingProvider.swift */; }; + 5493A81D2A471E37001EBA08 /* JustOneThingProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5493A81A2A471E36001EBA08 /* JustOneThingProvider.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -74,7 +77,7 @@ dstPath = "$(CONTENTS_FOLDER_PATH)/Watch"; dstSubfolderSpec = 16; files = ( - 5431ED7A2A2A77CA00515680 /* JustOneThingWatch Watch App.app in Embed Watch Content */, + 5431ED7A2A2A77CA00515680 /* JustOneThingWatch.app in Embed Watch Content */, ); name = "Embed Watch Content"; runOnlyForDeploymentPostprocessing = 0; @@ -105,8 +108,8 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ - 5407E5062A35B96E00EF00B8 /* JustOneThingWatch Watch App.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "JustOneThingWatch Watch App.entitlements"; sourceTree = ""; }; - 5431ED6D2A2A77C900515680 /* JustOneThingWatch Watch App.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "JustOneThingWatch Watch App.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 5407E5062A35B96E00EF00B8 /* JustOneThingWatch.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = JustOneThingWatch.entitlements; sourceTree = ""; }; + 5431ED6D2A2A77C900515680 /* JustOneThingWatch.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = JustOneThingWatch.app; sourceTree = BUILT_PRODUCTS_DIR; }; 547201942A461554005B2FCC /* PhoneWidget.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = PhoneWidget.entitlements; sourceTree = ""; }; 547201952A461558005B2FCC /* WatchWidget.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = WatchWidget.entitlements; sourceTree = ""; }; 548390372A2A773900BF5624 /* JustOneThing.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = JustOneThing.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -124,6 +127,7 @@ 54928C392A35F8B800095445 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 54928C462A35F8CB00095445 /* WatchWidgetExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = WatchWidgetExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; }; 54928C4A2A35F8CB00095445 /* JustOneThingWidget.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JustOneThingWidget.swift; sourceTree = ""; }; + 5493A81A2A471E36001EBA08 /* JustOneThingProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JustOneThingProvider.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -181,21 +185,22 @@ path = AppShared; sourceTree = ""; }; - 5431ED6E2A2A77C900515680 /* JustOneThingWatch Watch App */ = { + 5431ED6E2A2A77C900515680 /* JustOneThingWatch */ = { isa = PBXGroup; children = ( - 5407E5062A35B96E00EF00B8 /* JustOneThingWatch Watch App.entitlements */, + 5407E5062A35B96E00EF00B8 /* JustOneThingWatch.entitlements */, ); - path = "JustOneThingWatch Watch App"; + path = JustOneThingWatch; sourceTree = ""; }; 5472018B2A3655E4005B2FCC /* WidgetShared */ = { isa = PBXGroup; children = ( + 54928C4A2A35F8CB00095445 /* JustOneThingWidget.swift */, + 5493A81A2A471E36001EBA08 /* JustOneThingProvider.swift */, 54928C372A35F8B800095445 /* WidgetAssets.xcassets */, 54928C392A35F8B800095445 /* Info.plist */, 54928C1C2A35F89900095445 /* Widget.intentdefinition */, - 54928C4A2A35F8CB00095445 /* JustOneThingWidget.swift */, ); path = WidgetShared; sourceTree = ""; @@ -205,7 +210,7 @@ children = ( 5407E5012A2A8A5100EF00B8 /* AppShared */, 548390392A2A773900BF5624 /* JustOneThing */, - 5431ED6E2A2A77C900515680 /* JustOneThingWatch Watch App */, + 5431ED6E2A2A77C900515680 /* JustOneThingWatch */, 5472018B2A3655E4005B2FCC /* WidgetShared */, 54928C192A35F89900095445 /* MacWidget */, 54928C312A35F8B800095445 /* PhoneWidget */, @@ -219,7 +224,7 @@ isa = PBXGroup; children = ( 548390372A2A773900BF5624 /* JustOneThing.app */, - 5431ED6D2A2A77C900515680 /* JustOneThingWatch Watch App.app */, + 5431ED6D2A2A77C900515680 /* JustOneThingWatch.app */, 54928C132A35F89900095445 /* MacWidgetExtension.appex */, 54928C2E2A35F8B800095445 /* PhoneWidgetExtension.appex */, 54928C462A35F8CB00095445 /* WatchWidgetExtension.appex */, @@ -271,9 +276,9 @@ /* End PBXGroup section */ /* Begin PBXNativeTarget section */ - 5431ED6C2A2A77C900515680 /* JustOneThingWatch Watch App */ = { + 5431ED6C2A2A77C900515680 /* JustOneThingWatch */ = { isa = PBXNativeTarget; - buildConfigurationList = 5431ED7E2A2A77CA00515680 /* Build configuration list for PBXNativeTarget "JustOneThingWatch Watch App" */; + buildConfigurationList = 5431ED7E2A2A77CA00515680 /* Build configuration list for PBXNativeTarget "JustOneThingWatch" */; buildPhases = ( 5431ED692A2A77C900515680 /* Sources */, 5431ED6A2A2A77C900515680 /* Frameworks */, @@ -285,9 +290,9 @@ dependencies = ( 54928C532A35F8CC00095445 /* PBXTargetDependency */, ); - name = "JustOneThingWatch Watch App"; + name = JustOneThingWatch; productName = "JustOneThingWatch Watch App"; - productReference = 5431ED6D2A2A77C900515680 /* JustOneThingWatch Watch App.app */; + productReference = 5431ED6D2A2A77C900515680 /* JustOneThingWatch.app */; productType = "com.apple.product-type.application"; }; 548390362A2A773900BF5624 /* JustOneThing */ = { @@ -404,7 +409,7 @@ projectRoot = ""; targets = ( 548390362A2A773900BF5624 /* JustOneThing */, - 5431ED6C2A2A77C900515680 /* JustOneThingWatch Watch App */, + 5431ED6C2A2A77C900515680 /* JustOneThingWatch */, 54928C122A35F89900095445 /* MacWidgetExtension */, 54928C2D2A35F8B800095445 /* PhoneWidgetExtension */, 54928C452A35F8CB00095445 /* WatchWidgetExtension */, @@ -481,6 +486,7 @@ buildActionMask = 2147483647; files = ( 54928C212A35F89A00095445 /* Widget.intentdefinition in Sources */, + 5493A81B2A471E37001EBA08 /* JustOneThingProvider.swift in Sources */, 547201972A461DBE005B2FCC /* JustOneThingWidget.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -490,6 +496,7 @@ buildActionMask = 2147483647; files = ( 547201962A461DBE005B2FCC /* JustOneThingWidget.swift in Sources */, + 5493A81C2A471E37001EBA08 /* JustOneThingProvider.swift in Sources */, 5472018E2A36563B005B2FCC /* Widget.intentdefinition in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -499,6 +506,7 @@ buildActionMask = 2147483647; files = ( 547201902A36563C005B2FCC /* Widget.intentdefinition in Sources */, + 5493A81D2A471E37001EBA08 /* JustOneThingProvider.swift in Sources */, 54928C4B2A35F8CB00095445 /* JustOneThingWidget.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -509,7 +517,7 @@ 5431ED792A2A77CA00515680 /* PBXTargetDependency */ = { isa = PBXTargetDependency; platformFilter = ios; - target = 5431ED6C2A2A77C900515680 /* JustOneThingWatch Watch App */; + target = 5431ED6C2A2A77C900515680 /* JustOneThingWatch */; targetProxy = 5431ED782A2A77CA00515680 /* PBXContainerItemProxy */; }; 54928C242A35F89A00095445 /* PBXTargetDependency */ = { @@ -540,7 +548,7 @@ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; - CODE_SIGN_ENTITLEMENTS = "JustOneThingWatch Watch App/JustOneThingWatch Watch App.entitlements"; + CODE_SIGN_ENTITLEMENTS = JustOneThingWatch/JustOneThingWatch.entitlements; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_ASSET_PATHS = ""; @@ -572,7 +580,7 @@ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; - CODE_SIGN_ENTITLEMENTS = "JustOneThingWatch Watch App/JustOneThingWatch Watch App.entitlements"; + CODE_SIGN_ENTITLEMENTS = JustOneThingWatch/JustOneThingWatch.entitlements; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_ASSET_PATHS = ""; @@ -977,7 +985,7 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ - 5431ED7E2A2A77CA00515680 /* Build configuration list for PBXNativeTarget "JustOneThingWatch Watch App" */ = { + 5431ED7E2A2A77CA00515680 /* Build configuration list for PBXNativeTarget "JustOneThingWatch" */ = { isa = XCConfigurationList; buildConfigurations = ( 5431ED7C2A2A77CA00515680 /* Debug */, diff --git a/JustOneThing.xcodeproj/xcshareddata/xcschemes/JustOneThingWatch Watch App.xcscheme b/JustOneThing.xcodeproj/xcshareddata/xcschemes/JustOneThingWatch.xcscheme similarity index 89% rename from JustOneThing.xcodeproj/xcshareddata/xcschemes/JustOneThingWatch Watch App.xcscheme rename to JustOneThing.xcodeproj/xcshareddata/xcschemes/JustOneThingWatch.xcscheme index 960b8fb..75e1570 100644 --- a/JustOneThing.xcodeproj/xcshareddata/xcschemes/JustOneThingWatch Watch App.xcscheme +++ b/JustOneThing.xcodeproj/xcshareddata/xcschemes/JustOneThingWatch.xcscheme @@ -15,8 +15,8 @@ @@ -58,8 +58,8 @@ @@ -75,8 +75,8 @@ diff --git a/JustOneThing.xcodeproj/xcshareddata/xcschemes/WatchWidgetExtension.xcscheme b/JustOneThing.xcodeproj/xcshareddata/xcschemes/WatchWidgetExtension.xcscheme index 233e43a..bb90ac6 100644 --- a/JustOneThing.xcodeproj/xcshareddata/xcschemes/WatchWidgetExtension.xcscheme +++ b/JustOneThing.xcodeproj/xcshareddata/xcschemes/WatchWidgetExtension.xcscheme @@ -43,8 +43,8 @@ @@ -71,6 +71,15 @@ launchAutomaticallySubstyle = "2"> + + + + - + orderHint 4 - JustOneThingWatch Watch App.xcscheme_^#shared#^_ + JustOneThingWatch.xcscheme_^#shared#^_ orderHint 0 diff --git a/JustOneThingWatch Watch App/JustOneThingWatch Watch App.entitlements b/JustOneThingWatch/JustOneThingWatch.entitlements similarity index 100% rename from JustOneThingWatch Watch App/JustOneThingWatch Watch App.entitlements rename to JustOneThingWatch/JustOneThingWatch.entitlements diff --git a/WidgetShared/JustOneThingProvider.swift b/WidgetShared/JustOneThingProvider.swift new file mode 100644 index 0000000..4f983d5 --- /dev/null +++ b/WidgetShared/JustOneThingProvider.swift @@ -0,0 +1,47 @@ +// +// JustOneThingProvider.swift +// JustOneThing +// +// Created by Alan Francis on 24/06/2023. +// + +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) + } + + func recommendations() -> [IntentRecommendation] { + return [ + IntentRecommendation(intent: ConfigurationIntent(), description: "My Intent Widget") + ] + } +} + +struct SimpleEntry: TimelineEntry { + let date: Date + let configuration: ConfigurationIntent +} diff --git a/WidgetShared/JustOneThingWidget.swift b/WidgetShared/JustOneThingWidget.swift index ccf8e51..f12f807 100644 --- a/WidgetShared/JustOneThingWidget.swift +++ b/WidgetShared/JustOneThingWidget.swift @@ -16,42 +16,6 @@ struct JustOneThingWidgetBundle: WidgetBundle { } } -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) - } - - func recommendations() -> [IntentRecommendation] { - return [ - IntentRecommendation(intent: ConfigurationIntent(), description: "My Intent Widget") - ] - } -} - -struct SimpleEntry: TimelineEntry { - let date: Date - let configuration: ConfigurationIntent -} struct JustOneThingWidgetEntryView : View { var entry: Provider.Entry @@ -72,3 +36,15 @@ struct JustOneThingWidget: Widget { .description("This is an example widget.") } } + +struct Widget_Previews: PreviewProvider { + static var previews: some View { + JustOneThingWidgetEntryView(entry: SimpleEntry(date: Date(), configuration: ConfigurationIntent())) + #if os(watchOS) + .previewContext(WidgetPreviewContext(family: .accessoryRectangular)) + #else + .previewContext(WidgetPreviewContext(family: .systemMedium)) + #endif + + } +}