mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-23 06:33:42 +00:00
Rebranded the app for iOS
This commit is contained in:
committed by
Konstantin Pastbin
parent
51b669cfd1
commit
d4e1d53c40
@@ -0,0 +1,26 @@
|
||||
import ActivityKit
|
||||
import SwiftUI
|
||||
|
||||
@available(iOS 16.2, *)
|
||||
final class LiveActivityManager {
|
||||
static func startActivity<T: ActivityAttributes>(_ attributes: T, content: ActivityContent<T.ContentState>) throws -> Activity<T> {
|
||||
return try Activity.request(attributes: attributes, content: content, pushType: nil)
|
||||
}
|
||||
|
||||
static func update<T: ActivityAttributes>(_ activity: Activity<T>, content: ActivityContent<T.ContentState>) {
|
||||
Task {
|
||||
await activity.update(content)
|
||||
}
|
||||
}
|
||||
|
||||
static func stop(_ activity: Activity<some ActivityAttributes>) {
|
||||
// semaphore is used for removing the activity during the app termination
|
||||
let semaphore = DispatchSemaphore(value: 0)
|
||||
Task {
|
||||
await activity.end(nil, dismissalPolicy: .immediate)
|
||||
semaphore.signal()
|
||||
}
|
||||
semaphore.wait()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user