Skip to content

Commit

Permalink
Improve the looks of ebikes
Browse files Browse the repository at this point in the history
  • Loading branch information
cristan committed Sep 16, 2024
1 parent eff6527 commit b896ac2
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 4 deletions.
2 changes: 2 additions & 0 deletions app/src/main/java/nl/ovfietsbeschikbaarheid/TestData.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package nl.ovfietsbeschikbaarheid

import nl.ovfietsbeschikbaarheid.model.LocationOverviewModel
import nl.ovfietsbeschikbaarheid.model.LocationType

object TestData {
val testLocationOverviewModel = LocationOverviewModel(
Expand All @@ -10,5 +11,6 @@ object TestData {
"HVS",
latitude = 52.36599,
longitude = 6.469563,
type = LocationType.Regular
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import nl.ovfietsbeschikbaarheid.dto.LocationsDTO
import nl.ovfietsbeschikbaarheid.ext.distanceTo
import nl.ovfietsbeschikbaarheid.model.LocationOverviewModel
import nl.ovfietsbeschikbaarheid.model.LocationOverviewWithDistanceModel
import nl.ovfietsbeschikbaarheid.model.LocationType
import java.text.DecimalFormat
import kotlin.math.roundToInt

Expand All @@ -26,19 +27,30 @@ object LocationsMapper {

val replacements = hashMapOf(
Pair("s-Hertogenbosch", "'s-Hertogenbosch"),
Pair("P + R Utrecht Science Park (De Uithof)", "Utrecht P+R Science Park (De Uithof)"),
Pair("Delft, Fietsenstalling", "Delft"),
Pair("Leiden Centraal,Uitgang LUMC", "Leiden Centraal, Uitgang LUMC"),
Pair("Vianen OV-fiets", "Vianen"),
Pair("Hollandse Rading OV-fiets ", "Hollandse Rading"),
// All the other locations at Utrecht start with the word Utrecht, including the other P+Rs. Use the same scheme to make sure they're sorted together.
Pair("P + R Utrecht Science Park (De Uithof)", "Utrecht P+R Science Park (De Uithof)"),
// All of these also help with the alphabetical order
Pair("OV-ebike Arnhem Centrum", "Arnhem Centrum - OV-ebike"),
Pair("OV-ebike Driebergen-Zeist", "Driebergen-Zeist - OV-ebike"),
Pair("OV-ebike Groningen", "Groningen - OV-ebike"),
Pair("OV-ebike Maastricht", "Maastricht - OV-ebike"),
Pair("OV-fiets - Maastricht", "Maastricht"),
)

return locations.map { toMap ->
val description = replacements[toMap.description] ?: toMap.description
LocationOverviewModel(
title = description.trim().replace("P + R Utrecht Science Park (De Uithof)", "Utrecht P+R Science Park (De Uithof)"),
title = description,
uri = toMap.link.uri,
locationCode = toMap.extra.locationCode,
stationCode = toMap.stationCode,
latitude = toMap.lat,
longitude = toMap.lng,
type = if (description.contains("OV-ebike")) LocationType.EBike else LocationType.Regular
)
}.sortedBy { it.title }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@ data class LocationOverviewModel(
val stationCode: String,
val latitude: Double,
val longitude: Double,
val type: LocationType
)

data class LocationOverviewWithDistanceModel(
val distance: String,
val location: LocationOverviewModel
)
)

enum class LocationType {
Regular, EBike
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import nl.ovfietsbeschikbaarheid.TestData
import nl.ovfietsbeschikbaarheid.ext.OnReturnToScreenEffect
import nl.ovfietsbeschikbaarheid.model.LocationOverviewModel
import nl.ovfietsbeschikbaarheid.model.LocationOverviewWithDistanceModel
import nl.ovfietsbeschikbaarheid.model.LocationType
import nl.ovfietsbeschikbaarheid.ui.theme.Gray80
import nl.ovfietsbeschikbaarheid.ui.theme.Indigo05
import nl.ovfietsbeschikbaarheid.ui.theme.OVFietsBeschikbaarheidTheme
Expand Down Expand Up @@ -354,8 +355,9 @@ fun LocationCard(location: LocationOverviewModel, distance: String? = null, onCl
.padding(16.dp)
) {
// Bike icon at the start
val iconRes = if (location.type == LocationType.EBike) R.drawable.baseline_electric_bike_24 else R.drawable.pedal_bike_24px
Icon(
painter = painterResource(id = R.drawable.pedal_bike_24px),
painter = painterResource(id = iconRes),
tint = if (isSystemInDarkTheme()) Color.White else Color.Black,
contentDescription = null,
modifier = Modifier.padding(end = 8.dp)
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/drawable/baseline_electric_bike_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">

<path android:fillColor="@android:color/white" android:pathData="M19,7h-0.82l-1.7,-4.68C16.19,1.53 15.44,1 14.6,1H12v2h2.6l1.46,4h-4.81l-0.36,-1H12V4H7v2h1.75l1.82,5H9.9C9.46,8.77 7.59,7.12 5.25,7.01C2.45,6.87 0,9.2 0,12c0,2.8 2.2,5 5,5c2.46,0 4.45,-1.69 4.9,-4h4.2c0.44,2.23 2.31,3.88 4.65,3.99c2.8,0.13 5.25,-2.19 5.25,-5C24,9.2 21.8,7 19,7zM7.82,13c-0.4,1.17 -1.49,2 -2.82,2c-1.68,0 -3,-1.32 -3,-3s1.32,-3 3,-3c1.33,0 2.42,0.83 2.82,2H5v2H7.82zM14.1,11h-1.4l-0.73,-2H15C14.56,9.58 14.24,10.25 14.1,11zM19,15c-1.68,0 -3,-1.32 -3,-3c0,-0.93 0.41,-1.73 1.05,-2.28l0.96,2.64l1.88,-0.68l-0.97,-2.67C18.94,9.01 18.97,9 19,9c1.68,0 3,1.32 3,3S20.68,15 19,15z"/>

<path android:fillColor="@android:color/white" android:pathData="M11,20l-4,0l6,3l0,-2l4,0l-6,-3z"/>

</vector>

0 comments on commit b896ac2

Please sign in to comment.