diff --git a/lib/features/email/presentation/email_view.dart b/lib/features/email/presentation/email_view.dart index 635645612..f86424382 100644 --- a/lib/features/email/presentation/email_view.dart +++ b/lib/features/email/presentation/email_view.dart @@ -362,7 +362,10 @@ class EmailView extends GetWidget { presentationEmail: controller.currentEmail, onMailtoAttendeesAction: controller.handleMailToAttendees, )), - if (calendarEvent.getTitleEventAction(context, emailAddressSender ?? []).isNotEmpty) + if (_validateDisplayEventActionBanner( + context: context, + event: calendarEvent, + emailAddressSender: emailAddressSender ?? [])) CalendarEventActionBannerWidget( calendarEvent: calendarEvent, listEmailAddressSender: emailAddressSender ?? [] @@ -472,6 +475,20 @@ class EmailView extends GetWidget { ); } + bool _validateDisplayEventActionBanner({ + required BuildContext context, + required CalendarEvent event, + required List emailAddressSender + }) { + final usernameEvent = event.getUserNameEventAction( + context: context, + imagePaths: controller.imagePaths, + listEmailAddressSender: emailAddressSender); + final titleEvent = event.getTitleEventAction(context, emailAddressSender); + + return usernameEvent.isNotEmpty && titleEvent.isNotEmpty; + } + void _handleMoreEmailAction({ required BuildContext context, required PresentationEmail presentationEmail, diff --git a/lib/features/email/presentation/extensions/calendar_event_extension.dart b/lib/features/email/presentation/extensions/calendar_event_extension.dart index aec40e3ca..26713e87f 100644 --- a/lib/features/email/presentation/extensions/calendar_event_extension.dart +++ b/lib/features/email/presentation/extensions/calendar_event_extension.dart @@ -110,7 +110,7 @@ extension CalendarEventExtension on CalendarEvent { case EventMethod.refresh: case EventMethod.cancel: case EventMethod.declineCounter: - return getOrganizerNameEvent(context); + return organizerName; case EventMethod.reply: case EventMethod.counter: return getAttendeeNameEvent(context, listEmailAddressSender); @@ -119,8 +119,6 @@ extension CalendarEventExtension on CalendarEvent { } } - String getOrganizerNameEvent(BuildContext context) => organizer?.name ?? AppLocalizations.of(context).you; - String get organizerName => organizer?.name ?? organizer?.mailto?.value ?? ''; String getAttendeeNameEvent(BuildContext context, List listEmailAddressSender) { diff --git a/lib/features/email/presentation/extensions/list_attendee_extension.dart b/lib/features/email/presentation/extensions/list_attendee_extension.dart index 248fd32b4..9b43ae722 100644 --- a/lib/features/email/presentation/extensions/list_attendee_extension.dart +++ b/lib/features/email/presentation/extensions/list_attendee_extension.dart @@ -11,9 +11,12 @@ extension ListAttendeeExtension on List { .join(', '); } - List withoutOrganizer(CalendarOrganizer organizer) { - return where((attendee) => attendee.mailto?.mailAddress != organizer.mailto) - .whereNotNull() - .toList(); + List withoutOrganizer(CalendarOrganizer? organizer) { + if (organizer == null) { + return this; + } + return where((attendee) => attendee.mailto?.mailAddress != organizer.mailto) + .whereNotNull() + .toList(); } } \ No newline at end of file diff --git a/lib/features/email/presentation/widgets/calendar_event/calendar_event_detail_widget.dart b/lib/features/email/presentation/widgets/calendar_event/calendar_event_detail_widget.dart index 4cebe466c..558a15980 100644 --- a/lib/features/email/presentation/widgets/calendar_event/calendar_event_detail_widget.dart +++ b/lib/features/email/presentation/widgets/calendar_event/calendar_event_detail_widget.dart @@ -72,12 +72,13 @@ class CalendarEventDetailWidget extends StatelessWidget { children: [ if (calendarEvent.title?.isNotEmpty == true) EventTitleWidget(title: calendarEvent.title!), - Padding( - padding: const EdgeInsets.only(top: CalendarEventDetailWidgetStyles.fieldTopPadding), - child: EventBodyContentWidget( - content: eventDesc, - isDraggableAppActive: isDraggableAppActive, - onMailtoDelegateAction: onMailtoDelegateAction)), + if (eventDesc.isNotEmpty) + Padding( + padding: const EdgeInsets.only(top: CalendarEventDetailWidgetStyles.fieldTopPadding), + child: EventBodyContentWidget( + content: eventDesc, + isDraggableAppActive: isDraggableAppActive, + onMailtoDelegateAction: onMailtoDelegateAction)), _buildEventTimeWidget(), if (calendarEvent.videoConferences.isNotEmpty) Padding( @@ -93,12 +94,12 @@ class CalendarEventDetailWidget extends StatelessWidget { onOpenNewTabAction: onOpenNewTabAction, ), ), - if (calendarEvent.participants?.isNotEmpty == true && calendarEvent.organizer != null) + if (calendarEvent.participants?.isNotEmpty == true || calendarEvent.organizer != null) Padding( padding: const EdgeInsets.only(top: CalendarEventDetailWidgetStyles.fieldTopPadding), child: EventAttendeeDetailWidget( - attendees: calendarEvent.participants!, - organizer: calendarEvent.organizer!, + attendees: calendarEvent.participants ?? [], + organizer: calendarEvent.organizer, ), ), if (calendarEvent.isDisplayedEventReplyAction) diff --git a/lib/features/email/presentation/widgets/calendar_event/calendar_event_information_widget.dart b/lib/features/email/presentation/widgets/calendar_event/calendar_event_information_widget.dart index f3f708b74..cb177398a 100644 --- a/lib/features/email/presentation/widgets/calendar_event/calendar_event_information_widget.dart +++ b/lib/features/email/presentation/widgets/calendar_event/calendar_event_information_widget.dart @@ -79,27 +79,30 @@ class CalendarEventInformationWidget extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text.rich( - TextSpan( - style: const TextStyle( - fontSize: CalendarEventInformationWidgetStyles.invitationMessageTextSize, - fontWeight: FontWeight.w500, - color: CalendarEventInformationWidgetStyles.invitationMessageColor - ), - children: [ + if (calendarEvent.organizerName.isNotEmpty) + Padding( + padding: const EdgeInsets.only(bottom: CalendarEventInformationWidgetStyles.space), + child: Text.rich( TextSpan( - text: calendarEvent.organizerName, style: const TextStyle( - color: CalendarEventInformationWidgetStyles.invitationMessageColor, fontSize: CalendarEventInformationWidgetStyles.invitationMessageTextSize, - fontWeight: FontWeight.w700 + fontWeight: FontWeight.w500, + color: CalendarEventInformationWidgetStyles.invitationMessageColor ), - ), - TextSpan(text: AppLocalizations.of(context).invitationMessageCalendarInformation) - ] - ) - ), - const SizedBox(height: CalendarEventInformationWidgetStyles.space), + children: [ + TextSpan( + text: calendarEvent.organizerName, + style: const TextStyle( + color: CalendarEventInformationWidgetStyles.invitationMessageColor, + fontSize: CalendarEventInformationWidgetStyles.invitationMessageTextSize, + fontWeight: FontWeight.w700 + ), + ), + TextSpan(text: AppLocalizations.of(context).invitationMessageCalendarInformation) + ] + ) + ), + ), if (calendarEvent.title?.isNotEmpty == true) EventTitleWidget(title: calendarEvent.title!), _buildEventTimeInformationWidget(), @@ -112,12 +115,12 @@ class CalendarEventInformationWidget extends StatelessWidget { onOpenNewTabAction: onOpenNewTabAction, ), ), - if (calendarEvent.participants?.isNotEmpty == true && calendarEvent.organizer != null) + if (calendarEvent.participants?.isNotEmpty == true || calendarEvent.organizer != null) Padding( padding: const EdgeInsets.only(top: CalendarEventInformationWidgetStyles.fieldTopPadding), child: EventAttendeeInformationWidget( - attendees: calendarEvent.participants!, - organizer: calendarEvent.organizer!, + attendees: calendarEvent.participants ?? [], + organizer: calendarEvent.organizer, ), ), if (calendarEvent.isDisplayedEventReplyAction) @@ -136,81 +139,82 @@ class CalendarEventInformationWidget extends StatelessWidget { ) ], ) - : Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CalendarDateIconWidget(calendarEvent: calendarEvent), - Expanded(child: Container( - clipBehavior: Clip.antiAlias, - decoration: const ShapeDecoration( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.only( - topRight: Radius.circular(CalendarEventInformationWidgetStyles.borderRadius), - bottomRight: Radius.circular(CalendarEventInformationWidgetStyles.borderRadius) - ) - ), - color: Colors.white - ), - padding: const EdgeInsets.all(CalendarEventInformationWidgetStyles.calendarInformationMargin), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text.rich( - TextSpan( - style: const TextStyle( - fontSize: CalendarEventInformationWidgetStyles.invitationMessageTextSize, - fontWeight: FontWeight.w500, - color: CalendarEventInformationWidgetStyles.invitationMessageColor - ), - children: [ - TextSpan( - text: calendarEvent.organizerName, - style: const TextStyle( - color: CalendarEventInformationWidgetStyles.invitationMessageColor, - fontSize: CalendarEventInformationWidgetStyles.invitationMessageTextSize, - fontWeight: FontWeight.w700 - ), - ), - TextSpan(text: AppLocalizations.of(context).invitationMessageCalendarInformation) - ] + : IntrinsicHeight( + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CalendarDateIconWidget(calendarEvent: calendarEvent), + Expanded(child: Container( + clipBehavior: Clip.antiAlias, + decoration: const ShapeDecoration( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.only( + topRight: Radius.circular(CalendarEventInformationWidgetStyles.borderRadius), + bottomRight: Radius.circular(CalendarEventInformationWidgetStyles.borderRadius) ) ), - const SizedBox(height: CalendarEventInformationWidgetStyles.space), - if (calendarEvent.title?.isNotEmpty == true) - EventTitleWidget(title: calendarEvent.title!), - _buildEventTimeInformationWidget(), - if (calendarEvent.location?.isNotEmpty == true) - Padding( - padding: const EdgeInsets.only(top: CalendarEventInformationWidgetStyles.fieldTopPadding), - child: EventLocationInformationWidget( - locationEvent: calendarEvent.location!, - onOpenComposerAction: onOpenComposerAction, - onOpenNewTabAction: onOpenNewTabAction, + color: Colors.white + ), + padding: const EdgeInsets.all(CalendarEventInformationWidgetStyles.calendarInformationMargin), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + if (calendarEvent.organizerName.isNotEmpty) + Padding( + padding: const EdgeInsets.only(bottom: CalendarEventInformationWidgetStyles.space), + child: Text.rich( + TextSpan( + style: const TextStyle( + fontSize: CalendarEventInformationWidgetStyles.invitationMessageTextSize, + fontWeight: FontWeight.w500, + color: CalendarEventInformationWidgetStyles.invitationMessageColor + ), + children: [ + TextSpan( + text: calendarEvent.organizerName, + style: const TextStyle( + color: CalendarEventInformationWidgetStyles.invitationMessageColor, + fontSize: CalendarEventInformationWidgetStyles.invitationMessageTextSize, + fontWeight: FontWeight.w700 + ), + ), + TextSpan(text: AppLocalizations.of(context).invitationMessageCalendarInformation) + ] + ) + ), ), - ), - if (calendarEvent.participants?.isNotEmpty == true && calendarEvent.organizer != null) - Padding( - padding: const EdgeInsets.only(top: CalendarEventInformationWidgetStyles.fieldTopPadding), - child: EventAttendeeInformationWidget( - attendees: calendarEvent.participants!, - organizer: calendarEvent.organizer!, + if (calendarEvent.title?.isNotEmpty == true) + EventTitleWidget(title: calendarEvent.title!), + _buildEventTimeInformationWidget(), + if (calendarEvent.location?.isNotEmpty == true) + Padding( + padding: const EdgeInsets.only(top: CalendarEventInformationWidgetStyles.fieldTopPadding), + child: EventLocationInformationWidget( + locationEvent: calendarEvent.location!, + onOpenComposerAction: onOpenComposerAction, + onOpenNewTabAction: onOpenNewTabAction, + ), ), - ), - if (calendarEvent.isDisplayedEventReplyAction) - CalendarEventActionButtonWidget( - margin: EdgeInsetsDirectional.zero, - onCalendarEventReplyActionClick: onCalendarEventReplyActionClick, - calendarEventReplying: calendarEventReplying, - presentationEmail: presentationEmail, - onMailToAttendeesAction: () => onMailtoAttendeesAction?.call( - calendarEvent.organizer, - calendarEvent.participants, + if (calendarEvent.participants?.isNotEmpty == true || calendarEvent.organizer != null) + Padding( + padding: const EdgeInsets.only(top: CalendarEventInformationWidgetStyles.fieldTopPadding), + child: EventAttendeeInformationWidget( + attendees: calendarEvent.participants ?? [], + organizer: calendarEvent.organizer, + ), ), - ), - ], - ), - )) - ], + if (calendarEvent.isDisplayedEventReplyAction) + CalendarEventActionButtonWidget( + margin: EdgeInsetsDirectional.zero, + onCalendarEventReplyActionClick: onCalendarEventReplyActionClick, + calendarEventReplying: calendarEventReplying, + presentationEmail: presentationEmail, + ), + ], + ), + )) + ], + ), ), ); } diff --git a/lib/features/email/presentation/widgets/calendar_event/event_attendee_detail_widget.dart b/lib/features/email/presentation/widgets/calendar_event/event_attendee_detail_widget.dart index 8a83c240f..a5afaef29 100644 --- a/lib/features/email/presentation/widgets/calendar_event/event_attendee_detail_widget.dart +++ b/lib/features/email/presentation/widgets/calendar_event/event_attendee_detail_widget.dart @@ -15,7 +15,7 @@ class EventAttendeeDetailWidget extends StatefulWidget { static const int maxAttendeeDisplayed = 6; final List attendees; - final CalendarOrganizer organizer; + final CalendarOrganizer? organizer; const EventAttendeeDetailWidget({ super.key, @@ -59,10 +59,12 @@ class _EventAttendeeDetailWidgetState extends State { Expanded(child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - OrganizerWidget(organizer: widget.organizer), - ..._attendeesDisplayed - .map((attendee) => AttendeeWidget(attendee: attendee, listAttendees: _attendeesDisplayed)) - .toList(), + if (widget.organizer != null) + OrganizerWidget(organizer: widget.organizer!), + if (_attendeesDisplayed.isNotEmpty) + ..._attendeesDisplayed + .map((attendee) => AttendeeWidget(attendee: attendee, listAttendees: _attendeesDisplayed)) + .toList(), if (!_isShowAllAttendee) Padding( padding: const EdgeInsets.only(top: EventAttendeeDetailWidgetStyles.fieldTopPadding), diff --git a/lib/features/email/presentation/widgets/calendar_event/event_attendee_information_widget.dart b/lib/features/email/presentation/widgets/calendar_event/event_attendee_information_widget.dart index 9ab413796..d27211a16 100644 --- a/lib/features/email/presentation/widgets/calendar_event/event_attendee_information_widget.dart +++ b/lib/features/email/presentation/widgets/calendar_event/event_attendee_information_widget.dart @@ -11,9 +11,11 @@ import 'package:tmail_ui_user/main/localizations/app_localizations.dart'; class EventAttendeeInformationWidget extends StatelessWidget { final List attendees; - final CalendarOrganizer organizer; + final CalendarOrganizer? organizer; - const EventAttendeeInformationWidget({ + final _responsiveUtils = Get.find(); + + EventAttendeeInformationWidget({ super.key, required this.attendees, required this.organizer @@ -21,7 +23,6 @@ class EventAttendeeInformationWidget extends StatelessWidget { @override Widget build(BuildContext context) { - final responsiveUtils = Get.find(); return Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -44,22 +45,26 @@ class EventAttendeeInformationWidget extends StatelessWidget { color: EventAttendeeInformationWidgetStyles.valueColor ), children: [ - TextSpan( - text: '${organizer.mailto?.value} (${AppLocalizations.of(context).organizer})', - style: const TextStyle( - color: EventAttendeeInformationWidgetStyles.valueOrganizerColor, - fontSize: EventAttendeeInformationWidgetStyles.textSize, - fontWeight: FontWeight.w500 - ), - ), - const TextSpan(text: ', '), - TextSpan(text: attendees.withoutOrganizer(organizer).mailtoAsString) + if (organizer != null) + ...[ + TextSpan( + text: '${organizer!.mailto?.value} (${AppLocalizations.of(context).organizer})', + style: const TextStyle( + color: EventAttendeeInformationWidgetStyles.valueOrganizerColor, + fontSize: EventAttendeeInformationWidgetStyles.textSize, + fontWeight: FontWeight.w500 + ), + ), + const TextSpan(text: ', '), + ], + if (attendees.isNotEmpty) + TextSpan(text: attendees.withoutOrganizer(organizer).mailtoAsString) ] ), - overflow: responsiveUtils.isPortraitMobile(context) + overflow: _responsiveUtils.isPortraitMobile(context) ? TextOverflow.clip : TextOverflow.ellipsis, - maxLines: responsiveUtils.isPortraitMobile(context) ? null : 2, + maxLines: _responsiveUtils.isPortraitMobile(context) ? null : 2, )) ], );