diff --git a/evently/i18n/de.json b/evently/i18n/de.json index fdd77756cc..87f0e82879 100644 --- a/evently/i18n/de.json +++ b/evently/i18n/de.json @@ -42,5 +42,9 @@ "maximum_1000": "1,000 maximum", "publish": "Publish", "enjoy_the_event": "Enjoy the event!", - "picking_file_error": "Fehler beim Auswählen der Datei" + "picking_file_error": "Fehler beim Auswählen der Datei", + "enter_event_name": "Enter event name", + "event_name_remaining_characters": "Event name should have {} characters or more", + "enter_host_name": "Enter host name", + "host_name_remaining_characters": "Host name should have {} characters or more" } \ No newline at end of file diff --git a/evently/i18n/en-US.json b/evently/i18n/en-US.json index 1d9e6c4ffe..87f0e82879 100644 --- a/evently/i18n/en-US.json +++ b/evently/i18n/en-US.json @@ -42,5 +42,9 @@ "maximum_1000": "1,000 maximum", "publish": "Publish", "enjoy_the_event": "Enjoy the event!", - "picking_file_error": "Error while picking file" + "picking_file_error": "Fehler beim Auswählen der Datei", + "enter_event_name": "Enter event name", + "event_name_remaining_characters": "Event name should have {} characters or more", + "enter_host_name": "Enter host name", + "host_name_remaining_characters": "Host name should have {} characters or more" } \ No newline at end of file diff --git a/evently/i18n/es.json b/evently/i18n/es.json index 4765930576..87f0e82879 100644 --- a/evently/i18n/es.json +++ b/evently/i18n/es.json @@ -42,5 +42,9 @@ "maximum_1000": "1,000 maximum", "publish": "Publish", "enjoy_the_event": "Enjoy the event!", - "picking_file_error": "Error al seleccionar el archivo" + "picking_file_error": "Fehler beim Auswählen der Datei", + "enter_event_name": "Enter event name", + "event_name_remaining_characters": "Event name should have {} characters or more", + "enter_host_name": "Enter host name", + "host_name_remaining_characters": "Host name should have {} characters or more" } \ No newline at end of file diff --git a/evently/i18n/ru-RU.json b/evently/i18n/ru-RU.json index cc8e2c6599..87f0e82879 100644 --- a/evently/i18n/ru-RU.json +++ b/evently/i18n/ru-RU.json @@ -42,5 +42,9 @@ "maximum_1000": "1,000 maximum", "publish": "Publish", "enjoy_the_event": "Enjoy the event!", - "picking_file_error": "Ошибка при выборе файла" + "picking_file_error": "Fehler beim Auswählen der Datei", + "enter_event_name": "Enter event name", + "event_name_remaining_characters": "Event name should have {} characters or more", + "enter_host_name": "Enter host name", + "host_name_remaining_characters": "Host name should have {} characters or more" } \ No newline at end of file diff --git a/evently/lib/evently_provider.dart b/evently/lib/evently_provider.dart index b100ef5e7f..b0c3c5b44f 100644 --- a/evently/lib/evently_provider.dart +++ b/evently/lib/evently_provider.dart @@ -9,7 +9,7 @@ import 'package:injectable/injectable.dart'; enum FreeDrop { yes, no, unselected } -@lazySingleton +@LazySingleton() class EventlyProvider extends ChangeNotifier { EventlyProvider({ required this.repository, diff --git a/evently/lib/generated/locale_keys.g.dart b/evently/lib/generated/locale_keys.g.dart index b96017be86..be6426954b 100644 --- a/evently/lib/generated/locale_keys.g.dart +++ b/evently/lib/generated/locale_keys.g.dart @@ -45,5 +45,9 @@ abstract class LocaleKeys { static const publish = 'publish'; static const enjoy_the_event = 'enjoy_the_event'; static const picking_file_error = 'picking_file_error'; + static const enter_event_name = 'enter_event_name'; + static const event_name_remaining_characters = 'event_name_remaining_characters'; + static const enter_host_name = 'enter_host_name'; + static const host_name_remaining_characters = 'host_name_remaining_characters'; } diff --git a/evently/lib/screens/overview_screen.dart b/evently/lib/screens/overview_screen.dart index 5236f3adfe..a252ae575c 100644 --- a/evently/lib/screens/overview_screen.dart +++ b/evently/lib/screens/overview_screen.dart @@ -44,12 +44,8 @@ class _OverViewScreenState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - const VerticalSpace(20), MyStepsIndicator(currentStep: createEventViewModel.currentStep), - const VerticalSpace(5), StepLabels(currentPage: createEventViewModel.currentPage, currentStep: createEventViewModel.currentStep), - const VerticalSpace(10), - const VerticalSpace(20), Stack( alignment: Alignment.center, children: [ @@ -82,32 +78,39 @@ class _OverViewScreenState extends State { ), ], ), - const VerticalSpace(20), Padding( padding: EdgeInsets.symmetric(horizontal: 20.w, vertical: 15.h), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ EventlyTextField( - label: LocaleKeys.event_name.tr(), hint: LocaleKeys.what_your_event_called.tr(), controller: provider.eventNameController, textCapitalization: TextCapitalization.sentences, validator: (value) { + if (value!.isEmpty) { + _eventNameFieldError.value = LocaleKeys.enter_event_name.tr(); + return; + } + if (value.length <= kMinEventName) { + _eventNameFieldError.value = LocaleKeys.event_name_remaining_characters.tr(args: [kMinEventName.toString()]); + return; + } + _eventNameFieldError.value = ''; return null; }, ), ValueListenableBuilder( valueListenable: _eventNameFieldError, - builder: (_, String artNameFieldError, __) { - if (artNameFieldError.isEmpty) { + builder: (_, String eventNameFieldError, __) { + if (eventNameFieldError.isEmpty) { return const SizedBox.shrink(); } return Padding( padding: EdgeInsets.only(left: 10.w, right: 10.w, top: 2.h), child: Text( - artNameFieldError, + eventNameFieldError, style: TextStyle( fontSize: 12.sp, color: Colors.red, @@ -123,19 +126,28 @@ class _OverViewScreenState extends State { controller: provider.hostNameController, textCapitalization: TextCapitalization.sentences, validator: (value) { + if (value!.isEmpty) { + _hostNameFieldError.value = LocaleKeys.enter_host_name.tr(); + return; + } + if (value.length <= kMinEventName) { + _hostNameFieldError.value = LocaleKeys.host_name_remaining_characters.tr(args: [kMinHostName.toString()]); + return; + } + _hostNameFieldError.value = ''; return null; }, ), ValueListenableBuilder( valueListenable: _hostNameFieldError, - builder: (_, String artNameFieldError, __) { - if (artNameFieldError.isEmpty) { + builder: (_, String hostNameFieldError, __) { + if (hostNameFieldError.isEmpty) { return const SizedBox.shrink(); } return Padding( padding: EdgeInsets.only(left: 10.w, right: 10.w, top: 2.h), child: Text( - artNameFieldError, + hostNameFieldError, style: TextStyle( fontSize: 12.sp, color: Colors.red, @@ -185,7 +197,8 @@ class _OverViewScreenState extends State { bgColor: EventlyAppTheme.kBlue, textColor: EventlyAppTheme.kWhite, onPressed: () { - createEventViewModel.nextPage(); + // createEventViewModel.nextPage(); + validateAndUpdateDescription(moveNextPage: true); }, cuttingHeight: 15.h, clipperType: ClipperType.bottomLeftTopRight, @@ -212,4 +225,14 @@ class _OverViewScreenState extends State { )), ); } + + void validateAndUpdateDescription({required bool moveNextPage}) { + FocusScope.of(context).unfocus(); + if (!_formKey.currentState!.validate()) { + return; + } + if (_eventNameFieldError.value.isNotEmpty || _hostNameFieldError.value.isNotEmpty) { + return; + } + } } diff --git a/evently/lib/utils/constants.dart b/evently/lib/utils/constants.dart index 26c719db33..148370e685 100644 --- a/evently/lib/utils/constants.dart +++ b/evently/lib/utils/constants.dart @@ -29,6 +29,10 @@ const int kEthIntBase = 1000000000000000000; final List imageAllowedExts = ["png", "jpg", "jpeg", "heif"]; const kPylons = "Pylons"; +///number constant +const kMinEventName = 9; +const kMinHostName = 9; + /// ```SVG assets class SVGUtils { static const kSvgSplash = 'assets/images/svg/splash.svg'; diff --git a/evently/lib/utils/di/di.config.dart b/evently/lib/utils/di/di.config.dart index d6aa4a75f7..8c6b8dc150 100644 --- a/evently/lib/utils/di/di.config.dart +++ b/evently/lib/utils/di/di.config.dart @@ -10,11 +10,12 @@ // ignore_for_file: no_leading_underscores_for_library_prefixes import 'package:evently/evently_provider.dart' as _i8; import 'package:evently/repository/repository.dart' as _i7; -import 'package:evently/utils/file_utils_helper.dart' as _i4; +import 'package:evently/utils/di/register_modules.dart' as _i9; +import 'package:evently/utils/file_utils_helper.dart' as _i6; import 'package:evently/viewmodels/create_event_viewmodel.dart' as _i3; -import 'package:file_picker/file_picker.dart' as _i6; +import 'package:file_picker/file_picker.dart' as _i5; import 'package:get_it/get_it.dart' as _i1; -import 'package:image_cropper/image_cropper.dart' as _i5; +import 'package:image_cropper/image_cropper.dart' as _i4; import 'package:injectable/injectable.dart' as _i2; extension GetItInjectableX on _i1.GetIt { @@ -28,16 +29,21 @@ extension GetItInjectableX on _i1.GetIt { environment, environmentFilter, ); + final registerModule = _$RegisterModule(); gh.lazySingleton<_i3.CreateEventViewModel>( () => _i3.CreateEventViewModel()); - gh.lazySingleton<_i4.FileUtilsHelper>(() => _i4.FileUtilsHelperImpl( - imageCropper: gh<_i5.ImageCropper>(), - filePicker: gh<_i6.FilePicker>(), + gh.lazySingleton<_i4.ImageCropper>(() => registerModule.imageCropper); + gh.lazySingleton<_i5.FilePicker>(() => registerModule.filePicker); + gh.lazySingleton<_i6.FileUtilsHelper>(() => _i6.FileUtilsHelperImpl( + imageCropper: gh<_i4.ImageCropper>(), + filePicker: gh<_i5.FilePicker>(), )); gh.lazySingleton<_i7.Repository>( - () => _i7.RepositoryImp(fileUtilsHelper: gh<_i4.FileUtilsHelper>())); + () => _i7.RepositoryImp(fileUtilsHelper: gh<_i6.FileUtilsHelper>())); gh.lazySingleton<_i8.EventlyProvider>( () => _i8.EventlyProvider(repository: gh<_i7.Repository>())); return this; } } + +class _$RegisterModule extends _i9.RegisterModule {} diff --git a/evently/lib/utils/di/register_modules.dart b/evently/lib/utils/di/register_modules.dart index 4782ae37f2..7eafd2668e 100644 --- a/evently/lib/utils/di/register_modules.dart +++ b/evently/lib/utils/di/register_modules.dart @@ -3,10 +3,15 @@ // Injectable is a convenient code generator for get_it. // All you have to do now is annotate your injectable classes with @injectable and let the generator do the work. // This class is use to generate code to register objects on app start +import 'package:file_picker/file_picker.dart'; +import 'package:image_cropper/image_cropper.dart'; import 'package:injectable/injectable.dart'; - @module abstract class RegisterModule { + @LazySingleton() + ImageCropper get imageCropper => ImageCropper(); + @LazySingleton() + FilePicker get filePicker => FilePicker.platform; }