Add complete keyboard navigation.

This commit is contained in:
2026-08-07 17:00:49 +02:00
parent 87a161058f
commit 5709c80209
38 changed files with 1943 additions and 355 deletions

View File

@@ -1,5 +1,7 @@
use crate::components::keyboard;
use iced::widget::button;
use iced::widget::text::Shaping;
use iced::widget::{Column, Space, button, column, container, svg, text, tooltip};
use iced::widget::{Column, Space, column, container, svg, text, tooltip};
use iced::{Background, Border, Color, Element, Length, Theme};
use bds_core::i18n::UiLocale;
@@ -28,6 +30,21 @@ fn icon_svg(view: SidebarView) -> &'static [u8] {
}
}
pub fn access_key(view: SidebarView) -> char {
match view {
SidebarView::Posts => '1',
SidebarView::Pages => '2',
SidebarView::Media => '3',
SidebarView::Scripts => '4',
SidebarView::Templates => '5',
SidebarView::Tags => '6',
SidebarView::Chat => '7',
SidebarView::Import => '8',
SidebarView::Git => '9',
SidebarView::Settings => '0',
}
}
/// Top group of activity items.
const TOP_ACTIVITIES: &[SidebarView] = &[
SidebarView::Posts,
@@ -108,7 +125,7 @@ pub fn view(
.height(Length::Fixed(24.0))
.opacity(if is_active { 1.0_f32 } else { 0.4_f32 });
let btn = button(
let btn = iced::widget::button(
container(icon)
.center_x(Length::Fixed(48.0))
.center_y(Length::Fixed(48.0)),
@@ -140,13 +157,18 @@ pub fn view(
// Wrap in tooltip per layout.allium ActivityButton.label_key
let tip_text = t(locale, view.i18n_key());
tooltip(
btn_row,
text(tip_text).size(12).shaping(Shaping::Advanced),
tooltip::Position::Right,
keyboard::focusable(
tooltip(
btn_row,
text(tip_text).size(12).shaping(Shaping::Advanced),
tooltip::Position::Right,
)
.gap(4)
.style(inputs::tooltip_style),
true,
)
.gap(4)
.style(inputs::tooltip_style)
.hotkey(access_key(view))
.hint_position(keyboard::HintPosition::BottomTrailing)
.into()
};