Skip to content

Commit

Permalink
데모앱 대응
Browse files Browse the repository at this point in the history
  • Loading branch information
devMinseok committed Nov 26, 2024
1 parent e02bfbd commit 004126e
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,22 @@ public struct PomodoroCategory:
public var focusTime: String
public var restTime: String

public init(
no: Int,
baseCategoryCode: PomodoroCategoryCode,
title: String,
position: Int,
focusTime: String,
restTime: String
) {
self.no = no
self.baseCategoryCode = baseCategoryCode
self.title = title
self.position = position
self.focusTime = focusTime
self.restTime = restTime
}

@_spi(Internal)
public init(managedObject: PomodoroCategoryObject) {
self.no = managedObject.no
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,90 @@
// ContentView.swift
// LAPomodoroFeature
//
// Created by <#T##Author name#> on 11/23/24.
// Created by MinseokKang on 11/23/24.
//

import SwiftUI
import ActivityKit

import LiveActivityClientInterface
import PomodoroServiceInterface

import Dependencies

struct ContentView: View {
@State var testActivity: Activity<PomodoroActivityAttributes>?
@Dependency(LiveActivityClient.self) var liveActivityClient

var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
Text("Hello, world!")
Button {
startTestActivity()
} label: {
Text("Pomodoro LiveActivity start")
}

Button {
updateTestActivity()
} label: {
Text("Pomodoro LiveActivity update")
}

Button {
endTestActivity()
} label: {
Text("Pomodoro LiveActivity end")
}
}
.padding()
}

func startTestActivity() {
testActivity = try? liveActivityClient.protocolAdapter.startActivity(
attributes: PomodoroActivityAttributes(),
content: .init(
state: PomodoroActivityAttributes.ContentState(
category: .init(no: 0, baseCategoryCode: .basic, title: "테스트", position: 0, focusTime: "PT10M", restTime: "PT10M"),
goalDatetime: Date().addingTimeInterval(100),
isRest: false
),
staleDate: nil
),
pushType: nil
)
}

func updateTestActivity() {
guard let testActivity else { return }

Task {
await liveActivityClient.protocolAdapter.updateActivity(
PomodoroActivityAttributes.self,
id: testActivity.id,
content: .init(
state: PomodoroActivityAttributes.ContentState(
category: .init(no: 0, baseCategoryCode: .basic, title: "테스트2", position: 0, focusTime: "PT20M", restTime: "PT20M"),
goalDatetime: Date().addingTimeInterval(100),
isRest: false
),
staleDate: nil
)
)
}
}

func endTestActivity() {
guard let testActivity else { return }

Task {
await liveActivityClient.protocolAdapter.endActivity(
PomodoroActivityAttributes.self,
id: testActivity.id,
content: nil,
dismissalPolicy: .immediate
)
}
}
}

#Preview {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// LAPomodoroFeatureApp.swift
// LAPomodoroFeature
//
// Created by <#T##Author name#> on 11/23/24.
// Created by MinseokKang on 11/23/24.
//

import SwiftUI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ extension InfoPlist {
"LSRequiresIPhoneOS": true,


// MARK: - Live Activities

"NSSupportsLiveActivities": true,


// MARK: - Cocoa

"NSAppTransportSecurity": [
Expand Down

0 comments on commit 004126e

Please sign in to comment.