Skip to content

Commit

Permalink
feat: on continue save missing data
Browse files Browse the repository at this point in the history
  • Loading branch information
AhsanRns committed May 21, 2024
1 parent f1323e8 commit f6a526d
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 20 deletions.
6 changes: 3 additions & 3 deletions evently/lib/evently_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class EventlyProvider extends ChangeNotifier {
///* overview screen variable
String _eventName = '';
String _hostName = '';
String? _thumbnail;
String _thumbnail = '';
bool _isOverviewEnable = false;

String? get thumbnail => _thumbnail;
Expand All @@ -55,7 +55,7 @@ class EventlyProvider extends ChangeNotifier {
}

set setThumbnail(String? file) {
_thumbnail = file;
_thumbnail = file!;
checkIsOverEnable();
notifyListeners();
}
Expand All @@ -66,7 +66,7 @@ class EventlyProvider extends ChangeNotifier {
}

checkIsOverEnable() {
setOverviewEnable = thumbnail != null && eventName.length >= kMinEventName && hostName.length >= kMinHostName;
setOverviewEnable = thumbnail!.isNotEmpty && eventName.isNotEmpty && hostName.isNotEmpty;
}

///* detail screen
Expand Down
11 changes: 6 additions & 5 deletions evently/lib/screens/create_event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,12 @@ class _CreateEventState extends State<CreateEvent> {

@override
Widget build(BuildContext context) {
return PopScope(
child: ColoredBox(
color: EventlyAppTheme.kWhite,
child: SafeArea(
bottom: false,
return ColoredBox(
color: EventlyAppTheme.kWhite,
child: SafeArea(
bottom: false,
child: PopScope(
canPop: false,
child: Scaffold(
body: ChangeNotifierProvider.value(value: createEventViewModel, child: const CreateEventContent()),
),
Expand Down
26 changes: 21 additions & 5 deletions evently/lib/screens/detail_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class _DetailsScreenState extends State<DetailsScreen> {
onTap: () async {
_showDatePicker(onSelected: (DateTime? val) {
if (val == null) return;
provider.setStartDate = DateFormat("dd-MM-yyyy").format(val);
provider.setStartDate = _dateFormatter(val);
});
},
child: EventlyTextField(
Expand All @@ -73,7 +73,7 @@ class _DetailsScreenState extends State<DetailsScreen> {
onTap: () {
_showDatePicker(onSelected: (DateTime? val) {
if (val == null) return;
provider.setEndDate = DateFormat("dd-MM-yyyy").format(val);
provider.setEndDate = _dateFormatter(val);
});
},
child: EventlyTextField(
Expand All @@ -97,7 +97,9 @@ class _DetailsScreenState extends State<DetailsScreen> {
onTap: () {
_showTimerPicker(onSelected: (TimeOfDay? timeOfDay) {
if (timeOfDay == null) return;
provider.setStartTime = '${timeOfDay.hour}:${timeOfDay.minute}';
final currentTime = DateTime.now();
final time = currentTime.copyWith(hour: timeOfDay.hour, minute: timeOfDay.minute);
provider.setStartTime = _timerFormatter(time);
});
},
child: EventlyTextField(
Expand All @@ -117,7 +119,9 @@ class _DetailsScreenState extends State<DetailsScreen> {
onTap: () {
_showTimerPicker(onSelected: (TimeOfDay? timeOfDay) {
if (timeOfDay == null) return;
provider.setEndTime = '${timeOfDay.hour}:${timeOfDay.minute}';
final currentTime = DateTime.now();
final time = currentTime.copyWith(hour: timeOfDay.hour, minute: timeOfDay.minute);
provider.setEndTime = _timerFormatter(time);
});
},
child: EventlyTextField(
Expand Down Expand Up @@ -162,6 +166,10 @@ class _DetailsScreenState extends State<DetailsScreen> {
const VerticalSpace(80),
BottomButtons(
onPressContinue: () {
provider.saveAsDraft(
onCompleted: () => {},
uploadStep: UploadStep.price,
);
createEventViewModel.nextPage();
},
onPressSaveDraft: () {
Expand Down Expand Up @@ -198,7 +206,15 @@ class _DetailsScreenState extends State<DetailsScreen> {
showDatePicker(
context: context,
firstDate: DateTime.now(),
lastDate: DateTime.now(),
lastDate: DateTime(2099, 12),
).then((value) => onSelected(value!));
}

_timerFormatter(DateTime dateTime) {
return DateFormat('hh:mm a').format(dateTime);
}

_dateFormatter(DateTime dateTime) {
return DateFormat.yMMMMd('en_US').format(dateTime);
}
}
10 changes: 7 additions & 3 deletions evently/lib/screens/overview_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ class _OverViewScreenState extends State<OverViewScreen> {
dashPattern: const [10, 6],
color: EventlyAppTheme.kTextDarkPurple,
strokeWidth: 3.h,
child: provider.thumbnail != null
child: provider.thumbnail!.isNotEmpty
? SizedBox(
height: 180,
width: double.infinity,
child: Stack(
alignment: Alignment.center,
children: [
CachedNetworkImage(
fit: BoxFit.fill,
fit: BoxFit.contain,
imageUrl: provider.thumbnail!,
errorWidget: (a, b, c) => const Center(child: Icon(Icons.error_outline)),
progressIndicatorBuilder: (context, _, progress) {
Expand All @@ -110,7 +110,7 @@ class _OverViewScreenState extends State<OverViewScreen> {
onTap: () => provider.pickThumbnail(),
child: SvgPicture.asset(
SVGUtils.kSvgUpload,
color: EventlyAppTheme.kWhite,
color: Colors.white,
),
),
],
Expand Down Expand Up @@ -145,6 +145,10 @@ class _OverViewScreenState extends State<OverViewScreen> {
const VerticalSpace(80),
BottomButtons(
onPressContinue: () {
provider.saveAsDraft(
onCompleted: () => {},
uploadStep: UploadStep.overView,
);
createEventViewModel.nextPage();
},
onPressSaveDraft: () {
Expand Down
4 changes: 4 additions & 0 deletions evently/lib/screens/perks_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ class _PerksScreenState extends State<PerksScreen> {
padding: const EdgeInsets.symmetric(horizontal: 20),
child: BottomButtons(
onPressContinue: () {
provider.saveAsDraft(
onCompleted: () => {},
uploadStep: UploadStep.perks,
);
createEventViewModel.nextPage();
},
onPressSaveDraft: () {
Expand Down
5 changes: 4 additions & 1 deletion evently/lib/screens/price_screen.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:easy_localization/easy_localization.dart';
import 'package:evently/evently_provider.dart';
import 'package:evently/models/events.dart';
import 'package:evently/screens/custom_widgets/bottom_buttons.dart';
import 'package:evently/screens/custom_widgets/page_app_bar.dart';
import 'package:evently/screens/custom_widgets/step_labels.dart';
Expand Down Expand Up @@ -207,6 +206,10 @@ class _PriceScreenState extends State<PriceScreen> {
padding: EdgeInsets.symmetric(horizontal: 20.w),
child: BottomButtons(
onPressContinue: () {
provider.saveAsDraft(
onCompleted: () => {},
uploadStep: UploadStep.price,
);
homeViewModel.nextPage();
},
onPressSaveDraft: () {
Expand Down
3 changes: 0 additions & 3 deletions evently/lib/utils/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ const int kEthIntBase = 1000000000000000000;
final List<String> imageAllowedExts = ["png", "jpg", "jpeg", "heif"];
const kPylons = "Pylons";

///number constant
const kMinEventName = 9;
const kMinHostName = 9;

const kErrProfileNotExist = 'profileDoesNotExist';

Expand Down

0 comments on commit f6a526d

Please sign in to comment.