forked from eatvio/eatvio_app
card adding and selecting default one
This commit is contained in:
@@ -16,54 +16,32 @@ import 'package:go_router/go_router.dart';
|
||||
class MenuScreen extends StatelessWidget {
|
||||
final ProfileModel profileModel;
|
||||
|
||||
const MenuScreen({
|
||||
super.key,
|
||||
required this.profileModel,
|
||||
});
|
||||
const MenuScreen({super.key, required this.profileModel});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: false,
|
||||
title: Text('Меню'),
|
||||
),
|
||||
appBar: AppBar(centerTitle: false, title: Text('Меню')),
|
||||
body: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
_tile(
|
||||
title: 'Настройки профиля',
|
||||
leading: ImageConstant.icnProfileSettings,
|
||||
onTap: () => GoRouter.of(context).push('/settings-screen'),
|
||||
),
|
||||
_tile(title: 'Настройки профиля', leading: ImageConstant.icnProfileSettings, onTap: () => GoRouter.of(context).push('/settings-screen')),
|
||||
if (profileModel.roles.contains('consultant')) _divider(context),
|
||||
if (profileModel.roles.contains('consultant'))
|
||||
_tile(
|
||||
leading: ImageConstant.icnRecipes,
|
||||
title: 'Мои рецепты',
|
||||
onTap: () => GoRouter.of(context).push('/recipe-select-screen'),
|
||||
),
|
||||
_tile(leading: ImageConstant.icnRecipes, title: 'Мои рецепты', onTap: () => GoRouter.of(context).push('/recipe-select-screen')),
|
||||
if (profileModel.roles.contains('consultant')) _divider(context),
|
||||
if (profileModel.roles.contains('consultant'))
|
||||
_tile(
|
||||
leading: 'assets/icons/diets.svg',
|
||||
title: 'Мои диеты',
|
||||
onTap: () => GoRouter.of(context).push(MyDietsScreen.path),
|
||||
),
|
||||
_tile(leading: 'assets/icons/diets.svg', title: 'Мои диеты', onTap: () => GoRouter.of(context).push(MyDietsScreen.path)),
|
||||
if (profileModel.roles.contains('consultant')) _divider(context),
|
||||
if (profileModel.roles.contains('consultant'))
|
||||
_tile(
|
||||
leading: ImageConstant.icnPlans,
|
||||
title: 'Мои планы',
|
||||
onTap: () => GoRouter.of(context).push(MyPlansScreen.path),
|
||||
),
|
||||
_tile(leading: ImageConstant.icnPlans, title: 'Мои планы', onTap: () => GoRouter.of(context).push(MyPlansScreen.path)),
|
||||
_divider(context),
|
||||
_tile(
|
||||
leading: 'assets/icons/finance.svg',
|
||||
title: 'Мои финансы',
|
||||
onTap: () {
|
||||
if (profileModel.roles.contains('consultant')) {
|
||||
GoRouter.of(context).pushNamed('consultantFinanceScreen');
|
||||
GoRouter.of(context).pushNamed('userFinanceScreen');
|
||||
} else {
|
||||
GoRouter.of(context).pushNamed('userFinanceScreen');
|
||||
}
|
||||
@@ -76,17 +54,9 @@ class MenuScreen extends StatelessWidget {
|
||||
// onTap: () => GoRouter.of(context).push('/calendar-screen'),
|
||||
// ),
|
||||
_divider(context),
|
||||
_tile(
|
||||
leading: ImageConstant.icnGlossary,
|
||||
title: 'Глоссарий',
|
||||
onTap: () => GoRouter.of(context).push('/glossary-screen'),
|
||||
),
|
||||
_tile(leading: ImageConstant.icnGlossary, title: 'Глоссарий', onTap: () => GoRouter.of(context).push('/glossary-screen')),
|
||||
_divider(context),
|
||||
_tile(
|
||||
leading: ImageConstant.icnSupport,
|
||||
title: 'Поддержка',
|
||||
onTap: () => GoRouter.of(context).push('/support-screen'),
|
||||
),
|
||||
_tile(leading: ImageConstant.icnSupport, title: 'Поддержка', onTap: () => GoRouter.of(context).push('/support-screen')),
|
||||
_divider(context),
|
||||
_tile(
|
||||
leading: ImageConstant.icnDevTools,
|
||||
@@ -96,36 +66,19 @@ class MenuScreen extends StatelessWidget {
|
||||
},
|
||||
),
|
||||
_divider(context),
|
||||
_tile(
|
||||
leading: ImageConstant.icnExit,
|
||||
title: 'Выход',
|
||||
onTap: _onTapLogout(context),
|
||||
),
|
||||
_tile(leading: ImageConstant.icnExit, title: 'Выход', onTap: _onTapLogout(context)),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
_tile({
|
||||
required String title,
|
||||
required String leading,
|
||||
required Function() onTap,
|
||||
}) {
|
||||
_tile({required String title, required String leading, required Function() onTap}) {
|
||||
return ListTile(
|
||||
onTap: onTap,
|
||||
leading: SvgPicture.asset(
|
||||
leading,
|
||||
height: 24,
|
||||
width: 24,
|
||||
colorFilter: ColorFilter.mode(appTheme.blueA400, BlendMode.srcIn),
|
||||
),
|
||||
leading: SvgPicture.asset(leading, height: 24, width: 24, colorFilter: ColorFilter.mode(appTheme.blueA400, BlendMode.srcIn)),
|
||||
title: Text(title),
|
||||
trailing: Icon(
|
||||
Icons.arrow_forward_ios_rounded,
|
||||
size: 12,
|
||||
color: Colors.black38,
|
||||
),
|
||||
trailing: Icon(Icons.arrow_forward_ios_rounded, size: 12, color: Colors.black38),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -133,10 +86,7 @@ class MenuScreen extends StatelessWidget {
|
||||
return Container(
|
||||
height: 0.4,
|
||||
width: MediaQuery.of(context).size.width - 32,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black26,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
decoration: BoxDecoration(color: Colors.black26, borderRadius: BorderRadius.circular(16)),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -144,33 +94,32 @@ class MenuScreen extends StatelessWidget {
|
||||
return () async {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => CupertinoAlertDialog(
|
||||
title: Text("Выход"),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
onPressed: () async {
|
||||
try {
|
||||
await sl<Dio>().post(
|
||||
baseUrl + '/api/profile/logout',
|
||||
);
|
||||
} catch (e) {
|
||||
} finally {
|
||||
await TokenStorage.removeTokenInStorage();
|
||||
GoRouter.of(context).go('/auth-screen', extra: true);
|
||||
}
|
||||
},
|
||||
child: Text("Выйти"),
|
||||
isDestructiveAction: true,
|
||||
builder:
|
||||
(context) => CupertinoAlertDialog(
|
||||
title: Text("Выход"),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
onPressed: () async {
|
||||
try {
|
||||
await sl<Dio>().post(baseUrl + '/api/profile/logout');
|
||||
} catch (e) {
|
||||
} finally {
|
||||
await TokenStorage.removeTokenInStorage();
|
||||
GoRouter.of(context).go('/auth-screen', extra: true);
|
||||
}
|
||||
},
|
||||
child: Text("Выйти"),
|
||||
isDestructiveAction: true,
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: Text("Отмена"),
|
||||
),
|
||||
],
|
||||
content: Text("Вы уверены что хотите выйти из аккаунта?"),
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: Text("Отмена"),
|
||||
),
|
||||
],
|
||||
content: Text("Вы уверены что хотите выйти из аккаунта?"),
|
||||
),
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user