Remove the power mode UI by default.

This commit is contained in:
Beingpax 2025-10-17 13:11:51 +05:45
parent 81fb97f446
commit 7a7dbaecab
6 changed files with 85 additions and 23 deletions

View File

@ -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")
}
}
}

View File

@ -74,5 +74,3 @@ struct MiniRecorderView: View {
}
}
}

View File

@ -318,4 +318,4 @@ struct RecorderStatusDisplay: View {
}
}
}
}
}

View File

@ -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<Bool> {
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 }
}
}

View File

@ -243,6 +243,8 @@ struct SettingsView: View {
}
}
PowerModeSettingsSection()
ExperimentalFeaturesSection()
SettingsSection(
@ -529,5 +531,3 @@ extension Text {
.fixedSize(horizontal: false, vertical: true)
}
}

View File

@ -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) {}
}