Add local Live Activity and Dynamic Island track display
This commit is contained in:
@@ -3,14 +3,32 @@ import SwiftUI
|
||||
@main
|
||||
struct MusicBridgeApp: App {
|
||||
@StateObject private var store = PreviewSupport.makeStore()
|
||||
@StateObject private var liveActivity = LiveActivityManager()
|
||||
@Environment(\.scenePhase) private var phase
|
||||
|
||||
var body: some Scene {
|
||||
WindowGroup {
|
||||
ContentView(store: store)
|
||||
Group {
|
||||
if PreviewSupport.liveCard, let state = store.state {
|
||||
ScrollView {
|
||||
VStack(spacing: 24) {
|
||||
Text("Live Activity · предпросмотр").font(.headline)
|
||||
MusicActivityCard(state: LiveActivityManager.content(state), stale: false)
|
||||
.background(Color(.secondarySystemBackground), in: RoundedRectangle(cornerRadius: 24))
|
||||
MusicActivityCard(state: LiveActivityManager.content(state), stale: true)
|
||||
.background(Color(.secondarySystemBackground), in: RoundedRectangle(cornerRadius: 24))
|
||||
}.padding()
|
||||
}
|
||||
} else {
|
||||
ContentView(store: store, liveActivity: liveActivity)
|
||||
}
|
||||
}
|
||||
.dynamicTypeSize(PreviewSupport.largeText ? DynamicTypeSize.accessibility2...DynamicTypeSize.accessibility2 : DynamicTypeSize.xSmall...DynamicTypeSize.accessibility5)
|
||||
.onOpenURL { store.importInvitation($0.absoluteString) }
|
||||
.task { if !PreviewSupport.enabled { store.setActive(phase == .active) } }
|
||||
.onOpenURL { if $0.absoluteString != "musicbridge://player" { store.importInvitation($0.absoluteString) } }
|
||||
.task {
|
||||
store.liveActivity = liveActivity
|
||||
if !PreviewSupport.enabled { store.setActive(phase == .active) }
|
||||
}
|
||||
.onChange(of: phase) { _, value in if !PreviewSupport.enabled { store.setActive(value == .active) } }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user