add check availble filter rule in session
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
|
||||
import 'package:core/presentation/utils/responsive_utils.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/session/session.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';
|
||||
@@ -8,12 +11,48 @@ import 'package:tmail_ui_user/features/manage_account/presentation/model/account
|
||||
class ManageAccountMenuController extends BaseController {
|
||||
|
||||
final dashBoardController = Get.find<ManageAccountDashBoardController>();
|
||||
final _responsiveUtils = Get.find<ResponsiveUtils>();
|
||||
|
||||
final listAccountMenuItem = <AccountMenuItem>[
|
||||
late Worker sessionWorker;
|
||||
|
||||
final listAccountMenuItem = RxList<AccountMenuItem>([
|
||||
AccountMenuItem.profiles,
|
||||
AccountMenuItem.emailRules,
|
||||
AccountMenuItem.languageAndRegion,
|
||||
];
|
||||
]);
|
||||
|
||||
void _initWorker() {
|
||||
sessionWorker = ever(dashBoardController.sessionCurrent, (_) {
|
||||
_createListAccountMenuItemWithEmailRule();
|
||||
});
|
||||
}
|
||||
|
||||
void _clearWorker() {
|
||||
sessionWorker.call();
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
_initWorker();
|
||||
_createListAccountMenuItemWithEmailRule();
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
_createListAccountMenuItemWithEmailRule(){
|
||||
if (dashBoardController.checkAvailableRuleFilterInSession()) {
|
||||
listAccountMenuItem.clear();
|
||||
listAccountMenuItem.addAll([
|
||||
AccountMenuItem.profiles,
|
||||
AccountMenuItem.emailRules,
|
||||
AccountMenuItem.languageAndRegion,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
_clearWorker();
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
@override
|
||||
void onDone() {
|
||||
|
||||
@@ -77,19 +77,21 @@ 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),
|
||||
ListView.builder(
|
||||
padding: const EdgeInsets.only(left: 16, right: 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],
|
||||
controller.dashBoardController.accountMenuItemSelected.value,
|
||||
onSelectAccountMenuItemAction: (newAccountMenuItem) =>
|
||||
controller.selectAccountMenuItem(newAccountMenuItem)))),
|
||||
Obx(
|
||||
() => ListView.builder(
|
||||
padding: const EdgeInsets.only(left: 16, right: 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],
|
||||
controller.dashBoardController.accountMenuItemSelected.value,
|
||||
onSelectAccountMenuItemAction: (newAccountMenuItem) =>
|
||||
controller.selectAccountMenuItem(newAccountMenuItem)))),
|
||||
),
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 16),
|
||||
child: Divider(color: AppColor.lineItemListColor, height: 0.5, thickness: 0.2)),
|
||||
|
||||
Reference in New Issue
Block a user