Plans build function

This commit is contained in:
2024-01-17 14:58:34 +03:00
parent 083df35081
commit 4050e61258
3 changed files with 87 additions and 155 deletions

View File

@@ -54,8 +54,9 @@ class MyProfileBloc extends Bloc<MyProfileEvent, MyProfileState> {
final data = jsonDecode(response.body);
emit(state.copyWith(
user: data['user'],
chartPoints: data['chartPoints'],
userDetails: data['userDetails'],
chartPoints: data['chartPoints'],
plans: data['plans'],
circumferences: data['circumferences'],
));
}

View File

@@ -9,26 +9,30 @@ class MyProfileState extends Equatable {
this.user,
this.userDetails,
this.chartPoints,
this.plans,
this.circumferences});
MyProfileModel? myProfileModelObj;
Map<String, dynamic>? user;
Map<String, dynamic>? userDetails;
Map<String, dynamic>? chartPoints;
List<dynamic>? plans;
Map<String, dynamic>? circumferences;
@override
List<Object?> get props =>
[myProfileModelObj, user, chartPoints, circumferences];
[myProfileModelObj, user, chartPoints, circumferences, plans];
MyProfileState copyWith(
{MyProfileModel? myProfileModelObj,
Map<String, dynamic>? user,
Map<String, dynamic>? userDetails,
List<dynamic>? plans,
Map<String, dynamic>? chartPoints,
Map<String, dynamic>? circumferences}) {
return MyProfileState(
myProfileModelObj: myProfileModelObj ?? this.myProfileModelObj,
user: user ?? this.user,
plans: plans ?? this.plans,
userDetails: userDetails ?? this.userDetails,
circumferences: circumferences ?? this.circumferences,
chartPoints: chartPoints ?? this.chartPoints);

View File

@@ -31,7 +31,9 @@ class MyProfileScreen extends StatelessWidget {
child: Scaffold(
appBar: _buildAppBar(
context,
state.user?['name'] + ' ' + state.userDetails?['last_name'] ??
((state.user?['name'] ?? '') +
' ' +
(state.userDetails?['last_name'] ?? '')) ??
'loading'.tr),
body: Container(
width: double.maxFinite,
@@ -44,7 +46,7 @@ class MyProfileScreen extends StatelessWidget {
SizedBox(height: 30.v),
CarouselSlider(
options: CarouselOptions(height: 370.0),
items: [1, 2, 3].map((chartType) {
items: [1, 2, 3, 4].map((chartType) {
return Builder(
builder: (BuildContext context) {
switch (chartType) {
@@ -111,6 +113,18 @@ class MyProfileScreen extends StatelessWidget {
state.circumferences,
)
]);
case 4: //График обхватов
return NextStepButton(
buttonStyle:
CustomButtonStyles.outlinePrimaryTL15,
text: "тест".toUpperCase(),
margin: EdgeInsets.only(left: 10.h),
onPressed: () {
print(state.plans
?.map((plan) => plan['image'])
.toList()
.runtimeType);
});
default:
return Text('text',
style: TextStyle(fontSize: 16.0));
@@ -120,7 +134,10 @@ class MyProfileScreen extends StatelessWidget {
}).toList(),
),
SizedBox(height: 15.v),
_buildWidget(context),
_buildPlans(
context,
state.plans?.map((plan) => plan['name']).toList(),
state.plans?.map((plan) => plan['image']).toList()),
SizedBox(height: 5.v),
])),
bottomNavigationBar: _buildBottomBar(context)));
@@ -542,7 +559,8 @@ class MyProfileScreen extends StatelessWidget {
}
/// Section Widget
Widget _buildWidget(BuildContext context) {
Widget _buildPlans(
BuildContext context, List<dynamic>? plans, List<dynamic>? image_paths) {
return Padding(
padding: EdgeInsets.only(left: 7.h),
child: Container(
@@ -566,145 +584,65 @@ class MyProfileScreen extends StatelessWidget {
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(
left: 38.h,
bottom: 1.v),
child: Text("lbl12".tr,
style: CustomTextStyles
.titleSmallBluegray800Bold)),
Container(
height: 19.v,
width: 82.h,
decoration: BoxDecoration(
color:
appTheme.greenA700,
ListView.builder(
itemCount: plans!.length,
itemBuilder:
(BuildContext context, int i) {
String name = plans[i]['name'];
String imagePath =
image_paths![i]['path'];
return 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:
BorderRadius
.circular(5.h)))
]))),
Align(
alignment: Alignment.bottomRight,
child: Container(
width: 40.h,
margin: EdgeInsets.only(right: 30.h),
child: Text("done".tr,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style:
theme.textTheme.titleSmall)))
]))),
Align(
alignment: Alignment.bottomCenter,
child: Container(
height: 40.v,
width: 343.h,
margin: EdgeInsets.only(bottom: 21.v),
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(
left: 38.h, top: 1.v),
child: Text("lbl14".tr,
style: CustomTextStyles
.titleSmallBluegray800Bold)),
Container(
height: 19.v,
width: 82.h,
decoration: BoxDecoration(
color:
appTheme.greenA700,
borderRadius:
BorderRadius
.circular(5.h)))
]))),
Align(
alignment: Alignment.bottomRight,
child: Container(
width: 40.h,
margin: EdgeInsets.only(right: 30.h),
child: Text("done".tr,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style:
theme.textTheme.titleSmall)))
]))),
Align(
alignment: Alignment.bottomCenter,
child: Container(
margin: EdgeInsets.only(top: 66.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(
left: 38.h, bottom: 2.v),
child: Text("lbl15".tr,
style: CustomTextStyles
.titleSmallBluegray800Bold)),
SizedBox(
height: 19.v,
width: 94.h,
child: Stack(
alignment: Alignment.bottomCenter,
children: [
Align(
alignment: Alignment.topCenter,
child: Container(
height: 19.v,
width: 94.h,
decoration: BoxDecoration(
color: appTheme
.deepOrange900,
borderRadius:
BorderRadius
.circular(
5.h)))),
Align(
alignment:
Alignment.bottomCenter,
child: Text("in_progress".tr,
style: theme
.textTheme.titleSmall))
]))
BorderRadiusStyle
.roundedBorder5),
child: Row(
mainAxisAlignment:
MainAxisAlignment
.spaceBetween,
children: [
Padding(
padding:
EdgeInsets.only(
left: 38.h,
bottom: 1.v),
child: Text(
"plan_name",
style: CustomTextStyles
.titleSmallBluegray800Bold)),
Container(
height: 19.v,
width: 82.h,
decoration: BoxDecoration(
color: appTheme
.greenA700,
borderRadius:
BorderRadius
.circular(
5.h)))
])));
Align(
alignment: Alignment.bottomRight,
child: Container(
width: 40.h,
margin: EdgeInsets.only(
right: 30.h),
child: Text("plan_status",
maxLines: 2,
overflow:
TextOverflow.ellipsis,
style: theme.textTheme
.titleSmall)));
})
]))),
Align(
alignment: Alignment.center,
@@ -721,17 +659,6 @@ class MyProfileScreen extends StatelessWidget {
width: 25.adaptSize,
radius: BorderRadius.circular(12.h)),
SizedBox(height: 8.v),
CustomImageView(
imagePath: ImageConstant.imgEllipse2,
height: 25.adaptSize,
width: 25.adaptSize,
radius: BorderRadius.circular(12.h)),
SizedBox(height: 8.v),
CustomImageView(
imagePath: ImageConstant.imgEllipse3,
height: 25.adaptSize,
width: 25.adaptSize,
radius: BorderRadius.circular(12.h))
])))
]))
])));