diff --git a/lib/features/email/presentation/controller/single_email_controller.dart b/lib/features/email/presentation/controller/single_email_controller.dart index 23c7c541c..a2aa77aff 100644 --- a/lib/features/email/presentation/controller/single_email_controller.dart +++ b/lib/features/email/presentation/controller/single_email_controller.dart @@ -145,7 +145,9 @@ class SingleEmailController extends BaseController with AppLoaderMixin { EmailLoaded? get currentEmailLoaded => _currentEmailLoaded; - bool get calendarEventProcessing => viewState.value is CalendarEventReplying; + bool get calendarEventProcessing => viewState.value.fold( + (failure) => false, + (success) => success is CalendarEventReplying); CalendarEvent? get calendarEvent => blobCalendarEvent.value?.calendarEventList.firstOrNull; Id? get _displayingEventBlobId => blobCalendarEvent.value?.blobId; @@ -1684,8 +1686,8 @@ class SingleEmailController extends BaseController with AppLoaderMixin { ); } - void onCalendarEventReplyAction(EventAction eventAction) { - switch (eventAction.actionType) { + void onCalendarEventReplyAction(EventActionType eventActionType) { + switch (eventActionType) { case EventActionType.yes: _acceptCalendarEventAction(); break; diff --git a/lib/features/email/presentation/email_view.dart b/lib/features/email/presentation/email_view.dart index 57f2ed36a..990fd895a 100644 --- a/lib/features/email/presentation/email_view.dart +++ b/lib/features/email/presentation/email_view.dart @@ -375,6 +375,8 @@ class EmailView extends GetWidget { calendarEvent: calendarEvent, onOpenComposerAction: controller.openNewComposerAction, onOpenNewTabAction: controller.openNewTabAction, + onCalendarEventReplyActionClick: controller.onCalendarEventReplyAction, + calendarEventReplying: controller.calendarEventProcessing, ), if (calendarEvent.getTitleEventAction(context, emailAddressSender ?? []).isNotEmpty) CalendarEventActionBannerWidget( @@ -388,6 +390,8 @@ class EmailView extends GetWidget { onOpenComposerAction: controller.openNewComposerAction, onOpenNewTabAction: controller.openNewTabAction, onMailtoDelegateAction: controller.openMailToLink, + onCalendarEventReplyActionClick: controller.onCalendarEventReplyAction, + calendarEventReplying: controller.calendarEventProcessing, ), ], ) diff --git a/lib/features/email/presentation/styles/calendar_event_action_button_widget_styles.dart b/lib/features/email/presentation/styles/calendar_event_action_button_widget_styles.dart index 9a88292ba..8c98ed4da 100644 --- a/lib/features/email/presentation/styles/calendar_event_action_button_widget_styles.dart +++ b/lib/features/email/presentation/styles/calendar_event_action_button_widget_styles.dart @@ -10,6 +10,7 @@ class CalendarEventActionButtonWidgetStyles { static const double minWidth = 80; static const Color backgroundColor = Colors.transparent; + static Color loadingBackgroundColor = Colors.grey.shade300; static const Color textColor = AppColor.primaryColor; static const FontWeight fontWeight = FontWeight.w500; diff --git a/lib/features/email/presentation/widgets/calendar_event/calendar_event_action_button_widget.dart b/lib/features/email/presentation/widgets/calendar_event/calendar_event_action_button_widget.dart index 609764bd6..c75664e59 100644 --- a/lib/features/email/presentation/widgets/calendar_event/calendar_event_action_button_widget.dart +++ b/lib/features/email/presentation/widgets/calendar_event/calendar_event_action_button_widget.dart @@ -4,14 +4,19 @@ import 'package:flutter/material.dart'; import 'package:get/get.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'; -import 'package:tmail_ui_user/main/utils/app_utils.dart'; + +typedef OnCalendarEventReplyActionClick = void Function(EventActionType eventActionType); class CalendarEventActionButtonWidget extends StatelessWidget { final EdgeInsetsGeometry? margin; + final OnCalendarEventReplyActionClick onCalendarEventReplyActionClick; + final bool calendarEventReplying; const CalendarEventActionButtonWidget({ super.key, + required this.onCalendarEventReplyActionClick, + required this.calendarEventReplying, this.margin, }); @@ -30,7 +35,9 @@ class CalendarEventActionButtonWidget extends StatelessWidget { children: EventActionType.values .map((action) => TMailButtonWidget( text: action.getLabelButton(context), - backgroundColor: CalendarEventActionButtonWidgetStyles.backgroundColor, + backgroundColor: calendarEventReplying + ? CalendarEventActionButtonWidgetStyles.loadingBackgroundColor + : CalendarEventActionButtonWidgetStyles.backgroundColor, borderRadius: CalendarEventActionButtonWidgetStyles.borderRadius, padding: CalendarEventActionButtonWidgetStyles.buttonPadding, textStyle: const TextStyle( @@ -45,8 +52,9 @@ class CalendarEventActionButtonWidget extends StatelessWidget { width: CalendarEventActionButtonWidgetStyles.borderWidth, color: CalendarEventActionButtonWidgetStyles.textColor ), - // TODO: Handle in part 4 - onTapActionCallback: () => AppUtils.launchLink(''), + onTapActionCallback: calendarEventReplying + ? null + : () => onCalendarEventReplyActionClick(action), )) .toList(), ), 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 4908b3ac6..0b6abd201 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 @@ -21,11 +21,15 @@ class CalendarEventDetailWidget extends StatelessWidget { final OnOpenComposerAction? onOpenComposerAction; final bool? isDraggableAppActive; final OnMailtoDelegateAction? onMailtoDelegateAction; + final OnCalendarEventReplyActionClick onCalendarEventReplyActionClick; + final bool calendarEventReplying; const CalendarEventDetailWidget({ super.key, required this.calendarEvent, required this.emailContent, + required this.onCalendarEventReplyActionClick, + required this.calendarEventReplying, this.isDraggableAppActive, this.onOpenNewTabAction, this.onOpenComposerAction, @@ -89,7 +93,9 @@ class CalendarEventDetailWidget extends StatelessWidget { organizer: calendarEvent.organizer!, ), ), - const CalendarEventActionButtonWidget(), + CalendarEventActionButtonWidget( + onCalendarEventReplyActionClick: onCalendarEventReplyActionClick, + calendarEventReplying: calendarEventReplying), ], ), ); 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 e47949cb8..95edf1e32 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 @@ -21,10 +21,14 @@ class CalendarEventInformationWidget extends StatelessWidget { final CalendarEvent calendarEvent; final OnOpenNewTabAction? onOpenNewTabAction; final OnOpenComposerAction? onOpenComposerAction; + final OnCalendarEventReplyActionClick onCalendarEventReplyActionClick; + final bool calendarEventReplying; const CalendarEventInformationWidget({ super.key, required this.calendarEvent, + required this.onCalendarEventReplyActionClick, + required this.calendarEventReplying, this.onOpenNewTabAction, this.onOpenComposerAction, }); @@ -110,8 +114,10 @@ class CalendarEventInformationWidget extends StatelessWidget { organizer: calendarEvent.organizer!, ), ), - const CalendarEventActionButtonWidget( + CalendarEventActionButtonWidget( margin: EdgeInsetsDirectional.zero, + onCalendarEventReplyActionClick: onCalendarEventReplyActionClick, + calendarEventReplying: calendarEventReplying, ), ], ), @@ -178,8 +184,10 @@ class CalendarEventInformationWidget extends StatelessWidget { organizer: calendarEvent.organizer!, ), ), - const CalendarEventActionButtonWidget( + CalendarEventActionButtonWidget( margin: EdgeInsetsDirectional.zero, + onCalendarEventReplyActionClick: onCalendarEventReplyActionClick, + calendarEventReplying: calendarEventReplying, ), ], ), diff --git a/test/features/email/presentation/controller/single_email_controller_test.dart b/test/features/email/presentation/controller/single_email_controller_test.dart index ecbca6555..62c12ea9b 100644 --- a/test/features/email/presentation/controller/single_email_controller_test.dart +++ b/test/features/email/presentation/controller/single_email_controller_test.dart @@ -286,8 +286,7 @@ void main() { calendarEventList: [calendarEvent])])); // act - singleEmailController.onCalendarEventReplyAction( - EventAction(EventActionType.yes, '')); + singleEmailController.onCalendarEventReplyAction(EventActionType.yes); await untilCalled(acceptCalendarEventInteractor.execute(any, any)); // assert