Layout fix

This commit is contained in:
2024-01-29 15:21:38 +03:00
parent e9b0ea19b2
commit 972d64b00e

View File

@@ -29,17 +29,19 @@ class MyProfileScreen extends StatelessWidget {
child: MyProfileScreen());
}
Widget build(BuildContext context) {
Widget build(BuildContext context) {
return BlocBuilder<MyProfileBloc, MyProfileState>(
builder: (context, state) {
if (state is MyProfileInitialState) {
// Это начальное состояние, данные ещё не загружены.
return CircularProgressIndicator(color: Colors.white, backgroundColor: Colors.white,);
return CircularProgressIndicator(
color: Colors.white,
backgroundColor: Colors.white,
);
} else if (state is MyProfileLoadedState) {
// Данные загружены, можно строить экран.
return _buildMyProfileScreen(context, state);
}
else if (state is MyProfileErrorState) {
} else if (state is MyProfileErrorState) {
// Произошла ошибка при загрузке данных.
return Center(child: Text(state.errorMessage));
} else {
@@ -50,36 +52,36 @@ class MyProfileScreen extends StatelessWidget {
);
}
Widget _buildMyProfileScreen(BuildContext context, MyProfileLoadedState state) {
Widget _buildMyProfileScreen(
BuildContext context, MyProfileLoadedState state) {
mediaQueryData = MediaQuery.of(context);
return SafeArea(
child: Scaffold(
appBar: _buildAppBar(
context,
((state.user?['name'] ?? '') +
' ' +
(state.userDetails?['last_name'] ?? '')) ??
'loading'.tr),
body: Container(
width: double.maxFinite,
padding:
EdgeInsets.symmetric(horizontal: 8.h, vertical: 18.v),
child: Column(children: [
_buildMyBlog(context),
SizedBox(height: 15.v),
_buildSettings(context),
SizedBox(height: 30.v),
_buildCarousel(context, state),
SizedBox(height: 15.v),
_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)));
return SafeArea(
child: Scaffold(
appBar: _buildAppBar(
context,
((state.user?['name'] ?? '') +
' ' +
(state.userDetails?['last_name'] ?? '')) ??
'loading'.tr),
body: Container(
width: double.maxFinite,
padding: EdgeInsets.symmetric(horizontal: 8.h, vertical: 18.v),
child: Column(children: [
_buildMyBlog(context),
SizedBox(height: 15.v),
_buildSettings(context),
SizedBox(height: 30.v),
_buildCarousel(context, state),
SizedBox(height: 15.v),
_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)));
}
/// Section Widget
@@ -146,98 +148,92 @@ class MyProfileScreen extends StatelessWidget {
Widget _buildBottomBar(BuildContext context) {
return CustomBottomBar(onChanged: (BottomBarEnum type) {});
}
Widget _buildCarousel(BuildContext contex, MyProfileLoadedState state){
Widget _buildCarousel(BuildContext contex, MyProfileLoadedState state) {
return CarouselSlider(
options: CarouselOptions(height: 375.0),
items: [1, 2, 3].map((chartType) {
return Builder(
builder: (BuildContext context) {
switch (chartType) {
case 1: // График веса
return GestureDetector(
onTap: () {
_editWeight(context, state);
},
child: Column(children: [
Text(
"weight_chart".tr,
style: CustomTextStyles.titleMediumBlack
.copyWith(
color: appTheme.black900,
),
),
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<String>(
(e) => e['created_at'])
.toList()),
]));
case 2: // График ИМТ
return Column(children: [
Text(
"bodymass_chart".tr,
style: CustomTextStyles.titleMediumBlack
.copyWith(
color: appTheme.black900,
),
),
SizedBox(height: 50.v),
_buildChart(
context,
_bodyMassIndex(
state.chartPoints?.values
.map<int>((e) => e['weight'])
.toList()
.map((i) => i.toDouble())
.toList() ??
[10.0, 20.0, 30.0, 40.0],
state.userDetails?['height']
.toInt() ??
160),
state.chartPoints?.values
.map<String>((e) => e['created_at'])
.toList()),
]);
case 3: //График обхватов
return GestureDetector(
onTap: () {
_editCircumference(context, state);
},
child: Column(children: [
Text(
"circumferences_chart".tr,
style: CustomTextStyles.titleMediumBlack
.copyWith(
color: appTheme.black900,
),
),
SizedBox(height: 30.v),
_buildCircumferenceChart(
context,
state.circumferences,
state.chartPoints?.values
.map<String>(
(e) => e['created_at'])
.toList()),
_buildChartLegend()
]));
default:
return Text('text',
style: TextStyle(fontSize: 16.0));
}
},
);
}).toList(),
);
options: CarouselOptions(height: 375.0),
items: [1, 2, 3].map((chartType) {
return Builder(
builder: (BuildContext context) {
switch (chartType) {
case 1: // График веса
return GestureDetector(
onTap: () {
_editWeight(context, state);
},
child: Column(children: [
Text(
"weight_chart".tr,
style: CustomTextStyles.titleMediumBlack.copyWith(
color: appTheme.black900,
),
),
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<String>((e) => e['created_at'])
.toList()),
]));
case 2: // График ИМТ
return Column(children: [
Text(
"bodymass_chart".tr,
style: CustomTextStyles.titleMediumBlack.copyWith(
color: appTheme.black900,
),
),
SizedBox(height: 50.v),
_buildChart(
context,
_bodyMassIndex(
state.chartPoints?.values
.map<int>((e) => e['weight'])
.toList()
.map((i) => i.toDouble())
.toList() ??
[10.0, 20.0, 30.0, 40.0],
state.userDetails?['height'].toInt() ?? 160),
state.chartPoints?.values
.map<String>((e) => e['created_at'])
.toList()),
]);
case 3: //График обхватов
return GestureDetector(
onTap: () {
_editCircumference(context, state);
},
child: Column(children: [
Text(
"circumferences_chart".tr,
style: CustomTextStyles.titleMediumBlack.copyWith(
color: appTheme.black900,
),
),
SizedBox(height: 30.v),
_buildCircumferenceChart(
context,
state.circumferences,
state.chartPoints?.values
.map<String>((e) => e['created_at'])
.toList()),
_buildChartLegend()
]));
default:
return Text('text', style: TextStyle(fontSize: 16.0));
}
},
);
}).toList(),
);
}
Widget _buildChartLegend() {
final colors = [Colors.pink, Colors.green, Colors.purple];
final titles = ["chest".tr, "waist".tr, "hips".tr];
@@ -643,114 +639,121 @@ class MyProfileScreen extends StatelessWidget {
List<dynamic>? imagePaths, List<dynamic>? states) {
return Padding(
padding: EdgeInsets.only(left: 7.h),
child:
Column(children:
[
child: Column(children: [
Padding(
padding: EdgeInsets.only(left: 15.h),
child: Text("plans_complete".tr,
style: CustomTextStyles.titleSmallBluegray800)),
style: CustomTextStyles.titleSmallBluegray800)),
Container(
decoration: AppDecoration.outlineBlueGray
.copyWith(borderRadius: BorderRadiusStyle.roundedBorder5),
child:
Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
SizedBox(
height: 95.v,
width: 343.h,
child: Stack(alignment: Alignment.bottomCenter, children: [
Align(
alignment: Alignment.topCenter,
child: ListView.builder(
shrinkWrap: true,
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(
decoration: AppDecoration.outlineBlueGray
.copyWith(borderRadius: BorderRadiusStyle.roundedBorder5),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: 94.v,
width: 343.h,
child:
Stack(alignment: Alignment.bottomCenter, children: [
Align(
alignment: Alignment.topCenter,
child: ListView.builder(
shrinkWrap: true,
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,
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)))
]));
})),
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)))
]));
})),
]))
]))
]))]));
]));
}
List<double> _bodyMassIndex(List<double> weightPoints, int height) {