refactor(settings): 改用常规关于选项卡并统一蓝色强调色
This commit is contained in:
@@ -1,11 +1,20 @@
|
||||
{
|
||||
"colors" : [
|
||||
"colors": [
|
||||
{
|
||||
"idiom" : "universal"
|
||||
"idiom": "universal",
|
||||
"color": {
|
||||
"color-space": "srgb",
|
||||
"components": {
|
||||
"alpha": "1.000",
|
||||
"blue": "1.000",
|
||||
"green": "0.478",
|
||||
"red": "0.000"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
"info": {
|
||||
"author": "xcode",
|
||||
"version": 1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,31 +6,13 @@ nonisolated enum AppAppearance: String, CaseIterable, Identifiable {
|
||||
var id: String { rawValue }
|
||||
}
|
||||
|
||||
nonisolated enum AccentChoice: String, CaseIterable, Identifiable {
|
||||
case system, blue, purple, teal, green, orange, pink, custom
|
||||
var id: String { rawValue }
|
||||
}
|
||||
|
||||
@MainActor @Observable
|
||||
final class AppearancePreferences {
|
||||
@ObservationIgnored private let defaults: UserDefaults
|
||||
var appearance: AppAppearance { didSet { defaults.set(appearance.rawValue, forKey: "appearance") } }
|
||||
var accent: AccentChoice { didSet { defaults.set(accent.rawValue, forKey: "accent") } }
|
||||
var red: Double { didSet { defaults.set(red, forKey: "accent.red") } }
|
||||
var green: Double { didSet { defaults.set(green, forKey: "accent.green") } }
|
||||
var blue: Double { didSet { defaults.set(blue, forKey: "accent.blue") } }
|
||||
|
||||
init(defaults: UserDefaults = .standard) {
|
||||
self.defaults = defaults
|
||||
appearance = AppAppearance(rawValue: defaults.string(forKey: "appearance") ?? "") ?? .system
|
||||
accent = AccentChoice(rawValue: defaults.string(forKey: "accent") ?? "") ?? .system
|
||||
red = Self.component(defaults.object(forKey: "accent.red"), fallback: 0.2)
|
||||
green = Self.component(defaults.object(forKey: "accent.green"), fallback: 0.5)
|
||||
blue = Self.component(defaults.object(forKey: "accent.blue"), fallback: 0.9)
|
||||
}
|
||||
|
||||
private static func component(_ value: Any?, fallback: Double) -> Double {
|
||||
guard let value = value as? Double, value.isFinite else { return fallback }
|
||||
return min(1, max(0, value))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ struct MenuPanelView: View {
|
||||
Button { presentation.isPinned.toggle() } label: {
|
||||
Image(systemName: presentation.isPinned ? "pin.fill" : "pin")
|
||||
.frame(width: 20, height: 20)
|
||||
.foregroundStyle(presentation.isPinned ? preferences.tintColor : Color.primary)
|
||||
.foregroundStyle(presentation.isPinned ? Color.blue : Color.primary)
|
||||
}
|
||||
.help(Text(presentation.isPinned ? "panel.unpin" : "panel.pin"))
|
||||
.accessibilityLabel(Text(presentation.isPinned ? "panel.unpin" : "panel.pin"))
|
||||
@@ -151,7 +151,7 @@ struct MenuPanelView: View {
|
||||
Button { keepAwake.toggle() } label: {
|
||||
Image(systemName: keepAwake.isEnabled ? "cup.and.saucer.fill" : "cup.and.saucer")
|
||||
.frame(width: 20, height: 20)
|
||||
.foregroundStyle(keepAwake.isEnabled ? preferences.tintColor : Color.primary)
|
||||
.foregroundStyle(keepAwake.isEnabled ? Color.blue : Color.primary)
|
||||
}
|
||||
.help(keepAwake.didFail ? Text("awake.failed") : (keepAwake.isEnabled ? Text("awake.disable") : Text("awake.enable")))
|
||||
.accessibilityLabel(keepAwake.isEnabled ? Text("awake.disable") : Text("awake.enable"))
|
||||
|
||||
@@ -8,96 +8,30 @@ struct AppearanceSettingsView: View {
|
||||
@Bindable var sampling: SamplingPreferences
|
||||
let presentation: SettingsPresentation
|
||||
@Environment(\.locale) private var locale
|
||||
@State private var colorPicker = CustomColorPicker()
|
||||
@State private var selection: SettingsPage? = .appearance
|
||||
@State private var selection = SettingsPage.general
|
||||
|
||||
var body: some View {
|
||||
NavigationSplitView {
|
||||
List(selection: $selection) {
|
||||
ForEach(SettingsPage.allCases) { page in
|
||||
Label(page.title, systemImage: page.symbol).tag(page)
|
||||
}
|
||||
}
|
||||
.listStyle(.sidebar)
|
||||
.navigationSplitViewColumnWidth(min: 180, ideal: 205, max: 240)
|
||||
} detail: {
|
||||
Group {
|
||||
switch selectedPage {
|
||||
case .appearance: appearancePage
|
||||
case .language: languagePage
|
||||
case .monitoring: monitoringPage
|
||||
case .about: aboutPage
|
||||
}
|
||||
}
|
||||
.navigationTitle(selectedPage.title)
|
||||
TabView(selection: $selection) {
|
||||
generalPage
|
||||
.tabItem { Label("settings.general", systemImage: "gearshape") }
|
||||
.tag(SettingsPage.general)
|
||||
aboutPage
|
||||
.tabItem { Label("settings.about", systemImage: "info.circle") }
|
||||
.tag(SettingsPage.about)
|
||||
}
|
||||
.navigationSplitViewStyle(.balanced)
|
||||
.padding(12)
|
||||
.background(SettingsWindowLifecycle(title: AppLocalization.string("settings.title", locale: locale),
|
||||
requestID: presentation.requestID,
|
||||
onClose: { colorPicker.close() }))
|
||||
.onChange(of: preferences.accent) { _, choice in
|
||||
if choice == .custom {
|
||||
Task { @MainActor in
|
||||
await Task.yield()
|
||||
guard preferences.accent == .custom else { return }
|
||||
colorPicker.show(for: preferences)
|
||||
}
|
||||
} else { colorPicker.close() }
|
||||
}
|
||||
.onChange(of: selection) { _, _ in colorPicker.close() }
|
||||
.frame(minWidth: 720, idealWidth: 780, minHeight: 460, idealHeight: 540)
|
||||
requestID: presentation.requestID))
|
||||
.frame(minWidth: 600, idealWidth: 640, minHeight: 420, idealHeight: 460)
|
||||
.modifier(AppearanceStyle(preferences: preferences, refreshContentOnChange: true))
|
||||
}
|
||||
|
||||
private var selectedPage: SettingsPage { selection ?? .appearance }
|
||||
|
||||
private var appearancePage: some View {
|
||||
private var generalPage: some View {
|
||||
Form {
|
||||
Section {
|
||||
LabeledContent("appearance.title") {
|
||||
LiquidAppearancePicker(selection: $preferences.appearance)
|
||||
}
|
||||
LabeledContent("accent.title") {
|
||||
Picker("accent.title", selection: $preferences.accent) {
|
||||
Text("accent.system").tag(AccentChoice.system)
|
||||
Text("accent.blue").tag(AccentChoice.blue)
|
||||
Text("accent.purple").tag(AccentChoice.purple)
|
||||
Text("accent.teal").tag(AccentChoice.teal)
|
||||
Text("accent.green").tag(AccentChoice.green)
|
||||
Text("accent.orange").tag(AccentChoice.orange)
|
||||
Text("accent.pink").tag(AccentChoice.pink)
|
||||
Text("accent.custom").tag(AccentChoice.custom)
|
||||
}
|
||||
.labelsHidden()
|
||||
.fixedSize()
|
||||
}
|
||||
if preferences.accent == .custom {
|
||||
LabeledContent("accent.custom") {
|
||||
CustomColorWell(preferences: preferences, picker: colorPicker)
|
||||
.frame(width: 44, height: 26)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.formStyle(.grouped)
|
||||
.padding(.horizontal, 12)
|
||||
.padding(.top, 6)
|
||||
}
|
||||
|
||||
private var monitoringPage: some View {
|
||||
Form {
|
||||
Section {
|
||||
LabeledContent("sampling.background") {
|
||||
IntervalControl(milliseconds: $sampling.backgroundMilliseconds)
|
||||
}
|
||||
Text("sampling.backgroundHelp").font(.callout).foregroundStyle(.secondary)
|
||||
}
|
||||
}.formStyle(.grouped).padding(.horizontal, 12).padding(.top, 6)
|
||||
}
|
||||
|
||||
private var languagePage: some View {
|
||||
Form {
|
||||
Section {
|
||||
LabeledContent("language.title") {
|
||||
Picker("language.title", selection: $language.language) {
|
||||
Text("language.system").tag(AppLanguage.system)
|
||||
@@ -108,14 +42,15 @@ struct AppearanceSettingsView: View {
|
||||
.labelsHidden()
|
||||
.fixedSize()
|
||||
}
|
||||
Text("language.immediate")
|
||||
.font(.callout)
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
Section {
|
||||
LabeledContent("sampling.background") {
|
||||
IntervalControl(milliseconds: $sampling.backgroundMilliseconds)
|
||||
}
|
||||
Text("sampling.backgroundHelp").font(.callout).foregroundStyle(.secondary)
|
||||
}
|
||||
}
|
||||
.formStyle(.grouped)
|
||||
.padding(.horizontal, 12)
|
||||
.padding(.top, 6)
|
||||
}
|
||||
|
||||
private var aboutPage: some View {
|
||||
@@ -164,7 +99,7 @@ private struct LiquidAppearancePicker: View {
|
||||
HStack(spacing: 4) {
|
||||
ForEach(AppAppearance.allCases) { appearance in
|
||||
Button {
|
||||
// Theme changes must not animate the native split view / Form hierarchy.
|
||||
// Theme changes must not animate the native tab view / Form hierarchy.
|
||||
selection = appearance
|
||||
} label: {
|
||||
Label(appearance.title, systemImage: appearance.symbol)
|
||||
@@ -215,23 +150,6 @@ private extension AppAppearance {
|
||||
}
|
||||
}
|
||||
|
||||
private enum SettingsPage: String, CaseIterable, Identifiable {
|
||||
case appearance, language, monitoring, about
|
||||
var id: String { rawValue }
|
||||
var title: LocalizedStringKey {
|
||||
switch self {
|
||||
case .appearance: "settings.appearance"
|
||||
case .language: "settings.language"
|
||||
case .monitoring: "settings.monitoring"
|
||||
case .about: "settings.about"
|
||||
}
|
||||
}
|
||||
var symbol: String {
|
||||
switch self {
|
||||
case .appearance: "paintpalette"
|
||||
case .language: "globe"
|
||||
case .monitoring: "timer"
|
||||
case .about: "info.circle"
|
||||
}
|
||||
}
|
||||
private enum SettingsPage: Hashable {
|
||||
case general, about
|
||||
}
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
import AppKit
|
||||
import OSLog
|
||||
|
||||
@MainActor final class CustomColorPicker: NSObject {
|
||||
private let logger = Logger(subsystem: "cn.airnan.kymo", category: "color-picker")
|
||||
private static weak var owner: CustomColorPicker?
|
||||
private var preferences: AppearancePreferences?
|
||||
|
||||
func show(for preferences: AppearancePreferences) {
|
||||
logger.info("Custom color panel requested")
|
||||
Self.owner = self
|
||||
self.preferences = preferences
|
||||
let panel = NSColorPanel.shared
|
||||
panel.appearance = preferences.appearance.windowAppearance
|
||||
panel.showsAlpha = false
|
||||
panel.isContinuous = true
|
||||
panel.color = NSColor(srgbRed: preferences.red, green: preferences.green,
|
||||
blue: preferences.blue, alpha: 1)
|
||||
panel.setTarget(self)
|
||||
panel.setAction(#selector(colorChanged(_:)))
|
||||
NSApp.activate()
|
||||
panel.level = .floating
|
||||
panel.makeKeyAndOrderFront(nil)
|
||||
panel.orderFrontRegardless()
|
||||
logger.info("Custom color panel visible: \(panel.isVisible, privacy: .public)")
|
||||
}
|
||||
|
||||
@objc private func colorChanged(_ sender: NSColorPanel) {
|
||||
guard let preferences, let rgb = sender.color.usingColorSpace(.sRGB) else { return }
|
||||
preferences.red = rgb.redComponent
|
||||
preferences.green = rgb.greenComponent
|
||||
preferences.blue = rgb.blueComponent
|
||||
}
|
||||
|
||||
func close() {
|
||||
guard Self.owner === self else { return }
|
||||
NSColorPanel.shared.setTarget(nil)
|
||||
NSColorPanel.shared.setAction(nil)
|
||||
NSColorPanel.shared.close()
|
||||
preferences = nil
|
||||
Self.owner = nil
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
import SwiftUI
|
||||
import AppKit
|
||||
|
||||
/// A native hit target avoids Form/plain-Button hit-testing ambiguity on the swatch.
|
||||
struct CustomColorWell: NSViewRepresentable {
|
||||
let preferences: AppearancePreferences
|
||||
let picker: CustomColorPicker
|
||||
@Environment(\.locale) private var locale
|
||||
|
||||
func makeNSView(context: Context) -> SwatchButton {
|
||||
let button = SwatchButton()
|
||||
return button
|
||||
}
|
||||
|
||||
func updateNSView(_ button: SwatchButton, context: Context) {
|
||||
button.setAccessibilityLabel(AppLocalization.string("accent.custom", locale: locale))
|
||||
button.open = { picker.show(for: preferences) }
|
||||
button.swatchColor = NSColor(srgbRed: preferences.red, green: preferences.green, blue: preferences.blue, alpha: 1)
|
||||
}
|
||||
|
||||
func sizeThatFits(_ proposal: ProposedViewSize, nsView: SwatchButton, context: Context) -> CGSize? {
|
||||
CGSize(width: 44, height: 26)
|
||||
}
|
||||
|
||||
final class SwatchButton: NSButton {
|
||||
var swatchColor = NSColor.systemBlue { didSet { needsDisplay = true } }
|
||||
override var intrinsicContentSize: NSSize { NSSize(width: 44, height: 26) }
|
||||
|
||||
override func draw(_ dirtyRect: NSRect) {
|
||||
// Draw the actual RGB color inside bounds; no scalable SF Symbol/cell image.
|
||||
let shape = NSBezierPath(roundedRect: bounds.insetBy(dx: 4, dy: 4), xRadius: 4, yRadius: 4)
|
||||
(isHighlighted ? swatchColor.withAlphaComponent(0.7) : swatchColor).setFill()
|
||||
shape.fill()
|
||||
NSColor.separatorColor.setStroke()
|
||||
shape.lineWidth = 1
|
||||
shape.stroke()
|
||||
}
|
||||
|
||||
var open: () -> Void = {}
|
||||
override init(frame frameRect: NSRect) {
|
||||
super.init(frame: frameRect)
|
||||
bezelStyle = .rounded
|
||||
isBordered = false
|
||||
wantsLayer = true
|
||||
layer?.masksToBounds = true
|
||||
title = ""
|
||||
target = self
|
||||
action = #selector(openPicker)
|
||||
}
|
||||
required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
|
||||
override func acceptsFirstMouse(for event: NSEvent?) -> Bool { true }
|
||||
@objc func openPicker() { open() }
|
||||
}
|
||||
}
|
||||
@@ -133,213 +133,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"accent.blue" : {
|
||||
"extractionState" : "manual",
|
||||
"localizations" : {
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Blue"
|
||||
}
|
||||
},
|
||||
"zh-Hans" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "蓝色"
|
||||
}
|
||||
},
|
||||
"zh-Hant" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "藍色"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"accent.custom" : {
|
||||
"extractionState" : "manual",
|
||||
"localizations" : {
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Custom color"
|
||||
}
|
||||
},
|
||||
"zh-Hans" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "自选颜色"
|
||||
}
|
||||
},
|
||||
"zh-Hant" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "自選顏色"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"accent.green" : {
|
||||
"extractionState" : "manual",
|
||||
"localizations" : {
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Green"
|
||||
}
|
||||
},
|
||||
"zh-Hans" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "绿色"
|
||||
}
|
||||
},
|
||||
"zh-Hant" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "綠色"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"accent.orange" : {
|
||||
"extractionState" : "manual",
|
||||
"localizations" : {
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Orange"
|
||||
}
|
||||
},
|
||||
"zh-Hans" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "橙色"
|
||||
}
|
||||
},
|
||||
"zh-Hant" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "橘色"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"accent.pink" : {
|
||||
"extractionState" : "manual",
|
||||
"localizations" : {
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Pink"
|
||||
}
|
||||
},
|
||||
"zh-Hans" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "粉色"
|
||||
}
|
||||
},
|
||||
"zh-Hant" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "粉紅色"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"accent.purple" : {
|
||||
"extractionState" : "manual",
|
||||
"localizations" : {
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Purple"
|
||||
}
|
||||
},
|
||||
"zh-Hans" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "紫色"
|
||||
}
|
||||
},
|
||||
"zh-Hant" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "紫色"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"accent.system" : {
|
||||
"extractionState" : "manual",
|
||||
"localizations" : {
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "System accent"
|
||||
}
|
||||
},
|
||||
"zh-Hans" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "系统强调色"
|
||||
}
|
||||
},
|
||||
"zh-Hant" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "系統強調色"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"accent.teal" : {
|
||||
"extractionState" : "manual",
|
||||
"localizations" : {
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Teal"
|
||||
}
|
||||
},
|
||||
"zh-Hans" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "青色"
|
||||
}
|
||||
},
|
||||
"zh-Hant" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "青色"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"accent.title" : {
|
||||
"extractionState" : "manual",
|
||||
"localizations" : {
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Accent color"
|
||||
}
|
||||
},
|
||||
"zh-Hans" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "强调色"
|
||||
}
|
||||
},
|
||||
"zh-Hant" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "強調色"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"action.closeWindow" : {
|
||||
"extractionState" : "manual",
|
||||
"localizations" : {
|
||||
@@ -4295,6 +4088,28 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"settings.general" : {
|
||||
"localizations" : {
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "General"
|
||||
}
|
||||
},
|
||||
"zh-Hans" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "常规"
|
||||
}
|
||||
},
|
||||
"zh-Hant" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "一般"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"version" : "1.0"
|
||||
|
||||
@@ -16,21 +16,6 @@ extension AppAppearance {
|
||||
}
|
||||
}
|
||||
|
||||
extension AppearancePreferences {
|
||||
var tintColor: Color {
|
||||
switch accent {
|
||||
case .system: .accentColor
|
||||
case .blue: .blue
|
||||
case .purple: .purple
|
||||
case .teal: .teal
|
||||
case .green: .green
|
||||
case .orange: .orange
|
||||
case .pink: .pink
|
||||
case .custom: Color(red: red, green: green, blue: blue)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct AppearanceStyle: ViewModifier {
|
||||
let preferences: AppearancePreferences
|
||||
var refreshContentOnChange = false
|
||||
@@ -39,13 +24,13 @@ struct AppearanceStyle: ViewModifier {
|
||||
private var scheme: ColorScheme { resolved == .dark ? .dark : .light }
|
||||
func body(content: Content) -> some View {
|
||||
content
|
||||
// Settings split-view hosts can retain their previous native appearance.
|
||||
// Settings native hosts can retain their previous native appearance.
|
||||
// Keep state in the owning view, but replace the hosted subtree on a resolved theme change.
|
||||
.id(refreshContentOnChange ? resolved : nil)
|
||||
.background(WindowAppearanceBridge(choice: resolved))
|
||||
.preferredColorScheme(scheme)
|
||||
.environment(\.colorScheme, scheme)
|
||||
.tint(preferences.tintColor)
|
||||
.tint(.blue)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ struct IntervalControl: View {
|
||||
var body: some View {
|
||||
HStack(spacing: 3) {
|
||||
TextField("sampling.seconds", text: $text)
|
||||
.labelsHidden()
|
||||
.textFieldStyle(.roundedBorder).multilineTextAlignment(.trailing)
|
||||
.frame(width: 64).focused($focused)
|
||||
.onChange(of: text) { _, value in
|
||||
@@ -21,7 +22,10 @@ struct IntervalControl: View {
|
||||
}
|
||||
.onSubmit { commit() }
|
||||
Text("sampling.unit").foregroundStyle(.secondary).fixedSize()
|
||||
Stepper("sampling.interval", value: $milliseconds, in: range, step: step).labelsHidden().fixedSize()
|
||||
Stepper("sampling.interval", value: Binding(get: { milliseconds }, set: {
|
||||
milliseconds = $0
|
||||
synchronize()
|
||||
}), in: range, step: step).labelsHidden().fixedSize()
|
||||
}
|
||||
.font(.system(size: 11)).monospacedDigit().controlSize(.small)
|
||||
.fixedSize(horizontal: true, vertical: false)
|
||||
|
||||
Reference in New Issue
Block a user