Skip to content

Commit 244896a

Browse files
Merge pull request #1877 from EnsembleUI/textInput-Reader-Accessibility
Accessibility
2 parents cbd4363 + 8a902d6 commit 244896a

File tree

2 files changed

+31
-8
lines changed

2 files changed

+31
-8
lines changed

modules/ensemble/lib/layout/data_grid.dart

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ class DataGrid extends StatefulWidget
8282
controller.dataRowHeight = Utils.optionalDouble(val),
8383
'headingRowHeight': (val) =>
8484
controller.headingRowHeight = Utils.optionalDouble(val),
85+
'scrollbarBehaviour': (val) =>
86+
controller.scrollbarBehaviour =
87+
Utils.getEnum<ScrollbarBehaviour>(val, ScrollbarBehaviour.values),
88+
'thumbThickness': (val) =>
89+
controller.thumbThickness = Utils.optionalDouble(val),
8590
'columnSpacing': (val) =>
8691
controller.columnSpacing = Utils.optionalDouble(val),
8792
'dividerThickness': (val) =>
@@ -184,7 +189,9 @@ class DataGridController extends BoxController {
184189
GenericTextController? headingTextController;
185190
double? dataRowHeight;
186191
double? headingRowHeight;
192+
ScrollbarBehaviour? scrollbarBehaviour;
187193
double? columnSpacing;
194+
double? thumbThickness;
188195
GenericTextController? dataTextController;
189196
double? dividerThickness;
190197
TableBorder border = const TableBorder();
@@ -268,6 +275,7 @@ class DataGridState extends EWidgetState<DataGrid>
268275
@override
269276
Widget buildWidget(BuildContext context) {
270277
ScopeManager? scopeManager = DataScopeWidget.getScope(context);
278+
final ScrollController _scrollController = ScrollController();
271279
if (scopeManager == null) {
272280
throw Exception(
273281
'scopeManager is null in the DataGrid.buildWidget method. This is unexpected. DataGrid.id=${widget.id}');
@@ -311,13 +319,17 @@ class DataGridState extends EWidgetState<DataGrid>
311319
);
312320
return SingleChildScrollView(
313321
scrollDirection: Axis.vertical,
314-
child: SingleChildScrollView(
315-
scrollDirection: Axis.horizontal,
316322

317-
// DataTable requires all children to report their intrinsic height.
318-
// Some widgets don't like that so we expose this so the widgets
319-
// can react accordingly
320-
child: RequiresChildWithIntrinsicDimension(child: grid),
323+
child: RawScrollbar(
324+
thickness: widget.controller.thumbThickness,
325+
controller: _scrollController,
326+
thumbVisibility: widget.controller.scrollbarBehaviour == ScrollbarBehaviour.static,
327+
trackVisibility: widget.controller.scrollbarBehaviour == ScrollbarBehaviour.static,
328+
child: SingleChildScrollView(
329+
scrollDirection: Axis.horizontal,
330+
controller: _scrollController,
331+
child: RequiresChildWithIntrinsicDimension(child: grid),
332+
),
321333
),
322334
);
323335
}
@@ -407,7 +419,7 @@ class DataGridState extends EWidgetState<DataGrid>
407419
if (kDebugMode) {
408420
print(
409421
'Number of DataGrid columns must be equal to the number of cells in each row. Number of DataGrid columns is ${_columns.length} '
410-
'while number of cells in the row is ${cells.length}. We will try to match them to be the same');
422+
'while number of cells in the row is ${cells.length}. We will try to match them to be the same');
411423
}
412424
if (_columns.length > cells.length) {
413425
int diff = _columns.length - cells.length;
@@ -503,3 +515,7 @@ class DataGridState extends EWidgetState<DataGrid>
503515
}
504516
}
505517
}
518+
enum ScrollbarBehaviour{
519+
static,
520+
fade
521+
}

modules/ensemble/lib/widget/helpers/input_wrapper.dart

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,14 @@ class InputWrapper extends StatelessWidget {
7777
Theme.of(context).inputDecorationTheme.labelStyle,
7878
),
7979
),
80-
widget,
80+
// semantics for whatever text input comes through
81+
MergeSemantics(
82+
child: Semantics(
83+
label: controller.label,
84+
child: widget,
85+
),
86+
),
87+
8188
if (shouldShowLabel && controller.description != null)
8289
Container(
8390
margin: const EdgeInsets.only(top: 12.0),

0 commit comments

Comments
 (0)