Files
eatvio_app/lib/presentation/name_screen/name_screen.dart
2023-12-22 11:08:57 +03:00

143 lines
5.7 KiB
Dart

import 'bloc/name_bloc.dart';
import 'models/name_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:eatvio_app/widgets/custom_text_form_field.dart';
import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart';
import 'package:flutter/material.dart';
class NameScreen extends StatefulWidget {
const NameScreen({Key? key}) : super(key: key);
static Widget builder(BuildContext context) {
return BlocProvider<NameBloc>(
create: (context) => NameBloc(NameState(
nameModelObj: NameModel(
userRegistrationSheet: UserRegistrationSheet(
firstName: '1',
lastName: '1',
email: '1',
password: '1',
passwordConfirmation: '1',
termsAccepted: true,
birthdate: DateTime.now(),
gender: '1',
country: '1',
city: '1',
lang: '1',
weight: 1,
height: 1,
chestCircumference: 1,
waistCircumference: 1,
hipCircumference: 1,
bloodPressureUp: 1,
bloodPressureDown: 1,
hasHypo: false,
hasHyper: false,
aboutAllergy: '1',
aboutTakingPils: '1',
aboutSportHobbies: '1',
favoriteFoods: '1',
unfavoriteFoods: '1',
additionalInfo: '1'))))
..add(NameInitialEvent()),
child: NameScreen());
}
@override
State<NameScreen> createState() => _NameScreenState();
}
class _NameScreenState extends State<NameScreen> {
@override
Widget build(BuildContext context) {
mediaQueryData = MediaQuery.of(context);
return SafeArea(
child: 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: 0.1,
backgroundColor: theme.colorScheme.onPrimary,
valueColor: AlwaysStoppedAnimation<Color>(
appTheme.blueA400)))),
SizedBox(height: 39.v),
Text("what_is_your_name".tr,
style: theme.textTheme.headlineSmall),
SizedBox(height: 93.v),
Text("first_name".tr, style: theme.textTheme.bodyLarge),
SizedBox(height: 3.v),
BlocSelector<NameBloc, NameState, TextEditingController?>(
selector: (state) => state.valueController,
builder: (context, valueController) {
return CustomTextFormField(
controller: valueController,
textInputAction: TextInputAction.done);
}),
SizedBox(height: 19.v),
Text("last_name".tr, style: theme.textTheme.bodyLarge),
SizedBox(height: 5.v),
BlocSelector<NameBloc, NameState, TextEditingController?>(
selector: (state) => state.valueController1,
builder: (context, valueController1) {
return CustomTextFormField(
controller: valueController1,
);
}),
SizedBox(height: 21.v),
Spacer(),
NextStepButton(
text: "continue".tr.toUpperCase(),
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
onPressed: () {
navigateToGender(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 weightScreen when the action is triggered.
navigateToGender(BuildContext context) {
NavigatorService.pushNamed(
AppRoutes.genderScreen,
);
}
}