Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Some actions are not working when Semantics enabled #3086

Open
wants to merge 39 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
e989a7d
Add ADR for enable Semantics
dab246 Aug 19, 2024
fa7e795
Enable semantic
dab246 Aug 28, 2024
5a7ddc0
Fix cannot click item app grid
dab246 Aug 14, 2024
bbd66e5
Fix cannot click item in popup menu
dab246 Aug 14, 2024
2263fe4
Fix click event is overridden when clicking menu button in item mailbox
dab246 Aug 14, 2024
1db5b55
Fix cannot click item dropdown menu
dab246 Aug 14, 2024
7dad3f0
Fix cannot focus mailbox input field in MailboxCreatorView
dab246 Aug 15, 2024
3051c40
Fix cannot item in sortBy popup menu
dab246 Aug 15, 2024
d09edf4
Fix text field not focus when click in ContactView
dab246 Aug 15, 2024
02975c7
Fix text field not focus when click in RenameMailboxView
dab246 Aug 15, 2024
ba61a03
Fix cannot click bottom options (RichText, Attachment, Send, Draft,..)
dab246 Aug 19, 2024
dfa0a07
Fix composer lost focus when click onetime
dab246 Aug 20, 2024
b75178e
Fix overlap suggestion view with advanced search view
dab246 Aug 20, 2024
7d60202
Fix cannot change language in setting view
dab246 Aug 21, 2024
0b47b43
Fix input field lost focus when clicked in Forward View
dab246 Aug 21, 2024
ef73e6d
Fix subject field lost focus when clicked in Vacation View
dab246 Aug 21, 2024
e41ef0a
Fix advanced search view auto closed when click any field
dab246 Aug 21, 2024
523db5a
Fix input field lost focus when clicked in Search Mailbox View
dab246 Aug 21, 2024
ceb5e23
Fix input field lost focus when clicked in Search Email View on Table…
dab246 Aug 21, 2024
9c0b894
Fix lost subject focus in composer web
dab246 Aug 21, 2024
6c87b3f
Remove `dropZoneWidth` & `dropZoneHeight` are not used
dab246 Aug 21, 2024
fc5c194
Fix text color dialog opens twice in composer
dab246 Aug 28, 2024
ca3db0c
Fix `Paragraph` dialog & `Order list` dialog open twice and cannot be…
dab246 Aug 28, 2024
34b1419
Fix `Has attachment` checkbox still lost focus (click on it, but the …
dab246 Aug 28, 2024
5bc6a48
Fix can not use delete button in keyboard in search bar for folder if…
dab246 Aug 28, 2024
3925230
Fix attachment list dialog is closed when click to open pdf
dab246 Aug 28, 2024
4858dd1
Fix can not expand sub folder in Mailbox View
dab246 Aug 29, 2024
7693e53
Fix Advanced Search dialog cannot closed when click advanced search icon
dab246 Aug 29, 2024
6c75976
Fix focus is totally lost in quick form of creating email rule
dab246 Sep 26, 2024
2fb8a6b
Fix `Unexpected null value` when create new email rule
dab246 Sep 26, 2024
054c103
Fix can not select time in vacation
dab246 Sep 30, 2024
2a27c23
Fix can not select `Text color`, `Paragraph` & `Order list` in vacati…
dab246 Sep 30, 2024
288eb55
Fix use `tab` to change focus but focus is never go to body of composer
dab246 Sep 30, 2024
07c0475
Fix `select all` button is clicked, even advanced search stay overlays
dab246 Oct 1, 2024
49f5484
Fix `Select`, `Mark as read`, `Starred` button is clicked, even advan…
dab246 Oct 1, 2024
940b94d
Fix focus indicator still display, but can not fill text in composer …
dab246 Oct 22, 2024
3bdde7d
Fix click outside button (Add action & Add condition) but in the same…
dab246 Nov 6, 2024
7509a9e
Fix quick search and advanced search will show at the same time
dab246 Nov 8, 2024
427358b
Fix close dialog when clicking on empty area on dialog
dab246 Nov 8, 2024
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
1 change: 0 additions & 1 deletion core/lib/core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ export 'presentation/views/quick_search/quick_search_input_form.dart';
export 'presentation/views/toast/toast_position.dart';
export 'presentation/views/toast/tmail_toast.dart';
export 'presentation/views/bottom_popup/full_screen_action_sheet_builder.dart';
export 'presentation/views/checkbox/labeled_checkbox.dart';
export 'presentation/views/container/tmail_container_widget.dart';
export 'presentation/views/clipper/side_arrow_clipper.dart';
export 'presentation/views/avatar/gradient_circle_avatar_icon.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class ConfirmationDialogActionSheetBuilder {
return await showCupertinoModalPopup(
context: _context,
barrierColor: AppColor.colorDefaultCupertinoActionSheet,
barrierDismissible: false,
builder: (context) => PointerInterceptor(child: CupertinoActionSheet(
actions: [
if (_messageText != null && _messageText!.isNotEmpty)
Expand Down
32 changes: 32 additions & 0 deletions core/lib/presentation/views/button/tmail_button_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class TMailButtonWidget extends StatelessWidget {
final MainAxisSize mainAxisSize;
final bool isLoading;
final Color? hoverColor;
final bool expandedText;

const TMailButtonWidget({
super.key,
Expand Down Expand Up @@ -74,6 +75,7 @@ class TMailButtonWidget extends StatelessWidget {
this.mainAxisSize = MainAxisSize.max,
this.isLoading = false,
this.hoverColor,
this.expandedText = false,
});

factory TMailButtonWidget.fromIcon({
Expand Down Expand Up @@ -149,6 +151,7 @@ class TMailButtonWidget extends StatelessWidget {
BoxBorder? border,
int? maxLines,
Color? hoverColor,
bool expandedText = false,
}) {
return TMailButtonWidget(
key: key,
Expand All @@ -172,6 +175,7 @@ class TMailButtonWidget extends StatelessWidget {
border: border,
maxLines: maxLines,
hoverColor: hoverColor,
expandedText: expandedText,
);
}

Expand Down Expand Up @@ -244,6 +248,20 @@ class TMailButtonWidget extends StatelessWidget {
softWrap: maxLines == 1 ? CommonTextStyle.defaultSoftWrap : null,
),
)
else if (expandedText)
Expanded(
child: Text(
text,
textAlign: textAlign,
style: textStyle ?? const TextStyle(
fontSize: 12,
color: AppColor.colorTextButtonHeaderThread
),
maxLines: maxLines,
overflow: maxLines == 1 ? CommonTextStyle.defaultTextOverFlow : null,
softWrap: maxLines == 1 ? CommonTextStyle.defaultSoftWrap : null,
),
)
else
Text(
text,
Expand Down Expand Up @@ -288,6 +306,20 @@ class TMailButtonWidget extends StatelessWidget {
softWrap: maxLines == 1 ? CommonTextStyle.defaultSoftWrap : null,
),
)
else if (expandedText)
Expanded(
child: Text(
text,
textAlign: textAlign,
style: textStyle ?? const TextStyle(
fontSize: 12,
color: AppColor.colorTextButtonHeaderThread
),
maxLines: maxLines,
overflow: maxLines == 1 ? CommonTextStyle.defaultTextOverFlow : null,
softWrap: maxLines == 1 ? CommonTextStyle.defaultSoftWrap : null,
),
)
else
Text(
text,
Expand Down
60 changes: 0 additions & 60 deletions core/lib/presentation/views/checkbox/labeled_checkbox.dart

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class TMailContainerWidget extends StatelessWidget {
type: MaterialType.transparency,
child: InkWell(
onTap: onTapActionCallback,
excludeFromSemantics: true,
onTapDown: onTapActionAtPositionCallback != null
? (detail) {
if (onTapActionAtPositionCallback != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ class ColorPickerDialogBuilder {
})
],
),
)
),
barrierDismissible: false
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# 52. Enable Semantics to support integration test on Web

Date: 2024-08-19

## Status

Accepted

## Context

All the UI in a Flutter app is rendered as a `Widget Tree`. So the widgets can't access the widget tree elements.
So we have to use [Semantics](https://api.flutter.dev/flutter/widgets/Semantics-class.html)
so that when Flutter renders the `Widgets Tree`, it also maintains a second tree, called `Semantics Tree`,
which helps us to easily access each element, widget of the user interface.

## Decision

1. How to enable Semantics:

- Enable `Semantics` in main function:

```dart
void main() {
WidgetsFlutterBinding.ensureInitialized();
SemanticsBinding.instance.ensureSemantics();

runApp(const TMailApp());
}
```

- To access any widget element we just need to wrap it in a `Sematics` widget and set a `label` for it

```dart
Semantics(
label: 'Title-app',
child: Text('Twake Mail'),
);
```

2. To ignore `Sematics` for a specific widget, when we have Semantics enabled

- Way 1: Set the `excludeSemantics: true` property of the `Semantics` widget

```dart
Semantics(
label: 'Title-app',
excludeSemantics: true,
child: Text('Twake Mail'),
);
```

- Way 2: Use `ExcludeSemantics` widget instead of `Semantics` widget

```dart
ExcludeSemantics(
child: Text('Twake Mail'),
);
```

3. For a widget to be treated as a text field in the Semantics Tree

Set the ` textField: true` property of the `Semantics` widget

```dart
Semantics(
label: 'Subject-email',
textField: true,
child: TextField(),
);
```

## Consequences

- Enabling Semantics has given us easy access to the widget elements of each screen. Making `Integration test` implementation easy and efficient.

## Influence

Some widgets are not working due to Semantics overlap:

- Workaround:
- Ignore `Sematics` for a specific widget
- Use the correct properties for each widget used (`textField, button, container,...`)


2 changes: 2 additions & 0 deletions lib/features/base/base_mailbox_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ abstract class BaseMailboxController extends BaseController {
(value) => onRenameMailboxAction(presentationMailbox, MailboxName(value))
)
).build()),
barrierDismissible: false,
barrierColor: AppColor.colorDefaultCupertinoActionSheet,
);
}
Expand Down Expand Up @@ -437,6 +438,7 @@ abstract class BaseMailboxController extends BaseController {
..onConfirmButtonAction(AppLocalizations.of(context).delete, () => onDeleteMailboxAction(presentationMailbox))
..onCancelButtonAction(AppLocalizations.of(context).cancel, () => popBack())
).build()),
barrierDismissible: false,
barrierColor: AppColor.colorDefaultCupertinoActionSheet,
);
}
Expand Down
2 changes: 2 additions & 0 deletions lib/features/base/mixin/mailbox_action_handler_mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ mixin MailboxActionHandlerMixin {
..onCancelButtonAction(AppLocalizations.of(context).cancel, popBack))
.build()
),
barrierDismissible: false,
barrierColor: AppColor.colorDefaultCupertinoActionSheet,
);
}
Expand Down Expand Up @@ -160,6 +161,7 @@ mixin MailboxActionHandlerMixin {
})
..onCancelButtonAction(AppLocalizations.of(context).cancel, popBack)
).build()),
barrierDismissible: false,
barrierColor: AppColor.colorDefaultCupertinoActionSheet,
);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/features/base/mixin/message_dialog_action_mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ mixin MessageDialogActionMixin {
bool hasCancelButton = true,
bool showAsBottomSheet = false,
bool alignCenter = false,
bool outsideDismissible = true,
bool outsideDismissible = false,
bool autoPerformPopBack = true,
bool usePopScope = false,
List<TextSpan>? listTextSpan,
Expand Down
43 changes: 23 additions & 20 deletions lib/features/base/widget/drop_down_button_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,26 +78,29 @@ class DropDownButtonWidget<T> extends StatelessWidget {
items: items
.map((item) => DropdownMenuItem<T>(
value: item,
child: PointerInterceptor(
child: Container(
color: Colors.transparent,
height: heightItem,
child: Row(children: [
Expanded(child: Text(_getTextItemDropdown(context, item: item),
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.normal,
color: Colors.black),
maxLines: 1,
softWrap: CommonTextStyle.defaultSoftWrap,
overflow: CommonTextStyle.defaultTextOverFlow,
)),
if (supportSelectionIcon && item == itemSelected)
SvgPicture.asset(imagePaths.icChecked,
width: sizeIconChecked,
height: sizeIconChecked,
fit: BoxFit.fill)
]),
child: Semantics(
excludeSemantics: true,
child: PointerInterceptor(
child: Container(
color: Colors.transparent,
height: heightItem,
child: Row(children: [
Expanded(child: Text(_getTextItemDropdown(context, item: item),
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.normal,
color: Colors.black),
maxLines: 1,
softWrap: CommonTextStyle.defaultSoftWrap,
overflow: CommonTextStyle.defaultTextOverFlow,
)),
if (supportSelectionIcon && item == itemSelected)
SvgPicture.asset(imagePaths.icChecked,
width: sizeIconChecked,
height: sizeIconChecked,
fit: BoxFit.fill)
]),
),
),
),
))
Expand Down
Loading