Made visual improvements to the RecordingView view in the Recording package target.
This commit is contained in:
@@ -51,9 +51,10 @@ struct RecordingButtonStyle: ButtonStyle {
|
||||
width: size,
|
||||
height: size
|
||||
)
|
||||
.scaledToFit()
|
||||
.padding(padding)
|
||||
.scaledToFit()
|
||||
.foregroundStyle(.windowBackground)
|
||||
.foregroundStyle(.windowBackground.opacity(opacity))
|
||||
.environment(
|
||||
\.colorScheme,
|
||||
colorSchemeLabel
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user