Dynamic home message; improve node statut UX
This commit is contained in:
parent
488435405c
commit
cd6c3e9c70
Binary file not shown.
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 6.8 KiB |
Binary file not shown.
Before Width: | Height: | Size: 6.8 KiB After Width: | Height: | Size: 5.6 KiB |
|
@ -8,7 +8,7 @@ import 'package:logger/logger.dart';
|
|||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
// Version of box data
|
||||
const int dataVersion = 2;
|
||||
const int dataVersion = 3;
|
||||
|
||||
// Files paths
|
||||
Directory? appPath;
|
||||
|
|
|
@ -26,6 +26,7 @@ class HomeProvider with ChangeNotifier {
|
|||
Widget appBarTitle = Text('Ğecko', style: TextStyle(color: Colors.grey[850]));
|
||||
Widget appBarExplorer =
|
||||
Text('Explorateur', style: TextStyle(color: Colors.grey[850]));
|
||||
String homeMessage = "y'a pas de lézard ;-)";
|
||||
|
||||
Future<void> initHive() async {
|
||||
late Directory hivePath;
|
||||
|
@ -71,6 +72,15 @@ class HomeProvider with ChangeNotifier {
|
|||
return version + '+' + buildNumber;
|
||||
}
|
||||
|
||||
Future changeMessage(String newMessage, int seconds) async {
|
||||
final oldMessage = homeMessage;
|
||||
homeMessage = newMessage;
|
||||
notifyListeners();
|
||||
await Future.delayed(Duration(seconds: seconds));
|
||||
homeMessage = oldMessage;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<List?> getValidEndpoints() async {
|
||||
await configBox.delete('endpoint');
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ class MyWalletsProvider with ChangeNotifier {
|
|||
return listWallets;
|
||||
}
|
||||
|
||||
WalletData? getWalletData(List<int?> _id) {
|
||||
WalletData? getWalletDataById(List<int?> _id) {
|
||||
if (_id.isEmpty) return WalletData();
|
||||
int? _chest = _id[0];
|
||||
int? _nbr = _id[1];
|
||||
|
@ -57,13 +57,26 @@ class MyWalletsProvider with ChangeNotifier {
|
|||
return _targetedWallet;
|
||||
}
|
||||
|
||||
WalletData? getWalletDataByAddress(String address) {
|
||||
WalletData? _targetedWallet;
|
||||
|
||||
walletBox.toMap().forEach((key, value) {
|
||||
if (value.address == address) {
|
||||
_targetedWallet = value;
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
return _targetedWallet;
|
||||
}
|
||||
|
||||
WalletData? getDefaultWallet([int? chest]) {
|
||||
if (chestBox.isEmpty) {
|
||||
return WalletData(chest: 0, number: 0);
|
||||
} else {
|
||||
chest ??= getCurrentChest();
|
||||
int? defaultWalletNumber = chestBox.get(chest)!.defaultWallet;
|
||||
return getWalletData([chest, defaultWalletNumber]);
|
||||
return getWalletDataById([chest, defaultWalletNumber]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import 'package:flutter/services.dart';
|
|||
import 'package:gecko/globals.dart';
|
||||
import 'package:gecko/models/chest_data.dart';
|
||||
import 'package:gecko/models/wallet_data.dart';
|
||||
import 'package:gecko/providers/home.dart';
|
||||
import 'package:polkawallet_sdk/api/apiKeyring.dart';
|
||||
import 'package:polkawallet_sdk/api/types/networkParams.dart';
|
||||
import 'package:polkawallet_sdk/api/types/txInfoData.dart';
|
||||
|
@ -46,6 +47,7 @@ class SubstrateSdk with ChangeNotifier {
|
|||
|
||||
Future<void> connectNode(BuildContext ctx) async {
|
||||
List<NetworkParams> node = [];
|
||||
HomeProvider _homeProvider = Provider.of<HomeProvider>(ctx, listen: false);
|
||||
|
||||
for (String _endpoint in configBox.get('endpoint')) {
|
||||
final n = NetworkParams();
|
||||
|
@ -98,12 +100,14 @@ class SubstrateSdk with ChangeNotifier {
|
|||
notifyListeners();
|
||||
});
|
||||
notifyListeners();
|
||||
snackNode(ctx, true);
|
||||
_homeProvider.changeMessage('Vous êtes bien connecté', 3);
|
||||
// snackNode(ctx, true);
|
||||
} else {
|
||||
nodeConnected = false;
|
||||
debugConnection = res.toString();
|
||||
notifyListeners();
|
||||
snackNode(ctx, false);
|
||||
_homeProvider.changeMessage('Vous êtes pas connecté', 3);
|
||||
// snackNode(ctx, false);
|
||||
}
|
||||
|
||||
log.d(sdk.api.connectedNode?.endpoint);
|
||||
|
|
|
@ -31,7 +31,7 @@ class WalletOptionsProvider with ChangeNotifier {
|
|||
{required bool isCesium}) async {
|
||||
MyWalletsProvider myWalletClass = MyWalletsProvider();
|
||||
|
||||
WalletData _walletTarget = myWalletClass.getWalletData(_walletID)!;
|
||||
WalletData _walletTarget = myWalletClass.getWalletDataById(_walletID)!;
|
||||
_walletTarget.name = _newName;
|
||||
await walletBox.put(_walletTarget.key, _walletTarget);
|
||||
|
||||
|
@ -214,6 +214,9 @@ class WalletOptionsProvider with ChangeNotifier {
|
|||
TextButton(
|
||||
child: const Text("Valider"),
|
||||
onPressed: () async {
|
||||
final _wallet =
|
||||
_myWalletProvider.getWalletDataByAddress(address.text);
|
||||
await _sub.setCurrentWallet(_wallet!);
|
||||
_sub.confirmIdentity(_walletOptions.address.text, idtyName.text,
|
||||
_myWalletProvider.pinCode);
|
||||
Navigator.pop(context);
|
||||
|
|
|
@ -2,6 +2,7 @@ import 'package:bubble/bubble.dart';
|
|||
import 'package:gecko/globals.dart';
|
||||
import 'package:gecko/models/stateful_wrapper.dart';
|
||||
import 'package:gecko/providers/chest_provider.dart';
|
||||
import 'package:gecko/providers/home.dart';
|
||||
import 'package:gecko/providers/substrate_sdk.dart';
|
||||
import 'package:gecko/providers/wallets_profiles.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
@ -23,7 +24,6 @@ class HomeScreen extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
||||
// HomeProvider _homeProvider = Provider.of<HomeProvider>(context);
|
||||
MyWalletsProvider _myWalletProvider =
|
||||
Provider.of<MyWalletsProvider>(context);
|
||||
Provider.of<ChestProvider>(context);
|
||||
|
@ -103,6 +103,7 @@ class HomeScreen extends StatelessWidget {
|
|||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||
if (!_sub.sdkReady && !_sub.sdkLoading) await _sub.initApi();
|
||||
if (_sub.sdkReady && !_sub.nodeConnected) {
|
||||
// Check if versionData non compatible, drop everything
|
||||
if (walletBox.isNotEmpty &&
|
||||
walletBox.getAt(0)!.version! < dataVersion) {
|
||||
await infoPopup(context,
|
||||
|
@ -185,31 +186,32 @@ Widget geckHome(context) {
|
|||
]),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(top: 15 * ratio),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: const <Widget>[
|
||||
Text(
|
||||
"y'a pas de lézard ;-)",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.w700,
|
||||
shadows: <Shadow>[
|
||||
Shadow(
|
||||
offset: Offset(0, 0),
|
||||
blurRadius: 20,
|
||||
color: Colors.black,
|
||||
),
|
||||
Shadow(
|
||||
offset: Offset(0, 0),
|
||||
blurRadius: 20,
|
||||
color: Colors.black,
|
||||
),
|
||||
],
|
||||
),
|
||||
child:
|
||||
Row(mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[
|
||||
Consumer<HomeProvider>(builder: (context, _homeP, _) {
|
||||
return Text(
|
||||
_homeP.homeMessage,
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.w700,
|
||||
shadows: <Shadow>[
|
||||
Shadow(
|
||||
offset: Offset(0, 0),
|
||||
blurRadius: 20,
|
||||
color: Colors.black,
|
||||
),
|
||||
Shadow(
|
||||
offset: Offset(0, 0),
|
||||
blurRadius: 20,
|
||||
color: Colors.black,
|
||||
),
|
||||
],
|
||||
),
|
||||
]),
|
||||
);
|
||||
}),
|
||||
]),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
Expanded(
|
||||
|
|
|
@ -126,7 +126,7 @@ class WalletOptions extends StatelessWidget {
|
|||
historyWidget(
|
||||
context, _historyProvider, walletProvider),
|
||||
SizedBox(height: 12 * ratio),
|
||||
setDefaultWallet(context, walletProvider,
|
||||
setDefaultWalletWidget(context, walletProvider,
|
||||
_myWalletProvider, _walletOptions, _currentChest),
|
||||
SizedBox(height: 17 * ratio),
|
||||
if (!walletProvider.isDefaultWallet)
|
||||
|
@ -349,25 +349,20 @@ class WalletOptions extends StatelessWidget {
|
|||
);
|
||||
}
|
||||
|
||||
Widget setDefaultWallet(
|
||||
Widget setDefaultWalletWidget(
|
||||
BuildContext context,
|
||||
WalletOptionsProvider walletProvider,
|
||||
MyWalletsProvider _myWalletProvider,
|
||||
WalletOptionsProvider _walletOptions,
|
||||
int _currentChest) {
|
||||
WalletData defaultWallet = _myWalletProvider.getDefaultWallet()!;
|
||||
SubstrateSdk _sub = Provider.of<SubstrateSdk>(context, listen: false);
|
||||
|
||||
_walletOptions.isDefaultWallet = (defaultWallet.number == wallet.id()[1]);
|
||||
|
||||
return InkWell(
|
||||
key: const Key('setDefaultWallet'),
|
||||
onTap: !walletProvider.isDefaultWallet
|
||||
? () async {
|
||||
defaultWallet = wallet;
|
||||
await _sub.setCurrentWallet(wallet);
|
||||
_myWalletProvider.readAllWallets(_currentChest);
|
||||
_myWalletProvider.rebuildWidget();
|
||||
await setDefaultWallet(context, _currentChest);
|
||||
}
|
||||
: null,
|
||||
child: SizedBox(
|
||||
|
@ -397,6 +392,18 @@ class WalletOptions extends StatelessWidget {
|
|||
);
|
||||
}
|
||||
|
||||
Future setDefaultWallet(BuildContext context, int _currentChest) async {
|
||||
SubstrateSdk _sub = Provider.of<SubstrateSdk>(context, listen: false);
|
||||
MyWalletsProvider _myWalletProvider =
|
||||
Provider.of<MyWalletsProvider>(context, listen: false);
|
||||
|
||||
// WalletData defaultWallet = _myWalletProvider.getDefaultWallet()!;
|
||||
// defaultWallet = wallet;
|
||||
await _sub.setCurrentWallet(wallet);
|
||||
_myWalletProvider.readAllWallets(_currentChest);
|
||||
_myWalletProvider.rebuildWidget();
|
||||
}
|
||||
|
||||
Widget deleteWallet(
|
||||
BuildContext context,
|
||||
WalletOptionsProvider walletProvider,
|
||||
|
|
|
@ -4,10 +4,7 @@ import 'package:flutter/services.dart';
|
|||
import 'package:gecko/providers/my_wallets.dart';
|
||||
import 'package:gecko/providers/substrate_sdk.dart';
|
||||
import 'dart:io';
|
||||
// import 'package:gecko/screens/myWallets/import_cesium_wallet.dart';
|
||||
import 'package:gecko/globals.dart';
|
||||
import 'package:gecko/screens/myWallets/restore_chest.dart';
|
||||
import 'package:gecko/screens/onBoarding/5.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
// ignore: must_be_immutable
|
||||
|
@ -51,80 +48,42 @@ class SettingsScreen extends StatelessWidget {
|
|||
children: <Widget>[
|
||||
const SizedBox(height: 60),
|
||||
Row(children: [
|
||||
Text(' Noeud $currencyName :'),
|
||||
const SizedBox(width: 20),
|
||||
SizedBox(
|
||||
width: 200,
|
||||
height: 50,
|
||||
child: TextField(
|
||||
controller: _endpointController,
|
||||
autocorrect: false,
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
Consumer<SubstrateSdk>(builder: (context, _sub, _) {
|
||||
return _sub.isLoadingEndpoint
|
||||
? CircularProgressIndicator(color: orangeC)
|
||||
: IconButton(
|
||||
icon: Icon(
|
||||
Icons.send,
|
||||
color: orangeC,
|
||||
size: 40,
|
||||
),
|
||||
onPressed: () async {
|
||||
configBox.put('endpoint', [_endpointController.text]);
|
||||
await _sub.connectNode(context);
|
||||
});
|
||||
return Expanded(
|
||||
child: Row(children: [
|
||||
Text(' Noeud $currencyName :'),
|
||||
const Spacer(),
|
||||
Icon(_sub.nodeConnected ? Icons.check : Icons.close),
|
||||
const Spacer(),
|
||||
SizedBox(
|
||||
width: 200,
|
||||
height: 50,
|
||||
child: TextField(
|
||||
controller: _endpointController,
|
||||
autocorrect: false,
|
||||
),
|
||||
),
|
||||
const Spacer(flex: 5),
|
||||
_sub.isLoadingEndpoint
|
||||
? CircularProgressIndicator(color: orangeC)
|
||||
: IconButton(
|
||||
icon: Icon(
|
||||
Icons.send,
|
||||
color: orangeC,
|
||||
size: 40,
|
||||
),
|
||||
onPressed: () async {
|
||||
configBox
|
||||
.put('endpoint', [_endpointController.text]);
|
||||
await _sub.connectNode(context);
|
||||
}),
|
||||
const Spacer(flex: 8),
|
||||
]),
|
||||
);
|
||||
}),
|
||||
const Spacer(),
|
||||
]),
|
||||
SizedBox(height: isTall ? 50 : 20),
|
||||
SizedBox(
|
||||
height: buttonHigh,
|
||||
width: buttonWidth,
|
||||
child: ElevatedButton(
|
||||
key: const Key('generateKeychain'),
|
||||
style: ElevatedButton.styleFrom(
|
||||
elevation: 5,
|
||||
primary: yellowC, // background
|
||||
onPrimary: Colors.black, // foreground
|
||||
),
|
||||
onPressed: () => Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) {
|
||||
return const OnboardingStepFive(skipIntro: true);
|
||||
}),
|
||||
),
|
||||
child: const Text(
|
||||
"Générer un coffre",
|
||||
style: TextStyle(fontSize: fontSize),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
SizedBox(
|
||||
height: buttonHigh,
|
||||
width: buttonWidth,
|
||||
child: ElevatedButton(
|
||||
key: const Key('generateKeychain'),
|
||||
style: ElevatedButton.styleFrom(
|
||||
elevation: 5,
|
||||
primary: yellowC, // background
|
||||
onPrimary: Colors.black, // foreground
|
||||
),
|
||||
onPressed: () => Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) {
|
||||
return const RestoreChest(skipIntro: true);
|
||||
}),
|
||||
),
|
||||
child: const Text(
|
||||
"Restaurer un coffre",
|
||||
style: TextStyle(fontSize: fontSize),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 25),
|
||||
// SizedBox(height: isTall ? 80 : 120),
|
||||
const Spacer(),
|
||||
SizedBox(
|
||||
height: buttonHigh,
|
||||
width: buttonWidth,
|
||||
|
@ -138,14 +97,16 @@ class SettingsScreen extends StatelessWidget {
|
|||
child: const Text(
|
||||
'Oublier tous mes coffres',
|
||||
style: TextStyle(
|
||||
fontSize: fontSize + 3,
|
||||
fontSize: fontSize + 4,
|
||||
color: Color(0xffD80000),
|
||||
fontWeight: FontWeight.w500,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
// const Spacer(),
|
||||
SizedBox(height: isTall ? 90 : 60),
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -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.7+3
|
||||
version: 0.0.7+4
|
||||
|
||||
environment:
|
||||
sdk: '>=2.12.0 <3.0.0'
|
||||
|
|
Loading…
Reference in New Issue