gui: optimize title panel
This commit is contained in:
parent
f7c911fd9b
commit
cea0716eb6
2 changed files with 19 additions and 19 deletions
|
@ -13,6 +13,7 @@
|
|||
// limitations under the License.
|
||||
|
||||
use std::ops::{Deref, DerefMut};
|
||||
use egui::Widget;
|
||||
use crate::gui::platform::PlatformCallbacks;
|
||||
use crate::gui::screens::{Navigator, Screen, ScreenId};
|
||||
use crate::gui::{SYM_ACCOUNTS, SYM_ARROW_BACK, SYM_NETWORK, SYM_SETTINGS};
|
||||
|
@ -44,22 +45,21 @@ impl Screen for Accounts {
|
|||
cb: &dyn PlatformCallbacks) {
|
||||
let Self { title } = self;
|
||||
|
||||
TitlePanel::default()
|
||||
let mut panel: TitlePanel = TitlePanel::default()
|
||||
.title(title.to_owned())
|
||||
.left_action(if !dual_panel_mode(frame) {
|
||||
Some(PanelAction {
|
||||
icon: SYM_NETWORK.into(),
|
||||
on_click: Box::new(on_left_click),
|
||||
})
|
||||
} else {
|
||||
None
|
||||
})
|
||||
.right_action(Some(PanelAction {
|
||||
.right_action(PanelAction {
|
||||
icon: SYM_SETTINGS.into(),
|
||||
on_click: Box::new(on_right_click),
|
||||
}))
|
||||
.with_navigator(nav)
|
||||
.ui(ui);
|
||||
})
|
||||
.with_navigator(nav);
|
||||
if !dual_panel_mode(frame) {
|
||||
panel = panel.left_action(PanelAction {
|
||||
icon: SYM_NETWORK.into(),
|
||||
on_click: Box::new(on_left_click),
|
||||
});
|
||||
}
|
||||
panel.ui(ui);
|
||||
|
||||
ui.label(format!("{}Here we go 10000 ツ", SYM_ARROW_BACK));
|
||||
if ui.button("TEST").clicked() {
|
||||
nav.to(ScreenId::Account)
|
||||
|
|
|
@ -45,13 +45,13 @@ impl<'screen> TitlePanel<'screen> {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn left_action(mut self, action: Option<PanelAction>) -> Self {
|
||||
self.actions.left = action;
|
||||
pub fn left_action(mut self, action: PanelAction) -> Self {
|
||||
self.actions.left = Some(action);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn right_action(mut self, action: Option<PanelAction>) -> Self {
|
||||
self.actions.right = action;
|
||||
pub fn right_action(mut self, action: PanelAction) -> Self {
|
||||
self.actions.right = Some(action);
|
||||
self
|
||||
}
|
||||
|
||||
|
@ -61,8 +61,8 @@ impl<'screen> TitlePanel<'screen> {
|
|||
}
|
||||
}
|
||||
|
||||
impl TitlePanel<'_> {
|
||||
pub(crate) fn ui(&mut self, ui: &mut egui::Ui) {
|
||||
impl View for TitlePanel<'_> {
|
||||
fn ui(&mut self, ui: &mut egui::Ui) {
|
||||
// Disable stroke around panel
|
||||
ui.style_mut().visuals.widgets.noninteractive.bg_stroke = Stroke::NONE;
|
||||
|
||||
|
|
Loading…
Reference in a new issue