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 f90d7a9e..44c6b86f 100644 --- a/lib/presentation/profile/my_profile_screen/my_profile_screen.dart +++ b/lib/presentation/profile/my_profile_screen/my_profile_screen.dart @@ -29,15 +29,12 @@ class MyProfileScreen extends StatelessWidget { child: MyProfileScreen()); } - Widget build(BuildContext context) { + Widget build(BuildContext context) { return BlocBuilder( 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); @@ -49,122 +46,125 @@ 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), - 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, + 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), + 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((e) => e['weight']) + .toList() + .map((i) => i.toDouble()) + .toList() ?? + [0.0, 0.0, 0.0, 0.0], + state.chartPoints?.values + .map( + (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, - state.chartPoints?.values - .map((e) => e['weight']) - .toList() - .map((i) => i.toDouble()) - .toList() ?? - [0.0, 0.0, 0.0, 0.0], - state.chartPoints?.values - .map((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((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((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: 50.v), + _buildChart( + context, + _bodyMassIndex( + state.chartPoints?.values + .map((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((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((e) => e['created_at']) - .toList()), - _buildChartLegend() - ])); - default: - return Text('text', - style: TextStyle(fontSize: 16.0)); - } - }, - ); - }).toList(), - ), - 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))); + SizedBox(height: 30.v), + _buildCircumferenceChart( + context, + state.circumferences, + state.chartPoints?.values + .map( + (e) => e['created_at']) + .toList()), + _buildChartLegend() + ])); + default: + return Text('text', + style: TextStyle(fontSize: 16.0)); + } + }, + ); + }).toList(), + ), + 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 @@ -637,120 +637,114 @@ class MyProfileScreen extends StatelessWidget { List? imagePaths, List? 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: 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, - 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( + 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: - 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( - right: 22.h), - child: Text("$state".tr, - maxLines: 3, - overflow: TextOverflow - .ellipsis, - style: theme.textTheme - .titleSmall))) - ])); - })), - ])) + 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 _bodyMassIndex(List weightPoints, int height) {