-
Notifications
You must be signed in to change notification settings - Fork 2
fix: resolve app crash on hotkey press and add permission alerting #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
srlynch1
wants to merge
3
commits into
main
Choose a base branch
from
feature/real-world-testing
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,153 @@ | ||
| // OnboardingComponents.swift | ||
| // macOS Local Speech-to-Text Application | ||
| // | ||
| // Helper views for the onboarding flow | ||
|
|
||
| import SwiftUI | ||
|
|
||
| // MARK: - Feature Row | ||
|
|
||
| /// Row displaying a feature with icon and text | ||
| struct FeatureRow: View { | ||
| let icon: String | ||
| let text: String | ||
|
|
||
| var body: some View { | ||
| HStack(spacing: 12) { | ||
| Image(systemName: icon) | ||
| .foregroundStyle(Color("AmberPrimary", bundle: nil)) | ||
| Text(text) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // MARK: - Step Instruction | ||
|
|
||
| /// Numbered instruction step | ||
| struct StepInstruction: View { | ||
| let number: Int | ||
| let text: String | ||
|
|
||
| var body: some View { | ||
| HStack(alignment: .top, spacing: 8) { | ||
| Text("\(number).") | ||
| .fontWeight(.semibold) | ||
| Text(text) | ||
| } | ||
| .font(.callout) | ||
| } | ||
| } | ||
|
|
||
| // MARK: - Demo Instruction | ||
|
|
||
| /// Numbered demo instruction with green accent | ||
| struct DemoInstruction: View { | ||
| let number: Int | ||
| let text: String | ||
|
|
||
| var body: some View { | ||
| HStack(alignment: .top, spacing: 8) { | ||
| Text("\(number).") | ||
| .fontWeight(.semibold) | ||
| .foregroundStyle(.green) | ||
| Text(text) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // MARK: - Key Cap View | ||
|
|
||
| /// Keyboard key cap visualization | ||
| struct KeyCapView: View { | ||
| var symbol: String? | ||
| var text: String? | ||
|
|
||
| var body: some View { | ||
| Text(symbol ?? text ?? "") | ||
| .font(.title2) | ||
| .fontWeight(.medium) | ||
| .padding(.horizontal, 12) | ||
| .padding(.vertical, 8) | ||
| .background(Color.gray.opacity(0.2)) | ||
| .clipShape(RoundedRectangle(cornerRadius: 6)) | ||
| } | ||
| } | ||
|
|
||
| // MARK: - Quick Tip | ||
|
|
||
| /// Quick tip row with icon and text | ||
| struct QuickTip: View { | ||
| let icon: String | ||
| let text: String | ||
|
|
||
| var body: some View { | ||
| HStack(spacing: 12) { | ||
| Image(systemName: icon) | ||
| .foregroundStyle(.blue) | ||
| Text(text) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // MARK: - Permission Status Badge | ||
|
|
||
| /// Badge showing permission granted/missing status | ||
| struct PermissionStatusBadge: View { | ||
| let icon: String | ||
| let label: String | ||
| let isGranted: Bool | ||
|
|
||
| var body: some View { | ||
| VStack(spacing: 6) { | ||
| ZStack { | ||
| Circle() | ||
| .fill(isGranted ? Color.green.opacity(0.15) : Color.orange.opacity(0.15)) | ||
| .frame(width: 44, height: 44) | ||
|
|
||
| Image(systemName: icon) | ||
| .font(.system(size: 20)) | ||
| .foregroundStyle(isGranted ? .green : .orange) | ||
| } | ||
| .overlay(alignment: .bottomTrailing) { | ||
| Image(systemName: isGranted ? "checkmark.circle.fill" : "exclamationmark.circle.fill") | ||
| .font(.system(size: 14)) | ||
| .foregroundStyle(isGranted ? .green : .orange) | ||
| .background(Circle().fill(.white).padding(-2)) | ||
| } | ||
|
|
||
| Text(label) | ||
| .font(.caption2) | ||
| .foregroundStyle(.secondary) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // MARK: - Previews | ||
|
|
||
| #Preview("Feature Row") { | ||
| VStack(alignment: .leading, spacing: 12) { | ||
| FeatureRow(icon: "lock.shield.fill", text: "100% local processing") | ||
| FeatureRow(icon: "cpu.fill", text: "Apple Neural Engine powered") | ||
| } | ||
| .padding() | ||
| } | ||
|
|
||
| #Preview("Permission Status Badge") { | ||
| HStack(spacing: 16) { | ||
| PermissionStatusBadge(icon: "mic.fill", label: "Microphone", isGranted: true) | ||
| PermissionStatusBadge(icon: "hand.point.up.left.fill", label: "Accessibility", isGranted: false) | ||
| PermissionStatusBadge(icon: "keyboard.fill", label: "Input", isGranted: true) | ||
| } | ||
| .padding() | ||
| } | ||
|
|
||
| #Preview("Key Caps") { | ||
| HStack(spacing: 8) { | ||
| KeyCapView(symbol: "⌘") | ||
| Text("+") | ||
| KeyCapView(symbol: "⌃") | ||
| Text("+") | ||
| KeyCapView(text: "Space") | ||
| } | ||
| .padding() | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The URLs for system settings are hardcoded as string literals in the
showPermissionAlertcalls. To improve maintainability and avoid "magic strings", it's best practice to extract these into named constants. This makes the code easier to read and update if these URLs ever change.You could define them in a private
enumorstructlike this:Then you can use
SystemSettingsURL.microphoneandSystemSettingsURL.accessibilityin your function calls.