mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-06-29 04:49:51 +00:00
feat: Implement NFT Tab for Eth (#1166)
* feat: Implement NFT Listing and Importing of new NFTs, also display NFTs linked to the wallet address * Adjust UI based on wallet type, display nfts only when an ethereum wallet * fix: Prevent tab bar from scrolling * feat:Add NFT tab: adjust models and add localization * feat:Add NFT tab: adjust models and add localization * chore: Remove unused widget * fix: Adjust UI to reflect more data, display image based on type, either png or svg, adjust theme-a * fix: Update viewmodel * fix: Add missing dependency to fix failing CI * fix: Revert change in inject app script * Delete cw_polygon/pubspec.lock * - Code enhancements - UI fixes - Removing unrelated files --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
This commit is contained in:
parent
56619b8546
commit
0c77b23ecb
51 changed files with 1219 additions and 132 deletions
95
lib/entities/wallet_nft_response.dart
Normal file
95
lib/entities/wallet_nft_response.dart
Normal file
|
@ -0,0 +1,95 @@
|
|||
class WalletNFTsResponseModel {
|
||||
final int? page;
|
||||
final int? pageSize;
|
||||
|
||||
final List<NFTAssetModel>? result;
|
||||
final String? status;
|
||||
|
||||
WalletNFTsResponseModel({this.page, this.pageSize, this.result, this.status});
|
||||
|
||||
factory WalletNFTsResponseModel.fromJson(Map<String, dynamic> json) {
|
||||
return WalletNFTsResponseModel(
|
||||
page: json['page'] as int?,
|
||||
pageSize: json['page_size'] as int?,
|
||||
result: (json['result'] as List?)
|
||||
?.map((x) => NFTAssetModel.fromJson(x as Map<String, dynamic>))
|
||||
.toList(),
|
||||
status: json['status'] as String?,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class NFTAssetModel {
|
||||
final String? tokenAddress;
|
||||
final String? tokenId;
|
||||
final String? contractType;
|
||||
final String? name;
|
||||
final String? symbol;
|
||||
NormalizedMetadata? normalizedMetadata;
|
||||
|
||||
NFTAssetModel(
|
||||
{this.tokenAddress,
|
||||
this.tokenId,
|
||||
this.contractType,
|
||||
this.name,
|
||||
this.symbol,
|
||||
this.normalizedMetadata});
|
||||
|
||||
factory NFTAssetModel.fromJson(Map<String, dynamic> json) {
|
||||
return NFTAssetModel(
|
||||
tokenAddress: json['token_address'] as String?,
|
||||
tokenId: json['token_id'] as String?,
|
||||
contractType: json['contract_type'] as String?,
|
||||
name: json['name'] as String?,
|
||||
symbol: json['symbol'] as String?,
|
||||
normalizedMetadata: json['normalized_metadata'] != null
|
||||
? new NormalizedMetadata.fromJson(
|
||||
json['normalized_metadata'] as Map<String, dynamic>)
|
||||
: null,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class NormalizedMetadata {
|
||||
final String? name;
|
||||
final String? description;
|
||||
final String? image;
|
||||
NormalizedMetadata({
|
||||
this.name,
|
||||
this.description,
|
||||
this.image,
|
||||
});
|
||||
|
||||
factory NormalizedMetadata.fromJson(Map<String, dynamic> json) {
|
||||
return NormalizedMetadata(
|
||||
name: json['name'] as String?,
|
||||
description: json['description'] as String?,
|
||||
image: json['image'] as String?,
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
String? get imageUrl {
|
||||
if (image == null) return image;
|
||||
|
||||
if (image!.contains('ipfs.io')) return image;
|
||||
|
||||
if (!image!.contains('ipfs')) return image;
|
||||
|
||||
// IPFS public gateway provided by Cloudflare is https://cloudflare-ipfs.com/ipfs/
|
||||
//
|
||||
// Here is an example of an ipfs image link:
|
||||
//
|
||||
// [ipfs://bafkreia2i2ctfexpovgzfff66wqhbmwwpvqjvozan7ioifzcnq76jharwu]
|
||||
|
||||
//https://ipfs.io/ipfs/QmTRcRXo6cXByjHYHTVxGpag6vpocrG3rxjPC9PxKAArR9/1620.png
|
||||
|
||||
const String ipfsPublicGateway = 'https://cloudflare-ipfs.com/ipfs/';
|
||||
|
||||
final ipfsPath = image?.split('//')[1];
|
||||
|
||||
final imageLink = '$ipfsPublicGateway$ipfsPath';
|
||||
|
||||
return imageLink;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue