Skip to content

Commit

Permalink
#160 feat: 저장된 다크모드 설정 값을 기반으로 뷰 설정
Browse files Browse the repository at this point in the history
  • Loading branch information
LEEYOONJONG committed Dec 6, 2022
1 parent 64c1ac3 commit f4bdf8f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
6 changes: 6 additions & 0 deletions Segno/Segno/Application/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
let navigationController = UINavigationController()
coordinator = AppCoordinator(navigationController)
coordinator?.start()
setDarkMode()

window?.rootViewController = navigationController
window?.makeKeyAndVisible()
Expand All @@ -29,5 +30,10 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
func sceneWillResignActive(_ scene: UIScene) { }
func sceneWillEnterForeground(_ scene: UIScene) { }
func sceneDidEnterBackground(_ scene: UIScene) { }

private func setDarkMode() {
let mode = DarkModeManager.shared.getDarkMode()
DarkModeManager.shared.changeDarkMode(to: mode)
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -129,27 +129,15 @@ final class SettingsViewController: UIViewController {
let actionSheet = UIAlertController(title: Metric.darkModeSettingString, message: nil, preferredStyle: .actionSheet)
actionSheet.addAction(UIAlertAction(title: DarkMode.system.title, style: .default, handler: { _ in
self.viewModel.changeDarkMode(to: DarkMode.system.rawValue)
.subscribe(onSuccess: { mode in
self.view.window?.overrideUserInterfaceStyle = UIUserInterfaceStyle(rawValue: mode) ?? .unspecified
cell.configure(right: DarkMode.system.title)
})
.disposed(by: self.disposeBag)
cell.configure(right: DarkMode.system.title)
}))
actionSheet.addAction(UIAlertAction(title: DarkMode.light.title, style: .default, handler: { _ in
self.viewModel.changeDarkMode(to: DarkMode.light.rawValue)
.subscribe(onSuccess: { mode in
self.view.window?.overrideUserInterfaceStyle = UIUserInterfaceStyle(rawValue: mode) ?? .unspecified
cell.configure(right: DarkMode.light.title)
})
.disposed(by: self.disposeBag)
cell.configure(right: DarkMode.light.title)
}))
actionSheet.addAction(UIAlertAction(title: DarkMode.dark.title, style: .default, handler: { _ in
self.viewModel.changeDarkMode(to: DarkMode.dark.rawValue)
.subscribe(onSuccess: { mode in
self.view.window?.overrideUserInterfaceStyle = UIUserInterfaceStyle(rawValue: mode) ?? .unspecified
cell.configure(right: DarkMode.dark.title)
})
.disposed(by: self.disposeBag)
cell.configure(right: DarkMode.dark.title)
}))
actionSheet.addAction(UIAlertAction(title: Metric.cancelMessage
, style: .cancel, handler: { _ in
Expand Down

0 comments on commit f4bdf8f

Please sign in to comment.