diff --git a/iBox/Sources/Base/BaseBottomSheetViewController.swift b/iBox/Sources/Base/BaseBottomSheetViewController.swift index 02f2de8..85661cf 100644 --- a/iBox/Sources/Base/BaseBottomSheetViewController.swift +++ b/iBox/Sources/Base/BaseBottomSheetViewController.swift @@ -104,7 +104,7 @@ class BaseBottomSheetViewController: UIViewController { $0.height.equalTo(bottomSheetHeight) } UIView.animate(withDuration: 0.25, delay: 0, options: .curveEaseIn, animations: { - self.dimmedView.backgroundColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.75) + self.dimmedView.backgroundColor = ColorPalette.dimmedViewColor self.view.layoutIfNeeded() }) } diff --git a/iBox/Sources/Base/BaseNavigationBarViewController.swift b/iBox/Sources/Base/BaseNavigationBarViewController.swift index 0193cba..d7a31f2 100644 --- a/iBox/Sources/Base/BaseNavigationBarViewController.swift +++ b/iBox/Sources/Base/BaseNavigationBarViewController.swift @@ -52,7 +52,7 @@ class BaseNavigationBarViewController: UIViewController, BaseNav // MARK: - properties let backgroundColor: UIColor = .systemBackground - let tintColor: UIColor = .black + let tintColor: UIColor = .label let titleFont: UIFont = .systemFont(ofSize: 20, weight: .semibold) // MARK: - life cycle diff --git a/iBox/Sources/Model/Theme.swift b/iBox/Sources/Model/Theme.swift index 47d97fa..413e934 100644 --- a/iBox/Sources/Model/Theme.swift +++ b/iBox/Sources/Model/Theme.swift @@ -27,4 +27,12 @@ enum Theme: Codable, CaseIterable { case .system: UIImage(systemName: "circle.righthalf.filled") } } + + func toUserInterfaceStyle() -> UIUserInterfaceStyle { + switch self { + case .light: UIUserInterfaceStyle.light + case .dark: UIUserInterfaceStyle.dark + case .system: UIUserInterfaceStyle.unspecified + } + } } diff --git a/iBox/Sources/Presenter/MyPage/MyPageItemCell.swift b/iBox/Sources/Presenter/MyPage/MyPageItemCell.swift index 3d0619d..1c5cdf6 100644 --- a/iBox/Sources/Presenter/MyPage/MyPageItemCell.swift +++ b/iBox/Sources/Presenter/MyPage/MyPageItemCell.swift @@ -15,7 +15,6 @@ class MyPageItemCell: UITableViewCell, BaseViewProtocol { let titleLabel = UILabel().then { $0.font = .systemFont(ofSize: 16) - $0.textColor = .black } let descriptionLabel = UILabel().then { diff --git a/iBox/Sources/Presenter/MyPage/Theme/ThemeCell.swift b/iBox/Sources/Presenter/MyPage/Theme/ThemeCell.swift index 7c4499b..8a2cbdb 100644 --- a/iBox/Sources/Presenter/MyPage/Theme/ThemeCell.swift +++ b/iBox/Sources/Presenter/MyPage/Theme/ThemeCell.swift @@ -12,12 +12,11 @@ class ThemeCell: UITableViewCell, BaseViewProtocol { // MARK: - UI let themeImageView = UIImageView().then { - $0.tintColor = .black + $0.tintColor = .label } let titleLabel = UILabel().then { $0.font = .systemFont(ofSize: 16) - $0.textColor = .black } let selectButton = UIButton().then { diff --git a/iBox/Sources/Presenter/MyPage/Theme/ThemeViewController.swift b/iBox/Sources/Presenter/MyPage/Theme/ThemeViewController.swift index 5f6da74..5bacd40 100644 --- a/iBox/Sources/Presenter/MyPage/Theme/ThemeViewController.swift +++ b/iBox/Sources/Presenter/MyPage/Theme/ThemeViewController.swift @@ -24,11 +24,6 @@ class ThemeViewController: BaseNavigationBarViewController { contentView.tableView.dataSource = self } - override func viewWillDisappear(_ animated: Bool) { - super.viewWillDisappear(animated) - UserDefaultsManager.theme.value = selected - } - // MARK: - BaseNavigationBarViewControllerProtocol override func setupNavigationBar() { @@ -64,7 +59,10 @@ extension ThemeViewController: UITableViewDelegate, UITableViewDataSource { // 테이블 뷰 셀이 선택되었을 때 실행되는 메서드 func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { selected = Theme.allCases[indexPath.row] + guard let window = self.view.window else { return } + window.overrideUserInterfaceStyle = selected.toUserInterfaceStyle() tableView.reloadData() // 다시 그리기 + UserDefaultsManager.theme.value = selected } } diff --git a/iBox/Sources/SceneDelegate.swift b/iBox/Sources/SceneDelegate.swift index 77d235c..d765cc6 100644 --- a/iBox/Sources/SceneDelegate.swift +++ b/iBox/Sources/SceneDelegate.swift @@ -17,6 +17,10 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { window = UIWindow(frame: windowScene.coordinateSpace.bounds) window?.windowScene = windowScene window?.rootViewController = MainTabBarController() + + // 앱 테마 정보 + window?.overrideUserInterfaceStyle = UserDefaultsManager.theme.value.toUserInterfaceStyle() + window?.makeKeyAndVisible() // 윈도우를 화면에 보여줌 } diff --git a/iBox/Sources/Presenter/ColorPalette.swift b/iBox/Sources/Utils/ColorPalette.swift similarity index 79% rename from iBox/Sources/Presenter/ColorPalette.swift rename to iBox/Sources/Utils/ColorPalette.swift index da77a9b..433334c 100644 --- a/iBox/Sources/Presenter/ColorPalette.swift +++ b/iBox/Sources/Utils/ColorPalette.swift @@ -62,5 +62,15 @@ struct ColorPalette { } }() + public static var dimmedViewColor = { + return UIColor { (UITraitCollection: UITraitCollection) -> UIColor in + if UITraitCollection.userInterfaceStyle == .dark { + return UIColor(red: 0.1, green: 0.1, blue: 0.1, alpha: 0.75) + } else { + return UIColor(red: 0, green: 0, blue: 0, alpha: 0.75) + } + } + }() + }