update rentals list to match station list style

- Use emoji + bike number format (🚲/)
- Remove code display from rental rows
- Use navigation-sidebar CSS for consistent styling
- Remove scroll wrapper for better bottom sheet sizing

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Jonas Heinrich 2026-03-27 23:13:14 +01:00
parent be742a2e43
commit 61be1ea55e

View file

@ -1,8 +1,8 @@
use adw::prelude::*;
use adw::{Application, ApplicationWindow, BottomSheet, Clamp, HeaderBar, NavigationPage, NavigationView};
use gtk::{
Box, Button, Entry, Image, Label, ListBox, ListBoxRow, MenuButton, Orientation,
Overlay, ScrolledWindow, Spinner, Stack,
Box, Button, Entry, Label, ListBox, ListBoxRow, MenuButton, Orientation,
Overlay, Spinner, Stack,
};
use gtk::gio;
use gtk::glib;
@ -19,6 +19,7 @@ const BASE_URL: &str = "https://api.nextbike.net";
// ── Bike model ────────────────────────────────────────────────────────────────
#[derive(Clone)]
#[allow(dead_code)]
struct Bike {
id: String,
code: String,
@ -210,53 +211,22 @@ fn create_rental_row(bike: &Bike) -> ListBoxRow {
let hbox = Box::builder()
.orientation(Orientation::Horizontal)
.spacing(12)
.margin_top(12)
.margin_bottom(12)
.margin_start(16)
.margin_end(16)
.spacing(8)
.margin_top(8)
.margin_bottom(8)
.build();
// Bike icon
let icon = Image::from_icon_name(if bike.is_reserved {
"alarm-symbolic"
} else {
"system-run-symbolic"
});
icon.add_css_class("dim-label");
// Use emoji like station list: 🚲 for regular, ⚡ for e-bike
let icon = if bike.electric_lock { "" } else { "🚲" };
let status = if bike.is_reserved { " (reserved)" } else { "" };
// Info box
let info = Box::builder()
.orientation(Orientation::Vertical)
let label = Label::builder()
.label(&format!("{} {}{}", icon, bike.id, status))
.hexpand(true)
.build();
let title_text = if bike.is_reserved {
format!("Bike {} (Reserved)", bike.id)
} else {
format!("Bike {}", bike.id)
};
let title = Label::builder()
.label(&title_text)
.css_classes(["heading"])
.xalign(0.0)
.build();
let subtitle = Label::builder()
.label(&format!(
"Code: {}{}",
bike.code,
if bike.electric_lock { "" } else { "" }
))
.css_classes(["dim-label", "caption"])
.xalign(0.0)
.build();
info.append(&title);
info.append(&subtitle);
hbox.append(&icon);
hbox.append(&info);
hbox.append(&label);
row.set_child(Some(&hbox));
row
}
@ -614,21 +584,15 @@ map.addLayer(markers);
// — Rentals sheet —
let rentals_list = ListBox::builder()
.css_classes(["boxed-list"])
.selection_mode(gtk::SelectionMode::None)
.build();
let rentals_scroll = ScrolledWindow::builder()
.vexpand(true)
.max_content_height(300)
.child(&rentals_list)
.css_classes(["navigation-sidebar"])
.build();
let rentals_sheet = Box::builder()
.orientation(Orientation::Vertical)
.spacing(12)
.build();
rentals_sheet.append(&rentals_scroll);
rentals_sheet.append(&rentals_list);
// — Station bikes sheet —
let station_list = ListBox::builder()