Merge branch 'dragNDropWalletsTransfert' into 'master'

Drag n drop wallets transfert

See merge request clients/gecko!31
This commit is contained in:
pokapow 2022-09-12 08:36:12 +02:00
commit 09e1592f55
14 changed files with 473 additions and 398 deletions

View File

@ -158,6 +158,7 @@
"months": "{} months", "months": "{} months",
"certify": "Certify", "certify": "Certify",
"from": "From:", "from": "From:",
"to": "To:",
"amount": "Amount:", "amount": "Amount:",
"choiceOfSourceWallet": "Choose a source wallet", "choiceOfSourceWallet": "Choose a source wallet",
"extrinsicInProgress": "{} in progress", "extrinsicInProgress": "{} in progress",
@ -193,5 +194,6 @@
"revokeMyIdentity": "Revoke my identity", "revokeMyIdentity": "Revoke my identity",
"youCannotRevokeThisIdentity": "You cannot revoke this identity while\nit is member of the blacksmiths web", "youCannotRevokeThisIdentity": "You cannot revoke this identity while\nit is member of the blacksmiths web",
"showUdAmounts": "Show amounts in UD", "showUdAmounts": "Show amounts in UD",
"ud": "{}UD" "ud": "{}UD",
"chooseATargetWallet": "Choose a target wallet"
} }

View File

@ -158,6 +158,7 @@
"months": "{} months", "months": "{} months",
"certify": "Certify", "certify": "Certify",
"from": "From:", "from": "From:",
"to": "To:",
"amount": "Amount:", "amount": "Amount:",
"choiceOfSourceWallet": "Choose a source wallet", "choiceOfSourceWallet": "Choose a source wallet",
"extrinsicInProgress": "{} in progress", "extrinsicInProgress": "{} in progress",
@ -193,5 +194,6 @@
"revokeMyIdentity": "Revoke my identity", "revokeMyIdentity": "Revoke my identity",
"youCannotRevokeThisIdentity": "You cannot revoke this identity while\nit is member of the blacksmiths web", "youCannotRevokeThisIdentity": "You cannot revoke this identity while\nit is member of the blacksmiths web",
"showUdAmounts": "Show amounts in UD", "showUdAmounts": "Show amounts in UD",
"ud": "{}UD" "ud": "{}UD",
"chooseATargetWallet": "Choose a target wallet"
} }

View File

@ -159,6 +159,7 @@
"months": "{} mois", "months": "{} mois",
"certify": "Certifier", "certify": "Certifier",
"from": "Depuis:", "from": "Depuis:",
"to": "Vers:",
"amount": "Montant:", "amount": "Montant:",
"choiceOfSourceWallet": "Choix du portefeuille source", "choiceOfSourceWallet": "Choix du portefeuille source",
"extrinsicInProgress": "{} en cours", "extrinsicInProgress": "{} en cours",
@ -194,5 +195,6 @@
"revokeMyIdentity": "Révoquer mon identité", "revokeMyIdentity": "Révoquer mon identité",
"youCannotRevokeThisIdentity": "Vous ne pouvez pas révoquer cette identité tant\nqu'elle fait partie de la toile forgerons", "youCannotRevokeThisIdentity": "Vous ne pouvez pas révoquer cette identité tant\nqu'elle fait partie de la toile forgerons",
"showUdAmounts": "Afficher les montants en DU", "showUdAmounts": "Afficher les montants en DU",
"ud": "{}DU" "ud": "{}DU",
"chooseATargetWallet": "Choisissez un portefeuille cible"
} }

View File

@ -339,7 +339,7 @@ class DuniterIndexer with ChangeNotifier {
MaterialPageRoute(builder: (context) { MaterialPageRoute(builder: (context) {
walletsProfiles.address = profile['id']; walletsProfiles.address = profile['id'];
return WalletViewScreen( return WalletViewScreen(
pubkey: profile['id'], address: profile['id'],
username: g1WalletsBox username: g1WalletsBox
.get(profile['id']) .get(profile['id'])
?.id ?.id

View File

@ -13,6 +13,8 @@ class MyWalletsProvider with ChangeNotifier {
late String mnemonic; late String mnemonic;
int? pinLenght; int? pinLenght;
bool isNewDerivationLoading = false; bool isNewDerivationLoading = false;
String lastFlyBy = '';
String dragAddress = '';
int getCurrentChest() { int getCurrentChest() {
if (configBox.get('currentChest') == null) { if (configBox.get('currentChest') == null) {

View File

@ -44,7 +44,7 @@ class WalletsProfilesProvider with ChangeNotifier {
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute(builder: (context) { MaterialPageRoute(builder: (context) {
return WalletViewScreen(pubkey: barcode!.rawContent); return WalletViewScreen(address: barcode!.rawContent);
}), }),
); );
} else { } else {

View File

@ -354,7 +354,7 @@ class ActivityScreen extends StatelessWidget with ChangeNotifier {
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute(builder: (context) { MaterialPageRoute(builder: (context) {
return WalletViewScreen(pubkey: repository[1]); return WalletViewScreen(address: repository[1]);
}), }),
); );
// Navigator.pop(context); // Navigator.pop(context);

View File

@ -53,8 +53,6 @@ class ChooseWalletScreen extends StatelessWidget {
), ),
onPressed: () async { onPressed: () async {
await sub.setCurrentWallet(selectedWallet!); await sub.setCurrentWallet(selectedWallet!);
// _walletViewProvider.reload();
sub.reload(); sub.reload();
// Navigator.pop(context); // Navigator.pop(context);

View File

@ -1,7 +1,10 @@
// ignore_for_file: use_build_context_synchronously
import 'dart:io'; import 'dart:io';
import 'package:easy_localization/easy_localization.dart'; import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_markdown/flutter_markdown.dart';
import 'package:gecko/globals.dart'; import 'package:gecko/globals.dart';
import 'package:gecko/models/chest_data.dart'; import 'package:gecko/models/chest_data.dart';
import 'package:gecko/models/widgets_keys.dart'; import 'package:gecko/models/widgets_keys.dart';
@ -18,6 +21,7 @@ import 'package:gecko/screens/myWallets/choose_chest.dart';
import 'package:gecko/screens/myWallets/import_g1_v1.dart'; import 'package:gecko/screens/myWallets/import_g1_v1.dart';
import 'package:gecko/screens/myWallets/unlocking_wallet.dart'; import 'package:gecko/screens/myWallets/unlocking_wallet.dart';
import 'package:gecko/screens/myWallets/wallet_options.dart'; import 'package:gecko/screens/myWallets/wallet_options.dart';
import 'package:gecko/screens/wallet_view.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
class WalletsHome extends StatelessWidget { class WalletsHome extends StatelessWidget {
@ -38,7 +42,6 @@ class WalletsHome extends StatelessWidget {
return WillPopScope( return WillPopScope(
onWillPop: () { onWillPop: () {
// myWalletProvider.pinCode = myWalletProvider.mnemonic = '';
Navigator.popUntil( Navigator.popUntil(
context, context,
ModalRoute.withName('/'), ModalRoute.withName('/'),
@ -53,7 +56,6 @@ class WalletsHome extends StatelessWidget {
leading: IconButton( leading: IconButton(
icon: const Icon(Icons.arrow_back, color: Colors.black), icon: const Icon(Icons.arrow_back, color: Colors.black),
onPressed: () { onPressed: () {
// myWalletProvider.pinCode = myWalletProvider.mnemonic = '';
Navigator.popUntil( Navigator.popUntil(
context, context,
ModalRoute.withName('/'), ModalRoute.withName('/'),
@ -63,7 +65,9 @@ class WalletsHome extends StatelessWidget {
style: TextStyle(color: Colors.grey[850])), style: TextStyle(color: Colors.grey[850])),
backgroundColor: const Color(0xffFFD58D), backgroundColor: const Color(0xffFFD58D),
), ),
bottomNavigationBar: homeProvider.bottomAppBar(context), bottomNavigationBar: myWalletProvider.lastFlyBy == ''
? homeProvider.bottomAppBar(context)
: dragInfo(context),
body: SafeArea( body: SafeArea(
child: Stack(children: [ child: Stack(children: [
myWalletsTiles(context, currentChestNumber), myWalletsTiles(context, currentChestNumber),
@ -74,6 +78,37 @@ class WalletsHome extends StatelessWidget {
); );
} }
Widget dragInfo(BuildContext context) {
final myWalletProvider =
Provider.of<MyWalletsProvider>(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( Widget chestOptions(
BuildContext context, MyWalletsProvider myWalletProvider) { BuildContext context, MyWalletsProvider myWalletProvider) {
return Column(children: [ return Column(children: [
@ -159,6 +194,7 @@ class WalletsHome extends StatelessWidget {
WalletOptionsProvider walletOptions = WalletOptionsProvider walletOptions =
Provider.of<WalletOptionsProvider>(context, listen: false); Provider.of<WalletOptionsProvider>(context, listen: false);
final bool isWalletsExists = myWalletProvider.checkIfWalletExist(); final bool isWalletsExists = myWalletProvider.checkIfWalletExist();
SubstrateSdk sub = Provider.of<SubstrateSdk>(context, listen: false);
if (!isWalletsExists) { if (!isWalletsExists) {
return const Text(''); return const Text('');
@ -196,7 +232,56 @@ class WalletsHome extends StatelessWidget {
mainAxisSpacing: 0, mainAxisSpacing: 0,
children: <Widget>[ children: <Widget>[
for (WalletData repository in listWallets as Iterable<WalletData>) for (WalletData repository in listWallets as Iterable<WalletData>)
Padding( LongPressDraggable<String>(
delay: const Duration(milliseconds: 200),
data: repository.address!,
// dragAnchorStrategy:
// (Draggable<Object> _, 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(
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<String>(
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) {
if (repository.address! != myWalletProvider.lastFlyBy) {
myWalletProvider.lastFlyBy = repository.address!;
myWalletProvider.reload();
}
},
onWillAccept: (senderAddress) =>
senderAddress != repository.address!,
builder: (
BuildContext context,
List<dynamic> accepted,
List<dynamic> rejected,
) {
return Padding(
padding: const EdgeInsets.all(16), padding: const EdgeInsets.all(16),
child: GestureDetector( child: GestureDetector(
key: keyOpenWallet(repository.address!), key: keyOpenWallet(repository.address!),
@ -252,37 +337,35 @@ class WalletsHome extends StatelessWidget {
image: DecorationImage( image: DecorationImage(
fit: BoxFit.fitHeight, fit: BoxFit.fitHeight,
image: FileImage( image: FileImage(
File(repository.imageCustomPath!), File(repository
.imageCustomPath!),
), ),
), ),
), ),
), ),
)), )),
Stack(children: <Widget>[ Stack(children: <Widget>[
balanceBuilder(context, repository.address!, balanceBuilder(
repository.address == defaultWallet.address), context,
nameBuilder(context, repository, defaultWallet, repository.address!,
currentChestNumber), repository.address ==
defaultWallet.address),
nameBuilder(context, repository,
defaultWallet, currentChestNumber),
]), ]),
]), ]),
), ),
), ),
)), ),
);
}),
),
Consumer<SubstrateSdk>(builder: (context, sub, _) { Consumer<SubstrateSdk>(builder: (context, sub, _) {
return sub.nodeConnected return sub.nodeConnected
? addNewDerivation(context) ? addNewDerivation(context)
: const Text(''); : 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)), SliverToBoxAdapter(child: chestOptions(context, myWalletProvider)),
]); ]);
} }
@ -316,14 +399,9 @@ class WalletsHome extends StatelessWidget {
return ListTile( return ListTile(
shape: const RoundedRectangleBorder( shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(bottom: Radius.circular(12))), borderRadius: BorderRadius.vertical(bottom: Radius.circular(12))),
// contentPadding: const EdgeInsets.only(left: 7.0),
tileColor: repository.address == defaultWallet.address tileColor: repository.address == defaultWallet.address
? orangeC ? orangeC
: const Color(0xffFFD58D), : const Color(0xffFFD58D),
// leading: Text('IMAGE'),
// subtitle: Text(_repository.split(':')[3],
// style: TextStyle(fontSize: 12.0, fontFamily: 'Monospace')),
title: Center( title: Center(
child: Padding( child: Padding(
padding: const EdgeInsets.only(left: 5, right: 5, bottom: 35, top: 5), padding: const EdgeInsets.only(left: 5, right: 5, bottom: 35, top: 5),
@ -338,13 +416,7 @@ class WalletsHome extends StatelessWidget {
: Colors.black), : Colors.black),
), ),
), ),
// dense: true,
onTap: () { onTap: () {
// _walletOptions.readLocalWallet(
// context,
// _repository,
// _myWalletProvider.pinCode,
// pinLength);
walletOptions.getAddress(currentChestNumber, repository.derivation!); walletOptions.getAddress(currentChestNumber, repository.derivation!);
Navigator.push( Navigator.push(
context, context,
@ -420,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<Rect> { class CustomClipperOval extends CustomClipper<Rect> {
@override @override
Rect getClip(Size size) { Rect getClip(Size size) {

View File

@ -116,7 +116,7 @@ class ContactsScreen extends StatelessWidget {
walletsProfilesClass.address = walletsProfilesClass.address =
g1Wallet.pubkey; g1Wallet.pubkey;
return WalletViewScreen( return WalletViewScreen(
pubkey: g1Wallet.pubkey, address: g1Wallet.pubkey,
username: g1WalletsBox username: g1WalletsBox
.get(g1Wallet.pubkey) .get(g1Wallet.pubkey)
?.id ?.id

View File

@ -143,7 +143,7 @@ class SearchResultScreen extends StatelessWidget {
walletsProfilesClass.address = walletsProfilesClass.address =
g1Wallet.pubkey; g1Wallet.pubkey;
return WalletViewScreen( return WalletViewScreen(
pubkey: g1Wallet.pubkey, address: g1Wallet.pubkey,
username: g1WalletsBox username: g1WalletsBox
.get(g1Wallet.pubkey) .get(g1Wallet.pubkey)
?.id ?.id

View File

@ -24,9 +24,9 @@ import 'package:qr_flutter/qr_flutter.dart';
class WalletViewScreen extends StatelessWidget { class WalletViewScreen extends StatelessWidget {
const WalletViewScreen( const WalletViewScreen(
{required this.pubkey, this.username, this.avatar, Key? key}) {required this.address, this.username, this.avatar, Key? key})
: super(key: key); : super(key: key);
final String? pubkey; final String? address;
final String? username; final String? username;
final Image? avatar; final Image? avatar;
final double buttonSize = 100; final double buttonSize = 100;
@ -39,7 +39,7 @@ class WalletViewScreen extends StatelessWidget {
Provider.of<WalletsProfilesProvider>(context, listen: false); Provider.of<WalletsProfilesProvider>(context, listen: false);
CesiumPlusProvider cesiumPlusProvider = CesiumPlusProvider cesiumPlusProvider =
Provider.of<CesiumPlusProvider>(context, listen: false); Provider.of<CesiumPlusProvider>(context, listen: false);
walletProfile.address = pubkey!; walletProfile.address = address!;
SubstrateSdk sub = Provider.of<SubstrateSdk>(context, listen: false); SubstrateSdk sub = Provider.of<SubstrateSdk>(context, listen: false);
HomeProvider homeProvider = HomeProvider homeProvider =
Provider.of<HomeProvider>(context, listen: false); Provider.of<HomeProvider>(context, listen: false);
@ -49,9 +49,6 @@ class WalletViewScreen extends StatelessWidget {
sub.setCurrentWallet(defaultWallet); sub.setCurrentWallet(defaultWallet);
// sub.spawnBlock();
// sub.spawnBlock(0, 25);
return Scaffold( return Scaffold(
backgroundColor: backgroundColor, backgroundColor: backgroundColor,
resizeToAvoidBottomInset: true, resizeToAvoidBottomInset: true,
@ -67,14 +64,14 @@ class WalletViewScreen extends StatelessWidget {
onPressed: () async { onPressed: () async {
G1WalletsList? newContact; G1WalletsList? newContact;
g1WalletsBox.toMap().forEach((key, value) { g1WalletsBox.toMap().forEach((key, value) {
if (key == pubkey) newContact = value; if (key == address) newContact = value;
}); });
// G1WalletsList(pubkey: pubkey!, username: username); // G1WalletsList(pubkey: pubkey!, username: username);
await walletProfile.addContact( await walletProfile.addContact(
newContact ?? G1WalletsList(pubkey: pubkey!)); newContact ?? G1WalletsList(pubkey: address!));
}, },
icon: Icon( icon: Icon(
walletProfile.isContact(pubkey!) walletProfile.isContact(address!)
? Icons.add_reaction_rounded ? Icons.add_reaction_rounded
: Icons.add_reaction_outlined, : Icons.add_reaction_outlined,
size: 35, size: 35,
@ -110,7 +107,7 @@ class WalletViewScreen extends StatelessWidget {
bottomNavigationBar: homeProvider.bottomAppBar(context), bottomNavigationBar: homeProvider.bottomAppBar(context),
body: SafeArea( body: SafeArea(
child: Column(children: <Widget>[ child: Column(children: <Widget>[
walletProfile.headerProfileView(context, pubkey!, username), walletProfile.headerProfileView(context, address!, username),
SizedBox(height: isTall ? 10 : 0), SizedBox(height: isTall ? 10 : 0),
Row(mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Row(mainAxisAlignment: MainAxisAlignment.spaceAround, children: [
Column(children: <Widget>[ Column(children: <Widget>[
@ -118,7 +115,7 @@ class WalletViewScreen extends StatelessWidget {
height: buttonSize, height: buttonSize,
child: ClipOval( child: ClipOval(
child: Material( child: Material(
color: yellowC, //const Color(0xffFFD58D), // button color color: yellowC,
child: InkWell( child: InkWell(
key: keyViewActivity, key: keyViewActivity,
splashColor: orangeC, // inkwell color splashColor: orangeC, // inkwell color
@ -129,12 +126,11 @@ class WalletViewScreen extends StatelessWidget {
'assets/walletOptions/clock.png'), 'assets/walletOptions/clock.png'),
height: 90)), height: 90)),
onTap: () { onTap: () {
// _historyProvider.nPage = 1;
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute(builder: (context) { MaterialPageRoute(builder: (context) {
return ActivityScreen( return ActivityScreen(
address: pubkey, address: address,
avatar: avatar:
cesiumPlusProvider.defaultAvatar(50)); cesiumPlusProvider.defaultAvatar(50));
}), }),
@ -154,8 +150,7 @@ class WalletViewScreen extends StatelessWidget {
Consumer<SubstrateSdk>(builder: (context, sub, _) { Consumer<SubstrateSdk>(builder: (context, sub, _) {
WalletData? defaultWallet = myWalletProvider.getDefaultWallet(); WalletData? defaultWallet = myWalletProvider.getDefaultWallet();
return FutureBuilder( return FutureBuilder(
future: sub.certState(defaultWallet.address!, future: sub.certState(defaultWallet.address!, address!),
pubkey!), // .canCertify(_defaultWallet.address!, pubkey!),
builder: (context, AsyncSnapshot<Map<String, int>> snapshot) { builder: (context, AsyncSnapshot<Map<String, int>> snapshot) {
if (snapshot.data == null) return const SizedBox(); if (snapshot.data == null) return const SizedBox();
String duration = ''; String duration = '';
@ -207,11 +202,10 @@ class WalletViewScreen extends StatelessWidget {
height: buttonSize, height: buttonSize,
child: ClipOval( child: ClipOval(
child: Material( child: Material(
color: color: const Color(0xffFFD58D),
const Color(0xffFFD58D), // button color
child: InkWell( child: InkWell(
key: keyCertify, key: keyCertify,
splashColor: orangeC, // inkwell color splashColor: orangeC,
child: const Padding( child: const Padding(
padding: EdgeInsets.only(bottom: 0), padding: EdgeInsets.only(bottom: 0),
child: Image( child: Image(
@ -223,7 +217,7 @@ class WalletViewScreen extends StatelessWidget {
context, context,
"areYouSureYouWantToCertify".tr( "areYouSureYouWantToCertify".tr(
args: [ args: [
getShortPubkey(pubkey!) getShortPubkey(address!)
])); ]));
if (result ?? false) { if (result ?? false) {
@ -293,17 +287,17 @@ class WalletViewScreen extends StatelessWidget {
height: buttonSize, height: buttonSize,
child: ClipOval( child: ClipOval(
child: Material( child: Material(
color: const Color(0xffFFD58D), // button color color: const Color(0xffFFD58D),
child: InkWell( child: InkWell(
key: keyCopyAddress, key: keyCopyAddress,
splashColor: orangeC, // inkwell color splashColor: orangeC,
child: const Padding( child: const Padding(
padding: EdgeInsets.all(20), padding: EdgeInsets.all(20),
child: Image( child: Image(
image: AssetImage('assets/copy_key.png'), image: AssetImage('assets/copy_key.png'),
height: 90)), height: 90)),
onTap: () { onTap: () {
Clipboard.setData(ClipboardData(text: pubkey)); Clipboard.setData(ClipboardData(text: address));
snackCopyKey(context); snackCopyKey(context);
}), }),
), ),
@ -334,20 +328,20 @@ class WalletViewScreen extends StatelessWidget {
), ),
child: ClipOval( child: ClipOval(
child: Material( child: Material(
color: orangeC, // button color color: orangeC,
child: InkWell( child: InkWell(
key: keyPay, key: keyPay,
splashColor: yellowC, splashColor: yellowC,
onTap: sub.nodeConnected onTap: sub.nodeConnected
? () { ? () {
paymentPopup(context, walletProfile); paymentPopup(context, address!);
} }
: null, // inkwell color : null,
child: const Padding( child: const Padding(
padding: EdgeInsets.all(14), padding: EdgeInsets.all(14),
child: Image( child: Image(
image: AssetImage('assets/vector_white.png'), image: AssetImage('assets/vector_white.png')),
))), )),
), ),
), ),
), ),
@ -397,11 +391,11 @@ class WalletViewScreen extends StatelessWidget {
), ),
]); ]);
} }
}
void paymentPopup( void paymentPopup(BuildContext context, String toAddress) {
BuildContext context, WalletsProfilesProvider walletViewProvider) { final walletViewProvider =
// WalletsProfilesProvider _walletViewProvider = Provider.of<WalletsProfilesProvider>(context, listen: false);
// Provider.of<WalletsProfilesProvider>(context, listen: false);
final myWalletProvider = final myWalletProvider =
Provider.of<MyWalletsProvider>(context, listen: false); Provider.of<MyWalletsProvider>(context, listen: false);
@ -417,6 +411,43 @@ class WalletViewScreen extends StatelessWidget {
final udValue = sub.udValue; final udValue = sub.udValue;
final double balanceRatio = isUdUnit ? round(udValue / 100, 6) : 1; 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<WalletsProfilesProvider>(context, listen: false);
SubstrateSdk sub = Provider.of<SubstrateSdk>(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<void>( showModalBottomSheet<void>(
shape: const RoundedRectangleBorder( shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.only( borderRadius: BorderRadius.only(
@ -433,8 +464,9 @@ class WalletViewScreen extends StatelessWidget {
(double.parse(walletViewProvider.payAmount.text) + (double.parse(walletViewProvider.payAmount.text) +
2 / balanceRatio) <= 2 / balanceRatio) <=
(balanceCache[defaultWallet.address] ?? 0) && (balanceCache[defaultWallet.address] ?? 0) &&
walletViewProvider.address != defaultWallet.address) { toAddress != defaultWallet.address) {
if ((balanceCache[pubkey] == 0 || balanceCache[pubkey] == null) && if ((balanceCache[toAddress] == 0 ||
balanceCache[toAddress] == null) &&
double.parse(walletViewProvider.payAmount.text) < double.parse(walletViewProvider.payAmount.text) <
5 / balanceRatio) { 5 / balanceRatio) {
canValidate = false; canValidate = false;
@ -449,7 +481,7 @@ class WalletViewScreen extends StatelessWidget {
padding: EdgeInsets.only( padding: EdgeInsets.only(
bottom: MediaQuery.of(context).viewInsets.bottom), bottom: MediaQuery.of(context).viewInsets.bottom),
child: Container( child: Container(
height: 400, height: 420,
decoration: const ShapeDecoration( decoration: const ShapeDecoration(
color: Color(0xffffeed1), color: Color(0xffffeed1),
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
@ -507,8 +539,7 @@ class WalletViewScreen extends StatelessWidget {
), ),
); );
} }
if (pin != null || if (pin != null || myWalletProvider.pinCode != '') {
myWalletProvider.pinCode != '') {
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute(builder: (context) { MaterialPageRoute(builder: (context) {
@ -522,10 +553,9 @@ class WalletViewScreen extends StatelessWidget {
width: double.infinity, width: double.infinity,
decoration: BoxDecoration( decoration: BoxDecoration(
border: Border.all( border: Border.all(
color: Colors.blueAccent.shade200, color: Colors.blueAccent.shade200, width: 2),
width: 2), borderRadius:
borderRadius: const BorderRadius.all( const BorderRadius.all(Radius.circular(10.0)),
Radius.circular(10.0)),
), ),
padding: const EdgeInsets.all(10), padding: const EdgeInsets.all(10),
child: Row(children: [ child: Row(children: [
@ -536,9 +566,34 @@ class WalletViewScreen extends StatelessWidget {
), ),
); );
}), }),
const Spacer(), const SizedBox(height: 12),
Row(
// const SizedBox(height: 10), children: [
Text(
'to'.tr(),
style: TextStyle(
fontSize: 19,
fontWeight: FontWeight.w500,
color: Colors.grey[600]),
),
const SizedBox(width: 10),
Column(
children: [
const SizedBox(height: 2),
Text(
toWalletData == null
? getShortPubkey(toAddress)
: toWalletData.name!,
style: const TextStyle(
fontSize: 21,
fontWeight: FontWeight.w600,
),
),
],
),
],
),
const SizedBox(height: 12),
Text( Text(
'amount'.tr(), 'amount'.tr(),
style: TextStyle( style: TextStyle(
@ -548,23 +603,22 @@ class WalletViewScreen extends StatelessWidget {
), ),
const SizedBox(height: 10), const SizedBox(height: 10),
TextField( TextField(
textInputAction: TextInputAction.done,
onEditingComplete: () async =>
canValidate ? await executeTransfert() : null,
key: keyAmountField, key: keyAmountField,
controller: walletViewProvider.payAmount, controller: walletViewProvider.payAmount,
autofocus: true, autofocus: true,
maxLines: 1, maxLines: 1,
textAlign: TextAlign.center, textAlign: TextAlign.center,
keyboardType: TextInputType.number, keyboardType: TextInputType.number,
onChanged: (_) => setState(() { onChanged: (_) => setState(() {}),
// _walletViewProvider.reload();
}),
inputFormatters: <TextInputFormatter>[ inputFormatters: <TextInputFormatter>[
// FilteringTextInputFormatter.digitsOnly,
FilteringTextInputFormatter.deny(',', FilteringTextInputFormatter.deny(',',
replacementString: '.'), replacementString: '.'),
FilteringTextInputFormatter.allow( FilteringTextInputFormatter.allow(
RegExp(r'(^\d+\.?\d{0,2})')), RegExp(r'(^\d+\.?\d{0,2})')),
], ],
// onChanged: (v) => _searchProvider.reload(),
decoration: InputDecoration( decoration: InputDecoration(
hintText: '0.00', hintText: '0.00',
suffix: Text(isUdUnit suffix: Text(isUdUnit
@ -572,25 +626,19 @@ class WalletViewScreen extends StatelessWidget {
: currencyName), // udUnitDisplay(40), : currencyName), // udUnitDisplay(40),
filled: true, filled: true,
fillColor: Colors.transparent, fillColor: Colors.transparent,
// border: OutlineInputBorder(
// borderSide:
// BorderSide(color: Colors.grey[500], width: 2),
// borderRadius: BorderRadius.circular(8)),
focusedBorder: OutlineInputBorder( focusedBorder: OutlineInputBorder(
borderSide: BorderSide( borderSide:
color: Colors.grey[500]!, width: 2), BorderSide(color: Colors.grey[500]!, width: 2),
borderRadius: BorderRadius.circular(8), borderRadius: BorderRadius.circular(8),
), ),
contentPadding: const EdgeInsets.all(20), contentPadding: const EdgeInsets.all(20),
), ),
style: const TextStyle( style: const TextStyle(
fontSize: 40, fontSize: 35,
color: Colors.black, color: Colors.black,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
), ),
), ),
// const SizedBox(height: 40),
const Spacer(), const Spacer(),
SizedBox( SizedBox(
width: double.infinity, width: double.infinity,
@ -602,51 +650,7 @@ class WalletViewScreen extends StatelessWidget {
backgroundColor: orangeC, // foreground backgroundColor: orangeC, // foreground
), ),
onPressed: canValidate onPressed: canValidate
? () async { ? () async => await executeTransfert()
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<WalletsProfilesProvider>(
context,
listen: false);
SubstrateSdk sub =
Provider.of<SubstrateSdk>(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, : null,
child: Text( child: Text(
'executeTheTransfer'.tr(), 'executeTheTransfer'.tr(),
@ -662,5 +666,4 @@ class WalletViewScreen extends StatelessWidget {
); );
}); });
}).then((value) => walletViewProvider.payAmount.text = ''); }).then((value) => walletViewProvider.payAmount.text = '');
}
} }

View File

@ -611,7 +611,7 @@ packages:
name: image_picker_android name: image_picker_android
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.8.5+2" version: "0.8.5+3"
image_picker_for_web: image_picker_for_web:
dependency: transitive dependency: transitive
description: description:
@ -826,7 +826,7 @@ packages:
name: package_info_plus_windows name: package_info_plus_windows
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.0" version: "2.1.0"
path: path:
dependency: transitive dependency: transitive
description: description:
@ -980,7 +980,7 @@ packages:
name: pointycastle name: pointycastle
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "3.6.1" version: "3.6.2"
polkawallet_sdk: polkawallet_sdk:
dependency: "direct main" dependency: "direct main"
description: description:
@ -1003,7 +1003,7 @@ packages:
name: printing name: printing
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "5.9.2" version: "5.9.3"
process: process:
dependency: transitive dependency: transitive
description: description:
@ -1096,7 +1096,7 @@ packages:
name: shared_preferences_android name: shared_preferences_android
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.12" version: "2.0.13"
shared_preferences_ios: shared_preferences_ios:
dependency: transitive dependency: transitive
description: description:
@ -1325,7 +1325,7 @@ packages:
name: win32 name: win32
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.7.0" version: "3.0.0"
xdg_directories: xdg_directories:
dependency: transitive dependency: transitive
description: description:

View File

@ -5,7 +5,7 @@ description: Pay with G1.
# pub.dev using `pub publish`. This is preferred for private packages. # 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 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: environment:
sdk: '>=2.12.0 <3.0.0' sdk: '>=2.12.0 <3.0.0'