diff --git a/android/app/build.gradle b/android/app/build.gradle index 76c91a5..ecf1475 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -65,7 +65,7 @@ android { release { // TODO: Add your own signing config for the release build. // Signing with the debug keys for now, so `flutter run --release` works. - signingConfig signingConfigs.release //poka: comment this to build unsigned release, or set to signingConfigs.debug to sign with debug keys + signingConfig signingConfigs.debug //poka: comment this to build unsigned release, or set to signingConfigs.debug to sign with debug keys useProguard true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' diff --git a/lib/providers/home.dart b/lib/providers/home.dart index 2731b64..854d1ae 100644 --- a/lib/providers/home.dart +++ b/lib/providers/home.dart @@ -28,6 +28,7 @@ class HomeProvider with ChangeNotifier { Widget appBarExplorer = Text('Explorateur', style: TextStyle(color: Colors.grey[850])); String homeMessage = "y'a pas de lézard ;-)"; + String defaultMessage = "y'a pas de lézard ;-)"; Future initHive() async { late Directory hivePath; @@ -74,11 +75,10 @@ class HomeProvider with ChangeNotifier { } Future changeMessage(String newMessage, int seconds) async { - final oldMessage = homeMessage; homeMessage = newMessage; notifyListeners(); await Future.delayed(Duration(seconds: seconds)); - homeMessage = oldMessage; + if (seconds != 0) homeMessage = defaultMessage; notifyListeners(); } diff --git a/lib/providers/substrate_sdk.dart b/lib/providers/substrate_sdk.dart index 9863596..4b28bad 100644 --- a/lib/providers/substrate_sdk.dart +++ b/lib/providers/substrate_sdk.dart @@ -50,6 +50,8 @@ class SubstrateSdk with ChangeNotifier { List node = []; HomeProvider _homeProvider = Provider.of(ctx, listen: false); + _homeProvider.changeMessage("Connexion en cours...", 0); + for (String _endpoint in configBox.get('endpoint')) { final n = NetworkParams(); n.name = currencyName; @@ -98,16 +100,22 @@ class SubstrateSdk with ChangeNotifier { // Subscribe bloc number sdk.api.setting.subscribeBestNumber((res) { blocNumber = int.parse(res.toString()); + if (sdk.api.connectedNode?.endpoint == null) { + _homeProvider.changeMessage("Le réseau a été perdu...", 0); + } + notifyListeners(); }); notifyListeners(); - _homeProvider.changeMessage('Vous êtes bien connecté', 3); + _homeProvider.changeMessage( + 'Vous êtes bien connecté aux noeud\n${getConnectedEndpoint()!.split('/')[2]}', + 5); // snackNode(ctx, true); } else { nodeConnected = false; debugConnection = res.toString(); notifyListeners(); - _homeProvider.changeMessage("Vous n'êtes pas connecté:", 3); + _homeProvider.changeMessage("Aucun server disponible...", 0); // snackNode(ctx, false); } diff --git a/lib/screens/animated_text.dart b/lib/screens/animated_text.dart new file mode 100644 index 0000000..f62197a --- /dev/null +++ b/lib/screens/animated_text.dart @@ -0,0 +1,90 @@ +import 'package:flutter/material.dart'; + +typedef DataDidChangeCallback = bool Function(T o, T n); + +///Fades out the old data and back in with the new +class AnimatedFadeOutIn extends StatefulWidget { + ///If [initialData] is not null on first build it will be shown. + ///Directly after that the animation changes the value to [data]. + final T? initialData; + + ///The data to show + final T data; + final Duration duration; + final Widget Function(T data) builder; + final VoidCallback? onFadeComplete; + + /// Compare the values to determine if the data has changed. + /// If [null] the data is compared using `!=` expression + final DataDidChangeCallback? dataDidChange; + + const AnimatedFadeOutIn({ + Key? key, + this.initialData, + required this.data, + required this.builder, + this.duration = const Duration(milliseconds: 300), + this.onFadeComplete, + this.dataDidChange, + }) : super(key: key); + + @override + _AnimatedFadeOutInState createState() => _AnimatedFadeOutInState(); +} + +class _AnimatedFadeOutInState extends State> + with SingleTickerProviderStateMixin { + late AnimationController controller; + late Animation animation; + late T dataToShow; + + @override + void initState() { + super.initState(); + dataToShow = widget.initialData ?? widget.data; + controller = AnimationController(vsync: this, duration: widget.duration) + ..addListener(() => setState(() {})) + ..addStatusListener((status) { + if (status == AnimationStatus.completed) { + dataToShow = widget.data; + controller.reverse(from: 1.0); + } else if (status == AnimationStatus.dismissed) { + widget.onFadeComplete?.call(); + } + }); + + animation = Tween(begin: 0.0, end: 1.0).animate( + CurvedAnimation( + parent: controller, + curve: Curves.easeIn, + reverseCurve: Curves.easeOut, + ), + ); + if (widget.dataDidChange?.call(dataToShow, widget.data) ?? + widget.data != dataToShow) { + controller.forward(from: 0.0); + } + } + + @override + void dispose() { + controller.dispose(); + super.dispose(); + } + + @override + void didUpdateWidget(AnimatedFadeOutIn oldWidget) { + super.didUpdateWidget(oldWidget); + if (widget.dataDidChange?.call(oldWidget.data, widget.data) ?? + widget.data != oldWidget.data) { + dataToShow = oldWidget.data; + controller.forward(from: 0.0); + } + } + + @override + Widget build(BuildContext context) => Opacity( + opacity: 1.0 - animation.value, + child: widget.builder(dataToShow), + ); +} diff --git a/lib/screens/home.dart b/lib/screens/home.dart index 28a4ac4..bb5e6f5 100644 --- a/lib/screens/home.dart +++ b/lib/screens/home.dart @@ -8,6 +8,7 @@ import 'package:gecko/providers/wallets_profiles.dart'; import 'package:flutter/material.dart'; import 'package:gecko/providers/my_wallets.dart'; import 'package:gecko/models/wallet_data.dart'; +import 'package:gecko/screens/animated_text.dart'; import 'package:gecko/screens/common_elements.dart'; import 'package:gecko/screens/myWallets/restore_chest.dart'; import 'package:gecko/screens/myWallets/unlocking_wallet.dart'; @@ -190,29 +191,33 @@ Widget geckHome(context) { padding: EdgeInsets.only(top: 15 * ratio), child: Row(mainAxisAlignment: MainAxisAlignment.center, children: [ - Consumer(builder: (context, _homeP, _) { - return Text( - _homeP.homeMessage, - textAlign: TextAlign.center, - style: const TextStyle( - color: Colors.white, - fontSize: 24, - fontWeight: FontWeight.w700, - shadows: [ - Shadow( - offset: Offset(0, 0), - blurRadius: 20, - color: Colors.black, - ), - Shadow( - offset: Offset(0, 0), - blurRadius: 20, - color: Colors.black, - ), - ], - ), - ); - }), + DefaultTextStyle( + textAlign: TextAlign.center, + style: const TextStyle( + color: Colors.white, + fontSize: 24, + fontWeight: FontWeight.w700, + shadows: [ + Shadow( + offset: Offset(0, 0), + blurRadius: 20, + color: Colors.black, + ), + Shadow( + offset: Offset(0, 0), + blurRadius: 20, + color: Colors.black, + ), + ], + ), + child: Consumer(builder: (context, _homeP, _) { + return AnimatedFadeOutIn( + data: _homeP.homeMessage, + duration: const Duration(milliseconds: 100), + builder: (value) => Text(value), + ); + }), + ), ]), ), const SizedBox(height: 15), diff --git a/lib/screens/myWallets/custom_derivations.dart b/lib/screens/myWallets/custom_derivations.dart index 2d2f46e..4ddcd76 100644 --- a/lib/screens/myWallets/custom_derivations.dart +++ b/lib/screens/myWallets/custom_derivations.dart @@ -30,7 +30,7 @@ class _CustomDerivationState extends State { final derivationList = [ 'root', - for (var i = 0; i < 50; i += 1) i.toString() + for (var i = 0; i < 51; i += 1) i.toString() ]; final listWallets = _myWalletProvider.readAllWallets(); diff --git a/lib/screens/myWallets/wallets_home.dart b/lib/screens/myWallets/wallets_home.dart index 8f8eefb..600da42 100644 --- a/lib/screens/myWallets/wallets_home.dart +++ b/lib/screens/myWallets/wallets_home.dart @@ -100,34 +100,27 @@ class WalletsHome extends StatelessWidget { ), )), const SizedBox(height: 30), - SizedBox( - height: 90, - width: 420, - child: ElevatedButton.icon( - icon: Image.asset( - 'assets/chests/miniChests.png', - height: 70, - ), - style: ElevatedButton.styleFrom( - elevation: 2, - primary: floattingYellow, // background - onPrimary: Colors.black, // foreground - ), - onPressed: () => Navigator.push( - context, - MaterialPageRoute(builder: (context) { - return const ChooseChest(); - }), - ), - label: const Text( - " Changer de coffre", - style: TextStyle( - fontSize: 22, - fontWeight: FontWeight.w700, - color: Color(0xff8a3c0f), - ), - ), - )), + InkWell( + key: const Key('createNewChest'), + onTap: () { + Navigator.push( + context, + MaterialPageRoute(builder: (context) { + return const ChooseChest(); + }), + ); + }, + child: SizedBox( + width: 400, + height: 50, + child: Center( + child: Text('Changer de coffre', + style: TextStyle( + fontSize: 22, + color: orangeC, + fontWeight: FontWeight.w500))), + ), + ), const SizedBox(height: 30) ]); } diff --git a/pubspec.yaml b/pubspec.yaml index 563fb9c..c91691f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -81,7 +81,7 @@ dependencies: ref: fixAndroidActivityVersion dots_indicator: ^2.1.0 web_socket_channel: ^2.2.0 - + dev_dependencies: # flutter_launcher_icons: ^0.9.2 # flutter_launcher_icons_maker: ^^0.10.2