From 7bdd564a91aad35d9f9874321c7e48cd421fd51f Mon Sep 17 00:00:00 2001 From: poka Date: Thu, 23 Dec 2021 21:44:24 +0100 Subject: [PATCH] Adapt to large screen --- lib/main.dart | 2 +- lib/providers/chest_provider.dart | 4 +- lib/providers/generate_wallets.dart | 5 +- lib/providers/my_wallets.dart | 4 +- lib/providers/wallet_options.dart | 10 +- lib/screens/common_elements.dart | 61 +- .../myWallets/cesium_wallet_options.dart | 4 +- lib/screens/myWallets/choose_chest.dart | 2 +- lib/screens/myWallets/wallet_options.dart | 695 +++++++++--------- lib/screens/myWallets/wallets_home.dart | 32 +- lib/screens/onBoarding/10.dart | 4 +- lib/screens/onBoarding/12.dart | 12 +- lib/screens/onBoarding/5.dart | 4 +- lib/screens/onBoarding/6.dart | 7 +- lib/screens/onBoarding/7.dart | 8 +- lib/screens/search.dart | 3 +- test_driver/app_test.dart | 4 +- 17 files changed, 448 insertions(+), 413 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index c891721..e59041f 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -51,7 +51,7 @@ Future main() async { WidgetsFlutterBinding.ensureInitialized(); if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { setWindowTitle('Ğecko'); - setWindowMinSize(const Size(600, 800)); + setWindowMinSize(const Size(400, 700)); setWindowMaxSize(const Size(800, 1000)); } diff --git a/lib/providers/chest_provider.dart b/lib/providers/chest_provider.dart index 142ef4d..9c7250b 100644 --- a/lib/providers/chest_provider.dart +++ b/lib/providers/chest_provider.dart @@ -9,9 +9,9 @@ class ChestProvider with ChangeNotifier { } Future deleteChest(context, ChestData _chest) async { - final bool _answer = await (_confirmDeletingChest(context, _chest.name) as FutureOr); + final bool? _answer = await (_confirmDeletingChest(context, _chest.name)); - if (_answer) { + if (_answer!) { await chestBox.delete(_chest.key); if (chestBox.isEmpty) { await configBox.put('currentChest', 0); diff --git a/lib/providers/generate_wallets.dart b/lib/providers/generate_wallets.dart index a364cb1..91cdf8b 100644 --- a/lib/providers/generate_wallets.dart +++ b/lib/providers/generate_wallets.dart @@ -316,9 +316,9 @@ class GenerateWalletsProvider with ChangeNotifier { return bip39Words.contains(word); } - bool isBipWordsList(List words) { + bool isBipWordsList(List words) { bool isValid = true; - for (String word in words as Iterable) { + for (String word in words) { // Needed for bad encoding of UTF-8 word = word.replaceAll('é', 'é'); word = word.replaceAll('è', 'è'); @@ -380,6 +380,7 @@ class GenerateWalletsProvider with ChangeNotifier { if (generatedWallet == null) { return false; } else { + generatedMnemonic = inputMnemonic; return true; } } diff --git a/lib/providers/my_wallets.dart b/lib/providers/my_wallets.dart index d1d5e7c..3313304 100644 --- a/lib/providers/my_wallets.dart +++ b/lib/providers/my_wallets.dart @@ -65,8 +65,8 @@ class MyWalletsProvider with ChangeNotifier { try { log.w('DELETE ALL WALLETS ?'); - final bool _answer = await (_confirmDeletingAllWallets(context) as FutureOr); - if (_answer) { + final bool? _answer = await (_confirmDeletingAllWallets(context)); + if (_answer!) { await walletBox.clear(); await chestBox.clear(); await configBox.delete('defaultWallet'); diff --git a/lib/providers/wallet_options.dart b/lib/providers/wallet_options.dart index 5427c31..c18f062 100644 --- a/lib/providers/wallet_options.dart +++ b/lib/providers/wallet_options.dart @@ -108,6 +108,11 @@ class WalletOptionsProvider with ChangeNotifier { return pinLength; } + Future getBalance(String pubkey, {bool isUd = false}) async { + final node = Gva(node: endPointGVA); + return await node.balance(pubkey, ud: isUd); + } + void _renameWallet(List _walletID, _newName, {required bool isCesium}) async { if (isCesium) { @@ -145,10 +150,9 @@ class WalletOptionsProvider with ChangeNotifier { } Future deleteWallet(context, WalletData wallet) async { - final bool _answer = - await (_confirmDeletingWallet(context, wallet.name) as FutureOr); + final bool? _answer = await (_confirmDeletingWallet(context, wallet.name)); - if (_answer) { + if (_answer!) { walletBox.delete(wallet.key); Navigator.popUntil( diff --git a/lib/screens/common_elements.dart b/lib/screens/common_elements.dart index c9e040b..009eb48 100644 --- a/lib/screens/common_elements.dart +++ b/lib/screens/common_elements.dart @@ -8,39 +8,46 @@ class CommonElements { return const Text('Coucou'); } - Widget bubbleSpeak(String text, {double? long, Key? textKey}) { - return Bubble( - padding: long == null - ? const BubbleEdges.all(18) - : BubbleEdges.symmetric(horizontal: long, vertical: 30), - elevation: 5, - color: Colors.white, - margin: const BubbleEdges.fromLTRB(10, 0, 20, 10), - // nip: BubbleNip.leftTop, - child: Text( - text, - key: textKey, - style: const TextStyle( - color: Colors.black, fontSize: 18, fontWeight: FontWeight.w400), + Widget bubbleSpeak(String text, + {double? long, Key? textKey, bool isMaxWidth = true}) { + return SizedBox( + width: isMaxWidth ? double.infinity : 300, + child: Bubble( + padding: long == null + ? const BubbleEdges.all(18) + : BubbleEdges.symmetric(horizontal: long, vertical: 30), + elevation: 5, + color: Colors.white, + margin: const BubbleEdges.fromLTRB(10, 0, 20, 10), + // nip: BubbleNip.leftTop, + child: Text( + text, + key: textKey, + style: const TextStyle( + color: Colors.black, fontSize: 18, fontWeight: FontWeight.w400), + ), ), ); } Widget bubbleSpeakRich(List text, {Key? textKey}) { - return Bubble( - padding: const BubbleEdges.all(18), - elevation: 5, - color: Colors.white, - margin: const BubbleEdges.fromLTRB(10, 0, 20, 10), - // nip: BubbleNip.leftTop, - child: RichText( - key: textKey, - text: TextSpan( - style: const TextStyle( - fontSize: 18.0, - color: Colors.black, + return SizedBox( + width: double.infinity, + child: Bubble( + padding: const BubbleEdges.all(18), + elevation: 5, + color: Colors.white, + margin: const BubbleEdges.fromLTRB(10, 0, 20, 10), + // nip: BubbleNip.leftTop, + child: RichText( + key: textKey, + text: TextSpan( + style: const TextStyle( + fontSize: 18.0, + color: Colors.black, + ), + children: text, ), - children: text, ), ), ); diff --git a/lib/screens/myWallets/cesium_wallet_options.dart b/lib/screens/myWallets/cesium_wallet_options.dart index a08143a..5e9eff4 100644 --- a/lib/screens/myWallets/cesium_wallet_options.dart +++ b/lib/screens/myWallets/cesium_wallet_options.dart @@ -106,7 +106,7 @@ class CesiumWalletOptions extends StatelessWidget { const SizedBox(width: 25), InkWell( onTap: () async { - File newAvatar = await (_walletOptions.changeAvatar() as FutureOr); + File newAvatar = await (_walletOptions.changeAvatar()); cesiumWallet.imageFile = newAvatar; _walletOptions.reloadBuild(); }, @@ -119,7 +119,7 @@ class CesiumWalletOptions extends StatelessWidget { ), InkWell( onTap: () async { - File newAvatar = await (_walletOptions.changeAvatar() as FutureOr); + File newAvatar = await (_walletOptions.changeAvatar()); cesiumWallet.imageFile = newAvatar; _walletOptions.reloadBuild(); }, diff --git a/lib/screens/myWallets/choose_chest.dart b/lib/screens/myWallets/choose_chest.dart index a077369..c9b7aad 100644 --- a/lib/screens/myWallets/choose_chest.dart +++ b/lib/screens/myWallets/choose_chest.dart @@ -53,7 +53,7 @@ class _ChooseChestState extends State { enableInfiniteScroll: false, initialPage: currentChest!, enlargeCenterPage: true, - viewportFraction: 0.6, + viewportFraction: 0.5, ), items: chestBox.toMap().entries.map((i) { return Builder( diff --git a/lib/screens/myWallets/wallet_options.dart b/lib/screens/myWallets/wallet_options.dart index 519e212..c7da2fb 100644 --- a/lib/screens/myWallets/wallet_options.dart +++ b/lib/screens/myWallets/wallet_options.dart @@ -4,23 +4,18 @@ import 'dart:ui'; import 'package:flutter/material.dart'; import 'package:gecko/globals.dart'; import 'package:gecko/providers/my_wallets.dart'; -import 'package:gecko/models/queries.dart'; import 'package:gecko/models/wallet_data.dart'; import 'package:gecko/providers/wallet_options.dart'; import 'package:gecko/providers/wallets_profiles.dart'; import 'package:gecko/screens/history.dart'; -import 'package:graphql_flutter/graphql_flutter.dart'; import 'package:provider/provider.dart'; import 'package:flutter/services.dart'; import 'package:qr_flutter/qr_flutter.dart'; -// ignore: must_be_immutable class WalletOptions extends StatelessWidget { - WalletOptions({Key? keyMyWallets, required this.wallet}) + const WalletOptions({Key? keyMyWallets, required this.wallet}) : super(key: keyMyWallets); - WalletData wallet; - int _nbrLinesName = 1; - bool _isNewNameValid = false; + final WalletData wallet; @override Widget build(BuildContext context) { @@ -32,33 +27,13 @@ class WalletOptions extends StatelessWidget { MyWalletsProvider _myWalletProvider = Provider.of(context); + + _walletOptions.pubkey.text = log.d(_walletOptions.pubkey.text); - final int? _currentChest = _myWalletProvider.getCurrentChest(); - final String shortPubkey = - _walletOptions.getShortPubkey(_walletOptions.pubkey.text); + final int _currentChest = _myWalletProvider.getCurrentChest()!; - if (_isNewNameValid == false) { - _walletOptions.nameController.text = wallet.name!; - } else { - wallet.name = _walletOptions.nameController.text; - } - - _walletOptions.nameController.text.length >= 15 - ? _nbrLinesName = 2 - : _nbrLinesName = 1; - if (_walletOptions.nameController.text.length >= 26 && isTall) { - _nbrLinesName = 3; - } - - WalletData defaultWallet = - _myWalletProvider.getDefaultWallet(_currentChest)!; - - _walletOptions.isDefaultWallet = (defaultWallet.number == wallet.id()[1]); - - int? currentChest = _myWalletProvider.getCurrentChest(); - - log.d("Wallet options: $currentChest:${wallet.number}"); + log.d("Wallet options: $_currentChest:${wallet.number}"); return WillPopScope( onWillPop: () { @@ -112,167 +87,21 @@ class WalletOptions extends StatelessWidget { const Color(0xfffafafa), ], )), - child: Row(children: [ - const SizedBox(width: 25), - InkWell( - onTap: () async { - File newAvatar = await (walletProvider.changeAvatar() as FutureOr); - wallet.imageFile = newAvatar; - walletProvider.reloadBuild(); - }, - child: wallet.imageFile == null - ? Image.asset( - 'assets/avatars/${wallet.imageName}', - width: 110, - ) - : Image.file( - wallet.imageFile!, - width: 110, - ), - ), - InkWell( - onTap: () async { - File newAvatar = await (walletProvider.changeAvatar() as FutureOr); - wallet.imageFile = newAvatar; - walletProvider.reloadBuild(); - }, - child: Column(children: [ - Image.asset( - 'assets/walletOptions/camera.png', - height: 40, - ), - const SizedBox(height: 80) - ])), - Column(children: [ - Row(children: [ + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + const Spacer(), + avatar(walletProvider), + const Spacer(), Column(children: [ - SizedBox( - width: 260, - child: TextField( - key: const Key('walletName'), - autofocus: false, - focusNode: walletProvider.walletNameFocus, - enabled: walletProvider.isEditing, - controller: walletProvider.nameController, - maxLines: _nbrLinesName, - textAlign: TextAlign.center, - decoration: const InputDecoration( - border: InputBorder.none, - focusedBorder: InputBorder.none, - enabledBorder: InputBorder.none, - disabledBorder: InputBorder.none, - contentPadding: EdgeInsets.all(15.0), - ), - style: TextStyle( - fontSize: isTall ? 27 : 23, - color: Colors.black, - fontWeight: FontWeight.w400, - fontFamily: 'Monospace')), - ), + walletName(walletProvider, _walletOptions), SizedBox(height: isTall ? 5 : 0), - Query( - options: QueryOptions( - document: gql(getBalance), - variables: { - 'pubkey': walletProvider.pubkey.text, - }, - // pollInterval: Duration(seconds: 1), - ), - builder: (QueryResult result, - {VoidCallback? refetch, FetchMore? fetchMore}) { - if (result.hasException) { - return Text(result.exception.toString()); - } - - if (result.isLoading) { - return const Text('Loading'); - } - - // List repositories = result.data['viewer']['repositories']['nodes']; - String wBalanceUD; - if (result.data!['balance'] == null) { - wBalanceUD = '0.0'; - } else if (result.hasException) { - wBalanceUD = '?'; - } else { - int wBalanceG1 = - result.data!['balance']['amount']; - int currentUD = - result.data!['currentUd']['amount']; - double wBalanceUDBrut = - wBalanceG1 / currentUD; // .toString(); - wBalanceUD = double.parse( - (wBalanceUDBrut).toStringAsFixed(2)) - .toString(); - } - return Row(children: [ - ImageFiltered( - imageFilter: ImageFilter.blur( - sigmaX: - walletProvider.isBalanceBlur ? 6 : 0.001, - sigmaY: - walletProvider.isBalanceBlur ? 5 : 0.001), - child: Text( - wBalanceUD, - style: TextStyle( - fontSize: isTall ? 20 : 18, - color: Colors.black), - ), - ), - Text(' DU', - style: TextStyle( - fontSize: isTall ? 20 : 18, - color: Colors.black)) - ]); - - // Text( - // '$wBalanceUD DU', - // style: TextStyle( - // fontSize: 20, color: Colors.black), - // ); - }, - ), - const SizedBox(height: 5), - InkWell( - key: const Key('displayBalance'), - onTap: () { - walletProvider.bluringBalance(); - }, - child: Image.asset( - walletProvider.isBalanceBlur - ? 'assets/walletOptions/icon_oeuil.png' - : 'assets/walletOptions/icon_oeuil_close.png', - height: 35, - ), - ), + balance(walletProvider), ]), - const SizedBox(width: 0), - Column(children: [ - InkWell( - key: const Key('renameWallet'), - onTap: () async { - _isNewNameValid = walletProvider.editWalletName( - wallet.id(), - isCesium: false); - await Future.delayed( - const Duration(milliseconds: 30)); - walletProvider.walletNameFocus.requestFocus(); - }, - child: ClipRRect( - child: Image.asset( - walletProvider.isEditing - ? 'assets/walletOptions/android-checkmark.png' - : 'assets/walletOptions/edit.png', - width: 20, - height: 20), - )), - const SizedBox( - height: 60, - ) - ]) + const Spacer(), + const Spacer(), + const Spacer(), ]), - ]), - ]), ); }), SizedBox(height: 4 * ratio), @@ -285,169 +114,16 @@ class WalletOptions extends StatelessWidget { Consumer( builder: (context, walletProvider, _) { return Column(children: [ - GestureDetector( - key: const Key('copyPubkey'), - onTap: () { - Clipboard.setData( - ClipboardData(text: walletProvider.pubkey.text)); - walletProvider.snackCopyKey(ctx); - }, - child: SizedBox( - height: 50, - child: Row(children: [ - const SizedBox(width: 30), - Image.asset( - 'assets/walletOptions/key.png', - height: 45, - ), - const SizedBox(width: 20), - Text("${shortPubkey.split(':')[0]}:", - style: const TextStyle( - fontSize: 22, - fontWeight: FontWeight.w800, - fontFamily: 'Monospace', - color: Colors.black)), - Text(shortPubkey.split(':')[1], - style: const TextStyle( - fontSize: 22, - fontWeight: FontWeight.w800, - fontFamily: 'Monospace')), - const SizedBox(width: 15), - SizedBox( - height: 40, - child: ElevatedButton( - style: ElevatedButton.styleFrom( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(8), - ), - elevation: 1, - primary: orangeC, // background - onPrimary: Colors.black, // foreground - ), - onPressed: () { - Clipboard.setData(ClipboardData( - text: walletProvider.pubkey.text)); - walletProvider.snackCopyKey(ctx); - }, - child: Row(children: [ - Image.asset( - 'assets/walletOptions/copy-white.png', - height: 25, - ), - const SizedBox(width: 7), - Text( - 'Copier', - style: TextStyle( - fontSize: 15, color: Colors.grey[50]), - ) - ]), - ), - ), - ]), - ), - ), + pubkeyWidget(walletProvider, ctx), SizedBox(height: 10 * ratio), - InkWell( - key: const Key('displayHistory'), - onTap: () { - _historyProvider.nPage = 1; - Navigator.push( - context, - MaterialPageRoute(builder: (context) { - return HistoryScreen( - pubkey: walletProvider.pubkey.text, - avatar: wallet.imageFile == null - ? Image.asset( - 'assets/avatars/${wallet.imageName}', - width: 110, - ) - : Image.file( - wallet.imageFile!, - width: 110, - )); - }), - ); - }, - child: SizedBox( - height: 50, - child: Row(children: [ - const SizedBox(width: 30), - Image.asset( - 'assets/walletOptions/clock.png', - height: 45, - ), - const SizedBox(width: 22), - const Text('Historique des transactions', - style: - TextStyle(fontSize: 20, color: Colors.black)), - ]), - ), - ), + historyWidget(context, _historyProvider, walletProvider), SizedBox(height: 12 * ratio), - InkWell( - key: const Key('setDefaultWallet'), - onTap: !walletProvider.isDefaultWallet - ? () { - defaultWallet = wallet; - chestBox.get(currentChest)!.defaultWallet = - wallet.number; - _myWalletProvider.readAllWallets(_currentChest); - _myWalletProvider.rebuildWidget(); - } - : null, - child: SizedBox( - height: 50, - child: Row(children: [ - const SizedBox(width: 31), - CircleAvatar( - backgroundColor: Colors - .grey[walletProvider.isDefaultWallet ? 300 : 500], - child: Image.asset( - 'assets/walletOptions/android-checkmark.png', - height: 25, - ), - ), - const SizedBox(width: 22), - Text( - walletProvider.isDefaultWallet - ? 'Ce portefeuille est celui par defaut' - : 'Définir comme portefeuille par défaut', - style: TextStyle( - fontSize: 20, - color: walletProvider.isDefaultWallet - ? Colors.grey[500] - : Colors.black)), - ]), - ), - ), + setDefaultWallet(walletProvider, _myWalletProvider, + _walletOptions, _currentChest), SizedBox(height: 17 * ratio), if (!walletProvider.isDefaultWallet) - InkWell( - key: const Key('deleteWallet'), - onTap: !walletProvider.isDefaultWallet - ? () async { - await walletProvider.deleteWallet( - context, wallet); - WidgetsBinding.instance!.addPostFrameCallback((_) { - _myWalletProvider.listWallets = - _myWalletProvider - .readAllWallets(_currentChest); - _myWalletProvider.rebuildWidget(); - }); - } - : null, - child: Row(children: [ - const SizedBox(width: 30), - Image.asset( - 'assets/walletOptions/trash.png', - height: 45, - ), - const SizedBox(width: 19), - const Text('Supprimer ce portefeuille', - style: TextStyle( - fontSize: 20, color: Color(0xffD80000))), - ]), - ), + deleteWallet(context, walletProvider, _myWalletProvider, + _currentChest) ]); }), ]), @@ -456,4 +132,329 @@ class WalletOptions extends StatelessWidget { ), ); } + + Widget avatar(WalletOptionsProvider walletProvider) { + return Stack( + children: [ + InkWell( + onTap: () async { + File newAvatar = + await (walletProvider.changeAvatar()); + wallet.imageFile = newAvatar; + walletProvider.reloadBuild(); + }, + child: wallet.imageFile == null + ? Image.asset( + 'assets/avatars/${wallet.imageName}', + width: 110, + ) + : Image.file( + wallet.imageFile!, + width: 110, + ), + ), + Positioned( + right: 0, + child: InkWell( + onTap: () async { + File newAvatar = + await (walletProvider.changeAvatar()); + wallet.imageFile = newAvatar; + walletProvider.reloadBuild(); + }, + child: Image.asset( + 'assets/walletOptions/camera.png', + height: 40, + ), + ), + ), + ], + ); + } + + Widget walletName(WalletOptionsProvider walletProvider, + WalletOptionsProvider _walletOptions) { + int _nbrLinesName = 1; + _walletOptions.nameController.text.length >= 15 + ? _nbrLinesName = 2 + : _nbrLinesName = 1; + if (_walletOptions.nameController.text.length >= 26 && isTall) { + _nbrLinesName = 3; + } + bool _isNewNameValid = false; + if (_isNewNameValid == false) { + _walletOptions.nameController.text = wallet.name!; + } else { + wallet.name = _walletOptions.nameController.text; + } + + return SizedBox( + width: 260, + child: Stack(children: [ + TextField( + key: const Key('walletName'), + autofocus: false, + focusNode: walletProvider.walletNameFocus, + enabled: walletProvider.isEditing, + controller: walletProvider.nameController, + maxLines: _nbrLinesName, + textAlign: TextAlign.center, + decoration: const InputDecoration( + border: InputBorder.none, + focusedBorder: InputBorder.none, + enabledBorder: InputBorder.none, + disabledBorder: InputBorder.none, + contentPadding: EdgeInsets.all(15.0), + ), + style: TextStyle( + fontSize: isTall ? 27 : 23, + color: Colors.black, + fontWeight: FontWeight.w400, + fontFamily: 'Monospace'), + ), + Positioned( + right: 0, + child: InkWell( + key: const Key('renameWallet'), + onTap: () async { + _isNewNameValid = + walletProvider.editWalletName(wallet.id(), isCesium: false); + await Future.delayed(const Duration(milliseconds: 30)); + walletProvider.walletNameFocus.requestFocus(); + }, + child: ClipRRect( + child: Image.asset( + walletProvider.isEditing + ? 'assets/walletOptions/android-checkmark.png' + : 'assets/walletOptions/edit.png', + width: 20, + height: 20), + ), + ), + ), + ]), + ); + } + + Widget balance(WalletOptionsProvider walletProvider) { + return Column(children: [ + FutureBuilder( + future: walletProvider.getBalance(walletProvider.pubkey.text), + builder: (BuildContext context, AsyncSnapshot _balance) { + if (_balance.connectionState != ConnectionState.done || + _balance.hasError) { + return Text('', + style: TextStyle( + fontSize: isTall ? 20 : 18, + )); + } + return ImageFiltered( + imageFilter: ImageFilter.blur( + sigmaX: walletProvider.isBalanceBlur ? 6 : 0, + sigmaY: walletProvider.isBalanceBlur ? 5 : 0), + child: Text( + _balance.data.toString() + ' DU', + style: TextStyle( + fontSize: isTall ? 20 : 18, + ), + ), + ); + }), + const SizedBox(height: 5), + InkWell( + key: const Key('displayBalance'), + onTap: () { + walletProvider.bluringBalance(); + }, + child: Image.asset( + walletProvider.isBalanceBlur + ? 'assets/walletOptions/icon_oeuil.png' + : 'assets/walletOptions/icon_oeuil_close.png', + height: 35, + ), + ), + ]); + } + + Widget pubkeyWidget(WalletOptionsProvider walletProvider, BuildContext ctx) { + final String shortPubkey = + walletProvider.getShortPubkey(walletProvider.pubkey.text); + return GestureDetector( + key: const Key('copyPubkey'), + onTap: () { + Clipboard.setData(ClipboardData(text: walletProvider.pubkey.text)); + walletProvider.snackCopyKey(ctx); + }, + child: SizedBox( + height: 50, + child: Row(children: [ + const SizedBox(width: 30), + Image.asset( + 'assets/walletOptions/key.png', + height: 45, + ), + const SizedBox(width: 20), + Text("${shortPubkey.split(':')[0]}:", + style: const TextStyle( + fontSize: 22, + fontWeight: FontWeight.w800, + fontFamily: 'Monospace', + color: Colors.black)), + Text(shortPubkey.split(':')[1], + style: const TextStyle( + fontSize: 22, + fontWeight: FontWeight.w800, + fontFamily: 'Monospace')), + const SizedBox(width: 15), + SizedBox( + height: 40, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), + elevation: 1, + primary: orangeC, // background + onPrimary: Colors.black, // foreground + ), + onPressed: () { + Clipboard.setData( + ClipboardData(text: walletProvider.pubkey.text)); + walletProvider.snackCopyKey(ctx); + }, + child: Row(children: [ + Image.asset( + 'assets/walletOptions/copy-white.png', + height: 25, + ), + const SizedBox(width: 7), + Text( + 'Copier', + style: TextStyle(fontSize: 15, color: Colors.grey[50]), + ) + ]), + ), + ), + ]), + ), + ); + } + + Widget historyWidget( + BuildContext context, + WalletsProfilesProvider _historyProvider, + WalletOptionsProvider walletProvider) { + return InkWell( + key: const Key('displayHistory'), + onTap: () { + _historyProvider.nPage = 1; + Navigator.push( + context, + MaterialPageRoute(builder: (context) { + return HistoryScreen( + pubkey: walletProvider.pubkey.text, + avatar: wallet.imageFile == null + ? Image.asset( + 'assets/avatars/${wallet.imageName}', + width: 110, + ) + : Image.file( + wallet.imageFile!, + width: 110, + )); + }), + ); + }, + child: SizedBox( + height: 50, + child: Row(children: [ + const SizedBox(width: 30), + Image.asset( + 'assets/walletOptions/clock.png', + height: 45, + ), + const SizedBox(width: 22), + const Text('Historique des transactions', + style: TextStyle(fontSize: 20, color: Colors.black)), + ]), + ), + ); + } + + Widget setDefaultWallet( + WalletOptionsProvider walletProvider, + MyWalletsProvider _myWalletProvider, + WalletOptionsProvider _walletOptions, + int _currentChest) { + WalletData defaultWallet = + _myWalletProvider.getDefaultWallet(_currentChest)!; + + _walletOptions.isDefaultWallet = (defaultWallet.number == wallet.id()[1]); + + return InkWell( + key: const Key('setDefaultWallet'), + onTap: !walletProvider.isDefaultWallet + ? () { + defaultWallet = wallet; + chestBox.get(_currentChest)!.defaultWallet = wallet.number; + _myWalletProvider.readAllWallets(_currentChest); + _myWalletProvider.rebuildWidget(); + } + : null, + child: SizedBox( + height: 50, + child: Row(children: [ + const SizedBox(width: 31), + CircleAvatar( + backgroundColor: + Colors.grey[walletProvider.isDefaultWallet ? 300 : 500], + child: Image.asset( + 'assets/walletOptions/android-checkmark.png', + height: 25, + ), + ), + const SizedBox(width: 22), + Text( + walletProvider.isDefaultWallet + ? 'Ce portefeuille est celui par defaut' + : 'Définir comme portefeuille par défaut', + style: TextStyle( + fontSize: 20, + color: walletProvider.isDefaultWallet + ? Colors.grey[500] + : Colors.black)), + ]), + ), + ); + } + + Widget deleteWallet( + BuildContext context, + WalletOptionsProvider walletProvider, + MyWalletsProvider _myWalletProvider, + int _currentChest) { + return InkWell( + key: const Key('deleteWallet'), + onTap: !walletProvider.isDefaultWallet + ? () async { + await walletProvider.deleteWallet(context, wallet); + WidgetsBinding.instance!.addPostFrameCallback((_) { + _myWalletProvider.listWallets = + _myWalletProvider.readAllWallets(_currentChest); + _myWalletProvider.rebuildWidget(); + }); + } + : null, + child: Row(children: [ + const SizedBox(width: 30), + Image.asset( + 'assets/walletOptions/trash.png', + height: 45, + ), + const SizedBox(width: 19), + const Text('Supprimer ce portefeuille', + style: TextStyle(fontSize: 20, color: Color(0xffD80000))), + ]), + ); + } } diff --git a/lib/screens/myWallets/wallets_home.dart b/lib/screens/myWallets/wallets_home.dart index 95c2ec6..6fbcad9 100644 --- a/lib/screens/myWallets/wallets_home.dart +++ b/lib/screens/myWallets/wallets_home.dart @@ -68,11 +68,12 @@ class WalletsHome extends StatelessWidget { return Column(children: [ const SizedBox(height: 50), SizedBox( - height: 120, - width: 445, + height: 90, + width: 420, child: ElevatedButton.icon( icon: Image.asset( 'assets/chests/config.png', + height: 60, ), style: ElevatedButton.styleFrom( elevation: 2, @@ -86,9 +87,9 @@ class WalletsHome extends StatelessWidget { }), ), label: const Text( - " Paramétrer ce coffre", + " Paramétrer ce coffre", style: TextStyle( - fontSize: 25, + fontSize: 22, fontWeight: FontWeight.w700, color: Color(0xff8a3c0f), ), @@ -96,10 +97,13 @@ class WalletsHome extends StatelessWidget { )), const SizedBox(height: 30), SizedBox( - height: 120, - width: 445, + height: 90, + width: 420, child: ElevatedButton.icon( - icon: Image.asset('assets/chests/miniChests.png'), + icon: Image.asset( + 'assets/chests/miniChests.png', + height: 70, + ), style: ElevatedButton.styleFrom( elevation: 2, primary: floattingYellow, // background @@ -112,9 +116,9 @@ class WalletsHome extends StatelessWidget { }), ), label: const Text( - " Changer de coffre", + " Changer de coffre", style: TextStyle( - fontSize: 25, + fontSize: 22, fontWeight: FontWeight.w700, color: Color(0xff8a3c0f), ), @@ -148,12 +152,20 @@ class WalletsHome extends StatelessWidget { List _listWallets = _myWalletProvider.listWallets; WalletData? defaultWallet = _myWalletProvider.getDefaultWallet(configBox.get('currentChest')); + final double screenWidth = MediaQuery.of(context).size.width; + int nTule = 2; + + if (screenWidth >= 900) { + nTule = 4; + } else if (screenWidth >= 650) { + nTule = 3; + } return CustomScrollView(slivers: [ const SliverToBoxAdapter(child: SizedBox(height: 20)), SliverGrid.count( key: const Key('listWallets'), - crossAxisCount: 2, + crossAxisCount: nTule, childAspectRatio: 1, crossAxisSpacing: 0, mainAxisSpacing: 0, diff --git a/lib/screens/onBoarding/10.dart b/lib/screens/onBoarding/10.dart index 8392644..4f4aff0 100644 --- a/lib/screens/onBoarding/10.dart +++ b/lib/screens/onBoarding/10.dart @@ -31,7 +31,7 @@ class OnboardingStepTwelve extends StatelessWidget { const SizedBox(height: 10), Image.asset( 'assets/onBoarding/plusieurs-codes-secrets-un-trousseau.png', - height: 410 * ratio, + height: isTall ? 410 : 380, ), Expanded( child: Align( @@ -57,7 +57,7 @@ class OnboardingStepTwelve extends StatelessWidget { child: const Text("Générer le code secret", style: TextStyle(fontSize: 20))), ))), - SizedBox(height: isTall ? 80 : 40), + const SizedBox(height: 80), ]), )); } diff --git a/lib/screens/onBoarding/12.dart b/lib/screens/onBoarding/12.dart index 97b66f5..0bedd13 100644 --- a/lib/screens/onBoarding/12.dart +++ b/lib/screens/onBoarding/12.dart @@ -112,7 +112,7 @@ class OnboardingStepFourteen extends StatelessWidget { ) ], onCompleted: (_pin) async { - _myWalletProvider.pinCode = _pin; + _myWalletProvider.pinCode = _pin.toUpperCase(); _myWalletProvider.pinLenght = _pinLenght; log.d(_pin + ' || ' + _generateWalletProvider.pin.text); if (_pin.toUpperCase() == _generateWalletProvider.pin.text) { @@ -124,10 +124,12 @@ class OnboardingStepFourteen extends StatelessWidget { await _generateWalletProvider.storeHDWChest( generatedWallet, 'Mon portefeuille courant', context); _myWalletProvider.readAllWallets(_currentChest); - scheduleMicrotask(() { - _walletOptions.reloadBuild(); - _myWalletProvider.rebuildWidget(); - }); + // scheduleMicrotask(() { + _walletOptions.reloadBuild(); + // _myWalletProvider.rebuildWidget(); + // }); + _generateWalletProvider.generatedMnemonic = + _generateWalletProvider.pin.text = ''; Navigator.push( context, FaderTransition( diff --git a/lib/screens/onBoarding/5.dart b/lib/screens/onBoarding/5.dart index 7ca67f6..af8c3ad 100644 --- a/lib/screens/onBoarding/5.dart +++ b/lib/screens/onBoarding/5.dart @@ -43,8 +43,8 @@ class OnboardingStepSeven extends StatelessWidget { Container( padding: const EdgeInsets.only(bottom: 90), child: common.bubbleSpeak( - "Moi, j’ai déjà essayé de\nmémoriser une phrase de\nrestauration, mais je n’ai\npas une mémoire\nd’éléphant.", - ), + "Moi, j’ai déjà essayé de\nmémoriser une phrase de\nrestauration, mais je n’ai\npas une mémoire\nd’éléphant.", + isMaxWidth: false), ), Image.asset( 'assets/onBoarding/chopp-gecko.png', diff --git a/lib/screens/onBoarding/6.dart b/lib/screens/onBoarding/6.dart index 0c677a5..dc2b119 100644 --- a/lib/screens/onBoarding/6.dart +++ b/lib/screens/onBoarding/6.dart @@ -29,7 +29,7 @@ class OnboardingStepEight extends StatelessWidget { "J’ai généré votre phrase de restauration !\nTâchez de la garder bien secrète, car elle permet à quiconque la connaît d’accéder à tous vos portefeuilles.", textKey: const Key('step6'), ), - SizedBox(height: isTall ? 61 : 31), + SizedBox(height: isTall ? 70 : 40), // SizedBox(height: 30), sentanceArray(context), // ), @@ -63,9 +63,10 @@ class OnboardingStepEight extends StatelessWidget { } Widget sentanceArray(BuildContext context) { - return Container( + return Padding( padding: const EdgeInsets.symmetric(horizontal: 12), child: Container( + constraints: const BoxConstraints(maxWidth: 450), decoration: BoxDecoration( border: Border.all(color: Colors.black), color: Colors.grey[300], @@ -116,7 +117,7 @@ Widget arrayCell(dataWord) { ImageFiltered( imageFilter: ImageFilter.blur(sigmaX: 4, sigmaY: 4), child: Text(dataWord.split(':')[1], - style: const TextStyle(fontSize: 20, color: Colors.black)), + style: const TextStyle(fontSize: 19, color: Colors.black)), ) ], )); diff --git a/lib/screens/onBoarding/7.dart b/lib/screens/onBoarding/7.dart index c2d96c3..7d7d39f 100644 --- a/lib/screens/onBoarding/7.dart +++ b/lib/screens/onBoarding/7.dart @@ -115,9 +115,10 @@ Widget sentanceArray(BuildContext context) { List formatedArray = _generateWalletProvider.generateWordList(); - return Container( + return Padding( padding: const EdgeInsets.symmetric(horizontal: 12), child: Container( + constraints: const BoxConstraints(maxWidth: 450), decoration: BoxDecoration( border: Border.all(color: Colors.black), color: Colors.grey[300], @@ -187,6 +188,11 @@ class PrintWallet extends StatelessWidget { return MaterialApp( home: Scaffold( appBar: AppBar( + leading: IconButton( + icon: const Icon(Icons.arrow_back, color: Colors.white), + onPressed: () { + Navigator.pop(context); + }), toolbarHeight: 60 * ratio, title: const Text('Imprimer ce trousseau')), body: PdfPreview( diff --git a/lib/screens/search.dart b/lib/screens/search.dart index 25a2513..d98b98a 100644 --- a/lib/screens/search.dart +++ b/lib/screens/search.dart @@ -14,6 +14,7 @@ class SearchScreen extends StatelessWidget { Widget build(BuildContext context) { SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); SearchProvider _searchProvider = Provider.of(context); + final double screenHeight = MediaQuery.of(context).size.height; return WillPopScope( onWillPop: () { @@ -101,7 +102,7 @@ class SearchScreen extends StatelessWidget { ), ), ), - const Spacer(flex: 1), + Spacer(flex: screenHeight <= 800 ? 1 : 2), ]), ), )); diff --git a/test_driver/app_test.dart b/test_driver/app_test.dart index 029b13a..ce2e990 100644 --- a/test_driver/app_test.dart +++ b/test_driver/app_test.dart @@ -440,9 +440,9 @@ void main() { await goBack(); await deleteAllWallets(); await sleep(100); - final String pincode = await (createNewKeychain('Fast wallet') as FutureOr); + final String? pincode = await (createNewKeychain('Fast wallet')); await sleep(200); - await driver!.enterText(pincode); + await driver!.enterText(pincode!); await sleep(100); await createDerivation(); await sleep(100);