Skip to content

Commit

Permalink
Merge pull request #45 from krystxf/fix/app-crash-on-final-metro-stop
Browse files Browse the repository at this point in the history
fix: app crash on final metro stop
  • Loading branch information
krystxf authored Nov 15, 2024
2 parents 18432d8 + ee4b051 commit a801f18
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
6 changes: 4 additions & 2 deletions apps/mobile/metro-now/metro-now Watch App/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ struct ContentView: View {
let stops,
let closestStop = findClosestStop(to: location, stops: stops)
{
let platforms = closestStop.platforms.filter { $0.routes.count > 0 }

StopDeparturesView(
title: closestStop.name,
platforms: closestStop.platforms.map {
platform in
platforms: platforms.map { platform in

MainPagePlatform(
id: platform.id,
metroLine: MetroLine(rawValue: platform.routes[0].name),
Expand Down
16 changes: 8 additions & 8 deletions apps/mobile/metro-now/metro-now.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_ASSET_PATHS = "\"metro-now Watch App/Preview Content\"";
DEVELOPMENT_TEAM = R6WU5ABNG2;
ENABLE_PREVIEWS = YES;
Expand All @@ -382,7 +382,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 0.3;
MARKETING_VERSION = 0.2.1;
PRODUCT_BUNDLE_IDENTIFIER = "com.krystof.metro-now.watchkitapp";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = watchos;
Expand All @@ -400,7 +400,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_ASSET_PATHS = "\"metro-now Watch App/Preview Content\"";
DEVELOPMENT_TEAM = R6WU5ABNG2;
ENABLE_PREVIEWS = YES;
Expand All @@ -414,7 +414,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 0.3;
MARKETING_VERSION = 0.2.1;
PRODUCT_BUNDLE_IDENTIFIER = "com.krystof.metro-now.watchkitapp";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = watchos;
Expand All @@ -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 = 2;
DEVELOPMENT_ASSET_PATHS = "\"metro-now/Preview Content\"";
DEVELOPMENT_TEAM = R6WU5ABNG2;
ENABLE_PREVIEWS = YES;
Expand All @@ -451,7 +451,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 0.3;
MARKETING_VERSION = 0.2.1;
PRODUCT_BUNDLE_IDENTIFIER = "com.krystof.metro-now";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
Expand All @@ -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 = 2;
DEVELOPMENT_ASSET_PATHS = "\"metro-now/Preview Content\"";
DEVELOPMENT_TEAM = R6WU5ABNG2;
ENABLE_PREVIEWS = YES;
Expand All @@ -485,7 +485,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 0.3;
MARKETING_VERSION = 0.2.1;
PRODUCT_BUNDLE_IDENTIFIER = "com.krystof.metro-now";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
}
}
Expand Down

1 comment on commit a801f18

@vercel
Copy link

@vercel vercel bot commented on a801f18 Nov 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please # to comment.