TF-3678 Support accessibility for Input field in Identity dialog
Signed-off-by: dab246 <tdvu@linagora.com>
This commit is contained in:
@@ -100,6 +100,9 @@ export 'presentation/views/loading/cupertino_loading_widget.dart';
|
|||||||
export 'presentation/views/image/image_loader_mixin.dart';
|
export 'presentation/views/image/image_loader_mixin.dart';
|
||||||
export 'presentation/views/pull_to_refresh/pull_to_refresh_widget.dart';
|
export 'presentation/views/pull_to_refresh/pull_to_refresh_widget.dart';
|
||||||
export 'presentation/views/button/multi_click_widget.dart';
|
export 'presentation/views/button/multi_click_widget.dart';
|
||||||
|
export 'presentation/views/semantics/checkbox_semantics.dart';
|
||||||
|
export 'presentation/views/semantics/text_field_semantics.dart';
|
||||||
|
export 'presentation/views/semantics/icon_semantics.dart';
|
||||||
|
|
||||||
// Resources
|
// Resources
|
||||||
export 'presentation/resources/assets_paths.dart';
|
export 'presentation/resources/assets_paths.dart';
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class TextFieldSemantics extends StatelessWidget {
|
||||||
|
final Widget child;
|
||||||
|
final String label;
|
||||||
|
final String value;
|
||||||
|
|
||||||
|
const TextFieldSemantics({
|
||||||
|
super.key,
|
||||||
|
required this.child,
|
||||||
|
required this.label,
|
||||||
|
required this.value,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Semantics(label: label, value: value, container: true, child: child);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import 'package:core/presentation/extensions/color_extension.dart';
|
import 'package:core/presentation/extensions/color_extension.dart';
|
||||||
|
import 'package:core/presentation/views/semantics/text_field_semantics.dart';
|
||||||
import 'package:core/utils/direction_utils.dart';
|
import 'package:core/utils/direction_utils.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
@@ -25,6 +26,7 @@ class TextFieldBuilder extends StatefulWidget {
|
|||||||
final TextDirection textDirection;
|
final TextDirection textDirection;
|
||||||
final bool readOnly;
|
final bool readOnly;
|
||||||
final MouseCursor? mouseCursor;
|
final MouseCursor? mouseCursor;
|
||||||
|
final String? semanticLabel;
|
||||||
|
|
||||||
const TextFieldBuilder({
|
const TextFieldBuilder({
|
||||||
super.key,
|
super.key,
|
||||||
@@ -45,6 +47,7 @@ class TextFieldBuilder extends StatefulWidget {
|
|||||||
this.fromValue,
|
this.fromValue,
|
||||||
this.keyboardAppearance,
|
this.keyboardAppearance,
|
||||||
this.mouseCursor,
|
this.mouseCursor,
|
||||||
|
this.semanticLabel,
|
||||||
this.onTap,
|
this.onTap,
|
||||||
this.onTapOutside,
|
this.onTapOutside,
|
||||||
this.onTextChange,
|
this.onTextChange,
|
||||||
@@ -76,7 +79,7 @@ class _TextFieldBuilderState extends State<TextFieldBuilder> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return TextField(
|
final textField = TextField(
|
||||||
key: widget.key,
|
key: widget.key,
|
||||||
controller: _controller,
|
controller: _controller,
|
||||||
cursorColor: widget.cursorColor,
|
cursorColor: widget.cursorColor,
|
||||||
@@ -99,6 +102,16 @@ class _TextFieldBuilderState extends State<TextFieldBuilder> {
|
|||||||
onTap: widget.onTap,
|
onTap: widget.onTap,
|
||||||
onTapOutside: widget.onTapOutside,
|
onTapOutside: widget.onTapOutside,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (widget.semanticLabel != null) {
|
||||||
|
return TextFieldSemantics(
|
||||||
|
label: widget.semanticLabel!,
|
||||||
|
value: _controller?.text ?? '',
|
||||||
|
child: textField,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return textField;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onTextChanged(String value) {
|
void _onTextChanged(String value) {
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ class IdentityInputFieldBuilder extends StatelessWidget {
|
|||||||
focusNode: focusNode,
|
focusNode: focusNode,
|
||||||
textStyle: const TextStyle(color: Colors.black, fontSize: 16),
|
textStyle: const TextStyle(color: Colors.black, fontSize: 16),
|
||||||
keyboardType: inputType ?? TextInputType.text,
|
keyboardType: inputType ?? TextInputType.text,
|
||||||
|
semanticLabel: 'Identity input field',
|
||||||
decoration: (IdentityInputDecorationBuilder()
|
decoration: (IdentityInputDecorationBuilder()
|
||||||
..setContentPadding(EdgeInsets.symmetric(
|
..setContentPadding(EdgeInsets.symmetric(
|
||||||
vertical: PlatformInfo.isWeb ? 16 : 12,
|
vertical: PlatformInfo.isWeb ? 16 : 12,
|
||||||
|
|||||||
Reference in New Issue
Block a user