refactor(all): refactor

This commit is contained in:
alex
2024-07-09 17:50:32 +03:00
parent f79b9f03ae
commit e180ff16b6
37 changed files with 1706 additions and 1123 deletions

View File

@@ -16,9 +16,10 @@ class MedicineIntakeScreen extends StatefulWidget {
static Widget builder(BuildContext context, sheet) {
return BlocProvider<MedicineIntakeBloc>(
create: (context) => MedicineIntakeBloc(MedicineIntakeState(medicineIntakeModelObj: MedicineIntakeModel(userRegistrationSheet: sheet)))
..add(MedicineIntakeInitialEvent()),
child: MedicineIntakeScreen(),);
create: (context) =>
MedicineIntakeBloc(MedicineIntakeState(medicineIntakeModelObj: MedicineIntakeModel(userRegistrationSheet: sheet)))..add(MedicineIntakeInitialEvent()),
child: MedicineIntakeScreen(),
);
}
@override
@@ -30,54 +31,75 @@ class _MedicineIntakeScreenState extends State<MedicineIntakeScreen> {
Widget build(BuildContext context) {
mediaQueryData = MediaQuery.of(context);
return Scaffold(
resizeToAvoidBottomInset: false,
appBar: _buildAppBar(context),
body: Container(
width: double.maxFinite,
padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v),
child: Column(children: [
SizedBox(height: 7.v),
Container(
height: 16.v,
width: 343.h,
decoration: BoxDecoration(
color: theme.colorScheme.onPrimary,
borderRadius: BorderRadius.circular(8.h),
border: Border.all(color: theme.colorScheme.primary, width: 1.h),),
child: ClipRRect(
borderRadius: BorderRadius.circular(8.h),
child: LinearProgressIndicator(
value: 0.69, backgroundColor: theme.colorScheme.onPrimary, valueColor: AlwaysStoppedAnimation<Color>(appTheme.blueA400),),),),
SizedBox(height: 20.v),
Container(
width: 271.h,
margin: EdgeInsets.only(left: 35.h, right: 36.h),
child: Text("do_you_take_pills".tr,
maxLines: 2, overflow: TextOverflow.ellipsis, textAlign: TextAlign.center, style: theme.textTheme.headlineSmall,),),
SizedBox(height: 86.v),
_buildTextFormField(context),
Spacer(),
BlocBuilder<MedicineIntakeBloc, MedicineIntakeState>(builder: (context, state) {
resizeToAvoidBottomInset: false,
appBar: _buildAppBar(context),
body: Container(
width: double.maxFinite,
padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v),
child: Column(
children: [
SizedBox(height: 7.v),
Container(
height: 16.v,
width: 343.h,
decoration: BoxDecoration(
color: theme.colorScheme.onPrimary,
borderRadius: BorderRadius.circular(8.h),
border: Border.all(color: theme.colorScheme.primary, width: 1.h),
),
child: ClipRRect(
borderRadius: BorderRadius.circular(8.h),
child: LinearProgressIndicator(
value: (11 / 15).toDouble(),
backgroundColor: theme.colorScheme.onPrimary,
valueColor: AlwaysStoppedAnimation<Color>(appTheme.blueA400),
),
),
),
SizedBox(height: 20.v),
Container(
width: 271.h,
margin: EdgeInsets.only(left: 35.h, right: 36.h),
child: Text(
"do_you_take_pills".tr,
maxLines: 2,
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.center,
style: theme.textTheme.headlineSmall,
),
),
SizedBox(height: 86.v),
_buildTextFormField(context),
Spacer(),
BlocBuilder<MedicineIntakeBloc, MedicineIntakeState>(
builder: (context, state) {
return NextStepButton(
text: "continue".tr.toUpperCase(),
margin: EdgeInsets.only(left: 16.h, right: 16.h, bottom: 50.v),
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
onPressed: onTapNext(state, context),);
},),
BlocBuilder<MedicineIntakeBloc, MedicineIntakeState>(builder: (context, state) {
text: "continue".tr.toUpperCase(),
margin: EdgeInsets.only(left: 16.h, right: 16.h, bottom: 50.v),
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
onPressed: onTapNext(state, context),
);
},
),
BlocBuilder<MedicineIntakeBloc, MedicineIntakeState>(
builder: (context, state) {
return GestureDetector(
onTap: onTapSkip(state, context),
child: Text("skip".tr, style: theme.textTheme.bodyLarge),
);
},),
],),),);
},
),
],
),
),
);
}
onTapSkip(MedicineIntakeState state, BuildContext context) {
return () {
UserRegistrationSheet sheet = state.medicineIntakeModelObj!.userRegistrationSheet;
GoRouter.of(context).goNamed(
'bloodPressureScreen',
'favoriteSportsScreen',
extra: sheet,
);
};
@@ -88,7 +110,7 @@ class _MedicineIntakeScreenState extends State<MedicineIntakeScreen> {
UserRegistrationSheet sheet = state.medicineIntakeModelObj!.userRegistrationSheet;
sheet.aboutTakingPils = state.enterInformationController!.text;
GoRouter.of(context).goNamed(
'bloodPressureScreen',
'favoriteSportsScreen',
extra: sheet,
);
};
@@ -97,11 +119,12 @@ class _MedicineIntakeScreenState extends State<MedicineIntakeScreen> {
/// Section Widget
_buildAppBar(BuildContext context) {
return CustomAppBar(
leadingWidth: 31.h,
leading:
AppbarLeadingImage(imagePath: ImageConstant.imgArrowLeft, margin: EdgeInsets.only(left: 18.h, top: 15.v, bottom: 15.v), onTap: onTapBack(context)),
centerTitle: true,
title: AppbarTitleImage(imagePath: ImageConstant.imgLogoEatvio),);
leadingWidth: 31.h,
leading:
AppbarLeadingImage(imagePath: ImageConstant.imgArrowLeft, margin: EdgeInsets.only(left: 18.h, top: 15.v, bottom: 15.v), onTap: onTapBack(context)),
centerTitle: true,
title: AppbarTitleImage(imagePath: ImageConstant.imgLogoEatvio),
);
}
Function onTapBack(BuildContext context) {
@@ -112,16 +135,23 @@ class _MedicineIntakeScreenState extends State<MedicineIntakeScreen> {
/// Section Widget
_buildTextFormField(BuildContext context) {
return Column(children: [
Text("fill_in_information".tr, style: CustomTextStyles.titleMediumSegoeUI),
SizedBox(height: 2.v),
BlocSelector<MedicineIntakeBloc, MedicineIntakeState, TextEditingController?>(
return Column(
children: [
Text("fill_in_information".tr, style: CustomTextStyles.titleMediumSegoeUI),
SizedBox(height: 2.v),
BlocSelector<MedicineIntakeBloc, MedicineIntakeState, TextEditingController?>(
selector: (state) => state.enterInformationController,
builder: (context, enterInformationController) {
return CustomTextFormField(
controller: enterInformationController, hintText: "enter_information".tr, textInputAction: TextInputAction.done, maxLines: 8,);
},),
],);
controller: enterInformationController,
hintText: "enter_information".tr,
textInputAction: TextInputAction.done,
maxLines: 8,
);
},
),
],
);
}
/// Navigates to the previous screen.