forked from eatvio/eatvio_app
97 lines
2.8 KiB
Dart
97 lines
2.8 KiB
Dart
import 'package:dio/dio.dart';
|
|
import 'package:eatvio_app/core/constants/constants.dart';
|
|
import 'package:eatvio_app/core/token_storage.dart';
|
|
import 'package:eatvio_app/core/utils/image_constant.dart';
|
|
import 'package:eatvio_app/locator_service.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_svg/flutter_svg.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
|
|
class MenuScreen extends StatelessWidget {
|
|
const MenuScreen({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: Text('Меню'),
|
|
),
|
|
body: SingleChildScrollView(
|
|
child: Column(
|
|
children: [
|
|
_tile(
|
|
title: 'Настройки профиля',
|
|
leading: ImageConstant.icnProfileSettings,
|
|
onTap: () => GoRouter.of(context).push('/my-settings-screen'),
|
|
),
|
|
_tile(
|
|
leading: ImageConstant.icnRecipes,
|
|
title: 'Мои рецепты',
|
|
onTap: () => GoRouter.of(context).push('/recipe-select-screen'),
|
|
),
|
|
_tile(
|
|
leading: 'assets/icons/diets.svg',
|
|
title: 'Мои диеты',
|
|
onTap: () => GoRouter.of(context).push('/diet-select-screen'),
|
|
),
|
|
_tile(
|
|
leading: ImageConstant.icnPlans,
|
|
title: 'Мои планы',
|
|
onTap: () => GoRouter.of(context).push('/plan-select-screen'),
|
|
),
|
|
_tile(
|
|
leading: 'assets/icons/calendar.svg',
|
|
title: 'Календарь',
|
|
onTap: () => GoRouter.of(context).push('/calendar-screen'),
|
|
),
|
|
_tile(
|
|
leading: ImageConstant.icnGlossary,
|
|
title: 'Глоссарий',
|
|
onTap: () => GoRouter.of(context).push('/glossary-screen'),
|
|
),
|
|
_tile(
|
|
leading: ImageConstant.icnSupport,
|
|
title: 'Поддержка',
|
|
onTap: () {},
|
|
),
|
|
_tile(
|
|
leading: ImageConstant.icnExit,
|
|
title: 'Выход',
|
|
onTap: _onTapLogout(context),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
_tile({
|
|
required String title,
|
|
required String leading,
|
|
required Function() onTap,
|
|
}) {
|
|
return ListTile(
|
|
onTap: onTap,
|
|
leading: SvgPicture.asset(
|
|
leading,
|
|
height: 24,
|
|
width: 24,
|
|
),
|
|
title: Text(title),
|
|
);
|
|
}
|
|
|
|
_onTapLogout(BuildContext context) {
|
|
return () async {
|
|
final response = await sl<Dio>().post(
|
|
baseUrl + '/api/profile/logout',
|
|
);
|
|
|
|
if (response.statusCode == 204) {
|
|
await TokenStorage.removeTokenInStorage();
|
|
GoRouter.of(context).go('/auth-screen');
|
|
}
|
|
};
|
|
}
|
|
}
|