Skip to content

Commit

Permalink
feat: thumbnail validation
Browse files Browse the repository at this point in the history
  • Loading branch information
AhsanRns committed May 9, 2024
1 parent cf41a55 commit bef9f2e
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 40 deletions.
3 changes: 2 additions & 1 deletion evently/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,6 @@
"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"
"host_name_remaining_characters": "Host name should have {} characters or more",
"please_select_thumbnail" : "please select thumbnail"
}
3 changes: 2 additions & 1 deletion evently/i18n/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,6 @@
"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"
"host_name_remaining_characters": "Host name should have {} characters or more",
"please_select_thumbnail" : "please select thumbnail"
}
3 changes: 2 additions & 1 deletion evently/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,6 @@
"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"
"host_name_remaining_characters": "Host name should have {} characters or more",
"please_select_thumbnail" : "please select thumbnail"
}
3 changes: 2 additions & 1 deletion evently/i18n/ru-RU.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,6 @@
"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"
"host_name_remaining_characters": "Host name should have {} characters or more",
"please_select_thumbnail" : "please select thumbnail"
}
1 change: 1 addition & 0 deletions evently/lib/generated/locale_keys.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,6 @@ abstract class LocaleKeys {
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';
static const please_select_thumbnail = 'please_select_thumbnail';

}
107 changes: 71 additions & 36 deletions evently/lib/screens/overview_screen.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:io';

import 'package:dotted_border/dotted_border.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:evently/evently_provider.dart';
Expand All @@ -10,6 +12,7 @@ import 'package:evently/utils/space_utils.dart';
import 'package:evently/viewmodels/create_event_viewmodel.dart';
import 'package:evently/widgets/clipped_button.dart';
import 'package:evently/widgets/evently_text_field.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_svg/flutter_svg.dart';
Expand All @@ -26,6 +29,7 @@ class _OverViewScreenState extends State<OverViewScreen> {
final _formKey = GlobalKey<FormState>();
final ValueNotifier<String> _eventNameFieldError = ValueNotifier("");
final ValueNotifier<String> _hostNameFieldError = ValueNotifier("");
final ValueNotifier<String> _thumbnailError = ValueNotifier("");

@override
void initState() {
Expand Down Expand Up @@ -163,45 +167,76 @@ class _OverViewScreenState extends State<OverViewScreen> {
style: TextStyle(fontSize: 18.sp, fontWeight: FontWeight.w700),
),
VerticalSpace(10.h),
ClipRRect(
borderRadius: BorderRadius.only(topRight: Radius.circular(8.r), topLeft: Radius.circular(8.r)),
child: Center(
child: DottedBorder(
borderType: BorderType.Rect,
dashPattern: const [10, 6],
color: EventlyAppTheme.kLightPurple,
strokeWidth: 3.h,
child: provider.thumbnail != null
? Stack(
children: [
Image.file(provider.thumbnail!),
SvgPicture.asset(SVGUtils.kSvgUpload),
],
)
: GestureDetector(
onTap: () => provider.pickThumbnail(),
child: Container(
width: double.infinity,
padding: EdgeInsets.symmetric(vertical: 20.w),
child: Column(
FormField<File>(
validator: (_) {
if (provider.thumbnail == null) {
_thumbnailError.value = LocaleKeys.please_select_thumbnail.tr();
return;
}
_thumbnailError.value = '';
return null;
},
builder: (FormFieldState<File> field) {
return ClipRRect(
borderRadius: BorderRadius.only(topRight: Radius.circular(8.r), topLeft: Radius.circular(8.r)),
child: Center(
child: DottedBorder(
borderType: BorderType.Rect,
dashPattern: const [10, 6],
color: EventlyAppTheme.kLightPurple,
strokeWidth: 3.h,
child: provider.thumbnail != null
? Stack(
alignment: Alignment.center,
children: [
Text(
LocaleKeys.tap_select.tr(),
style: TextStyle(fontSize: 18.sp, fontWeight: FontWeight.bold, color: EventlyAppTheme.kLightPurple),
),
VerticalSpace(10.h),
SvgPicture.asset(SVGUtils.kSvgUpload),
VerticalSpace(10.h),
Text(
LocaleKeys.mb_limit.tr(),
style: TextStyle(fontSize: 18.sp, fontWeight: FontWeight.bold, color: EventlyAppTheme.kLightPurple),
),
Image.file(provider.thumbnail!),
GestureDetector(onTap: () => provider.pickThumbnail(), child: SvgPicture.asset(SVGUtils.kSvgUpload)),
],
)
: GestureDetector(
onTap: () => provider.pickThumbnail(),
child: Container(
width: double.infinity,
padding: EdgeInsets.symmetric(vertical: 20.w),
child: Column(
children: [
Text(
LocaleKeys.tap_select.tr(),
style: TextStyle(fontSize: 18.sp, fontWeight: FontWeight.bold, color: EventlyAppTheme.kLightPurple),
),
VerticalSpace(10.h),
SvgPicture.asset(SVGUtils.kSvgUpload),
VerticalSpace(10.h),
Text(
LocaleKeys.mb_limit.tr(),
style: TextStyle(fontSize: 18.sp, fontWeight: FontWeight.bold, color: EventlyAppTheme.kLightPurple),
),
],
),
),
),
),
),
),
),
),
),
);
},
),
ValueListenableBuilder<String>(
valueListenable: _thumbnailError,
builder: (_, String thumbnailError, __) {
if (thumbnailError.isEmpty) {
return const SizedBox.shrink();
}
return Padding(
padding: EdgeInsets.only(left: 10.w, right: 10.w, top: 2.h),
child: Text(
thumbnailError,
style: TextStyle(
fontSize: 12.sp,
color: Colors.red,
),
),
);
},
),
VerticalSpace(20.h),
ClippedButton(
Expand Down

0 comments on commit bef9f2e

Please sign in to comment.