Skip to content

Commit

Permalink
feat: pylon events publisher
Browse files Browse the repository at this point in the history
  • Loading branch information
AhsanRns committed May 20, 2024
1 parent 73b6d96 commit 49cc3f8
Show file tree
Hide file tree
Showing 19 changed files with 386 additions and 130 deletions.
4 changes: 3 additions & 1 deletion evently/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"recipe_created": "Recipe созданный",
"update_failed": "Upload Fehlgeschlagen",
"uploading": "Hochladen ...",
"uploading": "Hochladen ...",
"something_wrong_while_uploading": "Beim Hochladen ist etwas schief gelaufen. Bitte versuche es erneut.",
"cookbook_not_found": "Cookbook nicht gefunden",
"loading": "Wird geladen ...",
Expand All @@ -71,5 +72,6 @@
"save_error": "Failed to save draft",
"event_name" : "Event Name",
"are_you_sure_you_want_to_delete": "Möchten Sie diesen Entwurf wirklich löschen?",
"published": "Veröffentlicht"
"published": "Veröffentlicht",
"delete": "Löschen"
}
3 changes: 2 additions & 1 deletion evently/i18n/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,6 @@
"delete_error": "Failed to delete draft",
"event_name" : "Event Name",
"are_you_sure_you_want_to_delete": "Are you sure you want to delete this draft?",
"published": "Published"
"published": "Published",
"delete": "Delete"
}
3 changes: 2 additions & 1 deletion evently/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,6 @@
"save_error": "No se pudo guardar el Plan Preliminar",
"event_name" : "Event Name",
"are_you_sure_you_want_to_delete": "¿Seguro que quieres eliminar este Plan Preliminar?",
"published": "Publicado"
"published": "Publicado",
"delete": "Borrar"
}
3 changes: 2 additions & 1 deletion evently/i18n/ru-RU.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,6 @@
"save_error": "Не удалось сохранить черновик",
"event_name" : "Event Name",
"are_you_sure_you_want_to_delete": "Вы уверены, что хотите удалить этот черновик?",
"published": "изданный"
"published": "изданный",
"delete": "удалять"
}
2 changes: 1 addition & 1 deletion evently/lib/evently_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ class EventlyProvider extends ChangeNotifier {
required VoidCallback onCompleted,
required UploadStep uploadStep,
}) async {
final id = await repository.saveEvents(Events(step: uploadStep.toString(), eventName: eventName, hostName: hostName, thumbnail: thumbnail!));
await repository.saveEvents(Events(step: uploadStep.toString(), eventName: eventName, hostName: hostName, thumbnail: thumbnail!));
onCompleted();
}
}
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 @@ -70,5 +70,6 @@ abstract class LocaleKeys {
static const save_error = 'save_error';
static const are_you_sure_you_want_to_delete = 'are_you_sure_you_want_to_delete';
static const published = 'published';
static const delete = 'delete';

}
51 changes: 49 additions & 2 deletions evently/lib/repository/repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,29 @@ abstract class Repository {
/// Input: [id] the id of the nft which the user wants to delete
/// Output: [bool] returns whether the operation is successful or not
Future<Either<Failure, bool>> deleteNft(int id);

/// This method will set the input in the cache
/// Input: [key] the key against which the value is to be set, [value] the value that is to be set.
bool setCacheDynamicType({required String key, required dynamic value});

/// This method will set the input in the cache
/// Input: [key] the key against which the value is to be set, [value] the value that is to be set.
void setCacheString({required String key, required String value});

/// This method will return the saved String if exists
/// Input: [key] the key of the value
/// Output: [String] the value of the key
String getCacheString({required String key});

/// This method will delete the value from the cache
/// Input: [key] the key of the value
/// Output: [value] will return the value that is just removed
String deleteCacheString({required String key});

/// This method will return the saved String if exists
/// Input: [key] the key of the value
/// Output: [String] the value of the key
dynamic getCacheDynamicType({required String key});
}

@LazySingleton(as: Repository)
Expand Down Expand Up @@ -169,9 +192,33 @@ class RepositoryImp implements Repository {
try {
final bool result = await localDataSource.deleteNft(id);
return Right(result);
} on Exception catch (exception) {

} on Exception catch (_) {
return Left(CacheFailure(LocaleKeys.something_wrong.tr()));
}
}

@override
bool setCacheDynamicType({required String key, required dynamic value}) {
return localDataSource.setCacheDynamicType(key: key, value: value);
}

@override
void setCacheString({required String key, required String value}) {
localDataSource.setCacheString(key: key, value: value);
}

@override
String getCacheString({required String key}) {
return localDataSource.getCacheString(key: key);
}

@override
String deleteCacheString({required String key}) {
return localDataSource.deleteCacheString(key: key);
}

@override
dynamic getCacheDynamicType({required String key}) {
return localDataSource.getCacheDynamicType(key: key);
}
}
2 changes: 1 addition & 1 deletion evently/lib/screens/create_event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class _CreateEventState extends State<CreateEvent> {
context.read<EventlyProvider>().initStore();
});

createEventViewModel.init();
createEventViewModel.init(setTextField: () {});
}

@override
Expand Down
137 changes: 67 additions & 70 deletions evently/lib/screens/event_hub/event_hub_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -306,65 +306,77 @@ class DraftListTile extends StatefulWidget {

class _DraftListTileState extends State<DraftListTile> {
Widget getDraftCard() {
return DecoratedBox(
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.3),
offset: const Offset(0.0, 1.0),
blurRadius: 4.0,
),
],
),
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 15.w, vertical: 15.h),
child: Row(
children: [
CachedNetworkImage(
width: 90.w,
fit: BoxFit.contain,
imageUrl: widget.events.thumbnail,
errorWidget: (a, b, c) => const Center(child: Icon(Icons.error_outline)),
progressIndicatorBuilder: (context, _, progress) {
return Shimmer(color: EventlyAppTheme.kGrey04, child: const SizedBox.expand());
},
return InkWell(
onTap: (){

final DraftsBottomSheet draftsBottomSheet = DraftsBottomSheet(
buildContext: context,
events: widget.events,
);
draftsBottomSheet.show();
return;

},
child: DecoratedBox(
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.3),
offset: const Offset(0.0, 1.0),
blurRadius: 4.0,
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
(widget.events.eventName.isNotEmpty) ? widget.events.eventName : 'Event Name',
style: titleStyle.copyWith(fontSize: isTablet ? 13.sp : 18.sp),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
SizedBox(
height: 6.h,
),
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(1.h),
color: EventlyAppTheme.kLightRed,
],
),
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 15.w, vertical: 15.h),
child: Row(
children: [
CachedNetworkImage(
width: 90.w,
fit: BoxFit.contain,
imageUrl: widget.events.thumbnail,
errorWidget: (a, b, c) => const Center(child: Icon(Icons.error_outline)),
progressIndicatorBuilder: (context, _, progress) {
return Shimmer(color: EventlyAppTheme.kGrey04, child: const SizedBox.expand());
},
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
(widget.events.eventName.isNotEmpty) ? widget.events.eventName : 'Event Name',
style: titleStyle.copyWith(fontSize: isTablet ? 13.sp : 18.sp),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
padding: EdgeInsets.symmetric(horizontal: 6.w, vertical: 3.h),
child: Text(
LocaleKeys.draft.tr(),
style: EventlyAppTheme.titleStyle.copyWith(color: EventlyAppTheme.kWhite, fontSize: isTablet ? 8.sp : 11.sp),
SizedBox(
height: 6.h,
),
),
],
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(1.h),
color: EventlyAppTheme.kLightRed,
),
padding: EdgeInsets.symmetric(horizontal: 6.w, vertical: 3.h),
child: Text(
LocaleKeys.draft.tr(),
style: EventlyAppTheme.titleStyle.copyWith(color: EventlyAppTheme.kWhite, fontSize: isTablet ? 8.sp : 11.sp),
),
),
],
),
),
),
InkWell(
onTap: () {},
child: Padding(
padding: EdgeInsets.all(4.0.w),
child: SvgPicture.asset(SVGUtils.kSvgMoreOption),
InkWell(
onTap: () {},
child: Padding(
padding: EdgeInsets.all(4.0.w),
child: SvgPicture.asset(SVGUtils.kSvgMoreOption),
),
),
),
],
],
),
),
),
);
Expand Down Expand Up @@ -439,22 +451,7 @@ class BuildGridView extends StatelessWidget {
),
itemBuilder: (context, index) {
final events = eventsList[index];
if (events.price.isNotEmpty && double.parse(events.price) > 0) {
return ClipRRect(
child: Banner(
color: EventlyAppTheme.kDarkGreen,
location: BannerLocation.topEnd,
message: calculateBannerPrice(price: events.price, currency: events.denom),
child: NftGridViewItem(
events: events,
),
),
);
} else {
return NftGridViewItem(
events: events,
);
}
return NftGridViewItem(events: events);
},
),
);
Expand Down
6 changes: 6 additions & 0 deletions evently/lib/screens/event_hub/event_hub_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:easy_localization/easy_localization.dart';
import 'package:evently/generated/locale_keys.g.dart';
import 'package:evently/models/events.dart';
import 'package:evently/repository/repository.dart';
import 'package:evently/utils/constants.dart';
import 'package:evently/utils/extension_util.dart';
import 'package:evently/widgets/loading_with_progress.dart';
import 'package:flutter/cupertino.dart';
Expand Down Expand Up @@ -142,4 +143,9 @@ class EventHubViewModel extends ChangeNotifier {
eventForDraftList.removeWhere((element) => element.id == id);
notifyListeners();
}

void saveEvent({required Events events}) {
repository.setCacheDynamicType(key: eventKey, value: events);
repository.setCacheString(key: fromKey, value: kDraft);
}
}
19 changes: 8 additions & 11 deletions evently/lib/screens/event_hub/widgets/drafts_more_bottomsheet.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:easy_localization/easy_localization.dart';
import 'package:evently/evently_provider.dart';
import 'package:evently/main.dart';
import 'package:evently/models/events.dart';
Expand All @@ -6,6 +7,7 @@ import 'package:evently/screens/event_hub/widgets/delete_confirmation_dialog.dar
import 'package:evently/utils/constants.dart';
import 'package:evently/utils/di/di.dart';
import 'package:evently/utils/evently_app_theme.dart';
import 'package:evently/utils/route_util.dart';
import 'package:evently/widgets/clippers/bottom_sheet_clipper.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
Expand Down Expand Up @@ -45,28 +47,23 @@ class DraftsMoreBottomSheet extends StatelessWidget {

EventlyProvider get easelProvider => sl();

Future<void> onViewOnIPFSPressed({required BuildContext context, required Events events}) async {
// final easelProvider = Provider.of<EventlyProvider>(context, listen: false);
// await easelProvider.repository.launchMyUrl(url: nft.url.changeDomain());
}

@override
Widget build(BuildContext context) {
// final viewModel = context.watch<EventHubViewModel>();
final viewModel = context.watch<EventHubViewModel>();
return ClipPath(
clipper: BottomSheetClipper(),
child: Container(
color: EventlyAppTheme.kGrey02,
color: EventlyAppTheme.kGery03,
padding: EdgeInsets.symmetric(horizontal: 30.w, vertical: 30.h),
child: Wrap(
children: [
moreOptionTile(
title: "publish",
image: SVGUtils.kSvgPublish,
onPressed: () {
// viewModel.saveNFT(nft: nft);
// Navigator.of(context).pop();
// Navigator.of(context).pushNamed(RouteUtil.kRouteHome);
viewModel.saveEvent(events: events);
Navigator.of(context).pop();
Navigator.of(context).pushNamed(RouteUtil.kCreateEvent);
}),
const Divider(
color: EventlyAppTheme.kGrey01,
Expand Down Expand Up @@ -105,7 +102,7 @@ Widget moreOptionTile({required String title, required String image, required Vo
width: 30.w,
),
Text(
title,
title.tr(),
style: titleStyle.copyWith(fontSize: 16.sp),
)
],
Expand Down
Loading

0 comments on commit 49cc3f8

Please sign in to comment.