Skip to content

Commit

Permalink
Show disruptions when present
Browse files Browse the repository at this point in the history
  • Loading branch information
cristan committed Sep 3, 2024
1 parent 98e774c commit 900acad
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ object DetailsMapper {
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 disruptions = payload.infoImages.find { it.title == "Storing" }?.body

val location =
if (payload.city == "" || payload.city == null || payload.street == null || payload.houseNumber == null || payload.postalCode == null) {
Expand Down Expand Up @@ -100,6 +101,7 @@ object DetailsMapper {
serviceType = serviceType,
directions = if (directions != "") directions else null,
about = about,
disruptions = "Helaas kunt u hier op dit moment geen OV-fiets huren. Onze excuses voor dit ongemak. Raadpleeg de NS Reisplanner app of website (ns.nl/ov-fiets) voor de dichtstbijzijnde OV-fiets verhuurlocatie.",
location = location,
coordinates = LatLng(payload.lat, payload.lng),
stationName = allStations[payload.stationCode],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ data class DetailsModel(
val capacity: Int,
val serviceType: ServiceType?,
val about: String?,
val disruptions: String?,
val directions: String?,
val location: LocationModel?,
val coordinates: LatLng,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.HorizontalDivider
Expand Down Expand Up @@ -180,6 +181,10 @@ private fun ActualDetails(
Column(Modifier.padding(start = 20.dp, end = 20.dp, bottom = 20.dp, top = 4.dp)) {
MainInfo(details)

details?.disruptions?.let {
Disruptions(it)
}

Location(details, onLocationClicked)

ExtraInfo(details)
Expand Down Expand Up @@ -254,6 +259,23 @@ private fun MainInfo(details: DetailsModel) {
}
}

@Composable
private fun Disruptions(disruptions: String) {
Card(
modifier = Modifier.padding(top = 16.dp),
elevation = CardDefaults.cardElevation(
defaultElevation = 2.dp
),
colors = CardDefaults.cardColors(
containerColor = Red50,
),
) {
Column(Modifier.padding(16.dp)) {
Text(disruptions, color = Color.White)
}
}
}

@Composable
private fun Location(details: DetailsModel, onNavigateClicked: (String) -> Unit) {
OvCard(
Expand Down Expand Up @@ -451,6 +473,7 @@ fun DetailsPreview() {
105,
ServiceType.Sleutelautomaat,
about,
"Helaas kunt u hier op dit moment geen OV-fiets huren. Onze excuses voor dit ongemak. Raadpleeg de NS Reisplanner app of website (ns.nl/ov-fiets) voor de dichtstbijzijnde OV-fiets verhuurlocatie.",
directions,
locationModel,
LatLng(52.15446, 5.37339),
Expand Down

0 comments on commit 900acad

Please sign in to comment.