Skip to content

Commit

Permalink
modify ui
Browse files Browse the repository at this point in the history
new EthConversions class
  • Loading branch information
Yii committed Apr 20, 2022
1 parent f3a9e12 commit 9470c92
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 15 deletions.
6 changes: 6 additions & 0 deletions lib/core/util/theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<Color> 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);
Expand Down
36 changes: 36 additions & 0 deletions lib/core/util/web3/eth_conversions.dart
Original file line number Diff line number Diff line change
@@ -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;
}
}
4 changes: 2 additions & 2 deletions lib/pages/begin/data/models/wallet_info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<TokenInfo> tokenInfoList = [];
Expand All @@ -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;
Expand Down
26 changes: 13 additions & 13 deletions lib/pages/begin/presentation/pages/nft_detail_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class _NftDetailPageState extends State<NftDetailPage> {
_metaDataBox(),
],
),
SizedBox(height: 25),
const SizedBox(height: 25),
Wrap(
spacing: 5,
runSpacing: 5,
Expand Down Expand Up @@ -145,12 +145,12 @@ class _NftDetailPageState extends State<NftDetailPage> {
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,
),
Expand All @@ -163,7 +163,7 @@ class _NftDetailPageState extends State<NftDetailPage> {
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,
Expand All @@ -186,7 +186,7 @@ class _NftDetailPageState extends State<NftDetailPage> {
Row(
children: [
Image.asset('assets/images/crown.png', width: 30),
Text(
const Text(
'賦能',
style: CustomTheme.textWhite,
),
Expand Down Expand Up @@ -214,20 +214,20 @@ class _NftDetailPageState extends State<NftDetailPage> {
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,
),
Expand All @@ -239,12 +239,12 @@ class _NftDetailPageState extends State<NftDetailPage> {

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,
),
Expand Down

0 comments on commit 9470c92

Please sign in to comment.