Files
sodalive-ios/SodaLive/Sources/App/AppState.swift
Yu Sung 0285f62ecb 언어 설정 화면 추가 및 언어 헤더 적용
설정에서 시스템/한국어/영어/일본어 선택을 지원한다.

선택 시 Accept-Language 헤더와 UI locale을 즉시 반영한다.

언어 변경 후 스플래시를 거쳐 메인으로 소프트 재시작한다.
2025-12-16 22:56:37 +09:00

87 lines
2.2 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 var alreadyUpdatedMarketingInfo = false
@Published private(set) var appStep: AppStep = .splash
@Published var isShowPlayer = false {
didSet {
if isShowPlayer {
ContentPlayManager.shared.stopAudio()
ContentPlayerPlayManager.shared.resetPlayer()
}
}
}
@Published var isShowNotificationSettingsDialog = false
@Published var pushRoomId = 0
@Published var pushChannelId = 0
@Published var pushMessageId = 0
@Published var pushAudioContentId = 0
@Published var pushSeriesId = 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
@Published var isRestartApp = false
@Published var startTab: HomeViewModel.CurrentTab = .home
@Published var marketingUtmSource = ""
@Published var marketingUtmMedium = ""
@Published var marketingUtmCampaign = ""
@Published var isShowErrorPopup = false
@Published var errorMessage = ""
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
}
}
// ( -> ) UI
func softRestart() {
isRestartApp = true
setAppStep(step: .splash)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
self.setAppStep(step: .main)
}
}
}