tvOS 17+ SwiftUI client for the unofficial Yandex Music API: rotor stations with feedback, library, search, artist and album pages, synced lyrics, and system Now Playing integration.
42 lines
1.1 KiB
Swift
42 lines
1.1 KiB
Swift
import SwiftUI
|
|
|
|
@main
|
|
struct YaMusekApp: App {
|
|
@StateObject private var state = AppState()
|
|
@StateObject private var player = PlayerController.shared
|
|
|
|
var body: some Scene {
|
|
WindowGroup {
|
|
Group {
|
|
// The API client only learns the token inside boot(), so nothing
|
|
// that makes requests may appear before it finishes.
|
|
if state.isBooting {
|
|
SplashView()
|
|
} else if state.isAuthorized {
|
|
RootView()
|
|
} else {
|
|
LoginView()
|
|
}
|
|
}
|
|
.environmentObject(state)
|
|
.environmentObject(player)
|
|
.preferredColorScheme(.dark)
|
|
.task { await state.boot() }
|
|
}
|
|
}
|
|
}
|
|
|
|
struct SplashView: View {
|
|
var body: some View {
|
|
ZStack {
|
|
Color.black.ignoresSafeArea()
|
|
VStack(spacing: 24) {
|
|
Text("YaMusek")
|
|
.font(.system(size: 72, weight: .heavy, design: .rounded))
|
|
.foregroundStyle(Color.ymAccent)
|
|
ProgressView()
|
|
}
|
|
}
|
|
}
|
|
}
|