From c319beb13093249896372757d8df1ad880bb783c Mon Sep 17 00:00:00 2001 From: Krystof Date: Fri, 15 Nov 2024 22:18:06 +0100 Subject: [PATCH] fix(ios): crash at the final metro station --- .../metro-now.xcodeproj/project.pbxproj | 4 ++-- .../closest-metro-stop-section.view.swift | 17 +++++++++-------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/apps/mobile/metro-now/metro-now.xcodeproj/project.pbxproj b/apps/mobile/metro-now/metro-now.xcodeproj/project.pbxproj index 9a9ab567..81938477 100644 --- a/apps/mobile/metro-now/metro-now.xcodeproj/project.pbxproj +++ b/apps/mobile/metro-now/metro-now.xcodeproj/project.pbxproj @@ -433,7 +433,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = 0.2.1; DEVELOPMENT_ASSET_PATHS = "\"metro-now/Preview Content\""; DEVELOPMENT_TEAM = R6WU5ABNG2; ENABLE_PREVIEWS = YES; @@ -467,7 +467,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = 0.2.1; DEVELOPMENT_ASSET_PATHS = "\"metro-now/Preview Content\""; DEVELOPMENT_TEAM = R6WU5ABNG2; ENABLE_PREVIEWS = YES; diff --git a/apps/mobile/metro-now/metro-now/pages/closest-stop/closest-metro-stop-section.view.swift b/apps/mobile/metro-now/metro-now/pages/closest-stop/closest-metro-stop-section.view.swift index 00cc2efd..e4320416 100644 --- a/apps/mobile/metro-now/metro-now/pages/closest-stop/closest-metro-stop-section.view.swift +++ b/apps/mobile/metro-now/metro-now/pages/closest-stop/closest-metro-stop-section.view.swift @@ -9,27 +9,28 @@ struct ClosestMetroStopSectionView: View { var body: some View { ForEach(closestStop.platforms, id: \.id) { platform in - let routeLabel: String = platform.routes[0].name - let routeLabelBackground: Color = getColorByRouteName(routeLabel) - let platformDepartures: [ApiDeparture]? = departures?.filter { departure in - departure.platformId == platform.id - } + let platformDepartures: [ApiDeparture]? = departures?.filter { $0.platformId == platform.id } - if let platformDepartures, platformDepartures.count > 0 { + if platform.routes.count == 0 { + EmptyView() + } else if let platformDepartures, platformDepartures.count > 0 { + let routeLabel: String = platform.routes[0].name let nextDeparture = platformDepartures.count > 1 ? platformDepartures[1] : nil ClosestStopPageListItemView( routeLabel: routeLabel, - routeLabelBackground: routeLabelBackground, + routeLabelBackground: getColorByRouteName(routeLabel), headsign: platformDepartures[0].headsign, departure: platformDepartures[0].departure.predicted, nextHeadsign: nextDeparture?.headsign, nextDeparture: nextDeparture?.departure.scheduled ) } else { + let routeLabel: String = platform.routes[0].name + ClosestStopPageListItemPlaceholderView( routeLabel: routeLabel, - routeLabelBackground: routeLabelBackground + routeLabelBackground: getColorByRouteName(routeLabel) ) } }