feat: redesigned settings view. Each module has two views: module settings and widget settings. The previous widget settings view was too complicated and weird

This commit is contained in:
Serhiy Mytrovtsiy
2021-11-04 17:38:53 +01:00
parent e1bac3ffa0
commit b6c45c53b9
26 changed files with 480 additions and 728 deletions

View File

@@ -18,12 +18,7 @@ internal class Settings: NSStackView, Settings_v {
private var list: [String: Bool] = [:]
public init() {
super.init(frame: NSRect(
x: 0,
y: 0,
width: Constants.Settings.width - (Constants.Settings.margin*2),
height: 20
))
super.init(frame: NSRect(x: 0, y: 0, width: 0, height: 0))
self.orientation = .vertical
self.distribution = .gravityAreas
@@ -34,6 +29,8 @@ internal class Settings: NSStackView, Settings_v {
right: Constants.Settings.margin
)
self.spacing = Constants.Settings.margin
self.addArrangedSubview(NSView())
}
required init?(coder: NSCoder) {
@@ -50,8 +47,7 @@ internal class Settings: NSStackView, Settings_v {
list.forEach { (d: BLEDevice) in
if self.list[d.id] == nil {
let row: NSView = toggleTitleRow(
frame: NSRect(x: 0, y: 0, width: self.frame.width - (Constants.Settings.margin*2), height: Constants.Settings.row),
let row: NSView = toggleSettingRow(
title: d.name,
action: #selector(self.handleSelection),
state: d.state
@@ -63,11 +59,6 @@ internal class Settings: NSStackView, Settings_v {
self.addArrangedSubview(row)
}
}
let h = self.arrangedSubviews.map({ $0.bounds.height + self.spacing }).reduce(0, +) - self.spacing + self.edgeInsets.top + self.edgeInsets.bottom
if self.frame.size.height != h {
self.setFrameSize(NSSize(width: self.bounds.width, height: h))
}
}
@objc private func handleSelection(_ sender: NSControl) {