Skip to content

Commit

Permalink
feat: overscreen input validations
Browse files Browse the repository at this point in the history
  • Loading branch information
AhsanRns committed May 9, 2024
1 parent d88fd5c commit 73478d1
Show file tree
Hide file tree
Showing 10 changed files with 84 additions and 26 deletions.
6 changes: 5 additions & 1 deletion evently/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
6 changes: 5 additions & 1 deletion evently/i18n/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
6 changes: 5 additions & 1 deletion evently/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
6 changes: 5 additions & 1 deletion evently/i18n/ru-RU.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
2 changes: 1 addition & 1 deletion evently/lib/evently_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import 'package:injectable/injectable.dart';

enum FreeDrop { yes, no, unselected }

@lazySingleton
@LazySingleton()
class EventlyProvider extends ChangeNotifier {
EventlyProvider({
required this.repository,
Expand Down
4 changes: 4 additions & 0 deletions evently/lib/generated/locale_keys.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';

}
49 changes: 36 additions & 13 deletions evently/lib/screens/overview_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,8 @@ class _OverViewScreenState extends State<OverViewScreen> {
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: [
Expand Down Expand Up @@ -82,32 +78,39 @@ class _OverViewScreenState extends State<OverViewScreen> {
),
],
),
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<String>(
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,
Expand All @@ -123,19 +126,28 @@ class _OverViewScreenState extends State<OverViewScreen> {
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<String>(
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,
Expand Down Expand Up @@ -185,7 +197,8 @@ class _OverViewScreenState extends State<OverViewScreen> {
bgColor: EventlyAppTheme.kBlue,
textColor: EventlyAppTheme.kWhite,
onPressed: () {
createEventViewModel.nextPage();
// createEventViewModel.nextPage();
validateAndUpdateDescription(moveNextPage: true);
},
cuttingHeight: 15.h,
clipperType: ClipperType.bottomLeftTopRight,
Expand All @@ -212,4 +225,14 @@ class _OverViewScreenState extends State<OverViewScreen> {
)),
);
}

void validateAndUpdateDescription({required bool moveNextPage}) {
FocusScope.of(context).unfocus();
if (!_formKey.currentState!.validate()) {
return;
}
if (_eventNameFieldError.value.isNotEmpty || _hostNameFieldError.value.isNotEmpty) {
return;
}
}
}
4 changes: 4 additions & 0 deletions evently/lib/utils/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ const int kEthIntBase = 1000000000000000000;
final List<String> 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';
Expand Down
20 changes: 13 additions & 7 deletions evently/lib/utils/di/di.config.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion evently/lib/utils/di/register_modules.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 73478d1

Please sign in to comment.