can set custom indexer endpoint
This commit is contained in:
parent
b975061a67
commit
c5960f8376
|
@ -86,10 +86,11 @@ class DuniterIndexer with ChangeNotifier {
|
||||||
// _listEndpoints.shuffle();
|
// _listEndpoints.shuffle();
|
||||||
|
|
||||||
log.d(listIndexerEndpoints);
|
log.d(listIndexerEndpoints);
|
||||||
|
listIndexerEndpoints.add('Personnalisé');
|
||||||
|
|
||||||
if (configBox.containsKey('customIndexer')) {
|
if (configBox.containsKey('customIndexer')) {
|
||||||
// return configBox.get('customIndexer');
|
return configBox.get('customIndexer');
|
||||||
listIndexerEndpoints.insert(0, configBox.get('customIndexer'));
|
// listIndexerEndpoints.insert(0, configBox.get('customIndexer'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (configBox.containsKey('indexerEndpoint')) {
|
if (configBox.containsKey('indexerEndpoint')) {
|
||||||
|
|
|
@ -213,7 +213,7 @@ class SettingsScreen extends StatelessWidget {
|
||||||
|
|
||||||
String? selectedIndexerEndpoint;
|
String? selectedIndexerEndpoint;
|
||||||
if (configBox.containsKey('customIndexer')) {
|
if (configBox.containsKey('customIndexer')) {
|
||||||
selectedIndexerEndpoint = '';
|
selectedIndexerEndpoint = 'Personnalisé';
|
||||||
} else {
|
} else {
|
||||||
selectedIndexerEndpoint = indexerEndpoint;
|
selectedIndexerEndpoint = indexerEndpoint;
|
||||||
}
|
}
|
||||||
|
@ -222,7 +222,7 @@ class SettingsScreen extends StatelessWidget {
|
||||||
selectedIndexerEndpoint = _indexer.listIndexerEndpoints[0];
|
selectedIndexerEndpoint = _indexer.listIndexerEndpoints[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
TextEditingController _endpointController = TextEditingController(
|
TextEditingController _indexerEndpointController = TextEditingController(
|
||||||
text: configBox.containsKey('customIndexer')
|
text: configBox.containsKey('customIndexer')
|
||||||
? configBox.get('customIndexer')
|
? configBox.get('customIndexer')
|
||||||
: 'https://');
|
: 'https://');
|
||||||
|
@ -274,10 +274,21 @@ class SettingsScreen extends StatelessWidget {
|
||||||
),
|
),
|
||||||
onPressed: selectedIndexerEndpoint != indexerEndpoint
|
onPressed: selectedIndexerEndpoint != indexerEndpoint
|
||||||
? () async {
|
? () async {
|
||||||
log.d(
|
final finalEndpoint =
|
||||||
'connection to indexer $selectedIndexerEndpoint');
|
selectedIndexerEndpoint == 'Personnalisé'
|
||||||
await _indexer.checkIndexerEndpoint(
|
? _indexerEndpointController.text
|
||||||
selectedIndexerEndpoint!);
|
: selectedIndexerEndpoint!;
|
||||||
|
|
||||||
|
if (selectedIndexerEndpoint ==
|
||||||
|
'Personnalisé') {
|
||||||
|
configBox.put('customIndexer',
|
||||||
|
_indexerEndpointController.text);
|
||||||
|
} else {
|
||||||
|
configBox.delete('customIndexer');
|
||||||
|
}
|
||||||
|
log.d('connection to indexer $finalEndpoint');
|
||||||
|
await _indexer
|
||||||
|
.checkIndexerEndpoint(finalEndpoint);
|
||||||
}
|
}
|
||||||
: null);
|
: null);
|
||||||
}),
|
}),
|
||||||
|
@ -293,7 +304,7 @@ class SettingsScreen extends StatelessWidget {
|
||||||
width: 200,
|
width: 200,
|
||||||
height: 50,
|
height: 50,
|
||||||
child: TextField(
|
child: TextField(
|
||||||
controller: _endpointController,
|
controller: _indexerEndpointController,
|
||||||
autocorrect: false,
|
autocorrect: false,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in New Issue