Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion iBox/Sources/Base/BaseBottomSheetViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class BaseBottomSheetViewController<View: BaseView>: 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()
})
}
Expand Down
2 changes: 1 addition & 1 deletion iBox/Sources/Base/BaseNavigationBarViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class BaseNavigationBarViewController<View: BaseView>: 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
Expand Down
8 changes: 8 additions & 0 deletions iBox/Sources/Model/Theme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
1 change: 0 additions & 1 deletion iBox/Sources/Presenter/MyPage/MyPageItemCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class MyPageItemCell: UITableViewCell, BaseViewProtocol {

let titleLabel = UILabel().then {
$0.font = .systemFont(ofSize: 16)
$0.textColor = .black
}

let descriptionLabel = UILabel().then {
Expand Down
3 changes: 1 addition & 2 deletions iBox/Sources/Presenter/MyPage/Theme/ThemeCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 3 additions & 5 deletions iBox/Sources/Presenter/MyPage/Theme/ThemeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ class ThemeViewController: BaseNavigationBarViewController<ThemeView> {
contentView.tableView.dataSource = self
}

override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
UserDefaultsManager.theme.value = selected
}

// MARK: - BaseNavigationBarViewControllerProtocol

override func setupNavigationBar() {
Expand Down Expand Up @@ -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
}

}
4 changes: 4 additions & 0 deletions iBox/Sources/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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() // 윈도우를 화면에 보여줌
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}()

}