TF-2907 Hide widget when corresponding event attribute is null
This commit is contained in:
@@ -362,7 +362,10 @@ class EmailView extends GetWidget<SingleEmailController> {
|
|||||||
presentationEmail: controller.currentEmail,
|
presentationEmail: controller.currentEmail,
|
||||||
onMailtoAttendeesAction: controller.handleMailToAttendees,
|
onMailtoAttendeesAction: controller.handleMailToAttendees,
|
||||||
)),
|
)),
|
||||||
if (calendarEvent.getTitleEventAction(context, emailAddressSender ?? []).isNotEmpty)
|
if (_validateDisplayEventActionBanner(
|
||||||
|
context: context,
|
||||||
|
event: calendarEvent,
|
||||||
|
emailAddressSender: emailAddressSender ?? []))
|
||||||
CalendarEventActionBannerWidget(
|
CalendarEventActionBannerWidget(
|
||||||
calendarEvent: calendarEvent,
|
calendarEvent: calendarEvent,
|
||||||
listEmailAddressSender: emailAddressSender ?? []
|
listEmailAddressSender: emailAddressSender ?? []
|
||||||
@@ -472,6 +475,20 @@ class EmailView extends GetWidget<SingleEmailController> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool _validateDisplayEventActionBanner({
|
||||||
|
required BuildContext context,
|
||||||
|
required CalendarEvent event,
|
||||||
|
required List<String> 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({
|
void _handleMoreEmailAction({
|
||||||
required BuildContext context,
|
required BuildContext context,
|
||||||
required PresentationEmail presentationEmail,
|
required PresentationEmail presentationEmail,
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ extension CalendarEventExtension on CalendarEvent {
|
|||||||
case EventMethod.refresh:
|
case EventMethod.refresh:
|
||||||
case EventMethod.cancel:
|
case EventMethod.cancel:
|
||||||
case EventMethod.declineCounter:
|
case EventMethod.declineCounter:
|
||||||
return getOrganizerNameEvent(context);
|
return organizerName;
|
||||||
case EventMethod.reply:
|
case EventMethod.reply:
|
||||||
case EventMethod.counter:
|
case EventMethod.counter:
|
||||||
return getAttendeeNameEvent(context, listEmailAddressSender);
|
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 get organizerName => organizer?.name ?? organizer?.mailto?.value ?? '';
|
||||||
|
|
||||||
String getAttendeeNameEvent(BuildContext context, List<String> listEmailAddressSender) {
|
String getAttendeeNameEvent(BuildContext context, List<String> listEmailAddressSender) {
|
||||||
|
|||||||
@@ -11,7 +11,10 @@ extension ListAttendeeExtension on List<CalendarAttendee> {
|
|||||||
.join(', ');
|
.join(', ');
|
||||||
}
|
}
|
||||||
|
|
||||||
List<CalendarAttendee> withoutOrganizer(CalendarOrganizer organizer) {
|
List<CalendarAttendee> withoutOrganizer(CalendarOrganizer? organizer) {
|
||||||
|
if (organizer == null) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
return where((attendee) => attendee.mailto?.mailAddress != organizer.mailto)
|
return where((attendee) => attendee.mailto?.mailAddress != organizer.mailto)
|
||||||
.whereNotNull()
|
.whereNotNull()
|
||||||
.toList();
|
.toList();
|
||||||
|
|||||||
+4
-3
@@ -72,6 +72,7 @@ class CalendarEventDetailWidget extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
if (calendarEvent.title?.isNotEmpty == true)
|
if (calendarEvent.title?.isNotEmpty == true)
|
||||||
EventTitleWidget(title: calendarEvent.title!),
|
EventTitleWidget(title: calendarEvent.title!),
|
||||||
|
if (eventDesc.isNotEmpty)
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(top: CalendarEventDetailWidgetStyles.fieldTopPadding),
|
padding: const EdgeInsets.only(top: CalendarEventDetailWidgetStyles.fieldTopPadding),
|
||||||
child: EventBodyContentWidget(
|
child: EventBodyContentWidget(
|
||||||
@@ -93,12 +94,12 @@ class CalendarEventDetailWidget extends StatelessWidget {
|
|||||||
onOpenNewTabAction: onOpenNewTabAction,
|
onOpenNewTabAction: onOpenNewTabAction,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (calendarEvent.participants?.isNotEmpty == true && calendarEvent.organizer != null)
|
if (calendarEvent.participants?.isNotEmpty == true || calendarEvent.organizer != null)
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(top: CalendarEventDetailWidgetStyles.fieldTopPadding),
|
padding: const EdgeInsets.only(top: CalendarEventDetailWidgetStyles.fieldTopPadding),
|
||||||
child: EventAttendeeDetailWidget(
|
child: EventAttendeeDetailWidget(
|
||||||
attendees: calendarEvent.participants!,
|
attendees: calendarEvent.participants ?? [],
|
||||||
organizer: calendarEvent.organizer!,
|
organizer: calendarEvent.organizer,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (calendarEvent.isDisplayedEventReplyAction)
|
if (calendarEvent.isDisplayedEventReplyAction)
|
||||||
|
|||||||
+19
-15
@@ -79,7 +79,10 @@ class CalendarEventInformationWidget extends StatelessWidget {
|
|||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text.rich(
|
if (calendarEvent.organizerName.isNotEmpty)
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(bottom: CalendarEventInformationWidgetStyles.space),
|
||||||
|
child: Text.rich(
|
||||||
TextSpan(
|
TextSpan(
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: CalendarEventInformationWidgetStyles.invitationMessageTextSize,
|
fontSize: CalendarEventInformationWidgetStyles.invitationMessageTextSize,
|
||||||
@@ -99,7 +102,7 @@ class CalendarEventInformationWidget extends StatelessWidget {
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
const SizedBox(height: CalendarEventInformationWidgetStyles.space),
|
),
|
||||||
if (calendarEvent.title?.isNotEmpty == true)
|
if (calendarEvent.title?.isNotEmpty == true)
|
||||||
EventTitleWidget(title: calendarEvent.title!),
|
EventTitleWidget(title: calendarEvent.title!),
|
||||||
_buildEventTimeInformationWidget(),
|
_buildEventTimeInformationWidget(),
|
||||||
@@ -112,12 +115,12 @@ class CalendarEventInformationWidget extends StatelessWidget {
|
|||||||
onOpenNewTabAction: onOpenNewTabAction,
|
onOpenNewTabAction: onOpenNewTabAction,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (calendarEvent.participants?.isNotEmpty == true && calendarEvent.organizer != null)
|
if (calendarEvent.participants?.isNotEmpty == true || calendarEvent.organizer != null)
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(top: CalendarEventInformationWidgetStyles.fieldTopPadding),
|
padding: const EdgeInsets.only(top: CalendarEventInformationWidgetStyles.fieldTopPadding),
|
||||||
child: EventAttendeeInformationWidget(
|
child: EventAttendeeInformationWidget(
|
||||||
attendees: calendarEvent.participants!,
|
attendees: calendarEvent.participants ?? [],
|
||||||
organizer: calendarEvent.organizer!,
|
organizer: calendarEvent.organizer,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (calendarEvent.isDisplayedEventReplyAction)
|
if (calendarEvent.isDisplayedEventReplyAction)
|
||||||
@@ -136,7 +139,8 @@ class CalendarEventInformationWidget extends StatelessWidget {
|
|||||||
)
|
)
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
: Row(
|
: IntrinsicHeight(
|
||||||
|
child: Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
CalendarDateIconWidget(calendarEvent: calendarEvent),
|
CalendarDateIconWidget(calendarEvent: calendarEvent),
|
||||||
@@ -155,7 +159,10 @@ class CalendarEventInformationWidget extends StatelessWidget {
|
|||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text.rich(
|
if (calendarEvent.organizerName.isNotEmpty)
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(bottom: CalendarEventInformationWidgetStyles.space),
|
||||||
|
child: Text.rich(
|
||||||
TextSpan(
|
TextSpan(
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: CalendarEventInformationWidgetStyles.invitationMessageTextSize,
|
fontSize: CalendarEventInformationWidgetStyles.invitationMessageTextSize,
|
||||||
@@ -175,7 +182,7 @@ class CalendarEventInformationWidget extends StatelessWidget {
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
const SizedBox(height: CalendarEventInformationWidgetStyles.space),
|
),
|
||||||
if (calendarEvent.title?.isNotEmpty == true)
|
if (calendarEvent.title?.isNotEmpty == true)
|
||||||
EventTitleWidget(title: calendarEvent.title!),
|
EventTitleWidget(title: calendarEvent.title!),
|
||||||
_buildEventTimeInformationWidget(),
|
_buildEventTimeInformationWidget(),
|
||||||
@@ -188,12 +195,12 @@ class CalendarEventInformationWidget extends StatelessWidget {
|
|||||||
onOpenNewTabAction: onOpenNewTabAction,
|
onOpenNewTabAction: onOpenNewTabAction,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (calendarEvent.participants?.isNotEmpty == true && calendarEvent.organizer != null)
|
if (calendarEvent.participants?.isNotEmpty == true || calendarEvent.organizer != null)
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(top: CalendarEventInformationWidgetStyles.fieldTopPadding),
|
padding: const EdgeInsets.only(top: CalendarEventInformationWidgetStyles.fieldTopPadding),
|
||||||
child: EventAttendeeInformationWidget(
|
child: EventAttendeeInformationWidget(
|
||||||
attendees: calendarEvent.participants!,
|
attendees: calendarEvent.participants ?? [],
|
||||||
organizer: calendarEvent.organizer!,
|
organizer: calendarEvent.organizer,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (calendarEvent.isDisplayedEventReplyAction)
|
if (calendarEvent.isDisplayedEventReplyAction)
|
||||||
@@ -202,16 +209,13 @@ class CalendarEventInformationWidget extends StatelessWidget {
|
|||||||
onCalendarEventReplyActionClick: onCalendarEventReplyActionClick,
|
onCalendarEventReplyActionClick: onCalendarEventReplyActionClick,
|
||||||
calendarEventReplying: calendarEventReplying,
|
calendarEventReplying: calendarEventReplying,
|
||||||
presentationEmail: presentationEmail,
|
presentationEmail: presentationEmail,
|
||||||
onMailToAttendeesAction: () => onMailtoAttendeesAction?.call(
|
|
||||||
calendarEvent.organizer,
|
|
||||||
calendarEvent.participants,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
))
|
))
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-2
@@ -15,7 +15,7 @@ class EventAttendeeDetailWidget extends StatefulWidget {
|
|||||||
static const int maxAttendeeDisplayed = 6;
|
static const int maxAttendeeDisplayed = 6;
|
||||||
|
|
||||||
final List<CalendarAttendee> attendees;
|
final List<CalendarAttendee> attendees;
|
||||||
final CalendarOrganizer organizer;
|
final CalendarOrganizer? organizer;
|
||||||
|
|
||||||
const EventAttendeeDetailWidget({
|
const EventAttendeeDetailWidget({
|
||||||
super.key,
|
super.key,
|
||||||
@@ -59,7 +59,9 @@ class _EventAttendeeDetailWidgetState extends State<EventAttendeeDetailWidget> {
|
|||||||
Expanded(child: Column(
|
Expanded(child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
OrganizerWidget(organizer: widget.organizer),
|
if (widget.organizer != null)
|
||||||
|
OrganizerWidget(organizer: widget.organizer!),
|
||||||
|
if (_attendeesDisplayed.isNotEmpty)
|
||||||
..._attendeesDisplayed
|
..._attendeesDisplayed
|
||||||
.map((attendee) => AttendeeWidget(attendee: attendee, listAttendees: _attendeesDisplayed))
|
.map((attendee) => AttendeeWidget(attendee: attendee, listAttendees: _attendeesDisplayed))
|
||||||
.toList(),
|
.toList(),
|
||||||
|
|||||||
+11
-6
@@ -11,9 +11,11 @@ import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
|||||||
class EventAttendeeInformationWidget extends StatelessWidget {
|
class EventAttendeeInformationWidget extends StatelessWidget {
|
||||||
|
|
||||||
final List<CalendarAttendee> attendees;
|
final List<CalendarAttendee> attendees;
|
||||||
final CalendarOrganizer organizer;
|
final CalendarOrganizer? organizer;
|
||||||
|
|
||||||
const EventAttendeeInformationWidget({
|
final _responsiveUtils = Get.find<ResponsiveUtils>();
|
||||||
|
|
||||||
|
EventAttendeeInformationWidget({
|
||||||
super.key,
|
super.key,
|
||||||
required this.attendees,
|
required this.attendees,
|
||||||
required this.organizer
|
required this.organizer
|
||||||
@@ -21,7 +23,6 @@ class EventAttendeeInformationWidget extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final responsiveUtils = Get.find<ResponsiveUtils>();
|
|
||||||
return Row(
|
return Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
@@ -44,8 +45,10 @@ class EventAttendeeInformationWidget extends StatelessWidget {
|
|||||||
color: EventAttendeeInformationWidgetStyles.valueColor
|
color: EventAttendeeInformationWidgetStyles.valueColor
|
||||||
),
|
),
|
||||||
children: [
|
children: [
|
||||||
|
if (organizer != null)
|
||||||
|
...[
|
||||||
TextSpan(
|
TextSpan(
|
||||||
text: '${organizer.mailto?.value} (${AppLocalizations.of(context).organizer})',
|
text: '${organizer!.mailto?.value} (${AppLocalizations.of(context).organizer})',
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
color: EventAttendeeInformationWidgetStyles.valueOrganizerColor,
|
color: EventAttendeeInformationWidgetStyles.valueOrganizerColor,
|
||||||
fontSize: EventAttendeeInformationWidgetStyles.textSize,
|
fontSize: EventAttendeeInformationWidgetStyles.textSize,
|
||||||
@@ -53,13 +56,15 @@ class EventAttendeeInformationWidget extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
const TextSpan(text: ', '),
|
const TextSpan(text: ', '),
|
||||||
|
],
|
||||||
|
if (attendees.isNotEmpty)
|
||||||
TextSpan(text: attendees.withoutOrganizer(organizer).mailtoAsString)
|
TextSpan(text: attendees.withoutOrganizer(organizer).mailtoAsString)
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
overflow: responsiveUtils.isPortraitMobile(context)
|
overflow: _responsiveUtils.isPortraitMobile(context)
|
||||||
? TextOverflow.clip
|
? TextOverflow.clip
|
||||||
: TextOverflow.ellipsis,
|
: TextOverflow.ellipsis,
|
||||||
maxLines: responsiveUtils.isPortraitMobile(context) ? null : 2,
|
maxLines: _responsiveUtils.isPortraitMobile(context) ? null : 2,
|
||||||
))
|
))
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user