diff --git a/assets/avatars/3.png b/assets/avatars/3.png new file mode 100755 index 0000000..47e563e Binary files /dev/null and b/assets/avatars/3.png differ diff --git a/lib/models/my_wallets.dart b/lib/models/my_wallets.dart index 886202a..c37d994 100644 --- a/lib/models/my_wallets.dart +++ b/lib/models/my_wallets.dart @@ -128,7 +128,7 @@ class MyWalletsProvider with ChangeNotifier { number: _newWalletNbr, name: _name, derivation: _newDerivationNbr, - imageName: '${_newWalletNbr % 3}.png'); + imageName: '${_newWalletNbr % 4}.png'); await walletBox.add(newWallet); diff --git a/lib/screens/myWallets/choose_chest.dart b/lib/screens/myWallets/choose_chest.dart index 479e0e4..2cd337e 100644 --- a/lib/screens/myWallets/choose_chest.dart +++ b/lib/screens/myWallets/choose_chest.dart @@ -1,18 +1,28 @@ import 'package:flutter/services.dart'; import 'package:gecko/globals.dart'; import 'package:gecko/models/my_wallets.dart'; +import 'package:gecko/models/wallet_data.dart'; import 'package:gecko/screens/common_elements.dart'; import 'package:flutter/material.dart'; +import 'package:gecko/screens/myWallets/unlocking_wallet.dart'; import 'package:gecko/screens/onBoarding/1.dart'; import 'package:carousel_slider/carousel_slider.dart'; import 'package:provider/provider.dart'; +class ChooseChest extends StatefulWidget { + const ChooseChest({Key key}) : super(key: key); + + @override + State createState() { + return _ChooseChestState(); + } +} + // ignore: must_be_immutable -class ChooseChest extends StatelessWidget { +class _ChooseChestState extends State { TextEditingController tplController = TextEditingController(); CarouselController buttonCarouselController = CarouselController(); - - ChooseChest({Key key}) : super(key: key); + int currentChest = configBox.get('currentChest'); @override Widget build(BuildContext context) { @@ -20,8 +30,6 @@ class ChooseChest extends StatelessWidget { MyWalletsProvider _myWalletProvider = Provider.of(context); - int currentChest = configBox.get('currentChest'); - return Scaffold( appBar: AppBar( title: const SizedBox( @@ -30,13 +38,14 @@ class ChooseChest extends StatelessWidget { )), body: SafeArea( child: Column(children: [ - const SizedBox(height: 190), + SizedBox(height: 160 * ratio), CarouselSlider( carouselController: buttonCarouselController, options: CarouselOptions( height: 210, onPageChanged: (index, reason) { currentChest = index; + setState(() {}); }, enableInfiniteScroll: false, initialPage: currentChest, @@ -60,14 +69,29 @@ class ChooseChest extends StatelessWidget { ); }).toList(), ), - Image.asset('assets/chests/vector.png'), - const SizedBox(height: 15), - const Text( - 'Choisir un autre\ncoffre', - textAlign: TextAlign.center, - style: TextStyle(fontSize: 13), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: chestBox.toMap().entries.map((entry) { + return GestureDetector( + onTap: () => + buttonCarouselController.animateToPage(entry.key), + child: Container( + width: 12.0, + height: 12.0, + margin: const EdgeInsets.symmetric( + vertical: 8.0, horizontal: 4.0), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: (Theme.of(context).brightness == Brightness.dark + ? Colors.white + : Colors.black) + .withOpacity( + currentChest == entry.key ? 0.9 : 0.4)), + ), + ); + }).toList(), ), - const SizedBox(height: 80), + SizedBox(height: 80 * ratio), SizedBox( width: 400, height: 70, @@ -78,11 +102,16 @@ class ChooseChest extends StatelessWidget { ), onPressed: () { configBox.put('currentChest', currentChest); + WalletData defaultWallet = _myWalletProvider + .getDefaultWallet(configBox.get('currentChest')); _myWalletProvider.rebuildWidget(); - Navigator.popUntil( - context, - ModalRoute.withName('/mywallets'), - ); + Navigator.pushAndRemoveUntil(context, + MaterialPageRoute(builder: (context) { + return UnlockingWallet( + wallet: defaultWallet, + action: "mywallets", + ); + }), ModalRoute.withName('/')); }, child: Text( 'Ouvrir ce coffre', diff --git a/lib/screens/myWallets/unlocking_wallet.dart b/lib/screens/myWallets/unlocking_wallet.dart index 7e810a2..d06eccf 100644 --- a/lib/screens/myWallets/unlocking_wallet.dart +++ b/lib/screens/myWallets/unlocking_wallet.dart @@ -1,6 +1,7 @@ import 'dart:async'; import 'package:dubp/dubp.dart'; import 'package:flutter/services.dart'; +import 'package:gecko/models/chest_data.dart'; import 'package:gecko/models/history.dart'; import 'package:gecko/models/my_wallets.dart'; import 'package:gecko/models/wallet_data.dart'; @@ -37,6 +38,7 @@ class UnlockingWallet extends StatelessWidget { // log.d("defaultWallet: " + defaultWallet.toString()); final int _pinLenght = _walletOptions.getPinLenght(wallet.number); errorController = StreamController(); + ChestData currentChest = chestBox.get(wallet.chest); return Scaffold( // backgroundColor: Colors.brown[600], @@ -45,15 +47,33 @@ class UnlockingWallet extends StatelessWidget { const SizedBox(height: 20), Expanded( child: Column(children: [ - const SizedBox(height: 150), - const Text( - 'Veuillez tapper votre code secret pour dévérouiller votre portefeuille.', - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 15.0, - color: Colors.black, - fontWeight: FontWeight.w400), - ), + const SizedBox(height: 50), + Row(mainAxisAlignment: MainAxisAlignment.center, children: [ + Image.asset( + 'assets/chests/${currentChest.imageName}', + ), + const SizedBox(width: 5), + SizedBox( + width: 250, + child: Text( + currentChest.name, + textAlign: TextAlign.center, + style: const TextStyle( + fontSize: 25, + color: Colors.black, + fontWeight: FontWeight.w700), + )), + ]), + const SizedBox(height: 50), + const SizedBox( + width: 400, + child: Text( + 'Pour déverrouiller votre coffre, composez votre code secret à l’abri des lézards indiscrets :', + style: TextStyle( + fontSize: 19, + color: Colors.black, + fontWeight: FontWeight.w400), + )), const SizedBox(height: 50), pinForm(context, _pinLenght, wallet.number, wallet.derivation), ]), diff --git a/lib/screens/myWallets/wallets_home.dart b/lib/screens/myWallets/wallets_home.dart index 81b5be9..ed2a036 100644 --- a/lib/screens/myWallets/wallets_home.dart +++ b/lib/screens/myWallets/wallets_home.dart @@ -113,7 +113,7 @@ class WalletsHome extends StatelessWidget { onPressed: () => Navigator.push( context, MaterialPageRoute(builder: (context) { - return ChooseChest(); + return const ChooseChest(); }), ), label: const Text( diff --git a/pubspec.lock b/pubspec.lock index 7ff1640..97d22f2 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -814,7 +814,7 @@ packages: name: pin_code_fields url: "https://pub.dartlang.org" source: hosted - version: "6.1.0" + version: "7.3.0" platform: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index b5a9772..92f56f5 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.2+7 +version: 0.0.2+8 environment: sdk: ">=2.7.0 <3.0.0" @@ -36,7 +36,7 @@ dependencies: path_provider: ^2.0.3 pdf: ^3.5.0 permission_handler: 8.1.6 - pin_code_fields: ^6.0.2 + pin_code_fields: ^7.3.0 printing: ^5.6.0 provider: ^6.0.0 qrscan: ^0.3.2