Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions changelog.d/claude-project-thread-5mrv8h.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@
tooltip and accessible name of a button that deletes the item it sits in, "Delete" in
`DefaultWidgetsLocalizations` (Flutter 3.50.1's `MaterialLocalizations.deleteButtonTooltip`).
An implementor of the trait adds it.
- `WidgetsLocalizations::select_row_label(row)` (`flui-widgets`), a required method: the name of
the checkbox that selects data row `row` (1-based) of a table, "Select row 2" in
`DefaultWidgetsLocalizations`. Flutter 3.50.1 has no such string. An implementor of the trait
adds it.

### Changed

Expand Down Expand Up @@ -247,3 +251,10 @@
`WidgetsLocalizations::delete_button_tooltip` of the ambient `Localizations` ("Delete" in
English), as Flutter 3.50.1 names it by `MaterialLocalizations.deleteButtonTooltip`. Before,
every `Chip` and `FilterChip` with `on_deleted` had an unnamed button no reader could announce.
- A material `BackButton` has a name: the ambient `WidgetsLocalizations::back_button_label`
("Back" in English), the string Flutter 3.50.1's `BackButton` shows as its tooltip
(`MaterialLocalizations.backButtonTooltip`). Before, every app bar that implied a back button
showed a reader an unnamed button.
- A `DataTable`'s checkboxes have names, where Flutter 3.50.1 leaves them unnamed: the heading's
is the ambient `select_all_button_label` ("Select all"), each data row's is
`select_row_label` with its place below the heading ("Select row 1").
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ impl WidgetsLocalizations for GlobalWidgetsLocalizations {
fn menu_dismiss_label(&self) -> &'static str {
DefaultWidgetsLocalizations.menu_dismiss_label()
}
fn select_row_label(&self, row: usize) -> String {
DefaultWidgetsLocalizations.select_row_label(row)
}
}

/// A [`LocalizationsDelegate`] that resolves a [`GlobalWidgetsLocalizations`]
Expand Down
18 changes: 15 additions & 3 deletions crates/flui-widgets/src/localization/widgets_localizations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ pub trait WidgetsLocalizations: Any + fmt::Debug {
fn cut_button_label(&self) -> &'static str;
/// Label for "paste" edit buttons and menu items.
fn paste_button_label(&self) -> &'static str;
/// Label for "select all" edit buttons and menu items.
/// Label for "select all" edit buttons and menu items, and of the
/// checkbox in a table's heading that selects every row.
fn select_all_button_label(&self) -> &'static str;
/// Label for "look up" edit buttons and menu items.
fn look_up_button_label(&self) -> &'static str;
Expand All @@ -62,8 +63,10 @@ pub trait WidgetsLocalizations: Any + fmt::Debug {
/// Label of a toolbar's button that shows the commands its row has no
/// room for.
fn more_button_label(&self) -> &'static str;
/// Label of a toolbar's button that leaves the commands it showed and
/// returns to its row.
/// Label of a button that goes back: a toolbar's button that leaves the
/// commands it showed and returns to its row, and a page's back button
/// (Flutter 3.50.1's `MaterialLocalizations.backButtonTooltip`, which both
/// read, "Back" in English).
fn back_button_label(&self) -> &'static str;
/// Tooltip and accessible name of the button that deletes the item it sits
/// in, such as a chip's delete button (Flutter 3.50.1's
Expand Down Expand Up @@ -101,6 +104,11 @@ pub trait WidgetsLocalizations: Any + fmt::Debug {
fn modal_barrier_dismiss_label(&self) -> &'static str;
/// Semantics label of the barrier behind an open popup menu.
fn menu_dismiss_label(&self) -> &'static str;
/// Semantics label of the checkbox that selects data row `row` (1-based,
/// below the heading) of a table. Flutter 3.50.1's `DataTable` leaves its
/// row checkboxes unnamed (`_buildCheckbox`); the heading's checkbox is
/// named by [`select_all_button_label`](Self::select_all_button_label).
fn select_row_label(&self, row: usize) -> String;
/// What assistive technology hears after an item moved in a reorderable
/// list: the item, when it is named, at `position` (1-based) of `count`.
fn reorder_item_moved(&self, item: Option<&str>, position: usize, count: usize) -> String;
Expand Down Expand Up @@ -235,4 +243,8 @@ impl WidgetsLocalizations for DefaultWidgetsLocalizations {
fn menu_dismiss_label(&self) -> &'static str {
"Dismiss menu"
}

fn select_row_label(&self, row: usize) -> String {
format!("Select row {row}")
}
}
3 changes: 3 additions & 0 deletions crates/flui-widgets/tests/modal_barrier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,9 @@ impl WidgetsLocalizations for German {
fn menu_dismiss_label(&self) -> &'static str {
"Menü schließen"
}
fn select_row_label(&self, row: usize) -> String {
DefaultWidgetsLocalizations.select_row_label(row)
}
fn reorder_item_moved(&self, item: Option<&str>, position: usize, count: usize) -> String {
DefaultWidgetsLocalizations.reorder_item_moved(item, position, count)
}
Expand Down
3 changes: 3 additions & 0 deletions crates/flui-widgets/tests/page_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,9 @@ fn the_page_label_comes_from_the_widgets_localizations() {
fn menu_dismiss_label(&self) -> &'static str {
DefaultWidgetsLocalizations.menu_dismiss_label()
}
fn select_row_label(&self, row: usize) -> String {
DefaultWidgetsLocalizations.select_row_label(row)
}
}
#[derive(Debug)]
struct GermanDelegate;
Expand Down
7 changes: 0 additions & 7 deletions docs/gaps.md
Original file line number Diff line number Diff line change
Expand Up @@ -549,13 +549,6 @@ its anchor: update the links and the `GapId` slug in the same pull request.
- A list under a header sliver that scrolls away, or inside `SliverPadding`, has a rect smaller than the viewport's clip, so it does not. Nor does a `SingleChildScrollView`: the node holding its content sits above its viewport, outside the clip. AccessKit's filter reads only the nearest filtered parent. The content is still not `visible` to the agent and `Tester`: the actionability check narrows by every clipping ancestor, the scroll view included. A list under a pinned header does get the flag: the viewport shrinks that list's clip by the room the header takes, so a row wholly behind the header counts as past the edge, a translucent header included, as Flutter's viewport clips it.
- It closes with a clip the viewport hands each sliver for its own extent, and with the scroll semantics node formed inside the viewport's clip.

### A back button and a data table's row checkboxes have no accessible name

> **Environments:** all · **Who it hurts:** Screen-reader users: `BackButton` and the row checkboxes `DataTable` builds are announced as an unnamed button and unnamed checkboxes, and an application cannot name the checkboxes, which the table builds itself · **Parity:** [Accessibility](platform-parity.md#accessibility)

- `flui-material`'s tests end with exactly these `Unnamed` audit findings (`icon_face::a_widget_draws_the_glyph_the_face_names_for_its_icon`, `app_bar`, `data_table`, through `tests/common`'s `finish_with_unnamed`), so naming them fails those tests until the tests drop the expected findings.
- It closes as ADR-0407 names a control the framework builds: `BackButton` from a localized back-button tooltip (Flutter 3.50.1's `MaterialLocalizations.backButtonTooltip`), and each row's checkbox from a localized string `DataTable` reads, as a chip's delete button reads `WidgetsLocalizations::delete_button_tooltip`.

### Add-to-app: no FLUI view inside an existing native app

> **Environments:** all · **Who it hurts:** Teams adding FLUI to an app they already ship · **Parity:** [Windows](platform-parity.md#windows)
Expand Down
14 changes: 8 additions & 6 deletions docs/plans/specs/testing-platform/tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -834,11 +834,13 @@
убраны. Каждый тест кончается `t.finish()`; `finish_unchecked` — только там, где предмет теста
— работа, идущая, пока виджет смонтирован: неопределённый индикатор, бегущая волна,
обновление, которое не завершается. Аудит конца назвал два безымянных элемента управления, и
виджеты не правились (их имена — отдельное изменение по ADR-0407:
локализованная подсказка или метка `Semantics`): `BackButton` имени не берёт (Flutter 3.50.1 называет его
`MaterialLocalizations.backButtonTooltip`), чекбоксы строк `DataTable` безымянны (как
`_buildCheckbox` у Flutter); строка `BackButton` в `icon_face` и тесты чекбоксов `data_table`
кончаются `try_finish` ровно с находками `Unnamed` на эти узлы. Остальные элементы названы,
они названы из окружающих локализаций: `BackButton` — строкой
`WidgetsLocalizations::back_button_label` («Back», `MaterialLocalizations.backButtonTooltip`
у Flutter 3.50.1), чекбоксы `DataTable` — `select_all_button_label` у заголовка и
`select_row_label` у строк (у Flutter они безымянны, `_buildCheckbox`); строка `BackButton` в
`icon_face` и тесты `data_table` кончаются `t.finish()`, а имена на двух языках читают
`app_bar::a_back_button_is_named_in_the_ambient_language` и
`data_table::the_checkboxes_are_named_in_the_ambient_language`. Остальные элементы названы,
как их называет приложение: колодцы и поля — подписью (`Text`, `InputDecoration::label_text`),
элементы выбора — меткой `Semantics` вокруг них (ADR-0407). Переформулированные и ослабленные утверждения, каждое в
документе теста: пустота и число записей реестра кадров (`Vsync::is_empty`, `len`) читаются
Expand Down Expand Up @@ -909,7 +911,7 @@
конец пропустил проверки отравленного тестера. Аудит конца ни одного виджета не назвал:
безымянные элементы названы, как их называет приложение (`TextButton` с `Text` в
`AlertDialog`, `Semantics(label:)` у значка вкладки без текста и у панели ящика), а
безымянный `BackButton` в `app_bar` уходит со страницей до конца теста. Ящик открывается
`BackButton` в `app_bar` находится по имени «Back». Ящик открывается
кнопкой, которая зовёт `DrawerHandle::open_drawer` (вызов ручки вне хода владельца не
разрешает `GlobalKey`). Переформулированные и ослабленные утверждения, каждое в документе
теста: у диалога `show_dialog` не читаются флаг modal и `labelled_by` (у `Node` их нет), читаются
Expand Down
23 changes: 23 additions & 0 deletions packages/flui-material/src/ambient_strings.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//! The strings a widget of this package builds into what it shows or names, read from the
//! ambient [`WidgetsLocalizations`].
//!
//! A widget reads them where it builds the part that shows them, so a widget without that
//! part depends on no localizations. Without a `Localizations` above the widget, the strings
//! are [`DefaultWidgetsLocalizations`]' English ones.

use flui_sdk::view::BuildContext;
use flui_sdk::widgets::{
BoxedWidgetsLocalizations, DefaultWidgetsLocalizations, WidgetsLocalizations,
};

/// `read` applied to the [`WidgetsLocalizations`] above `ctx`, registering the dependency,
/// or to [`DefaultWidgetsLocalizations`] when none is above it.
pub(crate) fn localized<T>(
ctx: &dyn BuildContext,
read: impl FnOnce(&dyn WidgetsLocalizations) -> T,
) -> T {
match BoxedWidgetsLocalizations::maybe_of(ctx) {
Some(localizations) => read(&**localizations),
None => read(&DefaultWidgetsLocalizations),
}
}
11 changes: 9 additions & 2 deletions packages/flui-material/src/back_button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@
//! reading start.

use flui_sdk::view::prelude::*;
use flui_sdk::widgets::{Icon, IconData, PageHandle};
use flui_sdk::widgets::{Icon, IconData, PageHandle, WidgetsLocalizations};

use crate::ambient_strings::localized;
use crate::button_style_button::PressCallback;
use crate::icon_button::IconButton;

Expand All @@ -47,6 +48,11 @@ pub(crate) fn back_arrow_icon_data() -> IconData {
/// every route (and with no override), the button mounts disabled
/// rather than panicking.
///
/// Assistive technology hears it as the ambient
/// [`WidgetsLocalizations::back_button_label`](flui_sdk::widgets::WidgetsLocalizations::back_button_label)
/// ("Back" in English), the string Flutter 3.50.1's `BackButton` shows as its tooltip
/// (`MaterialLocalizations.backButtonTooltip`); no tooltip shows here.
///
/// ```rust
/// use flui_material::BackButton;
///
Expand Down Expand Up @@ -88,7 +94,8 @@ impl BackButton {

impl StatelessView for BackButton {
fn build(&self, ctx: &dyn BuildContext) -> impl IntoView {
let icon = Icon::new(back_arrow_icon_data());
let label = localized(ctx, WidgetsLocalizations::back_button_label);
let icon = Icon::new(back_arrow_icon_data()).semantic_label(label);
let mut button = IconButton::new(icon);

if let Some(on_pressed) = self.on_pressed.clone() {
Expand Down
22 changes: 6 additions & 16 deletions packages/flui-material/src/chip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ use flui_sdk::view::prelude::*;
use flui_sdk::widgets::__private::node::Description;
use flui_sdk::widgets::IconData;
use flui_sdk::widgets::{
BoxedWidgetsLocalizations, ConstrainedBox, CustomPaint, DefaultTextStyle,
DefaultWidgetsLocalizations, Icon, IconTheme, IconThemeData, Opacity, Padding, Row,
WidgetState, WidgetStates, WidgetsLocalizations,
ConstrainedBox, CustomPaint, DefaultTextStyle, Icon, IconTheme, IconThemeData, Opacity,
Padding, Row, WidgetState, WidgetStates, WidgetsLocalizations,
};
use flui_sdk::{
geometry::{EdgeInsets, Point, Size},
painting::styling::Color,
};

use crate::ambient_strings::localized;
use crate::color_scheme::ColorScheme;
use crate::ink_well::InkWell;
use crate::material::Material;
Expand Down Expand Up @@ -376,7 +376,7 @@ type FilterChipSelectCallback = Rc<dyn Fn(&mut flui_sdk::view::EventContext<'_>,
/// - **Delete-button tooltip** — Flutter shows `deleteButtonTooltipMessage`
/// as the tooltip and names the delete button's node with it, falling back
/// to `MaterialLocalizations.deleteButtonTooltip`. Here the node is named by
/// the ambient [`WidgetsLocalizations::delete_button_tooltip`] and no
/// the ambient [`WidgetsLocalizations::delete_button_tooltip`](flui_sdk::widgets::WidgetsLocalizations::delete_button_tooltip) and no
/// tooltip shows; there is no `delete_button_tooltip_message` override.
/// - **`focus_node`/`autofocus`** — [`InkWell`] itself has no `autofocus`
/// hook yet, matching every other selection-control's own deferred list.
Expand Down Expand Up @@ -544,7 +544,7 @@ impl StatelessView for Chip {
delete_icon_color,
self.enabled,
on_deleted,
delete_button_tooltip(ctx),
localized(ctx, WidgetsLocalizations::delete_button_tooltip),
)
});

Expand Down Expand Up @@ -835,7 +835,7 @@ impl StatelessView for FilterChip {
delete_icon_color,
enabled,
on_deleted,
delete_button_tooltip(ctx),
localized(ctx, WidgetsLocalizations::delete_button_tooltip),
)
});

Expand Down Expand Up @@ -886,16 +886,6 @@ impl StatelessView for FilterChip {
}
}

/// The delete button's name: the ambient [`WidgetsLocalizations::delete_button_tooltip`],
/// or the English default when no `Localizations` above the chip supplies one. Read only
/// where a delete button is built, so a chip without one depends on no localizations.
fn delete_button_tooltip(ctx: &dyn BuildContext) -> &'static str {
match BoxedWidgetsLocalizations::maybe_of(ctx) {
Some(localizations) => localizations.delete_button_tooltip(),
None => DefaultWidgetsLocalizations.delete_button_tooltip(),
}
}

/// A chip's delete button: a well of its own over the delete glyph, a button
/// node whether or not the chip has a handler of its own, so activating the
/// chip never deletes it and the delete button's node does not come and go
Expand Down
22 changes: 17 additions & 5 deletions packages/flui-material/src/data_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ use flui_sdk::semantics::SemanticsRole;
use flui_sdk::view::prelude::*;
use flui_sdk::widgets::{
Center, Container, DefaultTextStyle, Directionality, Padding, Semantics, SizedBox, Table,
TableCell, TableRow, WidgetState, WidgetStateProperty, WidgetStates,
TableCell, TableRow, WidgetState, WidgetStateProperty, WidgetStates, WidgetsLocalizations,
};

use crate::ambient_strings::localized;
use crate::checkbox::{CHECKBOX_EDGE_SIZE, Checkbox};
use crate::color_scheme::ColorScheme;
use crate::ink_well::InkWell;
Expand Down Expand Up @@ -262,6 +263,13 @@ impl DataRow {
/// [`DataTable::on_select_all`] overrides the fan-out; otherwise every
/// selectable row whose `selected` differs from the new value is toggled.
///
/// Assistive technology hears the heading checkbox as the ambient
/// [`WidgetsLocalizations::select_all_button_label`](flui_sdk::widgets::WidgetsLocalizations::select_all_button_label)
/// ("Select all") and each row's as
/// [`WidgetsLocalizations::select_row_label`](flui_sdk::widgets::WidgetsLocalizations::select_row_label)
/// with the row's 1-based place below the heading ("Select row 1"). Flutter 3.50.1's
/// `DataTable` leaves both unnamed (`_buildCheckbox`), so a reader announced a bare checkbox.
///
/// # Deferred (named, not silently dropped)
///
/// - **Sorting** — a sort column index and direction, per-column sort
Expand Down Expand Up @@ -784,31 +792,33 @@ fn wrap_selectable(
ink_well.boxed()
}

/// The heading checkbox cell: a tristate [`Checkbox`] centered in its
/// The heading checkbox cell: a tristate [`Checkbox`] named `label`, centered in its
/// margin, wrapped to fill the checkbox column's cell.
fn header_checkbox_cell(
checked: Option<bool>,
on_change: impl Fn(&mut flui_sdk::view::EventContext<'_>, Option<bool>) + 'static,
margin_start: f64,
margin_end: f64,
direction: TextDirection,
label: String,
) -> BoxedView {
let checkbox = Checkbox::tristate(checked).on_changed(on_change);
let content = Semantics::new().container(true).child(
Padding::new(horizontal_insets(margin_start, margin_end, direction))
.child(Center::new().child(checkbox)),
.child(Center::new().child(Semantics::new().label(label).child(checkbox))),
);
TableCell::new(TableCellVerticalAlignment::Fill, content).boxed()
}

/// A data row's checkbox cell: a non-tristate [`Checkbox`], with the whole
/// A data row's checkbox cell: a non-tristate [`Checkbox`] named `label`, with the whole
/// cell also tap-toggling the row when selectable.
fn row_checkbox_cell(
selected: bool,
on_select_changed: Option<RowSelectCallback>,
margin_start: f64,
margin_end: f64,
direction: TextDirection,
label: String,
overlay: Option<RowColorProperty>,
) -> BoxedView {
let mut checkbox = Checkbox::new(selected);
Expand All @@ -819,7 +829,7 @@ fn row_checkbox_cell(
.container(true)
.child(
Padding::new(horizontal_insets(margin_start, margin_end, direction))
.child(Center::new().child(checkbox)),
.child(Center::new().child(Semantics::new().label(label).child(checkbox))),
)
.boxed();

Expand Down Expand Up @@ -981,6 +991,7 @@ impl StatelessView for DataTable {
style.checkbox_margin_start,
style.checkbox_margin_end,
direction,
localized(ctx, WidgetsLocalizations::select_all_button_label).to_owned(),
));
}
for (index, column) in self.columns.iter().enumerate() {
Expand Down Expand Up @@ -1029,6 +1040,7 @@ impl StatelessView for DataTable {
style.checkbox_margin_start,
style.checkbox_margin_end,
direction,
localized(ctx, |strings| strings.select_row_label(row_index + 1)),
overlay.clone(),
));
}
Expand Down
1 change: 1 addition & 0 deletions packages/flui-material/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#![deny(missing_docs)]
#![warn(clippy::disallowed_types)]

mod ambient_strings;
mod animated_icons;
mod app;
mod app_bar;
Expand Down
Loading
Loading