Refined the Recording Live Activity presentation in the Attendi widget target.

This commit is contained in:
2026-07-06 04:07:14 +02:00
parent a1a27a51c2
commit 0f889e22e4
3 changed files with 39 additions and 42 deletions
@@ -37,8 +37,8 @@ struct ActionButtonStyle: PrimitiveButtonStyle {
width: Constant.Size.icon.width, width: Constant.Size.icon.width,
height: Constant.Size.icon.height height: Constant.Size.icon.height
) )
.foregroundStyle(.primary)
.padding(Constant.Padding.icon) .padding(Constant.Padding.icon)
.foregroundStyle(.windowBackground)
.background { .background {
Circle() Circle()
.foregroundStyle(backgroundColor) .foregroundStyle(backgroundColor)
@@ -18,12 +18,11 @@ struct RecordingLiveActivityView: View {
alignment: .center, alignment: .center,
spacing: Constant.Spacing.stack spacing: Constant.Spacing.stack
) { ) {
RecordingStateLabel(state: state)
RecordingTimerText(state: state) RecordingTimerText(state: state)
.font(.largeTitle) .font(.largeTitle)
.fontWeight(.bold) .fontWeight(.bold)
.monospacedDigit()
RecordingStateLabel(state: state)
RecordingControls(state: state) RecordingControls(state: state)
} }
@@ -35,35 +34,11 @@ struct RecordingLiveActivityView: View {
/// The constant values used across the recording Live Activity. /// The constant values used across the recording Live Activity.
private enum Constant { private enum Constant {
/// The size constants.
enum Size {
/// The maximum width of the timer in the compact trailing presentation of the Dynamic Island.
static let compactTimer: CGFloat = 44
}
/// 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 = 8
} }
/// The system symbol constants.
enum Symbol {
/// The symbol of the discard button.
static let discard = "trash"
/// The symbol marking the recording flow.
static let microphone = "mic.fill"
/// The symbol of the main button while recording.
static let pause = "pause.fill"
/// The symbol of the main button while paused.
static let record = "record.circle"
}
/// The time constants.
enum Time {
/// The span of the running timer, comfortably beyond the maximum lifetime of a Live Activity.
static let span: TimeInterval = 24 * 60 * 60
}
} }
// MARK: - Previews // MARK: - Previews
@@ -22,27 +22,49 @@ struct RecordingLiveActivity: Widget {
} dynamicIsland: { context in } dynamicIsland: { context in
DynamicIsland { DynamicIsland {
DynamicIslandExpandedRegion(.leading) { DynamicIslandExpandedRegion(.leading) {
RecordingStateLabel(state: context.state) RecordingStateLabel(
state: context.state
)
} }
DynamicIslandExpandedRegion(.trailing) { DynamicIslandExpandedRegion(.trailing) {
RecordingTimerText(state: context.state) RecordingTimerText(
.font(.title2) state: context.state
.fontWeight(.bold) )
.monospacedDigit()
} }
DynamicIslandExpandedRegion(.bottom) { DynamicIslandExpandedRegion(.bottom) {
RecordingControls(state: context.state) RecordingControls(
state: context.state
)
} }
} compactLeading: { } compactLeading: {
Image(systemName: Constant.Symbol.microphone) switch context.state.state {
.foregroundStyle(.red) case .paused:
Image.Symbol.pause
.foregroundStyle(.yellow)
case .processing:
Image.Symbol.send
.foregroundStyle(.green)
case .recording:
Image.Symbol.microphone
.foregroundStyle(.yellow)
}
} compactTrailing: { } compactTrailing: {
RecordingTimerText(state: context.state) RecordingTimerText(
.monospacedDigit() state: context.state
.frame(maxWidth: Constant.Size.compactTimer) )
.frame(maxWidth: Constant.Size.compactTimer)
} minimal: { } minimal: {
Image(systemName: Constant.Symbol.microphone) switch context.state.state {
.foregroundStyle(.red) case .paused:
Image.Symbol.pause
.foregroundStyle(.yellow)
case .processing:
Image.Symbol.send
.foregroundStyle(.green)
case .recording:
Image.Symbol.microphone
.foregroundStyle(.yellow)
}
} }
} }
} }