Optimize proxies expansion panel 2

Fix android scan qrcode error
This commit is contained in:
chen08209
2024-06-27 17:23:59 +08:00
parent 5e3b0e4929
commit 713e83d9d8
7 changed files with 122 additions and 104 deletions

View File

@@ -359,7 +359,9 @@ class AppController {
}
addProfileFormURL(String url) async {
globalState.navigatorKey.currentState?.popUntil((route) => route.isFirst);
if (globalState.navigatorKey.currentState?.canPop() ?? false) {
globalState.navigatorKey.currentState?.popUntil((route) => route.isFirst);
}
toProfiles();
final commonScaffoldState = globalState.homeScaffoldKey.currentState;
if (commonScaffoldState?.mounted != true) return;
@@ -421,18 +423,17 @@ class AppController {
});
}
List<Proxy> _sortOfName(List<Proxy> proxies) {
return List.of(proxies)
..sort(
(a, b) => other.sortByChar(a.name, b.name),
(a, b) => other.sortByChar(a.name, b.name),
);
}
List<Proxy> _sortOfDelay(List<Proxy> proxies) {
return proxies = List.of(proxies)
..sort(
(a, b) {
(a, b) {
final aDelay = appState.getDelay(a.name);
final bDelay = appState.getDelay(b.name);
if (aDelay == null && bDelay == null) {
@@ -449,11 +450,11 @@ class AppController {
);
}
List<Proxy> getSortProxies(List<Proxy> proxies){
return switch(config.proxiesSortType){
List<Proxy> getSortProxies(List<Proxy> proxies) {
return switch (config.proxiesSortType) {
ProxiesSortType.none => proxies,
ProxiesSortType.delay => _sortOfDelay(proxies),
ProxiesSortType.name =>_sortOfName(proxies),
ProxiesSortType.name => _sortOfName(proxies),
};
}
}