From 4050e6125840a7836cde3e70e112a00816c02e15 Mon Sep 17 00:00:00 2001 From: maxxkim Date: Wed, 17 Jan 2024 14:58:34 +0300 Subject: [PATCH] Plans build function --- .../bloc/my_profile_bloc.dart | 3 +- .../bloc/my_profile_state.dart | 6 +- .../my_profile_screen/my_profile_screen.dart | 233 ++++++------------ 3 files changed, 87 insertions(+), 155 deletions(-) diff --git a/lib/presentation/profile/my_profile_screen/bloc/my_profile_bloc.dart b/lib/presentation/profile/my_profile_screen/bloc/my_profile_bloc.dart index 1d6d3277..230fae60 100644 --- a/lib/presentation/profile/my_profile_screen/bloc/my_profile_bloc.dart +++ b/lib/presentation/profile/my_profile_screen/bloc/my_profile_bloc.dart @@ -54,8 +54,9 @@ class MyProfileBloc extends Bloc { 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'], )); } diff --git a/lib/presentation/profile/my_profile_screen/bloc/my_profile_state.dart b/lib/presentation/profile/my_profile_screen/bloc/my_profile_state.dart index 5c6b88bb..852c8da3 100644 --- a/lib/presentation/profile/my_profile_screen/bloc/my_profile_state.dart +++ b/lib/presentation/profile/my_profile_screen/bloc/my_profile_state.dart @@ -9,26 +9,30 @@ class MyProfileState extends Equatable { this.user, this.userDetails, this.chartPoints, + this.plans, this.circumferences}); MyProfileModel? myProfileModelObj; Map? user; Map? userDetails; Map? chartPoints; + List? plans; Map? circumferences; @override List get props => - [myProfileModelObj, user, chartPoints, circumferences]; + [myProfileModelObj, user, chartPoints, circumferences, plans]; MyProfileState copyWith( {MyProfileModel? myProfileModelObj, Map? user, Map? userDetails, + List? plans, Map? chartPoints, Map? 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); diff --git a/lib/presentation/profile/my_profile_screen/my_profile_screen.dart b/lib/presentation/profile/my_profile_screen/my_profile_screen.dart index 353b564d..ceb740d4 100644 --- a/lib/presentation/profile/my_profile_screen/my_profile_screen.dart +++ b/lib/presentation/profile/my_profile_screen/my_profile_screen.dart @@ -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? plans, List? 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)) ]))) ])) ])));