forked from polkawallet-io/polkawallet_plugin_acala
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c2f30e5
commit 46a65b7
Showing
10 changed files
with
226 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import 'package:flutter/cupertino.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:intl/intl.dart'; | ||
import 'package:polkawallet_plugin_acala/api/types/txHomaData.dart'; | ||
import 'package:polkawallet_plugin_acala/common/constants/index.dart'; | ||
import 'package:polkawallet_plugin_acala/polkawallet_plugin_acala.dart'; | ||
import 'package:polkawallet_plugin_acala/utils/i18n/index.dart'; | ||
import 'package:polkawallet_sdk/storage/keyring.dart'; | ||
import 'package:polkawallet_sdk/utils/i18n.dart'; | ||
import 'package:polkawallet_ui/components/txDetail.dart'; | ||
import 'package:polkawallet_ui/utils/format.dart'; | ||
|
||
class HomaTxDetailPage extends StatelessWidget { | ||
HomaTxDetailPage(this.plugin, this.keyring); | ||
final PluginAcala plugin; | ||
final Keyring keyring; | ||
|
||
static final String route = '/acala/homa/tx'; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final Map<String, String> dic = | ||
I18n.of(context).getDic(i18n_full_dic_acala, 'acala'); | ||
final decimals = plugin.networkState.tokenDecimals; | ||
final symbols = plugin.networkState.tokenSymbol; | ||
|
||
final TxHomaData tx = ModalRoute.of(context).settings.arguments; | ||
|
||
final symbol = relay_chain_token_symbol[plugin.basic.name]; | ||
final nativeDecimal = decimals[symbols.indexOf(symbol)]; | ||
final liquidDecimal = decimals[symbols.indexOf('L$symbol')]; | ||
|
||
String amountPay = Fmt.priceFloorBigInt(tx.amountPay, nativeDecimal); | ||
String amountReceive = | ||
Fmt.priceFloorBigInt(tx.amountReceive, liquidDecimal); | ||
if (tx.action == TxHomaData.actionRedeem) { | ||
amountPay += ' L$symbol'; | ||
amountReceive += ' $symbol'; | ||
} else { | ||
amountPay += ' $symbol'; | ||
amountReceive += ' L$symbol'; | ||
} | ||
|
||
final amountStyle = TextStyle(fontSize: 16, fontWeight: FontWeight.bold); | ||
return TxDetail( | ||
success: tx.isSuccess, | ||
action: tx.action, | ||
// blockNum: int.parse(tx.block), | ||
hash: tx.hash, | ||
blockTime: | ||
Fmt.dateTime(DateFormat("yyyy-MM-ddTHH:mm:ss").parse(tx.time, true)), | ||
networkName: plugin.basic.name, | ||
infoItems: [ | ||
TxDetailInfoItem( | ||
label: dic['dex.pay'], | ||
content: Text(amountPay, style: amountStyle), | ||
), | ||
TxDetailInfoItem( | ||
label: dic['dex.receive'], | ||
content: Text(amountReceive, style: amountStyle), | ||
) | ||
], | ||
); | ||
} | ||
} |
Oops, something went wrong.