Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat stamp ticket #2498

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
12 changes: 9 additions & 3 deletions wallet/lib/model/event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import 'package:pylons_wallet/pages/home/currency_screen/model/ibc_coins.dart';
import 'package:pylons_wallet/stores/wallet_store.dart';
import '../modules/Pylonstech.pylons.pylons/module/client/cosmos/base/v1beta1/coin.pb.dart';
import '../modules/Pylonstech.pylons.pylons/module/client/pylons/recipe.pb.dart';

enum FreeDrop { yes, no, unselected }

class Events extends Equatable {
Expand All @@ -22,6 +21,7 @@ class Events extends Equatable {
final String description;
final String numberOfTickets;
final String price;
final String? challenge;
final List<PerksModel>? listOfPerks;
final String isFreeDrops;
final String cookbookID;
Expand Down Expand Up @@ -58,6 +58,7 @@ class Events extends Equatable {
///* other
this.cookbookID = '',
this.recipeID = '',
this.challenge,

///* for tracking where its save as draft
this.step = '',
Expand Down Expand Up @@ -89,6 +90,7 @@ class Events extends Equatable {
map['price'] = price;
map['isFreeDrops'] = isFreeDrops;
map['cookbookID'] = cookbookID;
map['challenge'] = challenge ?? '';
map['step'] = step;
map['denom'] = denom.toString();
map['listOfPerks'] = perks;
Expand Down Expand Up @@ -116,6 +118,7 @@ class Events extends Equatable {
price: json['price'] as String,
isFreeDrops: json['isFreeDrops'] as String,
cookbookID: json['cookbookID'] as String,
challenge: json['challenge'] as String?,
step: json['step'] as String,
listOfPerks: listOfPerks,
denom: json['denom'].toString().toIBCCoinsEnumforEvent(),
Expand Down Expand Up @@ -160,6 +163,7 @@ class Events extends Equatable {
listOfPerks: listOfPerks,
cookbookID: map[kCookBookId]!,
recipeID: map[kRecipeId]!,
challenge: map[kChallenge],
denom: denom.isEmpty ? IBCCoins.upylon : denom.toIBCCoinsEnum(),
);
}
Expand All @@ -182,6 +186,7 @@ class Events extends Equatable {
case kPerks:
case kFreeDrop:
case kCookBookId:
case kChallenge:
case kRecipeId:
attributeValues[attribute.key] = attribute.value;
break;
Expand All @@ -202,11 +207,11 @@ class Events extends Equatable {

@override
List<Object?> get props =>
[eventName, hostName, thumbnail, startDate, endDate, startTime, endTime, location, description, numberOfTickets, price, listOfPerks, isFreeDrops, cookbookID, recipeID, step];
[eventName, hostName, thumbnail, startDate, endDate, startTime, endTime, location, description, numberOfTickets, price, listOfPerks, isFreeDrops, cookbookID, recipeID, step, challenge];

@override
String toString() {
return 'Event{eventName: $eventName, hostName: $hostName, thumbnail: $thumbnail, startDate: $startDate, endDate: $endDate, startTime: $startTime, endTime: $endTime, location: $location, description: $description, numberOfTickets: $numberOfTickets, price: $price, listOfPerks: $listOfPerks, isFreeDrop: $isFreeDrops, cookbookID: $cookbookID, recipeID: $recipeID, step: $step}';
return 'Event{eventName: $eventName, hostName: $hostName, thumbnail: $thumbnail, startDate: $startDate, endDate: $endDate, startTime: $startTime, endTime: $endTime, location: $location, description: $description, numberOfTickets: $numberOfTickets, price: $price, listOfPerks: $listOfPerks, isFreeDrop: $isFreeDrops, cookbookID: $cookbookID, recipeID: $recipeID, step: $step, challenge: $challenge}';
}

static Future<Events?> eventFromRecipeId(String cookbookId, String recipeId) async {
Expand Down Expand Up @@ -237,6 +242,7 @@ const kPrice = "kPrice";
const kFreeDrop = "kFreeDrop";
const kRecipeId = "kRecipeId";
const kCookBookId = "kCookBookId";
const kChallenge = "kChallenge";
const kVersion = "v0.2.0";
const kUpylon = "upylon";
const kPylonSymbol = 'upylon';
Expand Down
4 changes: 3 additions & 1 deletion wallet/lib/model/update_recipe_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class UpdateRecipeModel {
String nftPrice = "";
String denom = "";
int quantity = 0;
String challenge = "";

UpdateRecipeModel({
required this.recipe,
Expand All @@ -15,10 +16,11 @@ class UpdateRecipeModel {
required this.nftPrice,
required this.denom,
required this.quantity,
required this.challenge,
});

@override
String toString() {
return 'UpdateRecipeModel{recipe: $recipe, publicAddress: $publicAddress, enabledStatus: $enabledStatus, nftPrice: $nftPrice, denom: $denom, quantity: $quantity}';
return 'UpdateRecipeModel{recipe: $recipe, publicAddress: $publicAddress, enabledStatus: $enabledStatus, nftPrice: $nftPrice, denom: $denom, quantity: $quantity, challenge: $challenge}';
}
}
23 changes: 23 additions & 0 deletions wallet/lib/pages/detailed_asset_view/owner_view_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,7 @@ class OwnerViewViewModel extends ChangeNotifier {
notifyListeners();
}


Future<void> cancelTrade({required String tradeId, required String address}) async {
final tradeResponse = await repository.cancelTrade(
tradeId: TradeId(Int64(int.parse(tradeId))),
Expand All @@ -517,6 +518,28 @@ class OwnerViewViewModel extends ChangeNotifier {
}
}

Future<void> stampTicket({
required String cookbookId,
required String recipeId,
required Address creatorAddress,
required String challenge,
}) async {
final response = await repository.stampTicket(
cookBookId: CookbookId(cookbookId),
recipeId: RecipeId(recipeId),
creatorAddress: creatorAddress,
challenge: challenge,
);

if (response.isLeft()) {
throw response.getLeft();
}

notifyListeners();
}



void logEvent() {
repository.logUserJourney(screenName: AnalyticsScreenEvents.ownerView);
}
Expand Down
139 changes: 86 additions & 53 deletions wallet/lib/pages/events/event_qr_code_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:provider/provider.dart';
import 'package:pylons_wallet/components/buttons/custom_paint_button.dart';
import 'package:pylons_wallet/gen/assets.gen.dart';
import 'package:pylons_wallet/generated/locale_keys.g.dart';
Expand All @@ -12,6 +13,8 @@ import 'package:pylons_wallet/pages/detailed_asset_view/widgets/nft_image_asset.
import 'package:pylons_wallet/utils/constants.dart';
import 'package:qr_flutter/qr_flutter.dart';

import '../../providers/account_provider.dart';

class EventQrCodeScreen extends StatefulWidget {
const EventQrCodeScreen({
super.key,
Expand All @@ -25,67 +28,97 @@ class EventQrCodeScreen extends StatefulWidget {
}

class _EventQrCodeScreenState extends State<EventQrCodeScreen> {
String qrdata = "";
GlobalKey renderObjectKey = GlobalKey();


@override
Widget build(BuildContext context) {
return Material(
color: AppColors.kBlack,
child: Stack(
children: [
NftImageWidget(
url: widget.events.thumbnail,
opacity: 0.5,
),
Padding(
padding: EdgeInsets.only(left: 23.w, top: MediaQuery.of(context).viewPadding.top + 13.h),
child: GestureDetector(
onTap: () async {
Navigator.pop(context);
},
child: SvgPicture.asset(
Assets.images.icons.back,
height: 25.h,
),
void initState() {
super.initState();

createLink();
}

void createLink() {
final wallet = context
.read<AccountProvider>()
.accountPublicInfo;

if (wallet == null) {
return;
}
qrdata = jsonEncode({
'cookbookId': widget.events.cookbookID,
'recipeId': widget.events.recipeID,
'challenge': widget.events.challenge,
});
}

@override
Widget build(BuildContext context) {
return Material(
color: AppColors.kBlack,
child: Stack(
children: [
NftImageWidget(
url: widget.events.thumbnail,
opacity: 0.5,
),
),
ColoredBox(
color: AppColors.kBlack.withOpacity(0.5),
child: Align(
child: RepaintBoundary(
key: renderObjectKey,
child: QrImageView(
padding: EdgeInsets.zero,
data: jsonEncode(widget.events.toJson()),
size: 200,
dataModuleStyle: const QrDataModuleStyle(color: AppColors.kWhite),
eyeStyle: const QrEyeStyle(eyeShape: QrEyeShape.square, color: AppColors.kWhite),
Padding(
padding: EdgeInsets.only(left: 23.w, top: MediaQuery
.of(context)
.viewPadding
.top + 13.h),
child: GestureDetector(
onTap: () async {
Navigator.pop(context);
},
child: SvgPicture.asset(
Assets.images.icons.back,
height: 25.h,
),
),
),
),
Align(
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 20.w),
child: SvgPicture.asset(Assets.images.svg.qrSideBorder),
ColoredBox(
color: AppColors.kBlack.withOpacity(0.5),
child: Align(
child: RepaintBoundary(
key: renderObjectKey,
child: QrImageView(
padding: EdgeInsets.zero,
data: qrdata,
size: 200,
dataModuleStyle: const QrDataModuleStyle(
color: AppColors.kWhite),
eyeStyle: const QrEyeStyle(
eyeShape: QrEyeShape.square, color: AppColors.kWhite),
),
),
),
),
),
Align(
alignment: Alignment.bottomCenter,
child: Padding(
padding: EdgeInsets.only(bottom: 30.h),
child: CustomPaintButton(
title: LocaleKeys.done.tr(),
bgColor: AppColors.kWhite.withOpacity(0.3),
width: 280.w,
onPressed: () {
Navigator.pop(context);
},
Align(
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 20.w),
child: SvgPicture.asset(Assets.images.svg.qrSideBorder),
),
),
)
],
),
);
Align(
alignment: Alignment.bottomCenter,
child: Padding(
padding: EdgeInsets.only(bottom: 30.h),
child: CustomPaintButton(
title: LocaleKeys.done.tr(),
bgColor: AppColors.kWhite.withOpacity(0.3),
width: 280.w,
onPressed: () {
Navigator.pop(context);
},
),
),
)
],
),
);
}
}
}

Loading
Loading