Skip to content

Commit

Permalink
UI updates
Browse files Browse the repository at this point in the history
  • Loading branch information
joreilly committed Jun 8, 2024
1 parent fdde4ab commit 10ce6cc
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fun StationsScreen(networkId: String, popBack: (() -> Unit)?) {
TopAppBar(title = { Text(networkId) }, navigationIcon = navigationIcon!!)
}) { paddingValues ->
LazyColumn(Modifier.padding(paddingValues)) {
items(stations) { station ->
items(stations.sortedBy { it.name }) { station ->
StationView(station)
}
}
Expand All @@ -64,6 +64,15 @@ fun StationView(station: Station) {
Row(modifier = Modifier.padding(start = 16.dp, top = 8.dp, end = 16.dp, bottom = 8.dp).fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically) {

Column {
Image(
painterResource(R.drawable.ic_bike),
colorFilter = ColorFilter.tint(if (station.freeBikes() < 2) lowAvailabilityColor else highAvailabilityColor),
modifier = Modifier.size(32.dp), contentDescription = station.freeBikes().toString())
}

Spacer(modifier = Modifier.width(16.dp))

Column(modifier = Modifier.weight(1.0f)) {
Text(text = station.name, style = MaterialTheme.typography.bodyLarge, fontWeight = FontWeight.Bold)

Expand All @@ -72,24 +81,18 @@ fun StationView(station: Station) {
Column(modifier = Modifier.width(100.dp)) {
Text("Bikes")
Text(station.freeBikes().toString(),
color = if (station.freeBikes() < 5) lowAvailabilityColor else highAvailabilityColor)
color = if (station.freeBikes() < 2) lowAvailabilityColor else highAvailabilityColor)
}

Column {
Text("Stands")
Text(station.empty_slots.toString(),
color = if (station.freeBikes() < 5) lowAvailabilityColor else highAvailabilityColor)
color = if (station.freeBikes() < 2) lowAvailabilityColor else highAvailabilityColor)
}
}
}
}

Column {
Image(
painterResource(R.drawable.ic_bike),
colorFilter = ColorFilter.tint(if (station.freeBikes() < 5) lowAvailabilityColor else highAvailabilityColor),
modifier = Modifier.size(32.dp), contentDescription = station.freeBikes().toString())
}
}
}

Expand Down
38 changes: 24 additions & 14 deletions ios/BikeShare/BikeShare/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ struct StationListTabView: View {
Label("Map", systemImage: "location")
}
}
.navigationTitle(network.name)
.navigationTitle(network.id)
.onAppear {
viewModel.setNetwork(networkId: network.id)
}
Expand All @@ -75,7 +75,7 @@ struct StationListView: View {
var network: Network

var body: some View {
List(stations) { station in
List(stations.sorted { $0.name < $1.name }) { station in
StationView(station: station)
}
.navigationTitle(network.name)
Expand All @@ -86,25 +86,35 @@ struct StationView : View {
var station: Station

var body: some View {

HStack {
Image("ic_bike").resizable()
.renderingMode(.template)
.foregroundColor(station.freeBikes() < 5 ? .orange : .green)
.frame(width: 32.0, height: 32.0)

VStack(alignment: .trailing) {
Image("ic_bike").resizable()
.renderingMode(.template)
.foregroundColor(station.freeBikes() < 2 ? .orange : .green)
.frame(width: 32.0, height: 32.0)
}

Spacer().frame(width: 16)

VStack(alignment: .leading) {
Text(station.name).font(.headline)
Text(station.name).bold()

HStack {
Text("Free:").font(.subheadline).frame(width: 80, alignment: .leading)
Text("\(station.freeBikes())").font(.subheadline)
}
HStack {
Text("Slots:").font(.subheadline).frame(width: 80, alignment: .leading)
Text("\(station.slots())").font(.subheadline)
VStack(alignment: .leading) {
Text("Bikes")
Text("\(station.freeBikes())").font(.subheadline).foregroundColor(station.freeBikes() < 2 ? .orange : .green)
}

VStack(alignment: .leading) {
Text("Stands")
Text("\(station.slots())").font(.subheadline).foregroundColor(station.freeBikes() < 2 ? .orange : .green)
}
}

}

}
.navigationTitle(station.name)
}
Expand Down

0 comments on commit 10ce6cc

Please sign in to comment.