From 0592e4f0ad5475ce6f5e0c9bffcd2fac11cd9c56 Mon Sep 17 00:00:00 2001 From: Bart Louwers Date: Tue, 13 Jan 2026 17:29:42 +0100 Subject: [PATCH] make LongRunningMapView button more prominent in iOS test app (#4047) --- .../app-swift/Sources/MapLibreColors.swift | 7 +++++++ .../Sources/MapLibreNavigationView.swift | 12 ++++++++--- .../Sources/Stability/CountdownBadge.swift | 21 +++++++++++++++++++ .../Sources/Stability/LongRunningMap.swift | 19 +++++++++++++---- 4 files changed, 52 insertions(+), 7 deletions(-) create mode 100644 platform/ios/app-swift/Sources/MapLibreColors.swift create mode 100644 platform/ios/app-swift/Sources/Stability/CountdownBadge.swift diff --git a/platform/ios/app-swift/Sources/MapLibreColors.swift b/platform/ios/app-swift/Sources/MapLibreColors.swift new file mode 100644 index 000000000..3ed9162e0 --- /dev/null +++ b/platform/ios/app-swift/Sources/MapLibreColors.swift @@ -0,0 +1,7 @@ +import SwiftUI + +enum MapLibreColors { + static let primary = Color(red: 0x28 / 255.0, green: 0x5D / 255.0, blue: 0xAA / 255.0) + static let accent = Color(red: 0x95 / 255.0, green: 0xBE / 255.0, blue: 0xFA / 255.0) + static let white = Color.white +} diff --git a/platform/ios/app-swift/Sources/MapLibreNavigationView.swift b/platform/ios/app-swift/Sources/MapLibreNavigationView.swift index 1d58bc310..6eadfae05 100644 --- a/platform/ios/app-swift/Sources/MapLibreNavigationView.swift +++ b/platform/ios/app-swift/Sources/MapLibreNavigationView.swift @@ -5,6 +5,15 @@ struct MapLibreNavigationView: View { var body: some View { NavigationStack { List { + Section { + NavigationLink("Start Long Running Test") { + LongRunningMapView() + } + .listRowBackground(MapLibreColors.primary) + .foregroundColor(.white) + .fontWeight(.bold) + } + NavigationLink("SimpleMap") { SimpleMap().edgesIgnoringSafeArea(.all) } @@ -40,9 +49,6 @@ struct MapLibreNavigationView: View { NavigationLink("ObserverExample") { ObserverExampleViewUIViewControllerRepresentable() } - NavigationLink("LongRunningMap") { - LongRunningMapView().edgesIgnoringSafeArea(.all) - } Group { NavigationLink("AnimatedLineExample") { AnimatedLineExampleUIViewControllerRepresentable() diff --git a/platform/ios/app-swift/Sources/Stability/CountdownBadge.swift b/platform/ios/app-swift/Sources/Stability/CountdownBadge.swift new file mode 100644 index 000000000..7921d8177 --- /dev/null +++ b/platform/ios/app-swift/Sources/Stability/CountdownBadge.swift @@ -0,0 +1,21 @@ +import SwiftUI + +struct CountdownBadge: View { + let remainingTime: TimeInterval + + var body: some View { + Text(formatTime(remainingTime)) + .font(.system(size: 16, weight: .bold, design: .monospaced)) + .foregroundColor(.white) + .padding(12) + .background(MapLibreColors.primary) + .cornerRadius(12) + } + + private func formatTime(_ timeInterval: TimeInterval) -> String { + let hours = Int(timeInterval) / 3600 + let minutes = (Int(timeInterval) % 3600) / 60 + let seconds = Int(timeInterval) % 60 + return String(format: "%02dh %02dm %02ds", hours, minutes, seconds) + } +} diff --git a/platform/ios/app-swift/Sources/Stability/LongRunningMap.swift b/platform/ios/app-swift/Sources/Stability/LongRunningMap.swift index 164dfffc5..a0c1e4afd 100644 --- a/platform/ios/app-swift/Sources/Stability/LongRunningMap.swift +++ b/platform/ios/app-swift/Sources/Stability/LongRunningMap.swift @@ -27,21 +27,32 @@ struct LongRunningMapView: View { let DURATION = 72.0 * 60.0 * 60.0 @Environment(\.dismiss) var dismiss + @State private var remainingTime: TimeInterval = 72.0 * 60.0 * 60.0 var body: some View { - VStack { + VStack(spacing: 0) { UserMapView() NavigationMapView() } + .edgesIgnoringSafeArea(.bottom) .onAppear { UIApplication.shared.isIdleTimerDisabled = true + remainingTime = DURATION } .onDisappear { UIApplication.shared.isIdleTimerDisabled = false } - .onReceive(Timer.publish(every: DURATION, on: .current, in: .default).autoconnect()) { _ in - printMemoryUsage() - dismiss() + .onReceive(Timer.publish(every: 1.0, on: .current, in: .default).autoconnect()) { _ in + if remainingTime > 0 { + remainingTime -= 1.0 + } else { + printMemoryUsage() + dismiss() + } + } + .overlay(alignment: .topLeading) { + CountdownBadge(remainingTime: remainingTime) + .padding(16) } } }