TF-2858 Implement store event attendance status on presentation layer
This commit is contained in:
+130
-26
@@ -1,7 +1,8 @@
|
||||
|
||||
import 'package:core/core.dart';
|
||||
import 'package:core/presentation/utils/responsive_utils.dart';
|
||||
import 'package:core/presentation/views/button/tmail_button_widget.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:model/email/presentation_email.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/model/event_action.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/styles/calendar_event_action_button_widget_styles.dart';
|
||||
|
||||
@@ -12,52 +13,155 @@ class CalendarEventActionButtonWidget extends StatelessWidget {
|
||||
final EdgeInsetsGeometry? margin;
|
||||
final OnCalendarEventReplyActionClick onCalendarEventReplyActionClick;
|
||||
final bool calendarEventReplying;
|
||||
final PresentationEmail? presentationEmail;
|
||||
|
||||
const CalendarEventActionButtonWidget({
|
||||
final _responsiveUtils = Get.find<ResponsiveUtils>();
|
||||
|
||||
CalendarEventActionButtonWidget({
|
||||
super.key,
|
||||
required this.onCalendarEventReplyActionClick,
|
||||
required this.calendarEventReplying,
|
||||
this.margin,
|
||||
this.presentationEmail,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final responsiveUtils = Get.find<ResponsiveUtils>();
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
margin: margin ?? CalendarEventActionButtonWidgetStyles.margin,
|
||||
padding: responsiveUtils.isPortraitMobile(context)
|
||||
padding: _responsiveUtils.isPortraitMobile(context)
|
||||
? CalendarEventActionButtonWidgetStyles.paddingMobile
|
||||
: CalendarEventActionButtonWidgetStyles.paddingWeb,
|
||||
child: Wrap(
|
||||
spacing: CalendarEventActionButtonWidgetStyles.space,
|
||||
runSpacing: CalendarEventActionButtonWidgetStyles.space,
|
||||
children: EventActionType.values
|
||||
.map((action) => TMailButtonWidget(
|
||||
text: action.getLabelButton(context),
|
||||
backgroundColor: calendarEventReplying
|
||||
? CalendarEventActionButtonWidgetStyles.loadingBackgroundColor
|
||||
: CalendarEventActionButtonWidgetStyles.backgroundColor,
|
||||
borderRadius: CalendarEventActionButtonWidgetStyles.borderRadius,
|
||||
padding: CalendarEventActionButtonWidgetStyles.buttonPadding,
|
||||
textStyle: const TextStyle(
|
||||
fontWeight: CalendarEventActionButtonWidgetStyles.fontWeight,
|
||||
fontSize: CalendarEventActionButtonWidgetStyles.textSize,
|
||||
color: CalendarEventActionButtonWidgetStyles.textColor,
|
||||
.map((action) => AbsorbPointer(
|
||||
absorbing: _getCallbackFunction(action) == null,
|
||||
child: TMailButtonWidget(
|
||||
text: action.getLabelButton(context),
|
||||
backgroundColor: _getButtonBackgroundColor(action),
|
||||
borderRadius: CalendarEventActionButtonWidgetStyles.borderRadius,
|
||||
padding: CalendarEventActionButtonWidgetStyles.buttonPadding,
|
||||
textStyle: TextStyle(
|
||||
fontWeight: CalendarEventActionButtonWidgetStyles.fontWeight,
|
||||
fontSize: CalendarEventActionButtonWidgetStyles.textSize,
|
||||
color: _getButtonTextColor(action),
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
minWidth: CalendarEventActionButtonWidgetStyles.minWidth,
|
||||
width: _responsiveUtils.isPortraitMobile(context) ? double.infinity : null,
|
||||
border: Border.all(
|
||||
width: CalendarEventActionButtonWidgetStyles.borderWidth,
|
||||
color: _getButtonBorderColor(action)
|
||||
),
|
||||
onTapActionCallback: _getCallbackFunction(action),
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
minWidth: CalendarEventActionButtonWidgetStyles.minWidth,
|
||||
width: responsiveUtils.isPortraitMobile(context) ? double.infinity : null,
|
||||
border: Border.all(
|
||||
width: CalendarEventActionButtonWidgetStyles.borderWidth,
|
||||
color: CalendarEventActionButtonWidgetStyles.textColor
|
||||
),
|
||||
onTapActionCallback: calendarEventReplying
|
||||
? null
|
||||
: () => onCalendarEventReplyActionClick(action),
|
||||
))
|
||||
.toList(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Color _getButtonBackgroundColor(EventActionType eventActionType) {
|
||||
switch (eventActionType) {
|
||||
case EventActionType.yes:
|
||||
if (presentationEmail?.isAcceptedEventAttendance == true) {
|
||||
return CalendarEventActionButtonWidgetStyles.selectedBackgroundColor;
|
||||
}
|
||||
|
||||
if (calendarEventReplying) {
|
||||
return CalendarEventActionButtonWidgetStyles.loadingBackgroundColor;
|
||||
}
|
||||
|
||||
return CalendarEventActionButtonWidgetStyles.backgroundColor;
|
||||
case EventActionType.maybe:
|
||||
if (presentationEmail!.isTentativelyAcceptedEventAttendance == true) {
|
||||
return CalendarEventActionButtonWidgetStyles.selectedBackgroundColor;
|
||||
}
|
||||
|
||||
if (calendarEventReplying) {
|
||||
return CalendarEventActionButtonWidgetStyles.loadingBackgroundColor;
|
||||
}
|
||||
|
||||
return CalendarEventActionButtonWidgetStyles.backgroundColor;
|
||||
case EventActionType.no:
|
||||
if (presentationEmail?.isRejectedEventAttendance == true) {
|
||||
return CalendarEventActionButtonWidgetStyles.selectedBackgroundColor;
|
||||
}
|
||||
|
||||
if (calendarEventReplying) {
|
||||
return CalendarEventActionButtonWidgetStyles.loadingBackgroundColor;
|
||||
}
|
||||
|
||||
return CalendarEventActionButtonWidgetStyles.backgroundColor;
|
||||
}
|
||||
}
|
||||
|
||||
Color _getButtonTextColor(EventActionType eventActionType) {
|
||||
switch (eventActionType) {
|
||||
case EventActionType.yes:
|
||||
if (presentationEmail?.isAcceptedEventAttendance == true) {
|
||||
return CalendarEventActionButtonWidgetStyles.selectedTextColor;
|
||||
}
|
||||
|
||||
return CalendarEventActionButtonWidgetStyles.textColor;
|
||||
case EventActionType.maybe:
|
||||
if (presentationEmail?.isTentativelyAcceptedEventAttendance == true) {
|
||||
return CalendarEventActionButtonWidgetStyles.selectedTextColor;
|
||||
}
|
||||
|
||||
return CalendarEventActionButtonWidgetStyles.textColor;
|
||||
case EventActionType.no:
|
||||
if (presentationEmail?.isRejectedEventAttendance == true) {
|
||||
return CalendarEventActionButtonWidgetStyles.selectedTextColor;
|
||||
}
|
||||
|
||||
return CalendarEventActionButtonWidgetStyles.textColor;
|
||||
}
|
||||
}
|
||||
|
||||
Color _getButtonBorderColor(EventActionType eventActionType) {
|
||||
switch (eventActionType) {
|
||||
case EventActionType.yes:
|
||||
if (presentationEmail?.isAcceptedEventAttendance == true) {
|
||||
return CalendarEventActionButtonWidgetStyles.selectedBackgroundColor;
|
||||
}
|
||||
|
||||
return CalendarEventActionButtonWidgetStyles.textColor;
|
||||
case EventActionType.maybe:
|
||||
if (presentationEmail?.isTentativelyAcceptedEventAttendance == true) {
|
||||
return CalendarEventActionButtonWidgetStyles.selectedBackgroundColor;
|
||||
}
|
||||
|
||||
return CalendarEventActionButtonWidgetStyles.textColor;
|
||||
case EventActionType.no:
|
||||
if (presentationEmail?.isRejectedEventAttendance == true) {
|
||||
return CalendarEventActionButtonWidgetStyles.selectedBackgroundColor;
|
||||
}
|
||||
|
||||
return CalendarEventActionButtonWidgetStyles.textColor;
|
||||
}
|
||||
}
|
||||
|
||||
Function()? _getCallbackFunction(EventActionType eventActionType) {
|
||||
switch (eventActionType) {
|
||||
case EventActionType.yes:
|
||||
if (presentationEmail?.isAcceptedEventAttendance == true || calendarEventReplying) {
|
||||
return null;
|
||||
}
|
||||
return () => onCalendarEventReplyActionClick(eventActionType);
|
||||
case EventActionType.maybe:
|
||||
if (presentationEmail?.isTentativelyAcceptedEventAttendance == true || calendarEventReplying) {
|
||||
return null;
|
||||
}
|
||||
return () => onCalendarEventReplyActionClick(eventActionType);
|
||||
case EventActionType.no:
|
||||
if (presentationEmail?.isRejectedEventAttendance == true || calendarEventReplying) {
|
||||
return null;
|
||||
}
|
||||
return () => onCalendarEventReplyActionClick(eventActionType);
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
-3
@@ -1,7 +1,7 @@
|
||||
|
||||
import 'package:core/core.dart';
|
||||
import 'package:core/presentation/views/html_viewer/html_content_viewer_widget.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/calendar/calendar_event.dart';
|
||||
import 'package:model/email/presentation_email.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_detail_widget_styles.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/widgets/calendar_event/calendar_event_action_button_widget.dart';
|
||||
@@ -23,6 +23,7 @@ class CalendarEventDetailWidget extends StatelessWidget {
|
||||
final OnMailtoDelegateAction? onMailtoDelegateAction;
|
||||
final OnCalendarEventReplyActionClick onCalendarEventReplyActionClick;
|
||||
final bool calendarEventReplying;
|
||||
final PresentationEmail? presentationEmail;
|
||||
|
||||
const CalendarEventDetailWidget({
|
||||
super.key,
|
||||
@@ -34,6 +35,7 @@ class CalendarEventDetailWidget extends StatelessWidget {
|
||||
this.onOpenNewTabAction,
|
||||
this.onOpenComposerAction,
|
||||
this.onMailtoDelegateAction,
|
||||
this.presentationEmail,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -95,7 +97,9 @@ class CalendarEventDetailWidget extends StatelessWidget {
|
||||
),
|
||||
CalendarEventActionButtonWidget(
|
||||
onCalendarEventReplyActionClick: onCalendarEventReplyActionClick,
|
||||
calendarEventReplying: calendarEventReplying),
|
||||
calendarEventReplying: calendarEventReplying,
|
||||
presentationEmail: presentationEmail,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
+9
-4
@@ -1,9 +1,9 @@
|
||||
|
||||
import 'package:core/presentation/extensions/color_extension.dart';
|
||||
import 'package:core/presentation/utils/responsive_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/calendar/calendar_event.dart';
|
||||
import 'package:model/email/presentation_email.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_information_widget_styles.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/widgets/calendar_event/calendar_date_icon_widget.dart';
|
||||
@@ -23,19 +23,22 @@ class CalendarEventInformationWidget extends StatelessWidget {
|
||||
final OnOpenComposerAction? onOpenComposerAction;
|
||||
final OnCalendarEventReplyActionClick onCalendarEventReplyActionClick;
|
||||
final bool calendarEventReplying;
|
||||
final PresentationEmail? presentationEmail;
|
||||
|
||||
const CalendarEventInformationWidget({
|
||||
final _responsiveUtils = Get.find<ResponsiveUtils>();
|
||||
|
||||
CalendarEventInformationWidget({
|
||||
super.key,
|
||||
required this.calendarEvent,
|
||||
required this.onCalendarEventReplyActionClick,
|
||||
required this.calendarEventReplying,
|
||||
this.onOpenNewTabAction,
|
||||
this.onOpenComposerAction,
|
||||
this.presentationEmail,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final responsiveUtils = Get.find<ResponsiveUtils>();
|
||||
return Container(
|
||||
clipBehavior: Clip.antiAlias,
|
||||
decoration: const ShapeDecoration(
|
||||
@@ -51,7 +54,7 @@ class CalendarEventInformationWidget extends StatelessWidget {
|
||||
margin: const EdgeInsetsDirectional.symmetric(
|
||||
vertical: CalendarEventInformationWidgetStyles.verticalMargin,
|
||||
horizontal: CalendarEventInformationWidgetStyles.horizontalMargin),
|
||||
child: responsiveUtils.isPortraitMobile(context)
|
||||
child: _responsiveUtils.isPortraitMobile(context)
|
||||
? Column(
|
||||
children: [
|
||||
CalendarDateIconWidget(
|
||||
@@ -118,6 +121,7 @@ class CalendarEventInformationWidget extends StatelessWidget {
|
||||
margin: EdgeInsetsDirectional.zero,
|
||||
onCalendarEventReplyActionClick: onCalendarEventReplyActionClick,
|
||||
calendarEventReplying: calendarEventReplying,
|
||||
presentationEmail: presentationEmail,
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -188,6 +192,7 @@ class CalendarEventInformationWidget extends StatelessWidget {
|
||||
margin: EdgeInsetsDirectional.zero,
|
||||
onCalendarEventReplyActionClick: onCalendarEventReplyActionClick,
|
||||
calendarEventReplying: calendarEventReplying,
|
||||
presentationEmail: presentationEmail,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user