forked from mazdak/AudioWhisper
-
Notifications
You must be signed in to change notification settings - Fork 0
Design-fidelity follow-ups: cosmetic alignment, sidebar breakdown, mic-test banner #19
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
Merged
Merged
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
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,232 @@ | ||
| import SwiftUI | ||
|
|
||
| // MARK: - Mic Test Palette | ||
|
|
||
| /// Coral palette used by the mic-test banner. Mirrors the design prototype; | ||
| /// `coral` matches `DashboardTheme.accent` / `coralDeep` matches `accentDeep`. | ||
| private enum MicTestPalette { | ||
| static let coral = Color(red: 0.85, green: 0.45, blue: 0.30) | ||
| static let coralDeep = Color(red: 0.70, green: 0.34, blue: 0.23) | ||
| static let coralLite = Color(red: 0.91, green: 0.60, blue: 0.47) | ||
| static let sage = Color(red: 0.37, green: 0.66, blue: 0.46) | ||
| } | ||
|
|
||
| // MARK: - MicTestBanner | ||
|
|
||
| /// "Test with my voice" banner shown at the top of the Visuals tab. Captures | ||
| /// live mic audio and drives the shared `LivePreviewSampler` so every preview | ||
| /// reacts to the user's real voice. Nothing is recorded or persisted. | ||
| internal struct MicTestBanner: View { | ||
| let style: WaveformStyle | ||
| @ObservedObject var sampler: LivePreviewSampler | ||
| @ObservedObject var capture: MicTestCapture | ||
|
|
||
| private var isLive: Bool { capture.state == .live } | ||
|
|
||
| var body: some View { | ||
| HStack(alignment: .top, spacing: 16) { | ||
| previewTile | ||
| copyColumn | ||
| Spacer(minLength: 0) | ||
| actionButton | ||
| } | ||
| .padding(16) | ||
| .background( | ||
| RoundedRectangle(cornerRadius: 12) | ||
| .fill(Color.white) | ||
| ) | ||
| .overlay( | ||
| RoundedRectangle(cornerRadius: 12) | ||
| .stroke(isLive ? MicTestPalette.coral : DashboardTheme.rule, lineWidth: isLive ? 1 : 0.5) | ||
| ) | ||
| .shadow( | ||
| color: isLive ? MicTestPalette.coral.opacity(0.22) : Color.black.opacity(0.04), | ||
| radius: isLive ? 14 : 6, | ||
| y: isLive ? 0 : 2 | ||
| ) | ||
| } | ||
|
|
||
| // MARK: - Left: live preview | ||
|
|
||
| private var previewTile: some View { | ||
| VStack(spacing: 6) { | ||
| ZStack { | ||
| Color(red: 0.04, green: 0.04, blue: 0.04) | ||
| WaveformStylePreview(style: style, sampler: sampler) | ||
| .frame( | ||
| width: style.isRadial ? 96 : 122, | ||
| height: style.isRadial ? 96 : 64 | ||
| ) | ||
| } | ||
| .frame(width: 136, height: 80) | ||
| .clipShape(RoundedRectangle(cornerRadius: 8)) | ||
|
|
||
| HStack(spacing: 5) { | ||
| if isLive { | ||
| Circle() | ||
| .fill(MicTestPalette.coral) | ||
| .frame(width: 5, height: 5) | ||
| } | ||
| Text(isLive ? "Live" : "Preview") | ||
| .font(.system(size: 10, weight: .semibold)) | ||
| .tracking(0.4) | ||
| .foregroundStyle(isLive ? MicTestPalette.coral : DashboardTheme.inkMuted) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // MARK: - Middle: copy + meter | ||
|
|
||
| private var copyColumn: some View { | ||
| VStack(alignment: .leading, spacing: 5) { | ||
| Text(headline) | ||
| .font(DashboardTheme.Fonts.sans(15, weight: .semibold)) | ||
| .foregroundStyle(DashboardTheme.ink) | ||
|
|
||
| Text(subCopy) | ||
| .font(DashboardTheme.Fonts.sans(12, weight: .regular)) | ||
| .foregroundStyle(DashboardTheme.inkMuted) | ||
| .fixedSize(horizontal: false, vertical: true) | ||
|
|
||
| if isLive { | ||
| inputMeter | ||
| .padding(.top, 4) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private var inputMeter: some View { | ||
| HStack(spacing: 8) { | ||
| Text("Input") | ||
| .font(.system(size: 10, weight: .semibold)) | ||
| .tracking(0.4) | ||
| .textCase(.uppercase) | ||
| .foregroundStyle(DashboardTheme.inkLight) | ||
|
|
||
| GeometryReader { geo in | ||
| ZStack(alignment: .leading) { | ||
| Capsule() | ||
| .fill(DashboardTheme.rule.opacity(0.6)) | ||
| Capsule() | ||
| .fill(meterColor) | ||
| .frame(width: max(2, geo.size.width * CGFloat(min(1, capture.level)))) | ||
| } | ||
| } | ||
| .frame(width: 120, height: 6) | ||
|
|
||
| Text("\(Int((min(1, capture.level) * 100).rounded()))%") | ||
| .font(.system(size: 10, weight: .regular, design: .monospaced)) | ||
| .foregroundStyle(DashboardTheme.inkMuted) | ||
| } | ||
| } | ||
|
|
||
| private var meterColor: Color { | ||
| let level = capture.level | ||
| if level > 0.85 { return MicTestPalette.coralDeep } | ||
| if level > 0.5 { return MicTestPalette.coral } | ||
| return MicTestPalette.sage | ||
| } | ||
|
|
||
| // MARK: - Right: action button | ||
|
|
||
| private var actionButton: some View { | ||
| Button(action: toggle) { | ||
| HStack(spacing: 6) { | ||
| if isLive { | ||
| RoundedRectangle(cornerRadius: 2) | ||
| .fill(MicTestPalette.coral) | ||
| .frame(width: 9, height: 9) | ||
| } | ||
| Text(buttonTitle) | ||
| .font(DashboardTheme.Fonts.sans(13, weight: .semibold)) | ||
| } | ||
| .foregroundStyle(buttonForeground) | ||
| .padding(.horizontal, 16) | ||
| .padding(.vertical, 9) | ||
| .background(buttonBackground) | ||
| .overlay( | ||
| RoundedRectangle(cornerRadius: 8) | ||
| .stroke(isLive ? DashboardTheme.rule : Color.clear, lineWidth: 0.5) | ||
| ) | ||
| } | ||
| .buttonStyle(.plain) | ||
| } | ||
|
|
||
| @ViewBuilder | ||
| private var buttonBackground: some View { | ||
| if isLive { | ||
| RoundedRectangle(cornerRadius: 8).fill(Color.white) | ||
| } else { | ||
| RoundedRectangle(cornerRadius: 8) | ||
| .fill( | ||
| LinearGradient( | ||
| colors: [MicTestPalette.coralLite, MicTestPalette.coral], | ||
| startPoint: .top, | ||
| endPoint: .bottom | ||
| ) | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| private var buttonForeground: Color { | ||
| isLive ? DashboardTheme.ink : .white | ||
| } | ||
|
|
||
| private func toggle() { | ||
| if isLive { | ||
| capture.stop() | ||
| } else { | ||
| capture.start() | ||
| } | ||
| } | ||
|
|
||
| // MARK: - State-driven copy | ||
|
|
||
| private var headline: String { | ||
| switch capture.state { | ||
| case .off: | ||
| return "Test it with your voice." | ||
| case .live: | ||
| return capture.speaking ? "Looking good — keep going." : "Say something." | ||
| case .denied: | ||
| return "Microphone access blocked." | ||
| case .error: | ||
| return "Couldn't reach your microphone." | ||
| } | ||
| } | ||
|
|
||
| private var subCopy: String { | ||
| switch capture.state { | ||
| case .off: | ||
| return "Speak for a few seconds to see how each style responds to real " | ||
| + "audio. The mic is only used here — nothing is sent off-device." | ||
| case .live: | ||
| return "Switch styles below — the preview reacts in real time. Nothing is recorded." | ||
| case .denied: | ||
| return "Open System Settings → Privacy & Security → Microphone and allow AudioWhisper." | ||
| case .error(let reason): | ||
| return "Mic unavailable (\(reason)). Check that no other app is using it." | ||
| } | ||
| } | ||
|
|
||
| private var buttonTitle: String { | ||
| switch capture.state { | ||
| case .off: | ||
| return "Test with my voice" | ||
| case .live: | ||
| return "Stop" | ||
| case .denied, .error: | ||
| return "Try again" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #Preview("Mic test banner") { | ||
| MicTestBanner( | ||
| style: .classic, | ||
| sampler: LivePreviewSampler(), | ||
| capture: MicTestCapture(sampler: LivePreviewSampler()) | ||
| ) | ||
|
Comment on lines
+224
to
+229
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use one shared sampler in The preview currently gives 💡 Proposed fix `#Preview`("Mic test banner") {
+ let sampler = LivePreviewSampler()
MicTestBanner(
style: .classic,
- sampler: LivePreviewSampler(),
- capture: MicTestCapture(sampler: LivePreviewSampler())
+ sampler: sampler,
+ capture: MicTestCapture(sampler: sampler)
)🤖 Prompt for AI Agents |
||
| .padding(32) | ||
| .frame(width: 760) | ||
| } | ||
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.
🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: jtn0123/AudioWhisper
Length of output: 120
🏁 Script executed:
cat -n ./Sources/Views/Components/Waveform/MicTestBanner.swift | head -30Repository: jtn0123/AudioWhisper
Length of output: 1417
Annotate
MicTestBannerwith@MainActor.This view is a UI component in
Sources/**/*.swiftand should be explicitly main-actor isolated.💡 Proposed fix
As per coding guidelines,
Sources/**/*.swift: Use@MainActorannotation for UI components in Swift.📝 Committable suggestion
🤖 Prompt for AI Agents