live activity: robust full-vs-compact split; scale long station names
The adaptive layout picks the full three-column view when there's Lock Screen width and a compact price strip in the small CarPlay/Watch slot. Tighten the discriminant (rich ≥290pt, compact ≤220pt) so iPhone/iPad always get the full view and only genuinely small slots get the compact strip. Long station names used to clip at inconsistent points across the rich/compact/Dynamic Island views; both bodies now scale + tail- truncate so the caption stays consistent regardless of station name.
This commit is contained in:
@@ -59,16 +59,24 @@ struct FuelBoardLiveActivity: Widget {
|
||||
private struct FuelBoardLiveActivityView: View {
|
||||
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 {
|
||||
Link(destination: context.state.mapsURL) {
|
||||
ViewThatFits(in: .horizontal) {
|
||||
// rich first — wins on full-width Lock Screen / banner
|
||||
richBody
|
||||
// CarPlay / Watch small slot is far narrower than this,
|
||||
// so ViewThatFits reliably falls through to compactBody.
|
||||
.frame(minWidth: 280)
|
||||
.frame(minWidth: richMinWidth)
|
||||
// compact fallback — the car's small supplemental slot
|
||||
compactBody
|
||||
.frame(maxWidth: compactMaxWidth)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -90,6 +98,8 @@ private struct FuelBoardLiveActivityView: View {
|
||||
.font(.subheadline)
|
||||
.foregroundStyle(.secondary)
|
||||
.lineLimit(1)
|
||||
.minimumScaleFactor(0.75)
|
||||
.truncationMode(.tail)
|
||||
}
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
|
||||
@@ -127,6 +137,8 @@ private struct FuelBoardLiveActivityView: View {
|
||||
.font(.system(size: 9))
|
||||
.foregroundStyle(.secondary)
|
||||
.lineLimit(1)
|
||||
.minimumScaleFactor(0.7)
|
||||
.truncationMode(.tail)
|
||||
}
|
||||
.padding(8)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user