mirror of
https://github.com/librekeys/picoforge.git
synced 2026-07-28 08:01:19 -07:00
fix(ui): collapsed sidebare refresh status button
This commit is contained in:
@@ -12,6 +12,7 @@ pub struct AppSidebar<V: 'static> {
|
||||
state: GlobalDeviceState,
|
||||
on_select: Option<Rc<dyn Fn(&mut V, ActiveView, &mut Window, &mut Context<V>)>>,
|
||||
refresh_btn: Option<AnyElement>,
|
||||
refresh_btn_collapsed: Option<AnyElement>,
|
||||
}
|
||||
|
||||
impl<V: 'static> AppSidebar<V> {
|
||||
@@ -28,6 +29,7 @@ impl<V: 'static> AppSidebar<V> {
|
||||
state,
|
||||
on_select: None,
|
||||
refresh_btn: None,
|
||||
refresh_btn_collapsed: None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +46,11 @@ impl<V: 'static> AppSidebar<V> {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_refresh_btn_collapsed(mut self, btn: impl IntoElement) -> Self {
|
||||
self.refresh_btn_collapsed = Some(btn.into_any_element());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn render(self, cx: &mut Context<V>) -> impl IntoElement {
|
||||
let width = self.width;
|
||||
let collapsed = self.collapsed;
|
||||
@@ -169,7 +176,7 @@ impl<V: 'static> AppSidebar<V> {
|
||||
.items_center()
|
||||
.justify_center()
|
||||
.gap_2()
|
||||
.children(self.refresh_btn)
|
||||
.children(self.refresh_btn_collapsed)
|
||||
.child(div().w(px(8.)).h(px(8.)).rounded_full().bg(
|
||||
if let Some(status) = &state.device_status {
|
||||
if status.method == DeviceMethod::Fido {
|
||||
|
||||
@@ -115,6 +115,14 @@ impl Render for ApplicationRoot {
|
||||
this.active_view = view;
|
||||
})
|
||||
.with_refresh_btn(self.refresh_button.clone())
|
||||
.with_refresh_btn_collapsed(
|
||||
Button::new("refresh-btn-collapsed")
|
||||
.ghost()
|
||||
.child(Icon::default().path("icons/refresh-cw.svg"))
|
||||
.on_click(cx.listener(|this, _, _, cx| {
|
||||
this.refresh_device_status(cx);
|
||||
})),
|
||||
)
|
||||
.render(cx),
|
||||
)
|
||||
.child(
|
||||
|
||||
Reference in New Issue
Block a user