TF-2078 Display calendar event action
(cherry picked from commit 9949b4decc0628487e96f1e9a3c19f3ca94e4c50)
This commit is contained in:
@@ -32,6 +32,7 @@ class TMailButtonWidget extends StatelessWidget {
|
||||
final List<BoxShadow>? boxShadow;
|
||||
final TextAlign? textAlign;
|
||||
final bool flexibleText;
|
||||
final BoxBorder? border;
|
||||
|
||||
const TMailButtonWidget({
|
||||
super.key,
|
||||
@@ -59,6 +60,7 @@ class TMailButtonWidget extends StatelessWidget {
|
||||
this.margin,
|
||||
this.textAlign,
|
||||
this.flexibleText = false,
|
||||
this.border,
|
||||
});
|
||||
|
||||
factory TMailButtonWidget.fromIcon({
|
||||
@@ -125,6 +127,8 @@ class TMailButtonWidget extends StatelessWidget {
|
||||
List<BoxShadow>? boxShadow,
|
||||
EdgeInsetsGeometry? margin,
|
||||
TextAlign? textAlign,
|
||||
bool flexibleText = false,
|
||||
BoxBorder? border,
|
||||
}) {
|
||||
return TMailButtonWidget(
|
||||
key: key,
|
||||
@@ -143,6 +147,8 @@ class TMailButtonWidget extends StatelessWidget {
|
||||
boxShadow: boxShadow,
|
||||
margin: margin,
|
||||
textAlign: textAlign,
|
||||
flexibleText: flexibleText,
|
||||
border: border,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -261,6 +267,7 @@ class TMailButtonWidget extends StatelessWidget {
|
||||
padding: padding,
|
||||
margin: margin,
|
||||
boxShadow: boxShadow,
|
||||
border: border,
|
||||
child: childWidget,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ class TMailContainerWidget extends StatelessWidget {
|
||||
final EdgeInsetsGeometry? padding;
|
||||
final EdgeInsetsGeometry? margin;
|
||||
final List<BoxShadow>? boxShadow;
|
||||
final BoxBorder? border;
|
||||
|
||||
const TMailContainerWidget({
|
||||
super.key,
|
||||
@@ -35,6 +36,7 @@ class TMailContainerWidget extends StatelessWidget {
|
||||
this.padding,
|
||||
this.boxShadow,
|
||||
this.margin,
|
||||
this.border,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -64,6 +66,7 @@ class TMailContainerWidget extends StatelessWidget {
|
||||
decoration: BoxDecoration(
|
||||
color: backgroundColor ?? AppColor.colorButtonHeaderThread,
|
||||
borderRadius: BorderRadius.all(Radius.circular(borderRadius)),
|
||||
border: border,
|
||||
boxShadow: boxShadow
|
||||
),
|
||||
width: width,
|
||||
@@ -80,6 +83,7 @@ class TMailContainerWidget extends StatelessWidget {
|
||||
decoration: BoxDecoration(
|
||||
color: backgroundColor ?? AppColor.colorButtonHeaderThread,
|
||||
borderRadius: BorderRadius.all(Radius.circular(borderRadius)),
|
||||
border: border,
|
||||
boxShadow: boxShadow
|
||||
),
|
||||
width: width,
|
||||
|
||||
@@ -29,6 +29,7 @@ import 'package:tmail_ui_user/features/composer/presentation/extensions/email_ac
|
||||
import 'package:tmail_ui_user/features/destination_picker/presentation/model/destination_picker_arguments.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/extensions/list_attachments_extension.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/model/detailed_email.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/model/event_action.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/state/parse_calendar_event_state.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/usecases/parse_calendar_event_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/usecases/store_opened_email_interactor.dart';
|
||||
@@ -112,6 +113,7 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
|
||||
final emailContents = RxnString();
|
||||
final attachments = <Attachment>[].obs;
|
||||
final calendarEvent = Rxn<CalendarEvent>();
|
||||
final eventActions = <EventAction>[].obs;
|
||||
|
||||
EmailId? _currentEmailId;
|
||||
Identity? _identitySelected;
|
||||
@@ -394,7 +396,10 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
|
||||
initialEmailContents = success.emailContent;
|
||||
attachments.value = success.attachments;
|
||||
|
||||
_loadCalendarEventAction(success.attachments.calendarEventBlobIds);
|
||||
_loadCalendarEventAction(
|
||||
blobIds: success.attachments.calendarEventBlobIds,
|
||||
emailContents: success.emailContent
|
||||
);
|
||||
|
||||
final isShowMessageReadReceipt = success.emailCurrent?.hasReadReceipt(mailboxDashBoardController.mapMailboxById) == true;
|
||||
if (isShowMessageReadReceipt) {
|
||||
@@ -421,7 +426,10 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
|
||||
initialEmailContents = success.emailContent;
|
||||
attachments.value = success.attachments;
|
||||
|
||||
_loadCalendarEventAction(success.attachments.calendarEventBlobIds);
|
||||
_loadCalendarEventAction(
|
||||
blobIds: success.attachments.calendarEventBlobIds,
|
||||
emailContents: success.emailContent
|
||||
);
|
||||
|
||||
if (PlatformInfo.isMobile) {
|
||||
final detailedEmail = DetailedEmail(
|
||||
@@ -469,6 +477,7 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
|
||||
initialEmailContents = null;
|
||||
attachments.clear();
|
||||
calendarEvent.value = null;
|
||||
eventActions.clear();
|
||||
}
|
||||
|
||||
PresentationMailbox? getMailboxContain(PresentationEmail email) {
|
||||
@@ -1238,19 +1247,21 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
|
||||
}
|
||||
}
|
||||
|
||||
void _loadCalendarEventAction(Set<Id> blobIds) {
|
||||
void _loadCalendarEventAction({
|
||||
required Set<Id> blobIds,
|
||||
required String emailContents
|
||||
}) {
|
||||
log('SingleEmailController::_loadCalendarEventAction:blobIds: $blobIds');
|
||||
if (_isCalendarEventSupported) {
|
||||
if (currentEmail?.hasCalendarEvent == true &&
|
||||
blobIds.isNotEmpty &&
|
||||
mailboxDashBoardController.accountId.value != null) {
|
||||
_parseCalendarEventAction(
|
||||
mailboxDashBoardController.accountId.value!,
|
||||
blobIds
|
||||
);
|
||||
} else {
|
||||
logError('SingleEmailController::_loadCalendarEventAction: not found calendar event header');
|
||||
}
|
||||
if (_isCalendarEventSupported &&
|
||||
currentEmail?.hasCalendarEvent == true &&
|
||||
blobIds.isNotEmpty &&
|
||||
mailboxDashBoardController.accountId.value != null
|
||||
) {
|
||||
_parseCalendarEventAction(
|
||||
accountId: mailboxDashBoardController.accountId.value!,
|
||||
blobIds: blobIds,
|
||||
emailContents: emailContents
|
||||
);
|
||||
} else {
|
||||
logError('SingleEmailController::_loadCalendarEventAction: calendar event not supported');
|
||||
}
|
||||
@@ -1264,21 +1275,24 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
|
||||
CapabilityIdentifier.jamesCalendarEvent.isSupported(session, accountId);
|
||||
}
|
||||
|
||||
void _parseCalendarEventAction(AccountId accountId, Set<Id> blobIds) {
|
||||
void _parseCalendarEventAction({
|
||||
required AccountId accountId,
|
||||
required Set<Id> blobIds,
|
||||
required String emailContents
|
||||
}) {
|
||||
log("SingleEmailController::_parseCalendarEventAction:blobIds: $blobIds");
|
||||
if (_parseCalendarEventInteractor != null) {
|
||||
consumeState(_parseCalendarEventInteractor!.execute(accountId, blobIds));
|
||||
consumeState(_parseCalendarEventInteractor!.execute(accountId, blobIds, emailContents));
|
||||
} else {
|
||||
logError("SingleEmailController::_parseCalendarEventAction: _parseCalendarEventInteractor is NULL");
|
||||
}
|
||||
}
|
||||
|
||||
void _handleParseCalendarEventSuccess(ParseCalendarEventSuccess success) {
|
||||
if (success.calendarEventList.isNotEmpty) {
|
||||
calendarEvent.value = success.calendarEventList.first;
|
||||
if (PlatformInfo.isMobile) {
|
||||
_enableScrollPageView();
|
||||
}
|
||||
calendarEvent.value = success.calendarEventList.first;
|
||||
eventActions.value = success.eventActionList;
|
||||
if (PlatformInfo.isMobile) {
|
||||
_enableScrollPageView();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -308,6 +308,7 @@ class EmailView extends GetWidget<SingleEmailController> with AppLoaderMixin {
|
||||
),
|
||||
CalendarEventDetailWidget(
|
||||
calendarEvent: calendarEvent,
|
||||
eventActions: controller.eventActions,
|
||||
onOpenComposerAction: controller.openNewComposerAction,
|
||||
onOpenNewTabAction: controller.openNewTabAction,
|
||||
),
|
||||
|
||||
+6
@@ -1,8 +1,10 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/calendar/calendar_event.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/model/event_action.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';
|
||||
import 'package:tmail_ui_user/features/email/presentation/widgets/calendar_event/event_attendee_detail_widget.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/widgets/calendar_event/event_description_detail_widget.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/widgets/calendar_event/event_link_detail_widget.dart';
|
||||
@@ -13,12 +15,14 @@ import 'package:tmail_ui_user/features/email/presentation/widgets/calendar_event
|
||||
class CalendarEventDetailWidget extends StatelessWidget {
|
||||
|
||||
final CalendarEvent calendarEvent;
|
||||
final List<EventAction> eventActions;
|
||||
final OnOpenNewTabAction? onOpenNewTabAction;
|
||||
final OnOpenComposerAction? onOpenComposerAction;
|
||||
|
||||
const CalendarEventDetailWidget({
|
||||
super.key,
|
||||
required this.calendarEvent,
|
||||
required this.eventActions,
|
||||
this.onOpenNewTabAction,
|
||||
this.onOpenComposerAction,
|
||||
});
|
||||
@@ -79,6 +83,8 @@ class CalendarEventDetailWidget extends StatelessWidget {
|
||||
organizer: calendarEvent.organizer!,
|
||||
),
|
||||
),
|
||||
if (eventActions.isNotEmpty)
|
||||
CalendarEventActionButtonWidget(eventActions: eventActions),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user