TF-1611 Fix can not display correctly menu screen when open setting view

(cherry picked from commit 2ba04f782ef17dac3b93930dccd3723f13d6836d)
This commit is contained in:
dab246
2023-03-24 01:13:51 +07:00
committed by Dat Vu
parent bc01ab9b0f
commit fed514e40b
20 changed files with 174 additions and 274 deletions
@@ -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;
}
}
}