gui: optimize title panel
This commit is contained in:
parent
cea0716eb6
commit
b24a204d59
2 changed files with 8 additions and 8 deletions
|
@ -46,16 +46,16 @@ impl Screen for Accounts {
|
||||||
let Self { title } = self;
|
let Self { title } = self;
|
||||||
|
|
||||||
let mut panel: TitlePanel = TitlePanel::default()
|
let mut panel: TitlePanel = TitlePanel::default()
|
||||||
.title(title.to_owned())
|
.title(title)
|
||||||
.right_action(PanelAction {
|
.right_action(PanelAction {
|
||||||
icon: SYM_SETTINGS.into(),
|
icon: SYM_SETTINGS.into(),
|
||||||
on_click: Box::new(on_right_click),
|
on_click: Box::new(on_settings_click),
|
||||||
})
|
})
|
||||||
.with_navigator(nav);
|
.with_navigator(nav);
|
||||||
if !dual_panel_mode(frame) {
|
if !dual_panel_mode(frame) {
|
||||||
panel = panel.left_action(PanelAction {
|
panel = panel.left_action(PanelAction {
|
||||||
icon: SYM_NETWORK.into(),
|
icon: SYM_NETWORK.into(),
|
||||||
on_click: Box::new(on_left_click),
|
on_click: Box::new(on_network_click),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
panel.ui(ui);
|
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();
|
nav.as_mut().unwrap().toggle_left_panel();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_right_click(nav: &mut Option<&mut Navigator>) {
|
fn on_settings_click(nav: &mut Option<&mut Navigator>) {
|
||||||
nav.as_mut().unwrap().toggle_left_panel();
|
//TODO: Open settings
|
||||||
}
|
}
|
|
@ -34,13 +34,13 @@ pub struct PanelActions {
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct TitlePanel<'screen> {
|
pub struct TitlePanel<'screen> {
|
||||||
title: Option<String>,
|
title: Option<&'screen String>,
|
||||||
actions: PanelActions,
|
actions: PanelActions,
|
||||||
navigator: Option<&'screen mut Navigator>
|
navigator: Option<&'screen mut Navigator>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'screen> TitlePanel<'screen> {
|
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.title = Some(title);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue