diff --git a/TMT/TMT.xcodeproj/project.pbxproj b/TMT/TMT.xcodeproj/project.pbxproj index 42308b2..7dcdac0 100644 --- a/TMT/TMT.xcodeproj/project.pbxproj +++ b/TMT/TMT.xcodeproj/project.pbxproj @@ -17,8 +17,42 @@ D8D377E92CBE95C30043D103 /* BusSearchModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8D377E82CBE95C30043D103 /* BusSearchModel.swift */; }; D8D377EB2CBE95CA0043D103 /* BusSearchViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8D377EA2CBE95CA0043D103 /* BusSearchViewModel.swift */; }; D8D377ED2CBE95D10043D103 /* BusSearchView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8D377EC2CBE95D10043D103 /* BusSearchView.swift */; }; + D8D377E62CBE549F0043D103 /* BusStopData.csv in Resources */ = {isa = PBXBuildFile; fileRef = D8D377E52CBE549F0043D103 /* BusStopData.csv */; }; + D8D3781F2CBEE7710043D103 /* WidgetKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D8D3781E2CBEE7710043D103 /* WidgetKit.framework */; }; + D8D378212CBEE7710043D103 /* SwiftUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D8D378202CBEE7710043D103 /* SwiftUI.framework */; }; + D8D378242CBEE7710043D103 /* TMTWidgetBundle.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8D378232CBEE7710043D103 /* TMTWidgetBundle.swift */; }; + D8D378262CBEE7710043D103 /* TMTWidgetLiveActivity.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8D378252CBEE7710043D103 /* TMTWidgetLiveActivity.swift */; }; + D8D378282CBEE7710043D103 /* TMTWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8D378272CBEE7710043D103 /* TMTWidget.swift */; }; + D8D3782A2CBEE7710043D103 /* AppIntent.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8D378292CBEE7710043D103 /* AppIntent.swift */; }; + D8D3782C2CBEE7720043D103 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D8D3782B2CBEE7720043D103 /* Assets.xcassets */; }; + D8D378302CBEE7720043D103 /* TMTWidgetExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = D8D3781C2CBEE7710043D103 /* TMTWidgetExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; + D8D378352CBEE81C0043D103 /* TMTWidgetLiveActivity.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8D378252CBEE7710043D103 /* TMTWidgetLiveActivity.swift */; }; /* End PBXBuildFile section */ +/* Begin PBXContainerItemProxy section */ + D8D3782E2CBEE7720043D103 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = D86739612CA933CD00FFE8ED /* Project object */; + proxyType = 1; + remoteGlobalIDString = D8D3781B2CBEE7710043D103; + remoteInfo = TMTWidgetExtension; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + D8D378312CBEE7720043D103 /* Embed Foundation Extensions */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 13; + files = ( + D8D378302CBEE7720043D103 /* TMTWidgetExtension.appex in Embed Foundation Extensions */, + ); + name = "Embed Foundation Extensions"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + /* Begin PBXFileReference section */ D844BCB42CC0AE770059E31F /* BusStopData.csv */ = {isa = PBXFileReference; lastKnownFileType = text; path = BusStopData.csv; sourceTree = ""; }; 5B6DA5B72CBE551400613ACB /* MapView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapView.swift; sourceTree = ""; }; @@ -31,6 +65,16 @@ D8D377E82CBE95C30043D103 /* BusSearchModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BusSearchModel.swift; sourceTree = ""; }; D8D377EA2CBE95CA0043D103 /* BusSearchViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BusSearchViewModel.swift; sourceTree = ""; }; D8D377EC2CBE95D10043D103 /* BusSearchView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BusSearchView.swift; sourceTree = ""; }; + D8D377E52CBE549F0043D103 /* BusStopData.csv */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = BusStopData.csv; sourceTree = ""; }; + D8D3781C2CBEE7710043D103 /* TMTWidgetExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = TMTWidgetExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; }; + D8D3781E2CBEE7710043D103 /* WidgetKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WidgetKit.framework; path = System/Library/Frameworks/WidgetKit.framework; sourceTree = SDKROOT; }; + D8D378202CBEE7710043D103 /* SwiftUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftUI.framework; path = System/Library/Frameworks/SwiftUI.framework; sourceTree = SDKROOT; }; + D8D378232CBEE7710043D103 /* TMTWidgetBundle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TMTWidgetBundle.swift; sourceTree = ""; }; + D8D378252CBEE7710043D103 /* TMTWidgetLiveActivity.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TMTWidgetLiveActivity.swift; sourceTree = ""; }; + D8D378272CBEE7710043D103 /* TMTWidget.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TMTWidget.swift; sourceTree = ""; }; + D8D378292CBEE7710043D103 /* AppIntent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppIntent.swift; sourceTree = ""; }; + D8D3782B2CBEE7720043D103 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + D8D3782D2CBEE7720043D103 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -41,6 +85,15 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + D8D378192CBEE7710043D103 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + D8D378212CBEE7710043D103 /* SwiftUI.framework in Frameworks */, + D8D3781F2CBEE7710043D103 /* WidgetKit.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ @@ -48,6 +101,8 @@ isa = PBXGroup; children = ( D867396B2CA933CD00FFE8ED /* TMT */, + D8D378222CBEE7710043D103 /* TMTWidget */, + D8D3781D2CBEE7710043D103 /* Frameworks */, D867396A2CA933CD00FFE8ED /* Products */, ); sourceTree = ""; @@ -56,6 +111,7 @@ isa = PBXGroup; children = ( D86739692CA933CD00FFE8ED /* TMT.app */, + D8D3781C2CBEE7710043D103 /* TMTWidgetExtension.appex */, ); name = Products; sourceTree = ""; @@ -99,6 +155,26 @@ D8D377EC2CBE95D10043D103 /* BusSearchView.swift */, ); path = BusSearch; + D8D3781D2CBEE7710043D103 /* Frameworks */ = { + isa = PBXGroup; + children = ( + D8D3781E2CBEE7710043D103 /* WidgetKit.framework */, + D8D378202CBEE7710043D103 /* SwiftUI.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + D8D378222CBEE7710043D103 /* TMTWidget */ = { + isa = PBXGroup; + children = ( + D8D378232CBEE7710043D103 /* TMTWidgetBundle.swift */, + D8D378252CBEE7710043D103 /* TMTWidgetLiveActivity.swift */, + D8D378272CBEE7710043D103 /* TMTWidget.swift */, + D8D378292CBEE7710043D103 /* AppIntent.swift */, + D8D3782B2CBEE7720043D103 /* Assets.xcassets */, + D8D3782D2CBEE7720043D103 /* Info.plist */, + ); + path = TMTWidget; sourceTree = ""; }; /* End PBXGroup section */ @@ -111,16 +187,35 @@ D86739652CA933CD00FFE8ED /* Sources */, D86739662CA933CD00FFE8ED /* Frameworks */, D86739672CA933CD00FFE8ED /* Resources */, + D8D378312CBEE7720043D103 /* Embed Foundation Extensions */, ); buildRules = ( ); dependencies = ( + D8D3782F2CBEE7720043D103 /* PBXTargetDependency */, ); name = TMT; productName = TMT; productReference = D86739692CA933CD00FFE8ED /* TMT.app */; productType = "com.apple.product-type.application"; }; + D8D3781B2CBEE7710043D103 /* TMTWidgetExtension */ = { + isa = PBXNativeTarget; + buildConfigurationList = D8D378342CBEE7720043D103 /* Build configuration list for PBXNativeTarget "TMTWidgetExtension" */; + buildPhases = ( + D8D378182CBEE7710043D103 /* Sources */, + D8D378192CBEE7710043D103 /* Frameworks */, + D8D3781A2CBEE7710043D103 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = TMTWidgetExtension; + productName = TMTWidgetExtension; + productReference = D8D3781C2CBEE7710043D103 /* TMTWidgetExtension.appex */; + productType = "com.apple.product-type.app-extension"; + }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ @@ -134,6 +229,9 @@ D86739682CA933CD00FFE8ED = { CreatedOnToolsVersion = 15.4; }; + D8D3781B2CBEE7710043D103 = { + CreatedOnToolsVersion = 15.4; + }; }; }; buildConfigurationList = D86739642CA933CD00FFE8ED /* Build configuration list for PBXProject "TMT" */; @@ -150,6 +248,7 @@ projectRoot = ""; targets = ( D86739682CA933CD00FFE8ED /* TMT */, + D8D3781B2CBEE7710043D103 /* TMTWidgetExtension */, ); }; /* End PBXProject section */ @@ -165,6 +264,14 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + D8D3781A2CBEE7710043D103 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + D8D3782C2CBEE7720043D103 /* Assets.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -179,11 +286,31 @@ D867396D2CA933CD00FFE8ED /* TMTApp.swift in Sources */, D8D377EB2CBE95CA0043D103 /* BusSearchViewModel.swift in Sources */, D8D377ED2CBE95D10043D103 /* BusSearchView.swift in Sources */, + D8D378352CBEE81C0043D103 /* TMTWidgetLiveActivity.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + D8D378182CBEE7710043D103 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + D8D378282CBEE7710043D103 /* TMTWidget.swift in Sources */, + D8D3782A2CBEE7710043D103 /* AppIntent.swift in Sources */, + D8D378262CBEE7710043D103 /* TMTWidgetLiveActivity.swift in Sources */, + D8D378242CBEE7710043D103 /* TMTWidgetBundle.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ +/* Begin PBXTargetDependency section */ + D8D3782F2CBEE7720043D103 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = D8D3781B2CBEE7710043D103 /* TMTWidgetExtension */; + targetProxy = D8D3782E2CBEE7720043D103 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + /* Begin XCBuildConfiguration section */ D86739752CA933CE00FFE8ED /* Debug */ = { isa = XCBuildConfiguration; @@ -307,6 +434,7 @@ D86739782CA933CE00FFE8ED /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_IDENTITY = "Apple Development"; @@ -317,6 +445,7 @@ ENABLE_PREVIEWS = YES; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_KEY_NSLocationWhenInUseUsageDescription = "We want your location haha"; + INFOPLIST_KEY_NSSupportsLiveActivities = YES; INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchScreen_Generation = YES; @@ -339,6 +468,7 @@ D86739792CA933CE00FFE8ED /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_IDENTITY = "Apple Development"; @@ -349,6 +479,7 @@ ENABLE_PREVIEWS = YES; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_KEY_NSLocationWhenInUseUsageDescription = "We want your location haha"; + INFOPLIST_KEY_NSSupportsLiveActivities = YES; INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchScreen_Generation = YES; @@ -368,6 +499,62 @@ }; name = Release; }; + D8D378322CBEE7720043D103 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground; + CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = 7P5S729LQZ; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = TMTWidget/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = TMTWidget; + INFOPLIST_KEY_NSHumanReadableCopyright = ""; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@executable_path/../../Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = twomanythinking.TMT.TMTWidget; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + D8D378332CBEE7720043D103 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground; + CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = 7P5S729LQZ; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = TMTWidget/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = TMTWidget; + INFOPLIST_KEY_NSHumanReadableCopyright = ""; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@executable_path/../../Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = twomanythinking.TMT.TMTWidget; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -389,6 +576,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + D8D378342CBEE7720043D103 /* Build configuration list for PBXNativeTarget "TMTWidgetExtension" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + D8D378322CBEE7720043D103 /* Debug */, + D8D378332CBEE7720043D103 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; /* End XCConfigurationList section */ }; rootObject = D86739612CA933CD00FFE8ED /* Project object */; diff --git a/TMT/TMT.xcodeproj/xcshareddata/xcschemes/TMT.xcscheme b/TMT/TMT.xcodeproj/xcshareddata/xcschemes/TMT.xcscheme new file mode 100644 index 0000000..9d9fa1d --- /dev/null +++ b/TMT/TMT.xcodeproj/xcshareddata/xcschemes/TMT.xcscheme @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/TMT/TMTWidget/AppIntent.swift b/TMT/TMTWidget/AppIntent.swift new file mode 100644 index 0000000..35bafd0 --- /dev/null +++ b/TMT/TMTWidget/AppIntent.swift @@ -0,0 +1,18 @@ +// +// AppIntent.swift +// TMTWidget +// +// Created by 김유빈 on 10/16/24. +// + +import WidgetKit +import AppIntents + +struct ConfigurationAppIntent: WidgetConfigurationIntent { + static var title: LocalizedStringResource = "Configuration" + static var description = IntentDescription("This is an example widget.") + + // An example configurable parameter. + @Parameter(title: "Favorite Emoji", default: "😃") + var favoriteEmoji: String +} diff --git a/TMT/TMTWidget/Assets.xcassets/AccentColor.colorset/Contents.json b/TMT/TMTWidget/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 0000000..eb87897 --- /dev/null +++ b/TMT/TMTWidget/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/TMT/TMTWidget/Assets.xcassets/AppIcon.appiconset/Contents.json b/TMT/TMTWidget/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..13613e3 --- /dev/null +++ b/TMT/TMTWidget/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,13 @@ +{ + "images" : [ + { + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/TMT/TMTWidget/Assets.xcassets/Contents.json b/TMT/TMTWidget/Assets.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/TMT/TMTWidget/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/TMT/TMTWidget/Assets.xcassets/WidgetBackground.colorset/Contents.json b/TMT/TMTWidget/Assets.xcassets/WidgetBackground.colorset/Contents.json new file mode 100644 index 0000000..eb87897 --- /dev/null +++ b/TMT/TMTWidget/Assets.xcassets/WidgetBackground.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/TMT/TMTWidget/Info.plist b/TMT/TMTWidget/Info.plist new file mode 100644 index 0000000..0f118fb --- /dev/null +++ b/TMT/TMTWidget/Info.plist @@ -0,0 +1,11 @@ + + + + + NSExtension + + NSExtensionPointIdentifier + com.apple.widgetkit-extension + + + diff --git a/TMT/TMTWidget/TMTWidget.swift b/TMT/TMTWidget/TMTWidget.swift new file mode 100644 index 0000000..6836abe --- /dev/null +++ b/TMT/TMTWidget/TMTWidget.swift @@ -0,0 +1,84 @@ +// +// TMTWidget.swift +// TMTWidget +// +// Created by 김유빈 on 10/16/24. +// + +import WidgetKit +import SwiftUI + +struct Provider: AppIntentTimelineProvider { + func placeholder(in context: Context) -> SimpleEntry { + SimpleEntry(date: Date(), configuration: ConfigurationAppIntent()) + } + + func snapshot(for configuration: ConfigurationAppIntent, in context: Context) async -> SimpleEntry { + SimpleEntry(date: Date(), configuration: configuration) + } + + func timeline(for configuration: ConfigurationAppIntent, in context: Context) async -> 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) + } + + return Timeline(entries: entries, policy: .atEnd) + } +} + +struct SimpleEntry: TimelineEntry { + let date: Date + let configuration: ConfigurationAppIntent +} + +struct TMTWidgetEntryView : View { + var entry: Provider.Entry + + var body: some View { + VStack { + Text("Time:") + Text(entry.date, style: .time) + + Text("Favorite Emoji:") + Text(entry.configuration.favoriteEmoji) + } + } +} + +struct TMTWidget: Widget { + let kind: String = "TMTWidget" + + var body: some WidgetConfiguration { + AppIntentConfiguration(kind: kind, intent: ConfigurationAppIntent.self, provider: Provider()) { entry in + TMTWidgetEntryView(entry: entry) + .containerBackground(.fill.tertiary, for: .widget) + } + } +} + +extension ConfigurationAppIntent { + fileprivate static var smiley: ConfigurationAppIntent { + let intent = ConfigurationAppIntent() + intent.favoriteEmoji = "😀" + return intent + } + + fileprivate static var starEyes: ConfigurationAppIntent { + let intent = ConfigurationAppIntent() + intent.favoriteEmoji = "🤩" + return intent + } +} + +#Preview(as: .systemSmall) { + TMTWidget() +} timeline: { + SimpleEntry(date: .now, configuration: .smiley) + SimpleEntry(date: .now, configuration: .starEyes) +} diff --git a/TMT/TMTWidget/TMTWidgetBundle.swift b/TMT/TMTWidget/TMTWidgetBundle.swift new file mode 100644 index 0000000..25fc920 --- /dev/null +++ b/TMT/TMTWidget/TMTWidgetBundle.swift @@ -0,0 +1,17 @@ +// +// TMTWidgetBundle.swift +// TMTWidget +// +// Created by 김유빈 on 10/16/24. +// + +import WidgetKit +import SwiftUI + +@main +struct TMTWidgetBundle: WidgetBundle { + var body: some Widget { + TMTWidget() + TMTWidgetLiveActivity() + } +} diff --git a/TMT/TMTWidget/TMTWidgetLiveActivity.swift b/TMT/TMTWidget/TMTWidgetLiveActivity.swift new file mode 100644 index 0000000..6be4ebb --- /dev/null +++ b/TMT/TMTWidget/TMTWidgetLiveActivity.swift @@ -0,0 +1,80 @@ +// +// TMTWidgetLiveActivity.swift +// TMTWidget +// +// Created by 김유빈 on 10/16/24. +// + +import ActivityKit +import WidgetKit +import SwiftUI + +struct TMTWidgetAttributes: ActivityAttributes { + public struct ContentState: Codable, Hashable { + // Dynamic stateful properties about your activity go here! + var emoji: String + } + + // Fixed non-changing properties about your activity go here! + var name: String +} + +struct TMTWidgetLiveActivity: Widget { + var body: some WidgetConfiguration { + ActivityConfiguration(for: TMTWidgetAttributes.self) { context in + // Lock screen/banner UI goes here + VStack { + Text("Hello \(context.state.emoji)") + } + .activityBackgroundTint(Color.cyan) + .activitySystemActionForegroundColor(Color.black) + + } dynamicIsland: { context in + DynamicIsland { + // Expanded UI goes here. Compose the expanded UI through + // various regions, like leading/trailing/center/bottom + DynamicIslandExpandedRegion(.leading) { + Text("Leading") + } + DynamicIslandExpandedRegion(.trailing) { + Text("Trailing") + } + DynamicIslandExpandedRegion(.bottom) { + Text("Bottom \(context.state.emoji)") + // more content + } + } compactLeading: { + Text("L") + } compactTrailing: { + Text("T \(context.state.emoji)") + } minimal: { + Text(context.state.emoji) + } + .widgetURL(URL(string: "http://www.apple.com")) + .keylineTint(Color.red) + } + } +} + +extension TMTWidgetAttributes { + fileprivate static var preview: TMTWidgetAttributes { + TMTWidgetAttributes(name: "World") + } +} + +extension TMTWidgetAttributes.ContentState { + fileprivate static var smiley: TMTWidgetAttributes.ContentState { + TMTWidgetAttributes.ContentState(emoji: "😀") + } + + fileprivate static var starEyes: TMTWidgetAttributes.ContentState { + TMTWidgetAttributes.ContentState(emoji: "🤩") + } +} + +#Preview("Notification", as: .content, using: TMTWidgetAttributes.preview) { + TMTWidgetLiveActivity() +} contentStates: { + TMTWidgetAttributes.ContentState.smiley + TMTWidgetAttributes.ContentState.starEyes +}