diff --git a/lib/providers/substrate_sdk.dart b/lib/providers/substrate_sdk.dart index 9696018..1aa34a5 100644 --- a/lib/providers/substrate_sdk.dart +++ b/lib/providers/substrate_sdk.dart @@ -367,6 +367,19 @@ class SubstrateSdk with ChangeNotifier { notifyListeners(); } + Future txFees( + String fromAddress, String destAddress, double amount) async { + if (amount == 0) return 0; + final sender = await _setSender(fromAddress); + final txInfo = TxInfoData('balances', 'transferKeepAlive', sender); + final amountUnit = (amount * 100).toInt(); + + final estimateFees = + await sdk.api.tx.estimateFees(txInfo, [destAddress, amountUnit]); + + return estimateFees.partialFee / 100; + } + ///////////////////////////////////// ////// 3: SUBSTRATE CONNECTION ////// ///////////////////////////////////// @@ -714,7 +727,7 @@ class SubstrateSdk with ChangeNotifier { txOptions = [destAddress, false]; tx2 = 'api.tx.balances.transferAll("$destAddress", false)'; } else { - int amountUnit; + late int amountUnit; if (isUdUnit) { palette = 'universalDividend'; call = 'transferUd'; diff --git a/lib/screens/myWallets/migrate_identity.dart b/lib/screens/myWallets/migrate_identity.dart index 5c622d4..b11aac4 100644 --- a/lib/screens/myWallets/migrate_identity.dart +++ b/lib/screens/myWallets/migrate_identity.dart @@ -82,16 +82,18 @@ class MigrateIdentityScreen extends StatelessWidget { if (status.data == null) { return Column(children: [ const SizedBox(height: 80), - Row(mainAxisAlignment: MainAxisAlignment.center, children: const [ - SizedBox( - height: 35, - width: 35, - child: CircularProgressIndicator( - color: orangeC, - strokeWidth: 4, - ), - ), - ]), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: const [ + SizedBox( + height: 35, + width: 35, + child: CircularProgressIndicator( + color: orangeC, + strokeWidth: 4, + ), + ), + ]), ]); } diff --git a/lib/screens/myWallets/wallets_home.dart b/lib/screens/myWallets/wallets_home.dart index 236b104..929829b 100644 --- a/lib/screens/myWallets/wallets_home.dart +++ b/lib/screens/myWallets/wallets_home.dart @@ -221,6 +221,10 @@ class WalletsHome extends StatelessWidget { } else if (screenWidth >= 650) { nTule = 3; } + // Offset followDragAnchorStrategy( + // Draggable d, BuildContext context, Offset point) { + // return Offset(d.feedbackOffset.dx - 30, d.feedbackOffset.dy - 0); + // } return CustomScrollView(slivers: [ const SliverToBoxAdapter(child: SizedBox(height: 20)), @@ -235,10 +239,11 @@ class WalletsHome extends StatelessWidget { LongPressDraggable( delay: const Duration(milliseconds: 200), data: repository.address!, - // dragAnchorStrategy: - // (Draggable _, BuildContext __, Offset ___) => - // const Offset(40, 40), - dragAnchorStrategy: pointerDragAnchorStrategy, + dragAnchorStrategy: + (Draggable _, BuildContext __, Offset ___) => + const Offset(0, 0), + // feedbackOffset: const Offset(-500, -500), + // dragAnchorStrategy: childDragAnchorStrategy, onDragStarted: () => myWalletProvider.dragAddress = repository.address!, onDragEnd: (_) { diff --git a/lib/screens/qrcode_fullscreen.dart b/lib/screens/qrcode_fullscreen.dart index bdb508d..1406f24 100644 --- a/lib/screens/qrcode_fullscreen.dart +++ b/lib/screens/qrcode_fullscreen.dart @@ -24,7 +24,7 @@ class QrCodeFullscreen extends StatelessWidget { backgroundColor: color ?? Colors.black, toolbarHeight: 60 * ratio, leading: IconButton( - icon:const Icon(Icons.arrow_back, color: orangeC), + icon: const Icon(Icons.arrow_back, color: orangeC), onPressed: () { Navigator.pop(context); }), diff --git a/lib/screens/wallet_view.dart b/lib/screens/wallet_view.dart index 93132f0..de77061 100644 --- a/lib/screens/wallet_view.dart +++ b/lib/screens/wallet_view.dart @@ -452,6 +452,8 @@ void paymentPopup(BuildContext context, String toAddress) { isScrollControlled: true, context: context, builder: (BuildContext context) { + final sub = Provider.of(homeContext, listen: false); + double fees = 0; return StatefulBuilder( builder: (BuildContext context, StateSetter setState) { if (walletViewProvider.payAmount.text != '' && @@ -588,12 +590,26 @@ void paymentPopup(BuildContext context, String toAddress) { ], ), const SizedBox(height: 12), - Text( - 'amount'.tr(), - style: TextStyle( - fontSize: 19, - fontWeight: FontWeight.w500, - color: Colors.grey[600]), + Row( + children: [ + Text( + 'amount'.tr(), + style: TextStyle( + fontSize: 19, + fontWeight: FontWeight.w500, + color: Colors.grey[600]), + ), + const Spacer(), + Text( + 'frais: $fees $currencyName', + style: const TextStyle( + color: orangeC, + fontSize: 17, + fontWeight: FontWeight.w500, + ), + ), + const SizedBox(width: 10), + ], ), const SizedBox(height: 10), TextField( @@ -606,7 +622,17 @@ void paymentPopup(BuildContext context, String toAddress) { maxLines: 1, textAlign: TextAlign.center, keyboardType: TextInputType.number, - onChanged: (_) => setState(() {}), + onChanged: (_) async { + fees = await sub.txFees( + defaultWallet.address!, + toAddress, + double.parse( + walletViewProvider.payAmount.text == '' + ? '0' + : walletViewProvider.payAmount.text)); + log.d(fees); + setState(() {}); + }, inputFormatters: [ FilteringTextInputFormatter.deny(',', replacementString: '.'), diff --git a/pubspec.yaml b/pubspec.yaml index b77e500..b096b25 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -5,7 +5,7 @@ description: Pay with G1. # pub.dev using `pub publish`. This is preferred for private packages. publish_to: 'none' # Remove this line if you wish to publish to pub.dev -version: 0.0.11+31 +version: 0.0.11+32 environment: sdk: '>=2.12.0 <3.0.0'