Skip to content
Snippets Groups Projects
Commit 0f431009 authored by poka's avatar poka
Browse files

workflow for auto and custom endpoint is OK

parent c07cc904
No related branches found
No related tags found
1 merge request!25wip: use dropdown to chose auto or manual endpoints
Pipeline #16533 failed
......@@ -83,6 +83,9 @@ class HomeProvider with ChangeNotifier {
Future<List?> getValidEndpoints() async {
await configBox.delete('endpoint');
if (!configBox.containsKey('autoEndpoint')) {
configBox.put('autoEndpoint', true);
}
List _listEndpoints = [];
if (!configBox.containsKey('endpoint') ||
......
......@@ -29,7 +29,32 @@ class SettingsScreen extends StatelessWidget {
// List of items in our dropdown menu
var duniterBootstrapNodes = _sub.getDuniterBootstrap();
selectedDuniterEndpoint = _sub.getConnectedEndpoint();
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 Scaffold(
backgroundColor: backgroundColor,
......@@ -57,9 +82,8 @@ class SettingsScreen extends StatelessWidget {
Consumer<SettingsProvider>(builder: (context, _set, _) {
return DropdownButtonHideUnderline(
child: DropdownButton(
//TODO
value: selectedDuniterEndpoint ??
duniterBootstrapNodes.first.endpoint,
// alignment: AlignmentDirectional.topStart,
value: selectedDuniterEndpoint,
icon: const Icon(Icons.keyboard_arrow_down),
items: duniterBootstrapNodes
.map((NetworkParams _endpointParams) {
......@@ -92,8 +116,19 @@ class SettingsScreen extends StatelessWidget {
onPressed: selectedDuniterEndpoint !=
_sub.getConnectedEndpoint()
? () async {
configBox.put('customEndpoint',
selectedDuniterEndpoint);
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);
......@@ -103,6 +138,39 @@ class SettingsScreen extends StatelessWidget {
);
}),
]),
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: 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]),
),
),
);
});
}),
// SizedBox(height: isTall ? 80 : 120),
const Spacer(),
SizedBox(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment