Skip to content

Fastest and only macOS Dictation app with on-device STT and custom trained AI enhancement model. Windows, iOS testflight! Android, Linux waitlist open! A local Wispr Flow alternative. Follow https://x.com/fluidvoiceapp for more

refactor: centralize compact button variants

altic-devece2c93a8965
diff --git a/Sources/Fluid/Theme/NativeButtonStyles.swift b/Sources/Fluid/Theme/NativeButtonStyles.swift
index 589622f2..414e3792 100644
--- a/Sources/Fluid/Theme/NativeButtonStyles.swift
+++ b/Sources/Fluid/Theme/NativeButtonStyles.swift
@@ -41,7 +41,7 @@ enum FluidButtonSize: Equatable {
}
var accentCompact: Bool {
- self == .small
+ self == .small || self == .compact
}
}
@@ -81,6 +81,20 @@ extension View {
self.buttonStyle(InlineButtonStyle())
}
}
+
+ func fluidCompactButton(
+ size: FluidButtonSize = .compact,
+ isReady: Bool = false,
+ foreground: Color? = nil,
+ borderColor: Color? = nil
+ ) -> some View {
+ self.buttonStyle(CompactButtonStyle(
+ isReady: isReady,
+ foreground: foreground,
+ borderColor: borderColor,
+ height: size.controlHeight
+ ))
+ }
}
private struct FluidControlSurfaceModifier: ViewModifier {
diff --git a/Sources/Fluid/UI/AISettingsView+AIConfiguration.swift b/Sources/Fluid/UI/AISettingsView+AIConfiguration.swift
index ee19da22..a15c3560 100644
--- a/Sources/Fluid/UI/AISettingsView+AIConfiguration.swift
+++ b/Sources/Fluid/UI/AISettingsView+AIConfiguration.swift
@@ -1263,7 +1263,7 @@ extension AIEnhancementSettingsView {
}
.font(.caption)
}
- .buttonStyle(CompactButtonStyle(foreground: .red, borderColor: .red.opacity(0.6)))
+ .fluidCompactButton(foreground: .red, borderColor: .red.opacity(0.6))
}
}
})
@@ -1706,10 +1706,10 @@ extension AIEnhancementSettingsView {
Image(systemName: hasEnabledConfig ? "brain.fill" : "brain")
.font(.system(size: 12))
}
- .buttonStyle(CompactButtonStyle(
+ .fluidCompactButton(
foreground: hasEnabledConfig ? self.theme.palette.accent : nil,
borderColor: hasEnabledConfig ? self.theme.palette.accent.opacity(0.6) : nil
- ))
+ )
.frame(width: 28, height: 28)
.help("Configure reasoning parameters")
}
@@ -1867,7 +1867,7 @@ extension AIEnhancementSettingsView {
self.viewModel.resetVerification(for: self.viewModel.selectedProviderID)
self.viewModel.clearEditProviderDraft()
}
- .buttonStyle(CompactButtonStyle(foreground: .red, borderColor: .red.opacity(0.6)))
+ .fluidCompactButton(foreground: .red, borderColor: .red.opacity(0.6))
}
if !isBuiltIn {
@@ -1882,7 +1882,7 @@ extension AIEnhancementSettingsView {
}
.font(.caption)
}
- .buttonStyle(CompactButtonStyle(foreground: .red, borderColor: .red.opacity(0.6)))
+ .fluidCompactButton(foreground: .red, borderColor: .red.opacity(0.6))
}
}
}
@@ -1949,7 +1949,7 @@ extension AIEnhancementSettingsView {
Button(action: { self.viewModel.deleteSelectedModel() }) {
HStack(spacing: 4) { Image(systemName: "trash"); Text("Delete") }.font(.caption)
}
- .buttonStyle(CompactButtonStyle(foreground: .red, borderColor: .red.opacity(0.6)))
+ .fluidCompactButton(foreground: .red, borderColor: .red.opacity(0.6))
.frame(minWidth: AISettingsLayout.compactActionMinWidth, minHeight: AISettingsLayout.controlHeight)
}
@@ -1958,7 +1958,7 @@ extension AIEnhancementSettingsView {
self.viewModel.showingAddModel = true
self.viewModel.newModelName = ""
}
- .buttonStyle(CompactButtonStyle(isReady: true))
+ .fluidCompactButton(isReady: true)
.frame(minWidth: AISettingsLayout.wideActionMinWidth, minHeight: AISettingsLayout.controlHeight)
}
@@ -1969,10 +1969,10 @@ extension AIEnhancementSettingsView {
}
.font(.caption)
}
- .buttonStyle(CompactButtonStyle(
+ .fluidCompactButton(
foreground: self.viewModel.hasReasoningConfigForCurrentModel() ? self.theme.palette.accent : nil,
borderColor: self.viewModel.hasReasoningConfigForCurrentModel() ? self.theme.palette.accent.opacity(0.6) : nil
- ))
+ )
.frame(minWidth: AISettingsLayout.compactActionMinWidth, minHeight: AISettingsLayout.controlHeight)
}
}
@@ -1991,7 +1991,7 @@ extension AIEnhancementSettingsView {
}
}
Button("Add") { self.viewModel.addNewModel() }
- .buttonStyle(CompactButtonStyle(isReady: true))
+ .fluidCompactButton(isReady: true)
.frame(minWidth: AISettingsLayout.compactActionMinWidth, minHeight: AISettingsLayout.controlHeight)
.disabled(self.viewModel.newModelName.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty)
Button("Cancel") {
@@ -2172,7 +2172,7 @@ extension AIEnhancementSettingsView {
.font(.caption)
.fontWeight(.semibold)
}
- .buttonStyle(CompactButtonStyle(isReady: true))
+ .fluidCompactButton(isReady: true)
.frame(minWidth: AISettingsLayout.primaryActionMinWidth, minHeight: AISettingsLayout.controlHeight)
.disabled(self.viewModel.isTestingConnection ||
(!self.viewModel.isLocalEndpoint(self.viewModel.openAIBaseURL.trimmingCharacters(in: .whitespacesAndNewlines)) &&
@@ -2219,7 +2219,7 @@ extension AIEnhancementSettingsView {
Label("Add or Modify API Key", systemImage: "key.fill")
.labelStyle(.titleAndIcon).font(.caption)
}
- .buttonStyle(CompactButtonStyle(isReady: true))
+ .fluidCompactButton(isReady: true)
.frame(minWidth: AISettingsLayout.primaryActionMinWidth, minHeight: AISettingsLayout.controlHeight)
if let websiteInfo = ModelRepository.shared.providerWebsiteURL(for: self.viewModel.selectedProviderID),
diff --git a/Sources/Fluid/UI/AISettingsView+AdvancedSettings.swift b/Sources/Fluid/UI/AISettingsView+AdvancedSettings.swift
index 8e018a75..a054f64b 100644
--- a/Sources/Fluid/UI/AISettingsView+AdvancedSettings.swift
+++ b/Sources/Fluid/UI/AISettingsView+AdvancedSettings.swift
@@ -175,7 +175,7 @@ extension AIEnhancementSettingsView {
Button("+ Add Prompt") {
self.viewModel.openNewPromptEditor(prefillMode: self.selectedPromptMode)
}
- .buttonStyle(CompactButtonStyle(isReady: true))
+ .fluidCompactButton(isReady: true)
.frame(minWidth: AISettingsLayout.actionMinWidth, minHeight: AISettingsLayout.controlHeight)
Spacer(minLength: 8)
@@ -734,7 +734,7 @@ extension AIEnhancementSettingsView {
} label: {
Text("+ Add App")
}
- .buttonStyle(CompactButtonStyle(isReady: true))
+ .fluidCompactButton(isReady: true)
.frame(minHeight: 26)
.disabled(!isEnabled)
.opacity(isEnabled ? 1 : 0.48)