forked from eatvio/eatvio_app
feature(registration): refactor i5
This commit is contained in:
@@ -1,10 +1,22 @@
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart';
|
||||
import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_state.dart';
|
||||
import 'package:eatvio_app/features/registration/repositories/registration_repository.dart';
|
||||
import 'package:eatvio_app/presentation/registration/language_select_screen/models/language_select_model.dart';
|
||||
|
||||
class RegistrationCubit extends Cubit<RegistrationState> {
|
||||
RegistrationCubit() : super(RegistrationState(sheet: LanguageSelectModel().userRegistrationSheet));
|
||||
final RegistrationRepository registrationRepository;
|
||||
|
||||
RegistrationCubit({required this.registrationRepository}) : super(RegistrationState(sheet: LanguageSelectModel().userRegistrationSheet));
|
||||
|
||||
updateSheet(UserRegistrationSheet sheet) => emit(RegistrationState(sheet: sheet));
|
||||
|
||||
tryRegistration() async {
|
||||
try {
|
||||
final response = await registrationRepository.tryRegister(state.sheet);
|
||||
print(response);
|
||||
} catch (e) {
|
||||
print(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
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/locator_service.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';
|
||||
@@ -62,7 +63,7 @@ class _RegistrationScreenState extends State<RegistrationScreen> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider<RegistrationCubit>(
|
||||
create: (BuildContext context) => RegistrationCubit(),
|
||||
create: (BuildContext context) => sl<RegistrationCubit>(),
|
||||
child: BlocBuilder<RegistrationCubit, RegistrationState>(
|
||||
builder: (BuildContext context, RegistrationState state) {
|
||||
return PopScope(
|
||||
@@ -275,6 +276,9 @@ class _RegistrationScreenState extends State<RegistrationScreen> {
|
||||
);
|
||||
return false;
|
||||
}
|
||||
case 15:
|
||||
context.read<RegistrationCubit>().tryRegistration();
|
||||
return true;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart';
|
||||
import 'package:eatvio_app/features/registration/services/registration_service.dart';
|
||||
|
||||
class RegistrationRepository {
|
||||
final RegistrationService registrationService;
|
||||
|
||||
RegistrationRepository({required this.registrationService});
|
||||
|
||||
tryRegister(UserRegistrationSheet sheet) async {
|
||||
try {
|
||||
return await registrationService.register(sheet: sheet);
|
||||
} catch (e) {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
}
|
||||
15
lib/features/registration/services/registration_service.dart
Normal file
15
lib/features/registration/services/registration_service.dart
Normal file
@@ -0,0 +1,15 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart';
|
||||
import 'package:retrofit/retrofit.dart';
|
||||
|
||||
part 'registration_service.g.dart';
|
||||
|
||||
@RestApi()
|
||||
abstract class RegistrationService {
|
||||
factory RegistrationService(Dio dio, {String baseUrl}) = _RegistrationService;
|
||||
|
||||
@POST('/register')
|
||||
Future<void> register({
|
||||
@Body() required UserRegistrationSheet sheet,
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'registration_service.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// RetrofitGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element
|
||||
|
||||
class _RegistrationService implements RegistrationService {
|
||||
_RegistrationService(
|
||||
this._dio, {
|
||||
this.baseUrl,
|
||||
});
|
||||
|
||||
final Dio _dio;
|
||||
|
||||
String? baseUrl;
|
||||
|
||||
@override
|
||||
Future<void> register({required UserRegistrationSheet sheet}) async {
|
||||
final _extra = <String, dynamic>{};
|
||||
final queryParameters = <String, dynamic>{};
|
||||
final _headers = <String, dynamic>{};
|
||||
final _data = sheet;
|
||||
await _dio.fetch<void>(_setStreamType<void>(Options(
|
||||
method: 'POST',
|
||||
headers: _headers,
|
||||
extra: _extra,
|
||||
)
|
||||
.compose(
|
||||
_dio.options,
|
||||
'/register',
|
||||
queryParameters: queryParameters,
|
||||
data: _data,
|
||||
)
|
||||
.copyWith(
|
||||
baseUrl: _combineBaseUrls(
|
||||
_dio.options.baseUrl,
|
||||
baseUrl,
|
||||
))));
|
||||
}
|
||||
|
||||
RequestOptions _setStreamType<T>(RequestOptions requestOptions) {
|
||||
if (T != dynamic &&
|
||||
!(requestOptions.responseType == ResponseType.bytes ||
|
||||
requestOptions.responseType == ResponseType.stream)) {
|
||||
if (T == String) {
|
||||
requestOptions.responseType = ResponseType.plain;
|
||||
} else {
|
||||
requestOptions.responseType = ResponseType.json;
|
||||
}
|
||||
}
|
||||
return requestOptions;
|
||||
}
|
||||
|
||||
String _combineBaseUrls(
|
||||
String dioBaseUrl,
|
||||
String? baseUrl,
|
||||
) {
|
||||
if (baseUrl == null || baseUrl.trim().isEmpty) {
|
||||
return dioBaseUrl;
|
||||
}
|
||||
|
||||
final url = Uri.parse(baseUrl);
|
||||
|
||||
if (url.isAbsolute) {
|
||||
return url.toString();
|
||||
}
|
||||
|
||||
return Uri.parse(dioBaseUrl).resolveUri(url).toString();
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,9 @@ import 'package:eatvio_app/features/chat/services/chat_service.dart';
|
||||
import 'package:eatvio_app/features/feed/presentation/bloc/feed_cubit/feed_cubit.dart';
|
||||
import 'package:eatvio_app/features/feed/repositories/feed_repository.dart';
|
||||
import 'package:eatvio_app/features/feed/services/feed_service.dart';
|
||||
import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart';
|
||||
import 'package:eatvio_app/features/registration/repositories/registration_repository.dart';
|
||||
import 'package:eatvio_app/features/registration/services/registration_service.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
|
||||
@@ -22,6 +25,7 @@ Future<void> init() async {
|
||||
sl.registerLazySingleton<NewMessagesCubit>(() => NewMessagesCubit());
|
||||
sl.registerLazySingleton<NotificationsCubit>(() => NotificationsCubit());
|
||||
|
||||
sl.registerFactory<RegistrationCubit>(() => RegistrationCubit(registrationRepository: sl()));
|
||||
sl.registerFactory<ChatRoomCubit>(() => ChatRoomCubit(chatRepository: sl(), initializationCubit: sl()));
|
||||
sl.registerFactory<FeedCubit>(() => FeedCubit(feedRepository: sl()));
|
||||
sl.registerFactory<BlogPostCubit>(() => BlogPostCubit(blogPostRepository: sl()));
|
||||
@@ -30,11 +34,13 @@ Future<void> init() async {
|
||||
sl.registerLazySingleton<ChatRepository>(() => ChatRepository(chatService: sl()));
|
||||
sl.registerLazySingleton<FeedRepository>(() => FeedRepository(feedService: sl()));
|
||||
sl.registerLazySingleton<BlogPostRepository>(() => BlogPostRepository(blogPostService: sl()));
|
||||
sl.registerLazySingleton<RegistrationRepository>(() => RegistrationRepository(registrationService: sl()));
|
||||
|
||||
// Services
|
||||
sl.registerLazySingleton<ChatService>(() => ChatService(sl()));
|
||||
sl.registerLazySingleton<FeedService>(() => FeedService(sl()));
|
||||
sl.registerLazySingleton<BlogPostService>(() => BlogPostService(sl()));
|
||||
sl.registerLazySingleton<RegistrationService>(() => RegistrationService(sl()));
|
||||
|
||||
// External
|
||||
sl.registerLazySingleton(
|
||||
|
||||
@@ -1,14 +1,8 @@
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import 'bloc/additional_information_bloc.dart';
|
||||
import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart';
|
||||
import 'package:eatvio_app/core/app_export.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_dotenv/flutter_dotenv.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'dart:convert';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
class AdditionalInformationScreen extends StatefulWidget {
|
||||
final UserRegistrationSheet sheet;
|
||||
@@ -20,6 +14,14 @@ class AdditionalInformationScreen extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _AdditionalInformationScreenState extends State<AdditionalInformationScreen> {
|
||||
final editTextController = TextEditingController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
editTextController.text = widget.sheet.additionalInfo;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SingleChildScrollView(
|
||||
@@ -29,117 +31,31 @@ class _AdditionalInformationScreenState extends State<AdditionalInformationScree
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v),
|
||||
child: Column(
|
||||
children: [
|
||||
_buildTextFormField(context),
|
||||
// BlocBuilder<AdditionalInformationBloc, AdditionalInformationState>(
|
||||
// builder: (context, state) {
|
||||
// return NextStepButton(
|
||||
// text: "finish".tr.toUpperCase(),
|
||||
// margin: EdgeInsets.only(left: 16.h, right: 16.h, bottom: 50.v),
|
||||
// buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
|
||||
// onPressed: onTapFinish(state, context),
|
||||
// );
|
||||
// },
|
||||
// ),
|
||||
Container(
|
||||
width: 294.h,
|
||||
margin: EdgeInsets.only(left: 24.h, right: 23.h),
|
||||
child: Text(
|
||||
"enter_additional_information".tr,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.center,
|
||||
style: CustomTextStyles.titleMediumSegoeUI,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 10.v),
|
||||
CustomTextFormField(
|
||||
controller: editTextController,
|
||||
hintText: "У меня крепкое здоровье, но последнее время часто утомляюсь, однако, это мне не мешает радоваться жизни",
|
||||
textInputAction: TextInputAction.done,
|
||||
maxLines: 8,
|
||||
onChanged: (newValue) {
|
||||
final registrationCubit = context.read<RegistrationCubit>();
|
||||
registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(additionalInfo: newValue));
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
onTapFinish(AdditionalInformationState state, BuildContext context) {
|
||||
return () async {
|
||||
UserRegistrationSheet sheet = state.additionalInformationModelObj!.userRegistrationSheet;
|
||||
// sheet.additionalInfo = state.editTextController!.text;
|
||||
|
||||
final response = await http.post(
|
||||
Uri.parse(dotenv.env['SERVER_ROOT']! + '/register'),
|
||||
headers: {'Content-Type': 'application/json', 'Accept': 'application/json'},
|
||||
body: jsonEncode(sheet.toJson()),
|
||||
encoding: utf8,
|
||||
);
|
||||
|
||||
var res = await jsonDecode(response.body);
|
||||
if (response.statusCode == 200) {
|
||||
final box = await Hive.openBox('token');
|
||||
final token = res['token'];
|
||||
box.put('token', token);
|
||||
GoRouter.of(context).goNamed('myProfileScreen');
|
||||
} else {
|
||||
showErrorMessage(context, res['message']);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
onTapBack(BuildContext context) {
|
||||
return () {
|
||||
onTapArrowLeft(context);
|
||||
};
|
||||
}
|
||||
|
||||
/// Section Widget
|
||||
_buildTextFormField(BuildContext context) {
|
||||
return SizedBox(
|
||||
width: 343.h,
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
Align(
|
||||
alignment: Alignment.center,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
width: 294.h,
|
||||
margin: EdgeInsets.only(left: 24.h, right: 23.h),
|
||||
child: Text(
|
||||
"enter_additional_information".tr,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.center,
|
||||
style: CustomTextStyles.titleMediumSegoeUI,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 10.v),
|
||||
BlocSelector<AdditionalInformationBloc, AdditionalInformationState, TextEditingController?>(
|
||||
selector: (state) => state.editTextController,
|
||||
builder: (context, editTextController) {
|
||||
return CustomTextFormField(
|
||||
controller: editTextController,
|
||||
hintText: "У меня крепкое здоровье, но последнее время часто утомляюсь, однако, это мне не мешает радоваться жизни",
|
||||
textInputAction: TextInputAction.done,
|
||||
maxLines: 8,
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Navigates to the previous screen.
|
||||
onTapArrowLeft(BuildContext context) {
|
||||
GoRouter.of(context).pop();
|
||||
}
|
||||
|
||||
/// Displays an alert dialog when the action is triggered.
|
||||
/// The dialog box contains a title and a message with the `Теперь вы можете пользоваться полным функционалом приложения`
|
||||
showErrorMessage(BuildContext context, String text) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (_) => AlertDialog(
|
||||
title: const Text('Ошибка'),
|
||||
content: Text(text),
|
||||
actions: [TextButton(onPressed: onTapOk(context), child: const Text('Ok'))],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
onTapOk(BuildContext context) {
|
||||
return () {
|
||||
Navigator.pop(context);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import 'bloc/allergies_bloc.dart';
|
||||
// ignore: unused_import
|
||||
import 'models/allergies_model.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart';
|
||||
import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart';
|
||||
import 'package:eatvio_app/widgets/custom_text_form_field.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@@ -18,6 +14,14 @@ class AllergiesScreen extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _AllergiesScreenState extends State<AllergiesScreen> {
|
||||
final enterInformationController = TextEditingController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
enterInformationController.text = widget.sheet.aboutAllergy;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SingleChildScrollView(
|
||||
@@ -29,75 +33,21 @@ class _AllergiesScreenState extends State<AllergiesScreen> {
|
||||
children: [
|
||||
Text("allergies_presence".tr, style: theme.textTheme.headlineSmall),
|
||||
SizedBox(height: 22.v),
|
||||
_buildTextFormField(context),
|
||||
// BlocBuilder<AllergiesBloc, AllergiesState>(
|
||||
// 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: onTapContinue(state, context),
|
||||
// );
|
||||
// },
|
||||
// ),
|
||||
// BlocBuilder<AllergiesBloc, AllergiesState>(
|
||||
// builder: (context, state) {
|
||||
// return GestureDetector(
|
||||
// onTap: onTapSkip(state, context),
|
||||
// child: Text("skip".tr, style: theme.textTheme.bodyLarge),
|
||||
// );
|
||||
// },
|
||||
// ),
|
||||
Text("fill_in_information".tr, style: CustomTextStyles.titleMediumSegoeUI),
|
||||
SizedBox(height: 2.v),
|
||||
CustomTextFormField(
|
||||
controller: enterInformationController,
|
||||
hintText: "enter_information".tr,
|
||||
textInputAction: TextInputAction.done,
|
||||
maxLines: 8,
|
||||
onChanged: (newValue) {
|
||||
final registrationCubit = context.read<RegistrationCubit>();
|
||||
registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(aboutAllergy: newValue));
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
onTapSkip(AllergiesState state, BuildContext context) {
|
||||
return () {
|
||||
UserRegistrationSheet sheet = state.allergiesModelObj!.userRegistrationSheet;
|
||||
GoRouter.of(context).goNamed('medicineIntakeScreen', extra: sheet);
|
||||
};
|
||||
}
|
||||
|
||||
onTapContinue(AllergiesState state, BuildContext context) {
|
||||
return () {
|
||||
UserRegistrationSheet sheet = state.allergiesModelObj!.userRegistrationSheet;
|
||||
// sheet.aboutAllergy = state.enterInformationController!.text;
|
||||
GoRouter.of(context).goNamed('medicineIntakeScreen', extra: sheet);
|
||||
};
|
||||
}
|
||||
|
||||
onTapBack(BuildContext context) {
|
||||
return () {
|
||||
onTapArrowLeft(context);
|
||||
};
|
||||
}
|
||||
|
||||
/// Section Widget
|
||||
_buildTextFormField(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
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,
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// Navigates to the previous screen.
|
||||
onTapArrowLeft(BuildContext context) {
|
||||
GoRouter.of(context).pop();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,9 @@ import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '/core/app_export.dart';
|
||||
import 'package:eatvio_app/presentation/registration/blood_pressure_screen/models/blood_pressure_model.dart';
|
||||
|
||||
part 'blood_pressure_event.dart';
|
||||
|
||||
part 'blood_pressure_state.dart';
|
||||
|
||||
/// A bloc that manages the state of a BloodPressure according to the event that is dispatched to it.
|
||||
@@ -43,7 +45,11 @@ class BloodPressureBloc extends Bloc<BloodPressureEvent, BloodPressureState> {
|
||||
id: 1,
|
||||
title: "Да",
|
||||
),
|
||||
SelectionPopupModel(id: 2, title: "Нет", isSelected: true),
|
||||
SelectionPopupModel(
|
||||
id: 2,
|
||||
title: "Нет",
|
||||
isSelected: true,
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -51,11 +57,16 @@ class BloodPressureBloc extends Bloc<BloodPressureEvent, BloodPressureState> {
|
||||
BloodPressureInitialEvent event,
|
||||
Emitter<BloodPressureState> emit,
|
||||
) async {
|
||||
emit(state.copyWith(
|
||||
emit(
|
||||
state.copyWith(
|
||||
upPressureController: TextEditingController(),
|
||||
downPressureController: TextEditingController(),),);
|
||||
emit(state.copyWith(
|
||||
bloodPressureModelObj: state.bloodPressureModelObj
|
||||
?.copyWith(dropdownItemList: fillDropdownItemList()),),);
|
||||
downPressureController: TextEditingController(),
|
||||
),
|
||||
);
|
||||
emit(
|
||||
state.copyWith(
|
||||
bloodPressureModelObj: state.bloodPressureModelObj?.copyWith(dropdownItemList: fillDropdownItemList()),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
import 'package:eatvio_app/app_router.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import 'bloc/blood_pressure_bloc.dart';
|
||||
import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'models/blood_pressure_model.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:eatvio_app/widgets/custom_drop_down.dart';
|
||||
import 'package:eatvio_app/widgets/custom_text_form_field.dart';
|
||||
@@ -20,210 +16,147 @@ class BloodPressureScreen extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _BloodPressureScreenState extends State<BloodPressureScreen> {
|
||||
final List<SelectionPopupModel> selectionPopupList = [
|
||||
SelectionPopupModel(
|
||||
id: 1,
|
||||
title: "Да",
|
||||
),
|
||||
SelectionPopupModel(
|
||||
id: 2,
|
||||
title: "Нет",
|
||||
),
|
||||
];
|
||||
|
||||
late SelectionPopupModel selectedPopupHypo;
|
||||
late SelectionPopupModel selectedPopupHyper;
|
||||
|
||||
final digitsOnly = FilteringTextInputFormatter.digitsOnly;
|
||||
final upPressureController = TextEditingController();
|
||||
final downPressureController = TextEditingController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
selectedPopupHypo = selectionPopupList[1];
|
||||
selectedPopupHyper = selectionPopupList[1];
|
||||
upPressureController.text = widget.sheet.bloodPressureUp;
|
||||
downPressureController.text = widget.sheet.bloodPressureDown;
|
||||
if (widget.sheet.hasHyper.isNotEmpty) {
|
||||
widget.sheet.hasHyper == 'Да' ? selectedPopupHyper = selectionPopupList[0] : selectedPopupHyper = selectionPopupList[1];
|
||||
}
|
||||
if (widget.sheet.hasHypo.isNotEmpty) {
|
||||
widget.sheet.hasHypo == 'Да' ? selectedPopupHypo = selectionPopupList[0] : selectedPopupHypo = selectionPopupList[1];
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SingleChildScrollView(
|
||||
padding: EdgeInsets.only(bottom: 80),
|
||||
child: Container(
|
||||
width: double.maxFinite,
|
||||
padding: EdgeInsets.symmetric(horizontal: 12.h, vertical: 9.v),
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 224.h,
|
||||
child: Text(
|
||||
"your_blood_pressure".tr,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.center,
|
||||
style: theme.textTheme.headlineSmall,
|
||||
),
|
||||
width: double.maxFinite,
|
||||
padding: EdgeInsets.symmetric(horizontal: 12.h, vertical: 9.v),
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 224.h,
|
||||
child: Text(
|
||||
"your_blood_pressure".tr,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.center,
|
||||
style: theme.textTheme.headlineSmall,
|
||||
),
|
||||
SizedBox(height: 21.v),
|
||||
Container(
|
||||
margin: EdgeInsets.only(right: 1.h),
|
||||
padding: EdgeInsets.symmetric(horizontal: 3.h),
|
||||
child: Column(
|
||||
children: [
|
||||
Text("up_pressure".tr, style: theme.textTheme.bodyLarge),
|
||||
SizedBox(height: 2.v),
|
||||
BlocSelector<BloodPressureBloc, BloodPressureState, TextEditingController?>(
|
||||
selector: (state) => state.upPressureController,
|
||||
builder: (context, upPressureController) {
|
||||
return CustomTextFormField(inputFormatters: [digitsOnly], controller: upPressureController, hintText: "90".tr);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: 21.v),
|
||||
Container(
|
||||
margin: EdgeInsets.only(right: 1.h),
|
||||
padding: EdgeInsets.symmetric(horizontal: 3.h),
|
||||
child: Column(
|
||||
children: [
|
||||
Text("up_pressure".tr, style: theme.textTheme.bodyLarge),
|
||||
SizedBox(height: 2.v),
|
||||
CustomTextFormField(
|
||||
inputFormatters: [digitsOnly],
|
||||
controller: upPressureController,
|
||||
hintText: "90".tr,
|
||||
onChanged: (newValue) {
|
||||
final registrationCubit = context.read<RegistrationCubit>();
|
||||
registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(bloodPressureUp: newValue));
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 21.v),
|
||||
Container(
|
||||
margin: EdgeInsets.only(right: 1.h),
|
||||
padding: EdgeInsets.symmetric(horizontal: 3.h),
|
||||
child: Column(
|
||||
children: [
|
||||
Text("down_pressure".tr, style: theme.textTheme.bodyLarge),
|
||||
SizedBox(height: 2.v),
|
||||
BlocSelector<BloodPressureBloc, BloodPressureState, TextEditingController?>(
|
||||
selector: (state) => state.downPressureController,
|
||||
builder: (context, downPressureController) {
|
||||
return CustomTextFormField(inputFormatters: [digitsOnly], controller: downPressureController, hintText: "90".tr);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: 21.v),
|
||||
Container(
|
||||
margin: EdgeInsets.only(right: 1.h),
|
||||
padding: EdgeInsets.symmetric(horizontal: 3.h),
|
||||
child: Column(
|
||||
children: [
|
||||
Text("down_pressure".tr, style: theme.textTheme.bodyLarge),
|
||||
SizedBox(height: 2.v),
|
||||
CustomTextFormField(
|
||||
inputFormatters: [digitsOnly],
|
||||
controller: downPressureController,
|
||||
hintText: "90".tr,
|
||||
onChanged: (newValue) {
|
||||
final registrationCubit = context.read<RegistrationCubit>();
|
||||
registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(bloodPressureDown: newValue));
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 22.v),
|
||||
Text("do_you_have_hypotension_tendency".tr, style: theme.textTheme.bodyLarge),
|
||||
SizedBox(height: 2.v),
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 4.h),
|
||||
child: BlocSelector<BloodPressureBloc, BloodPressureState, BloodPressureModel?>(
|
||||
selector: (state) => state.bloodPressureModelObj,
|
||||
builder: (context, bloodPressureModelObj) {
|
||||
return CustomDropDown(
|
||||
icon: Container(
|
||||
margin: EdgeInsets.fromLTRB(30.h, 11.v, 13.h, 11.v),
|
||||
decoration: BoxDecoration(borderRadius: BorderRadius.circular(1.h)),
|
||||
child: CustomImageView(imagePath: ImageConstant.imgFavorite, height: 12.adaptSize, width: 12.adaptSize),
|
||||
),
|
||||
hintText: "Не выбрано".tr,
|
||||
items: bloodPressureModelObj?.dropdownItemList ?? [],
|
||||
onChanged: onChangeHyper(context),
|
||||
);
|
||||
},
|
||||
),
|
||||
SizedBox(height: 22.v),
|
||||
Text("do_you_have_hypotension_tendency".tr, style: theme.textTheme.bodyLarge),
|
||||
SizedBox(height: 2.v),
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 4.h),
|
||||
child: CustomDropDown(
|
||||
icon: Container(
|
||||
margin: EdgeInsets.fromLTRB(30.h, 11.v, 13.h, 11.v),
|
||||
decoration: BoxDecoration(borderRadius: BorderRadius.circular(1.h)),
|
||||
child: CustomImageView(imagePath: ImageConstant.imgFavorite, height: 12.adaptSize, width: 12.adaptSize),
|
||||
),
|
||||
hintText: "Не выбрано".tr,
|
||||
items: selectionPopupList,
|
||||
value: selectedPopupHypo,
|
||||
onChanged: (newPopup) {
|
||||
setState(() {
|
||||
selectedPopupHypo = newPopup;
|
||||
final registrationCubit = context.read<RegistrationCubit>();
|
||||
registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(hasHypo: selectedPopupHypo.title));
|
||||
});
|
||||
},
|
||||
),
|
||||
SizedBox(height: 22.v),
|
||||
Text("do_you_have_hypertension_tendency".tr, style: theme.textTheme.bodyLarge),
|
||||
SizedBox(height: 2.v),
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 4.h),
|
||||
child: BlocSelector<BloodPressureBloc, BloodPressureState, BloodPressureModel?>(
|
||||
selector: (state) => state.bloodPressureModelObj,
|
||||
builder: (context, bloodPressureModelObj) {
|
||||
return CustomDropDown(
|
||||
icon: Container(
|
||||
margin: EdgeInsets.fromLTRB(30.h, 11.v, 13.h, 11.v),
|
||||
decoration: BoxDecoration(borderRadius: BorderRadius.circular(1.h)),
|
||||
child: CustomImageView(imagePath: ImageConstant.imgFavorite, height: 12.adaptSize, width: 12.adaptSize),
|
||||
),
|
||||
hintText: "Не выбрано".tr,
|
||||
items: bloodPressureModelObj?.dropdownItemList ?? [],
|
||||
onChanged: onChangeHypo(context),
|
||||
);
|
||||
},
|
||||
),
|
||||
SizedBox(height: 22.v),
|
||||
Text("do_you_have_hypertension_tendency".tr, style: theme.textTheme.bodyLarge),
|
||||
SizedBox(height: 2.v),
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 4.h),
|
||||
child: CustomDropDown(
|
||||
icon: Container(
|
||||
margin: EdgeInsets.fromLTRB(30.h, 11.v, 13.h, 11.v),
|
||||
decoration: BoxDecoration(borderRadius: BorderRadius.circular(1.h)),
|
||||
child: CustomImageView(imagePath: ImageConstant.imgFavorite, height: 12.adaptSize, width: 12.adaptSize),
|
||||
),
|
||||
hintText: "Не выбрано".tr,
|
||||
items: selectionPopupList,
|
||||
value: selectedPopupHyper,
|
||||
onChanged: (newPopup) {
|
||||
setState(() {
|
||||
selectedPopupHyper = newPopup;
|
||||
final registrationCubit = context.read<RegistrationCubit>();
|
||||
registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(hasHyper: selectedPopupHyper.title));
|
||||
});
|
||||
},
|
||||
),
|
||||
// BlocBuilder<BloodPressureBloc, BloodPressureState>(
|
||||
// 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: onTapContinue(state, context),
|
||||
// );
|
||||
// },
|
||||
// ),
|
||||
// BlocBuilder<BloodPressureBloc, BloodPressureState>(
|
||||
// builder: (context, state) {
|
||||
// return GestureDetector(
|
||||
// onTap: onTapSkip(state, context),
|
||||
// child: Text("skip".tr, style: theme.textTheme.bodyLarge),
|
||||
// );
|
||||
// },
|
||||
// ),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
onTapSkip(BloodPressureState state, BuildContext context) {
|
||||
return () {
|
||||
UserRegistrationSheet sheet = state.bloodPressureModelObj!.userRegistrationSheet;
|
||||
AppRouter.navigatorKey.currentContext?.goNamed('allergiesScreen', extra: sheet);
|
||||
};
|
||||
}
|
||||
|
||||
onTapContinue(BloodPressureState state, BuildContext context) {
|
||||
return () {
|
||||
List<String> errors = validateFields(state.upPressureController!.text, state.downPressureController!.text);
|
||||
if (errors.isEmpty) {
|
||||
UserRegistrationSheet sheet = state.bloodPressureModelObj!.userRegistrationSheet;
|
||||
// sheet.bloodPressureUp = state.upPressureController!.text;
|
||||
// sheet.bloodPressureDown = state.downPressureController!.text;
|
||||
AppRouter.navigatorKey.currentContext?.goNamed('allergiesScreen', extra: sheet);
|
||||
} else {
|
||||
String errorMessage = '';
|
||||
|
||||
for (var error in errors) {
|
||||
errorMessage += error + '\n\n';
|
||||
}
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: Text('Ошибка'),
|
||||
content: Text(errorMessage),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: onTapOK(context),
|
||||
child: Text('OK'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
onTapOK(BuildContext context) {
|
||||
return () {
|
||||
Navigator.pop(context);
|
||||
};
|
||||
}
|
||||
|
||||
onChangeHypo(BuildContext context) {
|
||||
return (value) {
|
||||
context.read<BloodPressureBloc>().add(ChangeHyperDropDownEvent(value: value));
|
||||
};
|
||||
}
|
||||
|
||||
onChangeHyper(BuildContext context) {
|
||||
return (value) {
|
||||
context.read<BloodPressureBloc>().add(ChangeHypoDownEvent(value: value));
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Function onTapBack(BuildContext context) {
|
||||
return () {
|
||||
onTapArrowLeft(context);
|
||||
};
|
||||
}
|
||||
|
||||
/// Navigates to the previous screen.
|
||||
onTapArrowLeft(BuildContext context) {
|
||||
GoRouter.of(context).pop();
|
||||
}
|
||||
|
||||
List<String> validateFields(
|
||||
String bloodPressureUp,
|
||||
String bloodPressureDown,
|
||||
) {
|
||||
List<String> errors = [];
|
||||
|
||||
if (bloodPressureUp.isEmpty | bloodPressureDown.isEmpty) {
|
||||
errors.add('pressure_empty'.tr);
|
||||
}
|
||||
|
||||
if (![bloodPressureUp, bloodPressureDown].every((pressure) => int.tryParse(pressure) != null)) {
|
||||
errors.add('pressure_is_not_a_number'.tr);
|
||||
}
|
||||
|
||||
return errors;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import 'bloc/favorite_foods_bloc.dart';
|
||||
import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart';
|
||||
import 'package:eatvio_app/widgets/custom_text_form_field.dart';
|
||||
@@ -16,6 +14,16 @@ class FavoriteFoodsScreen extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _FavoriteFoodsScreenState extends State<FavoriteFoodsScreen> {
|
||||
final favoriteFoodsController = TextEditingController();
|
||||
final unFavoriteFoodsController = TextEditingController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
favoriteFoodsController.text = widget.sheet.favoriteFoods;
|
||||
unFavoriteFoodsController.text = widget.sheet.unfavoriteFoods;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SingleChildScrollView(
|
||||
@@ -37,100 +45,33 @@ class _FavoriteFoodsScreenState extends State<FavoriteFoodsScreen> {
|
||||
),
|
||||
),
|
||||
SizedBox(height: 13.v),
|
||||
_buildTextFormFieldFav(context),
|
||||
Text("favorite_foods".tr, style: CustomTextStyles.titleMediumSegoeUI),
|
||||
SizedBox(height: 2.v),
|
||||
CustomTextFormField(
|
||||
controller: favoriteFoodsController,
|
||||
hintText: "enter_information".tr,
|
||||
maxLines: 7,
|
||||
onChanged: (newValue) {
|
||||
final registrationCubit = context.read<RegistrationCubit>();
|
||||
registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(favoriteFoods: newValue));
|
||||
},
|
||||
),
|
||||
SizedBox(height: 12.v),
|
||||
_buildTextFormFieldUnfav(context),
|
||||
// BlocBuilder<FavoriteFoodsBloc, FavoriteFoodsState>(
|
||||
// builder: (context, state) {
|
||||
// return NextStepButton(
|
||||
// text: "continue".tr.toUpperCase(),
|
||||
// margin: EdgeInsets.only(left: 16.h, right: 16.h, bottom: 40.v),
|
||||
// buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
|
||||
// onPressed: onTapContinue(state, context),
|
||||
// );
|
||||
// },
|
||||
// ),
|
||||
// BlocBuilder<FavoriteFoodsBloc, FavoriteFoodsState>(
|
||||
// builder: (context, state) {
|
||||
// return GestureDetector(
|
||||
// onTap: onTapSkip(state, context),
|
||||
// child: Text("skip".tr, style: theme.textTheme.bodyLarge),
|
||||
// );
|
||||
// },
|
||||
// ),
|
||||
Text("unfavorite_foods".tr, style: CustomTextStyles.titleMediumSegoeUI),
|
||||
SizedBox(height: 2.v),
|
||||
CustomTextFormField(
|
||||
controller: unFavoriteFoodsController,
|
||||
hintText: "enter_information".tr,
|
||||
textInputAction: TextInputAction.done,
|
||||
maxLines: 7,
|
||||
onChanged: (newValue) {
|
||||
final registrationCubit = context.read<RegistrationCubit>();
|
||||
registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(unfavoriteFoods: newValue));
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
onTapSkip(FavoriteFoodsState state, BuildContext context) {
|
||||
return () {
|
||||
UserRegistrationSheet sheet = state.favoriteFoodsModelObj!.userRegistrationSheet;
|
||||
GoRouter.of(context).goNamed('additionalInformationScreen', extra: sheet);
|
||||
};
|
||||
}
|
||||
|
||||
onTapContinue(FavoriteFoodsState state, BuildContext context) {
|
||||
return () {
|
||||
UserRegistrationSheet sheet = state.favoriteFoodsModelObj!.userRegistrationSheet;
|
||||
// sheet.favoriteFoods = state.favoriteFoodsController!.text;
|
||||
// sheet.unfavoriteFoods = state.unfavoriteFoodsController!.text;
|
||||
GoRouter.of(context).goNamed('additionalInformationScreen', extra: sheet);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Function onTapBack(BuildContext context) {
|
||||
return () {
|
||||
onTapArrowLeft(context);
|
||||
};
|
||||
}
|
||||
|
||||
/// Section Widget
|
||||
_buildTextFormFieldFav(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
Text("favorite_foods".tr, style: CustomTextStyles.titleMediumSegoeUI),
|
||||
SizedBox(height: 2.v),
|
||||
BlocSelector<FavoriteFoodsBloc, FavoriteFoodsState, TextEditingController?>(
|
||||
selector: (state) => state.favoriteFoodsController,
|
||||
builder: (context, favoriteFoodsController) {
|
||||
return CustomTextFormField(controller: favoriteFoodsController, hintText: "enter_information".tr, maxLines: 7);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// Section Widget
|
||||
_buildTextFormFieldUnfav(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
Text("unfavorite_foods".tr, style: CustomTextStyles.titleMediumSegoeUI),
|
||||
SizedBox(height: 2.v),
|
||||
BlocSelector<FavoriteFoodsBloc, FavoriteFoodsState, TextEditingController?>(
|
||||
selector: (state) => state.unfavoriteFoodsController,
|
||||
builder: (context, unfavoriteFoodsController) {
|
||||
return CustomTextFormField(
|
||||
controller: unfavoriteFoodsController,
|
||||
hintText: "enter_information".tr,
|
||||
textInputAction: TextInputAction.done,
|
||||
maxLines: 7,
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// Navigates to the previous screen.
|
||||
onTapArrowLeft(BuildContext context) {
|
||||
GoRouter.of(context).pop();
|
||||
}
|
||||
|
||||
/// Navigates to the scheduleScreen when the action is triggered.
|
||||
navigateToAdditionalInformationScreen(BuildContext context) {
|
||||
GoRouter.of(context).goNamed('additionalInformationScreen');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import 'bloc/favorite_sports_bloc.dart';
|
||||
// ignore: unused_import
|
||||
import 'models/favorite_sports_model.dart';
|
||||
import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart';
|
||||
import 'package:eatvio_app/widgets/custom_text_form_field.dart';
|
||||
@@ -18,6 +14,14 @@ class FavoriteSportsScreen extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _FavoriteSportsScreenState extends State<FavoriteSportsScreen> {
|
||||
final enterInformationController = TextEditingController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
enterInformationController.text = widget.sheet.aboutSportHobbies;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SingleChildScrollView(
|
||||
@@ -30,76 +34,21 @@ class _FavoriteSportsScreenState extends State<FavoriteSportsScreen> {
|
||||
children: [
|
||||
Text("your_favorite_sports".tr, style: theme.textTheme.headlineSmall),
|
||||
SizedBox(height: 22.v),
|
||||
_buildTextFormFieldSection(context),
|
||||
// BlocBuilder<FavoriteSportsBloc, FavoriteSportsState>(
|
||||
// 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: onTapContinue(state, context),
|
||||
// );
|
||||
// },
|
||||
// ),
|
||||
// BlocBuilder<FavoriteSportsBloc, FavoriteSportsState>(
|
||||
// builder: (context, state) {
|
||||
// return GestureDetector(
|
||||
// onTap: onTapSkip(state, context),
|
||||
// child: Text("skip".tr, style: theme.textTheme.bodyLarge),
|
||||
// );
|
||||
// },
|
||||
// ),
|
||||
Text("fill_in_information".tr, style: CustomTextStyles.titleMediumSegoeUI),
|
||||
SizedBox(height: 2.v),
|
||||
CustomTextFormField(
|
||||
controller: enterInformationController,
|
||||
hintText: "Я занимаюсь плаванием , почти каждый вечер прогулки на свежем воздухе, пару раз в месяц играю в волейбол. Стараюсь не сидеть на месте!",
|
||||
textInputAction: TextInputAction.done,
|
||||
maxLines: 8,
|
||||
onChanged: (newValue) {
|
||||
final registrationCubit = context.read<RegistrationCubit>();
|
||||
registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(aboutSportHobbies: newValue));
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
onTapSkip(FavoriteSportsState state, BuildContext context) {
|
||||
return () {
|
||||
UserRegistrationSheet sheet = state.favoriteSportsModelObj!.userRegistrationSheet;
|
||||
GoRouter.of(context).goNamed('favoriteFoodsScreen', extra: sheet);
|
||||
};
|
||||
}
|
||||
|
||||
onTapContinue(FavoriteSportsState state, BuildContext context) {
|
||||
return () {
|
||||
UserRegistrationSheet sheet = state.favoriteSportsModelObj!.userRegistrationSheet;
|
||||
// sheet.aboutSportHobbies = state.enterinformationController!.text;
|
||||
GoRouter.of(context).goNamed('favoriteFoodsScreen', extra: sheet);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Function onTapBack(BuildContext context) {
|
||||
return () {
|
||||
onTapArrowLeft(context);
|
||||
};
|
||||
}
|
||||
|
||||
/// Section Widget
|
||||
_buildTextFormFieldSection(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
Text("fill_in_information".tr, style: CustomTextStyles.titleMediumSegoeUI),
|
||||
SizedBox(height: 2.v),
|
||||
BlocSelector<FavoriteSportsBloc, FavoriteSportsState, TextEditingController?>(
|
||||
selector: (state) => state.enterinformationController,
|
||||
builder: (context, enterinformationController) {
|
||||
return CustomTextFormField(
|
||||
controller: enterinformationController,
|
||||
hintText:
|
||||
"Я занимаюсь плаванием , почти каждый вечер прогулки на свежем воздухе, пару раз в месяц играю в волейбол. Стараюсь не сидеть на месте!",
|
||||
textInputAction: TextInputAction.done,
|
||||
maxLines: 8,
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
onTapArrowLeft(BuildContext context) {
|
||||
GoRouter.of(context).pop();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import 'bloc/height_bloc.dart';
|
||||
import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:eatvio_app/widgets/custom_text_form_field.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
@@ -17,6 +15,14 @@ class HeightScreen extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _HeightScreenState extends State<HeightScreen> {
|
||||
final heightController = TextEditingController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
heightController.text = widget.sheet.height;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SingleChildScrollView(
|
||||
@@ -38,17 +44,17 @@ class _HeightScreenState extends State<HeightScreen> {
|
||||
style: theme.textTheme.bodyLarge,
|
||||
),
|
||||
SizedBox(height: 4.v),
|
||||
BlocBuilder<HeightBloc, HeightState>(
|
||||
builder: (context, state) {
|
||||
return CustomTextFormField(
|
||||
width: 150.h,
|
||||
textInputAction: TextInputAction.done,
|
||||
controller: state.heightController,
|
||||
keyboardType: TextInputType.number,
|
||||
inputFormatters: <TextInputFormatter>[
|
||||
FilteringTextInputFormatter.digitsOnly,
|
||||
],
|
||||
);
|
||||
CustomTextFormField(
|
||||
width: 150.h,
|
||||
textInputAction: TextInputAction.done,
|
||||
controller: heightController,
|
||||
keyboardType: TextInputType.number,
|
||||
inputFormatters: <TextInputFormatter>[
|
||||
FilteringTextInputFormatter.digitsOnly,
|
||||
],
|
||||
onChanged: (newValue) {
|
||||
final registrationCubit = context.read<RegistrationCubit>();
|
||||
registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(height: newValue));
|
||||
},
|
||||
),
|
||||
],
|
||||
@@ -58,22 +64,4 @@ class _HeightScreenState extends State<HeightScreen> {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
onTapNext(HeightState state, BuildContext context) {
|
||||
return () {
|
||||
UserRegistrationSheet sheet = state.heightModelObj!.userRegistrationSheet;
|
||||
GoRouter.of(context).goNamed('bloodPressureScreen', extra: sheet);
|
||||
};
|
||||
}
|
||||
|
||||
Function onTapBack(BuildContext context) {
|
||||
return () {
|
||||
onTapArrowLeft(context);
|
||||
};
|
||||
}
|
||||
|
||||
/// Navigates to the previous screen.
|
||||
onTapArrowLeft(BuildContext context) {
|
||||
GoRouter.of(context).pop();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import 'bloc/medicine_intake_bloc.dart';
|
||||
import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:eatvio_app/widgets/custom_text_form_field.dart';
|
||||
import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart';
|
||||
@@ -16,6 +14,14 @@ class MedicineIntakeScreen extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _MedicineIntakeScreenState extends State<MedicineIntakeScreen> {
|
||||
final enterInformationController = TextEditingController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
enterInformationController.text = widget.sheet.aboutTakingPils;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SingleChildScrollView(
|
||||
@@ -36,83 +42,22 @@ class _MedicineIntakeScreenState extends State<MedicineIntakeScreen> {
|
||||
style: theme.textTheme.headlineSmall,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 86.v),
|
||||
_buildTextFormField(context),
|
||||
// BlocBuilder<MedicineIntakeBloc, MedicineIntakeState>(
|
||||
// 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),
|
||||
// );
|
||||
// },
|
||||
// ),
|
||||
// BlocBuilder<MedicineIntakeBloc, MedicineIntakeState>(
|
||||
// builder: (context, state) {
|
||||
// return GestureDetector(
|
||||
// onTap: onTapSkip(state, context),
|
||||
// child: Text("skip".tr, style: theme.textTheme.bodyLarge),
|
||||
// );
|
||||
// },
|
||||
// ),
|
||||
SizedBox(height: 16.v),
|
||||
Text("fill_in_information".tr, style: CustomTextStyles.titleMediumSegoeUI),
|
||||
SizedBox(height: 2.v),
|
||||
CustomTextFormField(
|
||||
controller: enterInformationController,
|
||||
hintText: "enter_information".tr,
|
||||
textInputAction: TextInputAction.done,
|
||||
maxLines: 8,
|
||||
onChanged: (newValue) {
|
||||
final registrationCubit = context.read<RegistrationCubit>();
|
||||
registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(aboutTakingPils: newValue));
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
onTapSkip(MedicineIntakeState state, BuildContext context) {
|
||||
return () {
|
||||
UserRegistrationSheet sheet = state.medicineIntakeModelObj!.userRegistrationSheet;
|
||||
GoRouter.of(context).goNamed(
|
||||
'favoriteSportsScreen',
|
||||
extra: sheet,
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
onTapNext(MedicineIntakeState state, BuildContext context) {
|
||||
return () {
|
||||
UserRegistrationSheet sheet = state.medicineIntakeModelObj!.userRegistrationSheet;
|
||||
// sheet.aboutTakingPils = state.enterInformationController!.text;
|
||||
GoRouter.of(context).goNamed(
|
||||
'favoriteSportsScreen',
|
||||
extra: sheet,
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Function onTapBack(BuildContext context) {
|
||||
return () {
|
||||
onTapArrowLeft(context);
|
||||
};
|
||||
}
|
||||
|
||||
/// Section Widget
|
||||
_buildTextFormField(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
Text("fill_in_information".tr, style: CustomTextStyles.titleMediumSegoeUI),
|
||||
SizedBox(height: 2.v),
|
||||
BlocSelector<MedicineIntakeBloc, MedicineIntakeState, TextEditingController?>(
|
||||
selector: (state) => state.enterInformationController,
|
||||
builder: (context, enterInformationController) {
|
||||
return CustomTextFormField(
|
||||
controller: enterInformationController,
|
||||
hintText: "enter_information".tr,
|
||||
textInputAction: TextInputAction.done,
|
||||
maxLines: 8,
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// Navigates to the previous screen.
|
||||
onTapArrowLeft(BuildContext context) {
|
||||
GoRouter.of(context).pop();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,75 +1,67 @@
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import 'bloc/weight_bloc.dart';
|
||||
import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:eatvio_app/widgets/custom_text_form_field.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class WeightScreen extends StatelessWidget {
|
||||
class WeightScreen extends StatefulWidget {
|
||||
final UserRegistrationSheet sheet;
|
||||
|
||||
const WeightScreen({super.key, required this.sheet});
|
||||
|
||||
@override
|
||||
State<WeightScreen> createState() => _WeightScreenState();
|
||||
}
|
||||
|
||||
class _WeightScreenState extends State<WeightScreen> {
|
||||
final weightController = TextEditingController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
weightController.text = widget.sheet.weight;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SingleChildScrollView(
|
||||
padding: EdgeInsets.only(bottom: 80),
|
||||
child: Container(
|
||||
width: double.maxFinite,
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
"weight_measurements".tr,
|
||||
style: theme.textTheme.headlineSmall,
|
||||
),
|
||||
SizedBox(height: 16.v),
|
||||
Column(
|
||||
children: [
|
||||
Text(
|
||||
"your_weight".tr,
|
||||
style: theme.textTheme.bodyLarge,
|
||||
),
|
||||
SizedBox(height: 4.v),
|
||||
BlocBuilder<WeightBloc, WeightState>(
|
||||
builder: (context, state) {
|
||||
return CustomTextFormField(
|
||||
width: 150.h,
|
||||
textInputAction: TextInputAction.done,
|
||||
controller: state.weightController,
|
||||
keyboardType: TextInputType.number,
|
||||
inputFormatters: <TextInputFormatter>[
|
||||
FilteringTextInputFormatter.digitsOnly,
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
width: double.maxFinite,
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
"weight_measurements".tr,
|
||||
style: theme.textTheme.headlineSmall,
|
||||
),
|
||||
SizedBox(height: 16.v),
|
||||
Column(
|
||||
children: [
|
||||
Text(
|
||||
"your_weight".tr,
|
||||
style: theme.textTheme.bodyLarge,
|
||||
),
|
||||
SizedBox(height: 4.v),
|
||||
CustomTextFormField(
|
||||
width: 150.h,
|
||||
textInputAction: TextInputAction.done,
|
||||
controller: weightController,
|
||||
keyboardType: TextInputType.number,
|
||||
inputFormatters: <TextInputFormatter>[
|
||||
FilteringTextInputFormatter.digitsOnly,
|
||||
],
|
||||
onChanged: (newValue) {
|
||||
final registrationCubit = context.read<RegistrationCubit>();
|
||||
registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(weight: newValue));
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
onTapNext(WeightState state, BuildContext context) {
|
||||
return () {
|
||||
UserRegistrationSheet sheet = state.weightModelObj!.userRegistrationSheet;
|
||||
GoRouter.of(context).goNamed('heightScreen', extra: sheet);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Function onTapBack(BuildContext context) {
|
||||
return () {
|
||||
onTapArrowLeft(context);
|
||||
};
|
||||
}
|
||||
|
||||
/// Navigates to the previous screen.
|
||||
onTapArrowLeft(BuildContext context) {
|
||||
GoRouter.of(context).pop();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user