feat: more details button in SendungsVerfolgung
This commit is contained in:
parent
f3732051af
commit
ae64f73176
4 changed files with 132 additions and 5 deletions
3
icons.toml
Normal file
3
icons.toml
Normal file
|
@ -0,0 +1,3 @@
|
|||
app_id = "de.j4ne.Paket"
|
||||
|
||||
icons = ["plus", "minus"]
|
|
@ -16,3 +16,4 @@ reqwest = "0.12"
|
|||
libpaket = { path = "../libpaket" }
|
||||
glycin = { version = "2.0.0-beta", features = ["gdk4"] }
|
||||
oo7 = { version = "0.3" }
|
||||
relm4-icons = { version = "0.9" }
|
|
@ -3,6 +3,7 @@ use std::sync::Arc;
|
|||
use login::{Login, LoginOutput, LoginSharedState};
|
||||
use ready::{Ready, ReadyOutput};
|
||||
use relm4::{
|
||||
RELM_THREADS,
|
||||
adw, gtk, main_adw_application, prelude::*, tokio::sync::Mutex,
|
||||
AsyncComponentSender, SharedState,
|
||||
};
|
||||
|
@ -289,6 +290,13 @@ fn convert_ready_response(response: ReadyOutput) -> AppInput {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
RELM_THREADS.set(4).unwrap();
|
||||
gtk::init().unwrap();
|
||||
let display = gtk::gdk::Display::default().unwrap();
|
||||
let theme = gtk::IconTheme::for_display(&display);
|
||||
theme.add_resource_path("/de/j4ne/Paket/icons/");
|
||||
theme.add_resource_path("/de/j4ne/Paket/scalable/actions/");
|
||||
relm4_icons::initialize_icons();
|
||||
let app = RelmApp::new(constants::APP_ID);
|
||||
app.run_async::<App>(());
|
||||
}
|
||||
|
|
|
@ -6,6 +6,20 @@ use relm4::{adw, gtk};
|
|||
|
||||
pub struct ShipmentView {
|
||||
model: Shipment,
|
||||
|
||||
// model abstraction
|
||||
have_events: bool,
|
||||
|
||||
// state
|
||||
expanded: bool,
|
||||
|
||||
// workarounds
|
||||
list_box_history: gtk::ListBox,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum ViewInput {
|
||||
ToggleExpand,
|
||||
}
|
||||
|
||||
#[relm4::factory(pub)]
|
||||
|
@ -13,7 +27,7 @@ impl FactoryComponent for ShipmentView {
|
|||
type CommandOutput = ();
|
||||
type Init = Shipment;
|
||||
type Output = ();
|
||||
type Input = ();
|
||||
type Input = ViewInput;
|
||||
type ParentWidget = gtk::Box;
|
||||
type Index = String;
|
||||
|
||||
|
@ -23,14 +37,26 @@ impl FactoryComponent for ShipmentView {
|
|||
add_css_class: relm4::css::CARD,
|
||||
set_hexpand: true,
|
||||
set_margin_all: 8,
|
||||
set_orientation: gtk::Orientation::Vertical,
|
||||
|
||||
gtk::ProgressBar {
|
||||
add_css_class: relm4::css::OSD,
|
||||
set_margin_start: 8,
|
||||
set_margin_end: 8,
|
||||
set_margin_bottom: 1,
|
||||
|
||||
set_fraction: f64::from(self.model.history.maximal_fortschritt) / f64::from(self.model.history.fortschritt),
|
||||
},
|
||||
|
||||
// title box
|
||||
gtk::Box {
|
||||
set_orientation: gtk::Orientation::Vertical,
|
||||
set_orientation: gtk::Orientation::Horizontal,
|
||||
set_hexpand: true,
|
||||
set_margin_all: 8,
|
||||
|
||||
gtk::Box {
|
||||
set_orientation: gtk::Orientation::Vertical,
|
||||
set_hexpand: true,
|
||||
set_halign: gtk::Align::Start,
|
||||
|
||||
gtk::Label {
|
||||
|
@ -61,9 +87,52 @@ impl FactoryComponent for ShipmentView {
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
gtk::Button {
|
||||
set_halign: gtk::Align::End,
|
||||
add_css_class: relm4::css::FLAT,
|
||||
|
||||
#[watch]
|
||||
set_icon_name: {
|
||||
if self.expanded {
|
||||
relm4_icons::icon_names::MINUS
|
||||
} else {
|
||||
relm4_icons::icon_names::PLUS
|
||||
}
|
||||
},
|
||||
|
||||
connect_clicked => ViewInput::ToggleExpand,
|
||||
}
|
||||
}
|
||||
}, // title box end
|
||||
|
||||
gtk::Revealer {
|
||||
#[watch]
|
||||
set_reveal_child: self.expanded,
|
||||
|
||||
#[wrap(Some)]
|
||||
set_child = >k::Box {
|
||||
// history viewstack
|
||||
adw::StatusPage {
|
||||
set_visible: !self.have_events,
|
||||
|
||||
set_title: "No events",
|
||||
|
||||
},
|
||||
|
||||
append = &self.list_box_history.clone() {
|
||||
set_visible: self.have_events,
|
||||
|
||||
add_css_class: relm4::css::BOXED_LIST,
|
||||
|
||||
set_selection_mode: gtk::SelectionMode::None,
|
||||
|
||||
},
|
||||
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fn init_model(
|
||||
|
@ -71,8 +140,54 @@ impl FactoryComponent for ShipmentView {
|
|||
index: &Self::Index,
|
||||
sender: relm4::FactorySender<Self>,
|
||||
) -> Self {
|
||||
let model = ShipmentView { model: init };
|
||||
let have_events = init.history.events.as_ref().is_some_and(|a| a.len() > 0);
|
||||
|
||||
model
|
||||
let list_box_history = gtk::ListBox::new();
|
||||
|
||||
let _self = ShipmentView {
|
||||
have_events,
|
||||
model: init,
|
||||
list_box_history,
|
||||
expanded: false,
|
||||
};
|
||||
|
||||
for elem in _self.model.history.events.as_ref().unwrap() {
|
||||
let label_datum = gtk::Label::builder()
|
||||
.css_classes([relm4::css::NUMERIC])
|
||||
.label(&elem.datum)
|
||||
.halign(gtk::Align::Start)
|
||||
.valign(gtk::Align::Start)
|
||||
.build();
|
||||
|
||||
// TODO: is html, parse it
|
||||
let label_status = gtk::Label::builder()
|
||||
.wrap(true)
|
||||
.halign(gtk::Align::Start)
|
||||
.valign(gtk::Align::Start)
|
||||
.build();
|
||||
label_status.set_markup(&elem.status);
|
||||
|
||||
let boxie = gtk::Box::builder()
|
||||
.orientation(gtk::Orientation::Horizontal)
|
||||
.margin_start(8)
|
||||
.margin_end(8)
|
||||
.spacing(8)
|
||||
.build();
|
||||
|
||||
boxie.append(&label_datum);
|
||||
boxie.append(&label_status);
|
||||
|
||||
_self.list_box_history.append(&boxie);
|
||||
}
|
||||
|
||||
_self
|
||||
}
|
||||
|
||||
fn update(&mut self, message: Self::Input, sender: FactorySender<Self>) {
|
||||
match message {
|
||||
ViewInput::ToggleExpand => {
|
||||
self.expanded = !self.expanded;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue