forked from eatvio/eatvio_app
132 lines
5.0 KiB
Dart
132 lines
5.0 KiB
Dart
import 'bloc/gender_bloc.dart';
|
|
import 'models/gender_model.dart';
|
|
import 'package:eatvio_app/core/app_export.dart';
|
|
import 'package:eatvio_app/widgets/app_bar/appbar_leading_image.dart';
|
|
import 'package:eatvio_app/widgets/app_bar/appbar_title_image.dart';
|
|
import 'package:eatvio_app/widgets/app_bar/custom_app_bar.dart';
|
|
import 'package:eatvio_app/widgets/next_step_button.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
enum Gender { male, female }
|
|
|
|
class GenderScreen extends StatefulWidget {
|
|
const GenderScreen({Key? key}) : super(key: key);
|
|
|
|
static Widget builder(BuildContext context) {
|
|
return BlocProvider<GenderBloc>(
|
|
create: (context) =>
|
|
GenderBloc(GenderState(genderModelObj: GenderModel()))
|
|
..add(GenderInitialEvent()),
|
|
child: GenderScreen());
|
|
}
|
|
|
|
@override
|
|
State<GenderScreen> createState() => _GenderScreenState();
|
|
}
|
|
|
|
class _GenderScreenState extends State<GenderScreen> {
|
|
Gender? _gender;
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
mediaQueryData = MediaQuery.of(context);
|
|
return BlocBuilder<GenderBloc, GenderState>(builder: (context, state) {
|
|
return SafeArea(
|
|
child: Scaffold(
|
|
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.16,
|
|
backgroundColor: theme.colorScheme.onPrimary,
|
|
valueColor: AlwaysStoppedAnimation<Color>(
|
|
appTheme.blueA400)))),
|
|
SizedBox(height: 36.v),
|
|
Text("your_gender".tr,
|
|
style: theme.textTheme.headlineSmall),
|
|
RadioListTile(
|
|
title: Text('Мужской'),
|
|
value: Gender.male,
|
|
groupValue: _gender,
|
|
onChanged: (value) {
|
|
setState(() {
|
|
_gender = value as Gender?;
|
|
});
|
|
},
|
|
secondary: Image.asset(
|
|
_gender == Gender.male
|
|
? 'assets/images/img_male.png'
|
|
: 'assets/images/img_male.png',
|
|
width: 40,
|
|
height: 40,
|
|
),
|
|
),
|
|
RadioListTile(
|
|
title: Text('Женский'),
|
|
value: Gender.female,
|
|
groupValue: _gender,
|
|
onChanged: (value) {
|
|
setState(() {
|
|
_gender = value as Gender?;
|
|
});
|
|
},
|
|
secondary: Image.asset(
|
|
_gender == Gender.female
|
|
? 'assets/images/img_female.png'
|
|
: 'assets/images/img_female.png',
|
|
width: 40,
|
|
height: 40,
|
|
),
|
|
),
|
|
Spacer(flex: 66),
|
|
NextStepButton(
|
|
text: "continue".tr.toUpperCase(),
|
|
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
|
|
onPressed: () {
|
|
navigateToDate(context);
|
|
}),
|
|
SizedBox(height: 17.v),
|
|
]))));
|
|
});
|
|
}
|
|
|
|
/// Section Widget
|
|
PreferredSizeWidget _buildAppBar(BuildContext context) {
|
|
return CustomAppBar(
|
|
leadingWidth: 29.h,
|
|
leading: AppbarLeadingImage(
|
|
imagePath: ImageConstant.imgArrowLeft,
|
|
margin: EdgeInsets.only(left: 16.h, top: 15.v, bottom: 15.v),
|
|
onTap: () {
|
|
onTapArrowLeft(context);
|
|
}),
|
|
centerTitle: true,
|
|
title: AppbarTitleImage(imagePath: ImageConstant.imgLogoEatvio));
|
|
}
|
|
|
|
/// Navigates to the previous screen.
|
|
onTapArrowLeft(BuildContext context) {
|
|
NavigatorService.goBack();
|
|
}
|
|
|
|
/// Navigates to the dateOfBirthScreen when the action is triggered.
|
|
navigateToDate(BuildContext context) {
|
|
NavigatorService.pushNamed(
|
|
AppRoutes.dateOfBirthScreen,
|
|
);
|
|
}
|
|
}
|