go router full
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import 'bloc/allergies_bloc.dart';
|
||||
import 'models/allergies_model.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
@@ -13,12 +15,9 @@ class AllergiesScreen extends StatefulWidget {
|
||||
const AllergiesScreen({Key? key}) : super(key: key);
|
||||
|
||||
static Widget builder(BuildContext context) {
|
||||
final sheet =
|
||||
ModalRoute.of(context)!.settings.arguments as UserRegistrationSheet;
|
||||
final sheet = ModalRoute.of(context)!.settings.arguments as UserRegistrationSheet;
|
||||
return BlocProvider<AllergiesBloc>(
|
||||
create: (context) => AllergiesBloc(AllergiesState(
|
||||
allergiesModelObj: AllergiesModel(userRegistrationSheet: sheet)))
|
||||
..add(AllergiesInitialEvent()),
|
||||
create: (context) => AllergiesBloc(AllergiesState(allergiesModelObj: AllergiesModel(userRegistrationSheet: sheet)))..add(AllergiesInitialEvent()),
|
||||
child: AllergiesScreen());
|
||||
}
|
||||
|
||||
@@ -45,32 +44,24 @@ class _AllergiesScreenState extends State<AllergiesScreen> {
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.onPrimary,
|
||||
borderRadius: BorderRadius.circular(8.h),
|
||||
border: Border.all(
|
||||
color: theme.colorScheme.primary, width: 1.h)),
|
||||
border: Border.all(color: theme.colorScheme.primary, width: 1.h)),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(8.h),
|
||||
child: LinearProgressIndicator(
|
||||
value: 0.76,
|
||||
backgroundColor: theme.colorScheme.onPrimary,
|
||||
valueColor: AlwaysStoppedAnimation<Color>(
|
||||
appTheme.blueA400)))),
|
||||
value: 0.76, backgroundColor: theme.colorScheme.onPrimary, valueColor: AlwaysStoppedAnimation<Color>(appTheme.blueA400)))),
|
||||
SizedBox(height: 22.v),
|
||||
Text("allergies_presence".tr,
|
||||
style: theme.textTheme.headlineSmall),
|
||||
Text("allergies_presence".tr, style: theme.textTheme.headlineSmall),
|
||||
Spacer(flex: 36),
|
||||
_buildTextFormField(context),
|
||||
Spacer(flex: 54),
|
||||
BlocBuilder<AllergiesBloc, AllergiesState>(
|
||||
builder: (context, state) {
|
||||
BlocBuilder<AllergiesBloc, AllergiesState>(builder: (context, state) {
|
||||
return NextStepButton(
|
||||
text: "continue".tr.toUpperCase(),
|
||||
margin: EdgeInsets.only(
|
||||
left: 16.h, right: 16.h, bottom: 50.v),
|
||||
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) {
|
||||
BlocBuilder<AllergiesBloc, AllergiesState>(builder: (context, state) {
|
||||
return GestureDetector(
|
||||
onTap: onTapSkip(state, context),
|
||||
child: Text("skip".tr, style: theme.textTheme.bodyLarge),
|
||||
@@ -81,26 +72,16 @@ class _AllergiesScreenState extends State<AllergiesScreen> {
|
||||
|
||||
onTapSkip(AllergiesState state, BuildContext context) {
|
||||
return () {
|
||||
UserRegistrationSheet sheet =
|
||||
state.allergiesModelObj!.userRegistrationSheet;
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
AppRoutes.medicineIntakeScreen,
|
||||
arguments: sheet,
|
||||
);
|
||||
UserRegistrationSheet sheet = state.allergiesModelObj!.userRegistrationSheet;
|
||||
GoRouter.of(context).goNamed('medicineIntakeScreen', extra: sheet);
|
||||
};
|
||||
}
|
||||
|
||||
onTapContinue(AllergiesState state, BuildContext context) {
|
||||
return () {
|
||||
UserRegistrationSheet sheet =
|
||||
state.allergiesModelObj!.userRegistrationSheet;
|
||||
UserRegistrationSheet sheet = state.allergiesModelObj!.userRegistrationSheet;
|
||||
sheet.aboutAllergy = state.enterInformationController!.text;
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
AppRoutes.medicineIntakeScreen,
|
||||
arguments: sheet,
|
||||
);
|
||||
GoRouter.of(context).goNamed('medicineIntakeScreen', extra: sheet);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -108,10 +89,8 @@ class _AllergiesScreenState extends State<AllergiesScreen> {
|
||||
_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)),
|
||||
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));
|
||||
}
|
||||
@@ -125,17 +104,13 @@ class _AllergiesScreenState extends State<AllergiesScreen> {
|
||||
/// Section Widget
|
||||
_buildTextFormField(BuildContext context) {
|
||||
return Column(children: [
|
||||
Text("fill_in_information".tr,
|
||||
style: CustomTextStyles.titleMediumSegoeUI),
|
||||
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);
|
||||
controller: enterInformationController, hintText: "enter_information".tr, textInputAction: TextInputAction.done, maxLines: 8);
|
||||
})
|
||||
]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user