From b24a204d5959665c4f8e5fffb58a0622faed8c2c Mon Sep 17 00:00:00 2001 From: ardocrat Date: Thu, 27 Apr 2023 22:42:32 +0300 Subject: [PATCH] gui: optimize title panel --- src/gui/screens/accounts.rs | 12 ++++++------ src/gui/views/title_panel.rs | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/gui/screens/accounts.rs b/src/gui/screens/accounts.rs index 6782e38..26739a2 100644 --- a/src/gui/screens/accounts.rs +++ b/src/gui/screens/accounts.rs @@ -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 } \ No newline at end of file diff --git a/src/gui/views/title_panel.rs b/src/gui/views/title_panel.rs index 3ef6d9a..e18ea68 100644 --- a/src/gui/views/title_panel.rs +++ b/src/gui/views/title_panel.rs @@ -34,13 +34,13 @@ pub struct PanelActions { #[derive(Default)] pub struct TitlePanel<'screen> { - title: Option, + 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 }