live activity: always render full card (drop compact fallback)
Long station names inflated richBody's IDEAL width, so ViewThatFits (which measures ideal, untruncated text) decided 'rich doesn't fit' and fell back to the compact strip — that's why 5-mi / long-named activities rendered small while 10-15-mi / short names stayed full. With .supplementalActivityFamilies already removed, the body is only ever Lock-Screen width, so drop ViewThatFits and compactBody entirely and always render the full three-column card; the station caption line-limits + scale-downs + tail-truncates in place.
This commit is contained in:
@@ -62,25 +62,19 @@ struct FuelBoardLiveActivity: Widget {
|
|||||||
private struct FuelBoardLiveActivityView: View {
|
private struct FuelBoardLiveActivityView: View {
|
||||||
let context: ActivityViewContext<FuelBoardLiveActivityAttributes>
|
let context: ActivityViewContext<FuelBoardLiveActivityAttributes>
|
||||||
|
|
||||||
/// Full rich layout needs at least this much width. iPhone/iPad Lock
|
|
||||||
/// Screen Live Activities are always wider than this, so they get the
|
|
||||||
/// full view; the CarPlay/Apple Watch Smart Stack small slot is far
|
|
||||||
/// narrower, so it reliably falls through to `compactBody`.
|
|
||||||
private let richMinWidth: CGFloat = 290
|
|
||||||
/// Only genuinely small slots get the compact strip — cap it so a
|
|
||||||
/// mid-width surface can never squeeze the full view into the car.
|
|
||||||
private let compactMaxWidth: CGFloat = 220
|
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
Link(destination: context.state.mapsURL) {
|
Link(destination: context.state.mapsURL) {
|
||||||
ViewThatFits(in: .horizontal) {
|
// Always the full three-column card. The station caption is
|
||||||
// rich first — wins on full-width Lock Screen / banner
|
// line-limited + scale-down + tail-truncated, so a LONG station
|
||||||
|
// name truncates in place instead of inflating this view's ideal
|
||||||
|
// width and tricking ViewThatFits into falling back to the compact
|
||||||
|
// strip (that is exactly what made 5-mi / long-named activities
|
||||||
|
// render small while 10-15-mi / short names stayed full).
|
||||||
|
//
|
||||||
|
// No ViewThatFits / compactBody: with `.supplementalActivityFamilies`
|
||||||
|
// removed, this body is only ever handed Lock-Screen width, so the
|
||||||
|
// compact fallback was both dead weight and the cause of the bug.
|
||||||
richBody
|
richBody
|
||||||
.frame(minWidth: richMinWidth)
|
|
||||||
// compact fallback — the car's small supplemental slot
|
|
||||||
compactBody
|
|
||||||
.frame(maxWidth: compactMaxWidth)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,32 +113,7 @@ private struct FuelBoardLiveActivityView: View {
|
|||||||
.padding()
|
.padding()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Minimal strip for the small CarPlay / Watch Smart Stack slot:
|
// NOTE: `compactBody` was removed — always render `richBody` (see body).
|
||||||
/// glyph + fuel left, bold price right, truncated station below.
|
|
||||||
private var compactBody: some View {
|
|
||||||
VStack(alignment: .leading, spacing: 3) {
|
|
||||||
HStack(spacing: 5) {
|
|
||||||
Image(systemName: "fuelpump.fill")
|
|
||||||
.font(.caption2)
|
|
||||||
.foregroundStyle(.green)
|
|
||||||
Text(context.state.fuel.displayName)
|
|
||||||
.font(.caption2.weight(.semibold))
|
|
||||||
.lineLimit(1)
|
|
||||||
Spacer(minLength: 4)
|
|
||||||
FuelStore.priceTextAttributed(context.state.pricePence,
|
|
||||||
style: context.state.priceDisplayStyle,
|
|
||||||
size: 15, weight: .bold)
|
|
||||||
.lineLimit(1)
|
|
||||||
}
|
|
||||||
Text("\(context.state.stationName) · \(context.state.distanceText)")
|
|
||||||
.font(.system(size: 9))
|
|
||||||
.foregroundStyle(.secondary)
|
|
||||||
.lineLimit(1)
|
|
||||||
.minimumScaleFactor(0.7)
|
|
||||||
.truncationMode(.tail)
|
|
||||||
}
|
|
||||||
.padding(8)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Dynamic Island expanded regions + compact trailing — price only.
|
/// Dynamic Island expanded regions + compact trailing — price only.
|
||||||
|
|||||||
Reference in New Issue
Block a user