fix: paket: actually deactive views
This commit is contained in:
parent
ef63f18a77
commit
ebde744290
2 changed files with 65 additions and 42 deletions
|
@ -6,9 +6,11 @@ license.workspace = true
|
||||||
version.workspace = true
|
version.workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
relm4 = { version = "0.9" , features = [ "libadwaita", "macros" ] }
|
# using git version, for https://github.com/Relm4/Relm4/pull/677
|
||||||
relm4-components = { version = "0.9" }
|
relm4 = { version = "0.9", features = [ "libadwaita", "macros" ], git = "https://github.com/Relm4/Relm4.git" }
|
||||||
relm4-macros = { version = "0.9" }
|
relm4-components = { version = "0.9", git = "https://github.com/Relm4/Relm4.git" }
|
||||||
|
relm4-macros = { version = "0.9", git = "https://github.com/Relm4/Relm4.git" }
|
||||||
|
relm4-icons = { version = "0.9", git = "https://github.com/Relm4/icons.git" }
|
||||||
tracker = "0.2"
|
tracker = "0.2"
|
||||||
adw = {package = "libadwaita", version = "0.7", features = [ "v1_5" ]}
|
adw = {package = "libadwaita", version = "0.7", features = [ "v1_5" ]}
|
||||||
webkit = { package = "webkit6", version = "0.4" }
|
webkit = { package = "webkit6", version = "0.4" }
|
||||||
|
@ -16,6 +18,5 @@ reqwest = "0.12"
|
||||||
libpaket = { path = "../libpaket" }
|
libpaket = { path = "../libpaket" }
|
||||||
glycin = { version = "2.0.0-beta", features = ["gdk4"] }
|
glycin = { version = "2.0.0-beta", features = ["gdk4"] }
|
||||||
oo7 = { version = "0.3" }
|
oo7 = { version = "0.3" }
|
||||||
relm4-icons = { version = "0.9" }
|
|
||||||
futures = "0.3"
|
futures = "0.3"
|
||||||
gtk = { package = "gtk4", version = "0.9", features = ["v4_16"]}
|
gtk = { package = "gtk4", version = "0.9", features = ["v4_16"]}
|
|
@ -17,9 +17,7 @@ use relm4::{
|
||||||
prelude::*,
|
prelude::*,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::advices::{AdvicesViewInput, AdvicesView};
|
use crate::advices::{AdvicesView, AdvicesViewInput};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[tracker::track]
|
#[tracker::track]
|
||||||
pub struct Ready {
|
pub struct Ready {
|
||||||
|
@ -27,6 +25,7 @@ pub struct Ready {
|
||||||
login: crate::LoginSharedState,
|
login: crate::LoginSharedState,
|
||||||
activate: bool,
|
activate: bool,
|
||||||
have_service_advices: bool,
|
have_service_advices: bool,
|
||||||
|
have_service_tracking: bool,
|
||||||
|
|
||||||
#[do_not_track]
|
#[do_not_track]
|
||||||
advices_component: AsyncController<AdvicesView>,
|
advices_component: AsyncController<AdvicesView>,
|
||||||
|
@ -51,12 +50,18 @@ pub enum ReadyCmds {
|
||||||
GotTracking(LibraryResult<Vec<Shipment>>),
|
GotTracking(LibraryResult<Vec<Shipment>>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum Services {
|
||||||
|
Advices,
|
||||||
|
SendungVerfolgung,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum ReadyInput {
|
pub enum ReadyInput {
|
||||||
Activate,
|
Activate,
|
||||||
Deactivate,
|
Deactivate,
|
||||||
HaveAdvicesService,
|
HaveService(Services),
|
||||||
HavePaketankuendigungService,
|
ServiceBorked(Services),
|
||||||
SearchTracking(String),
|
SearchTracking(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,18 +75,23 @@ impl Component for Ready {
|
||||||
view! {
|
view! {
|
||||||
#[root]
|
#[root]
|
||||||
adw::ViewStack {
|
adw::ViewStack {
|
||||||
add = model.advices_component.widget() -> >k::ScrolledWindow {
|
add = &model.advices_component.widget().clone() -> gtk::ScrolledWindow {
|
||||||
/*#[track(model.changed_have_service_advices())]
|
#[track(model.changed_have_service_advices())]
|
||||||
set_visible: model.have_service_advices,*/
|
set_visible: model.have_service_advices,
|
||||||
|
|
||||||
} -> /*page_advices: adw::ViewStackPage*/ {
|
} -> page_advices: adw::ViewStackPage {
|
||||||
set_title: Some("Mail notification"),
|
set_title: Some("Mail notification"),
|
||||||
set_name: Some("page_advices"),
|
set_name: Some("page_advices"),
|
||||||
/*#[track(model.changed_have_service_advices())]
|
set_icon_name: Some(relm4_icons::icon_names::MAIL),
|
||||||
set_visible: model.have_service_advices,*/
|
|
||||||
|
#[track(model.changed_have_service_advices())]
|
||||||
|
set_visible: model.have_service_advices,
|
||||||
},
|
},
|
||||||
|
|
||||||
add = &adw::Bin {
|
add = &adw::Bin {
|
||||||
|
#[track(model.changed_have_service_tracking())]
|
||||||
|
set_visible: model.have_service_tracking,
|
||||||
|
|
||||||
#[wrap(Some)]
|
#[wrap(Some)]
|
||||||
set_child = >k::ScrolledWindow {
|
set_child = >k::ScrolledWindow {
|
||||||
#[wrap(Some)]
|
#[wrap(Some)]
|
||||||
|
@ -110,9 +120,13 @@ impl Component for Ready {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} -> {
|
} -> page_tracking: adw::ViewStackPage {
|
||||||
set_title: Some("Shipment tracking"),
|
set_title: Some("Shipment tracking"),
|
||||||
set_name: Some("page_tracking"),
|
set_name: Some("page_tracking"),
|
||||||
|
set_icon_name: Some(relm4_icons::icon_names::PACKAGE_X_GENERIC),
|
||||||
|
|
||||||
|
#[track(model.changed_have_service_tracking())]
|
||||||
|
set_visible: model.have_service_tracking,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -127,6 +141,7 @@ impl Component for Ready {
|
||||||
|
|
||||||
let model = Ready {
|
let model = Ready {
|
||||||
have_service_advices: false,
|
have_service_advices: false,
|
||||||
|
have_service_tracking: true,
|
||||||
login: init.clone(),
|
login: init.clone(),
|
||||||
activate: false,
|
activate: false,
|
||||||
tracking_factory,
|
tracking_factory,
|
||||||
|
@ -210,7 +225,13 @@ impl Component for Ready {
|
||||||
ReadyInput::Deactivate => {
|
ReadyInput::Deactivate => {
|
||||||
self.set_activate(false);
|
self.set_activate(false);
|
||||||
}
|
}
|
||||||
ReadyInput::HavePaketankuendigungService => {
|
ReadyInput::HaveService(service) => match service {
|
||||||
|
Services::Advices => {
|
||||||
|
self.set_have_service_advices(true);
|
||||||
|
self.advices_component.emit(AdvicesViewInput::Fetch);
|
||||||
|
}
|
||||||
|
Services::SendungVerfolgung => {
|
||||||
|
self.set_have_service_tracking(true);
|
||||||
let token = self.login.clone();
|
let token = self.login.clone();
|
||||||
sender.oneshot_command(async move {
|
sender.oneshot_command(async move {
|
||||||
// fetching advices
|
// fetching advices
|
||||||
|
@ -229,10 +250,11 @@ impl Component for Ready {
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
ReadyInput::HaveAdvicesService => {
|
},
|
||||||
self.have_service_advices = true;
|
ReadyInput::ServiceBorked(service) => match service {
|
||||||
self.advices_component.emit(AdvicesViewInput::Fetch);
|
Services::Advices => self.set_have_service_advices(false),
|
||||||
}
|
Services::SendungVerfolgung => self.set_have_service_tracking(false),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,13 +273,13 @@ impl Component for Ready {
|
||||||
match service {
|
match service {
|
||||||
libpaket::stammdaten::CustomerDataService::Packstation => (),
|
libpaket::stammdaten::CustomerDataService::Packstation => (),
|
||||||
libpaket::stammdaten::CustomerDataService::Paketankuendigung => {
|
libpaket::stammdaten::CustomerDataService::Paketankuendigung => {
|
||||||
sender.input(ReadyInput::HavePaketankuendigungService);
|
sender.input(ReadyInput::HaveService(Services::SendungVerfolgung))
|
||||||
}
|
}
|
||||||
libpaket::stammdaten::CustomerDataService::PostfilialeDirekt => (),
|
libpaket::stammdaten::CustomerDataService::PostfilialeDirekt => (),
|
||||||
libpaket::stammdaten::CustomerDataService::Digiben => (),
|
libpaket::stammdaten::CustomerDataService::Digiben => (),
|
||||||
libpaket::stammdaten::CustomerDataService::GeraetAktiviert => (),
|
libpaket::stammdaten::CustomerDataService::GeraetAktiviert => (),
|
||||||
libpaket::stammdaten::CustomerDataService::Briefankuendigung => {
|
libpaket::stammdaten::CustomerDataService::Briefankuendigung => {
|
||||||
sender.input(ReadyInput::HaveAdvicesService);
|
sender.input(ReadyInput::HaveService(Services::Advices))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue