Skip to content

Commit

Permalink
Add sample Semantics identifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
tddang-linagora committed Sep 12, 2024
1 parent 30525ff commit e74e201
Show file tree
Hide file tree
Showing 14 changed files with 907 additions and 793 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class ConfirmationDialogKeyValues {
static const String title = 'tmail_confirmation_dialog_title';
static const String content = 'tmail_confirmation_dialog_content';
static const String confirmButton = 'tmail_confirmation_dialog_confirm_button';
static const String cancelButton = 'tmail_confirmation_dialog_cancel_button';
static const String closeButton = 'tmail_confirmation_dialog_close_button';
}
10 changes: 10 additions & 0 deletions core/lib/presentation/constants/search_key_values.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class SearchKeyValues {
static const String searchInputField = 'tmail_search_input_field';
static const String searchUserResult = 'tmail_search_user_result';
static const String searchEmailResult = 'tmail_search_email_result';
}

// When search input field is focused
// And search input field is not empty
// Then user result should be shown with maximum 2 results
// And email result should be shown with maximum 5 results
127 changes: 76 additions & 51 deletions core/lib/presentation/views/dialog/confirmation_dialog_builder.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

import 'package:core/core.dart';
import 'package:core/presentation/constants/confirmation_dialog_key_values.dart';
import 'package:core/presentation/views/dialog/confirm_dialog_button.dart';
import 'package:flutter/material.dart';

Expand Down Expand Up @@ -184,13 +185,16 @@ class ConfirmDialogBuilder {
if (_onCloseButtonAction != null)
Align(
alignment: AlignmentDirectional.centerEnd,
child: TMailButtonWidget.fromIcon(
icon: _imagePath.icCircleClose,
iconSize: 30,
padding: const EdgeInsets.all(3),
backgroundColor: Colors.transparent,
margin: const EdgeInsetsDirectional.only(top: 16, end: 16),
onTapActionCallback: _onCloseButtonAction
child: Semantics(
label: ConfirmationDialogKeyValues.closeButton,
child: TMailButtonWidget.fromIcon(
icon: _imagePath.icCircleClose,
iconSize: 30,
padding: const EdgeInsets.all(3),
backgroundColor: Colors.transparent,
margin: const EdgeInsetsDirectional.only(top: 16, end: 16),
onTapActionCallback: _onCloseButtonAction
),
)
),
if (_iconWidget != null)
Expand All @@ -203,32 +207,41 @@ class ConfirmDialogBuilder {
Padding(
padding: _paddingTitle ?? const EdgeInsetsDirectional.only(top: 12, start: 24, end: 24),
child: Center(
child: Text(
_title,
textAlign: TextAlign.center,
style: _styleTitle ?? const TextStyle(fontSize: 20.0, color: AppColor.colorActionDeleteConfirmDialog, fontWeight: FontWeight.w500)
child: Semantics(
identifier: ConfirmationDialogKeyValues.title,
child: Text(
_title,
textAlign: TextAlign.center,
style: _styleTitle ?? const TextStyle(fontSize: 20.0, color: AppColor.colorActionDeleteConfirmDialog, fontWeight: FontWeight.w500)
),
)
)
),
if (_content.isNotEmpty)
Padding(
padding: _paddingContent ?? const EdgeInsets.symmetric(horizontal: 16, vertical: 24),
child: Center(
child: Text(_content,
textAlign: TextAlign.center,
style: _styleContent ?? const TextStyle(fontSize: 17.0, color: AppColor.colorMessageDialog)
child: Semantics(
identifier: ConfirmationDialogKeyValues.content,
child: Text(_content,
textAlign: TextAlign.center,
style: _styleContent ?? const TextStyle(fontSize: 17.0, color: AppColor.colorMessageDialog)
),
),
),
)
else if (listTextSpan != null)
Padding(
padding: _paddingContent ?? const EdgeInsets.symmetric(horizontal: 16, vertical: 24),
child: Center(
child: RichText(
textAlign: TextAlign.center,
text: TextSpan(
style: _styleContent ?? const TextStyle(fontSize: 17.0, color: AppColor.colorMessageDialog),
children: listTextSpan
child: Semantics(
identifier: ConfirmationDialogKeyValues.content,
child: RichText(
textAlign: TextAlign.center,
text: TextSpan(
style: _styleContent ?? const TextStyle(fontSize: 17.0, color: AppColor.colorMessageDialog),
children: listTextSpan
),
),
),
),
Expand All @@ -238,26 +251,32 @@ class ConfirmDialogBuilder {
if (_cancelText.isNotEmpty)
Padding(
padding: const EdgeInsetsDirectional.only(top: 8, start: 16, end: 16),
child: ConfirmDialogButton(
label: _cancelText,
backgroundColor: _colorCancelButton,
borderRadius: _radiusButton,
textStyle: _styleTextCancelButton,
padding: _paddingButton,
maxLines: titleActionButtonMaxLines,
onTapAction: _onCancelButtonAction),
child: Semantics(
identifier: ConfirmationDialogKeyValues.cancelButton,
child: ConfirmDialogButton(
label: _cancelText,
backgroundColor: _colorCancelButton,
borderRadius: _radiusButton,
textStyle: _styleTextCancelButton,
padding: _paddingButton,
maxLines: titleActionButtonMaxLines,
onTapAction: _onCancelButtonAction),
),
),
if (_confirmText.isNotEmpty)
Padding(
padding: const EdgeInsetsDirectional.only(top: 8, start: 16, end: 16),
child: ConfirmDialogButton(
label: _confirmText,
backgroundColor: _colorConfirmButton,
borderRadius: _radiusButton,
textStyle: _styleTextConfirmButton,
padding: _paddingButton,
maxLines: titleActionButtonMaxLines,
onTapAction: _onConfirmButtonAction),
child: Semantics(
identifier: ConfirmationDialogKeyValues.confirmButton,
child: ConfirmDialogButton(
label: _confirmText,
backgroundColor: _colorConfirmButton,
borderRadius: _radiusButton,
textStyle: _styleTextConfirmButton,
padding: _paddingButton,
maxLines: titleActionButtonMaxLines,
onTapAction: _onConfirmButtonAction),
),
),
const SizedBox(height: 16),
]
Expand All @@ -267,24 +286,30 @@ class ConfirmDialogBuilder {
child: Row(
children: [
if (_cancelText.isNotEmpty)
Expanded(child: ConfirmDialogButton(
label: _cancelText,
backgroundColor: _colorCancelButton,
borderRadius: _radiusButton,
textStyle: _styleTextCancelButton,
padding: _paddingButton,
maxLines: titleActionButtonMaxLines,
onTapAction: _onCancelButtonAction)),
Expanded(child: Semantics(
identifier: ConfirmationDialogKeyValues.cancelButton,
child: ConfirmDialogButton(
label: _cancelText,
backgroundColor: _colorCancelButton,
borderRadius: _radiusButton,
textStyle: _styleTextCancelButton,
padding: _paddingButton,
maxLines: titleActionButtonMaxLines,
onTapAction: _onCancelButtonAction),
)),
if (_confirmText.isNotEmpty && _cancelText.isNotEmpty) const SizedBox(width: 8),
if (_confirmText.isNotEmpty)
Expanded(child: ConfirmDialogButton(
label: _confirmText,
backgroundColor: _colorConfirmButton,
borderRadius: _radiusButton,
textStyle: _styleTextConfirmButton,
padding: _paddingButton,
maxLines: titleActionButtonMaxLines,
onTapAction: _onConfirmButtonAction,))
Expanded(child: Semantics(
identifier: ConfirmationDialogKeyValues.confirmButton,
child: ConfirmDialogButton(
label: _confirmText,
backgroundColor: _colorConfirmButton,
borderRadius: _radiusButton,
textStyle: _styleTextConfirmButton,
padding: _paddingButton,
maxLines: titleActionButtonMaxLines,
onTapAction: _onConfirmButtonAction,),
))
]
))
]
Expand Down
102 changes: 56 additions & 46 deletions core/lib/presentation/views/quick_search/quick_search_input_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:async';
import 'dart:io';
import 'dart:math';

import 'package:core/presentation/constants/search_key_values.dart';
import 'package:core/presentation/extensions/color_extension.dart';
import 'package:core/utils/app_logger.dart';
import 'package:core/utils/direction_utils.dart';
Expand Down Expand Up @@ -850,47 +851,50 @@ class _TypeAheadFieldQuickSearchState<T, P, R> extends State<TypeAheadFieldQuick
if (widget.textFieldConfiguration.leftButton != null)
widget.textFieldConfiguration.leftButton!,
Expanded(
child: TextField(
focusNode: _effectiveFocusNode,
controller: _effectiveController,
decoration: widget.textFieldConfiguration.decoration,
style: widget.textFieldConfiguration.style,
textAlign: widget.textFieldConfiguration.textAlign,
enabled: widget.textFieldConfiguration.enabled,
keyboardType: widget.textFieldConfiguration.keyboardType,
autofocus: widget.textFieldConfiguration.autofocus,
inputFormatters: widget.textFieldConfiguration.inputFormatters,
autocorrect: widget.textFieldConfiguration.autocorrect,
maxLines: widget.textFieldConfiguration.maxLines,
textAlignVertical: widget.textFieldConfiguration.textAlignVertical,
minLines: widget.textFieldConfiguration.minLines,
maxLength: widget.textFieldConfiguration.maxLength,
maxLengthEnforcement: widget.textFieldConfiguration.maxLengthEnforcement,
obscureText: widget.textFieldConfiguration.obscureText,
onChanged: (input) {
widget.textFieldConfiguration.onChanged?.call(input);
if (input.isNotEmpty) {
final directionByText = DirectionUtils.getDirectionByEndsText(input);
if (directionByText != _textDirection) {
setState(() {
_textDirection = directionByText;
});
child: Semantics(
identifier: SearchKeyValues.searchInputField,
child: TextField(
focusNode: _effectiveFocusNode,
controller: _effectiveController,
decoration: widget.textFieldConfiguration.decoration,
style: widget.textFieldConfiguration.style,
textAlign: widget.textFieldConfiguration.textAlign,
enabled: widget.textFieldConfiguration.enabled,
keyboardType: widget.textFieldConfiguration.keyboardType,
autofocus: widget.textFieldConfiguration.autofocus,
inputFormatters: widget.textFieldConfiguration.inputFormatters,
autocorrect: widget.textFieldConfiguration.autocorrect,
maxLines: widget.textFieldConfiguration.maxLines,
textAlignVertical: widget.textFieldConfiguration.textAlignVertical,
minLines: widget.textFieldConfiguration.minLines,
maxLength: widget.textFieldConfiguration.maxLength,
maxLengthEnforcement: widget.textFieldConfiguration.maxLengthEnforcement,
obscureText: widget.textFieldConfiguration.obscureText,
onChanged: (input) {
widget.textFieldConfiguration.onChanged?.call(input);
if (input.isNotEmpty) {
final directionByText = DirectionUtils.getDirectionByEndsText(input);
if (directionByText != _textDirection) {
setState(() {
_textDirection = directionByText;
});
}
}
}
},
onSubmitted: widget.textFieldConfiguration.onSubmitted,
onEditingComplete: widget.textFieldConfiguration.onEditingComplete,
onTap: widget.textFieldConfiguration.onTap,
scrollPadding: widget.textFieldConfiguration.scrollPadding,
textInputAction: widget.textFieldConfiguration.textInputAction,
textCapitalization: widget.textFieldConfiguration.textCapitalization,
keyboardAppearance: widget.textFieldConfiguration.keyboardAppearance,
cursorWidth: widget.textFieldConfiguration.cursorWidth,
cursorRadius: widget.textFieldConfiguration.cursorRadius,
cursorColor: widget.textFieldConfiguration.cursorColor,
textDirection: _textDirection,
enableInteractiveSelection: widget.textFieldConfiguration.enableInteractiveSelection,
readOnly: widget.hideKeyboard,
},
onSubmitted: widget.textFieldConfiguration.onSubmitted,
onEditingComplete: widget.textFieldConfiguration.onEditingComplete,
onTap: widget.textFieldConfiguration.onTap,
scrollPadding: widget.textFieldConfiguration.scrollPadding,
textInputAction: widget.textFieldConfiguration.textInputAction,
textCapitalization: widget.textFieldConfiguration.textCapitalization,
keyboardAppearance: widget.textFieldConfiguration.keyboardAppearance,
cursorWidth: widget.textFieldConfiguration.cursorWidth,
cursorRadius: widget.textFieldConfiguration.cursorRadius,
cursorColor: widget.textFieldConfiguration.cursorColor,
textDirection: _textDirection,
enableInteractiveSelection: widget.textFieldConfiguration.enableInteractiveSelection,
readOnly: widget.hideKeyboard,
),
),
),
if (widget.textFieldConfiguration.clearTextButton != null
Expand Down Expand Up @@ -1202,9 +1206,12 @@ class _SuggestionsListState<T, P, R> extends State<_SuggestionsList<T, P, R>>
Widget createSuggestionsWidget() {
final listItemSuggestionWidget = _suggestions?.map((T suggestion) {
if (widget.itemBuilder != null) {
return InkWell(
child: widget.itemBuilder!(context, suggestion),
onTap: () => widget.onSuggestionSelected?.call(suggestion),
return Semantics(
identifier: SearchKeyValues.searchEmailResult,
child: InkWell(
child: widget.itemBuilder!(context, suggestion),
onTap: () => widget.onSuggestionSelected?.call(suggestion),
),
);
} else {
return const SizedBox.shrink();
Expand Down Expand Up @@ -1251,9 +1258,12 @@ class _SuggestionsListState<T, P, R> extends State<_SuggestionsList<T, P, R>>
if (widget.contactSuggestionBuilder != null) {
return Material(
type: MaterialType.transparency,
child: InkWell(
child: widget.contactSuggestionBuilder!(context, contact),
onTap: () => widget.onContactSuggestionSelected?.call(contact),
child: Semantics(
identifier: SearchKeyValues.searchUserResult,
child: InkWell(
child: widget.contactSuggestionBuilder!(context, contact),
onTap: () => widget.onContactSuggestionSelected?.call(contact),
),
),
);
} else {
Expand Down
6 changes: 6 additions & 0 deletions lib/features/base/key_values/login_basic_auth_key_values.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class LoginBasicAuthKeyValues {
static const String loginView = 'tmail_login_view';
static const String loginEmailField = 'tmail_login_email_field';
static const String loginPasswordField = 'tmail_login_password_field';
static const String loginSubmitButton = 'tmail_login_submit_button';
}
Loading

0 comments on commit e74e201

Please sign in to comment.