Merge branch 'manualNodeChange' into 'master'

wip: use dropdown to chose auto or manual endpoints

See merge request clients/gecko!25
This commit is contained in:
pokapow 2022-07-16 21:39:53 +02:00
commit f3cb9faca7
10 changed files with 434 additions and 125 deletions

View File

@ -1,4 +1,5 @@
[ [
"https://idx.gdev.cgeek.fr",
"https://duniter-indexer.coinduf.eu", "https://duniter-indexer.coinduf.eu",
"http://192.168.1.72:8080" "http://192.168.1.72:8080"
] ]

View File

@ -25,6 +25,7 @@ import 'package:gecko/providers/chest_provider.dart';
import 'package:gecko/models/g1_wallets_list.dart'; import 'package:gecko/models/g1_wallets_list.dart';
import 'package:gecko/providers/duniter_indexer.dart'; import 'package:gecko/providers/duniter_indexer.dart';
import 'package:gecko/providers/generate_wallets.dart'; import 'package:gecko/providers/generate_wallets.dart';
import 'package:gecko/providers/settings_provider.dart';
import 'package:gecko/providers/substrate_sdk.dart'; import 'package:gecko/providers/substrate_sdk.dart';
import 'package:gecko/providers/wallets_profiles.dart'; import 'package:gecko/providers/wallets_profiles.dart';
import 'package:gecko/providers/home.dart'; import 'package:gecko/providers/home.dart';
@ -59,12 +60,16 @@ Future<void> main() async {
} }
HomeProvider _homeProvider = HomeProvider(); HomeProvider _homeProvider = HomeProvider();
DuniterIndexer _duniterIndexer = DuniterIndexer(); // DuniterIndexer _duniterIndexer = DuniterIndexer();
await initHiveForFlutter(); await initHiveForFlutter();
await _homeProvider.initHive(); await _homeProvider.initHive();
appVersion = await _homeProvider.getAppVersion(); appVersion = await _homeProvider.getAppVersion();
prefs = await SharedPreferences.getInstance(); prefs = await SharedPreferences.getInstance();
// Reset GraphQL cache
final cache = HiveStore();
cache.reset();
// Configure Hive and open boxes // Configure Hive and open boxes
Hive.registerAdapter(WalletDataAdapter()); Hive.registerAdapter(WalletDataAdapter());
Hive.registerAdapter(ChestDataAdapter()); Hive.registerAdapter(ChestDataAdapter());
@ -84,8 +89,6 @@ Future<void> main() async {
} }
// log.d(await configBox.get('endpoint')); // log.d(await configBox.get('endpoint'));
_duniterIndexer.getValidIndexerEndpoint();
HttpOverrides.global = MyHttpOverrides(); HttpOverrides.global = MyHttpOverrides();
if (kReleaseMode && enableSentry) { if (kReleaseMode && enableSentry) {
@ -148,7 +151,8 @@ class Gecko extends StatelessWidget {
ChangeNotifierProvider(create: (_) => SearchProvider()), ChangeNotifierProvider(create: (_) => SearchProvider()),
ChangeNotifierProvider(create: (_) => CesiumPlusProvider()), ChangeNotifierProvider(create: (_) => CesiumPlusProvider()),
ChangeNotifierProvider(create: (_) => SubstrateSdk()), ChangeNotifierProvider(create: (_) => SubstrateSdk()),
ChangeNotifierProvider(create: (_) => DuniterIndexer()) ChangeNotifierProvider(create: (_) => DuniterIndexer()),
ChangeNotifierProvider(create: (_) => SettingsProvider())
], ],
child: MaterialApp( child: MaterialApp(
localizationsDelegates: context.localizationDelegates, localizationsDelegates: context.localizationDelegates,

View File

@ -22,41 +22,83 @@ class DuniterIndexer with ChangeNotifier {
int nPage = 1; int nPage = 1;
int nRepositories = 20; int nRepositories = 20;
List? transBC; List? transBC;
List listIndexerEndpoints = [];
bool isLoadingIndexer = false;
void reload() { void reload() {
notifyListeners(); notifyListeners();
} }
Future checkIndexerEndpoint() async { Future<bool> checkIndexerEndpoint(String endpoint) async {
final oldEndpoint = indexerEndpoint; isLoadingIndexer = true;
while (true) { notifyListeners();
await Future.delayed(const Duration(seconds: 30)); final _client = HttpClient();
final _client = HttpClient(); _client.connectionTimeout = const Duration(milliseconds: 4000);
_client.connectionTimeout = const Duration(milliseconds: 4000); try {
try { final request = await _client.postUrl(Uri.parse('$endpoint/v1/graphql'));
final request = final response = await request.close();
await _client.postUrl(Uri.parse('$oldEndpoint/v1/graphql')); if (response.statusCode != 200) {
final response = await request.close();
if (response.statusCode != 200) {
log.d('INDEXER IS OFFILINE');
indexerEndpoint = '';
} else {
// log.d('Indexer is online');
indexerEndpoint = oldEndpoint;
}
} catch (e) {
log.d('INDEXER IS OFFILINE'); log.d('INDEXER IS OFFILINE');
indexerEndpoint = ''; indexerEndpoint = '';
isLoadingIndexer = false;
notifyListeners();
return false;
} else {
indexerEndpoint = endpoint;
await configBox.put('indexerEndpoint', endpoint);
// await configBox.put('customEndpoint', endpoint);
isLoadingIndexer = false;
notifyListeners();
final cache = HiveStore();
cache.reset();
return true;
} }
} catch (e) {
log.d('INDEXER IS OFFILINE');
indexerEndpoint = '';
isLoadingIndexer = false;
notifyListeners();
return false;
} }
} }
// Future checkIndexerEndpointBackground() async {
// final oldEndpoint = indexerEndpoint;
// while (true) {
// await Future.delayed(const Duration(seconds: 30));
// final isValid = await checkIndexerEndpoint(oldEndpoint);
// if (!isValid) {
// log.d('INDEXER IS OFFILINE');
// indexerEndpoint = '';
// } else {
// // log.d('Indexer is online');
// indexerEndpoint = oldEndpoint;
// }
// }
// }
Future<String> getValidIndexerEndpoint() async { Future<String> getValidIndexerEndpoint() async {
List _listEndpoints = await rootBundle // await configBox.delete('indexerEndpoint');
listIndexerEndpoints = await rootBundle
.loadString('config/indexer_endpoints.json') .loadString('config/indexer_endpoints.json')
.then((jsonStr) => jsonDecode(jsonStr)); .then((jsonStr) => jsonDecode(jsonStr));
// _listEndpoints.shuffle(); // _listEndpoints.shuffle();
log.d(listIndexerEndpoints);
listIndexerEndpoints.add('Personnalisé');
if (configBox.containsKey('customIndexer')) {
return configBox.get('customIndexer');
// listIndexerEndpoints.insert(0, configBox.get('customIndexer'));
}
if (configBox.containsKey('indexerEndpoint')) {
if (await checkIndexerEndpoint(configBox.get('indexerEndpoint'))) {
return configBox.get('indexerEndpoint');
}
}
int i = 0; int i = 0;
// String _endpoint = ''; // String _endpoint = '';
int _statusCode = 0; int _statusCode = 0;
@ -65,25 +107,28 @@ class DuniterIndexer with ChangeNotifier {
_client.connectionTimeout = const Duration(milliseconds: 3000); _client.connectionTimeout = const Duration(milliseconds: 3000);
do { do {
int listLenght = _listEndpoints.length; int listLenght = listIndexerEndpoints.length;
if (i >= listLenght) { if (i >= listLenght) {
log.e('NO VALID INDEXER ENDPOINT FOUND'); log.e('NO VALID INDEXER ENDPOINT FOUND');
indexerEndpoint = ''; indexerEndpoint = '';
break; break;
} }
log.d( log.d((i + 1).toString() +
(i + 1).toString() + 'n indexer endpoint try: ${_listEndpoints[i]}'); 'n indexer endpoint try: ${listIndexerEndpoints[i]}');
if (i != 0) { if (i != 0) {
await Future.delayed(const Duration(milliseconds: 300)); await Future.delayed(const Duration(milliseconds: 300));
} }
try { try {
final request = String endpointPath = '${listIndexerEndpoints[i]}/v1/graphql';
await _client.postUrl(Uri.parse('${_listEndpoints[i]}/v1/graphql'));
final request = await _client.postUrl(Uri.parse(endpointPath));
final response = await request.close(); final response = await request.close();
indexerEndpoint = _listEndpoints[i]; indexerEndpoint = listIndexerEndpoints[i];
await configBox.put('indexerEndpoint', listIndexerEndpoints[i]);
_statusCode = response.statusCode; _statusCode = response.statusCode;
i++; i++;
} on TimeoutException catch (_) { } on TimeoutException catch (_) {
@ -202,13 +247,15 @@ class DuniterIndexer with ChangeNotifier {
return const Text('Aucun résultat'); return const Text('Aucun résultat');
} }
log.d(indexerEndpoint);
final _httpLink = HttpLink( final _httpLink = HttpLink(
'$indexerEndpoint/v1/graphql', '$indexerEndpoint/v1/graphql',
); );
final _client = ValueNotifier( final _client = ValueNotifier(
GraphQLClient( GraphQLClient(
cache: GraphQLCache(store: HiveStore()), cache: GraphQLCache(
store: HiveStore()), // GraphQLCache(store: HiveStore())
link: _httpLink, link: _httpLink,
), ),
); );

View File

@ -83,6 +83,9 @@ class HomeProvider with ChangeNotifier {
Future<List?> getValidEndpoints() async { Future<List?> getValidEndpoints() async {
await configBox.delete('endpoint'); await configBox.delete('endpoint');
if (!configBox.containsKey('autoEndpoint')) {
configBox.put('autoEndpoint', true);
}
List _listEndpoints = []; List _listEndpoints = [];
if (!configBox.containsKey('endpoint') || if (!configBox.containsKey('endpoint') ||

View File

@ -0,0 +1,7 @@
import 'package:flutter/material.dart';
class SettingsProvider with ChangeNotifier {
void reload() {
notifyListeners();
}
}

View File

@ -46,7 +46,6 @@ class SubstrateSdk with ChangeNotifier {
} }
Future<void> connectNode(BuildContext ctx) async { Future<void> connectNode(BuildContext ctx) async {
List<NetworkParams> node = [];
HomeProvider _homeProvider = Provider.of<HomeProvider>(ctx, listen: false); HomeProvider _homeProvider = Provider.of<HomeProvider>(ctx, listen: false);
// var connectivityResult = await (Connectivity().checkConnectivity()); // var connectivityResult = await (Connectivity().checkConnectivity());
@ -57,13 +56,14 @@ class SubstrateSdk with ChangeNotifier {
// } // }
_homeProvider.changeMessage("connectionPending".tr(), 0); _homeProvider.changeMessage("connectionPending".tr(), 0);
for (String _endpoint in configBox.get('endpoint')) { // configBox.delete('customEndpoint');
final n = NetworkParams(); final List<NetworkParams> listEndpoints =
n.name = currencyName; configBox.containsKey('customEndpoint')
n.endpoint = _endpoint; ? [getDuniterCustomEndpoint()]
n.ss58 = ss58; : getDuniterBootstrap();
node.add(n);
} // final nodes = getDuniterBootstrap();
int timeout = 10000; int timeout = 10000;
// if (n.endpoint!.startsWith('ws://')) { // if (n.endpoint!.startsWith('ws://')) {
@ -93,7 +93,7 @@ class SubstrateSdk with ChangeNotifier {
isLoadingEndpoint = true; isLoadingEndpoint = true;
notifyListeners(); notifyListeners();
final res = await sdk.api.connectNode(keyring, node).timeout( final res = await sdk.api.connectNode(keyring, listEndpoints).timeout(
Duration(milliseconds: timeout), Duration(milliseconds: timeout),
onTimeout: () => null, onTimeout: () => null,
); );
@ -133,6 +133,27 @@ class SubstrateSdk with ChangeNotifier {
log.d(sdk.api.connectedNode?.endpoint); log.d(sdk.api.connectedNode?.endpoint);
} }
List<NetworkParams> getDuniterBootstrap() {
List<NetworkParams> node = [];
for (String _endpoint in configBox.get('endpoint')) {
final n = NetworkParams();
n.name = currencyName;
n.endpoint = _endpoint;
n.ss58 = ss58;
node.add(n);
}
return node;
}
NetworkParams getDuniterCustomEndpoint() {
final nodeParams = NetworkParams();
nodeParams.name = currencyName;
nodeParams.endpoint = configBox.get('customEndpoint');
nodeParams.ss58 = ss58;
return nodeParams;
}
Future<String> importAccount( Future<String> importAccount(
{String mnemonic = '', {String mnemonic = '',
bool fromMnemonic = false, bool fromMnemonic = false,

View File

@ -107,6 +107,10 @@ class HomeScreen extends StatelessWidget {
builder: (ctx) => StatefulWrapper( builder: (ctx) => StatefulWrapper(
onInit: () { onInit: () {
WidgetsBinding.instance.addPostFrameCallback((_) async { WidgetsBinding.instance.addPostFrameCallback((_) async {
DuniterIndexer _duniterIndexer =
Provider.of<DuniterIndexer>(ctx, listen: false);
_duniterIndexer.getValidIndexerEndpoint();
if (!_sub.sdkReady && !_sub.sdkLoading) await _sub.initApi(); if (!_sub.sdkReady && !_sub.sdkLoading) await _sub.initApi();
if (_sub.sdkReady && !_sub.nodeConnected) { if (_sub.sdkReady && !_sub.nodeConnected) {
// Check if versionData non compatible, drop everything // Check if versionData non compatible, drop everything
@ -147,9 +151,7 @@ class HomeScreen extends StatelessWidget {
} }
}); });
} }
DuniterIndexer _duniterIndexer = // _duniterIndexer.checkIndexerEndpointBackground();
Provider.of<DuniterIndexer>(ctx, listen: false);
_duniterIndexer.checkIndexerEndpoint();
}); });
}, },
child: isWalletsExists ? geckHome(context) : welcomeHome(context) child: isWalletsExists ? geckHome(context) : welcomeHome(context)

View File

@ -1,26 +1,17 @@
import 'package:easy_localization/easy_localization.dart'; import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:durt/durt.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:gecko/providers/duniter_indexer.dart';
import 'package:gecko/providers/my_wallets.dart'; import 'package:gecko/providers/my_wallets.dart';
import 'package:gecko/providers/settings_provider.dart';
import 'package:gecko/providers/substrate_sdk.dart'; import 'package:gecko/providers/substrate_sdk.dart';
import 'dart:io';
import 'package:gecko/globals.dart'; import 'package:gecko/globals.dart';
import 'package:polkawallet_sdk/api/types/networkParams.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
// import 'package:dropdown_button2/dropdown_button2.dart';
// ignore: must_be_immutable // ignore: must_be_immutable
class SettingsScreen extends StatelessWidget { class SettingsScreen extends StatelessWidget {
String? generatedMnemonic;
bool walletIsGenerated = false;
NewWallet? actualWallet;
String? newWalletName;
bool hasError = false;
String validPin = 'NO PIN';
String currentText = "";
var pinColor = Colors.grey[300];
Directory? appPath;
final MyWalletsProvider _myWallets = MyWalletsProvider(); final MyWalletsProvider _myWallets = MyWalletsProvider();
SettingsScreen({Key? key}) : super(key: key); SettingsScreen({Key? key}) : super(key: key);
@ -32,10 +23,7 @@ class SettingsScreen extends StatelessWidget {
const double buttonHigh = 50; const double buttonHigh = 50;
const double buttonWidth = 240; const double buttonWidth = 240;
const double fontSize = 16; const double fontSize = 16;
TextEditingController _endpointController =
TextEditingController(text: configBox.get('endpoint').first);
// getAppDirectory();
return Scaffold( return Scaffold(
backgroundColor: backgroundColor, backgroundColor: backgroundColor,
appBar: AppBar( appBar: AppBar(
@ -44,75 +32,303 @@ class SettingsScreen extends StatelessWidget {
height: 22, height: 22,
child: Text('parameters'.tr()), child: Text('parameters'.tr()),
)), )),
body: Column( body: Column(children: <Widget>[
// crossAxisAlignment: CrossAxisAlignment.start, const SizedBox(height: 30),
children: <Widget>[ duniterEndpointSelection(context),
const SizedBox(height: 60), const SizedBox(height: 50),
Row(children: [ indexerEndpointSelection(context),
Consumer<SubstrateSdk>(builder: (context, _sub, _) {
log.d(_sub.sdk.api.connectedNode?.endpoint); // SizedBox(height: isTall ? 80 : 120),
return Expanded( const Spacer(),
child: Row(children: [ SizedBox(
const SizedBox(width: 10), height: buttonHigh,
Text('currencyNode'.tr(args: [currencyName])), width: buttonWidth,
const Spacer(), child: Center(
Icon(_sub.nodeConnected && !_sub.isLoadingEndpoint child: InkWell(
? Icons.check key: const Key('deleteChest'),
: Icons.close), onTap: () async {
const Spacer(), log.i('Oublier tous mes coffres');
SizedBox( await _myWallets.deleteAllWallet(context);
width: 200, },
height: 50, child: Text(
child: TextField( 'forgetAllMyChests'.tr(),
controller: _endpointController, style: const TextStyle(
autocorrect: false, fontSize: fontSize + 4,
), color: Color(0xffD80000),
), fontWeight: FontWeight.w600,
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),
]),
);
}),
]),
// SizedBox(height: isTall ? 80 : 120),
const Spacer(),
SizedBox(
height: buttonHigh,
width: buttonWidth,
child: Center(
child: InkWell(
key: const Key('deleteChest'),
onTap: () async {
log.i('Oublier tous mes coffres');
await _myWallets.deleteAllWallet(context);
},
child: Text(
'forgetAllMyChests'.tr(),
style: const TextStyle(
fontSize: fontSize + 4,
color: Color(0xffD80000),
fontWeight: FontWeight.w600,
),
),
), ),
), ),
), ),
// const Spacer(), ),
SizedBox(height: isTall ? 90 : 60), ),
]), // const Spacer(),
SizedBox(height: isTall ? 90 : 60),
]),
); );
} }
Widget duniterEndpointSelection(BuildContext context) {
SubstrateSdk _sub = Provider.of<SubstrateSdk>(context, listen: false);
String? selectedDuniterEndpoint;
// List of items in our dropdown menu
var duniterBootstrapNodes = _sub.getDuniterBootstrap();
selectedDuniterEndpoint =
_sub.getConnectedEndpoint() ?? duniterBootstrapNodes.first.endpoint;
final customEndpoint = NetworkParams();
customEndpoint.name = currencyName;
customEndpoint.endpoint = 'Personnalisé';
customEndpoint.ss58 = ss58;
final automaticEndpoint = NetworkParams();
automaticEndpoint.name = currencyName;
automaticEndpoint.endpoint = 'Auto';
automaticEndpoint.ss58 = ss58;
// duniterBootstrapNodes.add(_sub.getDuniterCustomEndpoint());
duniterBootstrapNodes.insert(0, automaticEndpoint);
duniterBootstrapNodes.add(customEndpoint);
if (configBox.get('autoEndpoint') == true) {
selectedDuniterEndpoint = automaticEndpoint.endpoint;
} else if (configBox.containsKey('customEndpoint')) {
selectedDuniterEndpoint = customEndpoint.endpoint;
}
TextEditingController _endpointController = TextEditingController(
text: configBox.containsKey('customEndpoint')
? configBox.get('customEndpoint')
: 'wss://');
return Column(children: <Widget>[
Row(children: [
Consumer<SubstrateSdk>(builder: (context, _sub, _) {
log.d(_sub.sdk.api.connectedNode?.endpoint);
return Expanded(
child: Row(children: [
const SizedBox(width: 10),
Text('currencyNode'.tr(args: [currencyName])),
const Spacer(),
Icon(_sub.nodeConnected && !_sub.isLoadingEndpoint
? Icons.check
: Icons.close),
const Spacer(),
Consumer<SettingsProvider>(builder: (context, _set, _) {
return DropdownButtonHideUnderline(
child: DropdownButton(
// alignment: AlignmentDirectional.topStart,
value: selectedDuniterEndpoint,
icon: const Icon(Icons.keyboard_arrow_down),
items: duniterBootstrapNodes
.map((NetworkParams _endpointParams) {
return DropdownMenuItem(
value: _endpointParams.endpoint,
child: Text(_endpointParams.endpoint!),
);
}).toList(),
onChanged: (String? _newEndpoint) {
log.d(_newEndpoint!);
selectedDuniterEndpoint = _newEndpoint;
_set.reload();
},
),
);
}),
const Spacer(flex: 5),
_sub.isLoadingEndpoint
? CircularProgressIndicator(color: orangeC)
: Consumer<SettingsProvider>(builder: (context, _set, _) {
return IconButton(
icon: Icon(
Icons.send,
color: selectedDuniterEndpoint !=
_sub.getConnectedEndpoint()
? orangeC
: Colors.grey[500],
size: 40,
),
onPressed: selectedDuniterEndpoint !=
_sub.getConnectedEndpoint()
? () async {
if (selectedDuniterEndpoint == 'Auto') {
configBox.delete('customEndpoint');
configBox.put('autoEndpoint', true);
} else {
configBox.put('autoEndpoint', false);
final finalEndpoint =
selectedDuniterEndpoint ==
'Personnalisé'
? _endpointController.text
: selectedDuniterEndpoint;
configBox.put(
'customEndpoint', finalEndpoint);
}
await _sub.connectNode(context);
}
: null);
}),
const Spacer(flex: 8),
]),
);
}),
]),
Consumer<SettingsProvider>(builder: (context, _set, _) {
return Visibility(
visible: selectedDuniterEndpoint == 'Personnalisé',
child: SizedBox(
width: 200,
height: 50,
child: TextField(
controller: _endpointController,
autocorrect: false,
),
),
);
}),
Consumer<SubstrateSdk>(builder: (context, _sub, _) {
return Consumer<SettingsProvider>(builder: (context, _set, _) {
return Visibility(
visible: selectedDuniterEndpoint == 'Auto',
child: SizedBox(
width: 250,
height: _sub.getConnectedEndpoint() == null ? 60 : 20,
child: Text(
_sub.getConnectedEndpoint() ??
"Un noeud sûr et valide sera choisi automatiquement parmis une liste aléatoire.",
style: TextStyle(
fontSize: 15,
fontStyle: FontStyle.italic,
color: Colors.grey[700]),
),
),
);
});
}),
]);
}
Widget indexerEndpointSelection(BuildContext context) {
DuniterIndexer _indexer =
Provider.of<DuniterIndexer>(context, listen: false);
String? selectedIndexerEndpoint;
if (configBox.containsKey('customIndexer')) {
selectedIndexerEndpoint = 'Personnalisé';
} else {
selectedIndexerEndpoint = indexerEndpoint;
}
if (selectedIndexerEndpoint == '') {
selectedIndexerEndpoint = _indexer.listIndexerEndpoints[0];
}
TextEditingController _indexerEndpointController = TextEditingController(
text: configBox.containsKey('customIndexer')
? configBox.get('customIndexer')
: 'https://');
return Column(children: <Widget>[
Row(children: [
Consumer<DuniterIndexer>(builder: (context, _indexer, _) {
log.d(selectedIndexerEndpoint);
log.d(_indexer.listIndexerEndpoints);
return Expanded(
child: Row(children: [
const SizedBox(width: 10),
const Text('Indexer : '),
const Spacer(),
Icon(indexerEndpoint != '' ? Icons.check : Icons.close),
const Spacer(),
Consumer<SettingsProvider>(builder: (context, _set, _) {
return DropdownButtonHideUnderline(
child: DropdownButton(
// alignment: AlignmentDirectional.topStart,
value: selectedIndexerEndpoint,
icon: const Icon(Icons.keyboard_arrow_down),
items:
_indexer.listIndexerEndpoints.map((_indexerEndpoint) {
return DropdownMenuItem(
value: _indexerEndpoint,
child: Text(_indexerEndpoint),
);
}).toList(),
onChanged: (_newEndpoint) {
log.d(_newEndpoint!);
selectedIndexerEndpoint = _newEndpoint.toString();
_set.reload();
},
),
);
}),
const Spacer(flex: 5),
_indexer.isLoadingIndexer
? CircularProgressIndicator(color: orangeC)
: Consumer<SettingsProvider>(builder: (context, _set, _) {
return IconButton(
icon: Icon(
Icons.send,
color: selectedIndexerEndpoint != indexerEndpoint
? orangeC
: Colors.grey[500],
size: 40,
),
onPressed: selectedIndexerEndpoint != indexerEndpoint
? () async {
final finalEndpoint =
selectedIndexerEndpoint == 'Personnalisé'
? _indexerEndpointController.text
: selectedIndexerEndpoint!;
if (selectedIndexerEndpoint ==
'Personnalisé') {
configBox.put('customIndexer',
_indexerEndpointController.text);
} else {
configBox.delete('customIndexer');
}
log.d('connection to indexer $finalEndpoint');
await _indexer
.checkIndexerEndpoint(finalEndpoint);
}
: null);
}),
const Spacer(flex: 8),
]),
);
}),
]),
Consumer<SettingsProvider>(builder: (context, _set, _) {
return Visibility(
visible: selectedIndexerEndpoint == 'Personnalisé',
child: SizedBox(
width: 200,
height: 50,
child: TextField(
controller: _indexerEndpointController,
autocorrect: false,
),
),
);
}),
Consumer<SubstrateSdk>(builder: (context, _sub, _) {
return Consumer<SettingsProvider>(builder: (context, _set, _) {
return Visibility(
visible: selectedIndexerEndpoint == 'Auto',
child: SizedBox(
width: 250,
height: 60,
child: Text(
_sub.getConnectedEndpoint() ??
"Un noeud sûr et valide sera choisi automatiquement parmis une liste aléatoire.",
style: TextStyle(
fontSize: 15,
fontStyle: FontStyle.italic,
color: Colors.grey[700]),
),
),
);
});
}),
]);
}
} }

View File

@ -309,6 +309,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.0" version: "2.1.0"
dropdown_button2:
dependency: "direct main"
description:
name: dropdown_button2
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.3"
durt: durt:
dependency: "direct main" dependency: "direct main"
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.9+14 version: 0.0.9+15
environment: environment:
sdk: '>=2.12.0 <3.0.0' sdk: '>=2.12.0 <3.0.0'
@ -74,6 +74,7 @@ dependencies:
image_cropper: ^2.0.3 image_cropper: ^2.0.3
easy_localization: ^3.0.1 easy_localization: ^3.0.1
flutter_markdown: ^0.6.10+2 flutter_markdown: ^0.6.10+2
dropdown_button2: ^1.6.3
dev_dependencies: dev_dependencies:
# flutter_launcher_icons: ^0.9.2 # flutter_launcher_icons: ^0.9.2