Skip to content

Commit

Permalink
Merge pull request #32 from DeveloperAcademy-POSTECH/feat/#25
Browse files Browse the repository at this point in the history
Feat/#25: deprecated 이슈 해결, view 주석 추가
  • Loading branch information
grootwo authored May 21, 2024
2 parents 5dd3eac + 0447130 commit 6df619a
Show file tree
Hide file tree
Showing 4 changed files with 214 additions and 2 deletions.
6 changes: 6 additions & 0 deletions LiveTimeWidget/LiveTimeWidget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import ActivityKit
struct LiveTimeWidget: Widget {
var body: some WidgetConfiguration {
ActivityConfiguration(for: LiveTimeAttributes.self) { context in
// lock screen & standby(잠금 화면과 notification center, 그리고 전체화면 버전)
HStack {
Image(systemName: "leaf.fill")
.foregroundStyle(.customGreen)
Expand All @@ -23,7 +24,9 @@ struct LiveTimeWidget: Widget {
}
.padding()
} dynamicIsland: { context in
// dynamic island
DynamicIsland {
// expanded dynamic island bottom(다이나믹 아일랜드 꾹 눌러서 확장되는 버전)
DynamicIslandExpandedRegion(.bottom) {
VStack {
Text("잔디 심을 시간이에요!")
Expand All @@ -35,13 +38,16 @@ struct LiveTimeWidget: Widget {
.padding()
}
} compactLeading: {
// compact leading(다이나믹 아일랜드 소형 버전 왼쪽)
Image(systemName: "leaf.fill")
.foregroundStyle(.customGreen)
} compactTrailing: {
// compact trailing(다이나믹 아일랜드 소형 버전 오른쪽)
Text(context.state.restOfTime, style: .relative)
.foregroundStyle(.customGreen)
.frame(width: 66)
} minimal: {
// minimal(다이나믹 아일랜드 가장 작은 버전)
Text(context.state.restOfTime, style: .relative)
.foregroundStyle(.customGreen)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1530"
wasCreatedForAppExtension = "YES"
version = "2.0">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES"
buildArchitectures = "Automatic">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1B6530482BFB8A0C00452ACB"
BuildableName = "LiveTimeWidgetExtension.appex"
BlueprintName = "LiveTimeWidgetExtension"
ReferencedContainer = "container:MC2-Team3-Pilling.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "939C87DB2BF307B600572EDC"
BuildableName = "MC2-Team3-Pilling.app"
BlueprintName = "MC2-Team3-Pilling"
ReferencedContainer = "container:MC2-Team3-Pilling.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = ""
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
launchStyle = "0"
askForAppToLaunch = "Yes"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES"
launchAutomaticallySubstyle = "2">
<RemoteRunnable
runnableDebuggingMode = "2"
BundleIdentifier = "com.apple.springboard">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1B6530482BFB8A0C00452ACB"
BuildableName = "LiveTimeWidgetExtension.appex"
BlueprintName = "LiveTimeWidgetExtension"
ReferencedContainer = "container:MC2-Team3-Pilling.xcodeproj">
</BuildableReference>
</RemoteRunnable>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "939C87DB2BF307B600572EDC"
BuildableName = "MC2-Team3-Pilling.app"
BlueprintName = "MC2-Team3-Pilling"
ReferencedContainer = "container:MC2-Team3-Pilling.xcodeproj">
</BuildableReference>
</MacroExpansion>
<EnvironmentVariables>
<EnvironmentVariable
key = "_XCWidgetKind"
value = ""
isEnabled = "YES">
</EnvironmentVariable>
<EnvironmentVariable
key = "_XCWidgetDefaultView"
value = "timeline"
isEnabled = "YES">
</EnvironmentVariable>
<EnvironmentVariable
key = "_XCWidgetFamily"
value = "systemMedium"
isEnabled = "YES">
</EnvironmentVariable>
</EnvironmentVariables>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES"
askForAppToLaunch = "Yes"
launchAutomaticallySubstyle = "2">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "939C87DB2BF307B600572EDC"
BuildableName = "MC2-Team3-Pilling.app"
BlueprintName = "MC2-Team3-Pilling"
ReferencedContainer = "container:MC2-Team3-Pilling.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1530"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES"
buildArchitectures = "Automatic">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "939C87DB2BF307B600572EDC"
BuildableName = "MC2-Team3-Pilling.app"
BlueprintName = "MC2-Team3-Pilling"
ReferencedContainer = "container:MC2-Team3-Pilling.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "939C87DB2BF307B600572EDC"
BuildableName = "MC2-Team3-Pilling.app"
BlueprintName = "MC2-Team3-Pilling"
ReferencedContainer = "container:MC2-Team3-Pilling.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "939C87DB2BF307B600572EDC"
BuildableName = "MC2-Team3-Pilling.app"
BlueprintName = "MC2-Team3-Pilling"
ReferencedContainer = "container:MC2-Team3-Pilling.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
8 changes: 6 additions & 2 deletions MC2-Team3-Pilling/View/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,17 @@ struct ContentView: View {
Button(action: {
isTracking.toggle()
if isTracking {
// start live activity
let attributes = LiveTimeAttributes()
let state = LiveTimeAttributes.ContentState(restOfTime: alarmTime)
activity = try? Activity<LiveTimeAttributes>.request(attributes: attributes, contentState: state, pushType: nil)
let content = ActivityContent<LiveTimeAttributes.ContentState>(state: state, staleDate: alarmTime.addingTimeInterval(600))
activity = try? Activity<LiveTimeAttributes>.request(attributes: attributes, content: content, pushType: nil)
} else {
// end live activity
let state = LiveTimeAttributes.ContentState(restOfTime: alarmTime)
let content = ActivityContent<LiveTimeAttributes.ContentState>(state: state, staleDate: alarmTime.addingTimeInterval(600))
Task {
await activity?.end(using: state, dismissalPolicy:.immediate)
await activity?.end(content, dismissalPolicy:.immediate)
}
}
}, label: {
Expand Down

0 comments on commit 6df619a

Please sign in to comment.