설정에서 시스템/한국어/영어/일본어 선택을 지원한다. 선택 시 Accept-Language 헤더와 UI locale을 즉시 반영한다. 언어 변경 후 스플래시를 거쳐 메인으로 소프트 재시작한다.
34 lines
1.1 KiB
Swift
34 lines
1.1 KiB
Swift
//
|
|
// ContentSettingsViewModel.swift
|
|
// SodaLive
|
|
//
|
|
// Created by klaus on 10/10/24.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
final class ContentSettingsViewModel: ObservableObject {
|
|
@Published var isAdultContentVisible = UserDefaults.isAdultContentVisible() {
|
|
didSet {
|
|
if oldValue != isAdultContentVisible {
|
|
UserDefaults.set(isAdultContentVisible, forKey: .isAdultContentVisible)
|
|
AppState.shared.isRestartApp = true
|
|
|
|
if !isAdultContentVisible {
|
|
adultContentPreference = .ALL
|
|
UserDefaults.set(ContentType.ALL.rawValue, forKey: .contentPreference)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
@Published var adultContentPreference = ContentType(rawValue: UserDefaults.string(forKey: .contentPreference)) ?? ContentType.ALL {
|
|
didSet {
|
|
if oldValue != adultContentPreference {
|
|
UserDefaults.set(adultContentPreference.rawValue, forKey: .contentPreference)
|
|
AppState.shared.isRestartApp = true
|
|
}
|
|
}
|
|
}
|
|
}
|