merge fromdiary to main

This commit is contained in:
Anatoliy Poloz
2024-06-19 12:12:00 +03:00
90 changed files with 4667 additions and 4314 deletions

View File

@@ -1,6 +1,7 @@
//import 'package:eatvio_app/presentation/auth/auth_screen/auth_screen.dart';
import 'dart:async';
import 'package:eatvio_app/app_router.dart';
import 'package:equatable/equatable.dart';
import 'package:flutter/material.dart';
import '/core/app_export.dart';
@@ -10,6 +11,7 @@ import 'dart:convert';
import 'package:hive/hive.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:image_picker/image_picker.dart';
import 'package:go_router/go_router.dart';
part 'my_profile_event.dart';
part 'my_profile_state.dart';
@@ -29,9 +31,7 @@ class MyProfileBloc extends Bloc<MyProfileEvent, MyProfileState> {
final box = await Hive.openBox('token');
final token = box.get('token');
if (token == null) {
NavigatorService.popAndPushNamed(
AppRoutes.authScreen,
); // Если токен есть, запускаем приложение
AppRouter.navigatorKey.currentContext?.goNamed('authScreen');
}
//final token =
// "9|laravel_sanctum_KFXbccDcWEvTPfJmV99EQv1ne AggmpR2TidVGDPN34fa201a";

View File

@@ -1,8 +1,9 @@
import 'package:go_router/go_router.dart';
import 'bloc/my_profile_bloc.dart';
import 'models/my_profile_model.dart';
import 'package:eatvio_app/core/app_export.dart';
import 'package:eatvio_app/widgets/app_bar/appbar_subtitle.dart';
import 'package:eatvio_app/widgets/custom_bottom_bar.dart';
import 'package:eatvio_app/widgets/custom_text_form_field.dart';
import 'package:carousel_slider/carousel_slider.dart';
import 'package:image_picker/image_picker.dart';
@@ -19,10 +20,13 @@ import 'dart:convert';
class MyProfileScreen extends StatelessWidget {
static Widget builder(BuildContext context) {
return BlocProvider<MyProfileBloc>(
create: (context) =>
MyProfileBloc(MyProfileState(myProfileModelObj: MyProfileModel()))
..add(MyProfileInitialEvent()),
child: MyProfileScreen());
create: (context) => MyProfileBloc(
MyProfileState(
myProfileModelObj: MyProfileModel(),
),
)..add(MyProfileInitialEvent()),
child: MyProfileScreen(),
);
}
Widget build(BuildContext context) {
@@ -30,9 +34,10 @@ class MyProfileScreen extends StatelessWidget {
builder: (context, state) {
if (state is MyProfileInitialState) {
// Это начальное состояние, данные ещё не загружены.
return CircularProgressIndicator(
color: Colors.white,
backgroundColor: Colors.white,
return Scaffold(
body: Center(
child: CircularProgressIndicator(),
),
);
} else if (state is MyProfileLoadedState) {
// Данные загружены, можно строить экран.
@@ -42,7 +47,11 @@ class MyProfileScreen extends StatelessWidget {
return Center(child: Text(state.errorMessage));
} else {
// Другие состояния, если они есть.
return Container(); // Пустой контейнер для необработанных состояний.
return Scaffold(
body: Center(
child: CircularProgressIndicator(),
),
);
}
},
);
@@ -51,89 +60,91 @@ class MyProfileScreen extends StatelessWidget {
_buildMyProfileScreen(BuildContext context, MyProfileLoadedState state) {
mediaQueryData = MediaQuery.of(context);
return Scaffold(
backgroundColor: Colors.grey[200],
resizeToAvoidBottomInset: true,
body: SafeArea(
child: SingleChildScrollView(
child: Container(
width: double.maxFinite,
decoration: BoxDecoration(color: Colors.grey[200]),
child: Padding(
padding: EdgeInsets.all(16),
child: Column(children: [
Container(
padding: EdgeInsets.symmetric(
horizontal: 24.h,
vertical: 12.v,
),
decoration: BoxDecoration(
color: Colors.white,
borderRadius:
const BorderRadius.all(Radius.circular(12)),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: Offset(0, 3),
),
],
),
child: _buildInfo(context, state)),
SizedBox(height: 15.v),
Container(
padding: EdgeInsets.symmetric(
horizontal: 24.h,
vertical: 12.v,
),
decoration: BoxDecoration(
color: Colors.white,
borderRadius:
const BorderRadius.all(Radius.circular(12)),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: Offset(0, 3),
),
],
),
child: _buildCarousel(context, state)),
SizedBox(height: 15.v),
if (!state.plans!.isEmpty)
Container(
padding: EdgeInsets.symmetric(
horizontal: 24.h,
vertical: 12.v,
),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.all(
Radius.circular(12)),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: Offset(0, 3),
),
],
),
child: _buildPlans(
context,
state.plans
?.map((plan) => plan['name'])
.toList(),
state.plans
?.map((plan) => plan['image'])
.toList(),
state.plans
?.map((plan) => plan['state'])
.toList(),
)),
SizedBox(height: 5.v),
]))))), bottomNavigationBar: _buildBottomBar(context));
appBar: AppBar(
toolbarHeight: 0,
automaticallyImplyLeading: false,
),
backgroundColor: Colors.grey[200],
resizeToAvoidBottomInset: true,
body: SingleChildScrollView(
child: Container(
width: double.maxFinite,
decoration: BoxDecoration(color: Colors.grey[200]),
child: Padding(
padding: EdgeInsets.all(16),
child: Column(
children: [
SizedBox(height: 30.v),
Container(
padding: EdgeInsets.symmetric(
horizontal: 24.h,
vertical: 12.v,
),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.all(Radius.circular(12)),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: Offset(0, 3),
),
],
),
child: _buildInfo(context, state),
),
SizedBox(height: 15.v),
Container(
padding: EdgeInsets.symmetric(
horizontal: 24.h,
vertical: 12.v,
),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.all(Radius.circular(12)),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: Offset(0, 3),
),
],
),
child: _buildCarousel(context, state)),
SizedBox(height: 15.v),
if (!state.plans!.isEmpty)
Container(
padding: EdgeInsets.symmetric(
horizontal: 24.h,
vertical: 12.v,
),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.all(Radius.circular(12)),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: Offset(0, 3),
),
],
),
child: _buildPlans(
context,
state.plans?.map((plan) => plan['name']).toList(),
state.plans?.map((plan) => plan['image']).toList(),
state.plans?.map((plan) => plan['state']).toList(),
)),
SizedBox(height: 5.v),
],
),
),
),
),
);
}
/// Section Widget
@@ -143,8 +154,7 @@ class MyProfileScreen extends StatelessWidget {
GestureDetector(
onTap: () => addImage(context),
child: CachedNetworkImage(
imageUrl: dotenv.env['STORAGE_URL']! +
(state.user?['profile_photo_path'] ?? ''),
imageUrl: dotenv.env['STORAGE_URL']! + (state.user?['profile_photo_path'] ?? ''),
imageBuilder: (context, imageProvider) => CircleAvatar(
backgroundImage: imageProvider,
radius: 60,
@@ -176,14 +186,10 @@ class MyProfileScreen extends StatelessWidget {
onTapSettings(BuildContext context) {
return () {
Navigator.pushNamed(context, AppRoutes.mySettings);
GoRouter.of(context).goNamed('mySettingsScreen');
};
}
_buildBottomBar(BuildContext context) {
return CustomBottomBar(onChanged: (BottomBarEnum type) {});
}
_buildCarousel(BuildContext contex, MyProfileLoadedState state) {
return CarouselSlider(
options: CarouselOptions(height: 320.0),
@@ -204,12 +210,7 @@ class MyProfileScreen extends StatelessWidget {
SizedBox(height: 50.v),
_buildChart(
context,
state.chartPoints?.values
.map<int>((e) => e['weight'])
.toList()
.map((i) => i.toDouble())
.toList() ??
[0.0, 0.0, 0.0, 0.0],
state.chartPoints?.values.map<int>((e) => e['weight']).toList().map((i) => i.toDouble()).toList() ?? [0.0, 0.0, 0.0, 0.0],
state.chartDates,
)
]));
@@ -224,13 +225,7 @@ class MyProfileScreen extends StatelessWidget {
SizedBox(height: 50.v),
_buildChart(
context,
_bodyMassIndex(
state.chartPoints?.values
.map<int>((e) => e['weight'])
.toList()
.map((i) => i.toDouble())
.toList() ??
[0.0, 0.0, 0.0, 0.0],
_bodyMassIndex(state.chartPoints?.values.map<int>((e) => e['weight']).toList().map((i) => i.toDouble()).toList() ?? [0.0, 0.0, 0.0, 0.0],
state.userDetails?['height'].toInt() ?? 160),
state.chartDates),
]);
@@ -245,8 +240,7 @@ class MyProfileScreen extends StatelessWidget {
),
),
SizedBox(height: 30.v),
_buildCircumferenceChart(
context, state.circumferences, state.chartDates),
_buildCircumferenceChart(context, state.circumferences, state.chartDates),
_buildChartLegend()
]));
default:
@@ -290,8 +284,7 @@ class MyProfileScreen extends StatelessWidget {
);
}
_buildChart(
BuildContext context, List<double> chartPoints, List<String>? dates) {
_buildChart(BuildContext context, List<double> chartPoints, List<String>? dates) {
List<FlSpot> spots = [];
for (int i = 0; i < 4; i++) {
spots.add(
@@ -299,8 +292,7 @@ class MyProfileScreen extends StatelessWidget {
);
}
Widget bottomTitleWidgets(
double value, TitleMeta meta, double chartWidth, List<String>? dates) {
Widget bottomTitleWidgets(double value, TitleMeta meta, double chartWidth, List<String>? dates) {
if (value % 1 != 0) {
return Container();
}
@@ -312,8 +304,7 @@ class MyProfileScreen extends StatelessWidget {
int index = value.toInt();
if (index >= 0 && index < dates!.length) {
// Проверка на допустимый индекс в массиве dates
String formattedDate =
DateFormat('dd.MM').format(DateTime.parse(dates[index]));
String formattedDate = DateFormat('dd.MM').format(DateTime.parse(dates[index]));
return SideTitleWidget(
axisSide: meta.axisSide,
space: 16,
@@ -370,18 +361,15 @@ class MyProfileScreen extends StatelessWidget {
dotData: const FlDotData(show: false),
),
],
minY: chartPoints.reduce(
(value, element) => value < element ? value : element),
maxY: chartPoints.reduce(
(value, element) => value > element ? value : element),
minY: chartPoints.reduce((value, element) => value < element ? value : element),
maxY: chartPoints.reduce((value, element) => value > element ? value : element),
minX: 1,
maxX: 4,
titlesData: FlTitlesData(
leftTitles: AxisTitles(
sideTitles: SideTitles(
showTitles: true,
getTitlesWidget: (value, meta) =>
leftTitleWidgets(value, meta, constraints.maxWidth),
getTitlesWidget: (value, meta) => leftTitleWidgets(value, meta, constraints.maxWidth),
reservedSize: 56,
),
drawBelowEverything: true,
@@ -392,8 +380,7 @@ class MyProfileScreen extends StatelessWidget {
bottomTitles: AxisTitles(
sideTitles: SideTitles(
showTitles: true,
getTitlesWidget: (value, meta) => bottomTitleWidgets(
value, meta, constraints.maxWidth, dates),
getTitlesWidget: (value, meta) => bottomTitleWidgets(value, meta, constraints.maxWidth, dates),
reservedSize: 36,
interval: 1,
),
@@ -453,11 +440,9 @@ class MyProfileScreen extends StatelessWidget {
};
}
_buildCircumferenceChart(
BuildContext context, chartPoints, List<String>? dates) {
_buildCircumferenceChart(BuildContext context, chartPoints, List<String>? dates) {
// Определение осей графика
final chestCircumferences =
chartPoints.values.map((e) => e['chest_circumference']).toList();
final chestCircumferences = chartPoints.values.map((e) => e['chest_circumference']).toList();
List<FlSpot> spotsChest = [];
for (int i = 0; i < 4; i++) {
chestCircumferences[i] = chestCircumferences[i] * 10 / 10;
@@ -465,8 +450,7 @@ class MyProfileScreen extends StatelessWidget {
FlSpot((i * 10 / 10) + 1, chestCircumferences[i] * 10 / 10),
);
}
final waistCircumferences =
chartPoints.values.map((e) => e['waist_circumference']).toList();
final waistCircumferences = chartPoints.values.map((e) => e['waist_circumference']).toList();
List<FlSpot> spotsWaist = [];
for (int i = 0; i < 4; i++) {
waistCircumferences[i] = waistCircumferences[i] * 10 / 10;
@@ -474,8 +458,7 @@ class MyProfileScreen extends StatelessWidget {
FlSpot((i * 10 / 10) + 1, waistCircumferences[i] * 10 / 10),
);
}
final hipCircumferences =
chartPoints.values.map((e) => e['hip_circumference']).toList();
final hipCircumferences = chartPoints.values.map((e) => e['hip_circumference']).toList();
List<FlSpot> spotsHip = [];
for (int i = 0; i < 4; i++) {
hipCircumferences[i] = hipCircumferences[i] * 10 / 10;
@@ -484,14 +467,9 @@ class MyProfileScreen extends StatelessWidget {
);
}
final allCircumferences = [
...chestCircumferences,
...hipCircumferences,
...waistCircumferences
];
final allCircumferences = [...chestCircumferences, ...hipCircumferences, ...waistCircumferences];
Widget bottomTitleWidgets(
double value, TitleMeta meta, double chartWidth, List<String>? dates) {
Widget bottomTitleWidgets(double value, TitleMeta meta, double chartWidth, List<String>? dates) {
if (value % 1 != 0) {
return Container();
}
@@ -503,8 +481,7 @@ class MyProfileScreen extends StatelessWidget {
int index = value.toInt();
if (index >= 0 && index < dates!.length) {
// Проверка на допустимый индекс в массиве dates
String formattedDate =
DateFormat('dd.MM').format(DateTime.parse(dates[index]));
String formattedDate = DateFormat('dd.MM').format(DateTime.parse(dates[index]));
return SideTitleWidget(
axisSide: meta.axisSide,
space: 16,
@@ -583,18 +560,15 @@ class MyProfileScreen extends StatelessWidget {
dotData: const FlDotData(show: false),
),
],
minY: allCircumferences.reduce(
(value, element) => value < element ? value : element),
maxY: allCircumferences.reduce(
(value, element) => value > element ? value : element),
minY: allCircumferences.reduce((value, element) => value < element ? value : element),
maxY: allCircumferences.reduce((value, element) => value > element ? value : element),
minX: 1,
maxX: 4,
titlesData: FlTitlesData(
leftTitles: AxisTitles(
sideTitles: SideTitles(
showTitles: true,
getTitlesWidget: (value, meta) =>
leftTitleWidgets(value, meta, constraints.maxWidth),
getTitlesWidget: (value, meta) => leftTitleWidgets(value, meta, constraints.maxWidth),
reservedSize: 56,
),
drawBelowEverything: true,
@@ -605,8 +579,7 @@ class MyProfileScreen extends StatelessWidget {
bottomTitles: AxisTitles(
sideTitles: SideTitles(
showTitles: true,
getTitlesWidget: (value, meta) => bottomTitleWidgets(
value, meta, constraints.maxWidth, dates),
getTitlesWidget: (value, meta) => bottomTitleWidgets(value, meta, constraints.maxWidth, dates),
reservedSize: 36,
interval: 1,
),
@@ -661,125 +634,80 @@ class MyProfileScreen extends StatelessWidget {
}
/// Section Widget
_buildPlans(BuildContext context, List<dynamic>? plans,
List<dynamic>? imagePaths, List<dynamic>? states) {
_buildPlans(BuildContext context, List<dynamic>? plans, List<dynamic>? imagePaths, List<dynamic>? states) {
return Padding(
padding: EdgeInsets.only(left: 7.h),
child: Column(children: [
Padding(
padding: EdgeInsets.only(left: 15.h),
child: Text("plans_complete".tr,
style: CustomTextStyles.titleMediumBlack
.copyWith(color: appTheme.black900))),
child: Text("plans_complete".tr, style: CustomTextStyles.titleMediumBlack.copyWith(color: appTheme.black900))),
SizedBox(height: 5.v),
Container(
decoration: AppDecoration.outlineBlueGray
.copyWith(borderRadius: BorderRadiusStyle.roundedBorder5),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: 105.v,
width: 343.h,
child:
Stack(alignment: Alignment.bottomCenter, children: [
Align(
alignment: Alignment.topCenter,
child: ListView.builder(
itemCount: plans?.length ?? 0,
itemBuilder: (context, i) {
String state = states?[i];
var boxColor = appTheme.greenA700;
switch (states?[i]) {
case 'active':
boxColor = appTheme.greenA700;
break;
case 'archived': // График ИМТ
boxColor = appTheme.gray400;
break;
case 'draft':
boxColor = appTheme.deepOrange900;
break;
case 'in_progress': //График обхватов
boxColor = appTheme.lightGreen300;
break;
}
return SizedBox(
height: 40.v,
width: 343.h,
child: Stack(
alignment: Alignment.bottomRight,
children: [
Align(
alignment:
Alignment.topCenter,
child: Container(
margin: EdgeInsets.only(
bottom: 11.v),
padding:
EdgeInsets.symmetric(
horizontal: 6.h,
vertical: 4.v),
decoration: AppDecoration
.fillGray
.copyWith(
borderRadius:
BorderRadiusStyle
.roundedBorder5),
child: Row(
mainAxisAlignment:
MainAxisAlignment
.spaceBetween,
children: [
Padding(
padding: EdgeInsets
.only(
bottom: 1
.v),
child: Text(
plans![i],
style: CustomTextStyles
.titleSmallBluegray800Bold)),
Container(
height: 19.v,
width: 100.h,
decoration: BoxDecoration(
color:
boxColor,
borderRadius:
BorderRadius.circular(
5.h)))
]))),
Align(
alignment: Alignment.center,
child: Container(
margin: EdgeInsets.only(
bottom: 12.h),
child: Image.network(
dotenv.env[
'STORAGE_URL']! +
imagePaths?[i],
height: 25.adaptSize,
width: 25.adaptSize,
))),
Align(
alignment:
Alignment.bottomRight,
child: Container(
width: 70.h,
margin: EdgeInsets.only(
bottom: 14.h,
right: 22.h),
child: Text("$state".tr,
maxLines: 3,
overflow: TextOverflow
.ellipsis,
style: theme.textTheme
.titleSmall)))
]));
})),
]))
]))
decoration: AppDecoration.outlineBlueGray.copyWith(borderRadius: BorderRadiusStyle.roundedBorder5),
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
SizedBox(
height: 105.v,
width: 343.h,
child: Stack(alignment: Alignment.bottomCenter, children: [
Align(
alignment: Alignment.topCenter,
child: ListView.builder(
itemCount: plans?.length ?? 0,
itemBuilder: (context, i) {
String state = states?[i];
var boxColor = appTheme.greenA700;
switch (states?[i]) {
case 'active':
boxColor = appTheme.greenA700;
break;
case 'archived': // График ИМТ
boxColor = appTheme.gray400;
break;
case 'draft':
boxColor = appTheme.deepOrange900;
break;
case 'in_progress': //График обхватов
boxColor = appTheme.lightGreen300;
break;
}
return SizedBox(
height: 40.v,
width: 343.h,
child: Stack(alignment: Alignment.bottomRight, children: [
Align(
alignment: Alignment.topCenter,
child: Container(
margin: EdgeInsets.only(bottom: 11.v),
padding: EdgeInsets.symmetric(horizontal: 6.h, vertical: 4.v),
decoration: AppDecoration.fillGray.copyWith(borderRadius: BorderRadiusStyle.roundedBorder5),
child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
Padding(
padding: EdgeInsets.only(bottom: 1.v),
child: Text(plans![i], style: CustomTextStyles.titleSmallBluegray800Bold)),
Container(
height: 19.v,
width: 100.h,
decoration: BoxDecoration(color: boxColor, borderRadius: BorderRadius.circular(5.h)))
]))),
Align(
alignment: Alignment.center,
child: Container(
margin: EdgeInsets.only(bottom: 12.h),
child: Image.network(
dotenv.env['STORAGE_URL']! + imagePaths?[i],
height: 25.adaptSize,
width: 25.adaptSize,
))),
Align(
alignment: Alignment.bottomRight,
child: Container(
width: 70.h,
margin: EdgeInsets.only(bottom: 14.h, right: 22.h),
child: Text("$state".tr, maxLines: 3, overflow: TextOverflow.ellipsis, style: theme.textTheme.titleSmall)))
]));
})),
]))
]))
]));
}
@@ -807,44 +735,38 @@ class MyProfileScreen extends StatelessWidget {
children: [
Padding(
padding: EdgeInsets.symmetric(vertical: 5.v),
child: Text("chest_circumference".tr,
style: theme.textTheme.bodyLarge),
child: Text("chest_circumference".tr, style: theme.textTheme.bodyLarge),
),
SizedBox(height: 5.v),
CustomTextFormField(
controller: state.chestCircumferenceController,
keyboardType: TextInputType.number,
inputFormatters: <TextInputFormatter>[
FilteringTextInputFormatter
.digitsOnly, // Ограничение ввода только цифрами
FilteringTextInputFormatter.digitsOnly, // Ограничение ввода только цифрами
],
),
Padding(
padding: EdgeInsets.symmetric(vertical: 15.v),
child: Text("waist_circumference".tr,
style: theme.textTheme.bodyLarge),
child: Text("waist_circumference".tr, style: theme.textTheme.bodyLarge),
),
SizedBox(height: 5.v),
CustomTextFormField(
controller: state.waistCircumferenceController,
keyboardType: TextInputType.number,
inputFormatters: <TextInputFormatter>[
FilteringTextInputFormatter
.digitsOnly, // Ограничение ввода только цифрами
FilteringTextInputFormatter.digitsOnly, // Ограничение ввода только цифрами
],
),
Padding(
padding: EdgeInsets.symmetric(vertical: 15.v),
child: Text("hip_circumference".tr,
style: theme.textTheme.bodyLarge),
child: Text("hip_circumference".tr, style: theme.textTheme.bodyLarge),
),
SizedBox(height: 5.v),
CustomTextFormField(
controller: state.hipCircumferenceController,
keyboardType: TextInputType.number,
inputFormatters: <TextInputFormatter>[
FilteringTextInputFormatter
.digitsOnly, // Ограничение ввода только цифрами
FilteringTextInputFormatter.digitsOnly, // Ограничение ввода только цифрами
],
),
],
@@ -863,8 +785,7 @@ class MyProfileScreen extends StatelessWidget {
),
],
backgroundColor: Colors.white,
titlePadding: EdgeInsets.all(
20.0), // Можете настроить отступы по вашему желанию
titlePadding: EdgeInsets.all(20.0), // Можете настроить отступы по вашему желанию
);
},
);
@@ -894,14 +815,10 @@ class MyProfileScreen extends StatelessWidget {
);
if (response.statusCode == 201) {
Navigator.pushNamed(
context,
AppRoutes.myProfile,
);
GoRouter.of(context).go('/my-profile-screen');
} else {
// Ошибка от сервера
print(
"Ошибка при отправке данных. Код ответа: ${response.statusCode}");
print("Ошибка при отправке данных. Код ответа: ${response.statusCode}");
}
} catch (e) {
// Обработка ошибок при отправке запроса
@@ -987,14 +904,10 @@ class MyProfileScreen extends StatelessWidget {
);
if (response.statusCode == 201) {
Navigator.pushNamed(
context,
AppRoutes.myProfile,
);
GoRouter.of(context).go('/my-profile-screen');
} else {
// Ошибка от сервера
print(
"Ошибка при отправке данных. Код ответа: ${response.statusCode}");
print("Ошибка при отправке данных. Код ответа: ${response.statusCode}");
}
} catch (e) {
// Обработка ошибок при отправке запроса

View File

@@ -1,10 +1,11 @@
import 'package:go_router/go_router.dart';
import 'bloc/my_profile_bloc.dart';
import 'models/my_profile_model.dart';
import 'package:eatvio_app/core/app_export.dart';
import 'package:eatvio_app/widgets/app_bar/appbar_subtitle.dart';
import 'package:eatvio_app/widgets/app_bar/appbar_leading_image.dart';
import 'package:eatvio_app/widgets/app_bar/custom_app_bar.dart';
import 'package:eatvio_app/widgets/custom_bottom_bar.dart';
import 'package:eatvio_app/widgets/custom_about_list.dart';
import 'package:eatvio_app/widgets/custom_expandable_list.dart';
import 'package:eatvio_app/widgets/custom_notification_screen.dart';
@@ -15,10 +16,7 @@ import 'package:flutter/material.dart';
class MySettingsScreen extends StatelessWidget {
static Widget builder(BuildContext context) {
return BlocProvider<MyProfileBloc>(
create: (context) =>
MyProfileBloc(MyProfileState(myProfileModelObj: MyProfileModel()))
..add(MyProfileInitialEvent()),
child: MySettingsScreen());
create: (context) => MyProfileBloc(MyProfileState(myProfileModelObj: MyProfileModel()))..add(MyProfileInitialEvent()), child: MySettingsScreen());
}
Widget build(BuildContext context) {
@@ -26,151 +24,151 @@ class MySettingsScreen extends StatelessWidget {
builder: (context, state) {
if (state is MyProfileInitialState) {
// Это начальное состояние, данные ещё не загружены.
return CircularProgressIndicator(
color: Colors.white,
backgroundColor: Colors.white,
return Scaffold(
body: Center(
child: CircularProgressIndicator(),
),
);
} else if (state is MyProfileLoadedState) {
// Данные загружены, можно строить экран.
return _buildSetingsScreen(context, state);
} else {
// Другие состояния, если они есть.
return Container(); // Пустой контейнер для необработанных состояний.
return Scaffold(
body: Center(
child: CircularProgressIndicator(),
),
);
}
},
);
}
_buildSetingsScreen(BuildContext context, MyProfileLoadedState state) {
mediaQueryData = MediaQuery.of(context);
return Scaffold(
backgroundColor: Colors.grey[200],
resizeToAvoidBottomInset: true,
body: SafeArea(
child: SingleChildScrollView(
child: Container(
width: double.maxFinite,
decoration: BoxDecoration(color: Colors.grey[200]),
child: Padding(
padding: EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
SizedBox(height: 30),
Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius:
const BorderRadius.all(Radius.circular(12)),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: Offset(0, 3),
),
],
return Scaffold(
appBar: AppBar(
toolbarHeight: 0,
automaticallyImplyLeading: false,
),
backgroundColor: Colors.grey[200],
resizeToAvoidBottomInset: true,
body: SingleChildScrollView(
child: Container(
width: double.maxFinite,
decoration: BoxDecoration(color: Colors.grey[200]),
child: Padding(
padding: EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
SizedBox(height: 30),
Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.all(Radius.circular(12)),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: Offset(0, 3),
),
],
),
child: CustomAppBar(
height: 54.v,
leadingWidth: 28.h,
leading: AppbarLeadingImage(
imagePath: ImageConstant.imgArrowLeft,
margin: EdgeInsets.only(left: 16.h, top: 15.v, bottom: 15.v),
onTap: () => GoRouter.of(context).pop(),
),
child: CustomAppBar(
height: 54.v,
leadingWidth: 28.h,
leading: AppbarLeadingImage(
imagePath: ImageConstant.imgArrowLeft,
margin: EdgeInsets.only(
left: 16.h, top: 15.v, bottom: 15.v),
onTap: onTapBack(context)),
title: Padding(
padding: EdgeInsets.only(left: 20.h),
child: Row(children: [
AppbarSubtitle(
text: state.user?['name'],
margin: EdgeInsets.only(
left: 80.h, top: 12.v, bottom: 9.v))
])),
)),
SizedBox(height: 20),
Container(
padding: EdgeInsets.symmetric(
horizontal: 24.h,
vertical: 12.v,
),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.all(Radius.circular(12)),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: Offset(0, 3),
),
],
),
child: Column(
children: [
SectionTitle('Язык'),
LanguageDropdown(),
],
),
title: Padding(
padding: EdgeInsets.only(left: 20.h),
child: Row(children: [AppbarSubtitle(text: state.user?['name'], margin: EdgeInsets.only(left: 80.h, top: 12.v, bottom: 9.v))])),
)),
SizedBox(height: 20),
Container(
padding: EdgeInsets.symmetric(
horizontal: 24.h,
vertical: 12.v,
),
SizedBox(height: 20),
Container(
padding: EdgeInsets.symmetric(
horizontal: 24.h,
vertical: 12.v,
),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.all(Radius.circular(12)),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: Offset(0, 3),
),
],
),
child: Column(
children: [
SectionTitle('Уведомления'),
NotificationSwitch('Уведомление об обновлениях'),
NotificationSwitch('Напоминания о заполнении'),
],
),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.all(Radius.circular(12)),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: Offset(0, 3),
),
],
),
SizedBox(height: 20),
Container(
padding: EdgeInsets.symmetric(
horizontal: 24.h,
vertical: 12.v,
),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.all(Radius.circular(12)),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: Offset(0, 3),
),
],
),
child: Column(
children: [
SectionTitle('Дополнительная информация'),
ExpandableList('Персональные данные'),
AboutList('О нас', ['ООО Итвио', '2023-н.в.']),
],
),
child: Column(
children: [
SectionTitle('Язык'),
LanguageDropdown(),
],
),
],
),
),
SizedBox(height: 20),
Container(
padding: EdgeInsets.symmetric(
horizontal: 24.h,
vertical: 12.v,
),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.all(Radius.circular(12)),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: Offset(0, 3),
),
],
),
child: Column(
children: [
SectionTitle('Уведомления'),
NotificationSwitch('Уведомление об обновлениях'),
NotificationSwitch('Напоминания о заполнении'),
],
),
),
SizedBox(height: 20),
Container(
padding: EdgeInsets.symmetric(
horizontal: 24.h,
vertical: 12.v,
),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.all(Radius.circular(12)),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: Offset(0, 3),
),
],
),
child: Column(
children: [
SectionTitle('Дополнительная информация'),
ExpandableList('Персональные данные'),
AboutList('О нас', ['ООО Итвио', '2023-н.в.']),
],
),
),
],
),
),
),
),
),
bottomNavigationBar: _buildBottomBar(context),
);
@@ -182,11 +180,7 @@ class MySettingsScreen extends StatelessWidget {
};
}
_buildBottomBar(BuildContext context) {
return CustomBottomBar(onChanged: (BottomBarEnum type) {});
}
onTapArrowLeft(BuildContext context) {
NavigatorService.goBack();
GoRouter.of(context).pop();
}
}