TF-4075 Jump to attachments list position on mobile
(cherry picked from commit cd2ca1ec3c5b5160820823905d9f0183536b07e3)
This commit is contained in:
@@ -86,10 +86,23 @@ class CollapseEmailInThreadDetailAction 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 int countAttachments;
|
||||
final bool isDisplayAllAttachments;
|
||||
final double screenHeight;
|
||||
|
||||
@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) {
|
||||
return;
|
||||
}
|
||||
jumpToAttachmentList();
|
||||
jumpToAttachmentList(
|
||||
emailId: _currentEmailId!,
|
||||
countAttachments: action.countAttachments,
|
||||
screenHeight: action.screenHeight,
|
||||
isDisplayAllAttachments: action.isDisplayAllAttachments,
|
||||
);
|
||||
mailboxDashBoardController.clearEmailUIAction();
|
||||
}
|
||||
}));
|
||||
@@ -1765,10 +1770,12 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
|
||||
|
||||
void showAllAttachmentsAction() {
|
||||
isDisplayAllAttachments.value = true;
|
||||
threadDetailController?.isDisplayAllAttachments = true;
|
||||
}
|
||||
|
||||
void hideAllAttachmentsAction() {
|
||||
isDisplayAllAttachments.value = false;
|
||||
threadDetailController?.isDisplayAllAttachments = false;
|
||||
}
|
||||
|
||||
void _unsubscribeEmail(BuildContext context, PresentationEmail presentationEmail) {
|
||||
|
||||
+41
-7
@@ -1,16 +1,50 @@
|
||||
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: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/utils/email_utils.dart';
|
||||
|
||||
extension HandleOpenAttachmentListExtension on SingleEmailController {
|
||||
void jumpToAttachmentList() {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (attachmentListKey == null) return;
|
||||
void jumpToAttachmentList({
|
||||
required EmailId emailId,
|
||||
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(
|
||||
key: attachmentListKey!,
|
||||
padding: 70,
|
||||
);
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (PlatformInfo.isWeb && attachmentListKey != null) {
|
||||
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 desktopMoreButtonMaxWidth = 70;
|
||||
static const double attachmentItemSpacing = 8;
|
||||
static const double attachmentItemHeight = 36;
|
||||
static const int maxMobileVisibleAttachments = 3;
|
||||
|
||||
EmailUtils._();
|
||||
|
||||
@@ -109,7 +109,7 @@ class AttachmentItemWidget extends StatelessWidget {
|
||||
);
|
||||
|
||||
return TMailContainerWidget(
|
||||
height: 36,
|
||||
height: EmailUtils.attachmentItemHeight,
|
||||
borderRadius: 8,
|
||||
border: Border.all(color: AppColor.m3Tertiary70),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
|
||||
@@ -65,7 +65,7 @@ class EmailAttachmentsWidget extends StatelessWidget {
|
||||
bool isMobile = responsiveUtils.isMobile(context);
|
||||
|
||||
final hideButton = SizedBox(
|
||||
height: 36,
|
||||
height: EmailUtils.attachmentItemHeight,
|
||||
width: isMobile ? double.infinity : null,
|
||||
child: ConfirmDialogButton(
|
||||
label: AppLocalizations.of(context).hideAll,
|
||||
@@ -105,7 +105,9 @@ class EmailAttachmentsWidget extends StatelessWidget {
|
||||
return AttachmentItemWidget(
|
||||
attachment: attachment,
|
||||
imagePaths: imagePaths,
|
||||
margin: const EdgeInsets.only(top: 8),
|
||||
margin: const EdgeInsets.only(
|
||||
top: EmailUtils.attachmentItemSpacing,
|
||||
),
|
||||
downloadAttachmentAction: downloadAttachmentAction,
|
||||
viewAttachmentAction: viewAttachmentAction,
|
||||
singleEmailControllerTag: singleEmailControllerTag,
|
||||
@@ -113,10 +115,10 @@ class EmailAttachmentsWidget extends StatelessWidget {
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
const SizedBox(height: EmailUtils.attachmentItemSpacing),
|
||||
if (hiddenItemsCount > 0)
|
||||
SizedBox(
|
||||
height: 36,
|
||||
height: EmailUtils.attachmentItemHeight,
|
||||
width: double.infinity,
|
||||
child: ConfirmDialogButton(
|
||||
label: AppLocalizations.of(context).moreAttachments(
|
||||
@@ -200,7 +202,7 @@ class EmailAttachmentsWidget extends StatelessWidget {
|
||||
}).toList(),
|
||||
if (hiddenItemsCount > 0)
|
||||
SizedBox(
|
||||
height: 36,
|
||||
height: EmailUtils.attachmentItemHeight,
|
||||
child: ConfirmDialogButton(
|
||||
label: '+$hiddenItemsCount',
|
||||
backgroundColor: Theme.of(context).colorScheme.outline.withValues(
|
||||
|
||||
Reference in New Issue
Block a user