-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ - Better Rail Live for Android (#256)
Added support for android devices: <img width="351" alt="image" src="https://github.com/better-rail/app/assets/12946462/585bdc90-e103-4993-a41e-065d3dfd0551"> Todo: - [x] Fix UI issues - [x] Add localization - [x] Replace staging env with production --------- Co-authored-by: Guy Tepper <[email protected]>
- Loading branch information
Showing
63 changed files
with
1,280 additions
and
376 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
android/app/src/main/res/drawable-anydpi-v24/notification_icon.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:viewportWidth="24" | ||
android:viewportHeight="24" | ||
android:tint="#FFFFFF"> | ||
<group android:scaleX="1.1621053" | ||
android:scaleY="1.1621053" | ||
android:translateX="-1.9452631" | ||
android:translateY="-1.3642105"> | ||
<path | ||
android:fillColor="@android:color/white" | ||
android:pathData="M12,2c-4,0 -8,0.5 -8,4v9.5C4,17.43 5.57,19 7.5,19L6,20.5v0.5h2.23l2,-2L14,19l2,2h2v-0.5L16.5,19c1.93,0 3.5,-1.57 3.5,-3.5L20,6c0,-3.5 -3.58,-4 -8,-4zM7.5,17c-0.83,0 -1.5,-0.67 -1.5,-1.5S6.67,14 7.5,14s1.5,0.67 1.5,1.5S8.33,17 7.5,17zM11,10L6,10L6,6h5v4zM13,10L13,6h5v4h-5zM16.5,17c-0.83,0 -1.5,-0.67 -1.5,-1.5s0.67,-1.5 1.5,-1.5 1.5,0.67 1.5,1.5 -0.67,1.5 -1.5,1.5z"/> | ||
</group> | ||
</vector> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { addMinutes } from "date-fns" | ||
import { RouteItem } from "../../services/api" | ||
import { getTrainFromStationId, getPreviousTrainFromStationId } from "../../utils/helpers/ride-helpers" | ||
import { RideStatus } from "./use-ride-progress" | ||
|
||
export type RideState = { | ||
status: RideStatus | ||
delay: number | ||
nextStationId: number | ||
} | ||
|
||
/** | ||
* Returns the end date for the current ride state. | ||
*/ | ||
export const getStatusEndDate = (route: RouteItem, state: RideState) => { | ||
const train = getTrainFromStationId(route, state.nextStationId) | ||
const departureDate = addMinutes(train.departureTime, state.delay) | ||
const arrivalDate = addMinutes(train.arrivalTime, state.delay) | ||
|
||
if (state.status === "waitForTrain" || state.status === "inExchange") { | ||
return departureDate | ||
} else if ( | ||
state.status === "inTransit" && | ||
train.originStationId == state.nextStationId && | ||
departureDate.getTime() > Date.now() | ||
) { | ||
const previousTrain = getPreviousTrainFromStationId(route, state.nextStationId) ?? train | ||
return addMinutes(previousTrain.arrivalTime, state.delay) | ||
} else { | ||
return arrivalDate | ||
} | ||
} | ||
|
||
/** | ||
* Get information about the current ride progress | ||
* @returns A tuple made out of the (current stop station index, total stop station count) | ||
*/ | ||
export const rideProgress = (route: RouteItem, nextStationId: number) => { | ||
const train = getTrainFromStationId(route, nextStationId) | ||
if (!train) return [0, 0] | ||
|
||
const totalStations = train.stopStations.length + 1 | ||
const currentIndex = train.stopStations.findIndex((station) => station.stationId === nextStationId) | ||
if (currentIndex >= 0) { | ||
return [currentIndex, totalStations] | ||
} else { | ||
for (let index = 0; index < route.trains.length; index++) { | ||
if (nextStationId === route.trains[index].destinationStationId) { | ||
let stopStationsCount = route.trains[index].stopStations.length + 1 | ||
return [stopStationsCount - 1, stopStationsCount] | ||
} | ||
} | ||
|
||
return [0, 0] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.