forked from eatvio/eatvio_app
feature(registration): refactor i5
This commit is contained in:
@@ -1,10 +1,6 @@
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import 'bloc/allergies_bloc.dart';
|
||||
// ignore: unused_import
|
||||
import 'models/allergies_model.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart';
|
||||
import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart';
|
||||
import 'package:eatvio_app/widgets/custom_text_form_field.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@@ -18,6 +14,14 @@ class AllergiesScreen extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _AllergiesScreenState extends State<AllergiesScreen> {
|
||||
final enterInformationController = TextEditingController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
enterInformationController.text = widget.sheet.aboutAllergy;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SingleChildScrollView(
|
||||
@@ -29,75 +33,21 @@ class _AllergiesScreenState extends State<AllergiesScreen> {
|
||||
children: [
|
||||
Text("allergies_presence".tr, style: theme.textTheme.headlineSmall),
|
||||
SizedBox(height: 22.v),
|
||||
_buildTextFormField(context),
|
||||
// BlocBuilder<AllergiesBloc, AllergiesState>(
|
||||
// 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: onTapContinue(state, context),
|
||||
// );
|
||||
// },
|
||||
// ),
|
||||
// BlocBuilder<AllergiesBloc, AllergiesState>(
|
||||
// builder: (context, state) {
|
||||
// return GestureDetector(
|
||||
// onTap: onTapSkip(state, context),
|
||||
// child: Text("skip".tr, style: theme.textTheme.bodyLarge),
|
||||
// );
|
||||
// },
|
||||
// ),
|
||||
Text("fill_in_information".tr, style: CustomTextStyles.titleMediumSegoeUI),
|
||||
SizedBox(height: 2.v),
|
||||
CustomTextFormField(
|
||||
controller: enterInformationController,
|
||||
hintText: "enter_information".tr,
|
||||
textInputAction: TextInputAction.done,
|
||||
maxLines: 8,
|
||||
onChanged: (newValue) {
|
||||
final registrationCubit = context.read<RegistrationCubit>();
|
||||
registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(aboutAllergy: newValue));
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
onTapSkip(AllergiesState state, BuildContext context) {
|
||||
return () {
|
||||
UserRegistrationSheet sheet = state.allergiesModelObj!.userRegistrationSheet;
|
||||
GoRouter.of(context).goNamed('medicineIntakeScreen', extra: sheet);
|
||||
};
|
||||
}
|
||||
|
||||
onTapContinue(AllergiesState state, BuildContext context) {
|
||||
return () {
|
||||
UserRegistrationSheet sheet = state.allergiesModelObj!.userRegistrationSheet;
|
||||
// sheet.aboutAllergy = state.enterInformationController!.text;
|
||||
GoRouter.of(context).goNamed('medicineIntakeScreen', extra: sheet);
|
||||
};
|
||||
}
|
||||
|
||||
onTapBack(BuildContext context) {
|
||||
return () {
|
||||
onTapArrowLeft(context);
|
||||
};
|
||||
}
|
||||
|
||||
/// Section Widget
|
||||
_buildTextFormField(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
Text("fill_in_information".tr, style: CustomTextStyles.titleMediumSegoeUI),
|
||||
SizedBox(height: 2.v),
|
||||
BlocSelector<AllergiesBloc, AllergiesState, TextEditingController?>(
|
||||
selector: (state) => state.enterInformationController,
|
||||
builder: (context, enterInformationController) {
|
||||
return CustomTextFormField(
|
||||
controller: enterInformationController,
|
||||
hintText: "enter_information".tr,
|
||||
textInputAction: TextInputAction.done,
|
||||
maxLines: 8,
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// Navigates to the previous screen.
|
||||
onTapArrowLeft(BuildContext context) {
|
||||
GoRouter.of(context).pop();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user