Skip to content

Commit

Permalink
Hide NFT send button for tezos_ebsi NFT #1840 our special NFT collect…
Browse files Browse the repository at this point in the history
…ion is not displayed properly #1841
  • Loading branch information
hawkbee1 committed Aug 31, 2023
1 parent 67debd6 commit 6e2be86
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 61 deletions.
11 changes: 9 additions & 2 deletions lib/app/shared/constants/altme_strings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ class AltMeStrings {
// static const int clientIdForID360 = 200;

//minter
static const String minterAddress =
'0x240863E65b2ace78eda93334be396FF220f14354';
static const List<String> minterBurnAddress = [
'0x240863E65b2ace78eda93334be396FF220f14354',
];

//Don't send address
static const List<String> contractDontSendAddress = [
'KT1VuCBGQW4WakHj1PXhFC1G848dKyNy34kB',
'KT1Wv4dPiswWYj2H9UrSrVNmcMd9w5NtzczG'
];
}
172 changes: 114 additions & 58 deletions lib/dashboard/home/tab_bar/nft/view/nft_details_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import 'package:altme/wallet/cubit/wallet_cubit.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_html/flutter_html.dart';
import 'package:matrix/matrix.dart';

class NftDetailsPage extends StatelessWidget {
const NftDetailsPage({
Expand Down Expand Up @@ -91,7 +90,7 @@ class _NftDetailsViewState extends State<NftDetailsView> {
child: CachedImageFromNetwork(
widget.nftModel.displayUrl ??
(widget.nftModel.thumbnailUrl ?? ''),
fit: BoxFit.fill,
fit: BoxFit.contain,
errorMessage: l10n.nftTooBigToLoad,
borderRadius: const BorderRadius.all(
Radius.circular(Sizes.largeRadius),
Expand Down Expand Up @@ -132,62 +131,7 @@ class _NftDetailsViewState extends State<NftDetailsView> {
),
),
),
navigation: (widget.nftModel.isTransferable == false ||
widget.nftModel.contractAddress
.equals(AltMeStrings.minterAddress))
? widget.nftModel.contractAddress.equals(AltMeStrings.minterAddress)
? SafeArea(
child: Padding(
padding: const EdgeInsets.all(Sizes.spaceSmall),
child: MyGradientButton(
text: l10n.burn,
onPressed: () async {
final confirmed = await showDialog<bool>(
context: context,
builder: (context) => ConfirmDialog(
title: l10n
.wouldYouLikeToConfirmThatYouIntendToBurnThisNFT,
yes: l10n.yes,
no: l10n.no,
showNoButton: true,
),
);
if (confirmed ?? false) {
await context
.read<NftDetailsCubit>()
.burnDefiComplianceToken(
nftModel: widget.nftModel,
)
.timeout(
const Duration(minutes: 1),
);
}
},
),
),
)
: null
: SafeArea(
child: Padding(
padding: const EdgeInsets.all(Sizes.spaceSmall),
child: MyGradientButton(
text: l10n.send,
onPressed: () {
Navigator.of(context).push<void>(
ConfirmTokenTransactionPage.route(
selectedToken: isTezos
? (widget.nftModel as TezosNftModel).getToken()
: (widget.nftModel as EthereumNftModel)
.getToken(),
withdrawalAddress: '',
amount: 1,
isNFT: true,
),
);
},
),
),
),
navigation: PickButton(l10n: l10n, isTezos: isTezos, widget: widget),
),
);
}
Expand Down Expand Up @@ -413,3 +357,115 @@ class _NftDetailsViewState extends State<NftDetailsView> {
];
}
}

class SendButton extends StatelessWidget {
const SendButton({
super.key,
required this.l10n,
required this.isTezos,
required this.widget,
});

final AppLocalizations l10n;
final bool isTezos;
final NftDetailsView widget;

@override
Widget build(BuildContext context) {
return SafeArea(
child: Padding(
padding: const EdgeInsets.all(Sizes.spaceSmall),
child: MyGradientButton(
text: l10n.send,
onPressed: () {
Navigator.of(context).push<void>(
ConfirmTokenTransactionPage.route(
selectedToken: isTezos
? (widget.nftModel as TezosNftModel).getToken()
: (widget.nftModel as EthereumNftModel).getToken(),
withdrawalAddress: '',
amount: 1,
isNFT: true,
),
);
},
),
),
);
}
}

class BurnButton extends StatelessWidget {
const BurnButton({
super.key,
required this.l10n,
required this.widget,
});

final AppLocalizations l10n;
final NftDetailsView widget;

@override
Widget build(BuildContext context) {
return SafeArea(
child: Padding(
padding: const EdgeInsets.all(Sizes.spaceSmall),
child: MyGradientButton(
text: l10n.burn,
onPressed: () async {
final confirmed = await showDialog<bool>(
context: context,
builder: (context) => ConfirmDialog(
title: l10n.wouldYouLikeToConfirmThatYouIntendToBurnThisNFT,
yes: l10n.yes,
no: l10n.no,
showNoButton: true,
),
);
if (confirmed ?? false) {
await context
.read<NftDetailsCubit>()
.burnDefiComplianceToken(
nftModel: widget.nftModel,
)
.timeout(
const Duration(minutes: 1),
);
}
},
),
),
);
}
}

class PickButton extends StatelessWidget {
const PickButton({
super.key,
required this.l10n,
required this.isTezos,
required this.widget,
});

final AppLocalizations l10n;
final bool isTezos;
final NftDetailsView widget;

@override
Widget build(BuildContext context) {
if (widget.nftModel.isTransferable == false ||
AltMeStrings.contractDontSendAddress
.contains(widget.nftModel.contractAddress)) {
return const SizedBox.shrink();
}
if (AltMeStrings.minterBurnAddress
.contains(widget.nftModel.contractAddress)) {
return BurnButton(l10n: l10n, widget: widget);
}
return SendButton(
l10n: l10n,
isTezos: isTezos,
widget: widget,
);
}
}
2 changes: 1 addition & 1 deletion lib/dashboard/home/tab_bar/nft/widgets/nft_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class NftItem extends StatelessWidget {
borderRadius: BorderRadius.circular(15),
child: CachedImageFromNetwork(
assetUrl,
fit: BoxFit.fill,
fit: BoxFit.contain,
errorMessage: l10n.nftTooBigToLoad,
),
),
Expand Down

0 comments on commit 6e2be86

Please sign in to comment.