TF-4075 Jump to attachments list position on mobile
(cherry picked from commit cd2ca1ec3c5b5160820823905d9f0183536b07e3)
This commit is contained in:
@@ -25,4 +25,18 @@ extension ScrollControllerExtension on ScrollController {
|
|||||||
curve: Curves.easeInOut,
|
curve: Curves.easeInOut,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void scrollToBottomWithPadding({required double padding}) {
|
||||||
|
try {
|
||||||
|
final maxExtent = position.maxScrollExtent;
|
||||||
|
|
||||||
|
final targetOffset = (maxExtent - padding).clamp(0.0, maxExtent);
|
||||||
|
|
||||||
|
animateTo(
|
||||||
|
targetOffset,
|
||||||
|
duration: const Duration(milliseconds: 500),
|
||||||
|
curve: Curves.easeInOut,
|
||||||
|
);
|
||||||
|
} catch (_) {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,10 +86,23 @@ class CollapseEmailInThreadDetailAction extends EmailUIAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class OpenAttachmentListAction extends EmailUIAction {
|
class OpenAttachmentListAction extends EmailUIAction {
|
||||||
OpenAttachmentListAction(this.emailId);
|
OpenAttachmentListAction({
|
||||||
|
required this.emailId,
|
||||||
|
required this.countAttachments,
|
||||||
|
required this.screenHeight,
|
||||||
|
this.isDisplayAllAttachments = false,
|
||||||
|
});
|
||||||
|
|
||||||
final EmailId? emailId;
|
final EmailId? emailId;
|
||||||
|
final int countAttachments;
|
||||||
|
final bool isDisplayAllAttachments;
|
||||||
|
final double screenHeight;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Object?> get props => [emailId];
|
List<Object?> get props => [
|
||||||
|
emailId,
|
||||||
|
countAttachments,
|
||||||
|
isDisplayAllAttachments,
|
||||||
|
screenHeight,
|
||||||
|
];
|
||||||
}
|
}
|
||||||
@@ -432,7 +432,12 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
|
|||||||
if (_currentEmailId == null || action.emailId != _currentEmailId) {
|
if (_currentEmailId == null || action.emailId != _currentEmailId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
jumpToAttachmentList();
|
jumpToAttachmentList(
|
||||||
|
emailId: _currentEmailId!,
|
||||||
|
countAttachments: action.countAttachments,
|
||||||
|
screenHeight: action.screenHeight,
|
||||||
|
isDisplayAllAttachments: action.isDisplayAllAttachments,
|
||||||
|
);
|
||||||
mailboxDashBoardController.clearEmailUIAction();
|
mailboxDashBoardController.clearEmailUIAction();
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
@@ -1765,10 +1770,12 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
|
|||||||
|
|
||||||
void showAllAttachmentsAction() {
|
void showAllAttachmentsAction() {
|
||||||
isDisplayAllAttachments.value = true;
|
isDisplayAllAttachments.value = true;
|
||||||
|
threadDetailController?.isDisplayAllAttachments = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void hideAllAttachmentsAction() {
|
void hideAllAttachmentsAction() {
|
||||||
isDisplayAllAttachments.value = false;
|
isDisplayAllAttachments.value = false;
|
||||||
|
threadDetailController?.isDisplayAllAttachments = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _unsubscribeEmail(BuildContext context, PresentationEmail presentationEmail) {
|
void _unsubscribeEmail(BuildContext context, PresentationEmail presentationEmail) {
|
||||||
|
|||||||
+41
-7
@@ -1,16 +1,50 @@
|
|||||||
import 'package:core/presentation/extensions/scroll_controller_extension.dart';
|
import 'package:core/presentation/extensions/scroll_controller_extension.dart';
|
||||||
|
import 'package:core/utils/app_logger.dart';
|
||||||
|
import 'package:core/utils/platform_info.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
||||||
import 'package:tmail_ui_user/features/email/presentation/controller/single_email_controller.dart';
|
import 'package:tmail_ui_user/features/email/presentation/controller/single_email_controller.dart';
|
||||||
|
import 'package:tmail_ui_user/features/email/presentation/utils/email_utils.dart';
|
||||||
|
|
||||||
extension HandleOpenAttachmentListExtension on SingleEmailController {
|
extension HandleOpenAttachmentListExtension on SingleEmailController {
|
||||||
void jumpToAttachmentList() {
|
void jumpToAttachmentList({
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
required EmailId emailId,
|
||||||
if (attachmentListKey == null) return;
|
required int countAttachments,
|
||||||
|
required double screenHeight,
|
||||||
|
bool isDisplayAllAttachments = false,
|
||||||
|
}) {
|
||||||
|
final scrollController = threadDetailController?.scrollController;
|
||||||
|
if (scrollController == null || !scrollController.hasClients) {
|
||||||
|
logError(
|
||||||
|
'$runtimeType::jumpToAttachmentList(): scrollController is null');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
threadDetailController?.scrollController?.scrollToWidgetTop(
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
key: attachmentListKey!,
|
if (PlatformInfo.isWeb && attachmentListKey != null) {
|
||||||
padding: 70,
|
scrollController.scrollToWidgetTop(
|
||||||
);
|
key: attachmentListKey!,
|
||||||
|
padding: 70,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
final emailContentHeight =
|
||||||
|
(screenHeight - 180).clamp(0.0, screenHeight).toDouble();
|
||||||
|
|
||||||
|
final totalItems = isDisplayAllAttachments
|
||||||
|
? countAttachments + 1
|
||||||
|
: EmailUtils.maxMobileVisibleAttachments + 1;
|
||||||
|
|
||||||
|
final totalAttachmentsHeight =
|
||||||
|
totalItems * EmailUtils.attachmentItemHeight +
|
||||||
|
(totalItems - 1) * EmailUtils.attachmentItemSpacing;
|
||||||
|
|
||||||
|
log('$runtimeType::jumpToAttachmentList(): totalAttachmentsHeight: $totalAttachmentsHeight, emailContentHeight: $emailContentHeight');
|
||||||
|
scrollController.scrollToBottomWithPadding(
|
||||||
|
padding: totalAttachmentsHeight < emailContentHeight
|
||||||
|
? 0
|
||||||
|
: emailContentHeight,
|
||||||
|
);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ class EmailUtils {
|
|||||||
static const double desktopItemMaxWidth = 260;
|
static const double desktopItemMaxWidth = 260;
|
||||||
static const double desktopMoreButtonMaxWidth = 70;
|
static const double desktopMoreButtonMaxWidth = 70;
|
||||||
static const double attachmentItemSpacing = 8;
|
static const double attachmentItemSpacing = 8;
|
||||||
|
static const double attachmentItemHeight = 36;
|
||||||
static const int maxMobileVisibleAttachments = 3;
|
static const int maxMobileVisibleAttachments = 3;
|
||||||
|
|
||||||
EmailUtils._();
|
EmailUtils._();
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ class AttachmentItemWidget extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return TMailContainerWidget(
|
return TMailContainerWidget(
|
||||||
height: 36,
|
height: EmailUtils.attachmentItemHeight,
|
||||||
borderRadius: 8,
|
borderRadius: 8,
|
||||||
border: Border.all(color: AppColor.m3Tertiary70),
|
border: Border.all(color: AppColor.m3Tertiary70),
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ class EmailAttachmentsWidget extends StatelessWidget {
|
|||||||
bool isMobile = responsiveUtils.isMobile(context);
|
bool isMobile = responsiveUtils.isMobile(context);
|
||||||
|
|
||||||
final hideButton = SizedBox(
|
final hideButton = SizedBox(
|
||||||
height: 36,
|
height: EmailUtils.attachmentItemHeight,
|
||||||
width: isMobile ? double.infinity : null,
|
width: isMobile ? double.infinity : null,
|
||||||
child: ConfirmDialogButton(
|
child: ConfirmDialogButton(
|
||||||
label: AppLocalizations.of(context).hideAll,
|
label: AppLocalizations.of(context).hideAll,
|
||||||
@@ -105,7 +105,9 @@ class EmailAttachmentsWidget extends StatelessWidget {
|
|||||||
return AttachmentItemWidget(
|
return AttachmentItemWidget(
|
||||||
attachment: attachment,
|
attachment: attachment,
|
||||||
imagePaths: imagePaths,
|
imagePaths: imagePaths,
|
||||||
margin: const EdgeInsets.only(top: 8),
|
margin: const EdgeInsets.only(
|
||||||
|
top: EmailUtils.attachmentItemSpacing,
|
||||||
|
),
|
||||||
downloadAttachmentAction: downloadAttachmentAction,
|
downloadAttachmentAction: downloadAttachmentAction,
|
||||||
viewAttachmentAction: viewAttachmentAction,
|
viewAttachmentAction: viewAttachmentAction,
|
||||||
singleEmailControllerTag: singleEmailControllerTag,
|
singleEmailControllerTag: singleEmailControllerTag,
|
||||||
@@ -113,10 +115,10 @@ class EmailAttachmentsWidget extends StatelessWidget {
|
|||||||
}).toList(),
|
}).toList(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: EmailUtils.attachmentItemSpacing),
|
||||||
if (hiddenItemsCount > 0)
|
if (hiddenItemsCount > 0)
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 36,
|
height: EmailUtils.attachmentItemHeight,
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
child: ConfirmDialogButton(
|
child: ConfirmDialogButton(
|
||||||
label: AppLocalizations.of(context).moreAttachments(
|
label: AppLocalizations.of(context).moreAttachments(
|
||||||
@@ -200,7 +202,7 @@ class EmailAttachmentsWidget extends StatelessWidget {
|
|||||||
}).toList(),
|
}).toList(),
|
||||||
if (hiddenItemsCount > 0)
|
if (hiddenItemsCount > 0)
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 36,
|
height: EmailUtils.attachmentItemHeight,
|
||||||
child: ConfirmDialogButton(
|
child: ConfirmDialogButton(
|
||||||
label: '+$hiddenItemsCount',
|
label: '+$hiddenItemsCount',
|
||||||
backgroundColor: Theme.of(context).colorScheme.outline.withValues(
|
backgroundColor: Theme.of(context).colorScheme.outline.withValues(
|
||||||
|
|||||||
@@ -68,8 +68,4 @@ extension GetThreadDetailActionStatus on ThreadDetailController {
|
|||||||
bool get threadDetailCanPermanentlyDelete {
|
bool get threadDetailCanPermanentlyDelete {
|
||||||
return threadDetailIsTrashed || threadDetailIsSpam || threadDetailIsDraft;
|
return threadDetailIsTrashed || threadDetailIsSpam || threadDetailIsDraft;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get isEmailExpandedHasAttachments {
|
|
||||||
return currentEmailLoaded.value?.attachments.isNotEmpty == true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-2
@@ -18,6 +18,7 @@ import 'package:tmail_ui_user/features/thread/domain/state/mark_as_multiple_emai
|
|||||||
import 'package:tmail_ui_user/features/thread/domain/state/mark_as_star_multiple_email_state.dart';
|
import 'package:tmail_ui_user/features/thread/domain/state/mark_as_star_multiple_email_state.dart';
|
||||||
import 'package:tmail_ui_user/features/thread_detail/presentation/extension/close_thread_detail_action.dart';
|
import 'package:tmail_ui_user/features/thread_detail/presentation/extension/close_thread_detail_action.dart';
|
||||||
import 'package:tmail_ui_user/features/thread_detail/presentation/extension/get_thread_detail_action_status.dart';
|
import 'package:tmail_ui_user/features/thread_detail/presentation/extension/get_thread_detail_action_status.dart';
|
||||||
|
import 'package:tmail_ui_user/features/thread_detail/presentation/extension/parsing_email_opened_properties_extension.dart';
|
||||||
import 'package:tmail_ui_user/features/thread_detail/presentation/thread_detail_controller.dart';
|
import 'package:tmail_ui_user/features/thread_detail/presentation/thread_detail_controller.dart';
|
||||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||||
import 'package:tmail_ui_user/main/routes/app_routes.dart';
|
import 'package:tmail_ui_user/main/routes/app_routes.dart';
|
||||||
@@ -219,9 +220,14 @@ extension OnThreadDetailActionClick on ThreadDetailController {
|
|||||||
return destinationMailbox.id;
|
return destinationMailbox.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void onOpenAttachmentListAction() {
|
void onOpenAttachmentListAction(double screenHeight) {
|
||||||
mailboxDashBoardController.dispatchEmailUIAction(
|
mailboxDashBoardController.dispatchEmailUIAction(
|
||||||
OpenAttachmentListAction(currentExpandedEmailId.value),
|
OpenAttachmentListAction(
|
||||||
|
emailId: currentExpandedEmailId.value,
|
||||||
|
countAttachments: currentAttachmentsList.length,
|
||||||
|
screenHeight: screenHeight,
|
||||||
|
isDisplayAllAttachments: isDisplayAllAttachments,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
import 'package:model/email/attachment.dart';
|
||||||
|
import 'package:tmail_ui_user/features/thread_detail/presentation/thread_detail_controller.dart';
|
||||||
|
|
||||||
|
extension ParsingEmailOpenedPropertiesExtension on ThreadDetailController {
|
||||||
|
List<Attachment> get currentAttachmentsList =>
|
||||||
|
currentEmailLoaded.value?.attachments ?? [];
|
||||||
|
|
||||||
|
bool get isEmailExpandedHasAttachments =>
|
||||||
|
currentAttachmentsList.isNotEmpty == true;
|
||||||
|
}
|
||||||
@@ -123,6 +123,7 @@ class ThreadDetailController extends BaseController {
|
|||||||
ScrollController? scrollController;
|
ScrollController? scrollController;
|
||||||
CreateNewEmailRuleFilterInteractor? _createNewEmailRuleFilterInteractor;
|
CreateNewEmailRuleFilterInteractor? _createNewEmailRuleFilterInteractor;
|
||||||
bool loadThreadOnThreadChanged = false;
|
bool loadThreadOnThreadChanged = false;
|
||||||
|
bool isDisplayAllAttachments = false;
|
||||||
|
|
||||||
AccountId? get accountId => mailboxDashBoardController.accountId.value;
|
AccountId? get accountId => mailboxDashBoardController.accountId.value;
|
||||||
Session? get session => mailboxDashBoardController.sessionCurrent;
|
Session? get session => mailboxDashBoardController.sessionCurrent;
|
||||||
@@ -232,6 +233,7 @@ class ThreadDetailController extends BaseController {
|
|||||||
currentEmailLoaded.value = null;
|
currentEmailLoaded.value = null;
|
||||||
cachedEmailLoaded.clear();
|
cachedEmailLoaded.clear();
|
||||||
_threadGetDebouncer.value = null;
|
_threadGetDebouncer.value = null;
|
||||||
|
isDisplayAllAttachments = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@@ -11,19 +11,19 @@ import 'package:tmail_ui_user/features/email/presentation/action/email_ui_action
|
|||||||
import 'package:tmail_ui_user/features/email/presentation/styles/email_view_app_bar_widget_styles.dart';
|
import 'package:tmail_ui_user/features/email/presentation/styles/email_view_app_bar_widget_styles.dart';
|
||||||
import 'package:tmail_ui_user/features/email/presentation/widgets/email_view_bottom_bar_widget.dart';
|
import 'package:tmail_ui_user/features/email/presentation/widgets/email_view_bottom_bar_widget.dart';
|
||||||
import 'package:tmail_ui_user/features/manage_account/presentation/extensions/vacation_response_extension.dart';
|
import 'package:tmail_ui_user/features/manage_account/presentation/extensions/vacation_response_extension.dart';
|
||||||
|
import 'package:tmail_ui_user/features/manage_account/presentation/vacation/widgets/vacation_notification_message_widget.dart';
|
||||||
import 'package:tmail_ui_user/features/thread_detail/domain/state/get_thread_by_id_state.dart';
|
import 'package:tmail_ui_user/features/thread_detail/domain/state/get_thread_by_id_state.dart';
|
||||||
import 'package:tmail_ui_user/features/thread_detail/presentation/extension/close_thread_detail_action.dart';
|
import 'package:tmail_ui_user/features/thread_detail/presentation/extension/close_thread_detail_action.dart';
|
||||||
import 'package:tmail_ui_user/features/thread_detail/presentation/extension/get_thread_detail_action_status.dart';
|
import 'package:tmail_ui_user/features/thread_detail/presentation/extension/get_thread_detail_action_status.dart';
|
||||||
import 'package:tmail_ui_user/features/thread_detail/presentation/extension/get_thread_details_email_views.dart';
|
import 'package:tmail_ui_user/features/thread_detail/presentation/extension/get_thread_details_email_views.dart';
|
||||||
import 'package:tmail_ui_user/features/thread_detail/presentation/extension/on_thread_detail_action_click.dart';
|
import 'package:tmail_ui_user/features/thread_detail/presentation/extension/on_thread_detail_action_click.dart';
|
||||||
import 'package:tmail_ui_user/features/thread_detail/presentation/extension/on_thread_page_changed.dart';
|
import 'package:tmail_ui_user/features/thread_detail/presentation/extension/on_thread_page_changed.dart';
|
||||||
|
import 'package:tmail_ui_user/features/thread_detail/presentation/extension/parsing_email_opened_properties_extension.dart';
|
||||||
import 'package:tmail_ui_user/features/thread_detail/presentation/thread_detail_controller.dart';
|
import 'package:tmail_ui_user/features/thread_detail/presentation/thread_detail_controller.dart';
|
||||||
import 'package:tmail_ui_user/features/thread_detail/presentation/widgets/thread_detail_app_bar.dart';
|
import 'package:tmail_ui_user/features/thread_detail/presentation/widgets/thread_detail_app_bar.dart';
|
||||||
import 'package:tmail_ui_user/features/thread_detail/presentation/widgets/thread_detail_cupertino_loading_widget.dart';
|
import 'package:tmail_ui_user/features/thread_detail/presentation/widgets/thread_detail_cupertino_loading_widget.dart';
|
||||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||||
|
|
||||||
import '../../manage_account/presentation/vacation/widgets/vacation_notification_message_widget.dart';
|
|
||||||
|
|
||||||
class ThreadDetailView extends GetWidget<ThreadDetailController> {
|
class ThreadDetailView extends GetWidget<ThreadDetailController> {
|
||||||
const ThreadDetailView({super.key});
|
const ThreadDetailView({super.key});
|
||||||
|
|
||||||
@@ -45,7 +45,9 @@ class ThreadDetailView extends GetWidget<ThreadDetailController> {
|
|||||||
onThreadActionClick: controller.onThreadDetailActionClick,
|
onThreadActionClick: controller.onThreadDetailActionClick,
|
||||||
onThreadMoreActionClick: controller.onThreadDetailMoreActionClick,
|
onThreadMoreActionClick: controller.onThreadDetailMoreActionClick,
|
||||||
onOpenAttachmentListAction: controller.isEmailExpandedHasAttachments
|
onOpenAttachmentListAction: controller.isEmailExpandedHasAttachments
|
||||||
? controller.onOpenAttachmentListAction
|
? () => controller.onOpenAttachmentListAction(
|
||||||
|
controller.responsiveUtils.getSizeScreenHeight(context),
|
||||||
|
)
|
||||||
: null,
|
: null,
|
||||||
optionWidgets: [
|
optionWidgets: [
|
||||||
if (controller.previousAvailable)
|
if (controller.previousAvailable)
|
||||||
|
|||||||
Reference in New Issue
Block a user