TF-1611 Fix can not display correctly menu screen when open setting view
(cherry picked from commit 2ba04f782ef17dac3b93930dccd3723f13d6836d)
This commit is contained in:
@@ -1,31 +1,10 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:tmail_ui_user/features/base/base_bindings.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/menu/manage_account_menu_controller.dart';
|
||||
|
||||
class ManageAccountMenuBindings extends BaseBindings {
|
||||
class ManageAccountMenuBindings extends Bindings {
|
||||
|
||||
@override
|
||||
void bindingsController() {
|
||||
Get.lazyPut(() => ManageAccountMenuController());
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsDataSource() {
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsDataSourceImpl() {
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsInteractor() {
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsRepository() {
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsRepositoryImpl() {
|
||||
void dependencies() {
|
||||
Get.put(ManageAccountMenuController());
|
||||
}
|
||||
}
|
||||
@@ -1,68 +1,59 @@
|
||||
|
||||
import 'package:core/core.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:tmail_ui_user/features/base/base_controller.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/manage_account_dashboard_controller.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/model/account_menu_item.dart';
|
||||
import 'package:tmail_ui_user/main/routes/route_navigation.dart';
|
||||
|
||||
class ManageAccountMenuController extends BaseController {
|
||||
class ManageAccountMenuController extends GetxController {
|
||||
|
||||
final dashBoardController = Get.find<ManageAccountDashBoardController>();
|
||||
|
||||
late Worker sessionWorker;
|
||||
final _responsiveUtils = Get.find<ResponsiveUtils>();
|
||||
|
||||
final listAccountMenuItem = RxList<AccountMenuItem>([
|
||||
AccountMenuItem.profiles,
|
||||
AccountMenuItem.vacation,
|
||||
AccountMenuItem.mailboxVisibility,
|
||||
AccountMenuItem.languageAndRegion,
|
||||
]);
|
||||
|
||||
void _initWorker() {
|
||||
sessionWorker = ever(dashBoardController.accountId, (_) {
|
||||
_createListAccountMenu();
|
||||
void _registerObxStreamListener() {
|
||||
ever(dashBoardController.accountId, (accountId) {
|
||||
if (accountId != null) {
|
||||
_createListAccountMenu();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void _clearWorker() {
|
||||
sessionWorker.call();
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
_initWorker();
|
||||
_createListAccountMenu();
|
||||
_registerObxStreamListener();
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
void _createListAccountMenu(){
|
||||
listAccountMenuItem.clear();
|
||||
listAccountMenuItem.add(AccountMenuItem.profiles);
|
||||
if (dashBoardController.isRuleFilterCapabilitySupported) {
|
||||
listAccountMenuItem.add(AccountMenuItem.emailRules);
|
||||
}
|
||||
if (dashBoardController.isForwardCapabilitySupported) {
|
||||
listAccountMenuItem.add(AccountMenuItem.forward);
|
||||
}
|
||||
if (dashBoardController.isVacationCapabilitySupported) {
|
||||
listAccountMenuItem.add(AccountMenuItem.vacation);
|
||||
}
|
||||
listAccountMenuItem.addAll(
|
||||
[
|
||||
AccountMenuItem.mailboxVisibility,
|
||||
AccountMenuItem.languageAndRegion
|
||||
]
|
||||
);
|
||||
}
|
||||
void _createListAccountMenu() {
|
||||
final newListMenuSetting = [
|
||||
AccountMenuItem.profiles,
|
||||
if (dashBoardController.isRuleFilterCapabilitySupported)
|
||||
AccountMenuItem.emailRules,
|
||||
if (dashBoardController.isForwardCapabilitySupported)
|
||||
AccountMenuItem.forward,
|
||||
if (dashBoardController.isVacationCapabilitySupported)
|
||||
AccountMenuItem.vacation,
|
||||
AccountMenuItem.mailboxVisibility,
|
||||
AccountMenuItem.languageAndRegion
|
||||
];
|
||||
listAccountMenuItem.value = newListMenuSetting;
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
_clearWorker();
|
||||
super.onClose();
|
||||
if (listAccountMenuItem.isNotEmpty) {
|
||||
if (currentContext != null && _responsiveUtils.isWebDesktop(currentContext!)) {
|
||||
selectAccountMenuItem(listAccountMenuItem.first);
|
||||
} else {
|
||||
selectAccountMenuItem(AccountMenuItem.none);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onDone() {}
|
||||
|
||||
void selectAccountMenuItem(AccountMenuItem newAccountMenuItem) {
|
||||
dashBoardController.selectAccountMenuItem(newAccountMenuItem);
|
||||
}
|
||||
|
||||
@@ -89,24 +89,29 @@ class ManageAccountMenuView extends GetWidget<ManageAccountMenuController> {
|
||||
AppLocalizations.of(context).manage_account,
|
||||
style: const TextStyle(color: Colors.black, fontWeight: FontWeight.bold, fontSize: 17))),
|
||||
const SizedBox(height: 12),
|
||||
Obx(
|
||||
() => ListView.builder(
|
||||
Obx(() {
|
||||
if (controller.listAccountMenuItem.isNotEmpty) {
|
||||
return ListView.builder(
|
||||
key: const Key('list_manage_account_menu_item'),
|
||||
padding: EdgeInsets.only(
|
||||
left: AppUtils.isDirectionRTL(context) ? 8 : 16,
|
||||
right: AppUtils.isDirectionRTL(context) ? 16 : 8
|
||||
),
|
||||
key: const Key('list_manage_account_property'),
|
||||
shrinkWrap: true,
|
||||
itemCount: controller.listAccountMenuItem.length,
|
||||
itemBuilder: (context, index) => Obx(() => AccountMenuItemTileBuilder(
|
||||
context,
|
||||
_imagePaths,
|
||||
_responsiveUtils,
|
||||
controller.listAccountMenuItem[index],
|
||||
itemBuilder: (context, index) => Obx(() {
|
||||
final menuItem = controller.listAccountMenuItem[index];
|
||||
return AccountMenuItemTileBuilder(
|
||||
menuItem,
|
||||
controller.dashBoardController.accountMenuItemSelected.value,
|
||||
onSelectAccountMenuItemAction: (newAccountMenuItem) =>
|
||||
controller.selectAccountMenuItem(newAccountMenuItem)))),
|
||||
),
|
||||
onSelectAccountMenuItemAction: controller.selectAccountMenuItem
|
||||
);
|
||||
})
|
||||
);
|
||||
} else {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
}),
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 16),
|
||||
child: Divider(color: AppColor.lineItemListColor, height: 0.5, thickness: 0.2)),
|
||||
@@ -117,7 +122,7 @@ class ManageAccountMenuView extends GetWidget<ManageAccountMenuController> {
|
||||
),
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
controller.logout(
|
||||
controller.dashBoardController.logout(
|
||||
controller.dashBoardController.sessionCurrent,
|
||||
controller.dashBoardController.accountId.value
|
||||
);
|
||||
|
||||
@@ -55,6 +55,9 @@ class SettingsView extends GetWidget<SettingsController> {
|
||||
top: 16),
|
||||
fromAccountDashBoard: true,
|
||||
vacationResponse: controller.manageAccountDashboardController.vacationResponse.value!,
|
||||
actionGotoVacationSetting: !controller.manageAccountDashboardController.inVacationSettings()
|
||||
? () => controller.manageAccountDashboardController.selectAccountMenuItem(AccountMenuItem.vacation)
|
||||
: null,
|
||||
actionEndNow: () => controller.manageAccountDashboardController.disableVacationResponder());
|
||||
} else if ((controller.manageAccountDashboardController.vacationResponse.value?.vacationResponderIsWaiting == true
|
||||
|| controller.manageAccountDashboardController.vacationResponse.value?.vacationResponderIsStopped == true)
|
||||
|
||||
+37
-27
@@ -1,61 +1,71 @@
|
||||
import 'package:core/core.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/model/account_menu_item.dart';
|
||||
|
||||
typedef OnSelectAccountMenuItemAction = void Function(AccountMenuItem);
|
||||
|
||||
class AccountMenuItemTileBuilder extends StatelessWidget {
|
||||
|
||||
final BuildContext _context;
|
||||
final ImagePaths _imagePaths;
|
||||
final ResponsiveUtils _responsiveUtils;
|
||||
final AccountMenuItem _menuItem;
|
||||
final AccountMenuItem _menuItemSelected;
|
||||
final AccountMenuItem? _menuItemSelected;
|
||||
final OnSelectAccountMenuItemAction? onSelectAccountMenuItemAction;
|
||||
|
||||
const AccountMenuItemTileBuilder(
|
||||
this._context,
|
||||
this._imagePaths,
|
||||
this._responsiveUtils,
|
||||
this._menuItem,
|
||||
this._menuItemSelected,
|
||||
{Key? key, this.onSelectAccountMenuItemAction}
|
||||
{
|
||||
Key? key,
|
||||
this.onSelectAccountMenuItemAction
|
||||
}
|
||||
) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final imagePaths = Get.find<ImagePaths>();
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(top: 6),
|
||||
child: InkWell(
|
||||
onTap: () => onSelectAccountMenuItemAction?.call(_menuItem),
|
||||
child: Container(
|
||||
key: const Key('account_menu_item_tile'),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: backgroundColorItem),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||||
child: Column(children: [
|
||||
Row(children: [
|
||||
SvgPicture.asset(_menuItem.getIcon(_imagePaths),
|
||||
width: 20,
|
||||
height: 20,
|
||||
fit: BoxFit.fill),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(child: Text(_menuItem.getName(context),
|
||||
style: const TextStyle(fontWeight: FontWeight.normal, fontSize: 15, color: Colors.black)))
|
||||
]),
|
||||
])
|
||||
key: const Key('account_menu_item_tile'),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: _getBackgroundColorItem(context)),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||||
child: Column(children: [
|
||||
Row(children: [
|
||||
SvgPicture.asset(
|
||||
_menuItem.getIcon(imagePaths),
|
||||
width: 20,
|
||||
height: 20,
|
||||
fit: BoxFit.fill),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(child: Text(
|
||||
_menuItem.getName(context),
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.normal,
|
||||
fontSize: 15,
|
||||
color: Colors.black
|
||||
)
|
||||
))
|
||||
]),
|
||||
])
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
Color get backgroundColorItem {
|
||||
Color _getBackgroundColorItem(BuildContext context) {
|
||||
final responsiveUtils = Get.find<ResponsiveUtils>();
|
||||
|
||||
if (_menuItemSelected == _menuItem) {
|
||||
return AppColor.colorBgMailboxSelected;
|
||||
}
|
||||
return _responsiveUtils.isWebDesktop(_context)
|
||||
} else {
|
||||
return responsiveUtils.isWebDesktop(context)
|
||||
? AppColor.colorBgDesktop
|
||||
: Colors.white;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user