forked from eatvio/eatvio_app
112 lines
3.4 KiB
Dart
112 lines
3.4 KiB
Dart
import 'package:go_router/go_router.dart';
|
|
|
|
import 'bloc/gender_bloc.dart';
|
|
import 'models/gender_model.dart';
|
|
import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart';
|
|
import 'package:eatvio_app/core/app_export.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
class GenderScreen extends StatefulWidget {
|
|
const GenderScreen({Key? key}) : super(key: key);
|
|
|
|
static Widget builder(BuildContext context, sheet) {
|
|
return BlocProvider<GenderBloc>(
|
|
create: (context) => GenderBloc(
|
|
GenderState(
|
|
genderModelObj: GenderModel(userRegistrationSheet: sheet),
|
|
),
|
|
)..add(GenderInitialEvent()),
|
|
child: GenderScreen(),
|
|
);
|
|
}
|
|
|
|
@override
|
|
State<GenderScreen> createState() => _GenderScreenState();
|
|
}
|
|
|
|
class _GenderScreenState extends State<GenderScreen> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return SingleChildScrollView(
|
|
padding: EdgeInsets.only(bottom: 80),
|
|
child: BlocBuilder<GenderBloc, GenderState>(
|
|
builder: (context, state) {
|
|
return Container(
|
|
width: double.maxFinite,
|
|
padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v),
|
|
child: Column(
|
|
children: [
|
|
Text("your_gender".tr, style: theme.textTheme.headlineSmall),
|
|
RadioListTile(
|
|
title: Text('Мужской'),
|
|
value: 'male',
|
|
groupValue: state.selectedRadioValue,
|
|
onChanged: onMale(context),
|
|
secondary: Image.asset(
|
|
'assets/images/img_male.png',
|
|
width: 40,
|
|
height: 40,
|
|
),
|
|
),
|
|
RadioListTile(
|
|
title: Text('Женский'),
|
|
value: 'female',
|
|
groupValue: state.selectedRadioValue,
|
|
onChanged: onFemale(context),
|
|
secondary: Image.asset(
|
|
'assets/images/img_female.png',
|
|
width: 40,
|
|
height: 40,
|
|
),
|
|
),
|
|
// BlocBuilder<GenderBloc, GenderState>(
|
|
// 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),
|
|
// );
|
|
// },
|
|
// ),
|
|
],
|
|
),
|
|
);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
onTapNext(GenderState state, BuildContext context) {
|
|
return () {
|
|
UserRegistrationSheet sheet = state.genderModelObj!.userRegistrationSheet;
|
|
sheet.gender = state.selectedRadioValue!;
|
|
GoRouter.of(context).goNamed('dateOfBirthScreen', extra: sheet);
|
|
};
|
|
}
|
|
|
|
onMale(BuildContext context) {
|
|
return (value) {
|
|
BlocProvider.of<GenderBloc>(context).add(GenderSelectEvent(value: 'male'));
|
|
};
|
|
}
|
|
|
|
onFemale(BuildContext context) {
|
|
return (value) {
|
|
BlocProvider.of<GenderBloc>(context).add(GenderSelectEvent(value: 'female'));
|
|
};
|
|
}
|
|
|
|
|
|
Function onTapBack() {
|
|
return () {
|
|
GoRouter.of(context).pop();
|
|
};
|
|
}
|
|
|
|
/// Navigates to the previous screen.
|
|
onTapArrowLeft(BuildContext context) {
|
|
GoRouter.of(context).pop();
|
|
}
|
|
}
|