diff --git a/lib/features/bottom_navigation_bar/presentation/widgets/bottom_navigation_bar_widget.dart b/lib/features/bottom_navigation_bar/presentation/widgets/bottom_navigation_bar_widget.dart index 8bc6bb3d..f17bb065 100644 --- a/lib/features/bottom_navigation_bar/presentation/widgets/bottom_navigation_bar_widget.dart +++ b/lib/features/bottom_navigation_bar/presentation/widgets/bottom_navigation_bar_widget.dart @@ -6,7 +6,7 @@ import 'package:eatvio_app/features/bottom_navigation_bar/presentation/bloc/noti import 'package:eatvio_app/features/bottom_navigation_bar/presentation/bloc/notifications_cubit/notifications_state.dart'; import 'package:eatvio_app/features/bottom_navigation_bar/presentation/bloc/profile_avatar_cubit/profile_avatar_cubit.dart'; import 'package:eatvio_app/features/bottom_navigation_bar/presentation/bloc/profile_avatar_cubit/profile_avatar_state.dart'; -import 'package:eatvio_app/localization/app_localization.dart'; +import 'package:eatvio_app/generated/l10n.dart'; import 'package:eatvio_app/locator_service.dart'; import 'package:eatvio_app/theme/theme_helper.dart'; import 'package:flutter/material.dart'; @@ -59,6 +59,7 @@ class _BottomNavigationBarWidgetState extends State { @override Widget build(BuildContext context) { + final s = S.of(context); return Scaffold( body: widget.child, bottomNavigationBar: SizedBox( @@ -103,7 +104,7 @@ class _BottomNavigationBarWidgetState extends State { ), ), BottomNavigationBarItem( - label: "diary".tr, + label: s.diary, icon: Padding( padding: const EdgeInsets.only(bottom: 2), child: SvgPicture.asset( @@ -127,7 +128,7 @@ class _BottomNavigationBarWidgetState extends State { ), ), BottomNavigationBarItem( - label: "chat".tr, + label: s.chat, icon: BlocBuilder( builder: (BuildContext context, NewMessagesState state) { return badges.Badge( diff --git a/lib/features/diary/presentation/pages/diary_screen.dart b/lib/features/diary/presentation/pages/diary_screen.dart index e2287ddd..f6825d9c 100644 --- a/lib/features/diary/presentation/pages/diary_screen.dart +++ b/lib/features/diary/presentation/pages/diary_screen.dart @@ -1,5 +1,3 @@ -// ignore_for_file: unused_local_variable - import 'package:carousel_slider_plus/carousel_slider_plus.dart'; import 'package:eatvio_app/core/const.dart'; import 'package:eatvio_app/data/models/selectionPopupModel/selection_popup_model.dart'; @@ -10,7 +8,6 @@ import 'package:eatvio_app/features/diary/models/portion.dart'; import 'package:eatvio_app/features/diary/models/product.dart'; import 'package:eatvio_app/features/diary/presentation/bloc/diary_bloc.dart'; import 'package:eatvio_app/features/diary/presentation/bloc/diary_state.dart'; -import 'package:eatvio_app/localization/app_localization.dart'; import 'package:eatvio_app/locator_service.dart'; import 'package:eatvio_app/theme/app_decoration.dart'; import 'package:eatvio_app/theme/custom_text_style.dart'; @@ -372,7 +369,6 @@ class DiaryScreen extends StatelessWidget { _buildMeal(BuildContext context, DiaryStateLoaded state) { final digitsOnly = FilteringTextInputFormatter.digitsOnly; List _options = state.autocompleteList.map((Product item) => item.name).toList(); - FocusNode focusNodeName = FocusNode(); return Container( padding: EdgeInsets.symmetric( horizontal: 24, @@ -781,7 +777,7 @@ class DiaryScreen extends StatelessWidget { bottom: 4, ), child: Text( - portion.quantity.toString() + ' ' + portion.portion.toString().tr, + portion.quantity.toString() + ' ' + portion.portion.toString(), ), ), Spacer(), @@ -839,7 +835,7 @@ class DiaryScreen extends StatelessWidget { bottom: 4, ), child: Text( - portion.quantity.toString() + ' ' + portion.portion.toString().tr, + portion.quantity.toString() + ' ' + portion.portion.toString(), ), ), ], diff --git a/lib/features/recipes/presentation/pages/recipe_create_screen.dart b/lib/features/recipes/presentation/pages/recipe_create_screen.dart index e4ac3b8b..947b2784 100644 --- a/lib/features/recipes/presentation/pages/recipe_create_screen.dart +++ b/lib/features/recipes/presentation/pages/recipe_create_screen.dart @@ -7,7 +7,6 @@ import 'package:eatvio_app/features/recipes/models/recipe_model.dart'; import 'package:eatvio_app/features/recipes/models/step.dart' as step; import 'package:eatvio_app/features/recipes/presentation/bloc/recipe_create_cubit.dart'; import 'package:eatvio_app/features/recipes/presentation/bloc/recipe_create_state.dart'; -import 'package:eatvio_app/localization/app_localization.dart'; import 'package:eatvio_app/locator_service.dart'; import 'package:eatvio_app/theme/app_decoration.dart'; import 'package:eatvio_app/theme/custom_text_style.dart'; @@ -422,7 +421,7 @@ class RecipeCreateScreen extends StatelessWidget { bottom: 4, ), child: Text( - ingredient.portion.toString() + ' ' + ingredient.unit.toString().tr, + ingredient.portion.toString() + ' ' + ingredient.unit.toString(), ), ), Spacer(), diff --git a/lib/features/recipes/presentation/pages/recipe_edit_screen.dart b/lib/features/recipes/presentation/pages/recipe_edit_screen.dart index 5bae7dba..a5abe676 100644 --- a/lib/features/recipes/presentation/pages/recipe_edit_screen.dart +++ b/lib/features/recipes/presentation/pages/recipe_edit_screen.dart @@ -5,7 +5,6 @@ import 'package:eatvio_app/features/recipes/models/recipe_model.dart'; import 'package:eatvio_app/features/recipes/models/step.dart' as step; import 'package:eatvio_app/features/recipes/presentation/bloc/recipe_create_cubit.dart'; import 'package:eatvio_app/features/recipes/presentation/bloc/recipe_create_state.dart'; -import 'package:eatvio_app/localization/app_localization.dart'; import 'package:eatvio_app/theme/app_decoration.dart'; import 'package:eatvio_app/theme/custom_text_style.dart'; import 'package:eatvio_app/theme/theme_helper.dart'; @@ -430,7 +429,7 @@ class RecipeEditScreen extends StatelessWidget { bottom: 4, ), child: Text( - ingredient.portion.toString() + ' ' + ingredient.unit.toString().tr, + ingredient.portion.toString() + ' ' + ingredient.unit.toString(), ), ), Spacer(), diff --git a/lib/features/registration/presentation/pages/allergies_screen.dart b/lib/features/registration/presentation/pages/allergies_screen.dart index d0df3b8d..430c4438 100644 --- a/lib/features/registration/presentation/pages/allergies_screen.dart +++ b/lib/features/registration/presentation/pages/allergies_screen.dart @@ -1,6 +1,6 @@ import 'package:eatvio_app/features/registration/models/user_registration_model.dart'; import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart'; -import 'package:eatvio_app/localization/app_localization.dart'; +import 'package:eatvio_app/generated/l10n.dart'; import 'package:eatvio_app/widgets/custom_text_form_field.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -27,12 +27,13 @@ class _AllergiesScreenState extends State { @override Widget build(BuildContext context) { + final s = S.of(context); return SingleChildScrollView( padding: EdgeInsets.only(bottom: 80, left: 16, right: 16, top: 16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("allergies_presence".tr), + Text(s.allergies_presence), SizedBox(height: 4), CustomTextFormField( controller: enterInformationController, diff --git a/lib/features/registration/presentation/pages/blood_pressure_screen.dart b/lib/features/registration/presentation/pages/blood_pressure_screen.dart index 8b735b00..5d390876 100644 --- a/lib/features/registration/presentation/pages/blood_pressure_screen.dart +++ b/lib/features/registration/presentation/pages/blood_pressure_screen.dart @@ -2,7 +2,7 @@ import 'package:eatvio_app/core/utils/image_constant.dart'; import 'package:eatvio_app/data/models/selectionPopupModel/selection_popup_model.dart'; import 'package:eatvio_app/features/registration/models/user_registration_model.dart'; import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart'; -import 'package:eatvio_app/localization/app_localization.dart'; +import 'package:eatvio_app/generated/l10n.dart'; import 'package:eatvio_app/widgets/custom_drop_down.dart'; import 'package:eatvio_app/widgets/custom_image_view.dart'; import 'package:eatvio_app/widgets/custom_text_form_field.dart'; @@ -53,38 +53,39 @@ class _BloodPressureScreenState extends State { @override Widget build(BuildContext context) { + final s = S.of(context); return SingleChildScrollView( padding: EdgeInsets.only(bottom: 80, left: 16, right: 16, top: 16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("up_pressure".tr), + Text(s.up_pressure), SizedBox(height: 4), CustomTextFormField( inputFormatters: [digitsOnly], controller: upPressureController, autofocus: true, focusNode: upFocusNode, - hintText: "90".tr, + hintText: "90", onChanged: (newValue) { final registrationCubit = context.read(); registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(bloodPressureUp: int.parse(newValue))); }, ), SizedBox(height: 16), - Text("down_pressure".tr), + Text(s.down_pressure), SizedBox(height: 4), CustomTextFormField( inputFormatters: [digitsOnly], controller: downPressureController, - hintText: "90".tr, + hintText: '90', onChanged: (newValue) { final registrationCubit = context.read(); registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(bloodPressureDown: int.parse(newValue))); }, ), SizedBox(height: 16), - Text("do_you_have_hypotension_tendency".tr), + Text(s.do_you_have_hypotension_tendency), SizedBox(height: 4), CustomDropDown( icon: Container( @@ -98,7 +99,7 @@ class _BloodPressureScreenState extends State { width: 16, ), ), - hintText: "Не выбрано".tr, + hintText: "Не выбрано", items: selectionPopupList, value: selectedPopupHypo, onChanged: (newPopup) { @@ -110,7 +111,7 @@ class _BloodPressureScreenState extends State { }, ), SizedBox(height: 16), - Text("do_you_have_hypertension_tendency".tr), + Text(s.do_you_have_hypertension_tendency), SizedBox(height: 4), CustomDropDown( icon: Container( @@ -124,7 +125,7 @@ class _BloodPressureScreenState extends State { width: 16, ), ), - hintText: "Не выбрано".tr, + hintText: "Не выбрано", items: selectionPopupList, value: selectedPopupHyper, onChanged: (newPopup) { diff --git a/lib/features/registration/presentation/pages/body_circumferences_screen.dart b/lib/features/registration/presentation/pages/body_circumferences_screen.dart index 0e692512..0f6fc0f2 100644 --- a/lib/features/registration/presentation/pages/body_circumferences_screen.dart +++ b/lib/features/registration/presentation/pages/body_circumferences_screen.dart @@ -1,6 +1,6 @@ import 'package:eatvio_app/features/registration/models/user_registration_model.dart'; import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart'; -import 'package:eatvio_app/localization/app_localization.dart'; +import 'package:eatvio_app/generated/l10n.dart'; import 'package:eatvio_app/widgets/custom_text_form_field.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -33,43 +33,44 @@ class _BodyCircumferencesScreenState extends State { @override Widget build(BuildContext context) { + final s = S.of(context); return SingleChildScrollView( padding: EdgeInsets.only(bottom: 80, left: 16, right: 16, top: 16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("chest_circumference".tr), + Text(s.chest_circumference), SizedBox(height: 4), CustomTextFormField( inputFormatters: [digitsOnly], autofocus: true, focusNode: chestFocus, controller: chestCircumferenceController, - hintText: "90".tr, + hintText: '90', onChanged: (value) { final registrationCubit = context.read(); registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(chestCircumference: int.parse(value))); }, ), SizedBox(height: 16), - Text("waist_circumference".tr), + Text(s.waist_circumference), SizedBox(height: 4), CustomTextFormField( inputFormatters: [digitsOnly], controller: waistCircumferenceController, - hintText: "60".tr, + hintText: "60", onChanged: (value) { final registrationCubit = context.read(); registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(waistCircumference: int.parse(value))); }, ), SizedBox(height: 16), - Text("hip_circumference".tr), + Text(s.hip_circumference), SizedBox(height: 4), CustomTextFormField( inputFormatters: [digitsOnly], controller: hipCircumferenceController, - hintText: "90".tr, + hintText: '90', textInputAction: TextInputAction.done, onChanged: (value) { final registrationCubit = context.read(); diff --git a/lib/features/registration/presentation/pages/credentials_screen.dart b/lib/features/registration/presentation/pages/credentials_screen.dart index cc06048d..325b3d89 100644 --- a/lib/features/registration/presentation/pages/credentials_screen.dart +++ b/lib/features/registration/presentation/pages/credentials_screen.dart @@ -1,6 +1,6 @@ import 'package:eatvio_app/features/registration/models/user_registration_model.dart'; import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart'; -import 'package:eatvio_app/localization/app_localization.dart'; +import 'package:eatvio_app/generated/l10n.dart'; import 'package:eatvio_app/widgets/custom_text_form_field.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -31,13 +31,14 @@ class _CredentialsScreenState extends State { @override Widget build(BuildContext context) { + final s = S.of(context); return SingleChildScrollView( padding: EdgeInsets.only(bottom: 80, top: 16, left: 16, right: 16), child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("email".tr), + Text(s.email), SizedBox(height: 4), CustomTextFormField( controller: emailController, @@ -51,7 +52,7 @@ class _CredentialsScreenState extends State { }, ), SizedBox(height: 16), - Text("password".tr), + Text(s.password), SizedBox(height: 4), CustomTextFormField( obscureText: true, @@ -64,7 +65,7 @@ class _CredentialsScreenState extends State { }, ), SizedBox(height: 16), - Text("password_confirmation".tr), + Text(s.password_confirmation), SizedBox(height: 4), CustomTextFormField( obscureText: true, diff --git a/lib/features/registration/presentation/pages/date_of_birth_screen.dart b/lib/features/registration/presentation/pages/date_of_birth_screen.dart index 2270e3c6..cf5c354b 100644 --- a/lib/features/registration/presentation/pages/date_of_birth_screen.dart +++ b/lib/features/registration/presentation/pages/date_of_birth_screen.dart @@ -1,7 +1,7 @@ import 'package:eatvio_app/core/utils/date_time_utils.dart'; import 'package:eatvio_app/features/registration/models/user_registration_model.dart'; import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart'; -import 'package:eatvio_app/localization/app_localization.dart'; +import 'package:eatvio_app/generated/l10n.dart'; import 'package:eatvio_app/theme/theme_helper.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -34,12 +34,13 @@ class _DateOfBirthScreenState extends State { @override Widget build(BuildContext context) { + final s = S.of(context); return SingleChildScrollView( padding: EdgeInsets.only(bottom: 80, top: 16, left: 16, right: 16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("date_of_birth".tr), + Text(s.date_of_birth), SizedBox(height: 4), ListTile( onTap: onTapCalendar(context), diff --git a/lib/features/registration/presentation/pages/favorite_foods_screen.dart b/lib/features/registration/presentation/pages/favorite_foods_screen.dart index 29fad0db..2de9c71c 100644 --- a/lib/features/registration/presentation/pages/favorite_foods_screen.dart +++ b/lib/features/registration/presentation/pages/favorite_foods_screen.dart @@ -1,6 +1,6 @@ import 'package:eatvio_app/features/registration/models/user_registration_model.dart'; import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart'; -import 'package:eatvio_app/localization/app_localization.dart'; +import 'package:eatvio_app/generated/l10n.dart'; import 'package:eatvio_app/widgets/custom_text_form_field.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -29,16 +29,17 @@ class _FavoriteFoodsScreenState extends State { @override Widget build(BuildContext context) { + final s = S.of(context); return SingleChildScrollView( padding: EdgeInsets.only(bottom: 80, left: 16, right: 16, top: 16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("favorite_foods".tr), + Text(s.favorite_foods), SizedBox(height: 4), CustomTextFormField( controller: favoriteFoodsController, - hintText: "enter_information".tr, + hintText: s.enter_information, maxLines: 7, minLines: 2, focusNode: favoriteFocusNode, @@ -49,11 +50,11 @@ class _FavoriteFoodsScreenState extends State { }, ), SizedBox(height: 16), - Text("unfavorite_foods".tr), + Text(s.unfavorite_foods), SizedBox(height: 4), CustomTextFormField( controller: unFavoriteFoodsController, - hintText: "enter_information".tr, + hintText: s.enter_information, textInputAction: TextInputAction.done, maxLines: 7, minLines: 2, diff --git a/lib/features/registration/presentation/pages/favorite_sports_screen.dart b/lib/features/registration/presentation/pages/favorite_sports_screen.dart index 3a746e11..bf54612e 100644 --- a/lib/features/registration/presentation/pages/favorite_sports_screen.dart +++ b/lib/features/registration/presentation/pages/favorite_sports_screen.dart @@ -1,6 +1,6 @@ import 'package:eatvio_app/features/registration/models/user_registration_model.dart'; import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart'; -import 'package:eatvio_app/localization/app_localization.dart'; +import 'package:eatvio_app/generated/l10n.dart'; import 'package:eatvio_app/widgets/custom_text_form_field.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -27,12 +27,13 @@ class _FavoriteSportsScreenState extends State { @override Widget build(BuildContext context) { + final s = S.of(context); return SingleChildScrollView( padding: EdgeInsets.only(bottom: 80, left: 16, right: 16, top: 16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("your_favorite_sports".tr), + Text(s.your_favorite_sports), SizedBox(height: 4), CustomTextFormField( controller: enterInformationController, diff --git a/lib/features/registration/presentation/pages/height_screen.dart b/lib/features/registration/presentation/pages/height_screen.dart index 2753784a..93ab620b 100644 --- a/lib/features/registration/presentation/pages/height_screen.dart +++ b/lib/features/registration/presentation/pages/height_screen.dart @@ -1,6 +1,6 @@ import 'package:eatvio_app/features/registration/models/user_registration_model.dart'; import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart'; -import 'package:eatvio_app/localization/app_localization.dart'; +import 'package:eatvio_app/generated/l10n.dart'; import 'package:eatvio_app/widgets/custom_text_form_field.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -28,12 +28,13 @@ class _HeightScreenState extends State { @override Widget build(BuildContext context) { + final s = S.of(context); return SingleChildScrollView( padding: EdgeInsets.only(bottom: 80, left: 16, right: 16, top: 16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("your_height".tr), + Text(s.your_height), SizedBox(height: 4), CustomTextFormField( textInputAction: TextInputAction.done, diff --git a/lib/features/registration/presentation/pages/language_select_screen.dart b/lib/features/registration/presentation/pages/language_select_screen.dart index a9c3dbb5..ed167fc1 100644 --- a/lib/features/registration/presentation/pages/language_select_screen.dart +++ b/lib/features/registration/presentation/pages/language_select_screen.dart @@ -1,7 +1,7 @@ import 'package:eatvio_app/data/models/selectionPopupModel/selection_popup_model.dart'; import 'package:eatvio_app/features/registration/models/user_registration_model.dart'; import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart'; -import 'package:eatvio_app/localization/app_localization.dart'; +import 'package:eatvio_app/generated/l10n.dart'; import 'package:eatvio_app/widgets/custom_drop_down.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -36,18 +36,19 @@ class _LanguageSelectScreenState extends State { @override Widget build(BuildContext context) { + final s = S.of(context); return SingleChildScrollView( padding: EdgeInsets.only(bottom: 80, right: 16, left: 16, top: 16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - "preferred_language".tr, + s.preferred_language, ), const SizedBox(height: 4), CustomDropDown( value: value, - hintText: "Не выбрано".tr, + hintText: "Не выбрано", items: dropdownItemList, onChanged: (SelectionPopupModel newValue) => setState(() { value = newValue; diff --git a/lib/features/registration/presentation/pages/medicine_intake_screen.dart b/lib/features/registration/presentation/pages/medicine_intake_screen.dart index 86e09604..2383bd16 100644 --- a/lib/features/registration/presentation/pages/medicine_intake_screen.dart +++ b/lib/features/registration/presentation/pages/medicine_intake_screen.dart @@ -1,6 +1,6 @@ import 'package:eatvio_app/features/registration/models/user_registration_model.dart'; import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart'; -import 'package:eatvio_app/localization/app_localization.dart'; +import 'package:eatvio_app/generated/l10n.dart'; import 'package:eatvio_app/widgets/custom_text_form_field.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -27,16 +27,17 @@ class _MedicineIntakeScreenState extends State { @override Widget build(BuildContext context) { + final s = S.of(context); return SingleChildScrollView( padding: EdgeInsets.only(bottom: 80, left: 16, right: 16, top: 16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("do_you_take_pills".tr), + Text(s.do_you_take_pills), SizedBox(height: 4), CustomTextFormField( controller: enterInformationController, - hintText: "enter_information".tr, + hintText: s.enter_information, textInputAction: TextInputAction.done, focusNode: infoFocusNode, autofocus: true, diff --git a/lib/features/registration/presentation/pages/name_screen.dart b/lib/features/registration/presentation/pages/name_screen.dart index e92ce31a..efb81f63 100644 --- a/lib/features/registration/presentation/pages/name_screen.dart +++ b/lib/features/registration/presentation/pages/name_screen.dart @@ -1,6 +1,6 @@ import 'package:eatvio_app/features/registration/models/user_registration_model.dart'; import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart'; -import 'package:eatvio_app/localization/app_localization.dart'; +import 'package:eatvio_app/generated/l10n.dart'; import 'package:eatvio_app/widgets/custom_text_form_field.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -29,12 +29,13 @@ class _NameScreenState extends State { @override Widget build(BuildContext context) { + final s = S.of(context); return SingleChildScrollView( padding: EdgeInsets.only(bottom: 80, top: 16, left: 16, right: 16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("first_name".tr), + Text(s.first_name), SizedBox(height: 4), CustomTextFormField( controller: firstNameController, @@ -47,7 +48,7 @@ class _NameScreenState extends State { }, ), SizedBox(height: 16), - Text("last_name".tr), + Text(s.last_name), SizedBox(height: 4), CustomTextFormField( controller: lastNameController, diff --git a/lib/features/registration/presentation/pages/registration_screen.dart b/lib/features/registration/presentation/pages/registration_screen.dart index 1b01acda..aa3ca881 100644 --- a/lib/features/registration/presentation/pages/registration_screen.dart +++ b/lib/features/registration/presentation/pages/registration_screen.dart @@ -16,7 +16,7 @@ import 'package:eatvio_app/features/registration/presentation/pages/language_sel import 'package:eatvio_app/features/registration/presentation/pages/medicine_intake_screen.dart'; import 'package:eatvio_app/features/registration/presentation/pages/name_screen.dart'; import 'package:eatvio_app/features/registration/presentation/pages/weight_screen.dart'; -import 'package:eatvio_app/localization/app_localization.dart'; +import 'package:eatvio_app/generated/l10n.dart'; import 'package:eatvio_app/locator_service.dart'; import 'package:eatvio_app/theme/theme_helper.dart'; import 'package:eatvio_app/widgets/app_bar/appbar_title_image.dart'; @@ -180,7 +180,12 @@ class _RegistrationScreenState extends State { Future canGoNext(RegistrationState state) async { switch (step) { case 2: - List errors = validateCredentialsFields(state.sheet.email, state.sheet.password, state.sheet.passwordConfirmation); + List errors = validateCredentialsFields( + state.sheet.email, + state.sheet.password, + state.sheet.passwordConfirmation, + context, + ); if (errors.isEmpty) { return true; } else { @@ -209,6 +214,7 @@ class _RegistrationScreenState extends State { List errors = validateNameFields( state.sheet.firstName.toString(), state.sheet.lastName.toString(), + context, ); if (errors.isEmpty) { return true; @@ -277,6 +283,7 @@ class _RegistrationScreenState extends State { state.sheet.chestCircumference.toString(), state.sheet.waistCircumference.toString(), state.sheet.hipCircumference.toString(), + context, ); if (errors.isEmpty) { return true; @@ -336,43 +343,57 @@ class _RegistrationScreenState extends State { String chestCircumference, String waistCircumference, String hipCircumference, + BuildContext context, ) { + final s = S.of(context); + List errors = []; if (chestCircumference.isEmpty | waistCircumference.isEmpty | hipCircumference.isEmpty) { - errors.add('circumference_empty'.tr); + errors.add(s.circumference_empty); } if (![chestCircumference, waistCircumference, hipCircumference].every((circumference) => int.tryParse(circumference) != null)) { - errors.add('circumference_is_not_a_number'.tr); + errors.add(s.circumference_is_not_a_number); } return errors; } - List validateCredentialsFields(String email, String password, String passwordConfirmation) { + List validateCredentialsFields( + String email, + String password, + String passwordConfirmation, + BuildContext context, + ) { + final s = S.of(context); + List errors = []; if (!isEmail(email)) { - errors.add('email_invalid'.tr); + errors.add(s.email_invalid); } if (email.isEmpty) { - errors.add('email_empty'.tr); + errors.add(s.email_empty); } if (password.length < 6) { - errors.add('password_short'.tr); + errors.add(s.password_short); } if (password != passwordConfirmation) { - errors.add('password_confirmation_mismatch'.tr); + errors.add(s.password_confirmation_mismatch); } return errors; } - List validateNameFields(String firstName, String lastName) { + List validateNameFields( + String firstName, + String lastName, + BuildContext context, + ) { List errors = []; if (firstName.isEmpty) { diff --git a/lib/features/registration/presentation/pages/weight_screen.dart b/lib/features/registration/presentation/pages/weight_screen.dart index 622cc772..4f8e9b9f 100644 --- a/lib/features/registration/presentation/pages/weight_screen.dart +++ b/lib/features/registration/presentation/pages/weight_screen.dart @@ -1,6 +1,6 @@ import 'package:eatvio_app/features/registration/models/user_registration_model.dart'; import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart'; -import 'package:eatvio_app/localization/app_localization.dart'; +import 'package:eatvio_app/generated/l10n.dart'; import 'package:eatvio_app/widgets/custom_text_form_field.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -28,12 +28,13 @@ class _WeightScreenState extends State { @override Widget build(BuildContext context) { + final s = S.of(context); return SingleChildScrollView( padding: EdgeInsets.only(bottom: 80, left: 16, right: 16, top: 16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("your_weight".tr), + Text(s.your_weight), SizedBox(height: 4), CustomTextFormField( autofocus: true, diff --git a/lib/generated/intl/messages_all.dart b/lib/generated/intl/messages_all.dart new file mode 100644 index 00000000..203415cc --- /dev/null +++ b/lib/generated/intl/messages_all.dart @@ -0,0 +1,63 @@ +// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart +// This is a library that looks up messages for specific locales by +// delegating to the appropriate library. + +// Ignore issues from commonly used lints in this file. +// ignore_for_file:implementation_imports, file_names, unnecessary_new +// ignore_for_file:unnecessary_brace_in_string_interps, directives_ordering +// ignore_for_file:argument_type_not_assignable, invalid_assignment +// ignore_for_file:prefer_single_quotes, prefer_generic_function_type_aliases +// ignore_for_file:comment_references + +import 'dart:async'; + +import 'package:flutter/foundation.dart'; +import 'package:intl/intl.dart'; +import 'package:intl/message_lookup_by_library.dart'; +import 'package:intl/src/intl_helpers.dart'; + +import 'messages_en.dart' as messages_en; + +typedef Future LibraryLoader(); +Map _deferredLibraries = { + 'en': () => new SynchronousFuture(null), +}; + +MessageLookupByLibrary? _findExact(String localeName) { + switch (localeName) { + case 'en': + return messages_en.messages; + default: + return null; + } +} + +/// User programs should call this before using [localeName] for messages. +Future initializeMessages(String localeName) { + var availableLocale = Intl.verifiedLocale( + localeName, (locale) => _deferredLibraries[locale] != null, + onFailure: (_) => null); + if (availableLocale == null) { + return new SynchronousFuture(false); + } + var lib = _deferredLibraries[availableLocale]; + lib == null ? new SynchronousFuture(false) : lib(); + initializeInternalMessageLookup(() => new CompositeMessageLookup()); + messageLookup.addLocale(availableLocale, _findGeneratedMessagesFor); + return new SynchronousFuture(true); +} + +bool _messagesExistFor(String locale) { + try { + return _findExact(locale) != null; + } catch (e) { + return false; + } +} + +MessageLookupByLibrary? _findGeneratedMessagesFor(String locale) { + var actualLocale = + Intl.verifiedLocale(locale, _messagesExistFor, onFailure: (_) => null); + if (actualLocale == null) return null; + return _findExact(actualLocale); +} diff --git a/lib/generated/intl/messages_en.dart b/lib/generated/intl/messages_en.dart new file mode 100644 index 00000000..2fee5ba3 --- /dev/null +++ b/lib/generated/intl/messages_en.dart @@ -0,0 +1,174 @@ +// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart +// This is a library that provides messages for a en locale. All the +// messages from the main program should be duplicated here with the same +// function name. + +// Ignore issues from commonly used lints in this file. +// ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new +// ignore_for_file:prefer_single_quotes,comment_references, directives_ordering +// ignore_for_file:annotate_overrides,prefer_generic_function_type_aliases +// ignore_for_file:unused_import, file_names, avoid_escaping_inner_quotes +// ignore_for_file:unnecessary_string_interpolations, unnecessary_string_escapes + +import 'package:intl/intl.dart'; +import 'package:intl/message_lookup_by_library.dart'; + +final messages = new MessageLookup(); + +typedef String MessageIfAbsent(String messageStr, List args); + +class MessageLookup extends MessageLookupByLibrary { + String get localeName => 'en'; + + final messages = _notInlinedMessages(_notInlinedMessages); + static Map _notInlinedMessages(_) => { + "Moscow": MessageLookupByLibrary.simpleMessage("Москва"), + "Russia": MessageLookupByLibrary.simpleMessage("Россия"), + "active": MessageLookupByLibrary.simpleMessage("Активен"), + "add_measure": MessageLookupByLibrary.simpleMessage("Добавить замер"), + "additional_information": + MessageLookupByLibrary.simpleMessage("Дополнительная информация"), + "admin": MessageLookupByLibrary.simpleMessage("Админ"), + "allergies_presence": + MessageLookupByLibrary.simpleMessage("Наличие аллергии"), + "archived": MessageLookupByLibrary.simpleMessage("В архиве"), + "authentificate": MessageLookupByLibrary.simpleMessage("Войти"), + "average_pressure": MessageLookupByLibrary.simpleMessage( + "Средние показатели давления:"), + "bodymass_chart": MessageLookupByLibrary.simpleMessage("График ИМТ"), + "chat": MessageLookupByLibrary.simpleMessage("Чат"), + "chest": MessageLookupByLibrary.simpleMessage("Грудь"), + "chest_circumference": + MessageLookupByLibrary.simpleMessage("Обхват груди"), + "circumference_empty": MessageLookupByLibrary.simpleMessage( + "Все замеры обязательны к заполнению"), + "circumference_is_not_a_number": MessageLookupByLibrary.simpleMessage( + "Все замеры должны быть числами"), + "circumferences_chart": + MessageLookupByLibrary.simpleMessage("График обхватов"), + "city": MessageLookupByLibrary.simpleMessage("Город"), + "city_of_living": + MessageLookupByLibrary.simpleMessage("Город проживания"), + "continueButton": MessageLookupByLibrary.simpleMessage("Продолжить"), + "country": MessageLookupByLibrary.simpleMessage("Страна"), + "date_of_birth": MessageLookupByLibrary.simpleMessage("Дата рождения"), + "diary": MessageLookupByLibrary.simpleMessage("Дневник"), + "do_you_have_hypertension_tendency": + MessageLookupByLibrary.simpleMessage("Есть ли у вас гипертония?"), + "do_you_have_hypotension_tendency": + MessageLookupByLibrary.simpleMessage("Есть ли у вас гипотония?"), + "do_you_take_pills": MessageLookupByLibrary.simpleMessage( + "Принимаете ли вы лекарства или бады?"), + "down_pressure": + MessageLookupByLibrary.simpleMessage("Нижние показатели давления:"), + "draft": MessageLookupByLibrary.simpleMessage("Черновик"), + "email": MessageLookupByLibrary.simpleMessage("Элетронная почта"), + "email_empty": MessageLookupByLibrary.simpleMessage( + "Необходимо ввести адрес электронной почты"), + "email_invalid": MessageLookupByLibrary.simpleMessage( + "Некорректный адрес электронной почты"), + "enter_additional_information": MessageLookupByLibrary.simpleMessage( + "Введите любую дополнительную информацию на своё усмотрение:"), + "enter_information": + MessageLookupByLibrary.simpleMessage("Введите информацию..."), + "exit": MessageLookupByLibrary.simpleMessage("Выйти"), + "favorite_foods": + MessageLookupByLibrary.simpleMessage("Любимые продукты"), + "favorite_unfavorite_foods": MessageLookupByLibrary.simpleMessage( + "Ваши любимые/нелюбимые продукты питания?"), + "female": MessageLookupByLibrary.simpleMessage("Женский"), + "fill_in_information": + MessageLookupByLibrary.simpleMessage("Заполните информацию:"), + "finish": MessageLookupByLibrary.simpleMessage("Завершить"), + "first_name": MessageLookupByLibrary.simpleMessage("Имя"), + "first_name_empty": MessageLookupByLibrary.simpleMessage( + "Имя обязательно для заполнения"), + "first_name_short": MessageLookupByLibrary.simpleMessage( + "В имени должен быть минимум 1 символ"), + "gr": MessageLookupByLibrary.simpleMessage("гр"), + "grams": MessageLookupByLibrary.simpleMessage("гр"), + "height_measurements": + MessageLookupByLibrary.simpleMessage("Замер роста"), + "hip_circumference": + MessageLookupByLibrary.simpleMessage("Обхват бедер"), + "hips": MessageLookupByLibrary.simpleMessage("Бедра"), + "in_progress": MessageLookupByLibrary.simpleMessage("В процессе"), + "initial_measurements": + MessageLookupByLibrary.simpleMessage("Первичные замеры"), + "language": MessageLookupByLibrary.simpleMessage("Язык:"), + "last_name": MessageLookupByLibrary.simpleMessage("Фамилия"), + "last_name_empty": MessageLookupByLibrary.simpleMessage( + "Фамилия обязательна для заполнения"), + "last_name_short": MessageLookupByLibrary.simpleMessage( + "В фамилии должен быть минимум 6 символов"), + "lbl_english": MessageLookupByLibrary.simpleMessage("English"), + "loading": MessageLookupByLibrary.simpleMessage("Загрузка..."), + "male": MessageLookupByLibrary.simpleMessage("Мужской"), + "msg_network_err": + MessageLookupByLibrary.simpleMessage("Сетевая ошибка!"), + "msg_something_went_wrong": + MessageLookupByLibrary.simpleMessage("Что то пошло не так!"), + "my_blog": MessageLookupByLibrary.simpleMessage("Мой блог"), + "my_settings": MessageLookupByLibrary.simpleMessage("Мои настройки"), + "name_empty": MessageLookupByLibrary.simpleMessage( + "Имя пользователя обязательно для заполнения"), + "name_short": MessageLookupByLibrary.simpleMessage( + "В имени пользователя должно быть минимум 6 символов"), + "no": MessageLookupByLibrary.simpleMessage("Нет"), + "no_account": + MessageLookupByLibrary.simpleMessage("У меня нет аккаунта"), + "password": MessageLookupByLibrary.simpleMessage("Пароль"), + "password_confirmation": + MessageLookupByLibrary.simpleMessage("Подтвердите пароль"), + "password_confirmation_mismatch": + MessageLookupByLibrary.simpleMessage("Пароли не совпадают"), + "password_empty": MessageLookupByLibrary.simpleMessage( + "Пароль обязателен для заполнения"), + "password_short": MessageLookupByLibrary.simpleMessage( + "В пароле должно быть минимум 6 символов"), + "pcs": MessageLookupByLibrary.simpleMessage("шт"), + "place_of_living": + MessageLookupByLibrary.simpleMessage("Место проживания"), + "plans_complete": + MessageLookupByLibrary.simpleMessage("Пройденные планы"), + "preferred_language": + MessageLookupByLibrary.simpleMessage("Предпочитаемый язык общения"), + "pressure_empty": MessageLookupByLibrary.simpleMessage( + "Все показатели давления обязательны к заполнению"), + "pressure_is_not_a_number": MessageLookupByLibrary.simpleMessage( + "Все показатели давления должны быть числами"), + "profile": MessageLookupByLibrary.simpleMessage("Профиль"), + "save": MessageLookupByLibrary.simpleMessage("Сохранить"), + "skip": MessageLookupByLibrary.simpleMessage("Пропустить"), + "tell_your_schedule": MessageLookupByLibrary.simpleMessage( + "Расскажите в свободной форме о том как просыпаетесь, когда едите, когда ложитесь спать:"), + "unfavorite_foods": + MessageLookupByLibrary.simpleMessage("Нелюбимые продукты"), + "up_pressure": MessageLookupByLibrary.simpleMessage( + "Верхние показатели давления:"), + "user_authorization": + MessageLookupByLibrary.simpleMessage("Аутентификация"), + "user_registration": + MessageLookupByLibrary.simpleMessage("Регистрация пользователя"), + "username": MessageLookupByLibrary.simpleMessage("Имя пользователя"), + "waist": MessageLookupByLibrary.simpleMessage("Талия"), + "waist_circumference": + MessageLookupByLibrary.simpleMessage("Обхват талии"), + "weight": MessageLookupByLibrary.simpleMessage("Вес"), + "weight_chart": MessageLookupByLibrary.simpleMessage("График веса"), + "weight_measurements": + MessageLookupByLibrary.simpleMessage("Замер веса"), + "what_is_your_name": + MessageLookupByLibrary.simpleMessage("Как вас зовут?"), + "wrong_credentials": MessageLookupByLibrary.simpleMessage( + "Неверные данные пользователя"), + "your_blood_pressure": + MessageLookupByLibrary.simpleMessage("Ваше артериальное давление?"), + "your_favorite_sports": + MessageLookupByLibrary.simpleMessage("Ваши спортивные увлечения?"), + "your_gender": MessageLookupByLibrary.simpleMessage("Ваш пол?"), + "your_height": MessageLookupByLibrary.simpleMessage("Ваш рост:"), + "your_schedule": MessageLookupByLibrary.simpleMessage("Ваш режим дня?"), + "your_weight": MessageLookupByLibrary.simpleMessage("Ваш вес:") + }; +} diff --git a/lib/generated/l10n.dart b/lib/generated/l10n.dart new file mode 100644 index 00000000..8440a2b7 --- /dev/null +++ b/lib/generated/l10n.dart @@ -0,0 +1,1048 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'intl/messages_all.dart'; + +// ************************************************************************** +// Generator: Flutter Intl IDE plugin +// Made by Localizely +// ************************************************************************** + +// ignore_for_file: non_constant_identifier_names, lines_longer_than_80_chars +// ignore_for_file: join_return_with_assignment, prefer_final_in_for_each +// ignore_for_file: avoid_redundant_argument_values, avoid_escaping_inner_quotes + +class S { + S(); + + static S? _current; + + static S get current { + assert(_current != null, + 'No instance of S was loaded. Try to initialize the S delegate before accessing S.current.'); + return _current!; + } + + static const AppLocalizationDelegate delegate = AppLocalizationDelegate(); + + static Future load(Locale locale) { + final name = (locale.countryCode?.isEmpty ?? false) + ? locale.languageCode + : locale.toString(); + final localeName = Intl.canonicalizedLocale(name); + return initializeMessages(localeName).then((_) { + Intl.defaultLocale = localeName; + final instance = S(); + S._current = instance; + + return instance; + }); + } + + static S of(BuildContext context) { + final instance = S.maybeOf(context); + assert(instance != null, + 'No instance of S present in the widget tree. Did you add S.delegate in localizationsDelegates?'); + return instance!; + } + + static S? maybeOf(BuildContext context) { + return Localizations.of(context, S); + } + + /// `Регистрация пользователя` + String get user_registration { + return Intl.message( + 'Регистрация пользователя', + name: 'user_registration', + desc: '', + args: [], + ); + } + + /// `Элетронная почта` + String get email { + return Intl.message( + 'Элетронная почта', + name: 'email', + desc: '', + args: [], + ); + } + + /// `Имя пользователя` + String get username { + return Intl.message( + 'Имя пользователя', + name: 'username', + desc: '', + args: [], + ); + } + + /// `Пароль` + String get password { + return Intl.message( + 'Пароль', + name: 'password', + desc: '', + args: [], + ); + } + + /// `Подтвердите пароль` + String get password_confirmation { + return Intl.message( + 'Подтвердите пароль', + name: 'password_confirmation', + desc: '', + args: [], + ); + } + + /// `Неверные данные пользователя` + String get wrong_credentials { + return Intl.message( + 'Неверные данные пользователя', + name: 'wrong_credentials', + desc: '', + args: [], + ); + } + + /// `Имя` + String get first_name { + return Intl.message( + 'Имя', + name: 'first_name', + desc: '', + args: [], + ); + } + + /// `Фамилия` + String get last_name { + return Intl.message( + 'Фамилия', + name: 'last_name', + desc: '', + args: [], + ); + } + + /// `Как вас зовут?` + String get what_is_your_name { + return Intl.message( + 'Как вас зовут?', + name: 'what_is_your_name', + desc: '', + args: [], + ); + } + + /// `Дата рождения` + String get date_of_birth { + return Intl.message( + 'Дата рождения', + name: 'date_of_birth', + desc: '', + args: [], + ); + } + + /// `Страна` + String get country { + return Intl.message( + 'Страна', + name: 'country', + desc: '', + args: [], + ); + } + + /// `Россия` + String get Russia { + return Intl.message( + 'Россия', + name: 'Russia', + desc: '', + args: [], + ); + } + + /// `Город` + String get city { + return Intl.message( + 'Город', + name: 'city', + desc: '', + args: [], + ); + } + + /// `Москва` + String get Moscow { + return Intl.message( + 'Москва', + name: 'Moscow', + desc: '', + args: [], + ); + } + + /// `Место проживания` + String get place_of_living { + return Intl.message( + 'Место проживания', + name: 'place_of_living', + desc: '', + args: [], + ); + } + + /// `Обхват бедер` + String get hip_circumference { + return Intl.message( + 'Обхват бедер', + name: 'hip_circumference', + desc: '', + args: [], + ); + } + + /// `Обхват груди` + String get chest_circumference { + return Intl.message( + 'Обхват груди', + name: 'chest_circumference', + desc: '', + args: [], + ); + } + + /// `Обхват талии` + String get waist_circumference { + return Intl.message( + 'Обхват талии', + name: 'waist_circumference', + desc: '', + args: [], + ); + } + + /// `Первичные замеры` + String get initial_measurements { + return Intl.message( + 'Первичные замеры', + name: 'initial_measurements', + desc: '', + args: [], + ); + } + + /// `Мужской` + String get male { + return Intl.message( + 'Мужской', + name: 'male', + desc: '', + args: [], + ); + } + + /// `Женский` + String get female { + return Intl.message( + 'Женский', + name: 'female', + desc: '', + args: [], + ); + } + + /// `Замер веса` + String get weight_measurements { + return Intl.message( + 'Замер веса', + name: 'weight_measurements', + desc: '', + args: [], + ); + } + + /// `Ваш вес:` + String get your_weight { + return Intl.message( + 'Ваш вес:', + name: 'your_weight', + desc: '', + args: [], + ); + } + + /// `Замер роста` + String get height_measurements { + return Intl.message( + 'Замер роста', + name: 'height_measurements', + desc: '', + args: [], + ); + } + + /// `Ваш рост:` + String get your_height { + return Intl.message( + 'Ваш рост:', + name: 'your_height', + desc: '', + args: [], + ); + } + + /// `Наличие аллергии` + String get allergies_presence { + return Intl.message( + 'Наличие аллергии', + name: 'allergies_presence', + desc: '', + args: [], + ); + } + + /// `Принимаете ли вы лекарства или бады?` + String get do_you_take_pills { + return Intl.message( + 'Принимаете ли вы лекарства или бады?', + name: 'do_you_take_pills', + desc: '', + args: [], + ); + } + + /// `Ваш пол?` + String get your_gender { + return Intl.message( + 'Ваш пол?', + name: 'your_gender', + desc: '', + args: [], + ); + } + + /// `Нет` + String get no { + return Intl.message( + 'Нет', + name: 'no', + desc: '', + args: [], + ); + } + + /// `Есть ли у вас гипертония?` + String get do_you_have_hypertension_tendency { + return Intl.message( + 'Есть ли у вас гипертония?', + name: 'do_you_have_hypertension_tendency', + desc: '', + args: [], + ); + } + + /// `Ваше артериальное давление?` + String get your_blood_pressure { + return Intl.message( + 'Ваше артериальное давление?', + name: 'your_blood_pressure', + desc: '', + args: [], + ); + } + + /// `Средние показатели давления:` + String get average_pressure { + return Intl.message( + 'Средние показатели давления:', + name: 'average_pressure', + desc: '', + args: [], + ); + } + + /// `Верхние показатели давления:` + String get up_pressure { + return Intl.message( + 'Верхние показатели давления:', + name: 'up_pressure', + desc: '', + args: [], + ); + } + + /// `Нижние показатели давления:` + String get down_pressure { + return Intl.message( + 'Нижние показатели давления:', + name: 'down_pressure', + desc: '', + args: [], + ); + } + + /// `Есть ли у вас гипотония?` + String get do_you_have_hypotension_tendency { + return Intl.message( + 'Есть ли у вас гипотония?', + name: 'do_you_have_hypotension_tendency', + desc: '', + args: [], + ); + } + + /// `Ваши спортивные увлечения?` + String get your_favorite_sports { + return Intl.message( + 'Ваши спортивные увлечения?', + name: 'your_favorite_sports', + desc: '', + args: [], + ); + } + + /// `Любимые продукты` + String get favorite_foods { + return Intl.message( + 'Любимые продукты', + name: 'favorite_foods', + desc: '', + args: [], + ); + } + + /// `Ваши любимые/нелюбимые продукты питания?` + String get favorite_unfavorite_foods { + return Intl.message( + 'Ваши любимые/нелюбимые продукты питания?', + name: 'favorite_unfavorite_foods', + desc: '', + args: [], + ); + } + + /// `Нелюбимые продукты` + String get unfavorite_foods { + return Intl.message( + 'Нелюбимые продукты', + name: 'unfavorite_foods', + desc: '', + args: [], + ); + } + + /// `Ваш режим дня?` + String get your_schedule { + return Intl.message( + 'Ваш режим дня?', + name: 'your_schedule', + desc: '', + args: [], + ); + } + + /// `Расскажите в свободной форме о том как просыпаетесь, когда едите, когда ложитесь спать:` + String get tell_your_schedule { + return Intl.message( + 'Расскажите в свободной форме о том как просыпаетесь, когда едите, когда ложитесь спать:', + name: 'tell_your_schedule', + desc: '', + args: [], + ); + } + + /// `Дополнительная информация` + String get additional_information { + return Intl.message( + 'Дополнительная информация', + name: 'additional_information', + desc: '', + args: [], + ); + } + + /// `Введите любую дополнительную информацию на своё усмотрение:` + String get enter_additional_information { + return Intl.message( + 'Введите любую дополнительную информацию на своё усмотрение:', + name: 'enter_additional_information', + desc: '', + args: [], + ); + } + + /// `English` + String get lbl_english { + return Intl.message( + 'English', + name: 'lbl_english', + desc: '', + args: [], + ); + } + + /// `Завершить` + String get finish { + return Intl.message( + 'Завершить', + name: 'finish', + desc: '', + args: [], + ); + } + + /// `Предпочитаемый язык общения` + String get preferred_language { + return Intl.message( + 'Предпочитаемый язык общения', + name: 'preferred_language', + desc: '', + args: [], + ); + } + + /// `Продолжить` + String get continueButton { + return Intl.message( + 'Продолжить', + name: 'continueButton', + desc: '', + args: [], + ); + } + + /// `Пропустить` + String get skip { + return Intl.message( + 'Пропустить', + name: 'skip', + desc: '', + args: [], + ); + } + + /// `Заполните информацию:` + String get fill_in_information { + return Intl.message( + 'Заполните информацию:', + name: 'fill_in_information', + desc: '', + args: [], + ); + } + + /// `Введите информацию...` + String get enter_information { + return Intl.message( + 'Введите информацию...', + name: 'enter_information', + desc: '', + args: [], + ); + } + + /// `Сетевая ошибка!` + String get msg_network_err { + return Intl.message( + 'Сетевая ошибка!', + name: 'msg_network_err', + desc: '', + args: [], + ); + } + + /// `Что то пошло не так!` + String get msg_something_went_wrong { + return Intl.message( + 'Что то пошло не так!', + name: 'msg_something_went_wrong', + desc: '', + args: [], + ); + } + + /// `Необходимо ввести адрес электронной почты` + String get email_empty { + return Intl.message( + 'Необходимо ввести адрес электронной почты', + name: 'email_empty', + desc: '', + args: [], + ); + } + + /// `Некорректный адрес электронной почты` + String get email_invalid { + return Intl.message( + 'Некорректный адрес электронной почты', + name: 'email_invalid', + desc: '', + args: [], + ); + } + + /// `Пароль обязателен для заполнения` + String get password_empty { + return Intl.message( + 'Пароль обязателен для заполнения', + name: 'password_empty', + desc: '', + args: [], + ); + } + + /// `В пароле должно быть минимум 6 символов` + String get password_short { + return Intl.message( + 'В пароле должно быть минимум 6 символов', + name: 'password_short', + desc: '', + args: [], + ); + } + + /// `Имя пользователя обязательно для заполнения` + String get name_empty { + return Intl.message( + 'Имя пользователя обязательно для заполнения', + name: 'name_empty', + desc: '', + args: [], + ); + } + + /// `В имени пользователя должно быть минимум 6 символов` + String get name_short { + return Intl.message( + 'В имени пользователя должно быть минимум 6 символов', + name: 'name_short', + desc: '', + args: [], + ); + } + + /// `Пароли не совпадают` + String get password_confirmation_mismatch { + return Intl.message( + 'Пароли не совпадают', + name: 'password_confirmation_mismatch', + desc: '', + args: [], + ); + } + + /// `Имя обязательно для заполнения` + String get first_name_empty { + return Intl.message( + 'Имя обязательно для заполнения', + name: 'first_name_empty', + desc: '', + args: [], + ); + } + + /// `В имени должен быть минимум 1 символ` + String get first_name_short { + return Intl.message( + 'В имени должен быть минимум 1 символ', + name: 'first_name_short', + desc: '', + args: [], + ); + } + + /// `Фамилия обязательна для заполнения` + String get last_name_empty { + return Intl.message( + 'Фамилия обязательна для заполнения', + name: 'last_name_empty', + desc: '', + args: [], + ); + } + + /// `В фамилии должен быть минимум 6 символов` + String get last_name_short { + return Intl.message( + 'В фамилии должен быть минимум 6 символов', + name: 'last_name_short', + desc: '', + args: [], + ); + } + + /// `Все замеры обязательны к заполнению` + String get circumference_empty { + return Intl.message( + 'Все замеры обязательны к заполнению', + name: 'circumference_empty', + desc: '', + args: [], + ); + } + + /// `Все замеры должны быть числами` + String get circumference_is_not_a_number { + return Intl.message( + 'Все замеры должны быть числами', + name: 'circumference_is_not_a_number', + desc: '', + args: [], + ); + } + + /// `Все показатели давления обязательны к заполнению` + String get pressure_empty { + return Intl.message( + 'Все показатели давления обязательны к заполнению', + name: 'pressure_empty', + desc: '', + args: [], + ); + } + + /// `Все показатели давления должны быть числами` + String get pressure_is_not_a_number { + return Intl.message( + 'Все показатели давления должны быть числами', + name: 'pressure_is_not_a_number', + desc: '', + args: [], + ); + } + + /// `У меня нет аккаунта` + String get no_account { + return Intl.message( + 'У меня нет аккаунта', + name: 'no_account', + desc: '', + args: [], + ); + } + + /// `Войти` + String get authentificate { + return Intl.message( + 'Войти', + name: 'authentificate', + desc: '', + args: [], + ); + } + + /// `Аутентификация` + String get user_authorization { + return Intl.message( + 'Аутентификация', + name: 'user_authorization', + desc: '', + args: [], + ); + } + + /// `Загрузка...` + String get loading { + return Intl.message( + 'Загрузка...', + name: 'loading', + desc: '', + args: [], + ); + } + + /// `График веса` + String get weight_chart { + return Intl.message( + 'График веса', + name: 'weight_chart', + desc: '', + args: [], + ); + } + + /// `График обхватов` + String get circumferences_chart { + return Intl.message( + 'График обхватов', + name: 'circumferences_chart', + desc: '', + args: [], + ); + } + + /// `Город проживания` + String get city_of_living { + return Intl.message( + 'Город проживания', + name: 'city_of_living', + desc: '', + args: [], + ); + } + + /// `График ИМТ` + String get bodymass_chart { + return Intl.message( + 'График ИМТ', + name: 'bodymass_chart', + desc: '', + args: [], + ); + } + + /// `Грудь` + String get chest { + return Intl.message( + 'Грудь', + name: 'chest', + desc: '', + args: [], + ); + } + + /// `Талия` + String get waist { + return Intl.message( + 'Талия', + name: 'waist', + desc: '', + args: [], + ); + } + + /// `Бедра` + String get hips { + return Intl.message( + 'Бедра', + name: 'hips', + desc: '', + args: [], + ); + } + + /// `Выйти` + String get exit { + return Intl.message( + 'Выйти', + name: 'exit', + desc: '', + args: [], + ); + } + + /// `Активен` + String get active { + return Intl.message( + 'Активен', + name: 'active', + desc: '', + args: [], + ); + } + + /// `В архиве` + String get archived { + return Intl.message( + 'В архиве', + name: 'archived', + desc: '', + args: [], + ); + } + + /// `Черновик` + String get draft { + return Intl.message( + 'Черновик', + name: 'draft', + desc: '', + args: [], + ); + } + + /// `Мой блог` + String get my_blog { + return Intl.message( + 'Мой блог', + name: 'my_blog', + desc: '', + args: [], + ); + } + + /// `Язык:` + String get language { + return Intl.message( + 'Язык:', + name: 'language', + desc: '', + args: [], + ); + } + + /// `В процессе` + String get in_progress { + return Intl.message( + 'В процессе', + name: 'in_progress', + desc: '', + args: [], + ); + } + + /// `Добавить замер` + String get add_measure { + return Intl.message( + 'Добавить замер', + name: 'add_measure', + desc: '', + args: [], + ); + } + + /// `Вес` + String get weight { + return Intl.message( + 'Вес', + name: 'weight', + desc: '', + args: [], + ); + } + + /// `Пройденные планы` + String get plans_complete { + return Intl.message( + 'Пройденные планы', + name: 'plans_complete', + desc: '', + args: [], + ); + } + + /// `Мои настройки` + String get my_settings { + return Intl.message( + 'Мои настройки', + name: 'my_settings', + desc: '', + args: [], + ); + } + + /// `Профиль` + String get profile { + return Intl.message( + 'Профиль', + name: 'profile', + desc: '', + args: [], + ); + } + + /// `Чат` + String get chat { + return Intl.message( + 'Чат', + name: 'chat', + desc: '', + args: [], + ); + } + + /// `Админ` + String get admin { + return Intl.message( + 'Админ', + name: 'admin', + desc: '', + args: [], + ); + } + + /// `Дневник` + String get diary { + return Intl.message( + 'Дневник', + name: 'diary', + desc: '', + args: [], + ); + } + + /// `Сохранить` + String get save { + return Intl.message( + 'Сохранить', + name: 'save', + desc: '', + args: [], + ); + } + + /// `шт` + String get pcs { + return Intl.message( + 'шт', + name: 'pcs', + desc: '', + args: [], + ); + } + + /// `гр` + String get gr { + return Intl.message( + 'гр', + name: 'gr', + desc: '', + args: [], + ); + } + + /// `гр` + String get grams { + return Intl.message( + 'гр', + name: 'grams', + desc: '', + args: [], + ); + } +} + +class AppLocalizationDelegate extends LocalizationsDelegate { + const AppLocalizationDelegate(); + + List get supportedLocales { + return const [ + Locale.fromSubtags(languageCode: 'en'), + ]; + } + + @override + bool isSupported(Locale locale) => _isSupported(locale); + @override + Future load(Locale locale) => S.load(locale); + @override + bool shouldReload(AppLocalizationDelegate old) => false; + + bool _isSupported(Locale locale) { + for (var supportedLocale in supportedLocales) { + if (supportedLocale.languageCode == locale.languageCode) { + return true; + } + } + return false; + } +} diff --git a/lib/localization/ru/ru_translations.dart b/lib/l10n/intl_en.arb similarity index 81% rename from lib/localization/ru/ru_translations.dart rename to lib/l10n/intl_en.arb index aff8f268..024f9a59 100644 --- a/lib/localization/ru/ru_translations.dart +++ b/lib/l10n/intl_en.arb @@ -1,44 +1,32 @@ -final Map ru = { - //credentials Screen +{ "user_registration": "Регистрация пользователя", "email": "Элетронная почта", "username": "Имя пользователя", "password": "Пароль", "password_confirmation": "Подтвердите пароль", - 'wrong_credentials': "Неверные данные пользователя", - - //name Screen + "wrong_credentials": "Неверные данные пользователя", "first_name": "Имя", "last_name": "Фамилия", "what_is_your_name": "Как вас зовут?", - - // date_of_birth Screen "date_of_birth": "Дата рождения", - // city_of_living Screen - "country": "Страна", "Russia": "Россия", "city": "Город", "Moscow": "Москва", + "country": "Страна", + "Russia": "Россия", + "city": "Город", + "Moscow": "Москва", "place_of_living": "Место проживания", - - // body_circumferences Screen - "hip_circumference": "Обхват бедер", "chest_circumference": "Обхват груди", + "hip_circumference": "Обхват бедер", + "chest_circumference": "Обхват груди", "waist_circumference": "Обхват талии", "initial_measurements": "Первичные замеры", - "male": "Мужской", "female": "Женский", - // weight Screen - "weight_measurements": "Замер веса", "your_weight": "Ваш вес:", - "height_measurements": "Замер роста", "your_height": "Ваш рост:", - - // allergies Screen + "weight_measurements": "Замер веса", + "your_weight": "Ваш вес:", + "height_measurements": "Замер роста", + "your_height": "Ваш рост:", "allergies_presence": "Наличие аллергии", - - // medicine_intake Screen "do_you_take_pills": "Принимаете ли вы лекарства или бады?", - - // gender Screen "your_gender": "Ваш пол?", - - // blood_pressure Screen "no": "Нет", "do_you_have_hypertension_tendency": "Есть ли у вас гипертония?", "your_blood_pressure": "Ваше артериальное давление?", @@ -46,39 +34,23 @@ final Map ru = { "up_pressure": "Верхние показатели давления:", "down_pressure": "Нижние показатели давления:", "do_you_have_hypotension_tendency": "Есть ли у вас гипотония?", - - // favorite_sports Screen "your_favorite_sports": "Ваши спортивные увлечения?", - - // favorite_foods Screen "favorite_foods": "Любимые продукты", "favorite_unfavorite_foods": "Ваши любимые/нелюбимые продукты питания?", "unfavorite_foods": "Нелюбимые продукты", - - // schedule Screen "your_schedule": "Ваш режим дня?", "tell_your_schedule": "Расскажите в свободной форме о том как просыпаетесь, когда едите, когда ложитесь спать:", - - // additional_information Screen "additional_information": "Дополнительная информация", "enter_additional_information": "Введите любую дополнительную информацию на своё усмотрение:", - - // language_select Screen "lbl_english": "English", "finish": "Завершить", "preferred_language": "Предпочитаемый язык общения", - - // Common String - "continue": "Продолжить", "skip": "Пропустить", + "continueButton": "Продолжить", + "skip": "Пропустить", "fill_in_information": "Заполните информацию:", "enter_information": "Введите информацию...", - - // Network Error String "msg_network_err": "Сетевая ошибка!", "msg_something_went_wrong": "Что то пошло не так!", - - // Errors - // Credentials "email_empty": "Необходимо ввести адрес электронной почты", "email_invalid": "Некорректный адрес электронной почты", "password_empty": "Пароль обязателен для заполнения", @@ -86,27 +58,17 @@ final Map ru = { "name_empty": "Имя пользователя обязательно для заполнения", "name_short": "В имени пользователя должно быть минимум 6 символов", "password_confirmation_mismatch": "Пароли не совпадают", - - // Name "first_name_empty": "Имя обязательно для заполнения", "first_name_short": "В имени должен быть минимум 1 символ", "last_name_empty": "Фамилия обязательна для заполнения", "last_name_short": "В фамилии должен быть минимум 6 символов", - - // Body Circumference "circumference_empty": "Все замеры обязательны к заполнению", "circumference_is_not_a_number": "Все замеры должны быть числами", - - // Body Circumference "pressure_empty": "Все показатели давления обязательны к заполнению", "pressure_is_not_a_number": "Все показатели давления должны быть числами", - - // Authorization "no_account": "У меня нет аккаунта", "authentificate": "Войти", "user_authorization": "Аутентификация", - - // Личный кабинет Screen "loading": "Загрузка...", "weight_chart": "График веса", "circumferences_chart": "График обхватов", @@ -133,5 +95,5 @@ final Map ru = { "save": "Сохранить", "pcs": "шт", "gr": "гр", - "grams": "гр", -}; + "grams": "гр" +} \ No newline at end of file diff --git a/lib/localization/app_localization.dart b/lib/localization/app_localization.dart deleted file mode 100644 index 7390b372..00000000 --- a/lib/localization/app_localization.dart +++ /dev/null @@ -1,61 +0,0 @@ -import 'package:eatvio_app/app_router.dart'; -import 'package:flutter/cupertino.dart'; - -//import 'en_us/en_us_translations.dart'; -import 'package:flutter/foundation.dart'; - -import 'ru/ru_translations.dart'; - -class AppLocalization { - AppLocalization(this.locale); - - Locale locale; - - static final Map> _localizedValues = { - 'ru': ru, - }; - - /*static final Map> __localizedValues = { - 'en': enUs - };*/ - - static AppLocalization of() { - final context = AppRouter.navigatorKey.currentContext; - if (context != null) { - return Localizations.of(context, AppLocalization)!; - } else { - // Обработка ситуации, когда context равен null - return AppLocalization( - Locale( - 'ru', - '', - ), - ); // Возвращаем дефолтное значение или обработку ошибки - } - } - - static List languages() => _localizedValues.keys.toList(); - - String getString(String text) => _localizedValues[locale.languageCode]![text] ?? text; -} - -class AppLocalizationDelegate extends LocalizationsDelegate { - const AppLocalizationDelegate(); - - @override - bool isSupported(Locale locale) => AppLocalization.languages().contains(locale.languageCode); - - //Returning a SynchronousFuture here because an async "load" operation - //cause an async "load" operation - @override - Future load(Locale locale) { - return SynchronousFuture(AppLocalization(locale)); - } - - @override - bool shouldReload(AppLocalizationDelegate old) => false; -} - -extension LocalizationExtension on String { - String get tr => AppLocalization.of().getString(this); -} diff --git a/lib/localization/en_us/en_us_translations.dart b/lib/localization/en_us/en_us_translations.dart deleted file mode 100644 index c68f1315..00000000 --- a/lib/localization/en_us/en_us_translations.dart +++ /dev/null @@ -1,63 +0,0 @@ -final Map enUs = { - // date_of_birth Screen - "date_of_birth": "Date of Birth", - - // city_of_living Screen - "country": "Country", "Russia": "Russia", "city": "City", "Moscow": "Moscow", - "place_of_living": "Place of Living", - - // body_circumferences Screen - "hip_circumference": "Hip circumference", - "chest_circumference": "Chest circumference", - "waist_circumference": "Waist circumference", - "initial_measurements": "Initial measurements", - - // weight Screen - "weight_measurements": "Weight measurements", "your_weight": "Your weight:", - "height_measurements": "Height measurements", "your_height": "Your height:", - - // allergies Screen - "allergies_presence": "Allergies presence", - - // medicine_intake Screen - "do_you_take_pills": "Do you take pills or supplements?", - - // gender Screen - "your_gender": "Your Gender?", - - // blood_pressure Screen - "no": "No", - "do_you_have_hypertension_tendency": "Do you have a tendency for hypertension?", - "your_blood_pressure": "Your blood pressure?", - "average_pressure": "Average pressure:", - "do_you_have_hypotension_tendency": "Do you have a tendency for hypotension?", - - // favorite_sports Screen - "your_favorite_sports": "Your Favorite Sports?", - - // favorite_foods Screen - "favorite_foods": "Favorite Foods:", - "favorite_unfavorite_foods": "Your most ot reast favorite foods?", - "unfavorite_foods": "Unfavorite Foods:", - - // schedule Screen - "your_schedule": "Your Daily Schedule?", - "tell_your_schedule": "Tell us about your daily routine, when you wake up, eat, and go to sleep:", - - // additional_information Screen - "additional_information": "Additional Information:", - "enter_additional_information": "Enter any additional information you would like to share:", - - // language_select Screen - "lbl_english": "English", - "preferred_language": "Preferred Language", - - // Common String - "continue": "Continue", "skip": "Skip", - "fill_in_information": "Fill in Information:", - "enter_information": "Enter Information...", - -// Network Error String - "msg_network_err": "Network Error!", - "msg_something_went_wrong": "Something went wrong!", -}; diff --git a/lib/main.dart b/lib/main.dart index 7191b2b0..0fe04674 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -2,7 +2,7 @@ import 'package:eatvio_app/app_router.dart'; import 'package:eatvio_app/core/initialization_cubit/initialization_cubit.dart'; import 'package:eatvio_app/features/bottom_navigation_bar/presentation/bloc/new_messages_cubit/new_messages_cubit.dart'; import 'package:eatvio_app/features/bottom_navigation_bar/presentation/bloc/notifications_cubit/notifications_cubit.dart'; -import 'package:eatvio_app/localization/app_localization.dart'; +import 'package:eatvio_app/generated/l10n.dart'; import 'package:eatvio_app/locator_service.dart' as di; import 'package:eatvio_app/locator_service.dart'; import 'package:eatvio_app/theme/theme_helper.dart'; @@ -33,21 +33,19 @@ class MyApp extends StatelessWidget { theme: ThemeData.light().copyWith( colorScheme: ColorScheme.fromSeed(seedColor: appTheme.blueA400), ), - // darkTheme: ThemeData.dark().copyWith(), + darkTheme: ThemeData.dark().copyWith( + colorScheme: ColorScheme.fromSeed(seedColor: appTheme.blueA400), + ), themeMode: ThemeMode.system, routerConfig: AppRouter.appRouter, debugShowCheckedModeBanner: false, - localizationsDelegates: [ - AppLocalizationDelegate(), + localizationsDelegates: const [ + S.delegate, GlobalMaterialLocalizations.delegate, GlobalWidgetsLocalizations.delegate, GlobalCupertinoLocalizations.delegate, ], - supportedLocales: [ - Locale( - 'ru', - ), - ], + supportedLocales: S.delegate.supportedLocales, ), ), ); diff --git a/lib/old/auth/auth_screen/auth_screen.dart b/lib/old/auth/auth_screen/auth_screen.dart index 37be6818..fc69d52d 100644 --- a/lib/old/auth/auth_screen/auth_screen.dart +++ b/lib/old/auth/auth_screen/auth_screen.dart @@ -3,7 +3,7 @@ import 'dart:convert'; import 'package:eatvio_app/core/const.dart'; import 'package:eatvio_app/core/token_storage.dart'; import 'package:eatvio_app/core/utils/image_constant.dart'; -import 'package:eatvio_app/localization/app_localization.dart'; +import 'package:eatvio_app/generated/l10n.dart'; import 'package:eatvio_app/theme/theme_helper.dart'; import 'package:eatvio_app/widgets/app_bar/appbar_title_image.dart'; import 'package:eatvio_app/widgets/custom_text_form_field.dart'; @@ -40,6 +40,7 @@ class _AuthScreenState extends State { @override Widget build(BuildContext context) { + final s = S.of(context); return Scaffold( appBar: AppBar( centerTitle: true, @@ -51,7 +52,7 @@ class _AuthScreenState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("email".tr), + Text(s.email), SizedBox(height: 4), BlocSelector( selector: (state) => state.emailController, @@ -66,7 +67,7 @@ class _AuthScreenState extends State { }, ), SizedBox(height: 16), - Text("password".tr), + Text(s.password), SizedBox(height: 4), BlocSelector( selector: (state) => state.passwordController, @@ -154,6 +155,7 @@ class _AuthScreenState extends State { } onTapAuth(AuthState state, BuildContext context) { + final s = S.of(context); return () async { List errors = validateFields(state.emailController!.text, state.passwordController!.text); if (errors.isEmpty) { @@ -178,7 +180,7 @@ class _AuthScreenState extends State { context: context, builder: (context) => AlertDialog( title: Text('Ошибка'), - content: Text('wrong_credentials'.tr), + content: Text(s.wrong_credentials), actions: [ TextButton( onPressed: () => Navigator.pop(context), @@ -213,22 +215,24 @@ class _AuthScreenState extends State { } List validateFields(String email, String password) { + final s = S.of(context); + List errors = []; if (!isEmail(email)) { - errors.add('email_invalid'.tr); + errors.add(s.email_invalid); } if (email.isEmpty) { - errors.add('email_empty'.tr); + errors.add(s.email_empty); } if (password.isEmpty) { - errors.add('password_empty'.tr); + errors.add(s.password_empty); } if (password.length < 6) { - errors.add('password_short'.tr); + errors.add(s.password_short); } return errors; diff --git a/lib/old/profile/my_profile_screen/my_profile_screen.dart b/lib/old/profile/my_profile_screen/my_profile_screen.dart index d425dd68..c732d5af 100644 --- a/lib/old/profile/my_profile_screen/my_profile_screen.dart +++ b/lib/old/profile/my_profile_screen/my_profile_screen.dart @@ -1,10 +1,9 @@ import 'dart:convert'; import 'dart:math'; - import 'package:cached_network_image/cached_network_image.dart'; import 'package:carousel_slider_plus/carousel_slider_plus.dart'; import 'package:eatvio_app/core/const.dart'; -import 'package:eatvio_app/localization/app_localization.dart'; +import 'package:eatvio_app/generated/l10n.dart'; import 'package:eatvio_app/theme/app_decoration.dart'; import 'package:eatvio_app/theme/custom_text_style.dart'; import 'package:eatvio_app/theme/theme_helper.dart'; @@ -194,7 +193,8 @@ class MyProfileScreen extends StatelessWidget { }; } - _buildCarousel(BuildContext contex, MyProfileLoadedState state) { + _buildCarousel(BuildContext context, MyProfileLoadedState state) { + final s = S.of(context); return CarouselSlider( options: CarouselOptions(height: 340), items: [1, 2, 3].map((chartType) { @@ -207,7 +207,7 @@ class MyProfileScreen extends StatelessWidget { child: Column( children: [ Text( - "weight_chart".tr, + s.weight_chart, style: CustomTextStyles.titleMediumBlack.copyWith( color: appTheme.black900, ), @@ -225,7 +225,7 @@ class MyProfileScreen extends StatelessWidget { return Column( children: [ Text( - "bodymass_chart".tr, + s.bodymass_chart, style: CustomTextStyles.titleMediumBlack.copyWith( color: appTheme.black900, ), @@ -247,14 +247,14 @@ class MyProfileScreen extends StatelessWidget { child: Column( children: [ Text( - "circumferences_chart".tr, + s.circumferences_chart, style: CustomTextStyles.titleMediumBlack.copyWith( color: appTheme.black900, ), ), SizedBox(height: 30), _buildCircumferenceChart(context, state.circumferences, state.chartDates), - _buildChartLegend(), + _buildChartLegend(context), ], ), ); @@ -267,9 +267,10 @@ class MyProfileScreen extends StatelessWidget { ); } - _buildChartLegend() { + _buildChartLegend(BuildContext context) { + final s = S.of(context); final colors = [Colors.pink, Colors.green, Colors.purple]; - final titles = ["chest".tr, "waist".tr, "hips".tr]; + final titles = [s.chest, s.waist, s.hips]; final style = TextStyle( color: Colors.black, fontWeight: FontWeight.bold, @@ -650,13 +651,14 @@ class MyProfileScreen extends StatelessWidget { /// Section Widget _buildPlans(BuildContext context, List? plans, List? imagePaths, List? states) { + final s = S.of(context); return Padding( padding: EdgeInsets.only(left: 7), child: Column( children: [ Padding( padding: EdgeInsets.only(left: 15), - child: Text("plans_complete".tr, style: CustomTextStyles.titleMediumBlack.copyWith(color: appTheme.black900)), + child: Text(s.plans_complete, style: CustomTextStyles.titleMediumBlack.copyWith(color: appTheme.black900)), ), SizedBox(height: 5), Container( @@ -735,7 +737,7 @@ class MyProfileScreen extends StatelessWidget { child: Container( width: 70, margin: EdgeInsets.only(bottom: 14, right: 22), - child: Text("$state".tr, maxLines: 3, overflow: TextOverflow.ellipsis, style: theme.textTheme.titleSmall), + child: Text("$state", maxLines: 3, overflow: TextOverflow.ellipsis, style: theme.textTheme.titleSmall), ), ), ], @@ -765,6 +767,7 @@ class MyProfileScreen extends StatelessWidget { } _editCircumference(BuildContext context, MyProfileLoadedState state) { + final s = S.of(context); showDialog( context: context, builder: (context) { @@ -779,7 +782,7 @@ class MyProfileScreen extends StatelessWidget { children: [ Padding( padding: EdgeInsets.symmetric(vertical: 5), - child: Text("chest_circumference".tr, style: theme.textTheme.bodyLarge), + child: Text(s.chest_circumference, style: theme.textTheme.bodyLarge), ), SizedBox(height: 5), CustomTextFormField( @@ -791,7 +794,7 @@ class MyProfileScreen extends StatelessWidget { ), Padding( padding: EdgeInsets.symmetric(vertical: 15), - child: Text("waist_circumference".tr, style: theme.textTheme.bodyLarge), + child: Text(s.waist_circumference, style: theme.textTheme.bodyLarge), ), SizedBox(height: 5), CustomTextFormField( @@ -803,7 +806,7 @@ class MyProfileScreen extends StatelessWidget { ), Padding( padding: EdgeInsets.symmetric(vertical: 15), - child: Text("hip_circumference".tr, style: theme.textTheme.bodyLarge), + child: Text(s.hip_circumference, style: theme.textTheme.bodyLarge), ), SizedBox(height: 5), CustomTextFormField( @@ -876,6 +879,7 @@ class MyProfileScreen extends StatelessWidget { } _editWeight(BuildContext context, MyProfileLoadedState state) { + final s = S.of(context); showDialog( context: context, builder: (context) { @@ -887,7 +891,7 @@ class MyProfileScreen extends StatelessWidget { children: [ Padding( padding: EdgeInsets.symmetric(vertical: 5), - child: Text("weight".tr, style: theme.textTheme.bodyLarge), + child: Text(s.weight, style: theme.textTheme.bodyLarge), ), SizedBox(height: 5), CustomTextFormField( diff --git a/lib/widgets/custom_expandable_list.dart b/lib/widgets/custom_expandable_list.dart index 5f208327..872a8fd5 100644 --- a/lib/widgets/custom_expandable_list.dart +++ b/lib/widgets/custom_expandable_list.dart @@ -2,7 +2,7 @@ import 'dart:convert'; import 'package:eatvio_app/core/const.dart'; import 'package:eatvio_app/core/token_storage.dart'; -import 'package:eatvio_app/localization/app_localization.dart'; +import 'package:eatvio_app/generated/l10n.dart'; import 'package:eatvio_app/old/profile/my_profile_screen/bloc/my_profile_bloc.dart'; import 'package:eatvio_app/theme/custom_button_style.dart'; import 'package:eatvio_app/widgets/custom_hyper_switch.dart'; @@ -87,6 +87,7 @@ class _ExpandableListState extends State { } _buildForm(BuildContext context, MyProfileLoadedState state) { + final s = S.of(context); List cities = [ 'Москва', 'Санкт-Петербург', @@ -134,14 +135,14 @@ class _ExpandableListState extends State { children: [ TextField( controller: state.firstNameFormController, - decoration: InputDecoration(labelText: 'first_name'.tr), + decoration: InputDecoration(labelText: s.first_name), ), TextField( controller: state.lastNameFormController, - decoration: InputDecoration(labelText: 'last_name'.tr), + decoration: InputDecoration(labelText: s.last_name), ), TextField( - decoration: InputDecoration(labelText: 'date_of_birth'.tr), + decoration: InputDecoration(labelText: s.date_of_birth), controller: state.dateFormController, onTap: inputTime(context, state), ), @@ -155,7 +156,7 @@ class _ExpandableListState extends State { child: Text(value), ); }).toList(), - decoration: InputDecoration(labelText: 'country'.tr), + decoration: InputDecoration(labelText: s.country), ), DropdownButtonFormField( hint: Text(state.selectedCity ?? "Не выбрано"), @@ -167,78 +168,78 @@ class _ExpandableListState extends State { child: Text(value), ); }).toList(), - decoration: InputDecoration(labelText: 'city_of_living'.tr), + decoration: InputDecoration(labelText: s.city_of_living), ), TextField( controller: state.weightFormController, - decoration: InputDecoration(labelText: 'weight_measurements'.tr), + decoration: InputDecoration(labelText: s.weight_measurements), keyboardType: TextInputType.number, inputFormatters: [digitsOnly], ), TextField( controller: state.heightFormController, - decoration: InputDecoration(labelText: 'height_measurements'.tr), + decoration: InputDecoration(labelText: s.height_measurements), keyboardType: TextInputType.number, inputFormatters: [digitsOnly], ), TextField( controller: state.chestCircumferenceFormController, - decoration: InputDecoration(labelText: 'chest_circumference'.tr), + decoration: InputDecoration(labelText: s.chest_circumference), keyboardType: TextInputType.number, inputFormatters: [digitsOnly], ), TextField( controller: state.waistCircumferenceFormController, - decoration: InputDecoration(labelText: 'waist_circumference'.tr), + decoration: InputDecoration(labelText: s.waist_circumference), keyboardType: TextInputType.number, inputFormatters: [digitsOnly], ), TextField( controller: state.hipCircumferenceFormController, - decoration: InputDecoration(labelText: 'hip_circumference'.tr), + decoration: InputDecoration(labelText: s.hip_circumference), keyboardType: TextInputType.number, inputFormatters: [digitsOnly], ), TextField( controller: state.upPressureFormController, - decoration: InputDecoration(labelText: 'up_pressure'.tr), + decoration: InputDecoration(labelText: s.up_pressure), keyboardType: TextInputType.number, inputFormatters: [digitsOnly], ), TextField( controller: state.downPressureFormController, - decoration: InputDecoration(labelText: 'down_pressure'.tr), + decoration: InputDecoration(labelText: s.down_pressure), keyboardType: TextInputType.number, inputFormatters: [digitsOnly], ), TextField( controller: state.allergiesFormController, - decoration: InputDecoration(labelText: 'allergies_presence'.tr), + decoration: InputDecoration(labelText: s.allergies_presence), maxLines: null, ), TextField( controller: state.pillsFormController, - decoration: InputDecoration(labelText: 'do_you_take_pills'.tr), + decoration: InputDecoration(labelText: s.do_you_take_pills), maxLines: null, ), TextField( controller: state.sportsFormController, - decoration: InputDecoration(labelText: 'your_favorite_sports'.tr), + decoration: InputDecoration(labelText: s.your_favorite_sports), maxLines: null, ), TextField( controller: state.favoriteFormController, - decoration: InputDecoration(labelText: 'favorite_foods'.tr), + decoration: InputDecoration(labelText: s.favorite_foods), maxLines: null, ), TextField( controller: state.unfavoriteFormController, - decoration: InputDecoration(labelText: 'unfavorite_foods'.tr), + decoration: InputDecoration(labelText: s.unfavorite_foods), maxLines: null, ), TextField( controller: state.additionalFormController, - decoration: InputDecoration(labelText: 'additional_information'.tr), + decoration: InputDecoration(labelText: s.additional_information), maxLines: null, ), DropdownButtonFormField( @@ -261,18 +262,18 @@ class _ExpandableListState extends State { ), Row( children: [ - HypoSwitch('do_you_have_hypotension_tendency'.tr, state), + HypoSwitch(s.do_you_have_hypotension_tendency, state), ], ), Row( children: [ - HyperSwitch('do_you_have_hypertension_tendency'.tr, state), + HyperSwitch(s.do_you_have_hypertension_tendency, state), ], ), NextStepButton( onPressed: () => sendProfileData(state), buttonStyle: CustomButtonStyles.outlinePrimaryTL15, - text: "save".tr.toUpperCase(), + text: s.save.toUpperCase(), margin: EdgeInsets.only(top: 20, bottom: 20), ), ], diff --git a/pubspec.yaml b/pubspec.yaml index 3d91e2f8..2532b9a1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -54,6 +54,7 @@ dependencies: flutter_html: ^3.0.0-beta.2 file_picker: ^8.1.2 audioplayers: ^6.1.0 + intl: ^0.19.0 dev_dependencies: build_runner: ^2.4.12 @@ -71,3 +72,5 @@ flutter: - assets/images/ - assets/audio/ - assets/icons/ +flutter_intl: + enabled: true diff --git a/test/auth_test.dart b/test/auth_test.dart index bc637b82..bd789695 100644 --- a/test/auth_test.dart +++ b/test/auth_test.dart @@ -1,11 +1,11 @@ -import 'package:eatvio_app/localization/app_localization.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:flutter_test/flutter_test.dart'; -import 'package:flutter_localizations/flutter_localizations.dart'; +import 'package:eatvio_app/generated/l10n.dart'; import 'package:eatvio_app/old/auth/auth_screen/auth_screen.dart'; import 'package:eatvio_app/old/auth/auth_screen/bloc/auth_bloc.dart'; import 'package:eatvio_app/old/auth/auth_screen/models/auth_model.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_localizations/flutter_localizations.dart'; +import 'package:flutter_test/flutter_test.dart'; void main() { group('AuthScreen', () { @@ -14,18 +14,13 @@ void main() { await tester.pumpWidget( MaterialApp( - localizationsDelegates: [ - AppLocalizationDelegate(), + localizationsDelegates: const [ + S.delegate, GlobalMaterialLocalizations.delegate, GlobalWidgetsLocalizations.delegate, GlobalCupertinoLocalizations.delegate, ], - supportedLocales: [ - Locale( - 'ru', - '', - ), - ], + supportedLocales: S.delegate.supportedLocales, home: BlocProvider( create: (context) => authBloc, child: Builder(