From 21d86cdc33741288c0a3151bbe39678db07d2d8a Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Sun, 5 Jul 2026 14:30:48 +0200 Subject: [PATCH] Made visual improvements to the RecordingView view in the Recording package target. --- .../Styles/Buttons/RecordingButtonStyle.swift | 3 +- .../View Models/RecordingViewModel.swift | 9 ++--- .../Recording/Views/RecordingView.swift | 35 ++++++++++--------- .../View Models/RecordingViewModelTests.swift | 6 ++-- 4 files changed, 25 insertions(+), 28 deletions(-) diff --git a/Packages/Features/Sources/Recording/Styles/Buttons/RecordingButtonStyle.swift b/Packages/Features/Sources/Recording/Styles/Buttons/RecordingButtonStyle.swift index 36fa0c7..3ef942b 100644 --- a/Packages/Features/Sources/Recording/Styles/Buttons/RecordingButtonStyle.swift +++ b/Packages/Features/Sources/Recording/Styles/Buttons/RecordingButtonStyle.swift @@ -51,9 +51,10 @@ struct RecordingButtonStyle: ButtonStyle { width: size, height: size ) + .scaledToFit() .padding(padding) .scaledToFit() - .foregroundStyle(.windowBackground) + .foregroundStyle(.windowBackground.opacity(opacity)) .environment( \.colorScheme, colorSchemeLabel diff --git a/Packages/Features/Sources/Recording/View Models/RecordingViewModel.swift b/Packages/Features/Sources/Recording/View Models/RecordingViewModel.swift index 4298bf6..e7a95ae 100644 --- a/Packages/Features/Sources/Recording/View Models/RecordingViewModel.swift +++ b/Packages/Features/Sources/Recording/View Models/RecordingViewModel.swift @@ -108,13 +108,8 @@ extension RecordingView { state == .processing } - /// Whether the discard button should be visible. - var shouldShowDiscard: Bool { - state == .paused - } - - /// Whether the send button should be visible. - var shouldShowSend: Bool { + /// Whether the action buttons (send and discard) should be visible. + var shouldShowActions: Bool { state != .notRecording && state != .recording } diff --git a/Packages/Features/Sources/Recording/Views/RecordingView.swift b/Packages/Features/Sources/Recording/Views/RecordingView.swift index 8040f11..61a6deb 100644 --- a/Packages/Features/Sources/Recording/Views/RecordingView.swift +++ b/Packages/Features/Sources/Recording/Views/RecordingView.swift @@ -82,7 +82,6 @@ public struct RecordingView: View { } label: { Image(model.iconMain) .resizable() - .scaledToFit() } .buttonStyle(.recording( invertStyle: true @@ -90,21 +89,7 @@ public struct RecordingView: View { .disabled(model.shouldDisableMain) .accessibilityLabel(labelMain) - if model.shouldShowDiscard { - Button { - model.pressedDiscard() - } label: { - Image(systemName: Constant.Symbol.discard) - .resizable() - .scaledToFit() - } - .buttonStyle(.recording( - invertStyle: true - )) - .accessibilityLabel(Constant.Text.labelDiscard) - } - - if model.shouldShowSend { + if model.shouldShowActions { Button { model.pressedSend() } label: { @@ -120,10 +105,26 @@ public struct RecordingView: View { )) .disabled(model.isProcessing) .accessibilityLabel(labelSend) + + Button { + model.pressedDiscard() + } label: { + Image(systemName: Constant.Symbol.discard) + .resizable() + } + .buttonStyle(.recording( + invertStyle: true + )) + .disabled(model.shouldDisableMain) + .accessibilityLabel(Constant.Text.labelDiscard) } } } } + .animation( + .easeInOut, + value: model.state + ) .onChange( of: model.transcription, initial: false @@ -216,7 +217,7 @@ private enum Constant { /// The spacing constants. enum Spacing { /// The spacing between the elements of a stack. - static let stack: CGFloat = 8 + static let stack: CGFloat = 16 } /// The symbol constants. diff --git a/Packages/Features/Tests/Recording/View Models/RecordingViewModelTests.swift b/Packages/Features/Tests/Recording/View Models/RecordingViewModelTests.swift index cdc200b..c2e68be 100644 --- a/Packages/Features/Tests/Recording/View Models/RecordingViewModelTests.swift +++ b/Packages/Features/Tests/Recording/View Models/RecordingViewModelTests.swift @@ -153,7 +153,7 @@ struct RecordingViewModelTests { @Test(arguments: zip( [Model.State.notRecording, .recording, .paused, .processing], - [false, false, true, false] + [false, false, true, true] )) func `discard button is visible only while paused`( for state: Model.State, @@ -163,7 +163,7 @@ struct RecordingViewModelTests { model.drive(to: state) - #expect(model.shouldShowDiscard == expected) + #expect(model.shouldShowActions == expected) } @Test(arguments: zip( @@ -178,7 +178,7 @@ struct RecordingViewModelTests { model.drive(to: state) - #expect(model.shouldShowSend == expected) + #expect(model.shouldShowActions == expected) } @Test(arguments: zip(