From 7a7dbaecab9efba03ae2b6e31cd6d0874875b012 Mon Sep 17 00:00:00 2001 From: Beingpax Date: Fri, 17 Oct 2025 13:11:51 +0545 Subject: [PATCH] Remove the power mode UI by default. --- VoiceInk/Views/ContentView.swift | 28 ++++----- .../Views/Recorder/MiniRecorderView.swift | 2 - .../Views/Recorder/RecorderComponents.swift | 2 +- .../Settings/PowerModeSettingsSection.swift | 62 +++++++++++++++++++ VoiceInk/Views/Settings/SettingsView.swift | 4 +- VoiceInk/VoiceInk.swift | 10 +-- 6 files changed, 85 insertions(+), 23 deletions(-) create mode 100644 VoiceInk/Views/Settings/PowerModeSettingsSection.swift diff --git a/VoiceInk/Views/ContentView.swift b/VoiceInk/Views/ContentView.swift index 4736d4b..1dcc2e4 100644 --- a/VoiceInk/Views/ContentView.swift +++ b/VoiceInk/Views/ContentView.swift @@ -55,8 +55,18 @@ struct DynamicSidebar: View { @Binding var selectedView: ViewType @Binding var hoveredView: ViewType? @Environment(\.colorScheme) private var colorScheme + @AppStorage("powerModeUIFlag") private var powerModeUIFlag = false @StateObject private var licenseViewModel = LicenseViewModel() @Namespace private var buttonAnimation + + private var visibleViewTypes: [ViewType] { + ViewType.allCases.filter { viewType in + if viewType == .powerMode { + return powerModeUIFlag + } + return true + } + } var body: some View { VStack(spacing: 15) { @@ -89,7 +99,7 @@ struct DynamicSidebar: View { .padding(.vertical, 12) // Navigation Items - ForEach(ViewType.allCases, id: \.self) { viewType in + ForEach(visibleViewTypes, id: \.self) { viewType in DynamicSidebarButton( title: viewType.rawValue, systemImage: viewType.icon, @@ -159,6 +169,7 @@ struct ContentView: View { @Environment(\.colorScheme) private var colorScheme @EnvironmentObject private var whisperState: WhisperState @EnvironmentObject private var hotkeyManager: HotkeyManager + @AppStorage("powerModeUIFlag") private var powerModeUIFlag = false @State private var selectedView: ViewType = .metrics @State private var hoveredView: ViewType? @State private var hasLoadedData = false @@ -195,38 +206,27 @@ struct ContentView: View { } // inside ContentView body: .onReceive(NotificationCenter.default.publisher(for: .navigateToDestination)) { notification in - print("ContentView: Received navigation notification") if let destination = notification.userInfo?["destination"] as? String { - print("ContentView: Destination received: \(destination)") switch destination { case "Settings": - print("ContentView: Navigating to Settings") selectedView = .settings case "AI Models": - print("ContentView: Navigating to AI Models") selectedView = .models case "VoiceInk Pro": - print("ContentView: Navigating to VoiceInk Pro") selectedView = .license case "History": - print("ContentView: Navigating to History") selectedView = .history case "Permissions": - print("ContentView: Navigating to Permissions") selectedView = .permissions case "Enhancement": - print("ContentView: Navigating to Enhancement") selectedView = .enhancement case "Transcribe Audio": - // Ensure we switch to the Transcribe Audio view in-place - print("ContentView: Navigating to Transcribe Audio") selectedView = .transcribeAudio + case "Power Mode": + selectedView = .powerMode default: - print("ContentView: No matching destination found for: \(destination)") break } - } else { - print("ContentView: No destination in notification") } } } diff --git a/VoiceInk/Views/Recorder/MiniRecorderView.swift b/VoiceInk/Views/Recorder/MiniRecorderView.swift index 6a6e888..81163d8 100644 --- a/VoiceInk/Views/Recorder/MiniRecorderView.swift +++ b/VoiceInk/Views/Recorder/MiniRecorderView.swift @@ -74,5 +74,3 @@ struct MiniRecorderView: View { } } } - - diff --git a/VoiceInk/Views/Recorder/RecorderComponents.swift b/VoiceInk/Views/Recorder/RecorderComponents.swift index 6cc2706..6137cc1 100644 --- a/VoiceInk/Views/Recorder/RecorderComponents.swift +++ b/VoiceInk/Views/Recorder/RecorderComponents.swift @@ -318,4 +318,4 @@ struct RecorderStatusDisplay: View { } } } -} \ No newline at end of file +} diff --git a/VoiceInk/Views/Settings/PowerModeSettingsSection.swift b/VoiceInk/Views/Settings/PowerModeSettingsSection.swift new file mode 100644 index 0000000..6ff2ab5 --- /dev/null +++ b/VoiceInk/Views/Settings/PowerModeSettingsSection.swift @@ -0,0 +1,62 @@ +import SwiftUI + +struct PowerModeSettingsSection: View { + @ObservedObject private var powerModeManager = PowerModeManager.shared + @AppStorage("powerModeUIFlag") private var powerModeUIFlag = false + @State private var showDisableAlert = false + + var body: some View { + VStack(alignment: .leading, spacing: 12) { + HStack(spacing: 12) { + Image(systemName: "sparkles.square.fill.on.square") + .font(.system(size: 20)) + .foregroundColor(.accentColor) + .frame(width: 24, height: 24) + + VStack(alignment: .leading, spacing: 2) { + Text("Power Mode") + .font(.headline) + Text("Enable to automatically apply custom configurations based on the app or website you are using.") + .font(.subheadline) + .foregroundColor(.secondary) + } + + Spacer() + + Toggle("Enable Power Mode", isOn: toggleBinding) + .labelsHidden() + .toggleStyle(.switch) + } + } + .padding(16) + .frame(maxWidth: .infinity, alignment: .leading) + .background(CardBackground(isSelected: false, useAccentGradientWhenSelected: true)) + .alert("Power Mode Still Active", isPresented: $showDisableAlert) { + Button("Got it", role: .cancel) { } + } message: { + Text("Power Mode can't be disabled while any configuration is still enabled. Disable or remove your Power Modes first.") + } + } + + private var toggleBinding: Binding { + Binding( + get: { powerModeUIFlag }, + set: { newValue in + if newValue { + powerModeUIFlag = true + } else if powerModeManager.configurations.noneEnabled { + powerModeUIFlag = false + } else { + showDisableAlert = true + } + } + ) + } + +} + +private extension Array where Element == PowerModeConfig { + var noneEnabled: Bool { + allSatisfy { !$0.isEnabled } + } +} diff --git a/VoiceInk/Views/Settings/SettingsView.swift b/VoiceInk/Views/Settings/SettingsView.swift index 41a1efd..481ae34 100644 --- a/VoiceInk/Views/Settings/SettingsView.swift +++ b/VoiceInk/Views/Settings/SettingsView.swift @@ -243,6 +243,8 @@ struct SettingsView: View { } } + PowerModeSettingsSection() + ExperimentalFeaturesSection() SettingsSection( @@ -529,5 +531,3 @@ extension Text { .fixedSize(horizontal: false, vertical: true) } } - - diff --git a/VoiceInk/VoiceInk.swift b/VoiceInk/VoiceInk.swift index bbaad7b..87ff8f1 100644 --- a/VoiceInk/VoiceInk.swift +++ b/VoiceInk/VoiceInk.swift @@ -30,7 +30,12 @@ struct VoiceInkApp: App { init() { // Configure FluidAudio logging subsystem AppLogger.defaultSubsystem = "com.prakashjoshipax.voiceink.parakeet" - + + if UserDefaults.standard.object(forKey: "powerModeUIFlag") == nil { + let hasEnabledPowerModes = PowerModeManager.shared.configurations.contains { $0.isEnabled } + UserDefaults.standard.set(hasEnabledPowerModes, forKey: "powerModeUIFlag") + } + do { let schema = Schema([ Transcription.self @@ -255,6 +260,3 @@ struct WindowAccessor: NSViewRepresentable { func updateNSView(_ nsView: NSView, context: Context) {} } - - -