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