From 8b32bb8e26c2a28da283ef2ed7002559ea0deafc Mon Sep 17 00:00:00 2001 From: poka Date: Mon, 12 Sep 2022 04:52:34 +0200 Subject: [PATCH 1/4] payment inter wallets is working; bug with feedback position --- lib/providers/duniter_indexer.dart | 2 +- lib/providers/wallets_profiles.dart | 2 +- lib/screens/activity.dart | 2 +- lib/screens/myWallets/choose_wallet.dart | 2 - lib/screens/myWallets/wallets_home.dart | 176 +++++--- lib/screens/my_contacts.dart | 2 +- lib/screens/search_result.dart | 2 +- lib/screens/wallet_view.dart | 537 +++++++++++------------ pubspec.lock | 12 +- 9 files changed, 385 insertions(+), 352 deletions(-) diff --git a/lib/providers/duniter_indexer.dart b/lib/providers/duniter_indexer.dart index 0def0b8..74bf308 100644 --- a/lib/providers/duniter_indexer.dart +++ b/lib/providers/duniter_indexer.dart @@ -339,7 +339,7 @@ class DuniterIndexer with ChangeNotifier { MaterialPageRoute(builder: (context) { walletsProfiles.address = profile['id']; return WalletViewScreen( - pubkey: profile['id'], + address: profile['id'], username: g1WalletsBox .get(profile['id']) ?.id diff --git a/lib/providers/wallets_profiles.dart b/lib/providers/wallets_profiles.dart index 3dba88a..f5b9561 100644 --- a/lib/providers/wallets_profiles.dart +++ b/lib/providers/wallets_profiles.dart @@ -44,7 +44,7 @@ class WalletsProfilesProvider with ChangeNotifier { Navigator.push( context, MaterialPageRoute(builder: (context) { - return WalletViewScreen(pubkey: barcode!.rawContent); + return WalletViewScreen(address: barcode!.rawContent); }), ); } else { diff --git a/lib/screens/activity.dart b/lib/screens/activity.dart index fa05a59..2bf3907 100644 --- a/lib/screens/activity.dart +++ b/lib/screens/activity.dart @@ -354,7 +354,7 @@ class ActivityScreen extends StatelessWidget with ChangeNotifier { Navigator.push( context, MaterialPageRoute(builder: (context) { - return WalletViewScreen(pubkey: repository[1]); + return WalletViewScreen(address: repository[1]); }), ); // Navigator.pop(context); diff --git a/lib/screens/myWallets/choose_wallet.dart b/lib/screens/myWallets/choose_wallet.dart index 0e26d01..54793cf 100644 --- a/lib/screens/myWallets/choose_wallet.dart +++ b/lib/screens/myWallets/choose_wallet.dart @@ -53,8 +53,6 @@ class ChooseWalletScreen extends StatelessWidget { ), onPressed: () async { await sub.setCurrentWallet(selectedWallet!); - - // _walletViewProvider.reload(); sub.reload(); // Navigator.pop(context); diff --git a/lib/screens/myWallets/wallets_home.dart b/lib/screens/myWallets/wallets_home.dart index c799a65..b314d5b 100644 --- a/lib/screens/myWallets/wallets_home.dart +++ b/lib/screens/myWallets/wallets_home.dart @@ -18,6 +18,7 @@ import 'package:gecko/screens/myWallets/choose_chest.dart'; import 'package:gecko/screens/myWallets/import_g1_v1.dart'; import 'package:gecko/screens/myWallets/unlocking_wallet.dart'; import 'package:gecko/screens/myWallets/wallet_options.dart'; +import 'package:gecko/screens/wallet_view.dart'; import 'package:provider/provider.dart'; class WalletsHome extends StatelessWidget { @@ -159,6 +160,7 @@ class WalletsHome extends StatelessWidget { WalletOptionsProvider walletOptions = Provider.of(context, listen: false); final bool isWalletsExists = myWalletProvider.checkIfWalletExist(); + SubstrateSdk sub = Provider.of(context, listen: false); if (!isWalletsExists) { return const Text(''); @@ -196,78 +198,114 @@ class WalletsHome extends StatelessWidget { mainAxisSpacing: 0, children: [ for (WalletData repository in listWallets as Iterable) - Padding( - padding: const EdgeInsets.all(16), - child: GestureDetector( - key: keyOpenWallet(repository.address!), - onTap: () { - walletOptions.getAddress( - currentChestNumber, repository.derivation!); - Navigator.push( - context, - SmoothTransition( - page: WalletOptions( - wallet: repository, + LongPressDraggable( + data: repository.address!, + dragAnchorStrategy: + (Draggable _, BuildContext __, Offset ___) => + const Offset(0, 0), + feedback: ElevatedButton( + onPressed: () {}, + style: ElevatedButton.styleFrom( + backgroundColor: orangeC, + shape: const CircleBorder(), + padding: const EdgeInsets.all(15), + ), + child: const SizedBox( + height: 35, + child: Image(image: AssetImage('assets/vector_white.png')), + ), + ), + child: DragTarget(onAccept: (senderAddress) async { + log.d( + 'INTERPAY: sender: $senderAddress --- receiver: ${repository.address!}'); + final walletData = + myWalletProvider.getWalletDataByAddress(senderAddress); + await sub.setCurrentWallet(walletData!); + sub.reload(); + paymentPopup(context, repository.address!); + }, builder: ( + BuildContext context, + List accepted, + List rejected, + ) { + return Padding( + padding: const EdgeInsets.all(16), + child: GestureDetector( + key: keyOpenWallet(repository.address!), + onTap: () { + walletOptions.getAddress( + currentChestNumber, repository.derivation!); + Navigator.push( + context, + SmoothTransition( + page: WalletOptions( + wallet: repository, + ), + ), + ); + }, + child: ClipOvalShadow( + shadow: const Shadow( + color: Colors.transparent, + offset: Offset(0, 0), + blurRadius: 5, ), - ), - ); - }, - child: ClipOvalShadow( - shadow: const Shadow( - color: Colors.transparent, - offset: Offset(0, 0), - blurRadius: 5, - ), - clipper: CustomClipperOval(), - child: ClipRRect( - borderRadius: - const BorderRadius.all(Radius.circular(12)), - child: Column(children: [ - Expanded( - child: Container( - width: double.infinity, - height: double.infinity, - decoration: BoxDecoration( - gradient: RadialGradient( - radius: 0.6, - colors: [ - Colors.green[400]!, - const Color(0xFFE7E7A6), - ], - )), - child: - // SvgPicture.asset('assets/chopp-gecko2.png', - // semanticsLabel: 'Gecko', height: 48), - repository.imageCustomPath == null || - repository.imageCustomPath == '' - ? Image.asset( - 'assets/avatars/${repository.imageDefaultPath}', - alignment: Alignment.bottomCenter, - scale: 0.5, - ) - : Container( - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.transparent, - image: DecorationImage( - fit: BoxFit.fitHeight, - image: FileImage( - File(repository.imageCustomPath!), + clipper: CustomClipperOval(), + child: ClipRRect( + borderRadius: + const BorderRadius.all(Radius.circular(12)), + child: Column(children: [ + Expanded( + child: Container( + width: double.infinity, + height: double.infinity, + decoration: BoxDecoration( + gradient: RadialGradient( + radius: 0.6, + colors: [ + Colors.green[400]!, + const Color(0xFFE7E7A6), + ], + )), + child: + // SvgPicture.asset('assets/chopp-gecko2.png', + // semanticsLabel: 'Gecko', height: 48), + repository.imageCustomPath == null || + repository.imageCustomPath == '' + ? Image.asset( + 'assets/avatars/${repository.imageDefaultPath}', + alignment: Alignment.bottomCenter, + scale: 0.5, + ) + : Container( + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.transparent, + image: DecorationImage( + fit: BoxFit.fitHeight, + image: FileImage( + File(repository + .imageCustomPath!), + ), + ), ), ), - ), - ), - )), - Stack(children: [ - balanceBuilder(context, repository.address!, - repository.address == defaultWallet.address), - nameBuilder(context, repository, defaultWallet, - currentChestNumber), - ]), - ]), - ), - ), - )), + )), + Stack(children: [ + balanceBuilder( + context, + repository.address!, + repository.address == + defaultWallet.address), + nameBuilder(context, repository, defaultWallet, + currentChestNumber), + ]), + ]), + ), + ), + )); + }), + ), Consumer(builder: (context, sub, _) { return sub.nodeConnected ? addNewDerivation(context) diff --git a/lib/screens/my_contacts.dart b/lib/screens/my_contacts.dart index 2f78986..fb5af15 100644 --- a/lib/screens/my_contacts.dart +++ b/lib/screens/my_contacts.dart @@ -116,7 +116,7 @@ class ContactsScreen extends StatelessWidget { walletsProfilesClass.address = g1Wallet.pubkey; return WalletViewScreen( - pubkey: g1Wallet.pubkey, + address: g1Wallet.pubkey, username: g1WalletsBox .get(g1Wallet.pubkey) ?.id diff --git a/lib/screens/search_result.dart b/lib/screens/search_result.dart index d4416d9..1cb57bd 100644 --- a/lib/screens/search_result.dart +++ b/lib/screens/search_result.dart @@ -143,7 +143,7 @@ class SearchResultScreen extends StatelessWidget { walletsProfilesClass.address = g1Wallet.pubkey; return WalletViewScreen( - pubkey: g1Wallet.pubkey, + address: g1Wallet.pubkey, username: g1WalletsBox .get(g1Wallet.pubkey) ?.id diff --git a/lib/screens/wallet_view.dart b/lib/screens/wallet_view.dart index 67a3abb..f043be7 100644 --- a/lib/screens/wallet_view.dart +++ b/lib/screens/wallet_view.dart @@ -24,9 +24,9 @@ import 'package:qr_flutter/qr_flutter.dart'; class WalletViewScreen extends StatelessWidget { const WalletViewScreen( - {required this.pubkey, this.username, this.avatar, Key? key}) + {required this.address, this.username, this.avatar, Key? key}) : super(key: key); - final String? pubkey; + final String? address; final String? username; final Image? avatar; final double buttonSize = 100; @@ -39,7 +39,7 @@ class WalletViewScreen extends StatelessWidget { Provider.of(context, listen: false); CesiumPlusProvider cesiumPlusProvider = Provider.of(context, listen: false); - walletProfile.address = pubkey!; + walletProfile.address = address!; SubstrateSdk sub = Provider.of(context, listen: false); HomeProvider homeProvider = Provider.of(context, listen: false); @@ -67,14 +67,14 @@ class WalletViewScreen extends StatelessWidget { onPressed: () async { G1WalletsList? newContact; g1WalletsBox.toMap().forEach((key, value) { - if (key == pubkey) newContact = value; + if (key == address) newContact = value; }); // G1WalletsList(pubkey: pubkey!, username: username); await walletProfile.addContact( - newContact ?? G1WalletsList(pubkey: pubkey!)); + newContact ?? G1WalletsList(pubkey: address!)); }, icon: Icon( - walletProfile.isContact(pubkey!) + walletProfile.isContact(address!) ? Icons.add_reaction_rounded : Icons.add_reaction_outlined, size: 35, @@ -110,7 +110,7 @@ class WalletViewScreen extends StatelessWidget { bottomNavigationBar: homeProvider.bottomAppBar(context), body: SafeArea( child: Column(children: [ - walletProfile.headerProfileView(context, pubkey!, username), + walletProfile.headerProfileView(context, address!, username), SizedBox(height: isTall ? 10 : 0), Row(mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Column(children: [ @@ -134,7 +134,7 @@ class WalletViewScreen extends StatelessWidget { context, MaterialPageRoute(builder: (context) { return ActivityScreen( - address: pubkey, + address: address, avatar: cesiumPlusProvider.defaultAvatar(50)); }), @@ -155,7 +155,7 @@ class WalletViewScreen extends StatelessWidget { WalletData? defaultWallet = myWalletProvider.getDefaultWallet(); return FutureBuilder( future: sub.certState(defaultWallet.address!, - pubkey!), // .canCertify(_defaultWallet.address!, pubkey!), + address!), // .canCertify(_defaultWallet.address!, pubkey!), builder: (context, AsyncSnapshot> snapshot) { if (snapshot.data == null) return const SizedBox(); String duration = ''; @@ -223,7 +223,7 @@ class WalletViewScreen extends StatelessWidget { context, "areYouSureYouWantToCertify".tr( args: [ - getShortPubkey(pubkey!) + getShortPubkey(address!) ])); if (result ?? false) { @@ -303,7 +303,7 @@ class WalletViewScreen extends StatelessWidget { image: AssetImage('assets/copy_key.png'), height: 90)), onTap: () { - Clipboard.setData(ClipboardData(text: pubkey)); + Clipboard.setData(ClipboardData(text: address)); snackCopyKey(context); }), ), @@ -340,14 +340,14 @@ class WalletViewScreen extends StatelessWidget { splashColor: yellowC, onTap: sub.nodeConnected ? () { - paymentPopup(context, walletProfile); + paymentPopup(context, address!); } : null, // inkwell color child: const Padding( - padding: EdgeInsets.all(14), - child: Image( - image: AssetImage('assets/vector_white.png'), - ))), + padding: EdgeInsets.all(14), + child: Image( + image: AssetImage('assets/vector_white.png')), + )), ), ), ), @@ -397,270 +397,267 @@ class WalletViewScreen extends StatelessWidget { ), ]); } +} - void paymentPopup( - BuildContext context, WalletsProfilesProvider walletViewProvider) { - // WalletsProfilesProvider _walletViewProvider = - // Provider.of(context, listen: false); +void paymentPopup(BuildContext context, String toAddress) { + // WalletsProfilesProvider _walletViewProvider = + // Provider.of(context, listen: false); + final walletViewProvider = + Provider.of(context, listen: false); - final myWalletProvider = - Provider.of(context, listen: false); - final sub = Provider.of(context, listen: false); + final myWalletProvider = + Provider.of(context, listen: false); + final sub = Provider.of(context, listen: false); - const double shapeSize = 20; - WalletData? defaultWallet = myWalletProvider.getDefaultWallet(); - log.d(defaultWallet.address); + const double shapeSize = 20; + WalletData? defaultWallet = myWalletProvider.getDefaultWallet(); + log.d(defaultWallet.address); - bool canValidate = false; + bool canValidate = false; - final bool isUdUnit = configBox.get('isUdUnit') ?? false; - final udValue = sub.udValue; - final double balanceRatio = isUdUnit ? round(udValue / 100, 6) : 1; + final bool isUdUnit = configBox.get('isUdUnit') ?? false; + final udValue = sub.udValue; + final double balanceRatio = isUdUnit ? round(udValue / 100, 6) : 1; - showModalBottomSheet( - shape: const RoundedRectangleBorder( - borderRadius: BorderRadius.only( - topRight: Radius.circular(shapeSize), - topLeft: Radius.circular(shapeSize), - ), + showModalBottomSheet( + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.only( + topRight: Radius.circular(shapeSize), + topLeft: Radius.circular(shapeSize), ), - isScrollControlled: true, - context: context, - builder: (BuildContext context) { - return StatefulBuilder( - builder: (BuildContext context, StateSetter setState) { - if (walletViewProvider.payAmount.text != '' && - (double.parse(walletViewProvider.payAmount.text) + - 2 / balanceRatio) <= - (balanceCache[defaultWallet.address] ?? 0) && - walletViewProvider.address != defaultWallet.address) { - if ((balanceCache[pubkey] == 0 || balanceCache[pubkey] == null) && - double.parse(walletViewProvider.payAmount.text) < - 5 / balanceRatio) { - canValidate = false; - } else { - canValidate = true; - } - } else { + ), + isScrollControlled: true, + context: context, + builder: (BuildContext context) { + return StatefulBuilder( + builder: (BuildContext context, StateSetter setState) { + if (walletViewProvider.payAmount.text != '' && + (double.parse(walletViewProvider.payAmount.text) + + 2 / balanceRatio) <= + (balanceCache[defaultWallet.address] ?? 0) && + toAddress != defaultWallet.address) { + if ((balanceCache[toAddress] == 0 || + balanceCache[toAddress] == null) && + double.parse(walletViewProvider.payAmount.text) < + 5 / balanceRatio) { canValidate = false; + } else { + canValidate = true; } - final bool isUdUnit = configBox.get('isUdUnit') ?? false; - return Padding( - padding: EdgeInsets.only( - bottom: MediaQuery.of(context).viewInsets.bottom), - child: Container( - height: 400, - decoration: const ShapeDecoration( - color: Color(0xffffeed1), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.only( - topRight: Radius.circular(shapeSize), - topLeft: Radius.circular(shapeSize), - ), + } else { + canValidate = false; + } + final bool isUdUnit = configBox.get('isUdUnit') ?? false; + return Padding( + padding: EdgeInsets.only( + bottom: MediaQuery.of(context).viewInsets.bottom), + child: Container( + height: 400, + decoration: const ShapeDecoration( + color: Color(0xffffeed1), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.only( + topRight: Radius.circular(shapeSize), + topLeft: Radius.circular(shapeSize), ), ), - child: Padding( - padding: const EdgeInsets.only( - top: 24, bottom: 0, left: 24, right: 24), - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - 'executeATransfer'.tr(), - style: const TextStyle( - fontSize: 26, fontWeight: FontWeight.w700), - ), - IconButton( - iconSize: 40, - icon: const Icon(Icons.cancel_outlined), - onPressed: () { - Navigator.pop(context); - }, - ), - ]), - const SizedBox(height: 20), - Text( - 'from'.tr(), - style: TextStyle( - fontSize: 19, - fontWeight: FontWeight.w500, - color: Colors.grey[600]), - ), - const SizedBox(height: 10), - Consumer(builder: (context, sub, _) { - return InkWell( - key: keyChangeChest, - onTap: () async { - String? pin; - if (myWalletProvider.pinCode == '') { - pin = await Navigator.push( - context, - MaterialPageRoute( - builder: (homeContext) { - return UnlockingWallet( - wallet: defaultWallet); - }, - ), - ); - } - if (pin != null || - myWalletProvider.pinCode != '') { - Navigator.push( - context, - MaterialPageRoute(builder: (context) { - return ChooseWalletScreen( - pin: pin ?? myWalletProvider.pinCode); - }), - ); - } - }, - child: Container( - width: double.infinity, - decoration: BoxDecoration( - border: Border.all( - color: Colors.blueAccent.shade200, - width: 2), - borderRadius: const BorderRadius.all( - Radius.circular(10.0)), - ), - padding: const EdgeInsets.all(10), - child: Row(children: [ - Text(defaultWallet.name!), - const Spacer(), - balance(context, defaultWallet.address!, 20) - ]), - ), - ); - }), - const Spacer(), - - // const SizedBox(height: 10), - Text( - 'amount'.tr(), - style: TextStyle( - fontSize: 19, - fontWeight: FontWeight.w500, - color: Colors.grey[600]), - ), - const SizedBox(height: 10), - TextField( - key: keyAmountField, - controller: walletViewProvider.payAmount, - autofocus: true, - maxLines: 1, - textAlign: TextAlign.center, - keyboardType: TextInputType.number, - onChanged: (_) => setState(() { - // _walletViewProvider.reload(); - }), - inputFormatters: [ - // FilteringTextInputFormatter.digitsOnly, - FilteringTextInputFormatter.deny(',', - replacementString: '.'), - FilteringTextInputFormatter.allow( - RegExp(r'(^\d+\.?\d{0,2})')), - ], - // onChanged: (v) => _searchProvider.reload(), - decoration: InputDecoration( - hintText: '0.00', - suffix: Text(isUdUnit - ? 'ud'.tr(args: ['']) - : currencyName), // udUnitDisplay(40), - filled: true, - fillColor: Colors.transparent, - // border: OutlineInputBorder( - // borderSide: - // BorderSide(color: Colors.grey[500], width: 2), - // borderRadius: BorderRadius.circular(8)), - - focusedBorder: OutlineInputBorder( - borderSide: BorderSide( - color: Colors.grey[500]!, width: 2), - borderRadius: BorderRadius.circular(8), - ), - contentPadding: const EdgeInsets.all(20), - ), - style: const TextStyle( - fontSize: 40, - color: Colors.black, - fontWeight: FontWeight.w600, - ), - ), - // const SizedBox(height: 40), - const Spacer(), - SizedBox( - width: double.infinity, - height: 60, - child: ElevatedButton( - key: keyConfirmPayment, - style: ElevatedButton.styleFrom( - foregroundColor: Colors.white, elevation: 4, - backgroundColor: orangeC, // foreground - ), - onPressed: canValidate - ? () async { - String? pin; - if (myWalletProvider.pinCode == '') { - pin = await Navigator.push( - context, - MaterialPageRoute( - builder: (homeContext) { - return UnlockingWallet( - wallet: defaultWallet); - }, - ), - ); - } - log.d(pin); - if (pin != null || - myWalletProvider.pinCode != '') { - // Payment workflow ! - WalletsProfilesProvider - walletViewProvider = - Provider.of( - context, - listen: false); - SubstrateSdk sub = - Provider.of(context, - listen: false); - final acc = sub.getCurrentWallet(); - log.d( - "fromAddress: ${acc.address!},destAddress: ${walletViewProvider.address!}, amount: ${double.parse(walletViewProvider.payAmount.text)}, password: $pin"); - sub.pay( - fromAddress: acc.address!, - destAddress: - walletViewProvider.address!, - amount: double.parse( - walletViewProvider - .payAmount.text), - password: - pin ?? myWalletProvider.pinCode); - Navigator.push( - context, - MaterialPageRoute(builder: (context) { - return const TransactionInProgress(); - }), - ); - } - } - : null, - child: Text( - 'executeTheTransfer'.tr(), - style: const TextStyle( - fontSize: 20, fontWeight: FontWeight.w600), - ), - ), - ), - const Spacer(), - ]), - ), ), - ); - }); - }).then((value) => walletViewProvider.payAmount.text = ''); - } + child: Padding( + padding: const EdgeInsets.only( + top: 24, bottom: 0, left: 24, right: 24), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'executeATransfer'.tr(), + style: const TextStyle( + fontSize: 26, fontWeight: FontWeight.w700), + ), + IconButton( + iconSize: 40, + icon: const Icon(Icons.cancel_outlined), + onPressed: () { + Navigator.pop(context); + }, + ), + ]), + const SizedBox(height: 20), + Text( + 'from'.tr(), + style: TextStyle( + fontSize: 19, + fontWeight: FontWeight.w500, + color: Colors.grey[600]), + ), + const SizedBox(height: 10), + Consumer(builder: (context, sub, _) { + return InkWell( + key: keyChangeChest, + onTap: () async { + String? pin; + if (myWalletProvider.pinCode == '') { + pin = await Navigator.push( + context, + MaterialPageRoute( + builder: (homeContext) { + return UnlockingWallet( + wallet: defaultWallet); + }, + ), + ); + } + if (pin != null || myWalletProvider.pinCode != '') { + Navigator.push( + context, + MaterialPageRoute(builder: (context) { + return ChooseWalletScreen( + pin: pin ?? myWalletProvider.pinCode); + }), + ); + } + }, + child: Container( + width: double.infinity, + decoration: BoxDecoration( + border: Border.all( + color: Colors.blueAccent.shade200, width: 2), + borderRadius: + const BorderRadius.all(Radius.circular(10.0)), + ), + padding: const EdgeInsets.all(10), + child: Row(children: [ + Text(defaultWallet.name!), + const Spacer(), + balance(context, defaultWallet.address!, 20) + ]), + ), + ); + }), + const Spacer(), + + // const SizedBox(height: 10), + Text( + 'amount'.tr(), + style: TextStyle( + fontSize: 19, + fontWeight: FontWeight.w500, + color: Colors.grey[600]), + ), + const SizedBox(height: 10), + TextField( + key: keyAmountField, + controller: walletViewProvider.payAmount, + autofocus: true, + maxLines: 1, + textAlign: TextAlign.center, + keyboardType: TextInputType.number, + onChanged: (_) => setState(() { + // _walletViewProvider.reload(); + }), + inputFormatters: [ + // FilteringTextInputFormatter.digitsOnly, + FilteringTextInputFormatter.deny(',', + replacementString: '.'), + FilteringTextInputFormatter.allow( + RegExp(r'(^\d+\.?\d{0,2})')), + ], + // onChanged: (v) => _searchProvider.reload(), + decoration: InputDecoration( + hintText: '0.00', + suffix: Text(isUdUnit + ? 'ud'.tr(args: ['']) + : currencyName), // udUnitDisplay(40), + filled: true, + fillColor: Colors.transparent, + // border: OutlineInputBorder( + // borderSide: + // BorderSide(color: Colors.grey[500], width: 2), + // borderRadius: BorderRadius.circular(8)), + + focusedBorder: OutlineInputBorder( + borderSide: + BorderSide(color: Colors.grey[500]!, width: 2), + borderRadius: BorderRadius.circular(8), + ), + contentPadding: const EdgeInsets.all(20), + ), + style: const TextStyle( + fontSize: 40, + color: Colors.black, + fontWeight: FontWeight.w600, + ), + ), + // const SizedBox(height: 40), + const Spacer(), + SizedBox( + width: double.infinity, + height: 60, + child: ElevatedButton( + key: keyConfirmPayment, + style: ElevatedButton.styleFrom( + foregroundColor: Colors.white, elevation: 4, + backgroundColor: orangeC, // foreground + ), + onPressed: canValidate + ? () async { + String? pin; + if (myWalletProvider.pinCode == '') { + pin = await Navigator.push( + context, + MaterialPageRoute( + builder: (homeContext) { + return UnlockingWallet( + wallet: defaultWallet); + }, + ), + ); + } + log.d(pin); + if (pin != null || + myWalletProvider.pinCode != '') { + // Payment workflow ! + WalletsProfilesProvider walletViewProvider = + Provider.of( + context, + listen: false); + SubstrateSdk sub = + Provider.of(context, + listen: false); + final acc = sub.getCurrentWallet(); + log.d( + "fromAddress: ${acc.address!},destAddress: $toAddress, amount: ${double.parse(walletViewProvider.payAmount.text)}, password: $pin"); + sub.pay( + fromAddress: acc.address!, + destAddress: toAddress, + amount: double.parse( + walletViewProvider.payAmount.text), + password: + pin ?? myWalletProvider.pinCode); + Navigator.push( + context, + MaterialPageRoute(builder: (context) { + return const TransactionInProgress(); + }), + ); + } + } + : null, + child: Text( + 'executeTheTransfer'.tr(), + style: const TextStyle( + fontSize: 20, fontWeight: FontWeight.w600), + ), + ), + ), + const Spacer(), + ]), + ), + ), + ); + }); + }).then((value) => walletViewProvider.payAmount.text = ''); } diff --git a/pubspec.lock b/pubspec.lock index 2ace6ec..61557e3 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -611,7 +611,7 @@ packages: name: image_picker_android url: "https://pub.dartlang.org" source: hosted - version: "0.8.5+2" + version: "0.8.5+3" image_picker_for_web: dependency: transitive description: @@ -826,7 +826,7 @@ packages: name: package_info_plus_windows url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0" path: dependency: transitive description: @@ -980,7 +980,7 @@ packages: name: pointycastle url: "https://pub.dartlang.org" source: hosted - version: "3.6.1" + version: "3.6.2" polkawallet_sdk: dependency: "direct main" description: @@ -1003,7 +1003,7 @@ packages: name: printing url: "https://pub.dartlang.org" source: hosted - version: "5.9.2" + version: "5.9.3" process: dependency: transitive description: @@ -1096,7 +1096,7 @@ packages: name: shared_preferences_android url: "https://pub.dartlang.org" source: hosted - version: "2.0.12" + version: "2.0.13" shared_preferences_ios: dependency: transitive description: @@ -1325,7 +1325,7 @@ packages: name: win32 url: "https://pub.dartlang.org" source: hosted - version: "2.7.0" + version: "3.0.0" xdg_directories: dependency: transitive description: From d76ad9b7e373d3db5607fe9b10568100aeac68e7 Mon Sep 17 00:00:00 2001 From: poka Date: Mon, 12 Sep 2022 07:26:13 +0200 Subject: [PATCH 2/4] improve dargndrop UX --- assets/translations/en.json | 4 +- assets/translations/es.json | 4 +- assets/translations/fr.json | 4 +- lib/providers/my_wallets.dart | 2 + lib/screens/myWallets/wallets_home.dart | 231 +++++++++++++++--------- pubspec.yaml | 2 +- 6 files changed, 157 insertions(+), 90 deletions(-) diff --git a/assets/translations/en.json b/assets/translations/en.json index 84e6836..6b60dcd 100644 --- a/assets/translations/en.json +++ b/assets/translations/en.json @@ -158,6 +158,7 @@ "months": "{} months", "certify": "Certify", "from": "From:", + "to": "To:", "amount": "Amount:", "choiceOfSourceWallet": "Choose a source wallet", "extrinsicInProgress": "{} in progress", @@ -193,5 +194,6 @@ "revokeMyIdentity": "Revoke my identity", "youCannotRevokeThisIdentity": "You cannot revoke this identity while\nit is member of the blacksmiths web", "showUdAmounts": "Show amounts in UD", - "ud": "{}UD" + "ud": "{}UD", + "chooseATargetWallet": "Choose a target wallet" } \ No newline at end of file diff --git a/assets/translations/es.json b/assets/translations/es.json index 16e8025..81688ce 100644 --- a/assets/translations/es.json +++ b/assets/translations/es.json @@ -158,6 +158,7 @@ "months": "{} months", "certify": "Certify", "from": "From:", + "to": "To:", "amount": "Amount:", "choiceOfSourceWallet": "Choose a source wallet", "extrinsicInProgress": "{} in progress", @@ -193,5 +194,6 @@ "revokeMyIdentity": "Revoke my identity", "youCannotRevokeThisIdentity": "You cannot revoke this identity while\nit is member of the blacksmiths web", "showUdAmounts": "Show amounts in UD", - "ud": "{}UD" + "ud": "{}UD", + "chooseATargetWallet": "Choose a target wallet" } \ No newline at end of file diff --git a/assets/translations/fr.json b/assets/translations/fr.json index 99164e8..9e3021b 100644 --- a/assets/translations/fr.json +++ b/assets/translations/fr.json @@ -159,6 +159,7 @@ "months": "{} mois", "certify": "Certifier", "from": "Depuis:", + "to": "Vers:", "amount": "Montant:", "choiceOfSourceWallet": "Choix du portefeuille source", "extrinsicInProgress": "{} en cours", @@ -194,5 +195,6 @@ "revokeMyIdentity": "Révoquer mon identité", "youCannotRevokeThisIdentity": "Vous ne pouvez pas révoquer cette identité tant\nqu'elle fait partie de la toile forgerons", "showUdAmounts": "Afficher les montants en DU", - "ud": "{}DU" + "ud": "{}DU", + "chooseATargetWallet": "Choisissez un portefeuille cible" } \ No newline at end of file diff --git a/lib/providers/my_wallets.dart b/lib/providers/my_wallets.dart index b38c122..dc41080 100644 --- a/lib/providers/my_wallets.dart +++ b/lib/providers/my_wallets.dart @@ -13,6 +13,8 @@ class MyWalletsProvider with ChangeNotifier { late String mnemonic; int? pinLenght; bool isNewDerivationLoading = false; + String lastFlyBy = ''; + String dragAddress = ''; int getCurrentChest() { if (configBox.get('currentChest') == null) { diff --git a/lib/screens/myWallets/wallets_home.dart b/lib/screens/myWallets/wallets_home.dart index b314d5b..ed73fb4 100644 --- a/lib/screens/myWallets/wallets_home.dart +++ b/lib/screens/myWallets/wallets_home.dart @@ -1,7 +1,10 @@ +// ignore_for_file: use_build_context_synchronously + import 'dart:io'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/services.dart'; +import 'package:flutter_markdown/flutter_markdown.dart'; import 'package:gecko/globals.dart'; import 'package:gecko/models/chest_data.dart'; import 'package:gecko/models/widgets_keys.dart'; @@ -64,7 +67,9 @@ class WalletsHome extends StatelessWidget { style: TextStyle(color: Colors.grey[850])), backgroundColor: const Color(0xffFFD58D), ), - bottomNavigationBar: homeProvider.bottomAppBar(context), + bottomNavigationBar: myWalletProvider.lastFlyBy == '' + ? homeProvider.bottomAppBar(context) + : dragInfo(context), body: SafeArea( child: Stack(children: [ myWalletsTiles(context, currentChestNumber), @@ -75,6 +80,37 @@ class WalletsHome extends StatelessWidget { ); } + Widget dragInfo(BuildContext context) { + final myWalletProvider = + Provider.of(context, listen: false); + + final walletDataFrom = + myWalletProvider.getWalletDataByAddress(myWalletProvider.dragAddress); + final walletDataTo = + myWalletProvider.getWalletDataByAddress(myWalletProvider.lastFlyBy); + + final bool isSameAddress = + myWalletProvider.dragAddress == myWalletProvider.lastFlyBy; + + final double screenWidth = MediaQuery.of(homeContext).size.width; + return Container( + color: yellowC, + width: screenWidth, + height: 80, + child: Center( + child: Column( + children: [ + const SizedBox(height: 5), + Text('${'executeATransfer'.tr()}:'), + MarkdownBody(data: '${'from'.tr()} **${walletDataFrom!.name}**'), + if (isSameAddress) Text('chooseATargetWallet'.tr()), + if (!isSameAddress) + MarkdownBody(data: 'Vers: **${walletDataTo!.name}**'), + ], + )), + ); + } + Widget chestOptions( BuildContext context, MyWalletsProvider myWalletProvider) { return Column(children: [ @@ -187,6 +223,7 @@ class WalletsHome extends StatelessWidget { } else if (screenWidth >= 650) { nTule = 3; } + // final dragAnchorStrategy = pointerDragAnchorStrategy; return CustomScrollView(slivers: [ const SliverToBoxAdapter(child: SizedBox(height: 20)), @@ -199,10 +236,19 @@ class WalletsHome extends StatelessWidget { children: [ for (WalletData repository in listWallets as Iterable) LongPressDraggable( + delay: const Duration(milliseconds: 200), data: repository.address!, - dragAnchorStrategy: - (Draggable _, BuildContext __, Offset ___) => - const Offset(0, 0), + // dragAnchorStrategy: + // (Draggable _, BuildContext __, Offset ___) => + // const Offset(40, 40), + dragAnchorStrategy: pointerDragAnchorStrategy, + onDragStarted: () => + myWalletProvider.dragAddress = repository.address!, + onDragEnd: (_) { + myWalletProvider.lastFlyBy = ''; + myWalletProvider.dragAddress = ''; + myWalletProvider.reload(); + }, feedback: ElevatedButton( onPressed: () {}, style: ElevatedButton.styleFrom( @@ -215,96 +261,109 @@ class WalletsHome extends StatelessWidget { child: Image(image: AssetImage('assets/vector_white.png')), ), ), - child: DragTarget(onAccept: (senderAddress) async { - log.d( - 'INTERPAY: sender: $senderAddress --- receiver: ${repository.address!}'); - final walletData = - myWalletProvider.getWalletDataByAddress(senderAddress); - await sub.setCurrentWallet(walletData!); - sub.reload(); - paymentPopup(context, repository.address!); - }, builder: ( - BuildContext context, - List accepted, - List rejected, - ) { - return Padding( - padding: const EdgeInsets.all(16), - child: GestureDetector( - key: keyOpenWallet(repository.address!), - onTap: () { - walletOptions.getAddress( - currentChestNumber, repository.derivation!); - Navigator.push( - context, - SmoothTransition( - page: WalletOptions( - wallet: repository, + child: DragTarget( + onAccept: (senderAddress) async { + log.d( + 'INTERPAY: sender: $senderAddress --- receiver: ${repository.address!}'); + final walletData = myWalletProvider + .getWalletDataByAddress(senderAddress); + await sub.setCurrentWallet(walletData!); + sub.reload(); + paymentPopup(context, repository.address!); + }, + // onMove: ((details) => log.d('oooookkkkkkkk')), + onMove: (details) { + if (repository.address! != myWalletProvider.lastFlyBy) { + log.d('oooookkkkkkkk: ${repository.address!}'); + myWalletProvider.lastFlyBy = repository.address!; + myWalletProvider.reload(); + } + }, + onWillAccept: (senderAddress) => + senderAddress != repository.address!, + builder: ( + BuildContext context, + List accepted, + List rejected, + ) { + return Padding( + padding: const EdgeInsets.all(16), + child: GestureDetector( + key: keyOpenWallet(repository.address!), + onTap: () { + walletOptions.getAddress( + currentChestNumber, repository.derivation!); + Navigator.push( + context, + SmoothTransition( + page: WalletOptions( + wallet: repository, + ), ), + ); + }, + child: ClipOvalShadow( + shadow: const Shadow( + color: Colors.transparent, + offset: Offset(0, 0), + blurRadius: 5, ), - ); - }, - child: ClipOvalShadow( - shadow: const Shadow( - color: Colors.transparent, - offset: Offset(0, 0), - blurRadius: 5, - ), - clipper: CustomClipperOval(), - child: ClipRRect( - borderRadius: - const BorderRadius.all(Radius.circular(12)), - child: Column(children: [ - Expanded( - child: Container( - width: double.infinity, - height: double.infinity, - decoration: BoxDecoration( - gradient: RadialGradient( - radius: 0.6, - colors: [ - Colors.green[400]!, - const Color(0xFFE7E7A6), - ], - )), - child: - // SvgPicture.asset('assets/chopp-gecko2.png', - // semanticsLabel: 'Gecko', height: 48), - repository.imageCustomPath == null || - repository.imageCustomPath == '' - ? Image.asset( - 'assets/avatars/${repository.imageDefaultPath}', - alignment: Alignment.bottomCenter, - scale: 0.5, - ) - : Container( - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.transparent, - image: DecorationImage( - fit: BoxFit.fitHeight, - image: FileImage( - File(repository - .imageCustomPath!), + clipper: CustomClipperOval(), + child: ClipRRect( + borderRadius: + const BorderRadius.all(Radius.circular(12)), + child: Column(children: [ + Expanded( + child: Container( + width: double.infinity, + height: double.infinity, + decoration: BoxDecoration( + gradient: RadialGradient( + radius: 0.6, + colors: [ + Colors.green[400]!, + const Color(0xFFE7E7A6), + ], + )), + child: + // SvgPicture.asset('assets/chopp-gecko2.png', + // semanticsLabel: 'Gecko', height: 48), + repository.imageCustomPath == null || + repository.imageCustomPath == '' + ? Image.asset( + 'assets/avatars/${repository.imageDefaultPath}', + alignment: Alignment.bottomCenter, + scale: 0.5, + ) + : Container( + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.transparent, + image: DecorationImage( + fit: BoxFit.fitHeight, + image: FileImage( + File(repository + .imageCustomPath!), + ), ), ), ), - ), - )), - Stack(children: [ - balanceBuilder( - context, - repository.address!, - repository.address == - defaultWallet.address), - nameBuilder(context, repository, defaultWallet, - currentChestNumber), + )), + Stack(children: [ + balanceBuilder( + context, + repository.address!, + repository.address == + defaultWallet.address), + nameBuilder(context, repository, + defaultWallet, currentChestNumber), + ]), ]), - ]), + ), ), ), - )); - }), + ); + }), ), Consumer(builder: (context, sub, _) { return sub.nodeConnected diff --git a/pubspec.yaml b/pubspec.yaml index 3e57510..e64697b 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+28 +version: 0.0.11+29 environment: sdk: '>=2.12.0 <3.0.0' From ad0019522ffdf6201d8c20c7f015e3e0245430c9 Mon Sep 17 00:00:00 2001 From: poka Date: Mon, 12 Sep 2022 08:24:13 +0200 Subject: [PATCH 3/4] improve payment popup --- lib/screens/wallet_view.dart | 121 +++++++++++++++++++++-------------- 1 file changed, 73 insertions(+), 48 deletions(-) diff --git a/lib/screens/wallet_view.dart b/lib/screens/wallet_view.dart index f043be7..622f413 100644 --- a/lib/screens/wallet_view.dart +++ b/lib/screens/wallet_view.dart @@ -419,6 +419,43 @@ void paymentPopup(BuildContext context, String toAddress) { final udValue = sub.udValue; final double balanceRatio = isUdUnit ? round(udValue / 100, 6) : 1; + final toWalletData = myWalletProvider.getWalletDataByAddress(toAddress); + + Future executeTransfert() async { + String? pin; + if (myWalletProvider.pinCode == '') { + pin = await Navigator.push( + context, + MaterialPageRoute( + builder: (homeContext) { + return UnlockingWallet(wallet: defaultWallet); + }, + ), + ); + } + log.d(pin); + if (pin != null || myWalletProvider.pinCode != '') { + // Payment workflow ! + WalletsProfilesProvider walletViewProvider = + Provider.of(context, listen: false); + SubstrateSdk sub = Provider.of(context, listen: false); + final acc = sub.getCurrentWallet(); + log.d( + "fromAddress: ${acc.address!},destAddress: $toAddress, amount: ${double.parse(walletViewProvider.payAmount.text)}, password: $pin"); + sub.pay( + fromAddress: acc.address!, + destAddress: toAddress, + amount: double.parse(walletViewProvider.payAmount.text), + password: pin ?? myWalletProvider.pinCode); + Navigator.push( + context, + MaterialPageRoute(builder: (context) { + return const TransactionInProgress(); + }), + ); + } + } + showModalBottomSheet( shape: const RoundedRectangleBorder( borderRadius: BorderRadius.only( @@ -452,7 +489,7 @@ void paymentPopup(BuildContext context, String toAddress) { padding: EdgeInsets.only( bottom: MediaQuery.of(context).viewInsets.bottom), child: Container( - height: 400, + height: 420, decoration: const ShapeDecoration( color: Color(0xffffeed1), shape: RoundedRectangleBorder( @@ -537,9 +574,36 @@ void paymentPopup(BuildContext context, String toAddress) { ), ); }), - const Spacer(), - - // const SizedBox(height: 10), + const SizedBox(height: 12), + Row( + children: [ + Text( + 'to'.tr(), + style: TextStyle( + fontSize: 19, + fontWeight: FontWeight.w500, + color: Colors.grey[600]), + ), + const SizedBox(width: 10), + // const Spacer(flex: 1), + Column( + children: [ + const SizedBox(height: 2), + Text( + toWalletData == null + ? getShortPubkey(toAddress) + : toWalletData.name!, + style: const TextStyle( + fontSize: 21, + fontWeight: FontWeight.w600, + ), + ), + // const Spacer(flex: 2), + ], + ), + ], + ), + const SizedBox(height: 12), Text( 'amount'.tr(), style: TextStyle( @@ -549,6 +613,9 @@ void paymentPopup(BuildContext context, String toAddress) { ), const SizedBox(height: 10), TextField( + textInputAction: TextInputAction.done, + onEditingComplete: () async => + canValidate ? await executeTransfert() : null, key: keyAmountField, controller: walletViewProvider.payAmount, autofocus: true, @@ -577,7 +644,6 @@ void paymentPopup(BuildContext context, String toAddress) { // borderSide: // BorderSide(color: Colors.grey[500], width: 2), // borderRadius: BorderRadius.circular(8)), - focusedBorder: OutlineInputBorder( borderSide: BorderSide(color: Colors.grey[500]!, width: 2), @@ -586,7 +652,7 @@ void paymentPopup(BuildContext context, String toAddress) { contentPadding: const EdgeInsets.all(20), ), style: const TextStyle( - fontSize: 40, + fontSize: 35, color: Colors.black, fontWeight: FontWeight.w600, ), @@ -603,48 +669,7 @@ void paymentPopup(BuildContext context, String toAddress) { backgroundColor: orangeC, // foreground ), onPressed: canValidate - ? () async { - String? pin; - if (myWalletProvider.pinCode == '') { - pin = await Navigator.push( - context, - MaterialPageRoute( - builder: (homeContext) { - return UnlockingWallet( - wallet: defaultWallet); - }, - ), - ); - } - log.d(pin); - if (pin != null || - myWalletProvider.pinCode != '') { - // Payment workflow ! - WalletsProfilesProvider walletViewProvider = - Provider.of( - context, - listen: false); - SubstrateSdk sub = - Provider.of(context, - listen: false); - final acc = sub.getCurrentWallet(); - log.d( - "fromAddress: ${acc.address!},destAddress: $toAddress, amount: ${double.parse(walletViewProvider.payAmount.text)}, password: $pin"); - sub.pay( - fromAddress: acc.address!, - destAddress: toAddress, - amount: double.parse( - walletViewProvider.payAmount.text), - password: - pin ?? myWalletProvider.pinCode); - Navigator.push( - context, - MaterialPageRoute(builder: (context) { - return const TransactionInProgress(); - }), - ); - } - } + ? () async => await executeTransfert() : null, child: Text( 'executeTheTransfer'.tr(), From a432db334de7e35f3ee8256e6e0725200036146b Mon Sep 17 00:00:00 2001 From: poka Date: Mon, 12 Sep 2022 08:28:19 +0200 Subject: [PATCH 4/4] remove unused commented code --- lib/screens/myWallets/wallets_home.dart | 31 --------------------- lib/screens/wallet_view.dart | 37 ++++++------------------- 2 files changed, 9 insertions(+), 59 deletions(-) diff --git a/lib/screens/myWallets/wallets_home.dart b/lib/screens/myWallets/wallets_home.dart index ed73fb4..2d8912e 100644 --- a/lib/screens/myWallets/wallets_home.dart +++ b/lib/screens/myWallets/wallets_home.dart @@ -42,7 +42,6 @@ class WalletsHome extends StatelessWidget { return WillPopScope( onWillPop: () { - // myWalletProvider.pinCode = myWalletProvider.mnemonic = ''; Navigator.popUntil( context, ModalRoute.withName('/'), @@ -57,7 +56,6 @@ class WalletsHome extends StatelessWidget { leading: IconButton( icon: const Icon(Icons.arrow_back, color: Colors.black), onPressed: () { - // myWalletProvider.pinCode = myWalletProvider.mnemonic = ''; Navigator.popUntil( context, ModalRoute.withName('/'), @@ -223,7 +221,6 @@ class WalletsHome extends StatelessWidget { } else if (screenWidth >= 650) { nTule = 3; } - // final dragAnchorStrategy = pointerDragAnchorStrategy; return CustomScrollView(slivers: [ const SliverToBoxAdapter(child: SizedBox(height: 20)), @@ -271,10 +268,8 @@ class WalletsHome extends StatelessWidget { sub.reload(); paymentPopup(context, repository.address!); }, - // onMove: ((details) => log.d('oooookkkkkkkk')), onMove: (details) { if (repository.address! != myWalletProvider.lastFlyBy) { - log.d('oooookkkkkkkk: ${repository.address!}'); myWalletProvider.lastFlyBy = repository.address!; myWalletProvider.reload(); } @@ -370,16 +365,7 @@ class WalletsHome extends StatelessWidget { ? addNewDerivation(context) : const Text(''); }), - // SizedBox(height: 1), - // Padding( - // padding: EdgeInsets.symmetric(horizontal: 35), - // child: Text( - // 'Ajouter un portefeuille', - // textAlign: TextAlign.center, - // style: TextStyle(fontSize: 18), - // )) ]), - // SliverToBoxAdapter(child: Spacer()), SliverToBoxAdapter(child: chestOptions(context, myWalletProvider)), ]); } @@ -413,14 +399,9 @@ class WalletsHome extends StatelessWidget { return ListTile( shape: const RoundedRectangleBorder( borderRadius: BorderRadius.vertical(bottom: Radius.circular(12))), - // contentPadding: const EdgeInsets.only(left: 7.0), tileColor: repository.address == defaultWallet.address ? orangeC : const Color(0xffFFD58D), - // leading: Text('IMAGE'), - - // subtitle: Text(_repository.split(':')[3], - // style: TextStyle(fontSize: 12.0, fontFamily: 'Monospace')), title: Center( child: Padding( padding: const EdgeInsets.only(left: 5, right: 5, bottom: 35, top: 5), @@ -435,13 +416,7 @@ class WalletsHome extends StatelessWidget { : Colors.black), ), ), - // dense: true, onTap: () { - // _walletOptions.readLocalWallet( - // context, - // _repository, - // _myWalletProvider.pinCode, - // pinLength); walletOptions.getAddress(currentChestNumber, repository.derivation!); Navigator.push( context, @@ -517,12 +492,6 @@ class WalletsHome extends StatelessWidget { } } -// extension Range on num { -// bool isBetween(num from, num to) { -// return from < this && this < to; -// } -// } - class CustomClipperOval extends CustomClipper { @override Rect getClip(Size size) { diff --git a/lib/screens/wallet_view.dart b/lib/screens/wallet_view.dart index 622f413..7de9771 100644 --- a/lib/screens/wallet_view.dart +++ b/lib/screens/wallet_view.dart @@ -49,9 +49,6 @@ class WalletViewScreen extends StatelessWidget { sub.setCurrentWallet(defaultWallet); - // sub.spawnBlock(); - // sub.spawnBlock(0, 25); - return Scaffold( backgroundColor: backgroundColor, resizeToAvoidBottomInset: true, @@ -118,7 +115,7 @@ class WalletViewScreen extends StatelessWidget { height: buttonSize, child: ClipOval( child: Material( - color: yellowC, //const Color(0xffFFD58D), // button color + color: yellowC, child: InkWell( key: keyViewActivity, splashColor: orangeC, // inkwell color @@ -129,7 +126,6 @@ class WalletViewScreen extends StatelessWidget { 'assets/walletOptions/clock.png'), height: 90)), onTap: () { - // _historyProvider.nPage = 1; Navigator.push( context, MaterialPageRoute(builder: (context) { @@ -154,8 +150,7 @@ class WalletViewScreen extends StatelessWidget { Consumer(builder: (context, sub, _) { WalletData? defaultWallet = myWalletProvider.getDefaultWallet(); return FutureBuilder( - future: sub.certState(defaultWallet.address!, - address!), // .canCertify(_defaultWallet.address!, pubkey!), + future: sub.certState(defaultWallet.address!, address!), builder: (context, AsyncSnapshot> snapshot) { if (snapshot.data == null) return const SizedBox(); String duration = ''; @@ -207,11 +202,10 @@ class WalletViewScreen extends StatelessWidget { height: buttonSize, child: ClipOval( child: Material( - color: - const Color(0xffFFD58D), // button color + color: const Color(0xffFFD58D), child: InkWell( key: keyCertify, - splashColor: orangeC, // inkwell color + splashColor: orangeC, child: const Padding( padding: EdgeInsets.only(bottom: 0), child: Image( @@ -293,10 +287,10 @@ class WalletViewScreen extends StatelessWidget { height: buttonSize, child: ClipOval( child: Material( - color: const Color(0xffFFD58D), // button color + color: const Color(0xffFFD58D), child: InkWell( key: keyCopyAddress, - splashColor: orangeC, // inkwell color + splashColor: orangeC, child: const Padding( padding: EdgeInsets.all(20), child: Image( @@ -334,7 +328,7 @@ class WalletViewScreen extends StatelessWidget { ), child: ClipOval( child: Material( - color: orangeC, // button color + color: orangeC, child: InkWell( key: keyPay, splashColor: yellowC, @@ -342,7 +336,7 @@ class WalletViewScreen extends StatelessWidget { ? () { paymentPopup(context, address!); } - : null, // inkwell color + : null, child: const Padding( padding: EdgeInsets.all(14), child: Image( @@ -400,8 +394,6 @@ class WalletViewScreen extends StatelessWidget { } void paymentPopup(BuildContext context, String toAddress) { - // WalletsProfilesProvider _walletViewProvider = - // Provider.of(context, listen: false); final walletViewProvider = Provider.of(context, listen: false); @@ -585,7 +577,6 @@ void paymentPopup(BuildContext context, String toAddress) { color: Colors.grey[600]), ), const SizedBox(width: 10), - // const Spacer(flex: 1), Column( children: [ const SizedBox(height: 2), @@ -598,7 +589,6 @@ void paymentPopup(BuildContext context, String toAddress) { fontWeight: FontWeight.w600, ), ), - // const Spacer(flex: 2), ], ), ], @@ -622,17 +612,13 @@ void paymentPopup(BuildContext context, String toAddress) { maxLines: 1, textAlign: TextAlign.center, keyboardType: TextInputType.number, - onChanged: (_) => setState(() { - // _walletViewProvider.reload(); - }), + onChanged: (_) => setState(() {}), inputFormatters: [ - // FilteringTextInputFormatter.digitsOnly, FilteringTextInputFormatter.deny(',', replacementString: '.'), FilteringTextInputFormatter.allow( RegExp(r'(^\d+\.?\d{0,2})')), ], - // onChanged: (v) => _searchProvider.reload(), decoration: InputDecoration( hintText: '0.00', suffix: Text(isUdUnit @@ -640,10 +626,6 @@ void paymentPopup(BuildContext context, String toAddress) { : currencyName), // udUnitDisplay(40), filled: true, fillColor: Colors.transparent, - // border: OutlineInputBorder( - // borderSide: - // BorderSide(color: Colors.grey[500], width: 2), - // borderRadius: BorderRadius.circular(8)), focusedBorder: OutlineInputBorder( borderSide: BorderSide(color: Colors.grey[500]!, width: 2), @@ -657,7 +639,6 @@ void paymentPopup(BuildContext context, String toAddress) { fontWeight: FontWeight.w600, ), ), - // const SizedBox(height: 40), const Spacer(), SizedBox( width: double.infinity,