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,
|
width: size,
|
||||||
height: size
|
height: size
|
||||||
)
|
)
|
||||||
|
.scaledToFit()
|
||||||
.padding(padding)
|
.padding(padding)
|
||||||
.scaledToFit()
|
.scaledToFit()
|
||||||
.foregroundStyle(.windowBackground)
|
.foregroundStyle(.windowBackground.opacity(opacity))
|
||||||
.environment(
|
.environment(
|
||||||
\.colorScheme,
|
\.colorScheme,
|
||||||
colorSchemeLabel
|
colorSchemeLabel
|
||||||
|
|||||||
@@ -108,13 +108,8 @@ extension RecordingView {
|
|||||||
state == .processing
|
state == .processing
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Whether the discard button should be visible.
|
/// Whether the action buttons (send and discard) should be visible.
|
||||||
var shouldShowDiscard: Bool {
|
var shouldShowActions: Bool {
|
||||||
state == .paused
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Whether the send button should be visible.
|
|
||||||
var shouldShowSend: Bool {
|
|
||||||
state != .notRecording
|
state != .notRecording
|
||||||
&& state != .recording
|
&& state != .recording
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,7 +82,6 @@ public struct RecordingView: View {
|
|||||||
} label: {
|
} label: {
|
||||||
Image(model.iconMain)
|
Image(model.iconMain)
|
||||||
.resizable()
|
.resizable()
|
||||||
.scaledToFit()
|
|
||||||
}
|
}
|
||||||
.buttonStyle(.recording(
|
.buttonStyle(.recording(
|
||||||
invertStyle: true
|
invertStyle: true
|
||||||
@@ -90,21 +89,7 @@ public struct RecordingView: View {
|
|||||||
.disabled(model.shouldDisableMain)
|
.disabled(model.shouldDisableMain)
|
||||||
.accessibilityLabel(labelMain)
|
.accessibilityLabel(labelMain)
|
||||||
|
|
||||||
if model.shouldShowDiscard {
|
if model.shouldShowActions {
|
||||||
Button {
|
|
||||||
model.pressedDiscard()
|
|
||||||
} label: {
|
|
||||||
Image(systemName: Constant.Symbol.discard)
|
|
||||||
.resizable()
|
|
||||||
.scaledToFit()
|
|
||||||
}
|
|
||||||
.buttonStyle(.recording(
|
|
||||||
invertStyle: true
|
|
||||||
))
|
|
||||||
.accessibilityLabel(Constant.Text.labelDiscard)
|
|
||||||
}
|
|
||||||
|
|
||||||
if model.shouldShowSend {
|
|
||||||
Button {
|
Button {
|
||||||
model.pressedSend()
|
model.pressedSend()
|
||||||
} label: {
|
} label: {
|
||||||
@@ -120,10 +105,26 @@ public struct RecordingView: View {
|
|||||||
))
|
))
|
||||||
.disabled(model.isProcessing)
|
.disabled(model.isProcessing)
|
||||||
.accessibilityLabel(labelSend)
|
.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(
|
.onChange(
|
||||||
of: model.transcription,
|
of: model.transcription,
|
||||||
initial: false
|
initial: false
|
||||||
@@ -216,7 +217,7 @@ private enum Constant {
|
|||||||
/// The spacing constants.
|
/// The spacing constants.
|
||||||
enum Spacing {
|
enum Spacing {
|
||||||
/// The spacing between the elements of a stack.
|
/// The spacing between the elements of a stack.
|
||||||
static let stack: CGFloat = 8
|
static let stack: CGFloat = 16
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The symbol constants.
|
/// The symbol constants.
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ struct RecordingViewModelTests {
|
|||||||
|
|
||||||
@Test(arguments: zip(
|
@Test(arguments: zip(
|
||||||
[Model.State.notRecording, .recording, .paused, .processing],
|
[Model.State.notRecording, .recording, .paused, .processing],
|
||||||
[false, false, true, false]
|
[false, false, true, true]
|
||||||
))
|
))
|
||||||
func `discard button is visible only while paused`(
|
func `discard button is visible only while paused`(
|
||||||
for state: Model.State,
|
for state: Model.State,
|
||||||
@@ -163,7 +163,7 @@ struct RecordingViewModelTests {
|
|||||||
|
|
||||||
model.drive(to: state)
|
model.drive(to: state)
|
||||||
|
|
||||||
#expect(model.shouldShowDiscard == expected)
|
#expect(model.shouldShowActions == expected)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(arguments: zip(
|
@Test(arguments: zip(
|
||||||
@@ -178,7 +178,7 @@ struct RecordingViewModelTests {
|
|||||||
|
|
||||||
model.drive(to: state)
|
model.drive(to: state)
|
||||||
|
|
||||||
#expect(model.shouldShowSend == expected)
|
#expect(model.shouldShowActions == expected)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(arguments: zip(
|
@Test(arguments: zip(
|
||||||
|
|||||||
Reference in New Issue
Block a user