Skip to content

Commit

Permalink
ライブアクティビティバグ修正
Browse files Browse the repository at this point in the history
  • Loading branch information
TinyKitten committed Oct 6, 2024
1 parent 5852413 commit 9a70339
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 17 deletions.
37 changes: 22 additions & 15 deletions ios/RideSessionActivity/RideSessionActivity.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down Expand Up @@ -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 {
Expand All @@ -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")
Expand Down Expand Up @@ -176,7 +183,7 @@ struct RideSessionWidget: Widget {
.opacity(0.75)
}
}

Image(systemName: "chevron.forward.dotted.chevron.forward")
}
} else if context.state.stopped {
Expand Down Expand Up @@ -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()
Expand All @@ -401,7 +408,7 @@ struct SmartStackLiveActivityContentView: View {
.multilineTextAlignment(.leading)
.opacity(0.75)
}

if context.state.passingStationName.isEmpty {
Text(
getRunningStateText(
Expand All @@ -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()
Expand All @@ -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
)
Expand Down
7 changes: 5 additions & 2 deletions src/hooks/useUpdateLiveActivities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) ?? '',
Expand Down

0 comments on commit 9a70339

Please sign in to comment.