Skip to content

Commit

Permalink
Add Semantics to email tile and email details
Browse files Browse the repository at this point in the history
  • Loading branch information
tddang-linagora committed Sep 20, 2024
1 parent a63812c commit da8fc31
Show file tree
Hide file tree
Showing 8 changed files with 439 additions and 380 deletions.
8 changes: 8 additions & 0 deletions lib/features/base/key_values/email_details_key_values.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class EmailDetailsKeyValues {
static const String emailDetails = 'tmail_email_details';
static const String subject = 'tmail_email_details_subject';
static const String sender = 'tmail_email_details_sender';
static const String senderEmail = 'tmail_email_details_sender_email';
static const String recipient = 'tmail_email_details_recipient';
// find email content with html "iframe"
}
6 changes: 6 additions & 0 deletions lib/features/base/key_values/email_tile_key_values.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class EmailTileKeyValues {
static const String emailTile = 'tmail_email_tile';
static const String sender = 'tmail_email_tile_sender';
static const String subject = 'tmail_email_tile_subject';
static const String preview = 'tmail_email_tile_preview';
}
318 changes: 161 additions & 157 deletions lib/features/email/presentation/email_view.dart

Large diffs are not rendered by default.

26 changes: 15 additions & 11 deletions lib/features/email/presentation/widgets/email_receiver_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import 'package:model/email/presentation_email.dart';
import 'package:model/extensions/email_address_extension.dart';
import 'package:model/extensions/list_email_address_extension.dart';
import 'package:model/extensions/presentation_email_extension.dart';
import 'package:tmail_ui_user/features/base/key_values/email_details_key_values.dart';
import 'package:tmail_ui_user/features/composer/presentation/extensions/prefix_email_address_extension.dart';
import 'package:tmail_ui_user/features/email/presentation/widgets/email_sender_builder.dart';
import 'package:tmail_ui_user/features/email/presentation/widgets/prefix_recipient_widget.dart';
Expand Down Expand Up @@ -231,18 +232,21 @@ class _EmailReceiverWidgetState extends State<EmailReceiverWidget> {

List<Widget> _buildRecipientsTag({required List<EmailAddress> listEmailAddress}) {
return listEmailAddress
.mapIndexed((index, emailAddress) => TMailButtonWidget.fromText(
text: index == listEmailAddress.length - 1
? emailAddress.asString()
: '${emailAddress.asString()},',
textStyle: Theme.of(context).textTheme.labelSmall?.copyWith(
color: Colors.black,
fontSize: 16,
.mapIndexed((index, emailAddress) => Semantics(
identifier: EmailDetailsKeyValues.recipient,
child: TMailButtonWidget.fromText(
text: index == listEmailAddress.length - 1
? emailAddress.asString()
: '${emailAddress.asString()},',
textStyle: Theme.of(context).textTheme.labelSmall?.copyWith(
color: Colors.black,
fontSize: 16,
),
padding: const EdgeInsetsDirectional.symmetric(vertical: 5, horizontal: 8),
backgroundColor: Colors.transparent,
onTapActionCallback: () => widget.openEmailAddressDetailAction?.call(context, emailAddress),
onLongPressActionCallback: () => AppUtils.copyEmailAddressToClipboard(context, emailAddress.emailAddress),
),
padding: const EdgeInsetsDirectional.symmetric(vertical: 5, horizontal: 8),
backgroundColor: Colors.transparent,
onTapActionCallback: () => widget.openEmailAddressDetailAction?.call(context, emailAddress),
onLongPressActionCallback: () => AppUtils.copyEmailAddressToClipboard(context, emailAddress.emailAddress),
))
.toList();
}
Expand Down
59 changes: 33 additions & 26 deletions lib/features/email/presentation/widgets/email_sender_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:core/presentation/utils/style_utils.dart';
import 'package:flutter/material.dart';
import 'package:jmap_dart_client/jmap/mail/email/email_address.dart';
import 'package:model/extensions/email_address_extension.dart';
import 'package:tmail_ui_user/features/base/key_values/email_details_key_values.dart';
import 'package:tmail_ui_user/features/base/widget/material_text_button.dart';
import 'package:tmail_ui_user/main/utils/app_utils.dart';

Expand All @@ -30,35 +31,41 @@ class EmailSenderBuilder extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
children: [
if (emailAddress.displayName.isNotEmpty)
MaterialTextButton(
label: emailAddress.displayName,
onTap: () => openEmailAddressDetailAction?.call(context, emailAddress),
onLongPress: () {
AppUtils.copyEmailAddressToClipboard(context, emailAddress.emailAddress);
},
borderRadius: 8,
padding: const EdgeInsets.all(3),
labelSize: 20,
labelColor: Colors.black,
labelWeight: FontWeight.bold,
overflow: CommonTextStyle.defaultTextOverFlow,
softWrap: CommonTextStyle.defaultSoftWrap
Semantics(
identifier: EmailDetailsKeyValues.sender,
child: MaterialTextButton(
label: emailAddress.displayName,
onTap: () => openEmailAddressDetailAction?.call(context, emailAddress),
onLongPress: () {
AppUtils.copyEmailAddressToClipboard(context, emailAddress.emailAddress);
},
borderRadius: 8,
padding: const EdgeInsets.all(3),
labelSize: 20,
labelColor: Colors.black,
labelWeight: FontWeight.bold,
overflow: CommonTextStyle.defaultTextOverFlow,
softWrap: CommonTextStyle.defaultSoftWrap
),
),
Padding(
padding: const EdgeInsets.only(top: 2),
child: MaterialTextButton(
label: '<${emailAddress.emailAddress}>',
onTap: () => openEmailAddressDetailAction?.call(context, emailAddress),
onLongPress: () {
AppUtils.copyEmailAddressToClipboard(context, emailAddress.emailAddress);
},
borderRadius: 8,
padding: const EdgeInsets.all(3),
labelSize: 16,
labelColor: AppColor.colorEmailAddressFull,
labelWeight: FontWeight.w500,
overflow: CommonTextStyle.defaultTextOverFlow,
softWrap: CommonTextStyle.defaultSoftWrap
child: Semantics(
identifier: EmailDetailsKeyValues.senderEmail,
child: MaterialTextButton(
label: '<${emailAddress.emailAddress}>',
onTap: () => openEmailAddressDetailAction?.call(context, emailAddress),
onLongPress: () {
AppUtils.copyEmailAddressToClipboard(context, emailAddress.emailAddress);
},
borderRadius: 8,
padding: const EdgeInsets.all(3),
labelSize: 16,
labelColor: AppColor.colorEmailAddressFull,
labelWeight: FontWeight.w500,
overflow: CommonTextStyle.defaultTextOverFlow,
softWrap: CommonTextStyle.defaultSoftWrap
),
),
)
]
Expand Down
21 changes: 13 additions & 8 deletions lib/features/email/presentation/widgets/email_subject_widget.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:model/email/presentation_email.dart';
import 'package:tmail_ui_user/features/base/key_values/email_details_key_values.dart';
import 'package:tmail_ui_user/features/email/presentation/styles/email_subject_styles.dart';

class EmailSubjectWidget extends StatelessWidget {
Expand All @@ -12,14 +13,18 @@ class EmailSubjectWidget extends StatelessWidget {
Widget build(BuildContext context) {
return Padding(
padding: EmailSubjectStyles.padding,
child: Text(
presentationEmail.getEmailTitle(),
maxLines: EmailSubjectStyles.maxLines,
style: const TextStyle(
fontSize: EmailSubjectStyles.textSize,
color: EmailSubjectStyles.textColor,
fontWeight: EmailSubjectStyles.fontWeight
)
child: Semantics(
identifier: EmailDetailsKeyValues.subject,
container: true,
child: Text(
presentationEmail.getEmailTitle(),
maxLines: EmailSubjectStyles.maxLines,
style: const TextStyle(
fontSize: EmailSubjectStyles.textSize,
color: EmailSubjectStyles.textColor,
fontWeight: EmailSubjectStyles.fontWeight
)
),
)
);
}
Expand Down
93 changes: 55 additions & 38 deletions lib/features/thread/presentation/mixin/base_email_item_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import 'package:model/email/presentation_email.dart';
import 'package:model/extensions/presentation_email_extension.dart';
import 'package:model/extensions/presentation_mailbox_extension.dart';
import 'package:model/mailbox/presentation_mailbox.dart';
import 'package:tmail_ui_user/features/base/key_values/email_tile_key_values.dart';
import 'package:tmail_ui_user/features/mailbox/presentation/extensions/presentation_mailbox_extension.dart';
import 'package:tmail_ui_user/features/thread/domain/model/search_query.dart';
import 'package:tmail_ui_user/features/thread/presentation/styles/item_email_tile_styles.dart';
Expand Down Expand Up @@ -85,29 +86,37 @@ mixin BaseEmailItemTile {
SearchQuery? query
) {
if (isSearchEnabled(isSearchEmailRunning, query)) {
return RichTextBuilder(
textOrigin: informationSender(email, mailbox),
wordToStyle: query?.value ?? '',
styleOrigin: TextStyle(
fontSize: 15,
color: buildTextColorForReadEmail(email),
fontWeight: buildFontForReadEmail(email)
return Semantics(
identifier: EmailTileKeyValues.sender,
container: true,
child: RichTextBuilder(
textOrigin: informationSender(email, mailbox),
wordToStyle: query?.value ?? '',
styleOrigin: TextStyle(
fontSize: 15,
color: buildTextColorForReadEmail(email),
fontWeight: buildFontForReadEmail(email)
),
styleWord: TextStyle(
fontSize: 15,
color: buildTextColorForReadEmail(email),
backgroundColor: AppColor.bgWordSearch,
fontWeight: buildFontForReadEmail(email)
)
),
styleWord: TextStyle(
fontSize: 15,
color: buildTextColorForReadEmail(email),
backgroundColor: AppColor.bgWordSearch,
fontWeight: buildFontForReadEmail(email)
)
);
} else {
return TextOverflowBuilder(
informationSender(email, mailbox),
style: TextStyle(
fontSize: 15,
overflow: CommonTextStyle.defaultTextOverFlow,
color: buildTextColorForReadEmail(email),
fontWeight: buildFontForReadEmail(email))
return Semantics(
identifier: EmailTileKeyValues.sender,
container: true,
child: TextOverflowBuilder(
informationSender(email, mailbox),
style: TextStyle(
fontSize: 15,
overflow: CommonTextStyle.defaultTextOverFlow,
color: buildTextColorForReadEmail(email),
fontWeight: buildFontForReadEmail(email))
),
);
}
}
Expand Down Expand Up @@ -152,27 +161,35 @@ mixin BaseEmailItemTile {
SearchQuery? query
) {
if (isSearchEnabled(isSearchEmailRunning, query)) {
return RichTextBuilder(
textOrigin: email.getPartialContent(),
wordToStyle: query?.value ?? '',
styleOrigin: const TextStyle(
fontSize: 13,
color: AppColor.colorContentEmail,
fontWeight: FontWeight.normal
return Semantics(
identifier: EmailTileKeyValues.preview,
container: true,
child: RichTextBuilder(
textOrigin: email.getPartialContent(),
wordToStyle: query?.value ?? '',
styleOrigin: const TextStyle(
fontSize: 13,
color: AppColor.colorContentEmail,
fontWeight: FontWeight.normal
),
styleWord: const TextStyle(
fontSize: 13,
color: AppColor.colorContentEmail,
backgroundColor: AppColor.bgWordSearch
)
),
styleWord: const TextStyle(
fontSize: 13,
color: AppColor.colorContentEmail,
backgroundColor: AppColor.bgWordSearch
)
);
} else {
return TextOverflowBuilder(
email.getPartialContent(),
style: const TextStyle(
fontSize: 13,
color: AppColor.colorContentEmail,
fontWeight: FontWeight.normal)
return Semantics(
identifier: EmailTileKeyValues.preview,
container: true,
child: TextOverflowBuilder(
email.getPartialContent(),
style: const TextStyle(
fontSize: 13,
color: AppColor.colorContentEmail,
fontWeight: FontWeight.normal)
),
);
}
}
Expand Down
Loading

0 comments on commit da8fc31

Please sign in to comment.