Formatted the timer text for the RecordingView view in the Recording package target.

This commit is contained in:
2026-07-03 19:21:37 +02:00
parent cad0a570ac
commit 946fa76c63
3 changed files with 13 additions and 5 deletions
@@ -29,7 +29,15 @@ public struct RecordingView: View {
spacing: Constant.Spacing.stack
) {
if model.shouldShowTimer {
Text(model.timerText)
Text(model.textTimer)
.font(.largeTitle)
.fontWeight(.bold)
.monospacedDigit()
.contentTransition(.numericText())
.animation(
.easeInOut,
value: model.textTimer
)
}
HStack(
@@ -80,7 +88,7 @@ private enum Constant {
/// The spacing constants.
enum Spacing {
/// The spacing between the elements of a stack.
static let stack: CGFloat = 16
static let stack: CGFloat = 8
}
}
@@ -63,7 +63,7 @@ extension RecordingView {
}
/// The elapsed recording time, formatted as `mm:ss` for the timer label.
var timerText: String {
var textTimer: String {
Duration
.seconds(secondsElapsed)
.formatted(.time(pattern: .minuteSecond(padMinuteToLength: 2)))
@@ -19,7 +19,7 @@ struct RecordingViewModelTests {
#expect(model.state == .notRecording)
#expect(model.secondsElapsed == 0)
#expect(model.timerText == "00:00")
#expect(model.textTimer == "00:00")
}
}
@@ -179,7 +179,7 @@ struct RecordingViewModelTests {
try await Task.sleep(for: .seconds(1.2))
#expect(model.secondsElapsed >= 1)
#expect(model.timerText == "00:01")
#expect(model.textTimer == "00:01")
model.state = .notRecording
model.updatedState(shouldRestartTimer: false)