Compare commits

..

9 Commits

Author SHA1 Message Date
chen08209
442c32b6eb Update Version 2024-05-03 15:32:12 +08:00
chen08209
949a2aaac3 Update ProxyGroup Sort 2024-05-03 14:31:10 +08:00
chen08209
c77463f337 Fix Android quickStart VpnService some problems 2024-05-02 00:46:42 +08:00
chen08209
00377d6070 Update version 2024-05-01 23:39:21 +08:00
chen08209
f393b4b3e9 Set Android notification low importance 2024-05-01 23:29:32 +08:00
chen08209
75e6cfde15 Add Telegram in README_zh_CN.md
(cherry picked from commit 8a188a37c9)
2024-05-01 21:52:22 +08:00
chen08209
7bfe5617d9 Add Telegram 2024-05-01 21:49:18 +08:00
chen08209
97cc96c243 Fix the issue that VpnService can't be closed correctly in special cases 2024-05-01 21:29:54 +08:00
chen08209
1821ee2f61 Fix the problem that TileService is not destroyed correctly in some cases
Adjust tab animation defaults
2024-05-01 15:13:09 +08:00
33 changed files with 488 additions and 1169 deletions

View File

@@ -89,7 +89,7 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
fetch-depth: 0 submodules: recursive
- name: Download - name: Download
uses: actions/download-artifact@v4 uses: actions/download-artifact@v4
@@ -101,13 +101,13 @@ jobs:
- name: Pre Release - name: Pre Release
run: | run: |
pip install gitchangelog pystache mustache markdown pip install gitchangelog pystache mustache markdown
pre=$(curl --silent "https://api.github.com/repos/chen08209/FlClash/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")' || echo "") prelease=$(curl --silent "https://api.github.com/repos/chen08209/FlClash/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")' || echo "")
if [ -z "pre" ]; then if [ -z "$prelease" ]; then
echo "init" > release.md echo "init" > release.md
else else
current="${{ github.ref_name }}" current="${{ github.ref_name }}"
echo -e "\n\n<details markdown=1><summary>All changes from $current to the latest commit:</summary>\n\n" >> release.md echo -e "\n\n<details markdown=1><summary>All changes from $current to the latest commit:</summary>\n\n" >> release.md
gitchangelog "${pre}.." >> release.md 2>&1 || echo "Error in gitchangelog" gitchangelog "${prelease}" >> release.md 2>&1 || echo "Error in gitchangelog"
echo -e "\n\n</details>" >> release.md echo -e "\n\n</details>" >> release.md
fi fi
- name: Release - name: Release

View File

@@ -7,17 +7,14 @@ import (
"github.com/metacubex/mihomo/component/process" "github.com/metacubex/mihomo/component/process"
"github.com/metacubex/mihomo/component/resolver" "github.com/metacubex/mihomo/component/resolver"
"github.com/metacubex/mihomo/config" "github.com/metacubex/mihomo/config"
"github.com/metacubex/mihomo/constant/provider"
"github.com/metacubex/mihomo/dns" "github.com/metacubex/mihomo/dns"
"github.com/metacubex/mihomo/hub/executor" "github.com/metacubex/mihomo/hub/executor"
"github.com/metacubex/mihomo/listener" "github.com/metacubex/mihomo/listener"
"github.com/metacubex/mihomo/log" "github.com/metacubex/mihomo/log"
"github.com/metacubex/mihomo/tunnel" "github.com/metacubex/mihomo/tunnel"
"math"
"os" "os"
"os/exec" "os/exec"
"runtime" "runtime"
"sync"
"syscall" "syscall"
) )
@@ -49,11 +46,6 @@ type Process struct {
Target string `json:"target"` Target string `json:"target"`
} }
type Now struct {
Name string `json:"name"`
Value string `json:"value"`
}
func restartExecutable(execPath string) { func restartExecutable(execPath string) {
var err error var err error
executor.Shutdown() executor.Shutdown()
@@ -129,7 +121,6 @@ func overwriteConfig(targetConfig *config.RawConfig, patchConfig config.RawConfi
targetConfig.Tun.Device = patchConfig.Tun.Device targetConfig.Tun.Device = patchConfig.Tun.Device
targetConfig.Tun.DNSHijack = patchConfig.Tun.DNSHijack targetConfig.Tun.DNSHijack = patchConfig.Tun.DNSHijack
targetConfig.Tun.Stack = patchConfig.Tun.Stack targetConfig.Tun.Stack = patchConfig.Tun.Stack
targetConfig.Profile.StoreSelected = false
if targetConfig.DNS.Enable == false { if targetConfig.DNS.Enable == false {
targetConfig.DNS = patchConfig.DNS targetConfig.DNS = patchConfig.DNS
} else { } else {
@@ -173,30 +164,10 @@ func patchConfig(general *config.General) {
resolver.DisableIPv6 = !general.IPv6 resolver.DisableIPv6 = !general.IPv6
} }
const concurrentCount = math.MaxInt func applyConfig(isPatch bool) bool {
if currentConfig == nil {
func hcCompatibleProvider(proxyProviders map[string]provider.ProxyProvider) { return false
wg := sync.WaitGroup{}
ch := make(chan struct{}, concurrentCount)
for _, proxyProvider := range proxyProviders {
proxyProvider := proxyProvider
if proxyProvider.VehicleType() == provider.Compatible {
log.Infoln("Start initial Compatible provider %s", proxyProvider.Name())
wg.Add(1)
ch <- struct{}{}
go func() {
defer func() { <-ch; wg.Done() }()
if err := proxyProvider.Initial(); err != nil {
log.Errorln("initial Compatible provider %s error: %v", proxyProvider.Name(), err)
}
}()
}
} }
}
func applyConfig(isPatch bool) {
cfg, err := config.ParseRawConfig(currentConfig) cfg, err := config.ParseRawConfig(currentConfig)
if err != nil { if err != nil {
cfg, _ = config.ParseRawConfig(config.DefaultRawConfig()) cfg, _ = config.ParseRawConfig(config.DefaultRawConfig())
@@ -205,5 +176,7 @@ func applyConfig(isPatch bool) {
patchConfig(cfg.General) patchConfig(cfg.General)
} else { } else {
executor.ApplyConfig(cfg, true) executor.ApplyConfig(cfg, true)
} }
return true
} }

View File

@@ -24,7 +24,7 @@ func InitDartApi(api unsafe.Pointer) {
} }
} }
func SendToPort(port int64, msg string) { func sendToPort(port int64, msg string) {
var obj C.Dart_CObject var obj C.Dart_CObject
obj._type = C.Dart_CObject_kString obj._type = C.Dart_CObject_kString
msgString := C.CString(msg) msgString := C.CString(msg)

View File

@@ -10,7 +10,6 @@ const (
Log MessageType = "log" Log MessageType = "log"
Tun MessageType = "tun" Tun MessageType = "tun"
Delay MessageType = "delay" Delay MessageType = "delay"
Now MessageType = "now"
Process MessageType = "process" Process MessageType = "process"
) )
@@ -25,5 +24,5 @@ func (message *Message) toJson() string {
} }
func SendMessage(message Message) { func SendMessage(message Message) {
SendToPort(*Port, message.toJson()) sendToPort(*Port, message.toJson())
} }

View File

@@ -7,7 +7,6 @@ import (
"fmt" "fmt"
"github.com/metacubex/mihomo/adapter" "github.com/metacubex/mihomo/adapter"
"github.com/metacubex/mihomo/adapter/outboundgroup" "github.com/metacubex/mihomo/adapter/outboundgroup"
"github.com/metacubex/mihomo/adapter/provider"
"github.com/metacubex/mihomo/common/utils" "github.com/metacubex/mihomo/common/utils"
"github.com/metacubex/mihomo/config" "github.com/metacubex/mihomo/config"
"github.com/metacubex/mihomo/constant" "github.com/metacubex/mihomo/constant"
@@ -64,30 +63,26 @@ func validateConfig(s *C.char) bool {
} }
//export updateConfig //export updateConfig
func updateConfig(s *C.char, port C.longlong) { func updateConfig(s *C.char) bool {
i := int64(port) paramsString := C.GoString(s)
go func() { var params = &GenerateConfigParams{}
paramsString := C.GoString(s) err := json.Unmarshal([]byte(paramsString), params)
var params = &GenerateConfigParams{} if err != nil {
err := json.Unmarshal([]byte(paramsString), params) log.Errorln("generateConfig Unmarshal error %v", err)
if err != nil { return false
bridge.SendToPort(i, err.Error()) }
return prof := decorationConfig(params.ProfilePath, *params.Config)
} currentConfig = prof
prof := decorationConfig(params.ProfilePath, *params.Config) if *params.IsPatch {
currentConfig = prof return applyConfig(true)
if *params.IsPatch { } else {
applyConfig(true) return applyConfig(false)
} else { }
applyConfig(false)
}
bridge.SendToPort(i, "")
}()
} }
//export getProxies //export getProxies
func getProxies() *C.char { func getProxies() *C.char {
data, err := json.Marshal(tunnel.ProxiesWithProviders()) data, err := json.Marshal(tunnel.Proxies())
if err != nil { if err != nil {
return C.CString("") return C.CString("")
} }
@@ -103,7 +98,7 @@ func changeProxy(s *C.char) bool {
log.Infoln("Unmarshal ChangeProxyParams %v", err) log.Infoln("Unmarshal ChangeProxyParams %v", err)
return false return false
} }
proxies := tunnel.ProxiesWithProviders() proxies := tunnel.Proxies()
proxy := proxies[*params.GroupName] proxy := proxies[*params.GroupName]
if proxy == nil { if proxy == nil {
return false return false
@@ -153,7 +148,7 @@ func asyncTestDelay(s *C.char) {
ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond*time.Duration(params.Timeout)) ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond*time.Duration(params.Timeout))
defer cancel() defer cancel()
proxies := tunnel.ProxiesWithProviders() proxies := tunnel.Proxies()
proxy := proxies[params.ProxyName] proxy := proxies[params.ProxyName]
delayData := &Delay{ delayData := &Delay{
@@ -240,42 +235,22 @@ func getProviders() *C.char {
return C.CString(string(data)) return C.CString(string(data))
} }
//export getProvider //export getProvider
func getProvider(name *C.char) *C.char { func getProvider(name *C.char) *C.char {
providerName := C.GoString(name) providerName := C.GoString(name)
providers := tunnel.Providers() providers := tunnel.Providers()
data, err := json.Marshal(providers[providerName]) var provider = providers[providerName]
data, err := json.Marshal(provider)
if err != nil { if err != nil {
return C.CString("") return C.CString("")
} }
return C.CString(string(data)) return C.CString(string(data))
} }
//export healthcheck
func healthcheck() {
hcCompatibleProvider(tunnel.Providers())
}
//export initNativeApiBridge //export initNativeApiBridge
func initNativeApiBridge(api unsafe.Pointer, port C.longlong) { func initNativeApiBridge(api unsafe.Pointer, port C.longlong) {
bridge.InitDartApi(api) bridge.InitDartApi(api)
i := int64(port) i := int64(port)
bridge.Port = &i bridge.Port = &i
} }
func init() {
provider.HealthcheckHook = func(name string, delay uint16) {
delayData := &Delay{
Name: name,
}
if delay == 0 {
delayData.Value = -1
} else {
delayData.Value = int32(delay)
}
bridge.SendMessage(bridge.Message{
Type: bridge.Delay,
Data: delayData,
})
}
}

View File

@@ -1,5 +1,3 @@
import 'dart:async';
import 'package:dynamic_color/dynamic_color.dart'; import 'package:dynamic_color/dynamic_color.dart';
import 'package:fl_clash/l10n/l10n.dart'; import 'package:fl_clash/l10n/l10n.dart';
import 'package:fl_clash/common/common.dart'; import 'package:fl_clash/common/common.dart';
@@ -114,6 +112,7 @@ class ApplicationState extends State<Application> {
primaryColor: config.primaryColor, primaryColor: config.primaryColor,
), ),
builder: (_, state, child) { builder: (_, state, child) {
debugPrint("[Application] update===>");
return DynamicColorBuilder( return DynamicColorBuilder(
builder: (lightDynamic, darkDynamic) { builder: (lightDynamic, darkDynamic) {
_updateSystemColorSchemes(lightDynamic, darkDynamic); _updateSystemColorSchemes(lightDynamic, darkDynamic);

View File

@@ -1,4 +1,3 @@
import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:ffi'; import 'dart:ffi';
import 'dart:io'; import 'dart:io';
@@ -17,22 +16,19 @@ class ClashCore {
late final ClashFFI clashFFI; late final ClashFFI clashFFI;
late final DynamicLibrary lib; late final DynamicLibrary lib;
DynamicLibrary _getClashLib() { ClashCore._internal() {
if (Platform.isWindows) { if (Platform.isWindows) {
return DynamicLibrary.open("libclash.dll"); lib = DynamicLibrary.open("libclash.dll");
clashFFI = ClashFFI(lib);
} }
if (Platform.isMacOS) { if (Platform.isMacOS) {
return DynamicLibrary.open("libclash.dylib"); lib = DynamicLibrary.open("libclash.dylib");
clashFFI = ClashFFI(lib);
} }
if (Platform.isAndroid || Platform.isLinux) { if (Platform.isAndroid || Platform.isLinux) {
return DynamicLibrary.open("libclash.so"); lib = DynamicLibrary.open("libclash.so");
clashFFI = ClashFFI(lib);
} }
throw "Platform is not supported";
}
ClashCore._internal() {
lib = _getClashLib();
clashFFI = ClashFFI(lib);
clashFFI.initNativeApiBridge( clashFFI.initNativeApiBridge(
NativeApi.initializeApiDLData, NativeApi.initializeApiDLData,
receiver.sendPort.nativePort, receiver.sendPort.nativePort,
@@ -65,21 +61,12 @@ class ClashCore {
1; 1;
} }
Future<String> updateConfig(UpdateConfigParams updateConfigParams) { bool updateConfig(UpdateConfigParams updateConfigParams) {
final completer = Completer<String>();
final receiver = ReceivePort();
receiver.listen((message) {
if (!completer.isCompleted) {
completer.complete(message);
receiver.close();
}
});
final params = json.encode(updateConfigParams); final params = json.encode(updateConfigParams);
clashFFI.updateConfig( return clashFFI.updateConfig(
params.toNativeUtf8().cast(), params.toNativeUtf8().cast(),
receiver.sendPort.nativePort, ) ==
); 1;
return completer.future;
} }
Future<List<Group>> getProxiesGroups() { Future<List<Group>> getProxiesGroups() {
@@ -87,22 +74,20 @@ class ClashCore {
final proxiesRawString = proxiesRaw.cast<Utf8>().toDartString(); final proxiesRawString = proxiesRaw.cast<Utf8>().toDartString();
return Isolate.run<List<Group>>(() { return Isolate.run<List<Group>>(() {
final proxies = json.decode(proxiesRawString); final proxies = json.decode(proxiesRawString);
final groupNames = [ final groupsRaw = (proxies[UsedProxy.GLOBAL.name]["all"] as List)
UsedProxy.GLOBAL.name, .where((e) {
...(proxies[UsedProxy.GLOBAL.name]["all"] as List).where((e) { final proxy = proxies[e];
final proxy = proxies[e]; final excludeName = !UsedProxyExtension.valueList
return GroupTypeExtension.valueList.contains(proxy['type']); .where((element) => element != UsedProxy.GLOBAL.name)
}) .contains(proxy['name']);
]; final validType = GroupTypeExtension.valueList.contains(proxy['type']);
final groupsRaw = groupNames.map((groupName) { return excludeName && validType;
}).map((groupName) {
final group = proxies[groupName]; final group = proxies[groupName];
group["all"] = ((group["all"] ?? []) as List) group["all"] = ((group["all"] ?? []) as List)
.map( .map(
(name) => proxies[name], (name) => proxies[name],
) )
.where(
(proxy) => proxy["type"] != GroupType.Selector.value,
)
.toList(); .toList();
return group; return group;
}).toList(); }).toList();
@@ -124,10 +109,6 @@ class ClashCore {
return true; return true;
} }
healthcheck() {
clashFFI.healthcheck();
}
VersionInfo getVersionInfo() { VersionInfo getVersionInfo() {
final versionInfoRaw = clashFFI.getVersionInfo(); final versionInfoRaw = clashFFI.getVersionInfo();
final versionInfo = json.decode(versionInfoRaw.cast<Utf8>().toDartString()); final versionInfo = json.decode(versionInfoRaw.cast<Utf8>().toDartString());

View File

@@ -907,22 +907,19 @@ class ClashFFI {
late final _validateConfig = late final _validateConfig =
_validateConfigPtr.asFunction<int Function(ffi.Pointer<ffi.Char>)>(); _validateConfigPtr.asFunction<int Function(ffi.Pointer<ffi.Char>)>();
void updateConfig( int updateConfig(
ffi.Pointer<ffi.Char> s, ffi.Pointer<ffi.Char> s,
int port,
) { ) {
return _updateConfig( return _updateConfig(
s, s,
port,
); );
} }
late final _updateConfigPtr = _lookup< late final _updateConfigPtr =
ffi.NativeFunction< _lookup<ffi.NativeFunction<GoUint8 Function(ffi.Pointer<ffi.Char>)>>(
ffi.Void Function( 'updateConfig');
ffi.Pointer<ffi.Char>, ffi.LongLong)>>('updateConfig');
late final _updateConfig = late final _updateConfig =
_updateConfigPtr.asFunction<void Function(ffi.Pointer<ffi.Char>, int)>(); _updateConfigPtr.asFunction<int Function(ffi.Pointer<ffi.Char>)>();
ffi.Pointer<ffi.Char> getProxies() { ffi.Pointer<ffi.Char> getProxies() {
return _getProxies(); return _getProxies();
@@ -1040,14 +1037,6 @@ class ClashFFI {
late final _getProvider = _getProviderPtr late final _getProvider = _getProviderPtr
.asFunction<ffi.Pointer<ffi.Char> Function(ffi.Pointer<ffi.Char>)>(); .asFunction<ffi.Pointer<ffi.Char> Function(ffi.Pointer<ffi.Char>)>();
void healthcheck() {
return _healthcheck();
}
late final _healthcheckPtr =
_lookup<ffi.NativeFunction<ffi.Void Function()>>('healthcheck');
late final _healthcheck = _healthcheckPtr.asFunction<void Function()>();
void initNativeApiBridge( void initNativeApiBridge(
ffi.Pointer<ffi.Void> api, ffi.Pointer<ffi.Void> api,
int port, int port,

View File

@@ -15,8 +15,6 @@ abstract mixin class ClashMessageListener {
void onDelay(Delay delay) {} void onDelay(Delay delay) {}
void onProcess(Metadata metadata) {} void onProcess(Metadata metadata) {}
void onNow(Now now) {}
} }
class ClashMessage { class ClashMessage {
@@ -43,9 +41,6 @@ class ClashMessage {
case MessageType.process: case MessageType.process:
listener.onProcess(Metadata.fromJson(m.data)); listener.onProcess(Metadata.fromJson(m.data));
break; break;
case MessageType.now:
listener.onNow(Now.fromJson(m.data));
break;
} }
} }
}); });

View File

@@ -19,8 +19,8 @@ Function debounce<F extends Function>(F func,{int milliseconds = 600}) {
if (timer != null) { if (timer != null) {
timer!.cancel(); timer!.cancel();
} }
timer = Timer(Duration(milliseconds: milliseconds), () async { timer = Timer(Duration(milliseconds: milliseconds), () {
await Function.apply(func, args ?? [], namedArgs); Function.apply(func, args ?? [], namedArgs);
}); });
}; };
} }

View File

@@ -35,6 +35,7 @@ class AppController {
config: config, config: config,
clashConfig: clashConfig, clashConfig: clashConfig,
); );
updateRunTime(); updateRunTime();
updateTraffic(); updateTraffic();
globalState.updateFunctionLists = [ globalState.updateFunctionLists = [
@@ -114,7 +115,7 @@ class AppController {
} }
} }
Future<String> updateClashConfig({bool isPatch = true}) async { Future<bool> updateClashConfig({bool isPatch = true}) async {
return await globalState.updateClashConfig( return await globalState.updateClashConfig(
clashConfig: clashConfig, clashConfig: clashConfig,
config: config, config: config,
@@ -122,31 +123,12 @@ class AppController {
); );
} }
applyProfile() async {
await globalState.applyProfile(
appState: appState,
config: config,
clashConfig: clashConfig,
);
}
Function? _changeProfileDebounce;
changeProfileDebounce(String? profileId) {
if (profileId == config.currentProfileId) return;
config.currentProfileId = profileId;
_changeProfileDebounce ??= debounce<Function(String?)>((profileId) async {
await applyProfile();
appState.delayMap = {};
saveConfigPreferences();
});
_changeProfileDebounce!([profileId]);
}
changeProfile(String? value) async { changeProfile(String? value) async {
if (value == config.currentProfileId) return; if (value == config.currentProfileId) return;
config.currentProfileId = value; config.currentProfileId = value;
await applyProfile(); await updateClashConfig(isPatch: false);
await updateGroups();
changeProxy();
appState.delayMap = {}; appState.delayMap = {};
saveConfigPreferences(); saveConfigPreferences();
} }
@@ -160,7 +142,10 @@ class AppController {
) )
.isBeforeNow(); .isBeforeNow();
if (isNotNeedUpdate == false) continue; if (isNotNeedUpdate == false) continue;
await profile.update(); final result = await profile.update();
if (result.type == ResultType.error) continue;
await updateGroups();
changeProxy();
} }
} }
@@ -222,30 +207,19 @@ class AppController {
} }
afterInit() async { afterInit() async {
if (config.autoRun) { if (appState.isInit) {
await updateSystemProxy(true); if (config.autoRun) {
} else { await updateSystemProxy(true);
await proxyManager.updateStartTime(); } else {
await updateSystemProxy(proxyManager.isStart); await proxyManager.updateStartTime();
await updateSystemProxy(proxyManager.isStart);
}
autoUpdateProfiles();
updateLogStatus();
if (!config.silentLaunch) {
window?.show();
}
} }
autoUpdateProfiles();
updateLogStatus();
if (!config.silentLaunch) {
window?.show();
}
}
healthcheck() {
if (globalState.healthcheckLock) return;
for (final delay in appState.delayMap.entries) {
setDelay(
Delay(
name: delay.key,
value: 0,
),
);
}
clashCore.healthcheck();
} }
setDelay(Delay delay) { setDelay(Delay delay) {

View File

@@ -52,4 +52,4 @@ enum ProfileType { file, url }
enum ResultType { success, error } enum ResultType { success, error }
enum MessageType { log, tun, delay, process, now } enum MessageType { log, tun, delay, process }

View File

@@ -80,15 +80,6 @@ class AboutFragment extends StatelessWidget {
}); });
}, },
), ),
ListTile(
title: const Text("Telegram"),
onTap: () {
launchUrl(
Uri.parse("https://t.me/+G-veVtwBOl4wODc1"),
);
},
trailing: const Icon(Icons.launch),
),
ListTile( ListTile(
title: Text(appLocalizations.project), title: Text(appLocalizations.project),
onTap: () { onTap: () {

View File

@@ -12,6 +12,7 @@ class CoreInfo extends StatelessWidget {
return Selector<AppState, VersionInfo?>( return Selector<AppState, VersionInfo?>(
selector: (_, appState) => appState.versionInfo, selector: (_, appState) => appState.versionInfo,
builder: (_, versionInfo, __) { builder: (_, versionInfo, __) {
debugPrint("[CoreInfo] update===>");
return CommonCard( return CommonCard(
info: Info( info: Info(
label: appLocalizations.coreInfo, label: appLocalizations.coreInfo,

View File

@@ -1,6 +1,6 @@
import 'package:fl_clash/common/common.dart'; import 'package:fl_clash/common/common.dart';
import 'package:fl_clash/enum/enum.dart';
import 'package:fl_clash/models/models.dart'; import 'package:fl_clash/models/models.dart';
import 'package:fl_clash/state.dart';
import 'package:fl_clash/widgets/widgets.dart'; import 'package:fl_clash/widgets/widgets.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
@@ -25,11 +25,6 @@ class _NetworkDetectionState extends State<NetworkDetection> {
), ),
); );
} }
if (currentProxyName == UsedProxy.DIRECT.name) {
return const Icon(
Icons.offline_bolt_outlined,
);
}
if (delay == 0 || delay == null) { if (delay == 0 || delay == null) {
return const AspectRatio( return const AspectRatio(
aspectRatio: 1, aspectRatio: 1,
@@ -78,6 +73,57 @@ class _NetworkDetectionState extends State<NetworkDetection> {
); );
} }
_updateCurrentDelay(
String? currentProxyName,
int? delay,
bool isCurrent,
bool isInit,
) {
if (!isCurrent || currentProxyName == null || !isInit) return;
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
if (delay == null) {
context.appController.setDelay(
Delay(
name: currentProxyName,
value: 0,
),
);
globalState.updateCurrentDelay(
currentProxyName,
);
}
});
}
_updateCurrentDelayContainer(Widget child) {
return Selector3<AppState, Config, ClashConfig,
UpdateCurrentDelaySelectorState>(
selector: (_, appState, config, clashConfig) {
final proxyName = appState.getCurrentProxyName(
config.currentProxyName,
clashConfig.mode,
);
return UpdateCurrentDelaySelectorState(
isInit: appState.isInit,
currentProxyName: proxyName,
delay: appState.delayMap[proxyName],
isCurrent: appState.currentLabel == 'dashboard',
);
},
builder: (_, state, __) {
debugPrint("[UpdateCurrentDelay] update===>");
_updateCurrentDelay(
state.currentProxyName,
state.delay,
state.isCurrent,
state.isInit,
);
return child;
},
child: child,
);
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return CommonCard( return CommonCard(
@@ -85,59 +131,59 @@ class _NetworkDetectionState extends State<NetworkDetection> {
iconData: Icons.network_check, iconData: Icons.network_check,
label: appLocalizations.networkDetection, label: appLocalizations.networkDetection,
), ),
child: Selector3<AppState, Config, ClashConfig, child: _updateCurrentDelayContainer(
NetworkDetectionSelectorState>( Selector3<AppState, Config, ClashConfig, NetworkDetectionSelectorState>(
selector: (_, appState, config, clashConfig) { selector: (_, appState, config, clashConfig) {
final proxyName = appState.getCurrentProxyName( final proxyName = appState.getCurrentProxyName(
config.currentProxyName, config.currentProxyName,
clashConfig.mode, clashConfig.mode,
); );
return NetworkDetectionSelectorState( return NetworkDetectionSelectorState(
isInit: appState.isInit, isInit: appState.isInit,
currentProxyName: proxyName, currentProxyName: proxyName,
delay: appState.getDelay( delay: appState.delayMap[proxyName],
proxyName, );
), },
); builder: (_, state, __) {
}, debugPrint("[NetworkDetection] update===>");
builder: (_, state, __) { return Container(
return Container( padding: const EdgeInsets.all(16).copyWith(top: 0),
padding: const EdgeInsets.all(16).copyWith(top: 0), child: Column(
child: Column( mainAxisSize: MainAxisSize.min,
mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, children: [
children: [ Flexible(
Flexible( flex: 0,
flex: 0, child: TooltipText(
child: TooltipText( text: Text(
text: Text( state.currentProxyName ?? appLocalizations.noProxy,
state.currentProxyName ?? appLocalizations.noProxy, overflow: TextOverflow.ellipsis,
overflow: TextOverflow.ellipsis, maxLines: 1,
maxLines: 1, style:
style: Theme.of(context).textTheme.titleMedium?.toSoftBold(),
Theme.of(context).textTheme.titleMedium?.toSoftBold(),
),
),
),
const SizedBox(
height: 8,
),
Flexible(
child: Container(
height: context.appController.measure.titleLargeHeight,
alignment: Alignment.centerLeft,
child: FadeBox(
child: _buildDescription(
state.currentProxyName,
state.delay,
), ),
), ),
), ),
), const SizedBox(
], height: 8,
), ),
); Flexible(
}, child: Container(
height: context.appController.measure.titleLargeHeight,
alignment: Alignment.centerLeft,
child: FadeBox(
child: _buildDescription(
state.currentProxyName,
state.delay,
),
),
),
),
],
),
);
},
),
), ),
); );
} }

View File

@@ -51,7 +51,7 @@ class _StartButtonState extends State<StartButton>
final appController = context.appController; final appController = context.appController;
await appController.updateSystemProxy(isStart); await appController.updateSystemProxy(isStart);
if (isStart && mounted) { if (isStart && mounted) {
appController.healthcheck(); appController.clearCurrentDelay();
} }
} }
@@ -63,6 +63,7 @@ class _StartButtonState extends State<StartButton>
hasProfile: config.profiles.isNotEmpty, hasProfile: config.profiles.isNotEmpty,
), ),
builder: (_, state, child) { builder: (_, state, child) {
debugPrint("[StartButton] update===>");
if (!state.isInit || !state.hasProfile) { if (!state.isInit || !state.hasProfile) {
return Container(); return Container();
} }

View File

@@ -24,7 +24,6 @@ class ProfilesFragment extends StatefulWidget {
} }
class _ProfilesFragmentState extends State<ProfilesFragment> { class _ProfilesFragmentState extends State<ProfilesFragment> {
String _getLastUpdateTimeDifference(DateTime lastDateTime) { String _getLastUpdateTimeDifference(DateTime lastDateTime) {
final currentDateTime = DateTime.now(); final currentDateTime = DateTime.now();
final difference = currentDateTime.difference(lastDateTime); final difference = currentDateTime.difference(lastDateTime);
@@ -210,7 +209,7 @@ class _ProfilesFragmentState extends State<ProfilesFragment> {
child: _profileItem( child: _profileItem(
profile: profile, profile: profile,
groupValue: state.currentProfileId, groupValue: state.currentProfileId,
onChanged: context.appController.changeProfileDebounce, onChanged: context.appController.changeProfile,
), ),
), ),
], ],
@@ -235,6 +234,7 @@ class _ProfilesFragmentState extends State<ProfilesFragment> {
currentProfileId: config.currentProfileId, currentProfileId: config.currentProfileId,
), ),
builder: (context, state, child) { builder: (context, state, child) {
debugPrint("[Profiles] update===>");
if (state.profiles.isEmpty) { if (state.profiles.isEmpty) {
return NullStatus( return NullStatus(
label: appLocalizations.nullProfileDesc, label: appLocalizations.nullProfileDesc,

View File

@@ -58,87 +58,146 @@ class _ProxiesFragmentState extends State<ProxiesFragment>
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return DelayTestButtonContainer( return Selector<AppState, bool>(
child: Selector<AppState, bool>( selector: (_, appState) => appState.currentLabel == 'proxies',
selector: (_, appState) => appState.currentLabel == 'proxies', builder: (_, isCurrent, child) {
builder: (_, isCurrent, child) { if (isCurrent) {
if (isCurrent) { _initActions();
_initActions(); }
} return child!;
return child!; },
child: Selector3<AppState, Config, ClashConfig, ProxiesSelectorState>(
selector: (_, appState, config, clashConfig) {
final currentGroups = appState.getCurrentGroups(clashConfig.mode);
final currentProxyName = appState.getCurrentGroupNameWithGroups(
currentGroups,
config.currentGroupName,
clashConfig.mode,
);
final currentIndex = currentGroups
.indexWhere((element) => element.name == currentProxyName);
return ProxiesSelectorState(
currentIndex: currentIndex != -1 ? currentIndex : 0,
groups: currentGroups,
);
}, },
child: Selector3<AppState, Config, ClashConfig, ProxiesSelectorState>( builder: (_, state, __) {
selector: (_, appState, config, clashConfig) { if (_tabController != null) {
final currentGroups = appState.getCurrentGroups(clashConfig.mode); _tabController!.dispose();
final groupNames = currentGroups.map((e) => e.name).toList(); _tabController = null;
final currentProxyName = appState.getCurrentGroupNameWithGroups( }
currentGroups, _tabController = TabController(
config.currentGroupName, length: state.groups.length,
clashConfig.mode, vsync: this,
); initialIndex: state.currentIndex,
final currentIndex = currentGroups );
.indexWhere((element) => element.name == currentProxyName); debugPrint("[Proxies] update===>");
return ProxiesSelectorState( return Column(
currentIndex: currentIndex, mainAxisAlignment: MainAxisAlignment.start,
groupNames: groupNames, crossAxisAlignment: CrossAxisAlignment.start,
); children: [
}, TabBar(
builder: (_, state, __) { controller: _tabController,
_tabController ??= TabController( padding: const EdgeInsets.symmetric(horizontal: 16),
length: state.groupNames.length, dividerColor: Colors.transparent,
vsync: this, isScrollable: true,
initialIndex: state.currentIndex, tabAlignment: TabAlignment.start,
); overlayColor:
return Column( const MaterialStatePropertyAll(Colors.transparent),
mainAxisAlignment: MainAxisAlignment.start, tabs: [
crossAxisAlignment: CrossAxisAlignment.start, for (final group in state.groups)
children: [ Tab(
TabBar( text: group.name,
),
],
),
Expanded(
child: TabBarView(
controller: _tabController, controller: _tabController,
padding: const EdgeInsets.symmetric(horizontal: 16), children: [
dividerColor: Colors.transparent, for (final group in state.groups)
isScrollable: true, KeepContainer(
tabAlignment: TabAlignment.start, child: ProxiesTabView(
overlayColor: group: group,
const MaterialStatePropertyAll(Colors.transparent), ),
tabs: [
for (final groupName in state.groupNames)
Tab(
text: groupName,
), ),
], ],
), ),
Expanded( )
child: TabBarView( ],
controller: _tabController, );
children: [ },
for (final groupName in state.groupNames)
KeepContainer(
key: ObjectKey(groupName),
child: ProxiesTabView(
groupName: groupName,
),
),
],
),
)
],
);
},
),
), ),
); );
} }
} }
class ProxiesTabView extends StatelessWidget { class ProxiesTabView extends StatefulWidget {
final String groupName; final Group group;
const ProxiesTabView({ const ProxiesTabView({
super.key, super.key,
required this.groupName, required this.group,
}); });
@override
State<ProxiesTabView> createState() => _ProxiesTabViewState();
}
class _ProxiesTabViewState extends State<ProxiesTabView>
with SingleTickerProviderStateMixin {
var lock = false;
late AnimationController _controller;
late Animation<double> _scale;
late Animation<double> _opacity;
@override
void initState() {
super.initState();
_controller = AnimationController(
vsync: this,
duration: const Duration(
milliseconds: 200,
),
);
_scale = Tween<double>(
begin: 1.0,
end: 0.8,
).animate(
CurvedAnimation(
parent: _controller,
curve: const Interval(
0.0,
0.3,
curve: Curves.easeIn,
),
),
);
_opacity = Tween<double>(
begin: 1.0,
end: 0.0,
).animate(
CurvedAnimation(
parent: _controller,
curve: const Interval(
0,
1,
curve: Curves.easeIn,
),
),
);
}
@override
void dispose() {
super.dispose();
_controller.dispose();
}
get group => widget.group;
get measure => context.appController.measure;
List<Proxy> _sortOfName(List<Proxy> proxies) { List<Proxy> _sortOfName(List<Proxy> proxies) {
return List.of(proxies) return List.of(proxies)
..sort( ..sort(
@@ -146,7 +205,7 @@ class ProxiesTabView extends StatelessWidget {
); );
} }
List<Proxy> _sortOfDelay(BuildContext context, List<Proxy> proxies) { List<Proxy> _sortOfDelay(List<Proxy> proxies) {
final appState = context.read<AppState>(); final appState = context.read<AppState>();
final delayMap = appState.delayMap; final delayMap = appState.delayMap;
return proxies = List.of(proxies) return proxies = List.of(proxies)
@@ -169,19 +228,38 @@ class ProxiesTabView extends StatelessWidget {
} }
_getProxies( _getProxies(
BuildContext context,
List<Proxy> proxies, List<Proxy> proxies,
ProxiesSortType proxiesSortType, ProxiesSortType proxiesSortType,
) { ) {
if (proxiesSortType == ProxiesSortType.delay) { if (proxiesSortType == ProxiesSortType.delay) return _sortOfDelay(proxies);
return _sortOfDelay(context, proxies);
}
if (proxiesSortType == ProxiesSortType.name) return _sortOfName(proxies); if (proxiesSortType == ProxiesSortType.name) return _sortOfName(proxies);
return proxies; return proxies;
} }
double _getItemHeight(BuildContext context) { _getDelayMap() async {
final measure = context.appController.measure; if (lock == true) return;
lock = true;
_controller.forward();
for (final proxy in group.all) {
context.appController.setDelay(
Delay(
name: proxy.name,
value: 0,
),
);
clashCore.delay(
proxy.name,
);
}
await Future.delayed(
appConstant.httpTimeoutDuration + appConstant.moreDuration,
);
lock = false;
_controller.reverse();
setState(() {});
}
double _getItemHeight() {
return 12 * 2 + return 12 * 2 +
measure.bodyMediumHeight * 2 + measure.bodyMediumHeight * 2 +
measure.bodySmallHeight + measure.bodySmallHeight +
@@ -189,13 +267,11 @@ class ProxiesTabView extends StatelessWidget {
8 * 2; 8 * 2;
} }
_card( _card({
BuildContext context, {
required void Function() onPressed, required void Function() onPressed,
required bool isSelected, required bool isSelected,
required Proxy proxy, required Proxy proxy,
}) { }) {
final measure = context.appController.measure;
return CommonCard( return CommonCard(
isSelected: isSelected, isSelected: isSelected,
onPressed: onPressed, onPressed: onPressed,
@@ -246,7 +322,7 @@ class ProxiesTabView extends StatelessWidget {
SizedBox( SizedBox(
height: measure.labelSmallHeight, height: measure.labelSmallHeight,
child: Selector<AppState, int?>( child: Selector<AppState, int?>(
selector: (context, appState) => appState.getDelay(proxy.name), selector: (context, appState) => appState.delayMap[proxy.name],
builder: (_, delay, __) { builder: (_, delay, __) {
return FadeBox( return FadeBox(
child: Builder( child: Builder(
@@ -284,217 +360,107 @@ class ProxiesTabView extends StatelessWidget {
); );
} }
Widget _buildGrid( _buildGrid({
BuildContext context, { required ProxiesSortType proxiesSortType,
required List<Proxy> proxies,
required int columns, required int columns,
}) { }) {
return GridView.builder( return SingleChildScrollView(
padding: const EdgeInsets.all(16), padding: const EdgeInsets.all(16),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( child: AnimateGrid<Proxy>(
crossAxisCount: columns, items: _getProxies(group.all, proxiesSortType),
mainAxisSpacing: 8, columns: columns,
crossAxisSpacing: 8, itemHeight: _getItemHeight(),
mainAxisExtent: _getItemHeight(context), keyBuilder: (item) {
), return ObjectKey(item);
itemCount: proxies.length, },
itemBuilder: (_, index) { builder: (_, proxy) {
final proxy = proxies[index]; return Selector3<AppState, Config, ClashConfig, String?>(
return Selector3<AppState, Config, ClashConfig, selector: (_, appState, config, clashConfig) =>
ProxiesCardSelectorState>( appState.getCurrentProxyName(
selector: (_, appState, config, clashConfig) {
final currentGroupName = appState.getCurrentGroupName(
config.currentGroupName,
clashConfig.mode,
);
final currentProxyName = appState.getCurrentProxyName(
config.currentProxyName, config.currentProxyName,
clashConfig.mode, clashConfig.mode,
); ),
final group = appState.getGroupWithName(groupName); builder: (_, value, __) {
final isSelected = group.type == GroupType.Selector final currentProxyName =
? group.name == currentGroupName && group.type == GroupType.Selector ? value : group.now;
proxy.name == currentProxyName return _card(
: group.now == proxy.name; isSelected: proxy.name == currentProxyName,
return ProxiesCardSelectorState( onPressed: () {
isSelected: isSelected, if (group.type == GroupType.Selector) {
currentGroupName: currentGroupName, final config = context.read<Config>();
currentProxyName: currentProxyName, config.currentProfile?.groupName = group.name;
); config.currentProfile?.proxyName = proxy.name;
}, config.update();
builder: (_, state, __) { context.appController.changeProxy();
return _card( }
context, },
isSelected: state.isSelected, proxy: proxy,
onPressed: () { );
final group =
context.appController.appState.getGroupWithName(groupName);
if (group.type == GroupType.Selector) {
final config = context.read<Config>();
config.currentProfile?.groupName = group.name;
config.currentProfile?.proxyName = proxy.name;
config.update();
context.appController.changeProxy();
}
},
proxy: proxy,
);
},
);
},
);
}
@override
Widget build(BuildContext context) {
return Selector2<AppState, Config, ProxiesTabViewSelectorState>(
selector: (_, appState, config) {
return ProxiesTabViewSelectorState(
proxiesSortType: config.proxiesSortType,
sortNum: appState.sortNum,
group: appState.getGroupWithName(groupName),
);
},
builder: (_, state, __) {
final proxies = _getProxies(
context,
state.group.all,
state.proxiesSortType,
);
return Align(
alignment: Alignment.topCenter,
child: SlotLayout(
config: {
Breakpoints.small: SlotLayout.from(
key: const Key('proxies_grid_small'),
builder: (_) => _buildGrid(
context,
proxies: proxies,
columns: 2,
),
),
Breakpoints.medium: SlotLayout.from(
key: const Key('proxies_grid_medium'),
builder: (_) => _buildGrid(
context,
proxies: proxies,
columns: 3,
),
),
Breakpoints.large: SlotLayout.from(
key: const Key('proxies_grid_large'),
builder: (_) => _buildGrid(
context,
proxies: proxies,
columns: 4,
),
),
}, },
);
},
),
);
}
@override
Widget build(BuildContext context) {
return Selector<Config, ProxiesSortType>(
selector: (_, config) => config.proxiesSortType,
builder: (_, proxiesSortType, __) {
return FloatLayout(
floatingWidget: FloatWrapper(
child: AnimatedBuilder(
animation: _controller,
builder: (_, __) {
return Transform.scale(
scale: _scale.value,
child: SizedBox(
width: 56,
height: 56,
child: Opacity(
opacity: _opacity.value,
child: FloatingActionButton(
heroTag: null,
onPressed: _getDelayMap,
child: const Icon(Icons.network_ping),
),
),
),
);
},
),
),
child: Align(
alignment: Alignment.topCenter,
child: SlotLayout(
config: {
Breakpoints.small: SlotLayout.from(
key: const Key('proxies_grid_small'),
builder: (_) => _buildGrid(
proxiesSortType: proxiesSortType,
columns: 2,
),
),
Breakpoints.medium: SlotLayout.from(
key: const Key('proxies_grid_medium'),
builder: (_) => _buildGrid(
proxiesSortType: proxiesSortType,
columns: 3,
),
),
Breakpoints.large: SlotLayout.from(
key: const Key('proxies_grid_large'),
builder: (_) => _buildGrid(
proxiesSortType: proxiesSortType,
columns: 4,
),
),
},
),
), ),
); );
}, },
); );
} }
} }
class DelayTestButtonContainer extends StatefulWidget {
final Widget child;
const DelayTestButtonContainer({
super.key,
required this.child,
});
@override
State<DelayTestButtonContainer> createState() =>
_DelayTestButtonContainerState();
}
class _DelayTestButtonContainerState extends State<DelayTestButtonContainer>
with SingleTickerProviderStateMixin {
late AnimationController _controller;
late Animation<double> _scale;
late Animation<double> _opacity;
_healthcheck() async {
_controller.forward();
context.appController.healthcheck();
await Future.delayed(
appConstant.httpTimeoutDuration + appConstant.moreDuration,
);
_controller.reverse();
}
@override
void initState() {
super.initState();
_controller = AnimationController(
vsync: this,
duration: const Duration(
milliseconds: 300,
),
);
_scale = Tween<double>(
begin: 1.0,
end: 0.0,
).animate(
CurvedAnimation(
parent: _controller,
curve: const Interval(
0,
1,
curve: Curves.easeIn,
),
),
);
_opacity = Tween<double>(
begin: 1.0,
end: 0.0,
).animate(
CurvedAnimation(
parent: _controller,
curve: const Interval(
0,
1,
curve: Curves.easeIn,
),
),
);
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return FloatLayout(
floatingWidget: FloatWrapper(
child: AnimatedBuilder(
animation: _controller,
builder: (_, child) {
return SizedBox(
width: 56,
height: 56,
child: Transform.scale(
scale: _scale.value,
child: Opacity(
opacity: _opacity.value,
child: child!,
),
),
);
},
child: FloatingActionButton(
heroTag: null,
onPressed: _healthcheck,
child: const Icon(Icons.network_ping),
),
),
),
child: widget.child,
);
}
}

View File

@@ -22,7 +22,6 @@ class AppState with ChangeNotifier {
String _currentLabel; String _currentLabel;
SystemColorSchemes _systemColorSchemes; SystemColorSchemes _systemColorSchemes;
List<Group> _groups; List<Group> _groups;
num _sortNum;
AppState() AppState()
: _navigationItems = [], : _navigationItems = [],
@@ -33,7 +32,6 @@ class AppState with ChangeNotifier {
_logs = [], _logs = [],
_groups = [], _groups = [],
_packages = [], _packages = [],
_sortNum = 0,
_systemColorSchemes = SystemColorSchemes(); _systemColorSchemes = SystemColorSchemes();
String get currentLabel => _currentLabel; String get currentLabel => _currentLabel;
@@ -81,15 +79,6 @@ class AppState with ChangeNotifier {
} }
} }
int? getDelay(String? proxyName) {
if (proxyName == null) return null;
final index = groups.indexWhere((element) => element.name == proxyName);
if (index == -1) return _delayMap[proxyName];
final group = groups[index];
if (group.now == null) return null;
return _delayMap[group.now];
}
setDelay(Delay delay) { setDelay(Delay delay) {
if (_delayMap[delay.name] != delay.value) { if (_delayMap[delay.name] != delay.value) {
_delayMap = Map.from(_delayMap)..[delay.name] = delay.value; _delayMap = Map.from(_delayMap)..[delay.name] = delay.value;
@@ -155,21 +144,12 @@ class AppState with ChangeNotifier {
List<Group> get groups => _groups; List<Group> get groups => _groups;
set groups(List<Group> value) { set groups(List<Group> value) {
if (!const ListEquality<Group>().equals(_groups, value)) { if (_groups != value) {
_groups = value; _groups = value;
notifyListeners(); notifyListeners();
} }
} }
num get sortNum => _sortNum;
set sortNum(num value) {
if (_sortNum != value) {
_sortNum = value;
notifyListeners();
}
}
List<Group> getCurrentGroups(Mode mode) { List<Group> getCurrentGroups(Mode mode) {
switch (mode) { switch (mode) {
case Mode.direct: case Mode.direct:
@@ -205,10 +185,6 @@ class AppState with ChangeNotifier {
return getCurrentGroupNameWithGroups(currentGroups, groupName, mode); return getCurrentGroupNameWithGroups(currentGroups, groupName, mode);
} }
Group getGroupWithName(String groupName) {
return groups.firstWhere((e) => e.name == groupName);
}
String? getCurrentProxyName(String? proxyName, Mode mode) { String? getCurrentProxyName(String? proxyName, Mode mode) {
final currentGroups = getCurrentGroups(mode); final currentGroups = getCurrentGroups(mode);
switch (mode) { switch (mode) {

View File

@@ -52,16 +52,6 @@ class Delay with _$Delay {
factory Delay.fromJson(Map<String, Object?> json) => _$DelayFromJson(json); factory Delay.fromJson(Map<String, Object?> json) => _$DelayFromJson(json);
} }
@freezed
class Now with _$Now {
const factory Now({
required String name,
required String value,
}) = _Now;
factory Now.fromJson(Map<String, Object?> json) => _$NowFromJson(json);
}
@freezed @freezed
class Process with _$Process { class Process with _$Process {
const factory Process({ const factory Process({

View File

@@ -672,151 +672,6 @@ abstract class _Delay implements Delay {
throw _privateConstructorUsedError; throw _privateConstructorUsedError;
} }
Now _$NowFromJson(Map<String, dynamic> json) {
return _Now.fromJson(json);
}
/// @nodoc
mixin _$Now {
String get name => throw _privateConstructorUsedError;
String get value => throw _privateConstructorUsedError;
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$NowCopyWith<Now> get copyWith => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $NowCopyWith<$Res> {
factory $NowCopyWith(Now value, $Res Function(Now) then) =
_$NowCopyWithImpl<$Res, Now>;
@useResult
$Res call({String name, String value});
}
/// @nodoc
class _$NowCopyWithImpl<$Res, $Val extends Now> implements $NowCopyWith<$Res> {
_$NowCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
@pragma('vm:prefer-inline')
@override
$Res call({
Object? name = null,
Object? value = null,
}) {
return _then(_value.copyWith(
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
value: null == value
? _value.value
: value // ignore: cast_nullable_to_non_nullable
as String,
) as $Val);
}
}
/// @nodoc
abstract class _$$NowImplCopyWith<$Res> implements $NowCopyWith<$Res> {
factory _$$NowImplCopyWith(_$NowImpl value, $Res Function(_$NowImpl) then) =
__$$NowImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({String name, String value});
}
/// @nodoc
class __$$NowImplCopyWithImpl<$Res> extends _$NowCopyWithImpl<$Res, _$NowImpl>
implements _$$NowImplCopyWith<$Res> {
__$$NowImplCopyWithImpl(_$NowImpl _value, $Res Function(_$NowImpl) _then)
: super(_value, _then);
@pragma('vm:prefer-inline')
@override
$Res call({
Object? name = null,
Object? value = null,
}) {
return _then(_$NowImpl(
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
value: null == value
? _value.value
: value // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
/// @nodoc
@JsonSerializable()
class _$NowImpl implements _Now {
const _$NowImpl({required this.name, required this.value});
factory _$NowImpl.fromJson(Map<String, dynamic> json) =>
_$$NowImplFromJson(json);
@override
final String name;
@override
final String value;
@override
String toString() {
return 'Now(name: $name, value: $value)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$NowImpl &&
(identical(other.name, name) || other.name == name) &&
(identical(other.value, value) || other.value == value));
}
@JsonKey(ignore: true)
@override
int get hashCode => Object.hash(runtimeType, name, value);
@JsonKey(ignore: true)
@override
@pragma('vm:prefer-inline')
_$$NowImplCopyWith<_$NowImpl> get copyWith =>
__$$NowImplCopyWithImpl<_$NowImpl>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$$NowImplToJson(
this,
);
}
}
abstract class _Now implements Now {
const factory _Now(
{required final String name, required final String value}) = _$NowImpl;
factory _Now.fromJson(Map<String, dynamic> json) = _$NowImpl.fromJson;
@override
String get name;
@override
String get value;
@override
@JsonKey(ignore: true)
_$$NowImplCopyWith<_$NowImpl> get copyWith =>
throw _privateConstructorUsedError;
}
Process _$ProcessFromJson(Map<String, dynamic> json) { Process _$ProcessFromJson(Map<String, dynamic> json) {
return _Process.fromJson(json); return _Process.fromJson(json);
} }

View File

@@ -53,7 +53,6 @@ const _$MessageTypeEnumMap = {
MessageType.tun: 'tun', MessageType.tun: 'tun',
MessageType.delay: 'delay', MessageType.delay: 'delay',
MessageType.process: 'process', MessageType.process: 'process',
MessageType.now: 'now',
}; };
_$DelayImpl _$$DelayImplFromJson(Map<String, dynamic> json) => _$DelayImpl( _$DelayImpl _$$DelayImplFromJson(Map<String, dynamic> json) => _$DelayImpl(
@@ -67,16 +66,6 @@ Map<String, dynamic> _$$DelayImplToJson(_$DelayImpl instance) =>
'value': instance.value, 'value': instance.value,
}; };
_$NowImpl _$$NowImplFromJson(Map<String, dynamic> json) => _$NowImpl(
name: json['name'] as String,
value: json['value'] as String,
);
Map<String, dynamic> _$$NowImplToJson(_$NowImpl instance) => <String, dynamic>{
'name': instance.name,
'value': instance.value,
};
_$ProcessImpl _$$ProcessImplFromJson(Map<String, dynamic> json) => _$ProcessImpl _$$ProcessImplFromJson(Map<String, dynamic> json) =>
_$ProcessImpl( _$ProcessImpl(
uid: (json['uid'] as num).toInt(), uid: (json['uid'] as num).toInt(),

View File

@@ -1744,7 +1744,7 @@ abstract class _HomeNavigationSelectorState
/// @nodoc /// @nodoc
mixin _$ProxiesSelectorState { mixin _$ProxiesSelectorState {
int get currentIndex => throw _privateConstructorUsedError; int get currentIndex => throw _privateConstructorUsedError;
List<String> get groupNames => throw _privateConstructorUsedError; List<Group> get groups => throw _privateConstructorUsedError;
@JsonKey(ignore: true) @JsonKey(ignore: true)
$ProxiesSelectorStateCopyWith<ProxiesSelectorState> get copyWith => $ProxiesSelectorStateCopyWith<ProxiesSelectorState> get copyWith =>
@@ -1757,7 +1757,7 @@ abstract class $ProxiesSelectorStateCopyWith<$Res> {
$Res Function(ProxiesSelectorState) then) = $Res Function(ProxiesSelectorState) then) =
_$ProxiesSelectorStateCopyWithImpl<$Res, ProxiesSelectorState>; _$ProxiesSelectorStateCopyWithImpl<$Res, ProxiesSelectorState>;
@useResult @useResult
$Res call({int currentIndex, List<String> groupNames}); $Res call({int currentIndex, List<Group> groups});
} }
/// @nodoc /// @nodoc
@@ -1775,17 +1775,17 @@ class _$ProxiesSelectorStateCopyWithImpl<$Res,
@override @override
$Res call({ $Res call({
Object? currentIndex = null, Object? currentIndex = null,
Object? groupNames = null, Object? groups = null,
}) { }) {
return _then(_value.copyWith( return _then(_value.copyWith(
currentIndex: null == currentIndex currentIndex: null == currentIndex
? _value.currentIndex ? _value.currentIndex
: currentIndex // ignore: cast_nullable_to_non_nullable : currentIndex // ignore: cast_nullable_to_non_nullable
as int, as int,
groupNames: null == groupNames groups: null == groups
? _value.groupNames ? _value.groups
: groupNames // ignore: cast_nullable_to_non_nullable : groups // ignore: cast_nullable_to_non_nullable
as List<String>, as List<Group>,
) as $Val); ) as $Val);
} }
} }
@@ -1798,7 +1798,7 @@ abstract class _$$ProxiesSelectorStateImplCopyWith<$Res>
__$$ProxiesSelectorStateImplCopyWithImpl<$Res>; __$$ProxiesSelectorStateImplCopyWithImpl<$Res>;
@override @override
@useResult @useResult
$Res call({int currentIndex, List<String> groupNames}); $Res call({int currentIndex, List<Group> groups});
} }
/// @nodoc /// @nodoc
@@ -1813,17 +1813,17 @@ class __$$ProxiesSelectorStateImplCopyWithImpl<$Res>
@override @override
$Res call({ $Res call({
Object? currentIndex = null, Object? currentIndex = null,
Object? groupNames = null, Object? groups = null,
}) { }) {
return _then(_$ProxiesSelectorStateImpl( return _then(_$ProxiesSelectorStateImpl(
currentIndex: null == currentIndex currentIndex: null == currentIndex
? _value.currentIndex ? _value.currentIndex
: currentIndex // ignore: cast_nullable_to_non_nullable : currentIndex // ignore: cast_nullable_to_non_nullable
as int, as int,
groupNames: null == groupNames groups: null == groups
? _value._groupNames ? _value._groups
: groupNames // ignore: cast_nullable_to_non_nullable : groups // ignore: cast_nullable_to_non_nullable
as List<String>, as List<Group>,
)); ));
} }
} }
@@ -1832,22 +1832,22 @@ class __$$ProxiesSelectorStateImplCopyWithImpl<$Res>
class _$ProxiesSelectorStateImpl implements _ProxiesSelectorState { class _$ProxiesSelectorStateImpl implements _ProxiesSelectorState {
const _$ProxiesSelectorStateImpl( const _$ProxiesSelectorStateImpl(
{required this.currentIndex, required final List<String> groupNames}) {required this.currentIndex, required final List<Group> groups})
: _groupNames = groupNames; : _groups = groups;
@override @override
final int currentIndex; final int currentIndex;
final List<String> _groupNames; final List<Group> _groups;
@override @override
List<String> get groupNames { List<Group> get groups {
if (_groupNames is EqualUnmodifiableListView) return _groupNames; if (_groups is EqualUnmodifiableListView) return _groups;
// ignore: implicit_dynamic_type // ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_groupNames); return EqualUnmodifiableListView(_groups);
} }
@override @override
String toString() { String toString() {
return 'ProxiesSelectorState(currentIndex: $currentIndex, groupNames: $groupNames)'; return 'ProxiesSelectorState(currentIndex: $currentIndex, groups: $groups)';
} }
@override @override
@@ -1857,13 +1857,12 @@ class _$ProxiesSelectorStateImpl implements _ProxiesSelectorState {
other is _$ProxiesSelectorStateImpl && other is _$ProxiesSelectorStateImpl &&
(identical(other.currentIndex, currentIndex) || (identical(other.currentIndex, currentIndex) ||
other.currentIndex == currentIndex) && other.currentIndex == currentIndex) &&
const DeepCollectionEquality() const DeepCollectionEquality().equals(other._groups, _groups));
.equals(other._groupNames, _groupNames));
} }
@override @override
int get hashCode => Object.hash(runtimeType, currentIndex, int get hashCode => Object.hash(
const DeepCollectionEquality().hash(_groupNames)); runtimeType, currentIndex, const DeepCollectionEquality().hash(_groups));
@JsonKey(ignore: true) @JsonKey(ignore: true)
@override @override
@@ -1877,358 +1876,14 @@ class _$ProxiesSelectorStateImpl implements _ProxiesSelectorState {
abstract class _ProxiesSelectorState implements ProxiesSelectorState { abstract class _ProxiesSelectorState implements ProxiesSelectorState {
const factory _ProxiesSelectorState( const factory _ProxiesSelectorState(
{required final int currentIndex, {required final int currentIndex,
required final List<String> groupNames}) = _$ProxiesSelectorStateImpl; required final List<Group> groups}) = _$ProxiesSelectorStateImpl;
@override @override
int get currentIndex; int get currentIndex;
@override @override
List<String> get groupNames; List<Group> get groups;
@override @override
@JsonKey(ignore: true) @JsonKey(ignore: true)
_$$ProxiesSelectorStateImplCopyWith<_$ProxiesSelectorStateImpl> _$$ProxiesSelectorStateImplCopyWith<_$ProxiesSelectorStateImpl>
get copyWith => throw _privateConstructorUsedError; get copyWith => throw _privateConstructorUsedError;
} }
/// @nodoc
mixin _$ProxiesCardSelectorState {
String? get currentGroupName => throw _privateConstructorUsedError;
String? get currentProxyName => throw _privateConstructorUsedError;
bool get isSelected => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$ProxiesCardSelectorStateCopyWith<ProxiesCardSelectorState> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $ProxiesCardSelectorStateCopyWith<$Res> {
factory $ProxiesCardSelectorStateCopyWith(ProxiesCardSelectorState value,
$Res Function(ProxiesCardSelectorState) then) =
_$ProxiesCardSelectorStateCopyWithImpl<$Res, ProxiesCardSelectorState>;
@useResult
$Res call(
{String? currentGroupName, String? currentProxyName, bool isSelected});
}
/// @nodoc
class _$ProxiesCardSelectorStateCopyWithImpl<$Res,
$Val extends ProxiesCardSelectorState>
implements $ProxiesCardSelectorStateCopyWith<$Res> {
_$ProxiesCardSelectorStateCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
@pragma('vm:prefer-inline')
@override
$Res call({
Object? currentGroupName = freezed,
Object? currentProxyName = freezed,
Object? isSelected = null,
}) {
return _then(_value.copyWith(
currentGroupName: freezed == currentGroupName
? _value.currentGroupName
: currentGroupName // ignore: cast_nullable_to_non_nullable
as String?,
currentProxyName: freezed == currentProxyName
? _value.currentProxyName
: currentProxyName // ignore: cast_nullable_to_non_nullable
as String?,
isSelected: null == isSelected
? _value.isSelected
: isSelected // ignore: cast_nullable_to_non_nullable
as bool,
) as $Val);
}
}
/// @nodoc
abstract class _$$ProxiesCardSelectorStateImplCopyWith<$Res>
implements $ProxiesCardSelectorStateCopyWith<$Res> {
factory _$$ProxiesCardSelectorStateImplCopyWith(
_$ProxiesCardSelectorStateImpl value,
$Res Function(_$ProxiesCardSelectorStateImpl) then) =
__$$ProxiesCardSelectorStateImplCopyWithImpl<$Res>;
@override
@useResult
$Res call(
{String? currentGroupName, String? currentProxyName, bool isSelected});
}
/// @nodoc
class __$$ProxiesCardSelectorStateImplCopyWithImpl<$Res>
extends _$ProxiesCardSelectorStateCopyWithImpl<$Res,
_$ProxiesCardSelectorStateImpl>
implements _$$ProxiesCardSelectorStateImplCopyWith<$Res> {
__$$ProxiesCardSelectorStateImplCopyWithImpl(
_$ProxiesCardSelectorStateImpl _value,
$Res Function(_$ProxiesCardSelectorStateImpl) _then)
: super(_value, _then);
@pragma('vm:prefer-inline')
@override
$Res call({
Object? currentGroupName = freezed,
Object? currentProxyName = freezed,
Object? isSelected = null,
}) {
return _then(_$ProxiesCardSelectorStateImpl(
currentGroupName: freezed == currentGroupName
? _value.currentGroupName
: currentGroupName // ignore: cast_nullable_to_non_nullable
as String?,
currentProxyName: freezed == currentProxyName
? _value.currentProxyName
: currentProxyName // ignore: cast_nullable_to_non_nullable
as String?,
isSelected: null == isSelected
? _value.isSelected
: isSelected // ignore: cast_nullable_to_non_nullable
as bool,
));
}
}
/// @nodoc
class _$ProxiesCardSelectorStateImpl implements _ProxiesCardSelectorState {
const _$ProxiesCardSelectorStateImpl(
{required this.currentGroupName,
required this.currentProxyName,
required this.isSelected});
@override
final String? currentGroupName;
@override
final String? currentProxyName;
@override
final bool isSelected;
@override
String toString() {
return 'ProxiesCardSelectorState(currentGroupName: $currentGroupName, currentProxyName: $currentProxyName, isSelected: $isSelected)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$ProxiesCardSelectorStateImpl &&
(identical(other.currentGroupName, currentGroupName) ||
other.currentGroupName == currentGroupName) &&
(identical(other.currentProxyName, currentProxyName) ||
other.currentProxyName == currentProxyName) &&
(identical(other.isSelected, isSelected) ||
other.isSelected == isSelected));
}
@override
int get hashCode =>
Object.hash(runtimeType, currentGroupName, currentProxyName, isSelected);
@JsonKey(ignore: true)
@override
@pragma('vm:prefer-inline')
_$$ProxiesCardSelectorStateImplCopyWith<_$ProxiesCardSelectorStateImpl>
get copyWith => __$$ProxiesCardSelectorStateImplCopyWithImpl<
_$ProxiesCardSelectorStateImpl>(this, _$identity);
}
abstract class _ProxiesCardSelectorState implements ProxiesCardSelectorState {
const factory _ProxiesCardSelectorState(
{required final String? currentGroupName,
required final String? currentProxyName,
required final bool isSelected}) = _$ProxiesCardSelectorStateImpl;
@override
String? get currentGroupName;
@override
String? get currentProxyName;
@override
bool get isSelected;
@override
@JsonKey(ignore: true)
_$$ProxiesCardSelectorStateImplCopyWith<_$ProxiesCardSelectorStateImpl>
get copyWith => throw _privateConstructorUsedError;
}
/// @nodoc
mixin _$ProxiesTabViewSelectorState {
ProxiesSortType get proxiesSortType => throw _privateConstructorUsedError;
num get sortNum => throw _privateConstructorUsedError;
Group get group => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$ProxiesTabViewSelectorStateCopyWith<ProxiesTabViewSelectorState>
get copyWith => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $ProxiesTabViewSelectorStateCopyWith<$Res> {
factory $ProxiesTabViewSelectorStateCopyWith(
ProxiesTabViewSelectorState value,
$Res Function(ProxiesTabViewSelectorState) then) =
_$ProxiesTabViewSelectorStateCopyWithImpl<$Res,
ProxiesTabViewSelectorState>;
@useResult
$Res call({ProxiesSortType proxiesSortType, num sortNum, Group group});
$GroupCopyWith<$Res> get group;
}
/// @nodoc
class _$ProxiesTabViewSelectorStateCopyWithImpl<$Res,
$Val extends ProxiesTabViewSelectorState>
implements $ProxiesTabViewSelectorStateCopyWith<$Res> {
_$ProxiesTabViewSelectorStateCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
@pragma('vm:prefer-inline')
@override
$Res call({
Object? proxiesSortType = null,
Object? sortNum = null,
Object? group = null,
}) {
return _then(_value.copyWith(
proxiesSortType: null == proxiesSortType
? _value.proxiesSortType
: proxiesSortType // ignore: cast_nullable_to_non_nullable
as ProxiesSortType,
sortNum: null == sortNum
? _value.sortNum
: sortNum // ignore: cast_nullable_to_non_nullable
as num,
group: null == group
? _value.group
: group // ignore: cast_nullable_to_non_nullable
as Group,
) as $Val);
}
@override
@pragma('vm:prefer-inline')
$GroupCopyWith<$Res> get group {
return $GroupCopyWith<$Res>(_value.group, (value) {
return _then(_value.copyWith(group: value) as $Val);
});
}
}
/// @nodoc
abstract class _$$ProxiesTabViewSelectorStateImplCopyWith<$Res>
implements $ProxiesTabViewSelectorStateCopyWith<$Res> {
factory _$$ProxiesTabViewSelectorStateImplCopyWith(
_$ProxiesTabViewSelectorStateImpl value,
$Res Function(_$ProxiesTabViewSelectorStateImpl) then) =
__$$ProxiesTabViewSelectorStateImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({ProxiesSortType proxiesSortType, num sortNum, Group group});
@override
$GroupCopyWith<$Res> get group;
}
/// @nodoc
class __$$ProxiesTabViewSelectorStateImplCopyWithImpl<$Res>
extends _$ProxiesTabViewSelectorStateCopyWithImpl<$Res,
_$ProxiesTabViewSelectorStateImpl>
implements _$$ProxiesTabViewSelectorStateImplCopyWith<$Res> {
__$$ProxiesTabViewSelectorStateImplCopyWithImpl(
_$ProxiesTabViewSelectorStateImpl _value,
$Res Function(_$ProxiesTabViewSelectorStateImpl) _then)
: super(_value, _then);
@pragma('vm:prefer-inline')
@override
$Res call({
Object? proxiesSortType = null,
Object? sortNum = null,
Object? group = null,
}) {
return _then(_$ProxiesTabViewSelectorStateImpl(
proxiesSortType: null == proxiesSortType
? _value.proxiesSortType
: proxiesSortType // ignore: cast_nullable_to_non_nullable
as ProxiesSortType,
sortNum: null == sortNum
? _value.sortNum
: sortNum // ignore: cast_nullable_to_non_nullable
as num,
group: null == group
? _value.group
: group // ignore: cast_nullable_to_non_nullable
as Group,
));
}
}
/// @nodoc
class _$ProxiesTabViewSelectorStateImpl
implements _ProxiesTabViewSelectorState {
const _$ProxiesTabViewSelectorStateImpl(
{required this.proxiesSortType,
required this.sortNum,
required this.group});
@override
final ProxiesSortType proxiesSortType;
@override
final num sortNum;
@override
final Group group;
@override
String toString() {
return 'ProxiesTabViewSelectorState(proxiesSortType: $proxiesSortType, sortNum: $sortNum, group: $group)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$ProxiesTabViewSelectorStateImpl &&
(identical(other.proxiesSortType, proxiesSortType) ||
other.proxiesSortType == proxiesSortType) &&
(identical(other.sortNum, sortNum) || other.sortNum == sortNum) &&
(identical(other.group, group) || other.group == group));
}
@override
int get hashCode => Object.hash(runtimeType, proxiesSortType, sortNum, group);
@JsonKey(ignore: true)
@override
@pragma('vm:prefer-inline')
_$$ProxiesTabViewSelectorStateImplCopyWith<_$ProxiesTabViewSelectorStateImpl>
get copyWith => __$$ProxiesTabViewSelectorStateImplCopyWithImpl<
_$ProxiesTabViewSelectorStateImpl>(this, _$identity);
}
abstract class _ProxiesTabViewSelectorState
implements ProxiesTabViewSelectorState {
const factory _ProxiesTabViewSelectorState(
{required final ProxiesSortType proxiesSortType,
required final num sortNum,
required final Group group}) = _$ProxiesTabViewSelectorStateImpl;
@override
ProxiesSortType get proxiesSortType;
@override
num get sortNum;
@override
Group get group;
@override
@JsonKey(ignore: true)
_$$ProxiesTabViewSelectorStateImplCopyWith<_$ProxiesTabViewSelectorStateImpl>
get copyWith => throw _privateConstructorUsedError;
}

View File

@@ -107,24 +107,7 @@ class HomeNavigationSelectorState with _$HomeNavigationSelectorState{
class ProxiesSelectorState with _$ProxiesSelectorState{ class ProxiesSelectorState with _$ProxiesSelectorState{
const factory ProxiesSelectorState({ const factory ProxiesSelectorState({
required int currentIndex, required int currentIndex,
required List<String> groupNames, required List<Group> groups,
}) = _ProxiesSelectorState; }) = _ProxiesSelectorState;
} }
@freezed
class ProxiesCardSelectorState with _$ProxiesCardSelectorState{
const factory ProxiesCardSelectorState({
required String? currentGroupName,
required String? currentProxyName,
required bool isSelected,
}) = _ProxiesCardSelectorState;
}
@freezed
class ProxiesTabViewSelectorState with _$ProxiesTabViewSelectorState{
const factory ProxiesTabViewSelectorState({
required ProxiesSortType proxiesSortType,
required num sortNum,
required Group group,
}) = _ProxiesTabViewSelectorState;
}

View File

@@ -140,6 +140,7 @@ class HomePage extends StatelessWidget {
child: Selector<AppState, List<NavigationItem>>( child: Selector<AppState, List<NavigationItem>>(
selector: (_, appState) => appState.navigationItems, selector: (_, appState) => appState.navigationItems,
builder: (_, navigationItems, __) { builder: (_, navigationItems, __) {
debugPrint("[Home] update===>");
final desktopNavigationItems = navigationItems final desktopNavigationItems = navigationItems
.where( .where(
(element) => (element) =>

View File

@@ -5,6 +5,7 @@ import 'dart:io';
import 'package:animations/animations.dart'; import 'package:animations/animations.dart';
import 'package:fl_clash/clash/clash.dart'; import 'package:fl_clash/clash/clash.dart';
import 'package:fl_clash/enum/enum.dart'; import 'package:fl_clash/enum/enum.dart';
import 'package:fl_clash/models/clash_config.dart';
import 'package:fl_clash/plugins/app.dart'; import 'package:fl_clash/plugins/app.dart';
import 'package:fl_clash/widgets/scaffold.dart'; import 'package:fl_clash/widgets/scaffold.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@@ -14,8 +15,8 @@ import 'common/common.dart';
class GlobalState { class GlobalState {
Timer? timer; Timer? timer;
Timer? currentDelayTimer;
Function? updateCurrentDelayDebounce; Function? updateCurrentDelayDebounce;
Function? updateSortNumDebounce;
PageController? pageController; PageController? pageController;
final navigatorKey = GlobalKey<NavigatorState>(); final navigatorKey = GlobalKey<NavigatorState>();
final Map<int, String?> packageNameMap = {}; final Map<int, String?> packageNameMap = {};
@@ -23,7 +24,6 @@ class GlobalState {
List<Function> updateFunctionLists = []; List<Function> updateFunctionLists = [];
List<NavigationItem> currentNavigationItems = []; List<NavigationItem> currentNavigationItems = [];
bool updatePackagesLock = false; bool updatePackagesLock = false;
bool healthcheckLock = false;
startListenUpdate() { startListenUpdate() {
if (timer != null && timer!.isActive == true) return; if (timer != null && timer!.isActive == true) return;
@@ -39,7 +39,7 @@ class GlobalState {
timer?.cancel(); timer?.cancel();
} }
Future<String> updateClashConfig({ Future<bool> updateClashConfig({
required ClashConfig clashConfig, required ClashConfig clashConfig,
required Config config, required Config config,
bool isPatch = true, bool isPatch = true,
@@ -88,25 +88,6 @@ class GlobalState {
updateCurrentDelayDebounce!([proxyName]); updateCurrentDelayDebounce!([proxyName]);
} }
applyProfile({
required AppState appState,
required Config config,
required ClashConfig clashConfig,
}) async {
final res = await updateClashConfig(
clashConfig: clashConfig,
config: config,
isPatch: false,
);
if (res.isNotEmpty) return Result.error(message: res);
await updateGroups(appState);
changeProxy(
appState: appState,
config: config,
clashConfig: clashConfig,
);
}
init({ init({
required AppState appState, required AppState appState,
required Config config, required Config config,
@@ -120,12 +101,18 @@ class GlobalState {
); );
} }
if (!appState.isInit) return; if (!appState.isInit) return;
await applyProfile( await updateClashConfig(
clashConfig: clashConfig,
config: config,
isPatch: false,
);
updateGroups(appState);
updateCoreVersionInfo(appState);
changeProxy(
appState: appState, appState: appState,
config: config, config: config,
clashConfig: clashConfig, clashConfig: clashConfig,
); );
updateCoreVersionInfo(appState);
} }
changeProxy({ changeProxy({
@@ -180,7 +167,7 @@ class GlobalState {
} }
Future<void> updateGroups(AppState appState) async { Future<void> updateGroups(AppState appState) async {
appState.groups = await clashCore.getProxiesGroups(); appState.groups = await clashCore.getProxiesGroups();
} }
showMessage({ showMessage({

View File

@@ -15,6 +15,7 @@ class AppStateContainer extends StatelessWidget {
return Selector<Config, bool>( return Selector<Config, bool>(
selector: (_, config) => config.autoLaunch, selector: (_, config) => config.autoLaunch,
builder: (_, isAutoLaunch, child) { builder: (_, isAutoLaunch, child) {
debugPrint("[autoLaunchContainer] update===>");
autoLaunch?.updateStatus(isAutoLaunch); autoLaunch?.updateStatus(isAutoLaunch);
return child!; return child!;
}, },
@@ -34,6 +35,7 @@ class AppStateContainer extends StatelessWidget {
); );
}, },
builder: (context, state, child) { builder: (context, state, child) {
debugPrint("[NavigationsContainer] update===>");
WidgetsBinding.instance.addPostFrameCallback( WidgetsBinding.instance.addPostFrameCallback(
(_) { (_) {
context.appController.appState.navigationItems = context.appController.appState.navigationItems =

View File

@@ -38,24 +38,13 @@ class _ClashMessageContainerState extends State<ClashMessageContainer>
@override @override
void onDelay(Delay delay) { void onDelay(Delay delay) {
globalState.healthcheckLock = true;
context.appController.setDelay(delay); context.appController.setDelay(delay);
WidgetsBinding.instance.addPostFrameCallback((_) {
globalState.updateSortNumDebounce ??= debounce<Function()>(
() {
context.appController.updateGroups();
context.appController.appState.sortNum++;
globalState.healthcheckLock = false;
},
milliseconds: 5000,
);
globalState.updateSortNumDebounce!();
});
super.onDelay(delay); super.onDelay(delay);
} }
@override @override
void onLog(Log log) { void onLog(Log log) {
debugPrint("$log");
context.appController.appState.addLog(log); context.appController.appState.addLog(log);
super.onLog(log); super.onLog(log);
} }

View File

@@ -446,6 +446,7 @@ class _OpenContainerRoute<T> extends ModalRoute<T> {
return Selector<Config, ThemeMode>( return Selector<Config, ThemeMode>(
selector: (_, config) => config.themeMode, selector: (_, config) => config.themeMode,
builder: (_, __, ___) { builder: (_, __, ___) {
debugPrint("[OpenContainerTheme] update===>");
_colorTween = _getColorTween( _colorTween = _getColorTween(
transitionType: transitionType, transitionType: transitionType,
closedColor: Theme.of(context).colorScheme.background, closedColor: Theme.of(context).colorScheme.background,

View File

@@ -144,6 +144,7 @@ class _TrayContainerState extends State<TrayContainer> with TrayListener {
locale: config.locale, locale: config.locale,
), ),
builder: (_, state, child) { builder: (_, state, child) {
debugPrint("[TrayContainer] update===>");
WidgetsBinding.instance.addPostFrameCallback((timeStamp) { WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
updateMenu(state); updateMenu(state);
}); });

View File

@@ -279,10 +279,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: flutter_plugin_android_lifecycle name: flutter_plugin_android_lifecycle
sha256: "8cf40eebf5dec866a6d1956ad7b4f7016e6c0cc69847ab946833b7d43743809f" sha256: "592dc01a18961a51c24ae5d963b724b2b7fa4a95c100fe8eb6ca8a5a4732cadf"
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.0.19" version: "2.0.18"
flutter_test: flutter_test:
dependency: "direct dev" dependency: "direct dev"
description: flutter description: flutter
@@ -957,10 +957,10 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: win32_registry name: win32_registry
sha256: "41fd8a189940d8696b1b810efb9abcf60827b6cbfab90b0c43e8439e3a39d85a" sha256: "10589e0d7f4e053f2c61023a31c9ce01146656a70b7b7f0828c0b46d7da2a9bb"
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.1.2" version: "1.1.3"
window_manager: window_manager:
dependency: "direct main" dependency: "direct main"
description: description:
@@ -997,10 +997,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: yaml_edit name: yaml_edit
sha256: e9c1a3543d2da0db3e90270dbb1e4eebc985ee5e3ffe468d83224472b2194a5f sha256: c566f4f804215d84a7a2c377667f546c6033d5b34b4f9e60dfb09d17c4e97826
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.2.1" version: "2.2.0"
sdks: sdks:
dart: ">=3.3.0 <4.0.0" dart: ">=3.3.0 <4.0.0"
flutter: ">=3.19.0" flutter: ">=3.19.0"

View File

@@ -1,7 +1,7 @@
name: fl_clash name: fl_clash
description: A multi-platform proxy client based on ClashMeta, simple and easy to use, open-source and ad-free. description: A multi-platform proxy client based on ClashMeta, simple and easy to use, open-source and ad-free.
publish_to: 'none' publish_to: 'none'
version: 0.7.11 version: 0.7.2
environment: environment:
sdk: '>=3.1.0 <4.0.0' sdk: '>=3.1.0 <4.0.0'