Skip to content

Commit

Permalink
Improve looks of the extra details
Browse files Browse the repository at this point in the history
  • Loading branch information
cristan committed Aug 31, 2024
1 parent 5ec2ab1 commit 6358edb
Show file tree
Hide file tree
Showing 10 changed files with 98 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ data class PayloadExtra(
// a string containing an Int. Weirdly nullable (see Raalte)
val rentalBikes: Int? = null,

// Can be Bemenst, Kluizen, Sleutelautomaat, Box (Enkhuizen)
// Can be Bemenst, Kluizen, Sleutelautomaat, Box (Enkhuizen) or null (Utrecht Terwijde)
val serviceType: String? = null,

val locationCode: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import nl.ovfietsbeschikbaarheid.model.DetailsModel
import nl.ovfietsbeschikbaarheid.model.LocationModel
import nl.ovfietsbeschikbaarheid.model.LocationOverviewModel
import nl.ovfietsbeschikbaarheid.model.OpeningHoursModel
import nl.ovfietsbeschikbaarheid.model.ServiceType
import timber.log.Timber
import java.util.Locale
import kotlin.math.max
Expand Down Expand Up @@ -65,8 +66,19 @@ object DetailsMapper {
val rentalBikesAvailable = payload.extra.rentalBikes
val maxCapacity = foundCapacity ?: rentalBikesAvailable ?: 0

val serviceType = payload.extra.serviceType
?: if (detailsDTO.self.uri.contains("Zelfservice")) "Zelfservice" else null

val serviceType = when(payload.extra.serviceType) {
"Bemenst" -> ServiceType.Bemenst
"Kluizen" -> ServiceType.Kluizen
"Sleutelautomaat" -> ServiceType.Sleutelautomaat
"Box" -> ServiceType.Box
null -> if (detailsDTO.self.uri.contains("Zelfservice", ignoreCase = true)) ServiceType.Zelfservice else null
else -> {
Timber.w("Unknown service type: ${payload.extra.serviceType}")
null
}
}

return DetailsModel(
description = payload.description,
openingHours = openingHoursModels,
Expand Down
17 changes: 15 additions & 2 deletions app/src/main/java/nl/ovfietsbeschikbaarheid/model/DetailsModel.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package nl.ovfietsbeschikbaarheid.model

import androidx.annotation.DrawableRes
import com.google.android.gms.maps.model.LatLng
import nl.ovfietsbeschikbaarheid.R

data class DetailsModel(
val description: String,
val openingHours: List<OpeningHoursModel>,
val rentalBikesAvailable: Int?,
val capacity: Int,
val serviceType: String?,
val serviceType: ServiceType?,
val about: String?,
val directions: String?,
val location: LocationModel?,
Expand All @@ -27,4 +29,15 @@ data class OpeningHoursModel(
val dayOfWeek: String,
val startTime: String,
val endTime: String,
)
)

enum class ServiceType(val text: String, @DrawableRes val icon: Int) {
Bemenst("Bemenst", R.drawable.baseline_person_24),
// See: https://www.ns.nl/fietsenstallingen/abonnementen/fietskluizen.html
Kluizen("Kluizen", R.drawable.fietskluizen_icon),
// No idea what this is, but there are only 2, so it doesn't matter that much
Box("Box", R.drawable.fietskluizen_icon),
Sleutelautomaat("Sleutelautomaat", R.drawable.baseline_key_24),
// Example: https://www.debeeldunie.nl/stock-photo-nederland-cuijk-14-07-2015-fietsenstalling-voor-ov-fietsen-op-reportage-image00157529.html
Zelfservice("Zelfservice", R.drawable.garage_home_24dp),
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.content.Intent
import android.content.res.Configuration
import android.net.Uri
import androidx.compose.foundation.clickable
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
Expand Down Expand Up @@ -36,6 +37,7 @@ import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.StrokeCap
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
Expand All @@ -57,6 +59,7 @@ import nl.ovfietsbeschikbaarheid.model.DetailsModel
import nl.ovfietsbeschikbaarheid.model.LocationModel
import nl.ovfietsbeschikbaarheid.model.LocationOverviewModel
import nl.ovfietsbeschikbaarheid.model.OpeningHoursModel
import nl.ovfietsbeschikbaarheid.model.ServiceType
import nl.ovfietsbeschikbaarheid.state.ScreenState
import nl.ovfietsbeschikbaarheid.ui.components.OvCard
import nl.ovfietsbeschikbaarheid.ui.theme.OVFietsBeschikbaarheidTheme
Expand All @@ -66,7 +69,6 @@ import nl.ovfietsbeschikbaarheid.ui.view.FullPageLoader
import nl.ovfietsbeschikbaarheid.viewmodel.DetailsViewModel
import org.koin.androidx.compose.koinViewModel
import java.net.URLEncoder
import java.util.Locale

@Composable
fun DetailScreen(
Expand Down Expand Up @@ -298,11 +300,27 @@ private fun Location(details: DetailsModel, onNavigateClicked: (String) -> Unit)
private fun ExtraInfo(details: DetailsModel) {
OvCard {
details.serviceType?.let {
Text("Type: ${it.lowercase(Locale.UK)}", Modifier.padding(bottom = 8.dp))
Row {
Icon(
painter = painterResource(id = it.icon),
tint = if (isSystemInDarkTheme()) Color.White else Color.Black,
contentDescription = null,
modifier = Modifier.padding(end = 8.dp)
)
Text(it.text)
}
}

val bottomPadding = if (details.about != null) 8.dp else 0.dp
Text("Totale capaciteit: ${details.capacity}", modifier = Modifier.padding(bottom = bottomPadding))
Row(Modifier.padding(bottom = bottomPadding)) {
Icon(
painter = painterResource(id = R.drawable.pedal_bike_24px),
tint = if (isSystemInDarkTheme()) Color.White else Color.Black,
contentDescription = null,
modifier = Modifier.padding(end = 8.dp)
)
Text("Totale capaciteit: ${details.capacity}")
}

if (details.about != null) {
val urlText = "ov-fiets.nl/slot"
Expand Down Expand Up @@ -385,7 +403,7 @@ fun DetailsPreview() {
openingHours,
144,
200,
"Bemenst",
ServiceType.Bemenst,
about,
directions,
locationModel,
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/baseline_key_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<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="M21,10h-8.35C11.83,7.67 9.61,6 7,6c-3.31,0 -6,2.69 -6,6s2.69,6 6,6c2.61,0 4.83,-1.67 5.65,-4H13l2,2l2,-2l2,2l4,-4.04L21,10zM7,15c-1.65,0 -3,-1.35 -3,-3c0,-1.65 1.35,-3 3,-3s3,1.35 3,3C10,13.65 8.65,15 7,15z"/>

</vector>
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/baseline_lock_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<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="M18,8h-1L17,6c0,-2.76 -2.24,-5 -5,-5S7,3.24 7,6v2L6,8c-1.1,0 -2,0.9 -2,2v10c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2L20,10c0,-1.1 -0.9,-2 -2,-2zM12,17c-1.1,0 -2,-0.9 -2,-2s0.9,-2 2,-2 2,0.9 2,2 -0.9,2 -2,2zM15.1,8L8.9,8L8.9,6c0,-1.71 1.39,-3.1 3.1,-3.1 1.71,0 3.1,1.39 3.1,3.1v2z"/>

</vector>
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/baseline_person_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<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="M12,12c2.21,0 4,-1.79 4,-4s-1.79,-4 -4,-4 -4,1.79 -4,4 1.79,4 4,4zM12,14c-2.67,0 -8,1.34 -8,4v2h16v-2c0,-2.66 -5.33,-4 -8,-4z"/>

</vector>
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/baseline_view_compact_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<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="M4,18h2.5v-2.5H4V18zM4,13.25h2.5v-2.5H4V13.25zM4,8.5h2.5V6H4V8.5zM17.5,6v2.5H20V6H17.5zM13,8.5h2.5V6H13V8.5zM17.5,18H20v-2.5h-2.5V18zM17.5,13.25H20v-2.5h-2.5V13.25zM8.5,18H11v-2.5H8.5V18zM13,18h2.5v-2.5H13V18zM8.5,8.5H11V6H8.5V8.5zM13,13.25h2.5v-2.5H13V13.25zM8.5,13.25H11v-2.5H8.5V13.25z"/>

</vector>
17 changes: 17 additions & 0 deletions app/src/main/res/drawable/fietskluizen_icon.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="100"
android:viewportHeight="100">
<group android:translateX="-5" android:translateY="5">
<path
android:pathData="M23,20L37,20A3,3 0,0 1,40 23L40,67A3,3 0,0 1,37 70L23,70A3,3 0,0 1,20 67L20,23A3,3 0,0 1,23 20z"
android:fillColor="#424242"/>
<path
android:pathData="M48,20L62,20A3,3 0,0 1,65 23L65,67A3,3 0,0 1,62 70L48,70A3,3 0,0 1,45 67L45,23A3,3 0,0 1,48 20z"
android:fillColor="#424242"/>
<path
android:pathData="M73,20L87,20A3,3 0,0 1,90 23L90,67A3,3 0,0 1,87 70L73,70A3,3 0,0 1,70 67L70,23A3,3 0,0 1,73 20z"
android:fillColor="#424242"/>
</group>
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/garage_home_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:pathData="M160,840v-480l320,-240 320,240v480h-80v-440L480,220 240,400v440h-80ZM360,760h240v-80L360,680v80ZM360,600h240v-80L360,520v80ZM280,840v-400h400v400L280,840Z"
android:fillColor="#000000"/>
</vector>

0 comments on commit 6358edb

Please sign in to comment.