-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
34f46b0
commit 64c1ac3
Showing
4 changed files
with
59 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// | ||
// DarkModeManager.swift | ||
// Segno | ||
// | ||
// Created by YOONJONG on 2022/12/06. | ||
// | ||
|
||
import UIKit | ||
|
||
import RxSwift | ||
|
||
class DarkModeManager { | ||
static let shared = DarkModeManager() | ||
|
||
let repository: LocalUtilityRepository | ||
|
||
private init() { | ||
self.repository = LocalUtilityRepositoryImpl() | ||
} | ||
|
||
func getDarkMode() -> Int { | ||
if let mode = repository.getUserDefaultsObject(forKey: .darkmode) as? Int { | ||
debugPrint("SettingsUseCase - getDarkMode : 키가 있습니다 - \(mode)") | ||
return mode | ||
} else { | ||
repository.setUserDefaults(DarkMode.system.rawValue, forKey: .darkmode) | ||
debugPrint("SettingsUseCase - getDarkMode : 키가 없어 \(DarkMode.system.rawValue) 로 설정합니다.") | ||
return DarkMode.system.rawValue | ||
} | ||
} | ||
|
||
func changeDarkMode(to mode: Int) { | ||
repository.setUserDefaults(mode, forKey: .darkmode) | ||
guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene, | ||
let window = windowScene.windows.first else { return } | ||
|
||
window.overrideUserInterfaceStyle = UIUserInterfaceStyle(rawValue: mode) ?? .unspecified | ||
debugPrint("SettingsUseCase - changeDarkMode : \(mode)로 설정") | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters