TF-904 Fix Clicking mailbox name redirects to mailbox
This commit is contained in:
committed by
Dat H. Pham
parent
93c703ac54
commit
c0fe0b8196
@@ -108,28 +108,26 @@ class EmailView extends GetWidget<EmailController> with NetworkConnectionMixin {
|
|||||||
Widget _buildAppBar(BuildContext context) {
|
Widget _buildAppBar(BuildContext context) {
|
||||||
return Obx(() => Padding(
|
return Obx(() => Padding(
|
||||||
padding: const EdgeInsets.only(top: 6),
|
padding: const EdgeInsets.only(top: 6),
|
||||||
child: (AppBarMailWidgetBuilder(
|
child: AppBarMailWidgetBuilder(
|
||||||
context,
|
controller.currentEmail,
|
||||||
imagePaths,
|
controller.currentMailbox,
|
||||||
responsiveUtils,
|
onBackActionClick: () => controller.closeEmailView(context),
|
||||||
controller.currentEmail,
|
onEmailActionClick: (email, action) =>
|
||||||
controller.currentMailbox)
|
controller.handleEmailAction(context, email, action),
|
||||||
..onBackActionClick(() => controller.closeEmailView(context))
|
onMoreActionClick: (email, position) {
|
||||||
..addOnEmailActionClick((email, action) =>
|
if (responsiveUtils.isMobile(context)) {
|
||||||
controller.handleEmailAction(context, email, action))
|
controller.openContextMenuAction(
|
||||||
..addOnMoreActionClick((email, position) {
|
context,
|
||||||
if (responsiveUtils.isMobile(context)) {
|
_emailActionMoreActionTile(context, email));
|
||||||
controller.openContextMenuAction(
|
} else {
|
||||||
context,
|
controller.openPopupMenuAction(
|
||||||
_emailActionMoreActionTile(context, email));
|
context,
|
||||||
} else {
|
position,
|
||||||
controller.openPopupMenuAction(
|
_popupMenuEmailActionTile(context, email));
|
||||||
context,
|
}
|
||||||
position,
|
}
|
||||||
_popupMenuEmailActionTile(context, email));
|
)
|
||||||
}
|
));
|
||||||
}))
|
|
||||||
.build()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildBottomBar(BuildContext context) {
|
Widget _buildBottomBar(BuildContext context) {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
import 'package:core/core.dart';
|
import 'package:core/core.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
import 'package:model/model.dart';
|
import 'package:model/model.dart';
|
||||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||||
|
|
||||||
@@ -9,118 +10,132 @@ typedef OnBackActionClick = void Function();
|
|||||||
typedef OnEmailActionClick = void Function(PresentationEmail, EmailActionType);
|
typedef OnEmailActionClick = void Function(PresentationEmail, EmailActionType);
|
||||||
typedef OnMoreActionClick = void Function(PresentationEmail, RelativeRect?);
|
typedef OnMoreActionClick = void Function(PresentationEmail, RelativeRect?);
|
||||||
|
|
||||||
class AppBarMailWidgetBuilder {
|
class AppBarMailWidgetBuilder extends StatelessWidget {
|
||||||
OnBackActionClick? _onBackActionClick;
|
final _imagePaths = Get.find<ImagePaths>();
|
||||||
OnEmailActionClick? _onEmailActionClick;
|
final _responsiveUtils = Get.find<ResponsiveUtils>();
|
||||||
OnMoreActionClick? _onMoreActionClick;
|
|
||||||
|
|
||||||
final BuildContext _context;
|
|
||||||
final ImagePaths _imagePaths;
|
|
||||||
final ResponsiveUtils _responsiveUtils;
|
|
||||||
final PresentationEmail? _presentationEmail;
|
final PresentationEmail? _presentationEmail;
|
||||||
final PresentationMailbox? _currentMailbox;
|
final PresentationMailbox? _currentMailbox;
|
||||||
|
final OnBackActionClick? onBackActionClick;
|
||||||
|
final OnEmailActionClick? onEmailActionClick;
|
||||||
|
final OnMoreActionClick? onMoreActionClick;
|
||||||
|
|
||||||
AppBarMailWidgetBuilder(
|
AppBarMailWidgetBuilder(
|
||||||
this._context,
|
|
||||||
this._imagePaths,
|
|
||||||
this._responsiveUtils,
|
|
||||||
this._presentationEmail,
|
this._presentationEmail,
|
||||||
this._currentMailbox,
|
this._currentMailbox,
|
||||||
);
|
{
|
||||||
|
Key? key,
|
||||||
|
this.onBackActionClick,
|
||||||
|
this.onEmailActionClick,
|
||||||
|
this.onMoreActionClick
|
||||||
|
}
|
||||||
|
) : super(key: key);
|
||||||
|
|
||||||
void onBackActionClick(OnBackActionClick onBackActionClick) {
|
@override
|
||||||
_onBackActionClick = onBackActionClick;
|
Widget build(BuildContext context) {
|
||||||
}
|
|
||||||
|
|
||||||
void addOnEmailActionClick(OnEmailActionClick onEmailActionClick) {
|
|
||||||
_onEmailActionClick = onEmailActionClick;
|
|
||||||
}
|
|
||||||
|
|
||||||
void addOnMoreActionClick(OnMoreActionClick onMoreActionClick) {
|
|
||||||
_onMoreActionClick = onMoreActionClick;
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget build() {
|
|
||||||
return Container(
|
return Container(
|
||||||
key: const Key('app_bar_messenger_widget'),
|
key: const Key('app_bar_messenger_widget'),
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
padding: EdgeInsets.zero,
|
color: Colors.transparent,
|
||||||
margin: EdgeInsets.zero,
|
padding: const EdgeInsets.only(left: 8),
|
||||||
child: MediaQuery(
|
child: Row(children: [
|
||||||
data: const MediaQueryData(padding: EdgeInsets.zero),
|
if (_responsiveUtils.mailboxDashboardHasMailboxAndEmailView(context))
|
||||||
child: Row(
|
Material(
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
color: Colors.transparent,
|
||||||
children: [
|
child: InkWell(
|
||||||
if (_responsiveUtils.mailboxDashboardHasMailboxAndEmailView(_context))
|
onTap: () => onBackActionClick?.call(),
|
||||||
_buildBackButton(),
|
borderRadius: BorderRadius.circular(15),
|
||||||
if (_responsiveUtils.mailboxDashboardHasMailboxAndEmailView(_context))
|
child: Tooltip(
|
||||||
Expanded(child: _buildMailboxName()),
|
message: AppLocalizations.of(context).back,
|
||||||
if (_presentationEmail != null) _buildListOptionButton(),
|
child: Container(
|
||||||
]
|
color: Colors.transparent,
|
||||||
)
|
height: 40,
|
||||||
)
|
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||||
|
child: Row(mainAxisSize: MainAxisSize.min, children: [
|
||||||
|
SvgPicture.asset(
|
||||||
|
_imagePaths.icBack,
|
||||||
|
width: 18,
|
||||||
|
height: 18,
|
||||||
|
color: AppColor.colorTextButton,
|
||||||
|
fit: BoxFit.fill),
|
||||||
|
Container(
|
||||||
|
margin: const EdgeInsets.only(left: 8),
|
||||||
|
constraints: BoxConstraints(
|
||||||
|
maxWidth: _responsiveUtils.getSizeScreenWidth(context) - 250),
|
||||||
|
child: Text(
|
||||||
|
_currentMailbox?.name?.name.capitalizeFirstEach ?? '',
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: CommonTextStyle.defaultTextOverFlow,
|
||||||
|
softWrap: CommonTextStyle.defaultSoftWrap,
|
||||||
|
style: const TextStyle(fontSize: 17, color: AppColor.colorTextButton)),
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Spacer(),
|
||||||
|
if (_presentationEmail != null) _buildListOptionButton(context),
|
||||||
|
])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildBackButton() {
|
Widget _buildListOptionButton(BuildContext context) {
|
||||||
return buildIconWeb(
|
|
||||||
icon: SvgPicture.asset(_imagePaths.icBack, width: 18, height: 18, color: AppColor.colorTextButton, fit: BoxFit.fill),
|
|
||||||
tooltip: AppLocalizations.of(_context).back,
|
|
||||||
onTap: () => _onBackActionClick?.call()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildMailboxName() {
|
|
||||||
return Transform(
|
|
||||||
transform: Matrix4.translationValues(-10.0, 0.0, 0.0),
|
|
||||||
child: Text(
|
|
||||||
_currentMailbox?.name?.name.capitalizeFirstEach ?? '',
|
|
||||||
maxLines: 1,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: const TextStyle(fontSize: 17, color: AppColor.colorTextButton))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildListOptionButton() {
|
|
||||||
return Row(
|
return Row(
|
||||||
children: [
|
children: [
|
||||||
buildIconWeb(
|
buildIconWeb(
|
||||||
icon: SvgPicture.asset(_imagePaths.icMoveEmail, fit: BoxFit.fill),
|
icon: SvgPicture.asset(_imagePaths.icMoveEmail, fit: BoxFit.fill),
|
||||||
tooltip: AppLocalizations.of(_context).move_message,
|
tooltip: AppLocalizations.of(context).move_message,
|
||||||
onTap: () => _onEmailActionClick?.call(_presentationEmail!, EmailActionType.moveToMailbox)),
|
onTap: () => onEmailActionClick?.call(
|
||||||
|
_presentationEmail!,
|
||||||
|
EmailActionType.moveToMailbox)),
|
||||||
buildIconWeb(
|
buildIconWeb(
|
||||||
icon: SvgPicture.asset(_presentationEmail!.hasStarred ? _imagePaths.icStar : _imagePaths.icUnStar, fit: BoxFit.fill),
|
icon: SvgPicture.asset(
|
||||||
tooltip: _presentationEmail!.hasStarred ? AppLocalizations.of(_context).not_starred : AppLocalizations.of(_context).mark_as_starred,
|
_presentationEmail!.hasStarred
|
||||||
onTap: () => _onEmailActionClick?.call(_presentationEmail!,
|
? _imagePaths.icStar
|
||||||
_presentationEmail!.hasStarred ? EmailActionType.unMarkAsStarred : EmailActionType.markAsStarred)),
|
: _imagePaths.icUnStar,
|
||||||
|
fit: BoxFit.fill),
|
||||||
|
tooltip: _presentationEmail!.hasStarred
|
||||||
|
? AppLocalizations.of(context).not_starred
|
||||||
|
: AppLocalizations.of(context).mark_as_starred,
|
||||||
|
onTap: () => onEmailActionClick?.call(_presentationEmail!,
|
||||||
|
_presentationEmail!.hasStarred
|
||||||
|
? EmailActionType.unMarkAsStarred
|
||||||
|
: EmailActionType.markAsStarred)),
|
||||||
buildIconWeb(
|
buildIconWeb(
|
||||||
icon: SvgPicture.asset(_imagePaths.icDeleteEmail, fit: BoxFit.fill),
|
icon: SvgPicture.asset(_imagePaths.icDeleteEmail, fit: BoxFit.fill),
|
||||||
tooltip: _currentMailbox?.role != PresentationMailbox.roleTrash
|
tooltip: _currentMailbox?.role != PresentationMailbox.roleTrash
|
||||||
? AppLocalizations.of(_context).move_to_trash
|
? AppLocalizations.of(context).move_to_trash
|
||||||
: AppLocalizations.of(_context).delete_permanently,
|
: AppLocalizations.of(context).delete_permanently,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (_currentMailbox?.role != PresentationMailbox.roleTrash) {
|
if (_currentMailbox?.role != PresentationMailbox.roleTrash) {
|
||||||
_onEmailActionClick?.call(_presentationEmail!, EmailActionType.moveToTrash);
|
onEmailActionClick?.call(
|
||||||
|
_presentationEmail!,
|
||||||
|
EmailActionType.moveToTrash);
|
||||||
} else {
|
} else {
|
||||||
_onEmailActionClick?.call(_presentationEmail!, EmailActionType.deletePermanently);
|
onEmailActionClick?.call(
|
||||||
|
_presentationEmail!,
|
||||||
|
EmailActionType.deletePermanently);
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(left: 10, right: 16),
|
padding: const EdgeInsets.only(left: 10, right: 16),
|
||||||
child: buildIconWebHasPosition(
|
child: buildIconWebHasPosition(
|
||||||
_context,
|
context,
|
||||||
tooltip: AppLocalizations.of(_context).more,
|
tooltip: AppLocalizations.of(context).more,
|
||||||
icon: SvgPicture.asset(_imagePaths.icMore, fit: BoxFit.fill),
|
icon: SvgPicture.asset(_imagePaths.icMore, fit: BoxFit.fill),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (_presentationEmail != null && _responsiveUtils.isMobile(_context)) {
|
if (_presentationEmail != null && _responsiveUtils.isMobile(context)) {
|
||||||
_onMoreActionClick?.call(_presentationEmail!, null);
|
onMoreActionClick?.call(_presentationEmail!, null);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onTapDown: (position) {
|
onTapDown: (position) {
|
||||||
if (_presentationEmail != null && !_responsiveUtils.isMobile(_context)) {
|
if (_presentationEmail != null && !_responsiveUtils.isMobile(context)) {
|
||||||
_onMoreActionClick?.call(_presentationEmail!, position);
|
onMoreActionClick?.call(_presentationEmail!, position);
|
||||||
}
|
}
|
||||||
})),
|
}
|
||||||
|
)
|
||||||
|
),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user