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 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
|
||||
}
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue