Skip to content

Commit 3585a38

Browse files
committed
feat(iOS): refreshable content
1 parent 86713eb commit 3585a38

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

apps/mobile/metro-now/metro-now/pages/closest-stop/closest-stop-page-view-model.swift

+9
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@ class ClosestStopPageViewModel: NSObject, ObservableObject, CLLocationManagerDel
3838
stopPeriodicRefresh()
3939
}
4040

41+
func refresh() {
42+
let stopIds = [closestMetroStop?.id ?? "", closestStop?.id ?? ""]
43+
44+
getDepartures(
45+
stopsIds: stopIds.filter { !$0.isEmpty },
46+
platformsIds: []
47+
)
48+
}
49+
4150
private func startPeriodicRefresh() {
4251
stopPeriodicRefresh() // Stop any existing timer to avoid duplication.
4352
refreshTimer = Timer.scheduledTimer(

apps/mobile/metro-now/metro-now/pages/closest-stop/closest-stop-page.view.swift

+9-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import SwiftUI
55

66
struct ClosestStopPageView: View {
77
@StateObject private var viewModel = ClosestStopPageViewModel()
8+
@AppStorage(
9+
AppStorageKeys.showMetroOnly.rawValue
10+
) var showMetroOnly = false
811

912
var body: some View {
1013
if viewModel.metroStops != nil || viewModel.allStops != nil {
@@ -18,7 +21,7 @@ struct ClosestStopPageView: View {
1821
}
1922
}
2023

21-
if let closestStop = viewModel.closestStop {
24+
if !showMetroOnly, let closestStop = viewModel.closestStop {
2225
let platforms = closestStop.platforms
2326
.filter { platform in
2427
platform.routes.contains(where: {
@@ -41,6 +44,11 @@ struct ClosestStopPageView: View {
4144
}
4245
}
4346
.navigationTitle(viewModel.closestMetroStop?.name ?? "")
47+
.refreshable {
48+
print("Refreshing")
49+
50+
viewModel.refresh()
51+
}
4452
} else {
4553
ProgressView()
4654
}

0 commit comments

Comments
 (0)