Add complete keyboard navigation.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
use crate::components::keyboard;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use bds_core::engine::git::{
|
||||
@@ -6,7 +7,7 @@ use bds_core::engine::git::{
|
||||
};
|
||||
use bds_core::i18n::UiLocale;
|
||||
use iced::widget::text::{Shaping, Wrapping};
|
||||
use iced::widget::{Space, button, column, container, row, scrollable, text, text_input, tooltip};
|
||||
use iced::widget::{Space, column, container, row, scrollable, text, text_input, tooltip};
|
||||
use iced::{Alignment, Background, Color, Element, Font, Length};
|
||||
|
||||
use crate::app::Message;
|
||||
@@ -152,7 +153,7 @@ pub fn sidebar_view(
|
||||
text(t(locale, "git.notRepository"))
|
||||
.size(12)
|
||||
.color(Color::from_rgb(0.6, 0.6, 0.65)),
|
||||
button(text(t(locale, "git.initialize")).size(12))
|
||||
keyboard::button(text(t(locale, "git.initialize")).size(12))
|
||||
.on_press(Message::GitInitialize)
|
||||
.padding([5, 8])
|
||||
.style(inputs::primary_button),
|
||||
@@ -180,7 +181,7 @@ pub fn sidebar_view(
|
||||
let network_running = state.network_run.is_some();
|
||||
let network_button =
|
||||
|key: &'static str, icon: &'static str, message: Message| -> Element<'static, Message> {
|
||||
let mut control = button(text(icon).size(16).shaping(Shaping::Advanced))
|
||||
let mut control = keyboard::button(text(icon).size(16).shaping(Shaping::Advanced))
|
||||
.width(Length::Fixed(30.0))
|
||||
.height(Length::Fixed(28.0))
|
||||
.padding(0)
|
||||
@@ -189,13 +190,16 @@ pub fn sidebar_view(
|
||||
control = control.on_press(message);
|
||||
}
|
||||
|
||||
tooltip(
|
||||
control,
|
||||
text(t(locale, key)).size(12),
|
||||
tooltip::Position::Bottom,
|
||||
keyboard::focusable(
|
||||
tooltip(
|
||||
control,
|
||||
text(t(locale, key)).size(12),
|
||||
tooltip::Position::Bottom,
|
||||
)
|
||||
.gap(4)
|
||||
.style(inputs::tooltip_style),
|
||||
!offline_mode && !network_running,
|
||||
)
|
||||
.gap(4)
|
||||
.style(inputs::tooltip_style)
|
||||
.into()
|
||||
};
|
||||
let actions = row![
|
||||
@@ -240,7 +244,7 @@ pub fn sidebar_view(
|
||||
.padding([5, 7])
|
||||
.style(inputs::field_style),
|
||||
{
|
||||
let commit = button(text(t(locale, "git.commit")).size(11))
|
||||
let commit = keyboard::button(text(t(locale, "git.commit")).size(11))
|
||||
.padding([5, 7])
|
||||
.style(inputs::primary_button);
|
||||
if state.files.is_empty() || state.commit_message.trim().is_empty() {
|
||||
@@ -265,7 +269,7 @@ pub fn sidebar_view(
|
||||
content.extend(state.history.iter().take(20).map(history_button));
|
||||
}
|
||||
content.push(
|
||||
button(text(t(locale, "git.pruneLfs")).size(11))
|
||||
keyboard::button(text(t(locale, "git.pruneLfs")).size(11))
|
||||
.on_press(Message::GitPruneLfs)
|
||||
.padding([4, 7])
|
||||
.style(inputs::secondary_button)
|
||||
@@ -303,7 +307,7 @@ fn error_view(error: Option<&str>) -> Element<'static, Message> {
|
||||
|
||||
fn status_button(file: &GitFileStatus) -> Element<'static, Message> {
|
||||
let path = file.path.clone();
|
||||
button(
|
||||
keyboard::button(
|
||||
row![
|
||||
text(path.clone()).size(11),
|
||||
Space::with_width(Length::Fill),
|
||||
@@ -322,7 +326,7 @@ fn history_button(commit: &GitCommit) -> Element<'static, Message> {
|
||||
let hash = commit.hash.clone();
|
||||
let subject = commit.subject.clone().unwrap_or_else(|| hash.clone());
|
||||
let short = hash.chars().take(7).collect::<String>();
|
||||
button(
|
||||
keyboard::button(
|
||||
column![
|
||||
text(subject.clone()).size(11),
|
||||
row![
|
||||
@@ -399,7 +403,7 @@ fn network_output(run: &GitNetworkRunState, locale: UiLocale) -> Element<'static
|
||||
.wrapping(Wrapping::Word)
|
||||
)
|
||||
.padding(6),
|
||||
button(text(t(locale, "common.cancel")).size(11))
|
||||
keyboard::button(text(t(locale, "common.cancel")).size(11))
|
||||
.on_press(Message::CancelTask(
|
||||
crate::state::navigation::TaskSource::Local,
|
||||
run.task_id,
|
||||
@@ -445,7 +449,7 @@ pub fn diff_view(
|
||||
.iter()
|
||||
.map(|change| {
|
||||
let selected = state.selected_path.as_deref() == Some(&change.path);
|
||||
let button = button(text(change.path.clone()).size(11))
|
||||
let button = keyboard::button(text(change.path.clone()).size(11))
|
||||
.padding([4, 7])
|
||||
.style(if selected {
|
||||
inputs::primary_button
|
||||
|
||||
Reference in New Issue
Block a user