From c846a0c8ca7dae333af196877ecf517f989abe94 Mon Sep 17 00:00:00 2001 From: maxxkim Date: Thu, 1 Feb 2024 11:15:02 +0300 Subject: [PATCH] New switches for hyper and hypo --- .../bloc/my_profile_bloc.dart | 4 ++ .../my_profile_screen/my_settings_screen.dart | 53 ++++++++++++++++--- 2 files changed, 50 insertions(+), 7 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 022d636e..9865e381 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 @@ -78,6 +78,8 @@ class MyProfileBloc extends Bloc { additionalFormController: currentState.additionalFormController, sportsFormController: currentState.sportsFormController, dateFormController: currentState.dateFormController, + hypoFormController: currentState.hypoFormController, + hyperFormController: currentState.hyperFormController, )); } else { print(data['userDetails']); @@ -89,6 +91,8 @@ class MyProfileBloc extends Bloc { userDetails: data['userDetails'], plans: data['plans'], token: token, + hypoFormController: data['userDetails']['has_hypo'].toString(), + hyperFormController: data['userDetails']['has_hyper'].toString(), chestCircumferenceFormController: TextEditingController( text: data['userDetails']['chest_circumference']?.toString()), waistCircumferenceFormController: TextEditingController( diff --git a/lib/presentation/profile/my_profile_screen/my_settings_screen.dart b/lib/presentation/profile/my_profile_screen/my_settings_screen.dart index 6f666b0a..753d5758 100644 --- a/lib/presentation/profile/my_profile_screen/my_settings_screen.dart +++ b/lib/presentation/profile/my_profile_screen/my_settings_screen.dart @@ -201,16 +201,55 @@ class _NotificationSwitchState extends State { } } -class HypoHyperSwitch extends StatefulWidget { +class HyperSwitch extends StatefulWidget { final String title; - - HypoHyperSwitch(this.title); + MyProfileLoadedState? state; + HyperSwitch(this.title, this.state); @override - _HypoHyperState createState() => _HypoHyperState(); + _HyperState createState() => _HyperState(); } -class _HypoHyperState extends State { +class _HyperState extends State { + bool switchValue = false; + + @override + Widget build(BuildContext context) { + return Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + widget.title, + style: TextStyle( + color: Colors.black, fontSize: 14, fontWeight: FontWeight.bold), + ), + Switch( + value: switchValue, + onChanged: (value) { + setState(() { + switchValue = value; + }); + }, + inactiveThumbColor: appTheme.blueA400, + inactiveTrackColor: Colors.white, + activeTrackColor: appTheme.blueA400, + activeColor: Colors.white, + ), + ], + ); + } +} + +class HypoSwitch extends StatefulWidget { + final String title; + + HypoSwitch(this.title); + + @override + _HypoState createState() => _HypoState(); +} + +class _HypoState extends State { bool switchValue = false; @override @@ -465,12 +504,12 @@ class _ExpandableListState extends State { ), Row( children: [ - HypoHyperSwitch('do_you_have_hypotension_tendency'.tr), + HypoSwitch('do_you_have_hypotension_tendency'.tr, state), ], ), Row( children: [ - HypoHyperSwitch('do_you_have_hypertension_tendency'.tr), + HypoSwitch('do_you_have_hypertension_tendency'.tr, state), ], ), NextStepButton(