-
Notifications
You must be signed in to change notification settings - Fork 350
/
SettingView+.swift
39 lines (29 loc) · 1.12 KB
/
SettingView+.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//
// SettingView+.swift
// DevToys
//
// Created by yuki on 2022/02/16.
//
import CoreUtil
final class SettingViewController: NSViewController {
private let cell = SettingView()
override func loadView() { self.view = cell }
override func chainObjectDidLoad() {
self.appModel.settings.$appearanceType
.sink{[unowned self] in self.cell.appearancePicker.selectedItem = $0 }.store(in: &objectBag)
self.cell.appearancePicker.itemPublisher
.sink{[unowned self] in self.appModel.settings.appearanceType = $0 }.store(in: &objectBag)
}
}
extension Settings.AppearanceType: TextItem {
static let allCases: [Self] = [.useSystemSettings, .lightMode, .darkMode]
var title: String { rawValue.localized() }
}
final private class SettingView: Page {
let appearancePicker = EnumPopupButton<Settings.AppearanceType>()
override func onAwake() {
self.addSection(
Area(icon: R.Image.paramators, title: "App Theme".localized(), message: "Select which app theme to display".localized(), control: appearancePicker)
)
}
}