diff --git a/assets/icons/check.svg b/assets/icons/check.svg new file mode 100644 index 00000000..d0d70964 --- /dev/null +++ b/assets/icons/check.svg @@ -0,0 +1,3 @@ + + + diff --git a/assets/icons/check_filled.svg b/assets/icons/check_filled.svg new file mode 100644 index 00000000..2366f097 --- /dev/null +++ b/assets/icons/check_filled.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/assets/icons/close_mark.svg b/assets/icons/close_mark.svg new file mode 100644 index 00000000..dad9d60c --- /dev/null +++ b/assets/icons/close_mark.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/assets/icons/sucess.svg b/assets/icons/sucess.svg new file mode 100644 index 00000000..a4cf6d09 --- /dev/null +++ b/assets/icons/sucess.svg @@ -0,0 +1,3 @@ + + + diff --git a/lib/core/di/cubit_registrations.dart b/lib/core/di/cubit_registrations.dart index a52d8e84..e01596f8 100644 --- a/lib/core/di/cubit_registrations.dart +++ b/lib/core/di/cubit_registrations.dart @@ -48,6 +48,7 @@ import 'package:eatvio_app/features/recipe/presentation/cubit/about_recipe_cubit import 'package:eatvio_app/features/recipe/presentation/cubit/my_recipes_cubit/my_recieps_cubit.dart'; import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart'; import 'package:eatvio_app/features/registration/presentation/bloc/verify_email_cubit/verify_email_cubit.dart'; +import 'package:eatvio_app/features/registration_v2/cubit/registration_cubit.dart'; import 'package:eatvio_app/features/settings/presentation/bloc/settings_cubit/settings_cubit.dart'; import 'package:eatvio_app/features/user_details/presentation/cubit/user_details_cubit.dart'; import 'package:eatvio_app/core/comments/comments_cubit/comments_cubit.dart'; @@ -80,6 +81,7 @@ class CubitRegistrations { sl.registerFactory(() => ResetPasswordCubit(resetPasswordRepository: sl())); sl.registerFactory(() => VerifyEmailCubit(profileRepository: sl())); sl.registerFactory(() => OAuthCubit(authRepository: sl(), prefs: sl())); + sl.registerFactory(() => RegistrationCubitV2(registrationRepository: sl())); // Feed related cubits sl.registerFactory(() => FeedCubit(feedRepository: sl())); sl.registerFactory(() => RecipesCubit(feedRepository: sl(), recipeRepository: sl(), aboutRecipeRepository: sl())); diff --git a/lib/core/di/repository_registrations.dart b/lib/core/di/repository_registrations.dart index dbfd1622..fbbb4498 100644 --- a/lib/core/di/repository_registrations.dart +++ b/lib/core/di/repository_registrations.dart @@ -30,6 +30,7 @@ import 'package:eatvio_app/features/profile/repositories/profile_repository.dart import 'package:eatvio_app/features/recipe/repositories/about_recipe_repository.dart'; import 'package:eatvio_app/features/recipe/repositories/my_recipes_repository.dart'; import 'package:eatvio_app/features/registration/repositories/registration_repository.dart'; +import 'package:eatvio_app/features/registration_v2/repositories/registration_repository_v2.dart'; import 'package:eatvio_app/features/settings/repositories/service_repository.dart'; import 'package:get_it/get_it.dart'; @@ -70,6 +71,7 @@ class RepositoryRegistrations { sl.registerLazySingleton(() => CommentsRepository(service: sl())); sl.registerLazySingleton(() => NotificationSettingsRepository(sl())); sl.registerLazySingleton(() => PersonalDietSuggestionRepository(personalDietSuggestionService: sl())); + sl.registerLazySingleton(() => RegistrationRepositoryV2(registrationService: sl())); // Content repositories sl.registerLazySingleton(() => BlogPostRepository(blogPostService: sl())); diff --git a/lib/core/di/service_registrations.dart b/lib/core/di/service_registrations.dart index 7e14b3a7..f70e28ce 100644 --- a/lib/core/di/service_registrations.dart +++ b/lib/core/di/service_registrations.dart @@ -32,6 +32,7 @@ import 'package:eatvio_app/features/profile/services/profile_service.dart'; import 'package:eatvio_app/features/recipe/services/about_recipe_service.dart'; import 'package:eatvio_app/features/recipe/services/my_recipes_service.dart'; import 'package:eatvio_app/features/registration/services/registration_service.dart'; +import 'package:eatvio_app/features/registration_v2/services/registration_service_v2.dart'; import 'package:eatvio_app/features/settings/services/settings_service.dart'; import 'package:get_it/get_it.dart'; @@ -78,6 +79,7 @@ class ServiceRegistrations { sl.registerLazySingleton(() => NotificationSettingsService(sl())); sl.registerLazySingleton(() => ViewsService(sl())); sl.registerLazySingleton(() => PersonalDietSuggestionService(sl())); + sl.registerLazySingleton(() => RegistrationServiceV2(sl())); // Content services sl.registerLazySingleton(() => CreateRecipeService(sl())); diff --git a/lib/core/routing/auth_routes.dart b/lib/core/routing/auth_routes.dart index 39e7b2a9..2ac62618 100644 --- a/lib/core/routing/auth_routes.dart +++ b/lib/core/routing/auth_routes.dart @@ -9,6 +9,7 @@ import 'package:eatvio_app/features/auth/presentation/pages/scan_qr_code_screen. import 'package:eatvio_app/features/registration/presentation/pages/registration_screen.dart'; import 'package:eatvio_app/features/registration/presentation/pages/verify_screen.dart'; import 'package:eatvio_app/features/registration/presentation/pages/verify_email_screen.dart'; +import 'package:eatvio_app/features/registration_v2/presentation/pages/registration_v2_page.dart'; import 'package:go_router/go_router.dart'; /// Маршруты для аутентификации @@ -26,6 +27,7 @@ class AuthRoutes { }, routes: [ GoRoute(path: RouteConstants.registrationScreen, name: 'registrationScreen', builder: (context, state) => const RegistrationScreen()), + GoRoute(path: RouteConstants.registrationScreenV2, name: 'registrationScreenV2', builder: (context, state) => const RegistrationV2Page()), GoRoute( path: RouteConstants.forgetPasswordScreen, name: 'forgetPasswordScreen', diff --git a/lib/core/routing/route_constants.dart b/lib/core/routing/route_constants.dart index 1702b425..4ce78f4f 100644 --- a/lib/core/routing/route_constants.dart +++ b/lib/core/routing/route_constants.dart @@ -3,6 +3,7 @@ class RouteConstants { // Auth routes static const String authScreen = '/auth-screen'; static const String registrationScreen = 'registration-screen'; + static const String registrationScreenV2 = 'registration-screen-v2'; static const String forgetPasswordScreen = 'forget-password-screen'; static const String scanQRCodeScreen = 'scan-qr-code-screen'; static const String verifyScreen = '/verify-screen'; diff --git a/lib/core/theme/custom_text_style.dart b/lib/core/theme/custom_text_style.dart index 1c065748..f0d0661b 100644 --- a/lib/core/theme/custom_text_style.dart +++ b/lib/core/theme/custom_text_style.dart @@ -10,161 +10,76 @@ class CustomTextStyles { static TextStyle get headlineSmallMulish => theme.textTheme.headlineSmall!.mulish; // Title text style - static TextStyle get titleMediumSegoeUI => theme.textTheme.titleMedium!.segoeUI.copyWith( - fontWeight: FontWeight.w600, - ); + static TextStyle get titleMediumSegoeUI => theme.textTheme.titleMedium!.segoeUI.copyWith(fontWeight: FontWeight.w600); - static TextStyle get bodyMediumBlack900 => theme.textTheme.bodyMedium!.copyWith( - color: appTheme.black900, - ); + static TextStyle get bodyMediumBlack900 => theme.textTheme.bodyMedium!.copyWith(color: appTheme.black900); - static TextStyle get bodyMediumBlack90013 => theme.textTheme.bodyMedium!.copyWith( - color: appTheme.black900, - fontSize: 13, - ); + static TextStyle get bodyMediumBlack90013 => theme.textTheme.bodyMedium!.copyWith(color: appTheme.black900, fontSize: 13); - static TextStyle get bodyMediumBluegray800 => theme.textTheme.bodyMedium!.copyWith( - color: appTheme.black, - ); + static TextStyle get bodyMediumBluegray800 => theme.textTheme.bodyMedium!.copyWith(color: appTheme.black); - static TextStyle get bodyMediumBluegray800_1 => theme.textTheme.bodyMedium!.copyWith( - color: appTheme.black, - ); + static TextStyle get bodyMediumBluegray800_1 => theme.textTheme.bodyMedium!.copyWith(color: appTheme.black); - static TextStyle get bodyMediumBluegray800_2 => theme.textTheme.bodyMedium!.copyWith( - color: appTheme.black, - ); + static TextStyle get bodyMediumBluegray800_2 => theme.textTheme.bodyMedium!.copyWith(color: appTheme.black); - static TextStyle get bodyMediumWhiteA700 => theme.textTheme.bodyMedium!.copyWith( - color: appTheme.whiteA700, - ); + static TextStyle get bodyMediumWhiteA700 => theme.textTheme.bodyMedium!.copyWith(color: appTheme.whiteA700); - static TextStyle get bodySmallMulishBlack900 => theme.textTheme.bodySmall!.mulish.copyWith( - color: appTheme.black900, - fontSize: 12, - ); + static TextStyle get bodySmallMulishBlack900 => theme.textTheme.bodySmall!.mulish.copyWith(color: appTheme.black900, fontSize: 12); - static TextStyle get bodySmallMulishBluegray800 => theme.textTheme.bodySmall!.mulish.copyWith( - color: appTheme.black, - fontSize: 12, - ); + static TextStyle get bodySmallMulishBluegray800 => theme.textTheme.bodySmall!.mulish.copyWith(color: appTheme.black, fontSize: 12); - static TextStyle get bodySmallMulishBluegray80012 => theme.textTheme.bodySmall!.mulish.copyWith( - color: appTheme.black, - fontSize: 12, - ); + static TextStyle get bodySmallMulishBluegray80012 => theme.textTheme.bodySmall!.mulish.copyWith(color: appTheme.black, fontSize: 12); - static TextStyle get bodySmallMulishBluegray80012_1 => theme.textTheme.bodySmall!.mulish.copyWith( - color: appTheme.black, - fontSize: 12, - ); + static TextStyle get bodySmallMulishBluegray80012_1 => theme.textTheme.bodySmall!.mulish.copyWith(color: appTheme.black, fontSize: 12); - static TextStyle get bodySmallMulishBluegray900 => theme.textTheme.bodySmall!.mulish.copyWith( - color: appTheme.blueGray900, - fontSize: 12, - ); + static TextStyle get bodySmallMulishBluegray900 => theme.textTheme.bodySmall!.mulish.copyWith(color: appTheme.blueGray900, fontSize: 12); - static TextStyle get bodySmallMulishGray600 => theme.textTheme.bodySmall!.mulish.copyWith( - color: appTheme.gray600, - ); + static TextStyle get bodySmallMulishGray600 => theme.textTheme.bodySmall!.mulish.copyWith(color: appTheme.gray600); - static TextStyle get bodySmallMulishPrimary => theme.textTheme.bodySmall!.mulish.copyWith( - color: theme.colorScheme.primary, - fontSize: 12, - ); + static TextStyle get bodySmallMulishPrimary => theme.textTheme.bodySmall!.mulish.copyWith(color: theme.colorScheme.primary, fontSize: 12); - static TextStyle get bodySmallSegoeUIBlack900 => theme.textTheme.bodySmall!.segoeUI.copyWith( - color: appTheme.black900, - fontSize: 12, - ); + static TextStyle get bodySmallSegoeUIBlack900 => theme.textTheme.bodySmall!.segoeUI.copyWith(color: appTheme.black900, fontSize: 12); // Label text style - static TextStyle get labelLargeGray60003 => theme.textTheme.labelLarge!.copyWith( - color: appTheme.gray60003, - ); + static TextStyle get labelLargeGray60003 => theme.textTheme.labelLarge!.copyWith(color: appTheme.gray60003); - static TextStyle get labelLargeWhiteA700 => theme.textTheme.labelLarge!.copyWith( - color: appTheme.whiteA700, - ); + static TextStyle get labelLargeWhiteA700 => theme.textTheme.labelLarge!.copyWith(color: appTheme.whiteA700); // Title text style - static TextStyle get titleMedium16 => theme.textTheme.titleMedium!.copyWith( - fontSize: 16, - ); + static TextStyle get titleMedium16 => theme.textTheme.titleMedium!.copyWith(fontSize: 16); - static TextStyle get titleMediumBlack => theme.textTheme.titleMedium!.copyWith( - fontSize: 17, - fontWeight: FontWeight.w900, - ); + static TextStyle get titleMediumBlack => theme.textTheme.titleMedium!.copyWith(fontSize: 17, fontWeight: FontWeight.w900); - static TextStyle get titleMediumBlack900 => theme.textTheme.titleMedium!.copyWith( - color: appTheme.black900, - ); + static TextStyle get titleMediumBlack900 => theme.textTheme.titleMedium!.copyWith(color: appTheme.black900); - static TextStyle get titleMediumSemiBold => theme.textTheme.titleMedium!.copyWith( - fontWeight: FontWeight.w600, - ); + static TextStyle get titleMediumSemiBold => theme.textTheme.titleMedium!.copyWith(fontWeight: FontWeight.w600); - static TextStyle get titleMediumWhiteA700 => theme.textTheme.titleMedium!.copyWith( - color: appTheme.whiteA700, - fontWeight: FontWeight.w600, - ); + static TextStyle get titleMediumWhiteA700 => theme.textTheme.titleMedium!.copyWith(color: appTheme.whiteA700, fontWeight: FontWeight.w600); - static TextStyle get titleSmallBlue800 => theme.textTheme.titleSmall!.copyWith( - color: appTheme.blue800, - fontWeight: FontWeight.w800, - ); + static TextStyle get titleSmallBlue800 => theme.textTheme.titleSmall!.copyWith(color: appTheme.blue800, fontWeight: FontWeight.w800); - static TextStyle get titleSmallBluegray800 => theme.textTheme.titleSmall!.copyWith( - color: appTheme.black, - ); + static TextStyle get titleSmallBluegray800 => theme.textTheme.titleSmall!.copyWith(color: appTheme.black); - static TextStyle get titleSmallBluegray800Bold => theme.textTheme.titleSmall!.copyWith( - color: appTheme.black, - fontWeight: FontWeight.w700, - ); + static TextStyle get titleSmallBluegray800Bold => theme.textTheme.titleSmall!.copyWith(color: appTheme.black, fontWeight: FontWeight.w700); - static TextStyle get titleSmallBluegray800ExtraBold => theme.textTheme.titleSmall!.copyWith( - color: appTheme.black, - fontWeight: FontWeight.w800, - ); + static TextStyle get titleSmallBluegray800ExtraBold => theme.textTheme.titleSmall!.copyWith(color: appTheme.black, fontWeight: FontWeight.w800); - static TextStyle get titleSmallBold => theme.textTheme.titleSmall!.copyWith( - fontSize: 15, - fontWeight: FontWeight.w700, - ); + static TextStyle get titleSmallBold => theme.textTheme.titleSmall!.copyWith(fontSize: 15, fontWeight: FontWeight.w700); - static TextStyle get titleSmallGreenA70001 => theme.textTheme.titleSmall!.copyWith( - color: appTheme.greenA70001, - ); + static TextStyle get titleSmallGreenA70001 => theme.textTheme.titleSmall!.copyWith(color: appTheme.greenA70001); - static TextStyle get titleSmallGreenA70001ExtraBold => theme.textTheme.titleSmall!.copyWith( - color: appTheme.greenA70001, - fontWeight: FontWeight.w800, - ); + static TextStyle get titleSmallGreenA70001ExtraBold => theme.textTheme.titleSmall!.copyWith(color: appTheme.greenA70001, fontWeight: FontWeight.w800); - static TextStyle get titleSmallLightgreen300 => theme.textTheme.titleSmall!.copyWith( - color: appTheme.lightGreen300, - fontWeight: FontWeight.w800, - ); + static TextStyle get titleSmallLightgreen300 => theme.textTheme.titleSmall!.copyWith(color: appTheme.lightGreen300, fontWeight: FontWeight.w800); - static TextStyle get titleSmallRed200 => theme.textTheme.titleSmall!.copyWith( - color: appTheme.red200, - fontWeight: FontWeight.w800, - ); + static TextStyle get titleSmallRed200 => theme.textTheme.titleSmall!.copyWith(color: appTheme.red200, fontWeight: FontWeight.w800); - static TextStyle get titleSmallSecondaryContainer => theme.textTheme.titleSmall!.copyWith( - color: theme.colorScheme.secondaryContainer, - fontWeight: FontWeight.w800, - ); + static TextStyle get titleSmallSecondaryContainer => + theme.textTheme.titleSmall!.copyWith(color: theme.colorScheme.secondaryContainer, fontWeight: FontWeight.w800); - static TextStyle get titleSmallSecondaryContainer_1 => theme.textTheme.titleSmall!.copyWith( - color: theme.colorScheme.secondaryContainer, - ); + static TextStyle get titleSmallSecondaryContainer_1 => theme.textTheme.titleSmall!.copyWith(color: theme.colorScheme.secondaryContainer); - static TextStyle get titleSmallSegoeUIOnPrimary => theme.textTheme.titleSmall!.segoeUI.copyWith( - color: theme.colorScheme.onPrimary, - ); + static TextStyle get titleSmallSegoeUIOnPrimary => theme.textTheme.titleSmall!.segoeUI.copyWith(color: theme.colorScheme.onPrimary); } extension on TextStyle { @@ -178,81 +93,32 @@ extension on TextStyle { } abstract class TextStyles { - static const headingXLSemibold = TextStyle( - fontSize: 20, - fontWeight: FontWeight.w600, - height: 1.255, - ); + static const headingXLSemibold = TextStyle(fontSize: 20, fontWeight: FontWeight.w600, height: 1.255); - static const headingFS40FW600 = TextStyle( - fontSize: 40, - fontWeight: FontWeight.w600, - height: 1.255, - ); + static const headingFS40FW600 = TextStyle(fontSize: 40, fontWeight: FontWeight.w600, height: 1.255); - static const textLSemibold = TextStyle( - fontSize: 18, - fontWeight: FontWeight.w600, - height: 1.255, - ); + static const textLSemibold = TextStyle(fontSize: 18, fontWeight: FontWeight.w600, height: 1.255); - static const textLMedium = TextStyle( - fontSize: 18, - fontWeight: FontWeight.w500, - height: 1.255, - ); - - static const textMSemibold = TextStyle( - fontSize: 16, - fontWeight: FontWeight.w600, - height: 1.255, - ); + static const textLMedium = TextStyle(fontSize: 18, fontWeight: FontWeight.w500, height: 1.255); - static const textMMedium = TextStyle( - fontSize: 16, - fontWeight: FontWeight.w500, - height: 1, - ); + static const textMSemibold = TextStyle(fontSize: 16, fontWeight: FontWeight.w600, height: 1.255); - static const textMMediumAuto = TextStyle( - fontSize: 16, - fontWeight: FontWeight.w500, - height: 1.255, - ); + static const textMMedium = TextStyle(fontSize: 16, fontWeight: FontWeight.w500, height: 1); - static const textSSemibold = TextStyle( - fontSize: 14, - fontWeight: FontWeight.w600, - height: 1.255, - ); + static const textMMediumAuto = TextStyle(fontSize: 16, fontWeight: FontWeight.w500, height: 1.255); - static const textSMedium = TextStyle( - fontSize: 14, - fontWeight: FontWeight.w500, - height: 1.255, - ); + static const textSSemibold = TextStyle(fontSize: 14, fontWeight: FontWeight.w600, height: 1.255); - static const textFS13FW400 = TextStyle( - fontSize: 14, - fontWeight: FontWeight.w400, - height: 1.255, - ); + static const textSMedium = TextStyle(fontSize: 14, fontWeight: FontWeight.w500, height: 1.255); - static const textXSSemibold = TextStyle( - fontSize: 12, - fontWeight: FontWeight.w500, - height: 1.255, - ); + static const textFS13FW400 = TextStyle(fontSize: 14, fontWeight: FontWeight.w400, height: 1.255); - static const textFS10FW500 = TextStyle( - fontSize: 10, - fontWeight: FontWeight.w500, - height: 1.255, - ); + static const textXSSemibold = TextStyle(fontSize: 12, fontWeight: FontWeight.w500, height: 1.255); + + static const textFS10FW500 = TextStyle(fontSize: 10, fontWeight: FontWeight.w500, height: 1.255); + + static const textFS24FW700 = TextStyle(fontSize: 24, fontWeight: FontWeight.w700, height: 1.255); + + static const textFS22FW600 = TextStyle(fontSize: 22, fontWeight: FontWeight.w600, height: 1.255); - static const textFS24FW700 = TextStyle( - fontSize: 24, - fontWeight: FontWeight.w700, - height: 1.255, - ); } diff --git a/lib/core/theme/theme_helper.dart b/lib/core/theme/theme_helper.dart index 75462df3..01f9a96b 100644 --- a/lib/core/theme/theme_helper.dart +++ b/lib/core/theme/theme_helper.dart @@ -7,23 +7,17 @@ class ThemeHelper { // The current app theme final _appTheme = 'primary'; -// A map of custom color themes supported by the app - final Map _supportedCustomColor = { - 'primary': PrimaryColors(), - }; + // A map of custom color themes supported by the app + final Map _supportedCustomColor = {'primary': PrimaryColors()}; -// A map of color schemes supported by the app - final Map _supportedColorScheme = { - 'primary': ColorSchemes.primaryColorScheme, - }; + // A map of color schemes supported by the app + final Map _supportedColorScheme = {'primary': ColorSchemes.primaryColorScheme}; /// Returns the primary colors for the current theme. PrimaryColors _getThemeColors() { //throw exception to notify given theme is not found or not generated by the generator if (!_supportedCustomColor.containsKey(_appTheme)) { - throw Exception( - "$_appTheme is not found.Make sure you have added this theme class in JSON Try running flutter pub run build_runner", - ); + throw Exception("$_appTheme is not found.Make sure you have added this theme class in JSON Try running flutter pub run build_runner"); } //return theme from map @@ -34,9 +28,7 @@ class ThemeHelper { ThemeData _getThemeData() { //throw exception to notify given theme is not found or not generated by the generator if (!_supportedColorScheme.containsKey(_appTheme)) { - throw Exception( - "$_appTheme is not found.Make sure you have added this theme class in JSON Try running flutter pub run build_runner", - ); + throw Exception("$_appTheme is not found.Make sure you have added this theme class in JSON Try running flutter pub run build_runner"); } //return theme from map @@ -60,17 +52,9 @@ class ThemeHelper { outlinedButtonTheme: OutlinedButtonThemeData( style: OutlinedButton.styleFrom( backgroundColor: Colors.transparent, - side: BorderSide( - color: colorScheme.primary, - width: 1, - ), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(20), - ), - visualDensity: const VisualDensity( - vertical: -4, - horizontal: -4, - ), + side: BorderSide(color: colorScheme.primary, width: 1), + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)), + visualDensity: const VisualDensity(vertical: -4, horizontal: -4), padding: EdgeInsets.zero, ), ), @@ -149,6 +133,7 @@ class PrimaryColors { Color get greenA70001 => const Color(0XFF00BE13); Color get green => const Color(0XFF0BB450); + Color get darkGreen => const Color(0XFF16A249); Color get transparentGreen => const Color.fromARGB(12, 1, 154, 63); @@ -184,6 +169,8 @@ class PrimaryColors { Color get lightGray0 => const Color(0xFFF6F6F6); + Color get darkGrey => const Color(0xFF5B656F); + Color get lightGray00 => const Color(0xFFE9E9EA); Color get dottedBorder => const Color(0xFFE6E6E6); @@ -210,6 +197,8 @@ class PrimaryColors { Color get cardNotificationsBG => const Color(0xFFA4A4A4); Color get grey7B => const Color(0xFF7B7B7B); + + Color get greyD9 => const Color(0xFFD9D9D9); } PrimaryColors get appTheme => ThemeHelper().themeColor(); diff --git a/lib/core/widgets/custom_drop_down_button.dart b/lib/core/widgets/custom_drop_down_button.dart index ac8f3c2b..d4c0e571 100644 --- a/lib/core/widgets/custom_drop_down_button.dart +++ b/lib/core/widgets/custom_drop_down_button.dart @@ -3,16 +3,28 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; class CustomDropDownButton extends StatelessWidget { - const CustomDropDownButton({super.key, required this.items, required this.onChanged, this.value, this.hint, this.hasError = false}); + const CustomDropDownButton({ + super.key, + required this.items, + required this.onChanged, + this.value, + this.hint, + this.selectedItemBuilder, + this.hasError = false, + this.isExpanded = false, + }); final T? value; final List> items; final void Function(T?)? onChanged; final Widget? hint; final bool hasError; + final List Function(BuildContext)? selectedItemBuilder; + final bool isExpanded; @override Widget build(BuildContext context) { return DropdownButtonFormField( hint: hint, + isExpanded: isExpanded, icon: SvgPicture.asset('assets/icons/arrow_down2.svg', width: 12, height: 8), borderRadius: BorderRadius.circular(20), dropdownColor: appTheme.lightGray0, @@ -35,6 +47,7 @@ class CustomDropDownButton extends StatelessWidget { initialValue: value, items: items, onChanged: onChanged, + selectedItemBuilder: selectedItemBuilder, ); } } diff --git a/lib/features/auth/presentation/pages/auth_screen.dart b/lib/features/auth/presentation/pages/auth_screen.dart index f7484a87..0220c9fb 100644 --- a/lib/features/auth/presentation/pages/auth_screen.dart +++ b/lib/features/auth/presentation/pages/auth_screen.dart @@ -337,7 +337,7 @@ class _AuthScreenState extends State { children: [ const Text('Нет аккаунта? '), GestureDetector( - onTap: () => GoRouter.of(context).goNamed('registrationScreen'), + onTap: () => GoRouter.of(context).pushNamed('registrationScreenV2'), child: Text( 'Зарегистрироваться', style: TextStyle(color: appTheme.blueA400, decorationColor: appTheme.blueA400, decoration: TextDecoration.underline), @@ -411,7 +411,7 @@ class _AuthScreenState extends State { _isLoading = false; }); }, - label: state is AuthStateLoading + label: state is AuthStateLoading || _isLoading ? const CupertinoActivityIndicator() : Text('Войти', style: theme.textTheme.titleSmall!.copyWith(color: Colors.white)), ), @@ -426,8 +426,8 @@ class _AuthScreenState extends State { elevation: 0, focusElevation: 0, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)), - backgroundColor: state is AuthStateLoading ? Colors.black.withAlpha(50) : appTheme.blueA400, - onPressed: state is AuthStateLoading + backgroundColor: state is AuthStateLoading || _isLoading ? Colors.black.withAlpha(50) : appTheme.blueA400, + onPressed: state is AuthStateLoading || _isLoading ? null : () async { await showDialog( @@ -487,7 +487,7 @@ class _AuthScreenState extends State { }, ); }, - label: state is AuthStateLoading + label: state is AuthStateLoading || _isLoading ? const CupertinoActivityIndicator() : const Icon(Icons.qr_code_scanner_rounded, color: Colors.white), ), diff --git a/lib/features/blog_post_create/presentation/pages/blog_post_create_screen.dart b/lib/features/blog_post_create/presentation/pages/blog_post_create_screen.dart index 48536468..98cb0053 100644 --- a/lib/features/blog_post_create/presentation/pages/blog_post_create_screen.dart +++ b/lib/features/blog_post_create/presentation/pages/blog_post_create_screen.dart @@ -5,6 +5,7 @@ import 'package:eatvio_app/core/app_config.dart'; import 'package:eatvio_app/core/app_router.dart'; import 'package:eatvio_app/core/permission_handler/permission_handler.dart'; import 'package:eatvio_app/core/theme/app_decoration.dart'; +import 'package:eatvio_app/core/widgets/loader.dart'; import 'package:eatvio_app/core/widgets/show_error_dialog.dart'; import 'package:eatvio_app/features/blog_post_create/bloc/blog_post_create_cubit/blog_post_create_cubit.dart'; import 'package:eatvio_app/features/blog_post_create/bloc/blog_post_create_cubit/blog_post_create_state.dart'; @@ -620,16 +621,16 @@ class _BlogPostCreateScreenState extends State { } }, borderRadius: BorderRadius.circular(16), - child: Ink( - width: MediaQuery.of(context).size.width - 32, - height: 52, - decoration: BoxDecoration(borderRadius: BorderRadius.circular(16), color: appTheme.blueA400), - child: isLoading - ? const Center(child: CircularProgressIndicator()) - : const Center( + child: isLoading + ? const Center(child: Loader()) + : Ink( + width: MediaQuery.of(context).size.width - 32, + height: 52, + decoration: BoxDecoration(borderRadius: BorderRadius.circular(16), color: appTheme.blueA400), + child: const Center( child: Text('Создать', style: TextStyle(color: Colors.white)), ), - ), + ), ); } diff --git a/lib/features/create_recipe/presentation/pages/recipe_create_screen.dart b/lib/features/create_recipe/presentation/pages/recipe_create_screen.dart index c8a6d4ef..932852ac 100644 --- a/lib/features/create_recipe/presentation/pages/recipe_create_screen.dart +++ b/lib/features/create_recipe/presentation/pages/recipe_create_screen.dart @@ -33,7 +33,7 @@ class _RecipeCreateScreenState extends State { late final CreateRecipeCubit createRecipeCubit; final GlobalKey _mdKey = GlobalKey(); bool _mdToolbarVisible = false; - + bool _isRecipeBeingPublished = false; @override void initState() { super.initState(); @@ -58,9 +58,7 @@ class _RecipeCreateScreenState extends State { return Scaffold( backgroundColor: const Color(0xFFF0F2F5), floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat, - floatingActionButton: _mdToolbarVisible && _mdKey.currentState != null - ? _mdKey.currentState!.buildToolbar(context) - : null, + floatingActionButton: _mdToolbarVisible && _mdKey.currentState != null ? _mdKey.currentState!.buildToolbar(context) : null, appBar: AppBar( title: widget.recipe != null ? const Text('Редактирование рецепта') : const Text('Добавление рецепта'), centerTitle: true, @@ -83,44 +81,55 @@ class _RecipeCreateScreenState extends State { builder: (context, state) { return Builder( builder: (context) { - return InkWell( - key: AppKeys.recipeCreateScreenPublishButton, - onTap: () async { - if (context.read().validateAll()) { - final isSuccess = await context.read().publishRecipe( - widget.recipe == null ? false : true, - widget.recipe?.slug, + return _isRecipeBeingPublished + ? const Center(child: Loader()) + : InkWell( + key: AppKeys.recipeCreateScreenPublishButton, + onTap: () async { + setState(() { + _isRecipeBeingPublished = true; + }); + if (context.read().validateAll()) { + final isSuccess = await context.read().publishRecipe( + widget.recipe == null ? false : true, + widget.recipe?.slug, + ); + setState(() { + _isRecipeBeingPublished = false; + }); + if (isSuccess) { + Future.delayed(const Duration(milliseconds: 500), () { + if (!context.mounted) return; + context.pop(); + showBottomSheetWithBlur( + userRootNavigator: true, + context: context, + child: SuccessPublishedRecipeBottomSheet(title: state.entity.title ?? 'Рецепт'), + ); + }); + } else { + if (!context.mounted) return; + showErrorDialog(context, title: '${s.could_not_publish_recipe} ${state.entity.title}'); + } + } + setState(() { + _isRecipeBeingPublished = false; + }); + }, + borderRadius: BorderRadius.circular(20), + child: Ink( + width: MediaQuery.of(context).size.width - 32, + decoration: BoxDecoration(color: appTheme.blueA400, borderRadius: BorderRadius.circular(20)), + child: Container( + padding: const EdgeInsets.all(16), + alignment: Alignment.center, + child: Text( + widget.recipe != null ? 'Обновить' : 'Опубликовать', + style: const TextStyle(fontSize: 16, color: Colors.white, fontWeight: FontWeight.w600), + ), + ), + ), ); - if (isSuccess) { - Future.delayed(const Duration(milliseconds: 500), () { - if (!context.mounted) return; - context.pop(); - showBottomSheetWithBlur( - userRootNavigator: true, - context: context, - child: SuccessPublishedRecipeBottomSheet(title: state.entity.title ?? 'Рецепт'), - ); - }); - } else { - if (!context.mounted) return; - showErrorDialog(context, title: '${s.could_not_publish_recipe} ${state.entity.title}'); - } - } - }, - borderRadius: BorderRadius.circular(20), - child: Ink( - width: MediaQuery.of(context).size.width - 32, - decoration: BoxDecoration(color: appTheme.blueA400, borderRadius: BorderRadius.circular(20)), - child: Container( - padding: const EdgeInsets.all(16), - alignment: Alignment.center, - child: Text( - widget.recipe != null ? 'Обновить' : 'Опубликовать', - style: const TextStyle(fontSize: 16, color: Colors.white, fontWeight: FontWeight.w600), - ), - ), - ), - ); }, ); }, diff --git a/lib/features/diary/presentation/pages/diary_screen.dart b/lib/features/diary/presentation/pages/diary_screen.dart index ae6f9e10..607e97d2 100644 --- a/lib/features/diary/presentation/pages/diary_screen.dart +++ b/lib/features/diary/presentation/pages/diary_screen.dart @@ -44,16 +44,24 @@ class UserDiaryScreen extends StatelessWidget { } } -class DiaryScreenContent extends StatelessWidget { +class DiaryScreenContent extends StatefulWidget { const DiaryScreenContent({super.key, this.diaryId, this.currentPlanDay}); final int? diaryId; final int? currentPlanDay; + + @override + State createState() => _DiaryScreenContentState(); +} + +class _DiaryScreenContentState extends State { + bool _isDiaryFinishing = false; + @override Widget build(BuildContext context) { final s = S.of(context); return MultiBlocProvider( providers: [ - BlocProvider(create: (BuildContext context) => sl()..fetchDiaryV2(needLoading: true, diaryId: diaryId)), + BlocProvider(create: (BuildContext context) => sl()..fetchDiaryV2(needLoading: true, diaryId: widget.diaryId)), BlocProvider(create: (context) => sl()), ], child: BlocBuilder( @@ -63,13 +71,13 @@ class DiaryScreenContent extends StatelessWidget { } if (state is DiaryStateError) { return Scaffold( - body: DataErrorWidget(onReload: () => context.read().fetchDiaryV2(needLoading: false, diaryId: diaryId)), + body: DataErrorWidget(onReload: () => context.read().fetchDiaryV2(needLoading: false, diaryId: widget.diaryId)), ); } return Scaffold( backgroundColor: Colors.grey.shade200, - appBar: diaryId == null + appBar: widget.diaryId == null ? AppBar(toolbarHeight: 0) : AppBar( title: Text( @@ -83,7 +91,7 @@ class DiaryScreenContent extends StatelessWidget { physics: const BouncingScrollPhysics(), child: Column( children: [ - if (diaryId == null) const CalendarWidget(), + if (widget.diaryId == null) const CalendarWidget(), if (state is DiaryStateLoading) ...[const SizedBox(height: 60), const Loader()], if (state is DiaryStateLoaded) WakeupAndRetireWidget( @@ -116,7 +124,23 @@ class DiaryScreenContent extends StatelessWidget { if (state is DiaryStateLoaded && !state.isConsultantView && !state.isDiaryFinished && !state.isDiaryCommented) Padding( padding: const EdgeInsets.only(top: 12), - child: FinishDayButtonWidget(diaryDay: state.diary), + child: _isDiaryFinishing + ? const Center(child: Loader()) + : FinishDayButtonWidget( + onPressed: () async { + setState(() { + _isDiaryFinishing = true; + }); + await context.read().finishDiaryDay( + diaryId: state.diary.id, + wakeUp: state.diary.wakeup.toString(), + retire: state.diary.retire.toString(), + ); + setState(() { + _isDiaryFinishing = false; + }); + }, + ), ), if (state is DiaryStateLoaded && state.isConsultantView && !state.isDiaryCommented) ...[ const SizedBox(height: 16), diff --git a/lib/features/diary/presentation/widgets/finish_day_button_widget.dart b/lib/features/diary/presentation/widgets/finish_day_button_widget.dart index b3f170ec..af58216a 100644 --- a/lib/features/diary/presentation/widgets/finish_day_button_widget.dart +++ b/lib/features/diary/presentation/widgets/finish_day_button_widget.dart @@ -1,13 +1,10 @@ -import 'package:eatvio_app/features/diary/entities/diary_day_entity.dart'; -import 'package:eatvio_app/features/diary/presentation/bloc/diary_cubit.dart'; import 'package:eatvio_app/core/theme/theme_helper.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; class FinishDayButtonWidget extends StatefulWidget { - final DiaryDayEntity diaryDay; + final Future Function() onPressed; - const FinishDayButtonWidget({super.key, required this.diaryDay}); + const FinishDayButtonWidget({super.key, required this.onPressed}); @override State createState() => _FinishDayButtonWidgetState(); @@ -17,11 +14,7 @@ class _FinishDayButtonWidgetState extends State { @override Widget build(BuildContext context) { return InkWell( - onTap: () => context.read().finishDiaryDay( - diaryId: widget.diaryDay.id, - wakeUp: widget.diaryDay.wakeup.toString(), - retire: widget.diaryDay.retire.toString(), - ), + onTap: widget.onPressed, borderRadius: BorderRadius.circular(20), child: Ink( padding: const EdgeInsets.symmetric(horizontal: 8), diff --git a/lib/features/registration_v2/cubit/registration_cubit.dart b/lib/features/registration_v2/cubit/registration_cubit.dart new file mode 100644 index 00000000..0a55ecff --- /dev/null +++ b/lib/features/registration_v2/cubit/registration_cubit.dart @@ -0,0 +1,239 @@ +import 'dart:developer'; + +import 'package:dio/dio.dart'; +import 'package:eatvio_app/core/token_storage.dart'; +import 'package:eatvio_app/core/utils/date_time_utils.dart'; +import 'package:eatvio_app/features/registration_v2/cubit/registration_state.dart'; +import 'package:eatvio_app/features/registration_v2/models/registration_model.dart'; +import 'package:eatvio_app/features/registration_v2/repositories/registration_repository_v2.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_password_generator/flutter_password_generator.dart'; + +class RegistrationCubitV2 extends Cubit { + final RegistrationRepositoryV2 registrationRepository; + RegistrationCubitV2({required this.registrationRepository}) : super(RegistrationStateV2()); + + void setFirstName(String firstName) { + emit(state.copyWith(firstName: firstName)); + validateFirstName(); + } + + void setLastName(String lastName) { + emit(state.copyWith(lastName: lastName)); + validateLastName(); + } + + void setEmail(String email) { + emit(state.copyWith(email: email)); + validateEmail(); + } + + void setPhone(String phone) { + emit(state.copyWith(phone: phone)); + validatePhone(); + } + + void setBirthday(DateTime birthday) { + emit(state.copyWith(birthday: birthday)); + validateBirthday(); + } + + void setGender(String gender) { + emit(state.copyWith(gender: gender)); + validateGender(); + } + + void setWeight(int weight) { + emit(state.copyWith(weight: weight)); + validateWeight(); + } + + void setHeight(int height) { + emit(state.copyWith(height: height)); + validateHeight(); + } + + void setActivityCoefficient(double activityCoefficient) { + emit(state.copyWith(activityCoefficient: activityCoefficient)); + validateActivityCoefficient(); + } + + void setPassword(String password) { + emit(state.copyWith(password: password)); + } + + bool validateFirstName() { + if (state.firstName.isEmpty) { + emit(state.copyWith(isFirstNameValid: false)); + return false; + } + emit(state.copyWith(isFirstNameValid: true)); + return true; + } + + bool validateLastName() { + if (state.lastName.isEmpty) { + emit(state.copyWith(isLastNameValid: false)); + return false; + } + emit(state.copyWith(isLastNameValid: true)); + return true; + } + + bool validateEmail() { + if (state.email.isEmpty) { + emit(state.copyWith(isEmailValid: false)); + return false; + } + emit(state.copyWith(isEmailValid: true)); + return true; + } + + bool validatePhone() { + if (state.phone.isEmpty) { + emit(state.copyWith(isPhoneValid: false)); + return false; + } + emit(state.copyWith(isPhoneValid: true)); + return true; + } + + bool validateGender() { + if (state.gender.isEmpty) { + emit(state.copyWith(isGenderValid: false)); + return false; + } + emit(state.copyWith(isGenderValid: true)); + return true; + } + + bool validateWeight() { + if (state.weight == 0) { + emit(state.copyWith(isWeightValid: false)); + return false; + } + emit(state.copyWith(isWeightValid: true)); + return true; + } + + bool validateHeight() { + if (state.height == 0) { + emit(state.copyWith(isHeightValid: false)); + return false; + } + emit(state.copyWith(isHeightValid: true)); + return true; + } + + bool validateActivityCoefficient() { + if (state.activityCoefficient == 0) { + emit(state.copyWith(isActivityCoefficientValid: false)); + return false; + } + emit(state.copyWith(isActivityCoefficientValid: true)); + return true; + } + + bool validateBirthday() { + if (state.birthday == null) { + emit(state.copyWith(isBirthdayValid: false)); + return false; + } + emit(state.copyWith(isBirthdayValid: true)); + return true; + } + + void nextStep() { + emit(state.copyWith(step: 1)); + } + + void prevStep() { + emit(state.copyWith(step: 0)); + } + + bool validateAllFields() { + if (!validateFirstName() || + !validateLastName() || + !validateEmail() || + !validatePhone() || + !validateGender() || + !validateWeight() || + !validateHeight() || + !validateActivityCoefficient() || + !validateBirthday()) { + return false; + } + return true; + } + + Future<(bool, bool)> register() async { + if (!validateAllFields()) { + return (false, true); + } + final birthday = state.birthday?.format('yyyy-MM-dd'); + if (birthday == null) { + validateBirthday(); + return (false, true); + } + final password = await _generatePassword(); + final registrationModel = RegistrationModel( + firstName: state.firstName, + lastName: state.lastName, + email: state.email, + phone: state.phone, + gender: state.gender, + password: password, + confirmPassword: password, + weight: state.weight, + height: state.height, + activityCoefficient: state.activityCoefficient, + birthday: birthday, + ); + bool didApiComplainOnValidation = false; + try { + final token = await registrationRepository.register(registrationModel: registrationModel); + if (token != null) { + TokenStorage.saveTokenInStorage(token); + return (true, false); + } + } on DioException catch (e) { + final errors = e.response?.data['errors'] as Map?; + final emailErrors = errors?['email'] as List?; + final phoneErrors = errors?['phone'] as List?; + final dateOfBirth = errors?['date_of_birth'] as List?; + if (emailErrors != null && emailErrors.isNotEmpty) { + if (emailErrors.contains('Некорректный формат email')) { + emit(state.copyWith(isEmailValid: false, emailDisplayError: 'Некорректный формат email')); + didApiComplainOnValidation = true; + } + if (emailErrors.contains('Такой Эл. почта уже существует.')) { + emit(state.copyWith(isEmailValid: false, emailDisplayError: 'Такая Эл. почта уже существует.')); + didApiComplainOnValidation = true; + } + } + if (phoneErrors != null && phoneErrors.isNotEmpty) { + if (phoneErrors.contains('Такой phone уже существует.')) { + emit(state.copyWith(isPhoneValid: false, phoneDisplayError: 'Такой номер телефона уже существует.')); + didApiComplainOnValidation = true; + } + } + if (dateOfBirth != null && dateOfBirth.isNotEmpty) { + if (dateOfBirth.contains('Некорректный формат даты рождения')) { + emit(state.copyWith(isBirthdayValid: false, emailDisplayError: 'Некорректный формат даты рождения')); + didApiComplainOnValidation = true; + } + } + } catch (e) { + log(e.toString()); + } + return (false, didApiComplainOnValidation); + } + + Future _generatePassword() async { + final generator = FlutterPasswordGenerator(length: 8); + final result = await generator.generatePassword(); + final password = result['password'] as String; + emit(state.copyWith(password: password)); + return password; + } +} diff --git a/lib/features/registration_v2/cubit/registration_state.dart b/lib/features/registration_v2/cubit/registration_state.dart new file mode 100644 index 00000000..de26c146 --- /dev/null +++ b/lib/features/registration_v2/cubit/registration_state.dart @@ -0,0 +1,32 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'registration_state.freezed.dart'; + +@freezed +abstract class RegistrationStateV2 with _$RegistrationStateV2 { + factory RegistrationStateV2({ + @Default('') String firstName, + @Default('') String lastName, + @Default('') String email, + @Default('') String phone, + @Default('') String gender, + @Default('') String password, + @Default(0) int weight, + @Default(0) int height, + @Default(1.2) double activityCoefficient, + DateTime? birthday, + @Default(true) bool isFirstNameValid, + @Default(true) bool isLastNameValid, + @Default(true) bool isEmailValid, + @Default(true) bool isPhoneValid, + @Default(true) bool isGenderValid, + @Default(true) bool isWeightValid, + @Default(true) bool isHeightValid, + @Default(true) bool isActivityCoefficientValid, + @Default(true) bool isBirthdayValid, + @Default(0) int step, + @Default('') String emailDisplayError, + @Default('') String phoneDisplayError, + @Default('') String dateOfBirthDisplayError, + }) = _RegistrationStateV2; +} diff --git a/lib/features/registration_v2/models/registration_model.dart b/lib/features/registration_v2/models/registration_model.dart new file mode 100644 index 00000000..0fe9239f --- /dev/null +++ b/lib/features/registration_v2/models/registration_model.dart @@ -0,0 +1,24 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'registration_model.freezed.dart'; +part 'registration_model.g.dart'; + +@freezed +abstract class RegistrationModel with _$RegistrationModel { + + factory RegistrationModel({ + @JsonKey(name: 'first_name') required String firstName, + @JsonKey(name: 'last_name') required String lastName, + @JsonKey(name: 'email') required String email, + @JsonKey(name: 'phone') required String phone, + @JsonKey(name: 'gender') required String gender, + @JsonKey(name: 'password') required String password, + @JsonKey(name: 'password_confirmation') required String confirmPassword, + @JsonKey(name: 'weight') required int weight, + @JsonKey(name: 'height') required int height, + @JsonKey(name: 'activity_coefficient') required double activityCoefficient, + @JsonKey(name: 'birthdate') required String birthday, + }) = _RegistrationModel; + + factory RegistrationModel.fromJson(Map json) => _$RegistrationModelFromJson(json); +} diff --git a/lib/features/registration_v2/presentation/pages/registration_v2_page.dart b/lib/features/registration_v2/presentation/pages/registration_v2_page.dart new file mode 100644 index 00000000..d69d27c4 --- /dev/null +++ b/lib/features/registration_v2/presentation/pages/registration_v2_page.dart @@ -0,0 +1,47 @@ +import 'package:eatvio_app/core/locator_service.dart'; +import 'package:eatvio_app/core/utils/image_constant.dart'; +import 'package:eatvio_app/features/registration_v2/cubit/registration_cubit.dart'; +import 'package:eatvio_app/features/registration_v2/cubit/registration_state.dart'; +import 'package:eatvio_app/features/registration_v2/presentation/widgets/first_step_content.dart'; +import 'package:eatvio_app/features/registration_v2/presentation/widgets/second_step_content.dart'; +import 'package:eatvio_app/features/registration_v2/presentation/widgets/step_progress.dart'; +import 'package:eatvio_app/features/registration_v2/presentation/widgets/step_widget.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_svg/svg.dart'; +import 'package:mask_text_input_formatter/mask_text_input_formatter.dart'; + +class RegistrationV2Page extends StatelessWidget { + const RegistrationV2Page({super.key}); + + @override + Widget build(BuildContext context) { + return BlocProvider(create: (context) => sl(), child: RegistrationV2PageContent()); + } +} + +class RegistrationV2PageContent extends StatelessWidget { + RegistrationV2PageContent({super.key}); + final maskFormatterForBirthday = MaskTextInputFormatter(mask: '##.##.####', filter: {"#": RegExp(r'[0-9]')}, type: MaskAutoCompletionType.lazy); + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar(centerTitle: true, toolbarHeight: 45, title: SvgPicture.asset(ImageConstant.imgLogoEatvio, height: 45), actions: const [StepWidget()]), + body: Padding( + padding: const EdgeInsets.symmetric(horizontal: 16), + child: BlocBuilder( + builder: (context, state) { + return Column( + children: [ + const SizedBox(height: 4), + const StepProgress(), + const SizedBox(height: 20), + if (state.step == 0) const Expanded(child: FirstStepContent()) else if (state.step == 1) const Expanded(child: SecondStepContent()), + ], + ); + }, + ), + ), + ); + } +} diff --git a/lib/features/registration_v2/presentation/widgets/first_step_content.dart b/lib/features/registration_v2/presentation/widgets/first_step_content.dart new file mode 100644 index 00000000..8f4b5372 --- /dev/null +++ b/lib/features/registration_v2/presentation/widgets/first_step_content.dart @@ -0,0 +1,176 @@ +import 'package:eatvio_app/core/theme/custom_text_style.dart'; +import 'package:eatvio_app/core/theme/theme_helper.dart'; +import 'package:eatvio_app/core/utils/date_time_utils.dart'; +import 'package:eatvio_app/core/widgets/custom_outlined_button.dart'; +import 'package:eatvio_app/core/widgets/custom_text_form_field.dart'; +import 'package:eatvio_app/features/create_diet/presentation/widgets/error_widget.dart'; +import 'package:eatvio_app/features/registration_v2/cubit/registration_cubit.dart'; +import 'package:eatvio_app/features/registration_v2/cubit/registration_state.dart'; +import 'package:eatvio_app/features/registration_v2/presentation/widgets/sex_widget.dart'; +import 'package:eatvio_app/generated/l10n.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:mask_text_input_formatter/mask_text_input_formatter.dart'; + +class FirstStepContent extends StatefulWidget { + const FirstStepContent({super.key}); + + @override + State createState() => _FirstStepContentState(); +} + +class _FirstStepContentState extends State { + final maskFormatterForBirthday = MaskTextInputFormatter(mask: '##.##.####', filter: {"#": RegExp(r'[0-9]')}, type: MaskAutoCompletionType.lazy); + + final firstNameController = TextEditingController(); + + final lastNameController = TextEditingController(); + + final emailController = TextEditingController(); + + final phoneController = TextEditingController(); + + final dateController = TextEditingController(); + @override + void initState() { + super.initState(); + firstNameController.text = context.read().state.firstName; + lastNameController.text = context.read().state.lastName; + emailController.text = context.read().state.email; + phoneController.text = context.read().state.phone; + dateController.text = context.read().state.birthday?.format('dd.MM.yyyy') ?? ''; + } + + @override + Widget build(BuildContext context) { + final s = S.of(context); + return BlocBuilder( + builder: (context, state) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(s.first_name, style: TextStyles.textSMedium.copyWith(color: appTheme.black)), + const SizedBox(height: 4), + CustomTextFormField( + hintText: s.your_name, + hasError: !state.isFirstNameValid, + controller: firstNameController, + onChanged: (val) { + context.read().setFirstName(val); + }, + ), + if (!state.isFirstNameValid) ...[const SizedBox(height: 4), ValidationErrorWidget(error: s.first_name_validation_error)], + ], + ), + ), + const SizedBox(width: 12), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(s.last_name, style: TextStyles.textSMedium.copyWith(color: appTheme.black)), + const SizedBox(height: 4), + CustomTextFormField( + hintText: s.your_last_name, + hasError: !state.isLastNameValid, + controller: lastNameController, + onChanged: (val) { + context.read().setLastName(val); + }, + ), + if (!state.isLastNameValid) ...[const SizedBox(height: 4), ValidationErrorWidget(error: s.last_name_error)], + ], + ), + ), + ], + ), + const SizedBox(height: 12), + Text(s.email, style: TextStyles.textSMedium.copyWith(color: appTheme.black)), + CustomTextFormField( + hintText: s.type_email, + hasError: !state.isEmailValid, + controller: emailController, + onChanged: (val) { + context.read().setEmail(val); + }, + ), + if (!state.isEmailValid) ...[ + const SizedBox(height: 4), + ValidationErrorWidget(error: state.emailDisplayError.isEmpty ? s.email_error : state.emailDisplayError), + ], + const SizedBox(height: 12), + Text(s.phone, style: TextStyles.textSMedium.copyWith(color: appTheme.black)), + Column( + children: [ + CustomTextFormField( + hintText: '+7 (999) 999 99 99', + controller: phoneController, + hasError: !state.isPhoneValid, + onChanged: (val) { + context.read().setPhone(val); + }, + ), + if (!state.isPhoneValid) ...[ + const SizedBox(height: 4), + ValidationErrorWidget(error: state.phoneDisplayError.isEmpty ? s.phone_error : state.phoneDisplayError), + ], + ], + ), + const SizedBox(height: 12), + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(s.date_of_birth, style: TextStyles.textSMedium.copyWith(color: appTheme.black)), + const SizedBox(height: 4), + CustomTextFormField( + textInputAction: TextInputAction.done, + hintText: '01.01.2000', + keyboardType: TextInputType.number, + inputFormatters: [maskFormatterForBirthday], + hasError: !state.isBirthdayValid, + controller: dateController, + onChanged: (val) { + final dateArray = val.split('.'); + if (dateArray.length != 3) return; + final date = DateTime(int.parse(dateArray[2]), int.parse(dateArray[1]), int.parse(dateArray[0])); + context.read().setBirthday(date); + }, + ), + if (!state.isBirthdayValid) ...[ + const SizedBox(height: 4), + ValidationErrorWidget(error: state.dateOfBirthDisplayError.isEmpty ? s.date_of_birth_error : state.dateOfBirthDisplayError), + ], + ], + ), + ), + const SizedBox(width: 12), + const Expanded(child: SexWidget()), + ], + ), + const Spacer(), + CustomOutlinedButton( + onPressed: () { + context.read().nextStep(); + }, + text: s.next, + height: 52, + buttonTextStyle: TextStyles.textSSemibold.copyWith(color: appTheme.whiteA700), + buttonStyle: ButtonStyle(side: const WidgetStatePropertyAll(BorderSide.none), backgroundColor: WidgetStatePropertyAll(appTheme.blueA400)), + ), + const SizedBox(height: 20), + ], + ); + }, + ); + } +} diff --git a/lib/features/registration_v2/presentation/widgets/password_field.dart b/lib/features/registration_v2/presentation/widgets/password_field.dart new file mode 100644 index 00000000..859f9b67 --- /dev/null +++ b/lib/features/registration_v2/presentation/widgets/password_field.dart @@ -0,0 +1,76 @@ +import 'package:eatvio_app/core/theme/custom_text_style.dart'; +import 'package:eatvio_app/core/theme/theme_helper.dart'; +import 'package:eatvio_app/features/registration_v2/cubit/registration_cubit.dart'; +import 'package:eatvio_app/features/registration_v2/cubit/registration_state.dart'; +import 'package:eatvio_app/generated/l10n.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_svg/svg.dart'; + +class PasswordField extends StatefulWidget { + const PasswordField({super.key, required this.cubit}); + final RegistrationCubitV2 cubit; + @override + State createState() => _PasswordFieldState(); +} + +class _PasswordFieldState extends State { + bool copied = false; + @override + Widget build(BuildContext context) { + final s = S.of(context); + return BlocBuilder( + bloc: widget.cubit, + builder: (context, state) { + return Column( + children: [ + Container( + decoration: BoxDecoration(color: appTheme.lightGray0, borderRadius: BorderRadius.circular(20)), + padding: const EdgeInsets.only(left: 24, right: 16, top: 16, bottom: 16), + width: double.infinity, + child: Row( + children: [ + Text(state.password, style: TextStyles.textMMediumAuto.copyWith(color: appTheme.black)), + const Spacer(), + GestureDetector( + onTap: copied + ? null + : () async { + Clipboard.setData(ClipboardData(text: state.password)); + setState(() { + copied = true; + }); + Future.delayed(const Duration(seconds: 3), () { + setState(() { + copied = false; + }); + }); + }, + child: SvgPicture.asset( + copied ? 'assets/icons/check_filled.svg' : 'assets/icons/copy2.svg', + height: 20, + width: 20, + colorFilter: copied ? null : ColorFilter.mode(appTheme.black, BlendMode.srcIn), + ), + ), + ], + ), + ), + if (copied) ...[ + const SizedBox(height: 6), + Row( + children: [ + SvgPicture.asset('assets/icons/check.svg', height: 10, width: 10), + const SizedBox(width: 4), + Text(s.copied2, style: TextStyles.textSMedium.copyWith(color: appTheme.darkGreen)), + ], + ), + ], + SizedBox(height: copied ? 18 : 12), + ], + ); + }, + ); + } +} diff --git a/lib/features/registration_v2/presentation/widgets/phisical_activity.dart b/lib/features/registration_v2/presentation/widgets/phisical_activity.dart new file mode 100644 index 00000000..86bb1fb8 --- /dev/null +++ b/lib/features/registration_v2/presentation/widgets/phisical_activity.dart @@ -0,0 +1,83 @@ +import 'package:eatvio_app/core/theme/custom_text_style.dart'; +import 'package:eatvio_app/core/theme/theme_helper.dart'; +import 'package:eatvio_app/core/widgets/custom_drop_down_button.dart'; +import 'package:eatvio_app/features/registration_v2/cubit/registration_cubit.dart'; +import 'package:eatvio_app/features/registration_v2/cubit/registration_state.dart'; +import 'package:eatvio_app/generated/l10n.dart'; +import 'package:flutter/material.dart'; +import 'package:collection/collection.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +class PhisicalActivity extends StatefulWidget { + const PhisicalActivity({super.key}); + + @override + State createState() => _PhisicalActivityState(); +} + +class _PhisicalActivityState extends State { + final List activityDropDownTitles = []; + final List activityDropDownValues = [1.2, 1.375, 1.55, 1.7, 1.9]; + @override + void didChangeDependencies() { + super.didChangeDependencies(); + final s = S.of(context); + if (activityDropDownTitles.isEmpty) { + activityDropDownTitles.add(s.activity_first_value); + activityDropDownTitles.add(s.activity_second_value); + activityDropDownTitles.add(s.activity_third_value); + activityDropDownTitles.add(s.activity_fourth_value); + activityDropDownTitles.add(s.activity_fifth_value); + } + } + + // String _getTitleFromValue(double value) { + // switch (value) { + // case 1.2: + // return activityDropDownTitles[0]; + // case 1.375: + // return activityDropDownTitles[1]; + // case 1.55: + // return activityDropDownTitles[2]; + // case 1.7: + // return activityDropDownTitles[3]; + // case 1.9: + // return activityDropDownTitles[4]; + // default: + // return activityDropDownTitles[5]; + // } + // } + + @override + Widget build(BuildContext context) { + return BlocBuilder( + builder: (context, state) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CustomDropDownButton( + isExpanded: true, + onChanged: (value) { + if (value != null) { + context.read().setActivityCoefficient(value); + } + }, + items: activityDropDownTitles + .mapIndexed( + (index, value) => DropdownMenuItem( + value: activityDropDownValues[index], + child: Text(activityDropDownTitles[index], style: TextStyles.textMMedium.copyWith(color: appTheme.black)), + ), + ) + .toList(), + value: state.activityCoefficient == 0 ? null : state.activityCoefficient, + selectedItemBuilder: (context) { + return activityDropDownTitles.mapIndexed((index, value) => Text(activityDropDownTitles[index], overflow: TextOverflow.clip, maxLines: 1)).toList(); + }, + ), + ], + ); + }, + ); + } +} diff --git a/lib/features/registration_v2/presentation/widgets/second_step_content.dart b/lib/features/registration_v2/presentation/widgets/second_step_content.dart new file mode 100644 index 00000000..45efc931 --- /dev/null +++ b/lib/features/registration_v2/presentation/widgets/second_step_content.dart @@ -0,0 +1,175 @@ +import 'package:eatvio_app/core/app_config.dart'; +import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/core/locator_service.dart'; +import 'package:eatvio_app/core/theme/custom_text_style.dart'; +import 'package:eatvio_app/core/theme/theme_helper.dart'; +import 'package:eatvio_app/core/widgets/custom_outlined_button.dart'; +import 'package:eatvio_app/core/widgets/custom_text_form_field.dart'; +import 'package:eatvio_app/core/widgets/loader.dart'; +import 'package:eatvio_app/features/create_diet/presentation/widgets/error_widget.dart'; +import 'package:eatvio_app/features/registration_v2/cubit/registration_cubit.dart'; +import 'package:eatvio_app/features/registration_v2/cubit/registration_state.dart'; +import 'package:eatvio_app/features/registration_v2/presentation/widgets/phisical_activity.dart'; +import 'package:eatvio_app/features/registration_v2/presentation/widgets/show_successful_registration_bottom_sheet.dart'; +import 'package:eatvio_app/generated/l10n.dart'; +import 'package:flutter/gestures.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +import 'package:url_launcher/url_launcher.dart'; + +class SecondStepContent extends StatefulWidget { + const SecondStepContent({super.key}); + + @override + State createState() => _SecondStepContentState(); +} + +class _SecondStepContentState extends State { + bool isLoading = false; + final weightController = TextEditingController(); + final heightController = TextEditingController(); + + @override + void initState() { + super.initState(); + heightController.text = context.read().state.height.toString(); + weightController.text = context.read().state.weight.toString(); + } + + @override + Widget build(BuildContext context) { + final s = S.of(context); + return BlocBuilder( + builder: (context, state) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(s.last_step, style: TextStyles.textFS24FW700.copyWith(color: appTheme.black)), + const SizedBox(height: 12), + Text(s.user_data_desc, style: TextStyles.textSMedium.copyWith(color: appTheme.black)), + const SizedBox(height: 16), + Row( + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(s.height, style: TextStyles.textSMedium.copyWith(color: appTheme.black)), + const SizedBox(height: 4), + CustomTextFormField( + hintText: s.type_height, + hasError: !state.isHeightValid, + controller: heightController, + textInputType: const TextInputType.numberWithOptions(), + onChanged: (val) { + context.read().setHeight(int.parse(val)); + }, + ), + if (!state.isHeightValid) ValidationErrorWidget(error: s.height_error), + ], + ), + ), + const SizedBox(width: 12), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(s.weight, style: TextStyles.textSMedium.copyWith(color: appTheme.black)), + const SizedBox(height: 4), + CustomTextFormField( + hintText: s.type_weight, + hasError: !state.isWeightValid, + controller: weightController, + textInputType: const TextInputType.numberWithOptions(), + onChanged: (val) { + context.read().setWeight(int.parse(val)); + }, + ), + if (!state.isWeightValid) ValidationErrorWidget(error: s.weight_error), + ], + ), + ), + ], + ), + const SizedBox(height: 12), + Text(s.phisical_activity, style: TextStyles.textSMedium.copyWith(color: appTheme.black)), + const PhisicalActivity(), + const SizedBox(height: 12), + const Spacer(), + Row( + children: [ + InkWell( + onTap: () { + context.read().prevStep(); + }, + borderRadius: BorderRadius.circular(20), + child: Ink( + height: 52, + width: 52, + decoration: BoxDecoration(color: appTheme.gray50, borderRadius: BorderRadius.circular(20)), + child: Center(child: Icon(Icons.arrow_back_ios_new_rounded, color: appTheme.blueA400, size: 24)), + ), + ), + const SizedBox(width: 4), + isLoading + ? const Expanded(child: Center(child: Loader())) + : Expanded( + child: CustomOutlinedButton( + onPressed: () async { + setState(() { + isLoading = true; + }); + final cubit = context.read(); + final (commonResult, hasValidationError) = await cubit.register(); + setState(() { + isLoading = false; + }); + if (context.mounted && !hasValidationError) { + showRegistrationBottomSheet(context, cubit, commonResult); + } + }, + text: s.register, + height: 52, + buttonTextStyle: TextStyles.textSSemibold.copyWith(color: appTheme.whiteA700), + buttonStyle: ButtonStyle( + side: const WidgetStatePropertyAll(BorderSide.none), + backgroundColor: WidgetStatePropertyAll(appTheme.blueA400), + ), + ), + ), + ], + ), + const SizedBox(height: 12), + Center( + child: RichText( + textAlign: TextAlign.center, + text: TextSpan( + text: 'Нажимая “Зарегистрироваться”, Вы соглашаетесь \n', + style: const TextStyle(fontSize: 12, color: Colors.black), + children: [ + const TextSpan(text: 'c '), + if (!hidePlans) ...[ + TextSpan( + text: ' Публичной офертой', + style: TextStyle(fontSize: 12, color: appTheme.blueA400, decorationColor: appTheme.blueA400, decoration: TextDecoration.underline), + recognizer: TapGestureRecognizer()..onTap = () async => await launchUrl(Uri.parse('${sl().baseUrl}/oferta_bs.pdf')), + ), + const TextSpan(text: ' и '), + ], + TextSpan( + text: 'Политикой конфиденциальности\nи защитой персональных данных', + style: TextStyle(fontSize: 12, color: appTheme.blueA400, decorationColor: appTheme.blueA400, decoration: TextDecoration.underline), + recognizer: TapGestureRecognizer()..onTap = () async => await launchUrl(Uri.parse('${sl().baseUrl}/docs/privacy.pdf')), + ), + ], + ), + ), + ), + const SizedBox(height: 30), + ], + ); + }, + ); + } +} diff --git a/lib/features/registration_v2/presentation/widgets/sex_widget.dart b/lib/features/registration_v2/presentation/widgets/sex_widget.dart new file mode 100644 index 00000000..60f0944f --- /dev/null +++ b/lib/features/registration_v2/presentation/widgets/sex_widget.dart @@ -0,0 +1,98 @@ +import 'package:eatvio_app/core/theme/custom_text_style.dart'; +import 'package:eatvio_app/core/theme/theme_helper.dart'; +import 'package:eatvio_app/features/create_diet/presentation/widgets/error_widget.dart'; +import 'package:eatvio_app/features/registration_v2/cubit/registration_cubit.dart'; +import 'package:eatvio_app/features/registration_v2/cubit/registration_state.dart'; +import 'package:eatvio_app/generated/l10n.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +class SexWidget extends StatelessWidget { + const SexWidget({super.key}); + + @override + Widget build(BuildContext context) { + final s = S.of(context); + return BlocBuilder( + builder: (context, state) { + return Column( + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(s.sex, style: TextStyles.textSMedium.copyWith(color: appTheme.black)), + InkWell( + onTap: () { + context.read().setGender('male'); + }, + borderRadius: BorderRadius.circular(20), + child: Ink( + height: 60, + decoration: BoxDecoration( + color: const Color(0xFFF6F6F6), + borderRadius: BorderRadius.circular(20), + border: state.isGenderValid + ? state.gender == 'male' + ? Border.all(width: 2, color: appTheme.blueA400) + : null + : Border.all(width: 1, color: appTheme.red), + ), + child: Center( + child: Text( + s.male_short, + style: TextStyle( + color: state.gender == 'male' ? appTheme.blueA400 : const Color(0xFF323F4B), + fontSize: 16, + fontWeight: FontWeight.w500, + ), + ), + ), + ), + ), + ], + ), + ), + const SizedBox(width: 4), + Expanded( + child: InkWell( + onTap: () { + context.read().setGender('female'); + }, + borderRadius: BorderRadius.circular(20), + child: Ink( + height: 60, + decoration: BoxDecoration( + color: const Color(0xFFF6F6F6), + borderRadius: BorderRadius.circular(20), + border: state.isGenderValid + ? state.gender == 'female' + ? Border.all(width: 2, color: appTheme.blueA400) + : null + : Border.all(width: 1, color: appTheme.red), + ), + child: Center( + child: Text( + s.female_short, + style: TextStyle( + color: state.gender == 'female' ? appTheme.blueA400 : const Color(0xFF323F4B), + fontSize: 16, + fontWeight: FontWeight.w500, + ), + ), + ), + ), + ), + ), + ], + ), + if (!state.isGenderValid) ...[const SizedBox(height: 4), ValidationErrorWidget(error: s.gender_error)], + ], + ); + }, + ); + } +} diff --git a/lib/features/registration_v2/presentation/widgets/show_successful_registration_bottom_sheet.dart b/lib/features/registration_v2/presentation/widgets/show_successful_registration_bottom_sheet.dart new file mode 100644 index 00000000..7be50ec2 --- /dev/null +++ b/lib/features/registration_v2/presentation/widgets/show_successful_registration_bottom_sheet.dart @@ -0,0 +1,106 @@ +import 'package:eatvio_app/core/app_router.dart'; +import 'package:eatvio_app/core/routing/route_constants.dart'; +import 'package:eatvio_app/core/theme/custom_text_style.dart'; +import 'package:eatvio_app/core/theme/theme_helper.dart'; +import 'package:eatvio_app/core/widgets/custom_outlined_button.dart'; +import 'package:eatvio_app/features/registration_v2/cubit/registration_cubit.dart'; +import 'package:eatvio_app/features/registration_v2/presentation/widgets/password_field.dart'; +import 'package:eatvio_app/generated/l10n.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:go_router/go_router.dart'; + +void showRegistrationBottomSheet(BuildContext context, RegistrationCubitV2 cubit, bool isSuccess) { + showModalBottomSheet( + context: context, + isScrollControlled: true, + backgroundColor: Colors.transparent, + builder: (context) => Container( + margin: EdgeInsets.only(left: 8, right: 8, bottom: MediaQuery.of(context).viewInsets.bottom + MediaQuery.of(context).padding.bottom), + decoration: BoxDecoration(borderRadius: BorderRadius.circular(12), color: appTheme.whiteA700), + child: RegistrationBottomSheet(cubit: cubit, isSuccess: isSuccess), + ), + ); +} + +class RegistrationBottomSheet extends StatefulWidget { + const RegistrationBottomSheet({super.key, required this.cubit, required this.isSuccess}); + final RegistrationCubitV2 cubit; + final bool isSuccess; + @override + State createState() => _RegistrationBottomSheetState(); +} + +class _RegistrationBottomSheetState extends State { + late bool isSuccess; + bool isLoading = false; + @override + void initState() { + super.initState(); + isSuccess = widget.isSuccess; + } + + @override + Widget build(BuildContext context) { + final s = S.of(context); + return Padding( + padding: const EdgeInsets.all(20), + child: Column( + mainAxisSize: MainAxisSize.min, + children: isSuccess + ? [ + Padding( + padding: const EdgeInsets.only(bottom: 12.0), + child: Row( + children: [ + SvgPicture.asset('assets/icons/sucess.svg', height: 16, width: 16), + const SizedBox(width: 8), + Text(s.registration_completed, style: TextStyles.textFS22FW600.copyWith(color: appTheme.black)), + ], + ), + ), + + Padding( + padding: const EdgeInsets.only(bottom: 16.0), + child: Text(s.acc_has_been_created, style: TextStyles.textMMediumAuto.copyWith(color: appTheme.darkGrey)), + ), + PasswordField(cubit: widget.cubit), + Padding( + padding: const EdgeInsets.only(bottom: 20.0), + child: Text(s.password_desc, style: TextStyles.textSMedium.copyWith(color: appTheme.darkGrey)), + ), + + CustomOutlinedButton( + text: s.login, + height: 52, + buttonTextStyle: TextStyles.textMSemibold.copyWith(color: appTheme.whiteA700), + buttonStyle: ButtonStyle(side: const WidgetStatePropertyAll(BorderSide.none), backgroundColor: WidgetStatePropertyAll(appTheme.blueA400)), + onPressed: () async { + AppRouter.navigatorKey.currentContext?.go(RouteConstants.feedScreen); + }, + ), + const SizedBox(width: 20), + //button + ] + : [ + Padding( + padding: const EdgeInsets.only(bottom: 12.0), + child: Row( + children: [ + SvgPicture.asset('assets/icons/close_mark.svg', height: 16, width: 16), + const SizedBox(width: 8), + Text(s.signUpFailed, style: TextStyles.textFS22FW600.copyWith(color: appTheme.black)), + ], + ), + ), + + Padding( + padding: const EdgeInsets.only(bottom: 16.0), + child: Text(s.error_desc, style: TextStyles.textMMediumAuto.copyWith(color: appTheme.darkGrey)), + ), + const SizedBox(width: 20), + ], + ), + ); + } +} diff --git a/lib/features/registration_v2/presentation/widgets/step_progress.dart b/lib/features/registration_v2/presentation/widgets/step_progress.dart new file mode 100644 index 00000000..7bb3497c --- /dev/null +++ b/lib/features/registration_v2/presentation/widgets/step_progress.dart @@ -0,0 +1,24 @@ +import 'package:eatvio_app/core/theme/theme_helper.dart'; +import 'package:eatvio_app/features/registration_v2/cubit/registration_cubit.dart'; +import 'package:eatvio_app/features/registration_v2/cubit/registration_state.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +class StepProgress extends StatelessWidget { + const StepProgress({super.key}); + + @override + Widget build(BuildContext context) { + return BlocBuilder( + builder: (context, state) { + return LinearProgressIndicator( + value: state.step == 0 ? 0.5 : 1, + borderRadius: BorderRadius.circular(6), + color: appTheme.blueA400, + backgroundColor: appTheme.greyD9, + minHeight: 8, + ); + }, + ); + } +} diff --git a/lib/features/registration_v2/presentation/widgets/step_widget.dart b/lib/features/registration_v2/presentation/widgets/step_widget.dart new file mode 100644 index 00000000..1176213a --- /dev/null +++ b/lib/features/registration_v2/presentation/widgets/step_widget.dart @@ -0,0 +1,24 @@ +import 'package:eatvio_app/core/theme/custom_text_style.dart'; +import 'package:eatvio_app/core/theme/theme_helper.dart'; +import 'package:eatvio_app/features/registration_v2/cubit/registration_cubit.dart'; +import 'package:eatvio_app/features/registration_v2/cubit/registration_state.dart'; +import 'package:eatvio_app/generated/l10n.dart'; +import 'package:flutter/widgets.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +class StepWidget extends StatelessWidget { + const StepWidget({super.key}); + + @override + Widget build(BuildContext context) { + final s = S.of(context); + return BlocBuilder( + builder: (context, state) { + return Padding( + padding: const EdgeInsets.only(right: 16.0), + child: Text(s.step_widget(state.step + 1), style: TextStyles.textMMedium.copyWith(color: appTheme.black)), + ); + }, + ); + } +} diff --git a/lib/features/registration_v2/repositories/registration_repository_v2.dart b/lib/features/registration_v2/repositories/registration_repository_v2.dart new file mode 100644 index 00000000..b30e61d8 --- /dev/null +++ b/lib/features/registration_v2/repositories/registration_repository_v2.dart @@ -0,0 +1,16 @@ +import 'package:eatvio_app/features/registration_v2/models/registration_model.dart'; +import 'package:eatvio_app/features/registration_v2/services/registration_service_v2.dart'; + +class RegistrationRepositoryV2 { + final RegistrationServiceV2 registrationService; + RegistrationRepositoryV2({required this.registrationService}); + + Future register({required RegistrationModel registrationModel}) async { + try { + final response = await registrationService.register(model: registrationModel.toJson()); + return response['token']; + } catch (e) { + rethrow; + } + } +} diff --git a/lib/features/registration_v2/services/registration_service_v2.dart b/lib/features/registration_v2/services/registration_service_v2.dart new file mode 100644 index 00000000..2472eb40 --- /dev/null +++ b/lib/features/registration_v2/services/registration_service_v2.dart @@ -0,0 +1,15 @@ +import 'package:dio/dio.dart'; +import 'package:retrofit/retrofit.dart'; + +part 'registration_service_v2.g.dart'; + +@RestApi() +abstract class RegistrationServiceV2 { + factory RegistrationServiceV2(Dio dio, {String baseUrl}) = _RegistrationServiceV2; + + @POST('/api/register') + Future> register({ + @Body() required Map model, + }); + +} diff --git a/lib/generated/intl/messages_en.dart b/lib/generated/intl/messages_en.dart index 3402d123..28705dcb 100644 --- a/lib/generated/intl/messages_en.dart +++ b/lib/generated/intl/messages_en.dart @@ -27,22 +27,24 @@ class MessageLookup extends MessageLookupByLibrary { static String m2(planName, name) => "План «${planName}» с пользователем ${name} начался"; - static String m3(planName, name) => + static String m3(step) => "шаг ${step} из 2"; + + static String m4(planName, name) => "Завтра начинается план «${planName}» с пользователем ${name}"; - static String m4(planName) => + static String m5(planName) => "Завтра начнется прохождение плана «${planName}»"; - static String m5(name, planName) => + static String m6(name, planName) => "Пользователь ${name} отменил подписку на план «${planName}»"; - static String m6(name, planName) => + static String m7(name, planName) => "Пользователь ${name} оплатил план «${planName}»"; - static String m7(name, planName) => + static String m8(name, planName) => "Пользователь ${name} подписался на план «${planName}»"; - static String m8(planName) => "Вы отменили подписку на план «${planName}»"; + static String m9(planName) => "Вы отменили подписку на план «${planName}»"; final messages = _notInlinedMessages(_notInlinedMessages); static Map _notInlinedMessages(_) => { @@ -51,6 +53,12 @@ class MessageLookup extends MessageLookupByLibrary { "about_diet": MessageLookupByLibrary.simpleMessage("Об этой диете"), "about_plan": MessageLookupByLibrary.simpleMessage("Об этом плане"), "about_recipe": MessageLookupByLibrary.simpleMessage("Об этом рецепте"), + "acc_has_been_created": MessageLookupByLibrary.simpleMessage( + "Ваш аккаунт создан. Для входа используйте этот пароль:", + ), + "acc_has_been_created_btn": MessageLookupByLibrary.simpleMessage( + "Войти в аккаунт", + ), "accountDeleting": MessageLookupByLibrary.simpleMessage( "Удаление аккаунта", ), @@ -59,6 +67,21 @@ class MessageLookup extends MessageLookupByLibrary { "Кол-во активных консультаций", ), "active_diet_state": MessageLookupByLibrary.simpleMessage("Активная"), + "activity_fifth_value": MessageLookupByLibrary.simpleMessage( + "1,9 — экстремальный (несколько интенсивных тренировок в день)", + ), + "activity_first_value": MessageLookupByLibrary.simpleMessage( + "1,2 — минимальный (сидячая работа, отсутствие физических нагрузок)", + ), + "activity_fourth_value": MessageLookupByLibrary.simpleMessage( + "1,7 — высокий (тренировки 30–60 мин 5–7 раза в неделю; тяжёлая физическая работа)", + ), + "activity_second_value": MessageLookupByLibrary.simpleMessage( + "1,375 — низкий (тренировки не менее 20 мин 1–3 раза в неделю)", + ), + "activity_third_value": MessageLookupByLibrary.simpleMessage( + "1,55 — умеренный (тренировки 30–60 мин 3–4 раза в неделю)", + ), "add": MessageLookupByLibrary.simpleMessage("Добавить"), "addAtLeastOneItem": MessageLookupByLibrary.simpleMessage( "Добавьте хотя бы одину опцию", @@ -218,6 +241,7 @@ class MessageLookup extends MessageLookupByLibrary { "continueButton": MessageLookupByLibrary.simpleMessage("Продолжить"), "continue_": MessageLookupByLibrary.simpleMessage("Продолжить"), "copied": MessageLookupByLibrary.simpleMessage("cкопирован"), + "copied2": MessageLookupByLibrary.simpleMessage("Скопировано!"), "copy": MessageLookupByLibrary.simpleMessage("Скопировать"), "copy_link": MessageLookupByLibrary.simpleMessage("Скопировать ссылку"), "copy_referral_link": MessageLookupByLibrary.simpleMessage( @@ -269,6 +293,9 @@ class MessageLookup extends MessageLookupByLibrary { "Дата старта начала консультации установлена", ), "date_of_birth": MessageLookupByLibrary.simpleMessage("Дата рождения"), + "date_of_birth_error": MessageLookupByLibrary.simpleMessage( + "Некорректная дата рождения", + ), "day": MessageLookupByLibrary.simpleMessage("День"), "dayComment": MessageLookupByLibrary.simpleMessage( "Комментарий ко всему дню", @@ -328,6 +355,9 @@ class MessageLookup extends MessageLookupByLibrary { "email_empty": MessageLookupByLibrary.simpleMessage( "Необходимо ввести адрес электронной почты", ), + "email_error": MessageLookupByLibrary.simpleMessage( + "Некорректный адрес электронной почты", + ), "email_invalid": MessageLookupByLibrary.simpleMessage( "Некорректный адрес электронной почты", ), @@ -346,6 +376,9 @@ class MessageLookup extends MessageLookupByLibrary { "enter_information": MessageLookupByLibrary.simpleMessage( "Введите информацию...", ), + "error_desc": MessageLookupByLibrary.simpleMessage( + "Произошла ошибка. Мы уже работаем над её устранением. Попробуйте позже", + ), "exit": MessageLookupByLibrary.simpleMessage("Выйти"), "expand": MessageLookupByLibrary.simpleMessage("Показать полностью"), "explainResonOfCancelation": MessageLookupByLibrary.simpleMessage( @@ -370,6 +403,7 @@ class MessageLookup extends MessageLookupByLibrary { "Ваши любимые/нелюбимые продукты питания?", ), "female": MessageLookupByLibrary.simpleMessage("Женский"), + "female_short": MessageLookupByLibrary.simpleMessage("Ж"), "fillYasterday": MessageLookupByLibrary.simpleMessage( "Заполните вчерашний день", ), @@ -384,6 +418,9 @@ class MessageLookup extends MessageLookupByLibrary { "first_name_short": MessageLookupByLibrary.simpleMessage( "В имени должен быть минимум 1 символ", ), + "first_name_validation_error": MessageLookupByLibrary.simpleMessage( + "Имя обязательно к заполнению", + ), "fit_type": MessageLookupByLibrary.simpleMessage("Поддержание формы"), "fit_type_desc": MessageLookupByLibrary.simpleMessage( "План питания для поддержания формы сбалансированный и разнообразный, чтобы обеспечить организм всеми необходимыми питательными веществами. Общие принципы: \n● Дробное питание; \n● Разнообразие продуктов; \n● Контроль порций; \n● Питьевой режим; \n● Ограничение вредных продуктов;", @@ -404,6 +441,7 @@ class MessageLookup extends MessageLookupByLibrary { "from_a_to_z": MessageLookupByLibrary.simpleMessage("Название: А-Я"), "from_z_to_a": MessageLookupByLibrary.simpleMessage("Название: Я-А"), "gallery": MessageLookupByLibrary.simpleMessage("Галерея"), + "gender_error": MessageLookupByLibrary.simpleMessage("Выберите пол"), "general_info": MessageLookupByLibrary.simpleMessage("Общая информация"), "goToMyDiets": MessageLookupByLibrary.simpleMessage( "Перейти к моим диетам", @@ -424,6 +462,7 @@ class MessageLookup extends MessageLookupByLibrary { "Враждебные высказывания", ), "height": MessageLookupByLibrary.simpleMessage("Рост"), + "height_error": MessageLookupByLibrary.simpleMessage("Введите рост"), "height_measurements": MessageLookupByLibrary.simpleMessage("Замер роста"), "hide": MessageLookupByLibrary.simpleMessage("Свернуть"), "hip_circumference": MessageLookupByLibrary.simpleMessage("Обхват бедер"), @@ -452,9 +491,13 @@ class MessageLookup extends MessageLookupByLibrary { "last_name_empty": MessageLookupByLibrary.simpleMessage( "Фамилия обязательна для заполнения", ), + "last_name_error": MessageLookupByLibrary.simpleMessage( + "Фамилия обязательна для заполнения", + ), "last_name_short": MessageLookupByLibrary.simpleMessage( "В фамилии должен быть минимум 6 символов", ), + "last_step": MessageLookupByLibrary.simpleMessage("Последний шаг"), "lawViolation": MessageLookupByLibrary.simpleMessage( "Нарушение законодательства", ), @@ -474,11 +517,13 @@ class MessageLookup extends MessageLookupByLibrary { "Ссылка успешно скопирована", ), "loading": MessageLookupByLibrary.simpleMessage("Загрузка..."), + "login": MessageLookupByLibrary.simpleMessage("Войти в аккаунт"), "lower": MessageLookupByLibrary.simpleMessage("Нижнее"), "mail_was_copied": MessageLookupByLibrary.simpleMessage( "Почта успешно скопирована", ), "male": MessageLookupByLibrary.simpleMessage("Мужской"), + "male_short": MessageLookupByLibrary.simpleMessage("М"), "markAsRead": MessageLookupByLibrary.simpleMessage( "Отметить всё прочитанным", ), @@ -530,6 +575,7 @@ class MessageLookup extends MessageLookupByLibrary { "В имени пользователя должно быть минимум 6 символов", ), "new_card": MessageLookupByLibrary.simpleMessage("Добавить карту"), + "next": MessageLookupByLibrary.simpleMessage("Далее"), "nicotine": MessageLookupByLibrary.simpleMessage("Никотин"), "no": MessageLookupByLibrary.simpleMessage("Нет"), "no_account": MessageLookupByLibrary.simpleMessage("У меня нет аккаунта"), @@ -574,6 +620,9 @@ class MessageLookup extends MessageLookupByLibrary { "password_confirmation_mismatch": MessageLookupByLibrary.simpleMessage( "Пароли не совпадают", ), + "password_desc": MessageLookupByLibrary.simpleMessage( + "Сохраните его в надежном месте! Вы сможете изменить пароль в настройках профиля", + ), "password_empty": MessageLookupByLibrary.simpleMessage( "Пароль обязателен для заполнения", ), @@ -592,6 +641,13 @@ class MessageLookup extends MessageLookupByLibrary { "Персональная диета установлена", ), "personal_diet_state": MessageLookupByLibrary.simpleMessage("Персональная"), + "phisical_activity": MessageLookupByLibrary.simpleMessage( + "Уровень физической активности", + ), + "phone": MessageLookupByLibrary.simpleMessage("Телефон"), + "phone_error": MessageLookupByLibrary.simpleMessage( + "Некорректный номер телефона", + ), "photo": MessageLookupByLibrary.simpleMessage("Фото"), "physical_fitness": MessageLookupByLibrary.simpleMessage( "Физическая форма", @@ -665,6 +721,10 @@ class MessageLookup extends MessageLookupByLibrary { "refuse_order": MessageLookupByLibrary.simpleMessage( "Отказаться от заказа", ), + "register": MessageLookupByLibrary.simpleMessage("Зарегистрироваться"), + "registration_completed": MessageLookupByLibrary.simpleMessage( + "Регистрация завершена!", + ), "removeFromActive": MessageLookupByLibrary.simpleMessage( "Снять с публикации", ), @@ -677,6 +737,9 @@ class MessageLookup extends MessageLookupByLibrary { "settings": MessageLookupByLibrary.simpleMessage("Настройки"), "sex": MessageLookupByLibrary.simpleMessage("Пол"), "share": MessageLookupByLibrary.simpleMessage("Поделиться"), + "signUpFailed": MessageLookupByLibrary.simpleMessage( + "Регистрация не удалась!", + ), "skip": MessageLookupByLibrary.simpleMessage("Пропустить"), "slim": MessageLookupByLibrary.simpleMessage("Похудение"), "slim_type": MessageLookupByLibrary.simpleMessage("Похудение"), @@ -717,6 +780,7 @@ class MessageLookup extends MessageLookupByLibrary { "step_by_step_photo_recipe": MessageLookupByLibrary.simpleMessage( "Пошаговый фоторецепт", ), + "step_widget": m3, "successfully_published": MessageLookupByLibrary.simpleMessage( "успешно опубликован", ), @@ -741,8 +805,8 @@ class MessageLookup extends MessageLookupByLibrary { "toOffer": MessageLookupByLibrary.simpleMessage("Предложить"), "to_draft": MessageLookupByLibrary.simpleMessage("В черновик"), "to_order": MessageLookupByLibrary.simpleMessage("Заказать"), - "tommorowPlanWithUserWillStart": m3, - "tomorrowYourPlanWillStart": m4, + "tommorowPlanWithUserWillStart": m4, + "tomorrowYourPlanWillStart": m5, "try_again": MessageLookupByLibrary.simpleMessage("Попробовать снова"), "try_again_2": MessageLookupByLibrary.simpleMessage("Попробуйте ещё раз"), "typeAmoutOfReturn": MessageLookupByLibrary.simpleMessage( @@ -757,9 +821,12 @@ class MessageLookup extends MessageLookupByLibrary { "typePortionComment": MessageLookupByLibrary.simpleMessage( "Прокомментируйте блюдо", ), + "type_email": MessageLookupByLibrary.simpleMessage("Введите email"), + "type_height": MessageLookupByLibrary.simpleMessage("Введите рост"), "type_here_your_complaint": MessageLookupByLibrary.simpleMessage( "Напишите здесь свою жалобу", ), + "type_weight": MessageLookupByLibrary.simpleMessage("Введите вес"), "unfavorite_foods": MessageLookupByLibrary.simpleMessage( "Нелюбимые продукты", ), @@ -767,7 +834,7 @@ class MessageLookup extends MessageLookupByLibrary { "Верхние показатели давления:", ), "upper": MessageLookupByLibrary.simpleMessage("Верхнее"), - "userCanceldThePlanSubscription": m5, + "userCanceldThePlanSubscription": m6, "userConfirmedPlanCompletion": MessageLookupByLibrary.simpleMessage( "Пользователь подтвердил прохождения плана. В ближайшее время Вы получите", ), @@ -775,12 +842,15 @@ class MessageLookup extends MessageLookupByLibrary { MessageLookupByLibrary.simpleMessage( "Пользователь подтвердил прохождения плана.", ), - "userPaidThePlan": m6, - "userSubscribedToPlan": m7, + "userPaidThePlan": m7, + "userSubscribedToPlan": m8, "user_authorization": MessageLookupByLibrary.simpleMessage( "Аутентификация", ), "user_data": MessageLookupByLibrary.simpleMessage("Данные пользователя"), + "user_data_desc": MessageLookupByLibrary.simpleMessage( + "Эти данные нужны для корректной работы дневника питания и расчета вашей дневной нормы потребления КБЖУ", + ), "user_info": MessageLookupByLibrary.simpleMessage("Анкета пользователя"), "user_registration": MessageLookupByLibrary.simpleMessage( "Регистрация пользователя", @@ -811,6 +881,7 @@ class MessageLookup extends MessageLookupByLibrary { "weapon": MessageLookupByLibrary.simpleMessage("Оружие"), "weight": MessageLookupByLibrary.simpleMessage("Вес"), "weight_chart": MessageLookupByLibrary.simpleMessage("График веса"), + "weight_error": MessageLookupByLibrary.simpleMessage("Введите вес"), "weight_measurements": MessageLookupByLibrary.simpleMessage("Замер веса"), "wellness": MessageLookupByLibrary.simpleMessage("Улучшение самочувствия"), "wellness_type": MessageLookupByLibrary.simpleMessage( @@ -829,7 +900,7 @@ class MessageLookup extends MessageLookupByLibrary { "youCanComplain": MessageLookupByLibrary.simpleMessage( "Если вас что-то не устроило, вы можете подать жалобу", ), - "youCanceledSubscriptionToPlan": m8, + "youCanceledSubscriptionToPlan": m9, "youShureYouWantToCancelOrder": MessageLookupByLibrary.simpleMessage( "Вы уверены, что хотите отменить заказ?", ), @@ -853,6 +924,8 @@ class MessageLookup extends MessageLookupByLibrary { ), "your_gender": MessageLookupByLibrary.simpleMessage("Ваш пол?"), "your_height": MessageLookupByLibrary.simpleMessage("Ваш рост:"), + "your_last_name": MessageLookupByLibrary.simpleMessage("Ваша фамилия"), + "your_name": MessageLookupByLibrary.simpleMessage("Ваше имя"), "your_rating": MessageLookupByLibrary.simpleMessage("Ваш рейтинг"), "your_schedule": MessageLookupByLibrary.simpleMessage("Ваш режим дня?"), "your_weight": MessageLookupByLibrary.simpleMessage("Ваш вес:"), diff --git a/lib/generated/l10n.dart b/lib/generated/l10n.dart index 71f87fc9..85a0adf7 100644 --- a/lib/generated/l10n.dart +++ b/lib/generated/l10n.dart @@ -3579,6 +3579,311 @@ class S { ); } + /// `шаг {step} из 2` + String step_widget(Object step) { + return Intl.message( + 'шаг $step из 2', + name: 'step_widget', + desc: '', + args: [step], + ); + } + + /// `Ваше имя` + String get your_name { + return Intl.message('Ваше имя', name: 'your_name', desc: '', args: []); + } + + /// `Ваша фамилия` + String get your_last_name { + return Intl.message( + 'Ваша фамилия', + name: 'your_last_name', + desc: '', + args: [], + ); + } + + /// `Введите email` + String get type_email { + return Intl.message( + 'Введите email', + name: 'type_email', + desc: '', + args: [], + ); + } + + /// `Телефон` + String get phone { + return Intl.message('Телефон', name: 'phone', desc: '', args: []); + } + + /// `М` + String get male_short { + return Intl.message('М', name: 'male_short', desc: '', args: []); + } + + /// `Ж` + String get female_short { + return Intl.message('Ж', name: 'female_short', desc: '', args: []); + } + + /// `Далее` + String get next { + return Intl.message('Далее', name: 'next', desc: '', args: []); + } + + /// `Введите рост` + String get type_height { + return Intl.message( + 'Введите рост', + name: 'type_height', + desc: '', + args: [], + ); + } + + /// `Введите вес` + String get type_weight { + return Intl.message('Введите вес', name: 'type_weight', desc: '', args: []); + } + + /// `Зарегистрироваться` + String get register { + return Intl.message( + 'Зарегистрироваться', + name: 'register', + desc: '', + args: [], + ); + } + + /// `Последний шаг` + String get last_step { + return Intl.message('Последний шаг', name: 'last_step', desc: '', args: []); + } + + /// `Эти данные нужны для корректной работы дневника питания и расчета вашей дневной нормы потребления КБЖУ` + String get user_data_desc { + return Intl.message( + 'Эти данные нужны для корректной работы дневника питания и расчета вашей дневной нормы потребления КБЖУ', + name: 'user_data_desc', + desc: '', + args: [], + ); + } + + /// `1,2 — минимальный (сидячая работа, отсутствие физических нагрузок)` + String get activity_first_value { + return Intl.message( + '1,2 — минимальный (сидячая работа, отсутствие физических нагрузок)', + name: 'activity_first_value', + desc: '', + args: [], + ); + } + + /// `1,375 — низкий (тренировки не менее 20 мин 1–3 раза в неделю)` + String get activity_second_value { + return Intl.message( + '1,375 — низкий (тренировки не менее 20 мин 1–3 раза в неделю)', + name: 'activity_second_value', + desc: '', + args: [], + ); + } + + /// `1,55 — умеренный (тренировки 30–60 мин 3–4 раза в неделю)` + String get activity_third_value { + return Intl.message( + '1,55 — умеренный (тренировки 30–60 мин 3–4 раза в неделю)', + name: 'activity_third_value', + desc: '', + args: [], + ); + } + + /// `1,7 — высокий (тренировки 30–60 мин 5–7 раза в неделю; тяжёлая физическая работа)` + String get activity_fourth_value { + return Intl.message( + '1,7 — высокий (тренировки 30–60 мин 5–7 раза в неделю; тяжёлая физическая работа)', + name: 'activity_fourth_value', + desc: '', + args: [], + ); + } + + /// `1,9 — экстремальный (несколько интенсивных тренировок в день)` + String get activity_fifth_value { + return Intl.message( + '1,9 — экстремальный (несколько интенсивных тренировок в день)', + name: 'activity_fifth_value', + desc: '', + args: [], + ); + } + + /// `Регистрация завершена!` + String get registration_completed { + return Intl.message( + 'Регистрация завершена!', + name: 'registration_completed', + desc: '', + args: [], + ); + } + + /// `Ваш аккаунт создан. Для входа используйте этот пароль:` + String get acc_has_been_created { + return Intl.message( + 'Ваш аккаунт создан. Для входа используйте этот пароль:', + name: 'acc_has_been_created', + desc: '', + args: [], + ); + } + + /// `Сохраните его в надежном месте! Вы сможете изменить пароль в настройках профиля` + String get password_desc { + return Intl.message( + 'Сохраните его в надежном месте! Вы сможете изменить пароль в настройках профиля', + name: 'password_desc', + desc: '', + args: [], + ); + } + + /// `Войти в аккаунт` + String get acc_has_been_created_btn { + return Intl.message( + 'Войти в аккаунт', + name: 'acc_has_been_created_btn', + desc: '', + args: [], + ); + } + + /// `Имя обязательно к заполнению` + String get first_name_validation_error { + return Intl.message( + 'Имя обязательно к заполнению', + name: 'first_name_validation_error', + desc: '', + args: [], + ); + } + + /// `Фамилия обязательна для заполнения` + String get last_name_error { + return Intl.message( + 'Фамилия обязательна для заполнения', + name: 'last_name_error', + desc: '', + args: [], + ); + } + + /// `Некорректный адрес электронной почты` + String get email_error { + return Intl.message( + 'Некорректный адрес электронной почты', + name: 'email_error', + desc: '', + args: [], + ); + } + + /// `Некорректный номер телефона` + String get phone_error { + return Intl.message( + 'Некорректный номер телефона', + name: 'phone_error', + desc: '', + args: [], + ); + } + + /// `Выберите пол` + String get gender_error { + return Intl.message( + 'Выберите пол', + name: 'gender_error', + desc: '', + args: [], + ); + } + + /// `Некорректная дата рождения` + String get date_of_birth_error { + return Intl.message( + 'Некорректная дата рождения', + name: 'date_of_birth_error', + desc: '', + args: [], + ); + } + + /// `Введите рост` + String get height_error { + return Intl.message( + 'Введите рост', + name: 'height_error', + desc: '', + args: [], + ); + } + + /// `Введите вес` + String get weight_error { + return Intl.message( + 'Введите вес', + name: 'weight_error', + desc: '', + args: [], + ); + } + + /// `Уровень физической активности` + String get phisical_activity { + return Intl.message( + 'Уровень физической активности', + name: 'phisical_activity', + desc: '', + args: [], + ); + } + + /// `Скопировано!` + String get copied2 { + return Intl.message('Скопировано!', name: 'copied2', desc: '', args: []); + } + + /// `Войти в аккаунт` + String get login { + return Intl.message('Войти в аккаунт', name: 'login', desc: '', args: []); + } + + /// `Регистрация не удалась!` + String get signUpFailed { + return Intl.message( + 'Регистрация не удалась!', + name: 'signUpFailed', + desc: '', + args: [], + ); + } + + /// `Произошла ошибка. Мы уже работаем над её устранением. Попробуйте позже` + String get error_desc { + return Intl.message( + 'Произошла ошибка. Мы уже работаем над её устранением. Попробуйте позже', + name: 'error_desc', + desc: '', + args: [], + ); + } + /// `Покупатель` String get customer { return Intl.message('Покупатель', name: 'customer', desc: '', args: []); diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb index c64c0321..2926e786 100644 --- a/lib/l10n/intl_en.arb +++ b/lib/l10n/intl_en.arb @@ -423,6 +423,41 @@ "cannotDeleteAccount": "Не получилось удалить ваш аккаунт", "resend": "Отправить повторно", "notifications": "Уведомления", + "step_widget": "шаг {step} из 2", + "your_name": "Ваше имя", + "your_last_name": "Ваша фамилия", + "type_email": "Введите email", + "phone": "Телефон", + "male_short": "М", + "female_short": "Ж", + "next": "Далее", + "type_height": "Введите рост", + "type_weight": "Введите вес", + "register": "Зарегистрироваться", + "last_step": "Последний шаг", + "user_data_desc": "Эти данные нужны для корректной работы дневника питания и расчета вашей дневной нормы потребления КБЖУ", + "activity_first_value": "1,2 — минимальный (сидячая работа, отсутствие физических нагрузок)", + "activity_second_value": "1,375 — низкий (тренировки не менее 20 мин 1–3 раза в неделю)", + "activity_third_value": "1,55 — умеренный (тренировки 30–60 мин 3–4 раза в неделю)", + "activity_fourth_value": "1,7 — высокий (тренировки 30–60 мин 5–7 раза в неделю; тяжёлая физическая работа)", + "activity_fifth_value": "1,9 — экстремальный (несколько интенсивных тренировок в день)", + "registration_completed": "Регистрация завершена!", + "acc_has_been_created": "Ваш аккаунт создан. Для входа используйте этот пароль:", + "password_desc": "Сохраните его в надежном месте! Вы сможете изменить пароль в настройках профиля", + "acc_has_been_created_btn": "Войти в аккаунт", + "first_name_validation_error": "Имя обязательно к заполнению", + "last_name_error": "Фамилия обязательна для заполнения", + "email_error": "Некорректный адрес электронной почты", + "phone_error": "Некорректный номер телефона", + "gender_error": "Выберите пол", + "date_of_birth_error": "Некорректная дата рождения", + "height_error": "Введите рост", + "weight_error": "Введите вес", + "phisical_activity": "Уровень физической активности", + "copied2": "Скопировано!", + "login": "Войти в аккаунт", + "signUpFailed": "Регистрация не удалась!", + "error_desc": "Произошла ошибка. Мы уже работаем над её устранением. Попробуйте позже", "customer": "Покупатель", "personal_diet_set": "Персональная диета установлена", "congratulations": "Поздравляем!", diff --git a/lib/main.dart b/lib/main.dart index af6db638..b6171864 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -9,7 +9,7 @@ import 'package:flutter_portal/flutter_portal.dart'; import 'package:keyboard_dismisser/keyboard_dismisser.dart'; Future main() async { - await AppInitializer.initialize(buildType: AppBuildType.prod); + await AppInitializer.initialize(buildType: AppBuildType.dev); await AppInitializer.runAppWithSentry(() => runApp(const MyApp())); } diff --git a/pubspec.yaml b/pubspec.yaml index 2625cc9c..96d5b2b2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -77,6 +77,7 @@ dependencies: vk_id: ^1.0.3 flutter_login_yandex: ^0.0.5 markdown: ^7.3.0 + flutter_password_generator: ^1.0.3 mobile_scanner: ^7.1.3 dev_dependencies: diff --git a/test/features/diary/presentation/widgets/basic_widget_test.dart b/test/features/diary/presentation/widgets/basic_widget_test.dart index 05daded2..02c97f23 100644 --- a/test/features/diary/presentation/widgets/basic_widget_test.dart +++ b/test/features/diary/presentation/widgets/basic_widget_test.dart @@ -220,7 +220,7 @@ void main() { testWidgets('should display FinishDayButtonWidget', (WidgetTester tester) async { // Arrange - final widget = FinishDayButtonWidget(diaryDay: testDiaryEntity); + final widget = FinishDayButtonWidget(onPressed: () async {}); // Act await tester.pumpWidget(createTestWidget(widget)); @@ -234,7 +234,7 @@ void main() { // Arrange diaryCubit.emit(DiaryState.loaded(diary: testDiaryEntity, nutrition: testNutrition, selectedDay: DateTime(2024, 1, 15), selectedMeal: 1)); - final widget = FinishDayButtonWidget(diaryDay: testDiaryEntity); + final widget = FinishDayButtonWidget(onPressed: () async {}); await tester.pumpWidget(createTestWidget(widget)); await tester.pumpAndSettle();