workflow for auto and custom endpoint is OK
This commit is contained in:
parent
c07cc9049b
commit
0f43100969
|
@ -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') ||
|
||||||
|
|
|
@ -29,7 +29,32 @@ class SettingsScreen extends StatelessWidget {
|
||||||
|
|
||||||
// List of items in our dropdown menu
|
// List of items in our dropdown menu
|
||||||
var duniterBootstrapNodes = _sub.getDuniterBootstrap();
|
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(
|
return Scaffold(
|
||||||
backgroundColor: backgroundColor,
|
backgroundColor: backgroundColor,
|
||||||
|
@ -57,9 +82,8 @@ class SettingsScreen extends StatelessWidget {
|
||||||
Consumer<SettingsProvider>(builder: (context, _set, _) {
|
Consumer<SettingsProvider>(builder: (context, _set, _) {
|
||||||
return DropdownButtonHideUnderline(
|
return DropdownButtonHideUnderline(
|
||||||
child: DropdownButton(
|
child: DropdownButton(
|
||||||
//TODO
|
// alignment: AlignmentDirectional.topStart,
|
||||||
value: selectedDuniterEndpoint ??
|
value: selectedDuniterEndpoint,
|
||||||
duniterBootstrapNodes.first.endpoint,
|
|
||||||
icon: const Icon(Icons.keyboard_arrow_down),
|
icon: const Icon(Icons.keyboard_arrow_down),
|
||||||
items: duniterBootstrapNodes
|
items: duniterBootstrapNodes
|
||||||
.map((NetworkParams _endpointParams) {
|
.map((NetworkParams _endpointParams) {
|
||||||
|
@ -92,8 +116,19 @@ class SettingsScreen extends StatelessWidget {
|
||||||
onPressed: selectedDuniterEndpoint !=
|
onPressed: selectedDuniterEndpoint !=
|
||||||
_sub.getConnectedEndpoint()
|
_sub.getConnectedEndpoint()
|
||||||
? () async {
|
? () async {
|
||||||
configBox.put('customEndpoint',
|
if (selectedDuniterEndpoint == 'Auto') {
|
||||||
selectedDuniterEndpoint);
|
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);
|
await _sub.connectNode(context);
|
||||||
}
|
}
|
||||||
: null);
|
: 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),
|
// SizedBox(height: isTall ? 80 : 120),
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
|
|
Loading…
Reference in New Issue