diff --git a/lib/core/util/theme.dart b/lib/core/util/theme.dart index 79b122a..50afc08 100644 --- a/lib/core/util/theme.dart +++ b/lib/core/util/theme.dart @@ -8,6 +8,12 @@ class CustomTheme { static const Color bgSecondColor = Color(0xFF2F2F47); static const Color gray = Color.fromARGB(255, 149, 149, 149); + static const List nftBgColors = [ + CustomTheme.primaryColor, + CustomTheme.secondColor, + Colors.deepPurpleAccent, + ]; + static const TextStyle textSmallPrimary = TextStyle(color: primaryColor, fontSize: 12, fontWeight: FontWeight.w600); static const TextStyle textPrimary = TextStyle(color: primaryColor, fontSize: 16, fontWeight: FontWeight.w600); static const TextStyle textSmallWhite = TextStyle(color: Colors.white, fontSize: 12, fontWeight: FontWeight.w600); diff --git a/lib/core/util/web3/eth_conversions.dart b/lib/core/util/web3/eth_conversions.dart new file mode 100644 index 0000000..32947da --- /dev/null +++ b/lib/core/util/web3/eth_conversions.dart @@ -0,0 +1,36 @@ +import 'dart:math'; + +class EthConversions { + static double weiToEth(BigInt amount, int? decimal) { + if (decimal == null) { + double db = amount / BigInt.from(10).pow(18); + return double.parse(db.toStringAsFixed(2)); + } else { + double db = amount / BigInt.from(10).pow(decimal); + return double.parse(db.toStringAsFixed(2)); + } + } + + static double weiToEthUnTrimmed(BigInt amount, int? decimal) { + if (decimal == null) { + double db = amount / BigInt.from(10).pow(18); + return double.parse(db.toStringAsFixed(6)); + } else { + double db = amount / BigInt.from(10).pow(decimal); + return double.parse(db.toStringAsFixed(6)); + } + } + + static String weiToGwei(BigInt amount) { + var db = amount / BigInt.from(10).pow(9); + return db.toStringAsPrecision(2); + } + + static BigInt ethToWei(String amount, int? decimal) { + double db = double.parse(amount) * pow(10, 4); + int it = db.toInt(); + BigInt bi = BigInt.from(it) * + BigInt.from(10).pow(decimal == null ? 14 : decimal - 4); + return bi; + } +} diff --git a/lib/pages/begin/data/models/wallet_info.dart b/lib/pages/begin/data/models/wallet_info.dart index 95f2e47..e815621 100644 --- a/lib/pages/begin/data/models/wallet_info.dart +++ b/lib/pages/begin/data/models/wallet_info.dart @@ -5,8 +5,8 @@ enum WalletImportMethod { metamask, privateKey, local } class WalletInfo { final String address; - final double etherAmount; final WalletImportMethod importMethod; + late final double etherAmount; /// 貨幣 List tokenInfoList = []; @@ -16,8 +16,8 @@ class WalletInfo { WalletInfo({ required this.address, - required this.etherAmount, required this.importMethod, + required this.etherAmount, }); bool get isFromMetamask => importMethod == WalletImportMethod.metamask; diff --git a/lib/pages/begin/presentation/pages/nft_detail_page.dart b/lib/pages/begin/presentation/pages/nft_detail_page.dart index 387d33e..af2d047 100644 --- a/lib/pages/begin/presentation/pages/nft_detail_page.dart +++ b/lib/pages/begin/presentation/pages/nft_detail_page.dart @@ -111,7 +111,7 @@ class _NftDetailPageState extends State { _metaDataBox(), ], ), - SizedBox(height: 25), + const SizedBox(height: 25), Wrap( spacing: 5, runSpacing: 5, @@ -145,12 +145,12 @@ class _NftDetailPageState extends State { CommonButton( onPress: () {}, color: CustomTheme.secondColor, - child: Container( + child: SizedBox( width: double.infinity, child: Container( - padding: EdgeInsets.all(20), + padding: const EdgeInsets.all(20), alignment: Alignment.center, - child: Text( + child: const Text( 'send', style: CustomTheme.textWhite, ), @@ -163,7 +163,7 @@ class _NftDetailPageState extends State { color: Colors.white, child: Container( width: double.infinity, - padding: EdgeInsets.all(20), + padding: const EdgeInsets.all(20), alignment: Alignment.center, child: Row( mainAxisAlignment: MainAxisAlignment.center, @@ -186,7 +186,7 @@ class _NftDetailPageState extends State { Row( children: [ Image.asset('assets/images/crown.png', width: 30), - Text( + const Text( '賦能', style: CustomTheme.textWhite, ), @@ -214,20 +214,20 @@ class _NftDetailPageState extends State { Widget _metaDataBox() { return Expanded( child: Container( - padding: EdgeInsets.symmetric(vertical: 14, horizontal: 8), + padding: const EdgeInsets.symmetric(vertical: 14, horizontal: 8), decoration: BoxDecoration( color: CustomTheme.bgSecondColor, borderRadius: BorderRadius.circular(5), ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const Text( + children: const [ + Text( 'Name', style: CustomTheme.textPrimary, ), - const SizedBox(height: 10), - const Text( + SizedBox(height: 10), + Text( '123', style: CustomTheme.textSmallWhite, ), @@ -239,12 +239,12 @@ class _NftDetailPageState extends State { Widget _metaDataTag() { return Container( - padding: EdgeInsets.all(8), + padding: const EdgeInsets.all(8), decoration: BoxDecoration( color: CustomTheme.primaryColor, borderRadius: BorderRadius.circular(20), ), - child: Text( + child: const Text( '# body1', style: CustomTheme.textBlack, ),