Add complete keyboard navigation.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
use crate::components::keyboard;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::f32::consts::{FRAC_PI_2, TAU};
|
||||
|
||||
@@ -7,9 +8,7 @@ use bds_core::engine::chat_surfaces::{
|
||||
};
|
||||
use bds_core::i18n::UiLocale;
|
||||
use iced::widget::canvas::{self, Path, Stroke, path};
|
||||
use iced::widget::{
|
||||
Space, button, checkbox, column, container, row, scrollable, text, text_editor,
|
||||
};
|
||||
use iced::widget::{Space, checkbox, column, container, row, scrollable, text, text_editor};
|
||||
use iced::{
|
||||
Alignment, Color, Element, Length, Point, Radians, Rectangle, Renderer, Size, Theme, mouse,
|
||||
};
|
||||
@@ -76,7 +75,7 @@ fn surface_view<'a>(
|
||||
}
|
||||
if dismissible {
|
||||
header = header.push(
|
||||
button(text(t(locale, "chat.surface.dismiss")))
|
||||
keyboard::button(text(t(locale, "chat.surface.dismiss")))
|
||||
.on_press(Message::ChatSurfaceDismissed(surface.id.clone()))
|
||||
.padding([4, 8])
|
||||
.style(inputs::secondary_button),
|
||||
@@ -113,7 +112,7 @@ fn surface_content<'a>(
|
||||
.iter()
|
||||
.fold(row![].spacing(8), |actions, item| {
|
||||
actions.push(
|
||||
button(text(item.label.clone()))
|
||||
keyboard::button(text(item.label.clone()))
|
||||
.on_press(Message::ChatSurfaceAction {
|
||||
surface_id: surface.id.clone(),
|
||||
action: item.action.clone(),
|
||||
@@ -196,15 +195,18 @@ fn form<'a>(
|
||||
let surface_id = surface.id.clone();
|
||||
let key = field.key.clone();
|
||||
let control: Element<'a, Message> = match field.input_type {
|
||||
FormInputType::Checkbox => checkbox(label, field.value.as_bool().unwrap_or(false))
|
||||
.on_toggle(move |value| Message::ChatSurfaceFieldChanged {
|
||||
surface_id: surface_id.clone(),
|
||||
field: key.clone(),
|
||||
value: value.into(),
|
||||
})
|
||||
.size(16)
|
||||
.text_size(13)
|
||||
.into(),
|
||||
FormInputType::Checkbox => keyboard::focusable(
|
||||
checkbox(label, field.value.as_bool().unwrap_or(false))
|
||||
.on_toggle(move |value| Message::ChatSurfaceFieldChanged {
|
||||
surface_id: surface_id.clone(),
|
||||
field: key.clone(),
|
||||
value: value.into(),
|
||||
})
|
||||
.size(16)
|
||||
.text_size(13),
|
||||
true,
|
||||
)
|
||||
.into(),
|
||||
FormInputType::Select => {
|
||||
let selected = field.options.iter().find(|option| {
|
||||
field
|
||||
@@ -278,7 +280,7 @@ fn form<'a>(
|
||||
}
|
||||
if let Some(action) = &surface.submit_action {
|
||||
children.push(
|
||||
button(text(
|
||||
keyboard::button(text(
|
||||
surface
|
||||
.submit_label
|
||||
.clone()
|
||||
@@ -437,7 +439,7 @@ fn tabs<'a>(
|
||||
.enumerate()
|
||||
.fold(row![].spacing(6), |controls, (index, tab)| {
|
||||
controls.push(
|
||||
button(text(tab.label.clone()))
|
||||
keyboard::button(text(tab.label.clone()))
|
||||
.on_press(Message::ChatSurfaceTabSelected {
|
||||
surface_id: surface.id.clone(),
|
||||
index,
|
||||
|
||||
Reference in New Issue
Block a user