feat: add settings

This commit is contained in:
mso7nueh
2024-09-27 11:55:42 +03:00
parent 2dcb677c7c
commit 346404503e
19 changed files with 1143 additions and 668 deletions

View File

@@ -1,9 +1,9 @@
import 'package:eatvio_app/data/models/selectionPopupModel/selection_popup_model.dart';
import 'package:eatvio_app/core/const.dart';
import 'package:eatvio_app/theme/theme_helper.dart';
import 'package:eatvio_app/widgets/custom_drop_down.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:url_launcher/url_launcher.dart';
class SettingsScreen extends StatefulWidget {
const SettingsScreen({super.key});
@@ -19,68 +19,35 @@ class _SettingsScreenState extends State<SettingsScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Color(0xFFF0F2F5),
appBar: AppBar(
title: Text('Настройки'),
),
body: SingleChildScrollView(
padding: EdgeInsets.symmetric(vertical: 16),
physics: const BouncingScrollPhysics(),
child: Column(
children: [
const SizedBox(height: 16),
_selectLanguageDropDown(),
const SizedBox(height: 20),
_additionalInfo(),
const SizedBox(height: 12),
_notifications(),
const SizedBox(height: 12),
_aboutEatvio(),
const SizedBox(height: 16),
const SizedBox(height: 12),
_becomeConsultantButton(),
const SizedBox(height: 8),
_deleteAccountButton(),
const SizedBox(height: 16),
],
),
),
);
}
_selectLanguageDropDown() {
final items = [SelectionPopupModel(title: 'Русский', id: 0, isSelected: true, value: 'Русский')];
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: Text(
'Язык',
style: TextStyle(
fontSize: 16,
height: 1,
color: Colors.grey,
),
),
),
const SizedBox(height: 8),
_actionsGroup(
CustomDropDown(
items: items,
value: items[0],
autofocus: false,
),
),
],
);
}
_additionalInfo() {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Text(
'Дополнительаная информация',
style: TextStyle(
@@ -91,108 +58,29 @@ class _SettingsScreenState extends State<SettingsScreen> {
),
),
),
const SizedBox(height: 8),
_actionsGroup(
Column(
children: [
const SizedBox(height: 8),
GestureDetector(
onTap: () => GoRouter.of(context).pushNamed('generalInfoScreen'),
child: Row(
children: [
Text(
'Общая информация',
style: TextStyle(
color: Colors.black,
),
),
const Spacer(),
Icon(
Icons.keyboard_arrow_right_rounded,
color: Colors.grey.shade400,
),
],
),
),
_divider(context),
GestureDetector(
onTap: () => GoRouter.of(context).pushNamed('physicalFormScreen'),
child: Row(
children: [
Text(
'Физическая форма',
style: TextStyle(
color: Colors.black,
),
),
const Spacer(),
Icon(
Icons.keyboard_arrow_right_rounded,
color: Colors.grey.shade400,
),
],
),
),
_divider(context),
GestureDetector(
onTap: () => GoRouter.of(context).pushNamed('pressureScreen'),
child: Row(
children: [
Text(
'Давление',
style: TextStyle(
color: Colors.black,
),
),
const Spacer(),
Icon(
Icons.keyboard_arrow_right_rounded,
color: Colors.grey.shade400,
),
],
),
),
_divider(context),
GestureDetector(
onTap: () => GoRouter.of(context).pushNamed('otherInfoScreen'),
child: Row(
children: [
Text(
'Прочая информация',
style: TextStyle(
color: Colors.black,
),
),
const Spacer(),
Icon(
Icons.keyboard_arrow_right_rounded,
color: Colors.grey.shade400,
),
],
),
),
_divider(context),
GestureDetector(
onTap: () => GoRouter.of(context).pushNamed('physicalActivityScreen'),
child: Row(
children: [
Text(
'Физическая нагрузка',
style: TextStyle(
color: Colors.black,
),
),
const Spacer(),
Icon(
Icons.keyboard_arrow_right_rounded,
color: Colors.grey.shade400,
),
],
),
),
const SizedBox(height: 8),
],
),
_tile(
onTap: () => GoRouter.of(context).pushNamed('generalInfoScreen'),
title: 'Общая информация',
),
_divider(context),
_tile(
onTap: () => GoRouter.of(context).pushNamed('physicalFormScreen'),
title: 'Физическая форма',
),
_divider(context),
_tile(
onTap: () => GoRouter.of(context).pushNamed('pressureScreen'),
title: 'Давление',
),
_divider(context),
_tile(
onTap: () => GoRouter.of(context).pushNamed('otherInfoScreen'),
title: 'Прочая информация',
),
_divider(context),
_tile(
onTap: () => GoRouter.of(context).pushNamed('physicalActivityScreen'),
title: 'Физическая нагрузка',
),
],
);
@@ -202,9 +90,8 @@ class _SettingsScreenState extends State<SettingsScreen> {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(height: 8),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Text(
'Уведомления',
style: TextStyle(
@@ -214,55 +101,41 @@ class _SettingsScreenState extends State<SettingsScreen> {
),
),
),
const SizedBox(height: 8),
_actionsGroup(
Column(
children: [
Row(
children: [
Text(
'Уведомление о новых обновлениях',
style: TextStyle(
color: Colors.black,
),
),
const Spacer(),
CupertinoSwitch(
value: updatesNotificationsSwitchState,
activeColor: appTheme.blueA400,
onChanged: (newValue) {
setState(() {
updatesNotificationsSwitchState = newValue;
});
},
),
],
),
_divider(context),
Row(
children: [
Text(
'Напоминание о заполнении дневника',
style: TextStyle(
color: Colors.black,
),
),
const Spacer(),
CupertinoSwitch(
value: fillDiaryNotificationsSwitchState,
activeColor: appTheme.blueA400,
onChanged: (newValue) {
setState(() {
fillDiaryNotificationsSwitchState = newValue;
});
},
),
],
),
],
_tile(
onTap: () {
setState(() {
updatesNotificationsSwitchState = !updatesNotificationsSwitchState;
});
},
title: 'Уведомление о новых обновлениях',
trailing: CupertinoSwitch(
value: updatesNotificationsSwitchState,
activeColor: appTheme.blueA400,
onChanged: (newValue) {
setState(() {
updatesNotificationsSwitchState = newValue;
});
},
),
),
_divider(context),
_tile(
onTap: () {
setState(() {
fillDiaryNotificationsSwitchState = !fillDiaryNotificationsSwitchState;
});
},
title: 'Напоминание о заполнении дневника',
trailing: CupertinoSwitch(
value: fillDiaryNotificationsSwitchState,
activeColor: appTheme.blueA400,
onChanged: (newValue) {
setState(() {
fillDiaryNotificationsSwitchState = newValue;
});
},
),
),
const SizedBox(height: 8),
],
);
}
@@ -272,7 +145,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Text(
'О Eatvio',
style: TextStyle(
@@ -282,45 +155,14 @@ class _SettingsScreenState extends State<SettingsScreen> {
),
),
),
const SizedBox(height: 8),
_actionsGroup(
Column(
children: [
const SizedBox(height: 8),
Row(
children: [
Text(
'О компании',
style: TextStyle(
color: Colors.black,
),
),
const Spacer(),
Icon(
Icons.keyboard_arrow_right_rounded,
color: Colors.grey.shade400,
),
],
),
_divider(context),
Row(
children: [
Text(
'Пользовательское соглашение',
style: TextStyle(
color: Colors.black,
),
),
const Spacer(),
Icon(
Icons.keyboard_arrow_right_rounded,
color: Colors.grey.shade400,
),
],
),
const SizedBox(height: 8),
],
),
_tile(
title: 'О компании',
onTap: () async => await launchUrl(Uri.parse(baseUrl + '/ru/company-details')),
),
_divider(context),
_tile(
title: 'Пользовательское соглашение',
onTap: () async => await launchUrl(Uri.parse(baseUrl + '/oferta_bs.pdf')),
),
],
);
@@ -328,15 +170,15 @@ class _SettingsScreenState extends State<SettingsScreen> {
_becomeConsultantButton() {
return Padding(
padding: EdgeInsets.symmetric(horizontal: 8),
padding: EdgeInsets.symmetric(horizontal: 16),
child: InkWell(
onTap: () {},
borderRadius: BorderRadius.circular(12),
borderRadius: BorderRadius.circular(20),
child: Ink(
height: 52,
width: MediaQuery.of(context).size.width - 16,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
borderRadius: BorderRadius.circular(20),
color: appTheme.blueA400,
),
child: Center(
@@ -357,16 +199,16 @@ class _SettingsScreenState extends State<SettingsScreen> {
_deleteAccountButton() {
return Padding(
padding: EdgeInsets.symmetric(horizontal: 8),
padding: EdgeInsets.symmetric(horizontal: 16),
child: InkWell(
onTap: () {},
borderRadius: BorderRadius.circular(12),
borderRadius: BorderRadius.circular(20),
child: Ink(
height: 52,
width: MediaQuery.of(context).size.width - 16,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
color: Colors.black.withOpacity(0.1),
borderRadius: BorderRadius.circular(20),
color: Color(0xFFEAEAEA),
),
child: Center(
child: Text(
@@ -384,25 +226,39 @@ class _SettingsScreenState extends State<SettingsScreen> {
);
}
_actionsGroup(Widget child) {
return Container(
padding: EdgeInsets.symmetric(vertical: 8, horizontal: 8),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
_tile({
required String title,
required Function() onTap,
Widget? trailing,
}) {
return ListTile(
onTap: onTap,
title: Text(
title,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
height: 1,
),
),
child: child,
trailing: trailing ??
Icon(
Icons.arrow_forward_ios_rounded,
size: 12,
color: Colors.black38,
),
);
}
_divider(BuildContext context) {
return Container(
margin: EdgeInsets.symmetric(vertical: 12),
height: 0.4,
width: MediaQuery.of(context).size.width - 16,
decoration: BoxDecoration(
color: Colors.black26,
borderRadius: BorderRadius.circular(16),
return Center(
child: Container(
height: 0.4,
width: MediaQuery.of(context).size.width - 32,
decoration: BoxDecoration(
color: Colors.black26,
borderRadius: BorderRadius.circular(16),
),
),
);
}