From 6dadabee4d439c45868f872c4f09c4336edf0fb6 Mon Sep 17 00:00:00 2001 From: Cristan Meijer Date: Sun, 1 Sep 2024 20:31:38 +0200 Subject: [PATCH] Show opening hours info --- .../java/nl/ovfietsbeschikbaarheid/mapper/DetailsMapper.kt | 3 +++ .../main/java/nl/ovfietsbeschikbaarheid/model/DetailsModel.kt | 1 + .../java/nl/ovfietsbeschikbaarheid/ui/screen/DetailScreen.kt | 4 ++++ 3 files changed, 8 insertions(+) diff --git a/app/src/main/java/nl/ovfietsbeschikbaarheid/mapper/DetailsMapper.kt b/app/src/main/java/nl/ovfietsbeschikbaarheid/mapper/DetailsMapper.kt index e637896..f5ff2ad 100644 --- a/app/src/main/java/nl/ovfietsbeschikbaarheid/mapper/DetailsMapper.kt +++ b/app/src/main/java/nl/ovfietsbeschikbaarheid/mapper/DetailsMapper.kt @@ -29,6 +29,8 @@ object DetailsMapper { // Just for Rotterdam Kralingse Zoom ?.replace("&", "&") val about = payload.infoImages.find { it.title == "Bijzonderheden" }?.body?.replace(newLinesAtEnd, "") + // Filled in example Leiden Centraal, Centrumzijde + val openingHoursInfo = payload.infoImages.find { it.title == "Info openingstijden" }?.body val location = if (payload.city == "" || payload.city == null || payload.street == null || payload.houseNumber == null || payload.postalCode == null) { @@ -83,6 +85,7 @@ object DetailsMapper { return DetailsModel( description = payload.description, + openingHoursInfo = openingHoursInfo, openingHours = openingHoursModels, rentalBikesAvailable = rentalBikesAvailable, capacity = max(rentalBikesAvailable ?: 0, maxCapacity), diff --git a/app/src/main/java/nl/ovfietsbeschikbaarheid/model/DetailsModel.kt b/app/src/main/java/nl/ovfietsbeschikbaarheid/model/DetailsModel.kt index 7d4a1af..f2a83dc 100644 --- a/app/src/main/java/nl/ovfietsbeschikbaarheid/model/DetailsModel.kt +++ b/app/src/main/java/nl/ovfietsbeschikbaarheid/model/DetailsModel.kt @@ -7,6 +7,7 @@ import nl.ovfietsbeschikbaarheid.R data class DetailsModel( val description: String, val openState: OpenState?, + val openingHoursInfo: String?, val openingHours: List, val rentalBikesAvailable: Int?, val capacity: Int, diff --git a/app/src/main/java/nl/ovfietsbeschikbaarheid/ui/screen/DetailScreen.kt b/app/src/main/java/nl/ovfietsbeschikbaarheid/ui/screen/DetailScreen.kt index 647c26b..85235c9 100644 --- a/app/src/main/java/nl/ovfietsbeschikbaarheid/ui/screen/DetailScreen.kt +++ b/app/src/main/java/nl/ovfietsbeschikbaarheid/ui/screen/DetailScreen.kt @@ -391,6 +391,9 @@ private fun OpeningHours(details: DetailsModel) { style = MaterialTheme.typography.headlineMedium, modifier = Modifier.padding(bottom = 8.dp) ) + details.openingHoursInfo?.let { + Text(it, Modifier.padding(bottom = 8.dp)) + } details.openingHours.forEach { Row(Modifier.fillMaxWidth()) { Text(it.dayOfWeek, Modifier.weight(1f)) @@ -442,6 +445,7 @@ fun DetailsPreview() { val details = DetailsModel( "Hilversum", OpenState.Open247, + null, openingHours, 144, 200,