gui: optimize title panel

This commit is contained in:
ardocrat 2023-04-27 22:42:32 +03:00
parent cea0716eb6
commit b24a204d59
2 changed files with 8 additions and 8 deletions

View file

@ -46,16 +46,16 @@ impl Screen for Accounts {
let Self { title } = self;
let mut panel: TitlePanel = TitlePanel::default()
.title(title.to_owned())
.title(title)
.right_action(PanelAction {
icon: SYM_SETTINGS.into(),
on_click: Box::new(on_right_click),
on_click: Box::new(on_settings_click),
})
.with_navigator(nav);
if !dual_panel_mode(frame) {
panel = panel.left_action(PanelAction {
icon: SYM_NETWORK.into(),
on_click: Box::new(on_left_click),
on_click: Box::new(on_network_click),
});
}
panel.ui(ui);
@ -70,10 +70,10 @@ impl Screen for Accounts {
}
}
fn on_left_click(nav: &mut Option<&mut Navigator>) {
fn on_network_click(nav: &mut Option<&mut Navigator>) {
nav.as_mut().unwrap().toggle_left_panel();
}
fn on_right_click(nav: &mut Option<&mut Navigator>) {
nav.as_mut().unwrap().toggle_left_panel();
fn on_settings_click(nav: &mut Option<&mut Navigator>) {
//TODO: Open settings
}

View file

@ -34,13 +34,13 @@ pub struct PanelActions {
#[derive(Default)]
pub struct TitlePanel<'screen> {
title: Option<String>,
title: Option<&'screen String>,
actions: PanelActions,
navigator: Option<&'screen mut Navigator>
}
impl<'screen> TitlePanel<'screen> {
pub fn title(mut self, title: String) -> Self {
pub fn title(mut self, title: &'screen String) -> Self {
self.title = Some(title);
self
}