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

@@ -20,45 +20,59 @@ class AdditionalInformationScreen extends StatelessWidget {
static Widget builder(BuildContext context, sheet) {
return BlocProvider<AdditionalInformationBloc>(
create: (context) =>
AdditionalInformationBloc(AdditionalInformationState(additionalInformationModelObj: AdditionalInformationModel(userRegistrationSheet: sheet)))
..add(AdditionalInformationInitialEvent()),
child: AdditionalInformationScreen(),);
create: (context) =>
AdditionalInformationBloc(AdditionalInformationState(additionalInformationModelObj: AdditionalInformationModel(userRegistrationSheet: sheet)))
..add(AdditionalInformationInitialEvent()),
child: AdditionalInformationScreen(),
);
}
@override
Widget build(BuildContext 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: 1, backgroundColor: theme.colorScheme.onPrimary, valueColor: AlwaysStoppedAnimation<Color>(appTheme.blueA400),),),),
SizedBox(height: 20.v),
SizedBox(height: 73.v),
_buildTextFormField(context),
Spacer(),
BlocBuilder<AdditionalInformationBloc, AdditionalInformationState>(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: (14 / 15).toDouble(),
backgroundColor: theme.colorScheme.onPrimary,
valueColor: AlwaysStoppedAnimation<Color>(appTheme.blueA400),
),
),
),
SizedBox(height: 20.v),
SizedBox(height: 73.v),
_buildTextFormField(context),
Spacer(),
BlocBuilder<AdditionalInformationBloc, AdditionalInformationState>(
builder: (context, state) {
return NextStepButton(
text: "finish".tr.toUpperCase(),
margin: EdgeInsets.only(left: 16.h, right: 16.h, bottom: 50.v),
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
onPressed: onTapFinish(state, context),);
},),
],),),);
text: "finish".tr.toUpperCase(),
margin: EdgeInsets.only(left: 16.h, right: 16.h, bottom: 50.v),
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
onPressed: onTapFinish(state, context),
);
},
),
],
),
),
);
}
onTapFinish(AdditionalInformationState state, BuildContext context) {
@@ -66,8 +80,12 @@ class AdditionalInformationScreen extends StatelessWidget {
UserRegistrationSheet sheet = state.additionalInformationModelObj!.userRegistrationSheet;
sheet.additionalInfo = state.editTextController!.text;
final response = await http.post(Uri.parse(dotenv.env['SERVER_ROOT']! + '/register'),
headers: {'Content-Type': 'application/json', 'Accept': 'application/json'}, body: jsonEncode(sheet.toJson()), encoding: utf8,);
final response = await http.post(
Uri.parse(dotenv.env['SERVER_ROOT']! + '/register'),
headers: {'Content-Type': 'application/json', 'Accept': 'application/json'},
body: jsonEncode(sheet.toJson()),
encoding: utf8,
);
var res = await jsonDecode(response.body);
if (response.statusCode == 200) {
@@ -84,11 +102,12 @@ class AdditionalInformationScreen extends StatelessWidget {
/// 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),
);
}
onTapBack(BuildContext context) {
@@ -100,29 +119,45 @@ class AdditionalInformationScreen extends StatelessWidget {
/// Section Widget
_buildTextFormField(BuildContext context) {
return SizedBox(
height: 315.v,
width: 343.h,
child: Stack(alignment: Alignment.center, children: [
height: 315.v,
width: 343.h,
child: Stack(
alignment: Alignment.center,
children: [
Align(
alignment: Alignment.center,
child: Column(mainAxisSize: MainAxisSize.min, children: [
alignment: Alignment.center,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
width: 294.h,
margin: EdgeInsets.only(left: 24.h, right: 23.h),
child: Text("enter_additional_information".tr,
maxLines: 2, overflow: TextOverflow.ellipsis, textAlign: TextAlign.center, style: CustomTextStyles.titleMediumSegoeUI,),),
width: 294.h,
margin: EdgeInsets.only(left: 24.h, right: 23.h),
child: Text(
"enter_additional_information".tr,
maxLines: 2,
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.center,
style: CustomTextStyles.titleMediumSegoeUI,
),
),
SizedBox(height: 10.v),
BlocSelector<AdditionalInformationBloc, AdditionalInformationState, TextEditingController?>(
selector: (state) => state.editTextController,
builder: (context, editTextController) {
return CustomTextFormField(
controller: editTextController,
hintText: "У меня крепкое здоровье, но последнее время часто утомляюсь, однако, это мне не мешает радоваться жизни",
textInputAction: TextInputAction.done,
maxLines: 8,);
},),
],),),
],),);
selector: (state) => state.editTextController,
builder: (context, editTextController) {
return CustomTextFormField(
controller: editTextController,
hintText: "У меня крепкое здоровье, но последнее время часто утомляюсь, однако, это мне не мешает радоваться жизни",
textInputAction: TextInputAction.done,
maxLines: 8,
);
},
),
],
),
),
],
),
);
}
/// Navigates to the previous screen.
@@ -134,12 +169,13 @@ class AdditionalInformationScreen extends StatelessWidget {
/// The dialog box contains a title and a message with the `Теперь вы можете пользоваться полным функционалом приложения`
showErrorMessage(BuildContext context, String text) {
showDialog(
context: context,
builder: (_) => AlertDialog(
title: const Text('Ошибка'),
content: Text(text),
actions: [TextButton(onPressed: onTapOk(context), child: const Text('Ok'))],
),);
context: context,
builder: (_) => AlertDialog(
title: const Text('Ошибка'),
content: Text(text),
actions: [TextButton(onPressed: onTapOk(context), child: const Text('Ok'))],
),
);
}
onTapOk(BuildContext context) {