forked from eatvio/eatvio_app
196 lines
8.7 KiB
Dart
196 lines
8.7 KiB
Dart
import 'package:eatvio_app/core/app_export.dart';
|
|
import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart';
|
|
import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_state.dart';
|
|
import 'package:eatvio_app/presentation/registration/additional_information_screen/additional_information_screen.dart';
|
|
import 'package:eatvio_app/presentation/registration/allergies_screen/allergies_screen.dart';
|
|
import 'package:eatvio_app/presentation/registration/blood_pressure_screen/blood_pressure_screen.dart';
|
|
import 'package:eatvio_app/presentation/registration/body_circumferences_screen/body_circumferences_screen.dart';
|
|
import 'package:eatvio_app/presentation/registration/city_of_living_screen/city_of_living_screen.dart';
|
|
import 'package:eatvio_app/presentation/registration/credentials_screen/credentials_screen.dart';
|
|
import 'package:eatvio_app/presentation/registration/date_of_birth_screen/date_of_birth_screen.dart';
|
|
import 'package:eatvio_app/presentation/registration/favorite_foods_screen/favorite_foods_screen.dart';
|
|
import 'package:eatvio_app/presentation/registration/favorite_sports_screen/favorite_sports_screen.dart';
|
|
import 'package:eatvio_app/presentation/registration/gender_screen/gender_screen.dart';
|
|
import 'package:eatvio_app/presentation/registration/height_screen/height_screen.dart';
|
|
import 'package:eatvio_app/presentation/registration/language_select_screen/language_select_screen.dart';
|
|
import 'package:eatvio_app/presentation/registration/medicine_intake_screen/medicine_intake_screen.dart';
|
|
import 'package:eatvio_app/presentation/registration/name_screen/name_screen.dart';
|
|
import 'package:eatvio_app/presentation/registration/weight_screen/weight_screen.dart';
|
|
import 'package:eatvio_app/widgets/app_bar/appbar_title_image.dart';
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
|
|
class RegistrationScreen extends StatefulWidget {
|
|
const RegistrationScreen({super.key});
|
|
|
|
@override
|
|
State<RegistrationScreen> createState() => _RegistrationScreenState();
|
|
}
|
|
|
|
class _RegistrationScreenState extends State<RegistrationScreen> {
|
|
double progressValue = 1 / 15;
|
|
int step = 1;
|
|
final pageController = PageController();
|
|
|
|
_showPopDialog() {
|
|
showDialog(
|
|
context: context,
|
|
builder: (context) => CupertinoAlertDialog(
|
|
content: Text('Отменить регистрацию? Заполненные данные не будут сохранены.'),
|
|
actions: [
|
|
CupertinoDialogAction(
|
|
onPressed: () {
|
|
Navigator.pop(context);
|
|
GoRouter.of(context).pop();
|
|
},
|
|
child: Text('Да'),
|
|
),
|
|
CupertinoDialogAction(
|
|
onPressed: () {
|
|
Navigator.pop(context);
|
|
},
|
|
isDefaultAction: true,
|
|
child: Text('Нет'),
|
|
)
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return BlocProvider<RegistrationCubit>(
|
|
create: (BuildContext context) => RegistrationCubit(),
|
|
child: BlocBuilder<RegistrationCubit, RegistrationState>(
|
|
builder: (BuildContext context, RegistrationState state) {
|
|
(state as RegistrationStateLoaded);
|
|
return PopScope(
|
|
canPop: false,
|
|
onPopInvoked: (_) => _showPopDialog(),
|
|
child: Scaffold(
|
|
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
|
|
floatingActionButton: Row(
|
|
children: [
|
|
Container(
|
|
height: 48,
|
|
width: MediaQuery.of(context).size.width * 0.2,
|
|
padding: EdgeInsets.only(left: 16, right: 4),
|
|
child: FloatingActionButton.extended(
|
|
heroTag: 'backButtonRegistration',
|
|
highlightElevation: 0,
|
|
elevation: 0,
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(16),
|
|
),
|
|
backgroundColor: Color(0xFFEAF2FD),
|
|
onPressed: () {
|
|
if (pageController.page == 0) _showPopDialog();
|
|
setState(() {
|
|
pageController.previousPage(
|
|
duration: const Duration(milliseconds: 350),
|
|
curve: Curves.easeInOut,
|
|
);
|
|
});
|
|
},
|
|
label: Icon(
|
|
Icons.arrow_back_ios_new_rounded,
|
|
color: appTheme.blueA400,
|
|
),
|
|
),
|
|
),
|
|
Container(
|
|
height: 48,
|
|
width: MediaQuery.of(context).size.width * 0.8,
|
|
padding: EdgeInsets.only(left: 4, right: 16),
|
|
child: FloatingActionButton.extended(
|
|
heroTag: 'nextButtonRegistration',
|
|
highlightElevation: 0,
|
|
elevation: 0,
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(16),
|
|
),
|
|
backgroundColor: appTheme.blueA400,
|
|
onPressed: () {
|
|
setState(() {
|
|
pageController.nextPage(
|
|
duration: const Duration(milliseconds: 350),
|
|
curve: Curves.easeInOut,
|
|
);
|
|
});
|
|
},
|
|
label: Text(
|
|
'Продолжить',
|
|
style: theme.textTheme.titleSmall,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
appBar: AppBar(
|
|
automaticallyImplyLeading: true,
|
|
centerTitle: true,
|
|
title: AppbarTitleImage(imagePath: ImageConstant.imgLogoEatvio),
|
|
actions: [
|
|
Padding(
|
|
padding: const EdgeInsets.only(right: 16),
|
|
child: Text('шаг $step из 15'),
|
|
),
|
|
],
|
|
bottom: PreferredSize(
|
|
preferredSize: Size(MediaQuery.of(context).size.width, 32),
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(16),
|
|
child: TweenAnimationBuilder<double>(
|
|
duration: const Duration(milliseconds: 350),
|
|
curve: Curves.easeInOut,
|
|
tween: Tween<double>(
|
|
begin: 0,
|
|
end: progressValue,
|
|
),
|
|
builder: (context, value, _) => LinearProgressIndicator(
|
|
value: value,
|
|
borderRadius: BorderRadius.circular(16),
|
|
minHeight: 8,
|
|
backgroundColor: Colors.grey.shade100,
|
|
valueColor: AlwaysStoppedAnimation<Color>(appTheme.blueA400),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
body: PageView(
|
|
physics: NeverScrollableScrollPhysics(),
|
|
controller: pageController,
|
|
onPageChanged: (index) {
|
|
setState(() {
|
|
step = index + 1;
|
|
progressValue = step / 15;
|
|
});
|
|
},
|
|
children: [
|
|
LanguageSelectScreen.builder(context),
|
|
CredentialsScreen.builder(context, state.sheet),
|
|
NameScreen.builder(context, state.sheet),
|
|
GenderScreen.builder(context, state.sheet),
|
|
DateOfBirthScreen.builder(context, state.sheet),
|
|
CityOfLivingScreen.builder(context, state.sheet),
|
|
BodyCircumferencesScreen.builder(context, state.sheet),
|
|
WeightScreen.builder(context, state.sheet),
|
|
HeightScreen.builder(context, state.sheet),
|
|
BloodPressureScreen.builder(context, state.sheet),
|
|
AllergiesScreen.builder(context, state.sheet),
|
|
MedicineIntakeScreen.builder(context, state.sheet),
|
|
FavoriteSportsScreen.builder(context, state.sheet),
|
|
FavoriteFoodsScreen.builder(context, state.sheet),
|
|
AdditionalInformationScreen.builder(context, state.sheet),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
}
|