Commit fc449841 by Demid Merzlyakov

Settings / Theme Selection: images are tappable. An ability to disable automatic.

parent 339c720e
......@@ -68,16 +68,26 @@ class SettingsThemeCell: UITableViewCell {
@objc private func handleThemeButton(button: UIButton) {
switch button {
case lightThemeButton:
Settings.shared.appTheme = .light
selectLightTheme()
case darkThemeButton:
Settings.shared.appTheme = .dark
selectDarkTheme()
default:
break
}
}
@objc private func handleAutomaticSwith() {
Settings.shared.appTheme = .system
if automaticSwitchButton.isOn {
Settings.shared.appTheme = .system
}
else {
switch interfaceStyle {
case .light:
Settings.shared.appTheme = .light
case .dark:
Settings.shared.appTheme = .dark
}
}
}
//Public
......@@ -104,13 +114,27 @@ private extension SettingsThemeCell {
}
}
@objc
private func selectLightTheme() {
Settings.shared.appTheme = .light
}
@objc
private func selectDarkTheme() {
Settings.shared.appTheme = .dark
}
func prepareLightTheme() {
lightThemeImageView.clipsToBounds = true
lightThemeImageView.layer.cornerRadius = 10
lightThemeImageView.contentMode = .scaleAspectFill
lightThemeImageView.image = UIImage(named: "theme_sample_light")
lightThemeImageView.isUserInteractionEnabled = true
container.addSubview(lightThemeImageView)
let gesture = UITapGestureRecognizer(target: self, action: #selector(selectLightTheme))
lightThemeImageView.addGestureRecognizer(gesture)
lightThemeLabel.textAlignment = .center
lightThemeLabel.setContentHuggingPriority(.fittingSizeLevel, for: .vertical)
lightThemeLabel.font = AppFont.SFPro.regular(size: 16)
......@@ -145,8 +169,12 @@ private extension SettingsThemeCell {
darkThemeImageView.clipsToBounds = true
darkThemeImageView.contentMode = .scaleAspectFill
darkThemeImageView.image = UIImage(named: "theme_sample_dark")
darkThemeImageView.isUserInteractionEnabled = true
container.addSubview(darkThemeImageView)
let gesture = UITapGestureRecognizer(target: self, action: #selector(selectDarkTheme))
darkThemeImageView.addGestureRecognizer(gesture)
darkThemeLabel.textAlignment = .center
darkThemeLabel.font = AppFont.SFPro.regular(size: 16)
darkThemeLabel.text = "settings.theme.dark".localized()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment