65 lines
1.4 KiB
Swift
65 lines
1.4 KiB
Swift
//
|
|
// AppState.swift
|
|
// SodaLive
|
|
//
|
|
// Created by klaus on 2023/08/09.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
class AppState: ObservableObject {
|
|
static let shared = AppState()
|
|
|
|
private var appStepBackStack = [AppStep]()
|
|
|
|
@Published private(set) var appStep: AppStep = .splash
|
|
|
|
@Published var isShowPlayer = false {
|
|
didSet {
|
|
if isShowPlayer {
|
|
ContentPlayManager.shared.stopAudio()
|
|
}
|
|
}
|
|
}
|
|
|
|
@Published var isShowNotificationSettingsDialog = false
|
|
|
|
@Published var pushRoomId = 0
|
|
@Published var pushChannelId = 0
|
|
@Published var pushMessageId = 0
|
|
@Published var pushAudioContentId = 0
|
|
@Published var roomId = 0 {
|
|
didSet {
|
|
if roomId <= 0 {
|
|
isShowPlayer = false
|
|
}
|
|
}
|
|
}
|
|
|
|
@Published var eventPopup: EventItem? = nil
|
|
@Published var purchasedContentId = 0
|
|
@Published var purchasedContentOrderType = OrderType.KEEP
|
|
|
|
func setAppStep(step: AppStep) {
|
|
switch step {
|
|
case .splash, .main:
|
|
appStepBackStack.removeAll()
|
|
|
|
default:
|
|
appStepBackStack.append(appStep)
|
|
}
|
|
|
|
DispatchQueue.main.async {
|
|
self.appStep = step
|
|
}
|
|
}
|
|
|
|
func back() {
|
|
if let step = appStepBackStack.popLast() {
|
|
self.appStep = step
|
|
} else {
|
|
self.appStep = .main
|
|
}
|
|
}
|
|
}
|