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

Fixed Buy Button removed issue in expanded detail view in Pylons #1118

Merged
merged 6 commits into from
Sep 27, 2022
77 changes: 70 additions & 7 deletions wallet/lib/pages/purchase_item/purchase_item_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,15 @@ class _PurchaseItemScreenState extends State<PurchaseItemScreen> {
widget.purchaseItemViewModel.destroyPlayers(widget.nft);
return true;
},
child: const PurchaseItemContent(
)),
child: const PurchaseItemContent()),
);
}
}

class PurchaseItemContent extends StatefulWidget {


const PurchaseItemContent({Key? key,}) : super(key: key);
const PurchaseItemContent({
Key? key,
}) : super(key: key);

@override
_PurchaseItemContentState createState() => _PurchaseItemContentState();
Expand Down Expand Up @@ -285,7 +284,6 @@ class _OwnerBottomDrawerState extends State<OwnerBottomDrawer> {
onTap: () async {
final Size size = MediaQuery.of(context).size;
context.read<PurchaseItemViewModel>().shareNFTLink(size: size);

},
child: Container(
padding: EdgeInsets.only(bottom: 12.h),
Expand Down Expand Up @@ -657,7 +655,6 @@ class _OwnerBottomDrawerState extends State<OwnerBottomDrawer> {
onTap: () async {
final Size size = MediaQuery.of(context).size;
context.read<PurchaseItemViewModel>().shareNFTLink(size: size);

},
child: SvgPicture.asset(
SVGUtil.OWNER_SHARE,
Expand All @@ -670,6 +667,72 @@ class _OwnerBottomDrawerState extends State<OwnerBottomDrawer> {
],
),
),
if (viewModel.nft.amountMinted < viewModel.nft.quantity)
ClipPath(
clipper: BuyClipper(),
child: InkWell(
onTap: () async {
bool balancesFetchResult = true;
if (viewModel.nft.price != kZeroInt) {
final balancesEither = await viewModel.getBalanceOfSelectedCurrency(
selectedDenom: viewModel.nft.denom,
requiredAmount: double.parse(viewModel.nft.price) / kBigIntBase,
);

if (balancesEither.isLeft()) {
balancesEither.swap().getOrElse(() => '').show();
return;
}

balancesFetchResult = balancesEither.getOrElse(() => false);
}

final PayNowDialog payNowDialog = PayNowDialog(
buildContext: context,
nft: viewModel.nft,
purchaseItemViewModel: viewModel,
onPurchaseDone: (txId) {
showTransactionCompleteDialog(txId);
},
shouldBuy: balancesFetchResult);
payNowDialog.show();
},
child: Container(
width: 200.w,
height: 60.h,
color: kDarkRed.withOpacity(0.8),
child: Row(
children: [
Container(
padding: EdgeInsets.only(left: 20.w),
alignment: Alignment.center,
child: Container(
height: 10.w,
width: 10.w,
decoration: const BoxDecoration(shape: BoxShape.circle, color: kButtonBuyNowColor),
),
),
const Spacer(),
Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"${"buy_for".tr()} ${viewModel.nft.ibcCoins.getCoinWithProperDenomination(viewModel.nft.price)}",
style: TextStyle(color: Colors.white, fontSize: 16.sp),
),
SizedBox(
width: 8.w,
),
viewModel.nft.ibcCoins.getAssets(),
],
),
const Spacer(),
],
),
),
),
)
],
),
),
Expand Down