From 9a70339b73754af32a1e6ebbad54fdfe369e95d9 Mon Sep 17 00:00:00 2001 From: Tsubasa SEKIGUCHI Date: Sun, 6 Oct 2024 09:29:29 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=A9=E3=82=A4=E3=83=96=E3=82=A2=E3=82=AF?= =?UTF-8?q?=E3=83=86=E3=82=A3=E3=83=93=E3=83=86=E3=82=A3=E3=83=90=E3=82=B0?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RideSessionActivity.swift | 37 +++++++++++-------- src/hooks/useUpdateLiveActivities.ts | 7 +++- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/ios/RideSessionActivity/RideSessionActivity.swift b/ios/RideSessionActivity/RideSessionActivity.swift index 560601dbe..7470c40fa 100644 --- a/ios/RideSessionActivity/RideSessionActivity.swift +++ b/ios/RideSessionActivity/RideSessionActivity.swift @@ -20,15 +20,18 @@ func getRunningStateText( } return String(localized: "next") } + + if stopped { + return String(localized: "stop") + } + if approaching { if isNextLastStop { return String(localized: "soonLast") } return String(localized: "soon") } - if stopped { - return String(localized: "stop") - } + if isNextLastStop { return String(localized: "nextLast") } @@ -126,8 +129,10 @@ struct RideSessionWidget: Widget { } } compactLeading: { HStack { - if context.state.stopped { - Image(systemName: "stop.fill") + if context.state.approaching { + EmptyView() + } else if context.state.stopped { + Image(systemName: "stop.circle") } if context.state.passingStationName.isEmpty { @@ -144,8 +149,10 @@ struct RideSessionWidget: Widget { } else { Text("pass") } - - if !context.state.passingStationName.isEmpty || context.state.stopped { + + if !context.state.passingStationName.isEmpty + || (context.state.stopped && !context.state.approaching) + { EmptyView() } else if context.state.isNextLastStop { Image(systemName: "chevron.forward.to.line") @@ -176,7 +183,7 @@ struct RideSessionWidget: Widget { .opacity(0.75) } } - + Image(systemName: "chevron.forward.dotted.chevron.forward") } } else if context.state.stopped { @@ -389,7 +396,7 @@ struct SmartStackLiveActivityContentView: View { var body: some View { ZStack { VStack(alignment: .leading) { - HStack { + HStack(spacing: 2) { Text(context.state.lineName) .font(.caption) .bold() @@ -401,7 +408,7 @@ struct SmartStackLiveActivityContentView: View { .multilineTextAlignment(.leading) .opacity(0.75) } - + if context.state.passingStationName.isEmpty { Text( getRunningStateText( @@ -413,17 +420,17 @@ struct SmartStackLiveActivityContentView: View { .font(.callout) .bold() .multilineTextAlignment(.leading) - + Text( context.state.stopped - ? context.state.stationName : context.state.nextStationName + ? context.state.stationName : context.state.nextStationName ) .font(.headline) .bold() .multilineTextAlignment(.leading) Text( context.state.stopped - ? context.state.stationNumber : context.state.nextStationNumber + ? context.state.stationNumber : context.state.nextStationNumber ) .font(.caption) .bold() @@ -434,14 +441,14 @@ struct SmartStackLiveActivityContentView: View { .font(.callout) .bold() .multilineTextAlignment(.leading) - + Text( context.state.passingStationName ) .font(.headline) .bold() .multilineTextAlignment(.leading) - + Text( context.state.passingStationNumber ) diff --git a/src/hooks/useUpdateLiveActivities.ts b/src/hooks/useUpdateLiveActivities.ts index 108b711ec..2457390c4 100644 --- a/src/hooks/useUpdateLiveActivities.ts +++ b/src/hooks/useUpdateLiveActivities.ts @@ -90,8 +90,11 @@ export const useUpdateLiveActivities = (): void => { }, [directionalStops, getStationNumberIndex]) const stoppedStation = useMemo( - () => previousStation ?? currentStation, - [currentStation, previousStation] + () => + arrivedFromState && !approachingFromState + ? currentStation + : previousStation, + [approachingFromState, arrivedFromState, currentStation, previousStation] ) const stationName = useMemo( () => (isJapanese ? stoppedStation?.name : stoppedStation?.nameRoman) ?? '',