feat: Add Power Mode Toggle and update to version 0.96

This commit is contained in:
Beingpax 2025-03-01 13:24:02 +05:45
parent e390094b87
commit 1bff2d94ec
6 changed files with 108 additions and 73 deletions

View File

@ -13,7 +13,7 @@
<a href="https://www.youtube.com/@tryvoiceink">YouTube</a>
</p>
<a href="https://tryvoiceink.com">
<a href="https://tryvoiceink.com">w
<img src="https://img.shields.io/badge/Download%20Now-Latest%20Version-blue?style=for-the-badge&logo=apple" alt="Download VoiceInk" width="250"/>
</a>
</div>

View File

@ -468,7 +468,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 95;
CURRENT_PROJECT_VERSION = 96;
DEVELOPMENT_ASSET_PATHS = "\"VoiceInk/Preview Content\"";
DEVELOPMENT_TEAM = V6J6A3VWY2;
ENABLE_HARDENED_RUNTIME = YES;
@ -483,7 +483,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 0.95;
MARKETING_VERSION = 0.96;
PRODUCT_BUNDLE_IDENTIFIER = com.prakashjoshipax.VoiceInk;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
@ -501,7 +501,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 95;
CURRENT_PROJECT_VERSION = 96;
DEVELOPMENT_ASSET_PATHS = "\"VoiceInk/Preview Content\"";
DEVELOPMENT_TEAM = V6J6A3VWY2;
ENABLE_HARDENED_RUNTIME = YES;
@ -516,7 +516,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 0.95;
MARKETING_VERSION = 0.96;
PRODUCT_BUNDLE_IDENTIFIER = com.prakashjoshipax.VoiceInk;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;

View File

@ -30,11 +30,16 @@ class PowerModeManager: ObservableObject {
static let shared = PowerModeManager()
@Published var configurations: [PowerModeConfig] = []
@Published var defaultConfig: PowerModeConfig
@Published var isPowerModeEnabled: Bool
private let configKey = "powerModeConfigurations"
private let defaultConfigKey = "defaultPowerModeConfig"
private let powerModeEnabledKey = "isPowerModeEnabled"
private init() {
// Load power mode enabled state
self.isPowerModeEnabled = UserDefaults.standard.bool(forKey: powerModeEnabledKey)
// Initialize default config with default values
if let data = UserDefaults.standard.data(forKey: defaultConfigKey),
let config = try? JSONDecoder().decode(PowerModeConfig.self, from: data) {
@ -150,4 +155,9 @@ class PowerModeManager: ObservableObject {
}
}
}
// Save power mode enabled state
func savePowerModeEnabled() {
UserDefaults.standard.set(isPowerModeEnabled, forKey: powerModeEnabledKey)
}
}

View File

@ -57,22 +57,29 @@ class ActiveWindowService: ObservableObject {
guard let enhancementService = enhancementService else { return }
await MainActor.run {
// Apply AI enhancement settings
enhancementService.isEnhancementEnabled = config.isAIEnhancementEnabled
// Handle prompt selection
if config.isAIEnhancementEnabled {
if let promptId = config.selectedPrompt,
let uuid = UUID(uuidString: promptId) {
print("🎯 Applied Prompt: \(enhancementService.allPrompts.first(where: { $0.id == uuid })?.title ?? "Unknown")")
enhancementService.selectedPromptId = uuid
} else {
// Auto-select first prompt if none is selected and AI is enabled
if let firstPrompt = enhancementService.allPrompts.first {
print("🎯 Auto-selected Prompt: \(firstPrompt.title)")
enhancementService.selectedPromptId = firstPrompt.id
// Only apply settings if power mode is enabled globally
if PowerModeManager.shared.isPowerModeEnabled {
// Apply AI enhancement settings
enhancementService.isEnhancementEnabled = config.isAIEnhancementEnabled
// Handle prompt selection
if config.isAIEnhancementEnabled {
if let promptId = config.selectedPrompt,
let uuid = UUID(uuidString: promptId) {
print("🎯 Applied Prompt: \(enhancementService.allPrompts.first(where: { $0.id == uuid })?.title ?? "Unknown")")
enhancementService.selectedPromptId = uuid
} else {
// Auto-select first prompt if none is selected and AI is enabled
if let firstPrompt = enhancementService.allPrompts.first {
print("🎯 Auto-selected Prompt: \(firstPrompt.title)")
enhancementService.selectedPromptId = firstPrompt.id
}
}
}
} else {
// If power mode is disabled globally, disable AI enhancement
enhancementService.isEnhancementEnabled = false
print("🔌 Power Mode is disabled globally")
}
}
}

View File

@ -349,61 +349,80 @@ struct PowerModeView: View {
subtitle: "See Power Mode in action"
)
// Default Configuration Section
// Power Mode Toggle Section
VStack(alignment: .leading, spacing: 16) {
Text("Default Configuration")
.font(.headline)
ConfiguredAppRow(
config: powerModeManager.defaultConfig,
isEditing: configurationMode?.isEditingDefault ?? false,
action: {
configurationMode = .editDefault(powerModeManager.defaultConfig)
showingConfigSheet = true
}
)
.background(RoundedRectangle(cornerRadius: 8)
.fill(Color(.windowBackgroundColor).opacity(0.4)))
.overlay(RoundedRectangle(cornerRadius: 8)
.stroke(Color.accentColor.opacity(0.2), lineWidth: 1))
HStack {
Text("Enable Power Mode")
.font(.headline)
Spacer()
Toggle("", isOn: $powerModeManager.isPowerModeEnabled)
.toggleStyle(SwitchToggleStyle(tint: .blue))
.labelsHidden()
.scaleEffect(1.2)
.onChange(of: powerModeManager.isPowerModeEnabled) { _ in
powerModeManager.savePowerModeEnabled()
}
}
}
.padding(.horizontal)
// Apps Section
VStack(spacing: 16) {
if powerModeManager.configurations.isEmpty {
PowerModeEmptyStateView(
showAddModal: $showingConfigSheet,
configMode: $configurationMode
)
} else {
Text("Power Mode Configurations")
if powerModeManager.isPowerModeEnabled {
// Default Configuration Section
VStack(alignment: .leading, spacing: 16) {
Text("Default Configuration")
.font(.headline)
.frame(maxWidth: .infinity, alignment: .leading)
.padding(.horizontal)
ConfiguredAppsGrid(powerModeManager: powerModeManager)
Button(action: {
print("🔍 Add button clicked - Setting config mode and showing sheet")
configurationMode = .add
print("🔍 Configuration mode set to: \(String(describing: configurationMode))")
showingConfigSheet = true
print("🔍 showingConfigSheet set to: \(showingConfigSheet)")
}) {
HStack(spacing: 6) {
Image(systemName: "plus")
.font(.system(size: 12, weight: .semibold))
Text("Add New Mode")
.font(.system(size: 13, weight: .medium))
ConfiguredAppRow(
config: powerModeManager.defaultConfig,
isEditing: configurationMode?.isEditingDefault ?? false,
action: {
configurationMode = .editDefault(powerModeManager.defaultConfig)
showingConfigSheet = true
}
)
.background(RoundedRectangle(cornerRadius: 8)
.fill(Color(.windowBackgroundColor).opacity(0.4)))
.overlay(RoundedRectangle(cornerRadius: 8)
.stroke(Color.accentColor.opacity(0.2), lineWidth: 1))
}
.padding(.horizontal)
// Apps Section
VStack(spacing: 16) {
if powerModeManager.configurations.isEmpty {
PowerModeEmptyStateView(
showAddModal: $showingConfigSheet,
configMode: $configurationMode
)
} else {
Text("Power Mode Configurations")
.font(.headline)
.frame(maxWidth: .infinity, alignment: .leading)
.padding(.horizontal)
ConfiguredAppsGrid(powerModeManager: powerModeManager)
Button(action: {
print("🔍 Add button clicked - Setting config mode and showing sheet")
configurationMode = .add
print("🔍 Configuration mode set to: \(String(describing: configurationMode))")
showingConfigSheet = true
print("🔍 showingConfigSheet set to: \(showingConfigSheet)")
}) {
HStack(spacing: 6) {
Image(systemName: "plus")
.font(.system(size: 12, weight: .semibold))
Text("Add New Mode")
.font(.system(size: 13, weight: .medium))
}
}
.buttonStyle(.borderedProminent)
.controlSize(.regular)
.tint(Color(NSColor.controlAccentColor))
.frame(maxWidth: .infinity, alignment: .center)
.help("Add a new mode")
.padding(.top, 12)
}
.buttonStyle(.borderedProminent)
.controlSize(.regular)
.tint(Color(NSColor.controlAccentColor))
.frame(maxWidth: .infinity, alignment: .center)
.help("Add a new mode")
.padding(.top, 12)
}
}
}

View File

@ -3,19 +3,18 @@
<channel>
<title>VoiceInk Releases</title>
<item>
<title>0.95</title>
<title>0.96</title>
<pubDate>Thu, 20 Feb 2025 07:51:55 +0545</pubDate>
<sparkle:version>95</sparkle:version>
<sparkle:shortVersionString>0.95</sparkle:shortVersionString>
<sparkle:version>96</sparkle:version>
<sparkle:shortVersionString>0.96</sparkle:shortVersionString>
<sparkle:minimumSystemVersion>14.0</sparkle:minimumSystemVersion>
<description><![CDATA[
<h3>What's New in Version 0.95 🚀⚡</h3>
<h3>What's New in Version 0.96 🚀⚡</h3>
<ul>
<li>More stats in dashboard</li>
<li>Minor fixes & Improvements</li>
<li>Added Power Mode Toggle option</li>
</ul>
]]></description>
<enclosure url="https://github.com/Beingpax/VoiceInk/releases/download/v.0.95/VoiceInk.dmg" length="5721468" type="application/octet-stream" sparkle:edSignature="i/E5T4CGy55EGJfiESHdiQCC1Tre4caaTALKSWIhKBCNV3cG42IODEoTwVksVb6gGONwzu3NhUtPCOlMs24VCQ=="/>
<enclosure url="https://github.com/Beingpax/VoiceInk/releases/download/v0.96/VoiceInk.dmg" length="5729623" type="application/octet-stream" sparkle:edSignature="jlwFE/eSFNrjcTiq7aLfgrUXEGED8QolzzZZq6kFYd+ZQX2mQOa9zxh9ugowWTCMGg6AW9hFUpuVsTwtmPuQBQ=="/>
</item>
</channel>
</rss>