Skip to content

Commit

Permalink
feat: list view and grid view of the events on event hub screen
Browse files Browse the repository at this point in the history
  • Loading branch information
AhsanRns committed May 20, 2024
1 parent 28f4f56 commit 112e826
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 117 deletions.
3 changes: 3 additions & 0 deletions evently/assets/images/svg/file_type_image.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion evently/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,6 @@
"save_error": "Entwurf konnte nicht gespeichert werden",
"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?"
"are_you_sure_you_want_to_delete": "Möchten Sie diesen Entwurf wirklich löschen?",
"published": "Veröffentlicht"
}
3 changes: 2 additions & 1 deletion evently/i18n/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,6 @@
"get_error": "Failed to get draft",
"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?"
"are_you_sure_you_want_to_delete": "Are you sure you want to delete this draft?",
"published": "Published"
}
3 changes: 2 additions & 1 deletion evently/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,6 @@
"delete_error": "No se pudo eliminar el Plan Preliminar",
"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?"
"are_you_sure_you_want_to_delete": "¿Seguro que quieres eliminar este Plan Preliminar?",
"published": "Publicado"
}
3 changes: 2 additions & 1 deletion evently/i18n/ru-RU.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,6 @@
"delete_error": "Не удалось удалить черновик",
"save_error": "Не удалось сохранить черновик",
"event_name" : "Event Name",
"are_you_sure_you_want_to_delete": "Вы уверены, что хотите удалить этот черновик?"
"are_you_sure_you_want_to_delete": "Вы уверены, что хотите удалить этот черновик?",
"published": "изданный"
}
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 @@ -69,5 +69,6 @@ abstract class LocaleKeys {
static const delete_error = 'delete_error';
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';

}
5 changes: 3 additions & 2 deletions evently/lib/screens/event_hub/event_hub_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:evently/models/events.dart';
import 'package:evently/screens/event_hub/event_hub_view_model.dart';
import 'package:evently/screens/event_hub/widgets/delete_confirmation_dialog.dart';
import 'package:evently/screens/event_hub/widgets/drafts_more_bottomsheet.dart';
import 'package:evently/screens/event_hub/widgets/nfts_grid_view.dart';
import 'package:evently/utils/constants.dart';
import 'package:evently/utils/di/di.dart';
import 'package:evently/utils/evently_app_theme.dart';
Expand Down Expand Up @@ -515,13 +516,13 @@ class BuildGridView extends StatelessWidget {
location: BannerLocation.topEnd,
message: calculateBannerPrice(price: events.price, currency: events.denom),
child: NftGridViewItem(
nft: nft,
events: events,
),
),
);
} else {
return NftGridViewItem(
nft: nft,
events: events,
);
}
},
Expand Down
56 changes: 9 additions & 47 deletions evently/lib/screens/event_hub/widgets/drafts_more_bottomsheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@ import 'package:evently/evently_provider.dart';
import 'package:evently/main.dart';
import 'package:evently/models/events.dart';
import 'package:evently/screens/event_hub/event_hub_view_model.dart';
import 'package:evently/screens/event_hub/widgets/delete_confirmation_dialog.dart';
import 'package:evently/utils/constants.dart';
import 'package:evently/utils/di/di.dart';
import 'package:evently/utils/evently_app_theme.dart';
import 'package:evently/widgets/clippers/bottom_sheet_clipper.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:provider/provider.dart';

import '../../../generated/locale_keys.g.dart';

TextStyle titleStyle = TextStyle(fontSize: isTablet ? 13.sp : 16.sp, fontWeight: FontWeight.w800, fontFamily: kUniversalFontFamily, color: EventlyAppTheme.kBlack);

class DraftsBottomSheet {
Expand Down Expand Up @@ -54,7 +52,7 @@ class DraftsMoreBottomSheet extends StatelessWidget {

@override
Widget build(BuildContext context) {
final viewModel = context.watch<EventHubViewModel>();
// final viewModel = context.watch<EventHubViewModel>();
return ClipPath(
clipper: BottomSheetClipper(),
child: Container(
Expand All @@ -66,71 +64,35 @@ class DraftsMoreBottomSheet extends StatelessWidget {
title: "publish",
image: SVGUtils.kSvgPublish,
onPressed: () {
viewModel.saveNFT(nft: nft);
Navigator.of(context).pop();
Navigator.of(context).pushNamed(RouteUtil.kRouteHome);
// viewModel.saveNFT(nft: nft);
// Navigator.of(context).pop();
// Navigator.of(context).pushNamed(RouteUtil.kRouteHome);
}),
const Divider(
color: EaselAppTheme.kGrey,
color: EventlyAppTheme.kGrey01,
),
moreOptionTile(
title: "delete",
image: SVGUtils.kSvgDelete,
onPressed: () {
Navigator.of(context).pop();

final DeleteDialog deleteDialog = DeleteDialog(contextt: context, nft: nft);
final DeleteDialog deleteDialog = DeleteDialog(contextt: context, events: events);

deleteDialog.show();
}),
const Divider(
color: EaselAppTheme.kGrey,
color: EventlyAppTheme.kGrey01,
),
CidOrIpfs(
viewCid: (context) {
return moreOptionTile(
onPressed: () async {
final state = ScaffoldMessenger.of(context);
Navigator.of(context).pop();
await Clipboard.setData(ClipboardData(text: nft.cid));
state
..hideCurrentSnackBar()
..showSnackBar(
SnackBar(content: Text(LocaleKeys.copied_to_clipboard.tr())),
);
},
title: LocaleKeys.copy_cid.tr(),
image: PngUtils.kSvgIpfsLogo,
isSvg: false,
);
},
viewIpfs: (context) {
return moreOptionTile(
onPressed: () async {
Navigator.of(context).pop();
onViewOnIPFSPressed(nft: nft, context: context);
},
title: LocaleKeys.view.tr(),
image: PngUtils.kSvgIpfsLogo,
isSvg: false,
);
},
type: nft.assetType)
],
),
),
);
}

void navigateToPreviewScreen({required BuildContext context, required NFT nft}) {
easelProvider.setPublishedNFTClicked(nft);
easelProvider.setPublishedNFTDuration(nft.duration);
Navigator.of(context).pushReplacementNamed(RouteUtil.kRoutePreviewNFTFullScreen);
}
}

Widget moreOptionTile({required String title, required String image, required VoidCallback onPressed, bool isSvg = true}) {
final TextStyle titleStyle = TextStyle(fontSize: isTablet ? 13.sp : 16.sp, fontWeight: FontWeight.w800, fontFamily: kUniversalFontFamily, color: EaselAppTheme.kBlack);
final TextStyle titleStyle = TextStyle(fontSize: isTablet ? 13.sp : 16.sp, fontWeight: FontWeight.w800, fontFamily: kUniversalFontFamily, color: EventlyAppTheme.kBlack);

return Padding(
padding: EdgeInsets.symmetric(vertical: 8.h),
Expand Down
83 changes: 19 additions & 64 deletions evently/lib/screens/event_hub/widgets/nfts_grid_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import 'package:easy_localization/easy_localization.dart';
import 'package:evently/evently_provider.dart';
import 'package:evently/models/events.dart';
import 'package:evently/screens/event_hub/event_hub_view_model.dart';
import 'package:evently/screens/event_hub/widgets/drafts_more_bottomsheet.dart';
import 'package:evently/utils/constants.dart';
import 'package:evently/utils/evently_app_theme.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
Expand Down Expand Up @@ -51,33 +53,22 @@ class NftGridViewItem extends StatelessWidget {
height: 200.h,
width: 150.w,
child: InkWell(

onTap: () {
if (context.read<EventHubViewModel>().selectedCollectionType == CollectionType.draft) {
final DraftsBottomSheet draftsBottomSheet = DraftsBottomSheet(
buildContext: context,
nft: nft,
events: events,
);
draftsBottomSheet.show();
return;
}
buildBottomSheet(context: context);
},
child: NftTypeBuilder(
onImage: (context) => buildNFTPreview(url: nft.url.changeDomain()),
onVideo: (context) => buildNFTPreview(url: nft.thumbnailUrl.changeDomain()),
onAudio: (context) => buildNFTPreview(url: nft.thumbnailUrl.changeDomain()),
onPdf: (context) => buildNFTPreview(url: nft.thumbnailUrl.changeDomain()),
on3D: (context) => IgnorePointer(
child: ModelViewer(
src: nft.url.changeDomain(),
ar: false,
autoRotate: false,
backgroundColor: EaselAppTheme.kWhite,
cameraControls: false,
),
),
assetType: nft.assetType.toAssetTypeEnum(),
child: CachedNetworkImage(
fit: BoxFit.fitHeight,
imageUrl: events.thumbnail,
errorWidget: (a, b, c) => const Center(child: Icon(Icons.error_outline)),
placeholder: (context, url) => Shimmer(color: EventlyAppTheme.kGery03, child: const SizedBox.expand()),
),
),
),
Expand All @@ -96,8 +87,7 @@ class NftGridViewItem extends StatelessWidget {
child: Padding(
padding: EdgeInsets.only(left: 8.w, top: 10.0.h),
child: SvgPicture.asset(
getNFTIcon(),
key: Key(getNFTIconKey()),
SVGUtils.kFileTypeImageIcon,
color: Colors.white,
width: 14,
height: 14,
Expand All @@ -118,30 +108,25 @@ class NftGridViewItem extends StatelessWidget {
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(1.h),
color: context.read<CreatorHubViewModel>().selectedCollectionType == CollectionType.draft
? EaselAppTheme.kLightRed
: EaselAppTheme.kDarkGreen,
color: context.read<EventHubViewModel>().selectedCollectionType == CollectionType.draft ? EventlyAppTheme.kLightRed : EventlyAppTheme.kDarkGreen,
),
padding: EdgeInsets.symmetric(horizontal: 6.w, vertical: 3.h),
margin: EdgeInsets.symmetric(horizontal: 6.w, vertical: 6.h),
child: Text(
context.read<CreatorHubViewModel>().selectedCollectionType == CollectionType.draft
? LocaleKeys.draft.tr()
: LocaleKeys.published.tr(),
style: EaselAppTheme.titleStyle.copyWith(
color: EaselAppTheme.kWhite,
context.read<EventHubViewModel>().selectedCollectionType == CollectionType.draft ? LocaleKeys.draft.tr() : LocaleKeys.published.tr(),
style: EventlyAppTheme.titleStyle.copyWith(
color: EventlyAppTheme.kWhite,
fontSize: isTablet ? 8.sp : 11.sp,
),
),
),
const Spacer(),
InkWell(
key: const Key(kGridViewTileMoreOptionKey),
onTap: () {
if (context.read<CreatorHubViewModel>().selectedCollectionType == CollectionType.draft) {
if (context.read<EventHubViewModel>().selectedCollectionType == CollectionType.draft) {
final DraftsBottomSheet draftsBottomSheet = DraftsBottomSheet(
buildContext: context,
nft: nft,
events: events,
);
draftsBottomSheet.show();
return;
Expand Down Expand Up @@ -170,43 +155,13 @@ class NftGridViewItem extends StatelessWidget {
fit: BoxFit.fitHeight,
imageUrl: url,
errorWidget: (a, b, c) => const Center(child: Icon(Icons.error_outline)),
placeholder: (context, url) => Shimmer(color: EaselAppTheme.cardBackground, child: const SizedBox.expand()),
placeholder: (context, url) => Shimmer(color: EventlyAppTheme.kGrey01, child: const SizedBox.expand()),
);
}

void buildBottomSheet({required BuildContext context}) {
final bottomSheet = BuildPublishedNFTsBottomSheet(context: context, nft: nft, easelProvider: _easelProvider);

bottomSheet.show();
}

String getNFTIcon() {
switch (nft.assetType) {
case kVideoText:
return SVGUtils.kSvgNftFormatVideo;
case kAudioText:
return SVGUtils.kSvgNftFormatAudio;
case kPdfText:
return SVGUtils.kSvgNftFormatPDF;
case k3dText:
return SVGUtils.kSvgNftFormat3d;
default:
return SVGUtils.kFileTypeImageIcon;
}
}

String getNFTIconKey() {
switch (nft.assetType) {
case kVideoText:
return kNFTTypeVideoIconKey;
case kAudioText:
return kNFTTypeAudioIconKey;
case kPdfText:
return kNFTTypePdfIconKey;
case k3dText:
return kNFTType3dModelIconKey;
default:
return kNFTTypeImageIconKey;
}
// final bottomSheet = BuildPublishedNFTsBottomSheet(context: context, nft: nft, easelProvider: _easelProvider);
//
// bottomSheet.show();
}
}
1 change: 1 addition & 0 deletions evently/lib/utils/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class SVGUtils {
static const kGridIcon = 'assets/images/svg/grid.svg';
static const kListIcon = 'assets/images/svg/list.svg';
static const kSvgPublish = 'assets/images/svg/publish.svg';
static const kFileTypeImageIcon = 'assets/images/svg/file_type_image.svg';


}
Expand Down

0 comments on commit 112e826

Please sign in to comment.