feat: update new style
This commit is contained in:
1 parent
93265fd4fc
commit
7034e13263
3 files changed
+24
-17
No files matched your search
@@ -125,7 +125,7 @@ class TableGroupSetView: NSStackView {
|
||||
/// likes system settings UI, with configurable styles and events.
|
||||
class TableGroupView: ClickHoverStackView {
|
||||
static let spacing = CGFloat(10)
|
||||
static let rowIntraSpacing = CGFloat(2)
|
||||
static let rowIntraSpacing = CGFloat(5)
|
||||
static let backgroundColor = NSColor.lightGray.withAlphaComponent(0.1).cgColor
|
||||
static let borderColor = NSColor.lightGray.withAlphaComponent(0.2).cgColor
|
||||
static let cornerRadius = CGFloat(5)
|
||||
@@ -283,7 +283,7 @@ class TableGroupView: ClickHoverStackView {
|
||||
|
||||
if let subText = subText {
|
||||
let subLabel = createSubLabel(with: subText, rightViewsWidth: mainRow.arrangedSubviews[2].fittingSize.width)
|
||||
setSecondaryRow([subLabel], in: rowView, below: mainRow)
|
||||
setSecondaryRow([subLabel], rowView: rowView, mainRow: mainRow)
|
||||
} else {
|
||||
mainRow.bottomAnchor.constraint(equalTo: rowView.bottomAnchor, constant: -TableGroupView.spacing).isActive = true
|
||||
}
|
||||
@@ -292,6 +292,7 @@ class TableGroupView: ClickHoverStackView {
|
||||
}
|
||||
|
||||
func addRow(leftViews: [NSView]? = nil, rightViews: [NSView]? = nil, secondaryViews: [NSView]? = nil,
|
||||
secondaryViewsOrientation: NSUserInterfaceLayoutOrientation = .horizontal,
|
||||
onClick: EventClosure? = nil,
|
||||
onMouseEntered: EventClosure? = nil,
|
||||
onMouseExited: EventClosure? = nil) -> RowInfo {
|
||||
@@ -300,7 +301,7 @@ class TableGroupView: ClickHoverStackView {
|
||||
setMainRow(mainRow, in: rowView)
|
||||
|
||||
if let secondaryViews = secondaryViews {
|
||||
setSecondaryRow(secondaryViews, in: rowView, below: mainRow)
|
||||
setSecondaryRow(secondaryViews, rowView: rowView, mainRow: mainRow, orientation: secondaryViewsOrientation)
|
||||
} else {
|
||||
mainRow.bottomAnchor.constraint(equalTo: rowView.bottomAnchor, constant: -TableGroupView.spacing).isActive = true
|
||||
}
|
||||
@@ -328,12 +329,16 @@ class TableGroupView: ClickHoverStackView {
|
||||
return rowView
|
||||
}
|
||||
|
||||
private func createMainRow(leftText: String?, rightViews: [NSView]?) -> NSStackView {
|
||||
static func makeText(_ leftText: String?) -> NSTextField {
|
||||
let leftLabel = NSTextField(labelWithString: leftText ?? "")
|
||||
leftLabel.alignment = .left
|
||||
leftLabel.lineBreakMode = .byWordWrapping
|
||||
leftLabel.maximumNumberOfLines = 0
|
||||
return leftLabel
|
||||
}
|
||||
|
||||
private func createMainRow(leftText: String?, rightViews: [NSView]?) -> NSStackView {
|
||||
let leftLabel = TableGroupView.makeText(leftText)
|
||||
return createMainRow(leftViews: [leftLabel], rightViews: rightViews)
|
||||
}
|
||||
|
||||
@@ -399,9 +404,10 @@ class TableGroupView: ClickHoverStackView {
|
||||
return subLabel
|
||||
}
|
||||
|
||||
private func setSecondaryRow(_ secondaryRows: [NSView]?, in rowView: ClickHoverStackView, below mainRow: NSStackView) {
|
||||
private func setSecondaryRow(_ secondaryRows: [NSView]?, rowView: ClickHoverStackView, mainRow: NSStackView,
|
||||
orientation: NSUserInterfaceLayoutOrientation = .horizontal) {
|
||||
let view = NSStackView()
|
||||
view.orientation = .horizontal
|
||||
view.orientation = orientation
|
||||
view.spacing = TableGroupView.spacing
|
||||
if let secondaryRows = secondaryRows {
|
||||
view.setViews(secondaryRows, in: .leading)
|
||||
|
||||
@@ -431,12 +431,13 @@ class CustomizeModelSettingsWindow: NSWindow {
|
||||
}
|
||||
|
||||
@objc func switchTab(_ sender: NSSegmentedControl) {
|
||||
if sender.selectedSegment == 0 {
|
||||
showHideView.isHidden = false
|
||||
advancedView.isHidden = true
|
||||
} else if sender.selectedSegment == 1 {
|
||||
advancedView.isHidden = false
|
||||
showHideView.isHidden = true
|
||||
let selectedIndex = sender.selectedSegment
|
||||
[showHideView, advancedView].enumerated().forEach { (index, view) in
|
||||
if selectedIndex == index {
|
||||
view.isHidden = false
|
||||
} else {
|
||||
view.isHidden = true
|
||||
}
|
||||
}
|
||||
adjustWindowHeight()
|
||||
}
|
||||
@@ -560,7 +561,7 @@ class Popover: NSPopover {
|
||||
|
||||
class AppearanceTab: NSObject {
|
||||
static var shared = AppearanceTab()
|
||||
static let width = CGFloat(650)
|
||||
static let width = CGFloat(550)
|
||||
static let sheetWidth = CGFloat(512)
|
||||
|
||||
static var modelAdvancedButton: NSButton!
|
||||
@@ -586,10 +587,10 @@ class AppearanceTab: NSObject {
|
||||
let table = TableGroupView(title: "Appearance",
|
||||
subTitle: "The appearance feature allows the switcher to switch between three different modes, each having a distinct UI to adapt to different workflows. Each appearance mode has its own unique settings.",
|
||||
width: AppearanceTab.width)
|
||||
_ = table.addRow(leftText: NSLocalizedString("Appearance model", comment: ""),
|
||||
rightViews: LabelAndControl.makeLabelWithImageRadioButtons("", "appearanceModel", AppearanceModelPreference.allCases, extraAction: { _ in
|
||||
_ = table.addRow(leftText: NSLocalizedString("Appearance model", comment: ""))
|
||||
_ = table.addRow(secondaryViews: [LabelAndControl.makeLabelWithImageRadioButtons("", "appearanceModel", AppearanceModelPreference.allCases, extraAction: { _ in
|
||||
toggleModelAdvancedButton()
|
||||
}, buttonSpacing: 20)[1])
|
||||
}, buttonSpacing: 20)[1]])
|
||||
_ = table.addRow(leftText: NSLocalizedString("Appearance size", comment: ""),
|
||||
rightViews: LabelAndControl.makeLabelWithRadioButtons("", "appearanceSize", AppearanceSizePreference.allCases)[1])
|
||||
_ = table.addRow(rightViews: modelAdvancedButton)
|
||||
|
||||
@@ -200,7 +200,7 @@ class ControlsTab {
|
||||
let shortcutStyle = LabelAndControl.makeDropdown(Preferences.indexToName("shortcutStyle", index), ShortcutStylePreference.allCases)
|
||||
|
||||
let table2 = TableGroupView(title: NSLocalizedString("Trigger Shortcuts", comment: ""), width: AppearanceTab.width)
|
||||
_ = table2.addRow(TableGroupView.Row(leftTitle: NSLocalizedString("AltTab shortcuts", comment: ""), rightViews: holdShortcut + nextWindowShortcut))
|
||||
_ = table2.addRow(TableGroupView.Row(leftTitle: NSLocalizedString("AltTab shortcuts", comment: ""), rightViews: holdShortcut + [nextWindowShortcut[0]]))
|
||||
_ = table2.addRow(TableGroupView.Row(leftTitle: NSLocalizedString("After release the shortcuts", comment: ""), rightViews: [shortcutStyle]))
|
||||
|
||||
let view = TableGroupSetView(originalViews: [table2, table1], padding: 0)
|
||||
|
||||
Reference in new issue
Block a user