forked from eatvio/eatvio_app
Layout fix
This commit is contained in:
@@ -29,17 +29,19 @@ class MyProfileScreen extends StatelessWidget {
|
|||||||
child: MyProfileScreen());
|
child: MyProfileScreen());
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocBuilder<MyProfileBloc, MyProfileState>(
|
return BlocBuilder<MyProfileBloc, MyProfileState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
if (state is MyProfileInitialState) {
|
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) {
|
} else if (state is MyProfileLoadedState) {
|
||||||
// Данные загружены, можно строить экран.
|
// Данные загружены, можно строить экран.
|
||||||
return _buildMyProfileScreen(context, state);
|
return _buildMyProfileScreen(context, state);
|
||||||
}
|
} else if (state is MyProfileErrorState) {
|
||||||
else if (state is MyProfileErrorState) {
|
|
||||||
// Произошла ошибка при загрузке данных.
|
// Произошла ошибка при загрузке данных.
|
||||||
return Center(child: Text(state.errorMessage));
|
return Center(child: Text(state.errorMessage));
|
||||||
} else {
|
} 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);
|
mediaQueryData = MediaQuery.of(context);
|
||||||
return SafeArea(
|
return SafeArea(
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
appBar: _buildAppBar(
|
appBar: _buildAppBar(
|
||||||
context,
|
context,
|
||||||
((state.user?['name'] ?? '') +
|
((state.user?['name'] ?? '') +
|
||||||
' ' +
|
' ' +
|
||||||
(state.userDetails?['last_name'] ?? '')) ??
|
(state.userDetails?['last_name'] ?? '')) ??
|
||||||
'loading'.tr),
|
'loading'.tr),
|
||||||
body: Container(
|
body: Container(
|
||||||
width: double.maxFinite,
|
width: double.maxFinite,
|
||||||
padding:
|
padding: EdgeInsets.symmetric(horizontal: 8.h, vertical: 18.v),
|
||||||
EdgeInsets.symmetric(horizontal: 8.h, vertical: 18.v),
|
child: Column(children: [
|
||||||
child: Column(children: [
|
_buildMyBlog(context),
|
||||||
_buildMyBlog(context),
|
SizedBox(height: 15.v),
|
||||||
SizedBox(height: 15.v),
|
_buildSettings(context),
|
||||||
_buildSettings(context),
|
SizedBox(height: 30.v),
|
||||||
SizedBox(height: 30.v),
|
_buildCarousel(context, state),
|
||||||
_buildCarousel(context, state),
|
SizedBox(height: 15.v),
|
||||||
SizedBox(height: 15.v),
|
_buildPlans(
|
||||||
_buildPlans(
|
context,
|
||||||
context,
|
state.plans?.map((plan) => plan['name']).toList(),
|
||||||
state.plans?.map((plan) => plan['name']).toList(),
|
state.plans?.map((plan) => plan['image']).toList(),
|
||||||
state.plans?.map((plan) => plan['image']).toList(),
|
state.plans?.map((plan) => plan['state']).toList(),
|
||||||
state.plans?.map((plan) => plan['state']).toList(),
|
),
|
||||||
),
|
SizedBox(height: 5.v),
|
||||||
SizedBox(height: 5.v),
|
])),
|
||||||
])),
|
bottomNavigationBar: _buildBottomBar(context)));
|
||||||
bottomNavigationBar: _buildBottomBar(context)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Section Widget
|
/// Section Widget
|
||||||
@@ -146,98 +148,92 @@ class MyProfileScreen extends StatelessWidget {
|
|||||||
Widget _buildBottomBar(BuildContext context) {
|
Widget _buildBottomBar(BuildContext context) {
|
||||||
return CustomBottomBar(onChanged: (BottomBarEnum type) {});
|
return CustomBottomBar(onChanged: (BottomBarEnum type) {});
|
||||||
}
|
}
|
||||||
Widget _buildCarousel(BuildContext contex, MyProfileLoadedState state){
|
|
||||||
|
Widget _buildCarousel(BuildContext contex, MyProfileLoadedState state) {
|
||||||
return CarouselSlider(
|
return CarouselSlider(
|
||||||
options: CarouselOptions(height: 375.0),
|
options: CarouselOptions(height: 375.0),
|
||||||
items: [1, 2, 3].map((chartType) {
|
items: [1, 2, 3].map((chartType) {
|
||||||
return Builder(
|
return Builder(
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
switch (chartType) {
|
switch (chartType) {
|
||||||
case 1: // График веса
|
case 1: // График веса
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
_editWeight(context, state);
|
_editWeight(context, state);
|
||||||
},
|
},
|
||||||
child: Column(children: [
|
child: Column(children: [
|
||||||
Text(
|
Text(
|
||||||
"weight_chart".tr,
|
"weight_chart".tr,
|
||||||
style: CustomTextStyles.titleMediumBlack
|
style: CustomTextStyles.titleMediumBlack.copyWith(
|
||||||
.copyWith(
|
color: appTheme.black900,
|
||||||
color: appTheme.black900,
|
),
|
||||||
),
|
),
|
||||||
),
|
SizedBox(height: 50.v),
|
||||||
SizedBox(height: 50.v),
|
_buildChart(
|
||||||
_buildChart(
|
context,
|
||||||
context,
|
state.chartPoints?.values
|
||||||
state.chartPoints?.values
|
.map<int>((e) => e['weight'])
|
||||||
.map<int>((e) => e['weight'])
|
.toList()
|
||||||
.toList()
|
.map((i) => i.toDouble())
|
||||||
.map((i) => i.toDouble())
|
.toList() ??
|
||||||
.toList() ??
|
[0.0, 0.0, 0.0, 0.0],
|
||||||
[0.0, 0.0, 0.0, 0.0],
|
state.chartPoints?.values
|
||||||
state.chartPoints?.values
|
.map<String>((e) => e['created_at'])
|
||||||
.map<String>(
|
.toList()),
|
||||||
(e) => e['created_at'])
|
]));
|
||||||
.toList()),
|
case 2: // График ИМТ
|
||||||
]));
|
return Column(children: [
|
||||||
case 2: // График ИМТ
|
Text(
|
||||||
return Column(children: [
|
"bodymass_chart".tr,
|
||||||
Text(
|
style: CustomTextStyles.titleMediumBlack.copyWith(
|
||||||
"bodymass_chart".tr,
|
color: appTheme.black900,
|
||||||
style: CustomTextStyles.titleMediumBlack
|
),
|
||||||
.copyWith(
|
),
|
||||||
color: appTheme.black900,
|
SizedBox(height: 50.v),
|
||||||
),
|
_buildChart(
|
||||||
),
|
context,
|
||||||
SizedBox(height: 50.v),
|
_bodyMassIndex(
|
||||||
_buildChart(
|
state.chartPoints?.values
|
||||||
context,
|
.map<int>((e) => e['weight'])
|
||||||
_bodyMassIndex(
|
.toList()
|
||||||
state.chartPoints?.values
|
.map((i) => i.toDouble())
|
||||||
.map<int>((e) => e['weight'])
|
.toList() ??
|
||||||
.toList()
|
[10.0, 20.0, 30.0, 40.0],
|
||||||
.map((i) => i.toDouble())
|
state.userDetails?['height'].toInt() ?? 160),
|
||||||
.toList() ??
|
state.chartPoints?.values
|
||||||
[10.0, 20.0, 30.0, 40.0],
|
.map<String>((e) => e['created_at'])
|
||||||
state.userDetails?['height']
|
.toList()),
|
||||||
.toInt() ??
|
]);
|
||||||
160),
|
case 3: //График обхватов
|
||||||
state.chartPoints?.values
|
return GestureDetector(
|
||||||
.map<String>((e) => e['created_at'])
|
onTap: () {
|
||||||
.toList()),
|
_editCircumference(context, state);
|
||||||
]);
|
},
|
||||||
case 3: //График обхватов
|
child: Column(children: [
|
||||||
return GestureDetector(
|
Text(
|
||||||
onTap: () {
|
"circumferences_chart".tr,
|
||||||
_editCircumference(context, state);
|
style: CustomTextStyles.titleMediumBlack.copyWith(
|
||||||
},
|
color: appTheme.black900,
|
||||||
child: Column(children: [
|
),
|
||||||
Text(
|
),
|
||||||
"circumferences_chart".tr,
|
SizedBox(height: 30.v),
|
||||||
style: CustomTextStyles.titleMediumBlack
|
_buildCircumferenceChart(
|
||||||
.copyWith(
|
context,
|
||||||
color: appTheme.black900,
|
state.circumferences,
|
||||||
),
|
state.chartPoints?.values
|
||||||
),
|
.map<String>((e) => e['created_at'])
|
||||||
SizedBox(height: 30.v),
|
.toList()),
|
||||||
_buildCircumferenceChart(
|
_buildChartLegend()
|
||||||
context,
|
]));
|
||||||
state.circumferences,
|
default:
|
||||||
state.chartPoints?.values
|
return Text('text', style: TextStyle(fontSize: 16.0));
|
||||||
.map<String>(
|
}
|
||||||
(e) => e['created_at'])
|
},
|
||||||
.toList()),
|
);
|
||||||
_buildChartLegend()
|
}).toList(),
|
||||||
]));
|
);
|
||||||
default:
|
|
||||||
return Text('text',
|
|
||||||
style: TextStyle(fontSize: 16.0));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}).toList(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildChartLegend() {
|
Widget _buildChartLegend() {
|
||||||
final colors = [Colors.pink, Colors.green, Colors.purple];
|
final colors = [Colors.pink, Colors.green, Colors.purple];
|
||||||
final titles = ["chest".tr, "waist".tr, "hips".tr];
|
final titles = ["chest".tr, "waist".tr, "hips".tr];
|
||||||
@@ -643,114 +639,121 @@ class MyProfileScreen extends StatelessWidget {
|
|||||||
List<dynamic>? imagePaths, List<dynamic>? states) {
|
List<dynamic>? imagePaths, List<dynamic>? states) {
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: EdgeInsets.only(left: 7.h),
|
padding: EdgeInsets.only(left: 7.h),
|
||||||
child:
|
child: Column(children: [
|
||||||
Column(children:
|
|
||||||
[
|
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.only(left: 15.h),
|
padding: EdgeInsets.only(left: 15.h),
|
||||||
child: Text("plans_complete".tr,
|
child: Text("plans_complete".tr,
|
||||||
style: CustomTextStyles.titleSmallBluegray800)),
|
style: CustomTextStyles.titleSmallBluegray800)),
|
||||||
Container(
|
Container(
|
||||||
decoration: AppDecoration.outlineBlueGray
|
decoration: AppDecoration.outlineBlueGray
|
||||||
.copyWith(borderRadius: BorderRadiusStyle.roundedBorder5),
|
.copyWith(borderRadius: BorderRadiusStyle.roundedBorder5),
|
||||||
child:
|
child: Column(
|
||||||
Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 95.v,
|
height: 94.v,
|
||||||
width: 343.h,
|
width: 343.h,
|
||||||
child: Stack(alignment: Alignment.bottomCenter, children: [
|
child:
|
||||||
Align(
|
Stack(alignment: Alignment.bottomCenter, children: [
|
||||||
alignment: Alignment.topCenter,
|
Align(
|
||||||
child: ListView.builder(
|
alignment: Alignment.topCenter,
|
||||||
shrinkWrap: true,
|
child: ListView.builder(
|
||||||
itemCount: plans?.length ?? 0,
|
shrinkWrap: true,
|
||||||
itemBuilder: (context, i) {
|
itemCount: plans?.length ?? 0,
|
||||||
String state = states?[i];
|
itemBuilder: (context, i) {
|
||||||
var boxColor = appTheme.greenA700;
|
String state = states?[i];
|
||||||
switch (states?[i]) {
|
var boxColor = appTheme.greenA700;
|
||||||
case 'active':
|
switch (states?[i]) {
|
||||||
boxColor = appTheme.greenA700;
|
case 'active':
|
||||||
break;
|
boxColor = appTheme.greenA700;
|
||||||
case 'archived': // График ИМТ
|
break;
|
||||||
boxColor = appTheme.gray400;
|
case 'archived': // График ИМТ
|
||||||
break;
|
boxColor = appTheme.gray400;
|
||||||
case 'draft':
|
break;
|
||||||
boxColor = appTheme.deepOrange900;
|
case 'draft':
|
||||||
break;
|
boxColor = appTheme.deepOrange900;
|
||||||
case 'in_progress': //График обхватов
|
break;
|
||||||
boxColor = appTheme.lightGreen300;
|
case 'in_progress': //График обхватов
|
||||||
break;
|
boxColor = appTheme.lightGreen300;
|
||||||
}
|
break;
|
||||||
return SizedBox(
|
}
|
||||||
height: 40.v,
|
return SizedBox(
|
||||||
width: 343.h,
|
height: 40.v,
|
||||||
child: Stack(
|
width: 343.h,
|
||||||
alignment: Alignment.bottomRight,
|
child: Stack(
|
||||||
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,
|
alignment: Alignment.bottomRight,
|
||||||
child: Container(
|
children: [
|
||||||
width: 70.h,
|
Align(
|
||||||
margin: EdgeInsets.only(
|
alignment:
|
||||||
bottom: 14.h, right: 22.h),
|
Alignment.topCenter,
|
||||||
child: Text("$state".tr,
|
child: Container(
|
||||||
maxLines: 3,
|
margin: EdgeInsets.only(
|
||||||
overflow:
|
bottom: 11.v),
|
||||||
TextOverflow.ellipsis,
|
padding:
|
||||||
style: theme
|
EdgeInsets.symmetric(
|
||||||
.textTheme.titleSmall)))
|
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) {
|
List<double> _bodyMassIndex(List<double> weightPoints, int height) {
|
||||||
|
|||||||
Reference in New Issue
Block a user