Skip to content

Commit

Permalink
#157 feat: 다크모드 화면 구성
Browse files Browse the repository at this point in the history
  • Loading branch information
LEEYOONJONG committed Dec 6, 2022
1 parent 210a373 commit 34f46b0
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Segno/Segno/Presentation/View/NicknameCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ final class NicknameCell: UITableViewCell {
let label = UILabel()
label.text = Metric.nicknameLabelText
label.font = .appFont(.surroundAir, size: Metric.textSize)
label.textColor = .appColor(.grey2)
label.textColor = .appColor(.grey3)
return label
}()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ enum SettingsCellActions: Int {
}

final class SettingsViewController: UIViewController {
private enum Metric {
static let settingString: String = "설정"
static let darkModeSettingString: String = "다크 모드 설정"
static let cancelMessage: String = "취소"
}

private let disposeBag = DisposeBag()
private let viewModel: SettingsViewModel
private lazy var tableView: UITableView = {
Expand Down Expand Up @@ -50,7 +56,7 @@ final class SettingsViewController: UIViewController {
}

private func setupView() {
title = "설정"
title = Metric.settingString
view.backgroundColor = .appColor(.background)
}

Expand Down Expand Up @@ -118,21 +124,38 @@ final class SettingsViewController: UIViewController {
guard let action = SettingsCellActions(rawValue: indexPath.row) else { return }
switch action {
case .darkmode: // 다크 모드 설정
guard let cell = self?.tableView.cellForRow(at: indexPath) as? SettingsActionSheetCell else { return }
let actionSheet = UIAlertController(title: "다크 모드 설정", message: nil, preferredStyle: .actionSheet)
guard let cell = self?.tableView.cellForRow(at: indexPath) as? SettingsActionSheetCell,
let self = self else { return }
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)
cell.configure(right: DarkMode.system.title)
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)
}))
actionSheet.addAction(UIAlertAction(title: DarkMode.light.title, style: .default, handler: { _ in
self?.viewModel.changeDarkMode(to: DarkMode.light.rawValue)
cell.configure(right: DarkMode.light.title)
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)
}))
actionSheet.addAction(UIAlertAction(title: DarkMode.dark.title, style: .default, handler: { _ in
self?.viewModel.changeDarkMode(to: DarkMode.dark.rawValue)
cell.configure(right: DarkMode.dark.title)
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)
}))
actionSheet.addAction(UIAlertAction(title: Metric.cancelMessage
, style: .cancel, handler: { _ in
self.dismiss(animated: true)
}))
self?.present(actionSheet, animated: true)
self.present(actionSheet, animated: true)
default:
break
}
Expand Down

0 comments on commit 34f46b0

Please sign in to comment.