TF-2068 Fix calendar banner widget is gray bar
(cherry picked from commit 69998d944921d045c2c26acf0c66e01feb79112d)
This commit is contained in:
@@ -17,12 +17,14 @@ import 'package:model/email/attachment.dart';
|
||||
import 'package:model/email/email_action_type.dart';
|
||||
import 'package:model/email/presentation_email.dart';
|
||||
import 'package:model/extensions/list_attachment_extension.dart';
|
||||
import 'package:model/extensions/list_email_address_extension.dart';
|
||||
import 'package:model/extensions/presentation_email_extension.dart';
|
||||
import 'package:model/mailbox/presentation_mailbox.dart';
|
||||
import 'package:tmail_ui_user/features/base/mixin/app_loader_mixin.dart';
|
||||
import 'package:tmail_ui_user/features/base/widget/custom_scroll_behavior.dart';
|
||||
import 'package:tmail_ui_user/features/base/widget/popup_item_widget.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/controller/single_email_controller.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/extensions/calendar_event_extension.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/styles/email_view_styles.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/widgets/app_bar_mail_widget_builder.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/widgets/attachment_file_tile_builder.dart';
|
||||
@@ -289,21 +291,20 @@ class EmailView extends GetWidget<SingleEmailController> with AppLoaderMixin {
|
||||
)),
|
||||
if (email.hasCalendarEvent)
|
||||
Obx(() {
|
||||
if (controller.calendarEvent.value != null) {
|
||||
final calendarEvent = controller.calendarEvent.value;
|
||||
final listEmailAddressSender = controller.currentEmail?.listEmailAddressSender.getListAddress() ?? [];
|
||||
if (calendarEvent != null) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
CalendarEventInformationWidget(
|
||||
calendarEvent: controller.calendarEvent.value!
|
||||
),
|
||||
CalendarEventActionBannerWidget(
|
||||
calendarEvent: controller.calendarEvent.value!,
|
||||
listFromEmailAddress: controller.currentEmail?.from
|
||||
),
|
||||
CalendarEventDetailWidget(
|
||||
calendarEvent: controller.calendarEvent.value!
|
||||
),
|
||||
CalendarEventInformationWidget(calendarEvent: calendarEvent),
|
||||
if (calendarEvent.getTitleEventAction(context, listEmailAddressSender).isNotEmpty)
|
||||
CalendarEventActionBannerWidget(
|
||||
calendarEvent: calendarEvent,
|
||||
listEmailAddressSender: listEmailAddressSender
|
||||
),
|
||||
CalendarEventDetailWidget(calendarEvent: calendarEvent),
|
||||
],
|
||||
);
|
||||
} else {
|
||||
|
||||
@@ -14,7 +14,7 @@ import 'package:tmail_ui_user/main/utils/app_utils.dart';
|
||||
|
||||
extension CalendarEventExtension on CalendarEvent {
|
||||
|
||||
Color getColorEventActionBanner(String senderEmailAddress) {
|
||||
Color getColorEventActionBanner(List<String> listEmailAddressSender) {
|
||||
switch(method) {
|
||||
case EventMethod.request:
|
||||
case EventMethod.add:
|
||||
@@ -26,7 +26,7 @@ extension CalendarEventExtension on CalendarEvent {
|
||||
case EventMethod.declineCounter:
|
||||
return AppColor.colorCanceledEventActionText;
|
||||
case EventMethod.reply:
|
||||
final matchedAttendee = findAttendeeHasUpdatedStatus(senderEmailAddress);
|
||||
final matchedAttendee = findAttendeeHasUpdatedStatus(listEmailAddressSender);
|
||||
if (matchedAttendee != null) {
|
||||
return getAttendeeMessageTextColor(matchedAttendee.participationStatus);
|
||||
} else {
|
||||
@@ -37,7 +37,7 @@ extension CalendarEventExtension on CalendarEvent {
|
||||
}
|
||||
}
|
||||
|
||||
Color getColorEventActionText(String senderEmailAddress) {
|
||||
Color getColorEventActionText(List<String> listEmailAddressSender) {
|
||||
switch(method) {
|
||||
case EventMethod.request:
|
||||
case EventMethod.add:
|
||||
@@ -49,7 +49,7 @@ extension CalendarEventExtension on CalendarEvent {
|
||||
case EventMethod.declineCounter:
|
||||
return AppColor.colorCanceledEventActionText;
|
||||
case EventMethod.reply:
|
||||
final matchedAttendee = findAttendeeHasUpdatedStatus(senderEmailAddress);
|
||||
final matchedAttendee = findAttendeeHasUpdatedStatus(listEmailAddressSender);
|
||||
if (matchedAttendee != null) {
|
||||
return getAttendeeMessageTextColor(matchedAttendee.participationStatus);
|
||||
} else {
|
||||
@@ -74,7 +74,7 @@ extension CalendarEventExtension on CalendarEvent {
|
||||
}
|
||||
}
|
||||
|
||||
String getTitleEventAction(BuildContext context, String senderEmailAddress) {
|
||||
String getTitleEventAction(BuildContext context, List<String> listEmailAddressSender) {
|
||||
switch(method) {
|
||||
case EventMethod.request:
|
||||
case EventMethod.add:
|
||||
@@ -84,7 +84,7 @@ extension CalendarEventExtension on CalendarEvent {
|
||||
case EventMethod.cancel:
|
||||
return AppLocalizations.of(context).messageEventActionBannerOrganizerCanceled;
|
||||
case EventMethod.reply:
|
||||
final matchedAttendee = findAttendeeHasUpdatedStatus(senderEmailAddress);
|
||||
final matchedAttendee = findAttendeeHasUpdatedStatus(listEmailAddressSender);
|
||||
if (matchedAttendee != null) {
|
||||
return getAttendeeMessageStatus(context, matchedAttendee.participationStatus);
|
||||
} else {
|
||||
@@ -113,7 +113,7 @@ extension CalendarEventExtension on CalendarEvent {
|
||||
String getUserNameEventAction({
|
||||
required BuildContext context,
|
||||
required ImagePaths imagePaths,
|
||||
required String senderEmailAddress
|
||||
required List<String> listEmailAddressSender
|
||||
}) {
|
||||
switch(method) {
|
||||
case EventMethod.request:
|
||||
@@ -124,7 +124,7 @@ extension CalendarEventExtension on CalendarEvent {
|
||||
return getOrganizerName(context);
|
||||
case EventMethod.reply:
|
||||
case EventMethod.counter:
|
||||
return getAttendeeName(context, senderEmailAddress);
|
||||
return getAttendeeName(context, listEmailAddressSender);
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
@@ -132,8 +132,8 @@ extension CalendarEventExtension on CalendarEvent {
|
||||
|
||||
String getOrganizerName(BuildContext context) => organizer?.name ?? AppLocalizations.of(context).you;
|
||||
|
||||
String getAttendeeName(BuildContext context, String senderEmailAddress) {
|
||||
final matchedAttendee = findAttendeeHasUpdatedStatus(senderEmailAddress);
|
||||
String getAttendeeName(BuildContext context, List<String> listEmailAddressSender) {
|
||||
final matchedAttendee = findAttendeeHasUpdatedStatus(listEmailAddressSender);
|
||||
if (matchedAttendee != null) {
|
||||
return matchedAttendee.name?.name ?? AppLocalizations.of(context).anAttendee;
|
||||
} else {
|
||||
@@ -141,10 +141,10 @@ extension CalendarEventExtension on CalendarEvent {
|
||||
}
|
||||
}
|
||||
|
||||
CalendarAttendee? findAttendeeHasUpdatedStatus(String senderEmailAddress) {
|
||||
CalendarAttendee? findAttendeeHasUpdatedStatus(List<String> listEmailAddressSender) {
|
||||
if (participants?.isNotEmpty == true) {
|
||||
final listMatchedAttendee = participants
|
||||
!.where((attendee) => attendee.mailto?.mailAddress.value == senderEmailAddress)
|
||||
!.where((attendee) => attendee.mailto != null && listEmailAddressSender.contains(attendee.mailto!.mailAddress.value))
|
||||
.whereNotNull();
|
||||
log('CalendarEventExtension::findAttendeeHasUpdatedStatus:listMatchedAttendee: $listMatchedAttendee');
|
||||
if (listMatchedAttendee.isNotEmpty) {
|
||||
|
||||
+7
-17
@@ -5,20 +5,18 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/calendar/calendar_event.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/email/presentation/extensions/calendar_event_extension.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/styles/calendar_event_action_banner_styles.dart';
|
||||
|
||||
class CalendarEventActionBannerWidget extends StatelessWidget {
|
||||
|
||||
final CalendarEvent calendarEvent;
|
||||
final Set<EmailAddress>? listFromEmailAddress;
|
||||
final List<String> listEmailAddressSender;
|
||||
|
||||
const CalendarEventActionBannerWidget({
|
||||
super.key,
|
||||
required this.calendarEvent,
|
||||
required this.listFromEmailAddress,
|
||||
required this.listEmailAddressSender,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -27,7 +25,7 @@ class CalendarEventActionBannerWidget extends StatelessWidget {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(CalendarEventActionBannerStyles.borderRadius)),
|
||||
color: calendarEvent.getColorEventActionBanner(_getSenderEmailAddress()).withOpacity(0.12)
|
||||
color: calendarEvent.getColorEventActionBanner(listEmailAddressSender).withOpacity(0.12)
|
||||
),
|
||||
padding: const EdgeInsets.all(CalendarEventActionBannerStyles.contentPadding),
|
||||
margin: const EdgeInsets.symmetric(
|
||||
@@ -56,22 +54,22 @@ class CalendarEventActionBannerWidget extends StatelessWidget {
|
||||
style: TextStyle(
|
||||
fontSize: CalendarEventActionBannerStyles.titleTextSize,
|
||||
fontWeight: FontWeight.w400,
|
||||
color: calendarEvent.getColorEventActionText(_getSenderEmailAddress())
|
||||
color: calendarEvent.getColorEventActionText(listEmailAddressSender)
|
||||
),
|
||||
children: [
|
||||
TextSpan(
|
||||
text: calendarEvent.getUserNameEventAction(
|
||||
context: context,
|
||||
imagePaths: imagePaths,
|
||||
senderEmailAddress: _getSenderEmailAddress()
|
||||
listEmailAddressSender: listEmailAddressSender
|
||||
),
|
||||
style: TextStyle(
|
||||
color: calendarEvent.getColorEventActionText(_getSenderEmailAddress()),
|
||||
color: calendarEvent.getColorEventActionText(listEmailAddressSender),
|
||||
fontSize: CalendarEventActionBannerStyles.titleTextSize,
|
||||
fontWeight: FontWeight.w700
|
||||
),
|
||||
),
|
||||
TextSpan(text: calendarEvent.getTitleEventAction(context, _getSenderEmailAddress()))
|
||||
TextSpan(text: calendarEvent.getTitleEventAction(context, listEmailAddressSender))
|
||||
]
|
||||
)
|
||||
),
|
||||
@@ -90,12 +88,4 @@ class CalendarEventActionBannerWidget extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
String _getSenderEmailAddress() {
|
||||
if (listFromEmailAddress?.isNotEmpty == true) {
|
||||
return listFromEmailAddress!.first.emailAddress;
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,8 @@ extension ListEmailAddressExtension on Set<EmailAddress>? {
|
||||
|
||||
List<EmailAddress> asList() => this != null ? this!.toList() : List.empty();
|
||||
|
||||
Set<EmailAddress> asSet() => this ?? {};
|
||||
|
||||
List<String> emailAddressToListString({ExpandMode expandMode = ExpandMode.EXPAND, int limitAddress = 1, bool isFullEmailAddress = false}) {
|
||||
if (this != null) {
|
||||
if (expandMode == ExpandMode.EXPAND) {
|
||||
|
||||
@@ -34,6 +34,8 @@ extension PresentationEmailExtension on PresentationEmail {
|
||||
return '';
|
||||
}
|
||||
|
||||
Set<EmailAddress> get listEmailAddressSender => from.asSet()..addAll(replyTo.asSet());
|
||||
|
||||
PresentationEmail toggleSelect() {
|
||||
return PresentationEmail(
|
||||
id: this.id,
|
||||
|
||||
Reference in New Issue
Block a user