Compare commits

..

21 Commits

Author SHA1 Message Date
chen08209
74c3d0ae25 New Async UpdateConfig 2024-05-05 03:13:52 +08:00
chen08209
ecd1bcafd5 add changeProfileDebounce 2024-05-05 03:13:51 +08:00
chen08209
184d2d117a Update Workflow 2024-05-05 03:13:50 +08:00
chen08209
89e6f17794 Fix ChangeProfile block 2024-05-05 03:13:49 +08:00
chen08209
aef50fe0e3 Fix Release Message Error 2024-05-04 16:14:03 +08:00
chen08209
fc0767ed25 Update Selector 2 2024-05-04 01:14:56 +08:00
chen08209
dbf1724cca Update Version 2024-05-04 00:14:34 +08:00
chen08209
909aa4038e Fix Proxies Select Error 2024-05-04 00:14:07 +08:00
chen08209
2d0a7d8d46 Fix the problem that the proxy group is empty in global mode. 2024-05-03 23:08:06 +08:00
chen08209
ca96cd1d82 Fix the problem that the proxy group is empty in global mode. 2024-05-03 23:07:38 +08:00
chen08209
91ab1e5dac Add ProxyProvider2 2024-05-03 21:48:22 +08:00
chen08209
b3a5f74df8 Add ProxyProvider 2024-05-03 21:28:22 +08:00
chen08209
1f98be8ad8 Update Version 2024-05-03 15:33:46 +08:00
chen08209
453c7c98d0 Update ProxyGroup Sort 2024-05-03 15:33:45 +08:00
chen08209
91faed35c0 Fix Android quickStart VpnService some problems 2024-05-02 00:32:11 +08:00
chen08209
07bbaf6b6f Update version 2024-05-01 23:40:04 +08:00
chen08209
e8feb7c431 Set Android notification low importance 2024-05-01 23:40:03 +08:00
chen08209
4d16820526 Fix the issue that VpnService can't be closed correctly in special cases 2024-05-01 23:40:00 +08:00
chen08209
92294b49c6 Fix the problem that TileService is not destroyed correctly in some cases
Adjust tab animation defaults
2024-05-01 23:39:59 +08:00
chen08209
8a188a37c9 Add Telegram in README_zh_CN.md 2024-05-01 21:52:07 +08:00
chen08209
48af16c265 Add Telegram 2024-05-01 21:50:26 +08:00
75 changed files with 1003 additions and 2445 deletions

View File

@@ -3,67 +3,25 @@ package main
import "C" import "C"
import ( import (
"github.com/metacubex/mihomo/adapter/inbound" "github.com/metacubex/mihomo/adapter/inbound"
ap "github.com/metacubex/mihomo/adapter/provider"
"github.com/metacubex/mihomo/component/dialer" "github.com/metacubex/mihomo/component/dialer"
"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"
"path/filepath"
"runtime" "runtime"
"strings"
"sync"
"syscall" "syscall"
) )
type healthCheckSchema struct {
Enable bool `provider:"enable"`
URL string `provider:"url"`
Interval int `provider:"interval"`
TestTimeout int `provider:"timeout,omitempty"`
Lazy bool `provider:"lazy,omitempty"`
ExpectedStatus string `provider:"expected-status,omitempty"`
}
type proxyProviderSchema struct {
Type string `provider:"type"`
Path string `provider:"path,omitempty"`
URL string `provider:"url,omitempty"`
Proxy string `provider:"proxy,omitempty"`
Interval int `provider:"interval,omitempty"`
Filter string `provider:"filter,omitempty"`
ExcludeFilter string `provider:"exclude-filter,omitempty"`
ExcludeType string `provider:"exclude-type,omitempty"`
DialerProxy string `provider:"dialer-proxy,omitempty"`
HealthCheck healthCheckSchema `provider:"health-check,omitempty"`
Override ap.OverrideSchema `provider:"override,omitempty"`
Header map[string][]string `provider:"header,omitempty"`
}
type ruleProviderSchema struct {
Type string `provider:"type"`
Behavior string `provider:"behavior"`
Path string `provider:"path,omitempty"`
URL string `provider:"url,omitempty"`
Proxy string `provider:"proxy,omitempty"`
Format string `provider:"format,omitempty"`
Interval int `provider:"interval,omitempty"`
}
type GenerateConfigParams struct { type GenerateConfigParams struct {
ProfilePath *string `json:"profile-path"` ProfilePath *string `json:"profile-path"`
Config *config.RawConfig `json:"config" ` Config *config.RawConfig `json:"config" `
IsPatch *bool `json:"is-patch"` IsPatch *bool `json:"is-patch"`
IsCompatible *bool `json:"is-compatible"`
} }
type ChangeProxyParams struct { type ChangeProxyParams struct {
@@ -88,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,19 +82,6 @@ func readFile(path string) ([]byte, error) {
return data, err return data, err
} }
func removeFile(path string) error {
absPath, err := filepath.Abs(path)
if err != nil {
return err
}
err = os.Remove(absPath)
if err != nil {
return err
}
return nil
}
func getRawConfigWithPath(path *string) *config.RawConfig { func getRawConfigWithPath(path *string) *config.RawConfig {
if path == nil { if path == nil {
return config.DefaultRawConfig() return config.DefaultRawConfig()
@@ -160,164 +100,18 @@ func getRawConfigWithPath(path *string) *config.RawConfig {
} }
} }
func decorationConfig(profilePath *string, cfg config.RawConfig, compatible bool) *config.RawConfig { func decorationConfig(profilePath *string, cfg config.RawConfig) *config.RawConfig {
prof := getRawConfigWithPath(profilePath) prof := getRawConfigWithPath(profilePath)
overwriteConfig(prof, cfg, compatible) overwriteConfig(prof, cfg)
return prof return prof
} }
func Reduce[T any, U any](s []T, initVal U, f func(U, T) U) U { func overwriteConfig(targetConfig *config.RawConfig, patchConfig config.RawConfig) {
for _, v := range s {
initVal = f(initVal, v)
}
return initVal
}
func Map[T, U any](slice []T, fn func(T) U) []U {
result := make([]U, len(slice))
for i, v := range slice {
result[i] = fn(v)
}
return result
}
func replaceFromMap(s string, m map[string]string) string {
for k, v := range m {
s = strings.ReplaceAll(s, k, v)
}
return s
}
func removeDuplicateFromSlice[T any](slice []T) []T {
result := make([]T, 0)
seen := make(map[any]struct{})
for _, value := range slice {
if _, ok := seen[value]; !ok {
result = append(result, value)
seen[value] = struct{}{}
}
}
return result
}
func generateProxyGroupAndRule(proxyGroup *[]map[string]any, rule *[]string) {
var replacements = map[string]string{}
var selectArr []map[string]any
var urlTestArr []map[string]any
var fallbackArr []map[string]any
for _, group := range *proxyGroup {
switch group["type"] {
case "select":
selectArr = append(selectArr, group)
replacements[group["name"].(string)] = "Proxy"
break
case "url-test":
urlTestArr = append(urlTestArr, group)
replacements[group["name"].(string)] = "Auto"
break
case "fallback":
fallbackArr = append(fallbackArr, group)
replacements[group["name"].(string)] = "Fallback"
break
default:
break
}
}
ProxyProxies := Reduce(selectArr, []string{}, func(res []string, cur map[string]any) []string {
if cur["proxies"] == nil {
return res
}
for _, proxyName := range cur["proxies"].([]interface{}) {
if str, ok := proxyName.(string); ok {
str = replaceFromMap(str, replacements)
if str != "Proxy" {
res = append(res, str)
}
}
}
return res
})
ProxyProxies = removeDuplicateFromSlice(ProxyProxies)
AutoProxies := Reduce(urlTestArr, []string{}, func(res []string, cur map[string]any) []string {
if cur["proxies"] == nil {
return res
}
for _, proxyName := range cur["proxies"].([]interface{}) {
if str, ok := proxyName.(string); ok {
str = replaceFromMap(str, replacements)
if str != "Auto" {
res = append(res, str)
}
}
}
return res
})
AutoProxies = removeDuplicateFromSlice(AutoProxies)
FallbackProxies := Reduce(fallbackArr, []string{}, func(res []string, cur map[string]any) []string {
if cur["proxies"] == nil {
return res
}
for _, proxyName := range cur["proxies"].([]interface{}) {
if str, ok := proxyName.(string); ok {
str = replaceFromMap(str, replacements)
if str != "Fallback" {
res = append(res, str)
}
}
}
return res
})
FallbackProxies = removeDuplicateFromSlice(FallbackProxies)
var computedProxyGroup []map[string]any
if len(ProxyProxies) > 0 {
computedProxyGroup = append(computedProxyGroup,
map[string]any{
"name": "Proxy",
"type": "select",
"proxies": ProxyProxies,
})
}
if len(AutoProxies) > 0 {
computedProxyGroup = append(computedProxyGroup,
map[string]any{
"name": "Auto",
"type": "url-test",
"proxies": AutoProxies,
})
}
if len(FallbackProxies) > 0 {
computedProxyGroup = append(computedProxyGroup,
map[string]any{
"name": "Fallback",
"type": "fallback",
"proxies": FallbackProxies,
})
}
computedRule := Map(*rule, func(value string) string {
return replaceFromMap(value, replacements)
})
*proxyGroup = computedProxyGroup
*rule = computedRule
}
func overwriteConfig(targetConfig *config.RawConfig, patchConfig config.RawConfig, compatible bool) {
targetConfig.ExternalController = "" targetConfig.ExternalController = ""
targetConfig.ExternalUI = "" targetConfig.ExternalUI = ""
targetConfig.Interface = "" targetConfig.Interface = ""
targetConfig.ExternalUIURL = "" targetConfig.ExternalUIURL = ""
//targetConfig.IPv6 = patchConfig.IPv6 targetConfig.IPv6 = patchConfig.IPv6
targetConfig.LogLevel = patchConfig.LogLevel targetConfig.LogLevel = patchConfig.LogLevel
targetConfig.FindProcessMode = process.FindProcessAlways targetConfig.FindProcessMode = process.FindProcessAlways
targetConfig.AllowLan = patchConfig.AllowLan targetConfig.AllowLan = patchConfig.AllowLan
@@ -327,22 +121,22 @@ 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.GeodataLoader = "standard"
targetConfig.Profile.StoreSelected = false
if targetConfig.DNS.Enable == false { if targetConfig.DNS.Enable == false {
targetConfig.DNS = patchConfig.DNS targetConfig.DNS = patchConfig.DNS
} else {
targetConfig.DNS.UseHosts = patchConfig.DNS.UseHosts
targetConfig.DNS.EnhancedMode = patchConfig.DNS.EnhancedMode
targetConfig.DNS.IPv6 = patchConfig.DNS.IPv6
targetConfig.DNS.DefaultNameserver = append(patchConfig.DNS.DefaultNameserver, targetConfig.DNS.DefaultNameserver...)
targetConfig.DNS.NameServer = append(patchConfig.DNS.NameServer, targetConfig.DNS.NameServer...)
targetConfig.DNS.FakeIPFilter = append(patchConfig.DNS.FakeIPFilter, targetConfig.DNS.FakeIPFilter...)
targetConfig.DNS.Fallback = append(patchConfig.DNS.Fallback, targetConfig.DNS.Fallback...)
if runtime.GOOS == "android" {
targetConfig.DNS.NameServer = append(targetConfig.DNS.NameServer, "dhcp://"+dns.SystemDNSPlaceholder)
} else if runtime.GOOS == "windows" {
targetConfig.DNS.NameServer = append(targetConfig.DNS.NameServer, dns.SystemDNSPlaceholder)
}
} }
if runtime.GOOS == "android" {
targetConfig.DNS.NameServer = append(targetConfig.DNS.NameServer, "dhcp://"+dns.SystemDNSPlaceholder)
} else if runtime.GOOS == "windows" {
targetConfig.DNS.NameServer = append(targetConfig.DNS.NameServer, dns.SystemDNSPlaceholder)
}
if compatible == false {
targetConfig.ProxyProvider = make(map[string]map[string]any)
targetConfig.RuleProvider = make(map[string]map[string]any)
generateProxyGroupAndRule(&targetConfig.ProxyGroup, &targetConfig.Rule)
}
} }
func patchConfig(general *config.General) { func patchConfig(general *config.General) {
@@ -370,28 +164,6 @@ func patchConfig(general *config.General) {
resolver.DisableIPv6 = !general.IPv6 resolver.DisableIPv6 = !general.IPv6
} }
const concurrentCount = math.MaxInt
func hcCompatibleProvider(proxyProviders map[string]provider.ProxyProvider) {
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) { func applyConfig(isPatch bool) {
cfg, err := config.ParseRawConfig(currentConfig) cfg, err := config.ParseRawConfig(currentConfig)
if err != nil { if err != nil {
@@ -401,6 +173,5 @@ func applyConfig(isPatch bool) {
patchConfig(cfg.General) patchConfig(cfg.General)
} else { } else {
executor.ApplyConfig(cfg, true) executor.ApplyConfig(cfg, true)
healthcheck()
} }
} }

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"
) )
@@ -19,11 +18,11 @@ type Message struct {
Data interface{} `json:"data"` Data interface{} `json:"data"`
} }
func (message *Message) Json() string { func (message *Message) toJson() string {
data, _ := json.Marshal(message) data, _ := json.Marshal(message)
return string(data) return string(data)
} }
func SendMessage(message Message) { func SendMessage(message Message) {
SendToPort(*Port, message.Json()) SendToPort(*Port, message.toJson())
} }

View File

@@ -7,8 +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/structure"
"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"
@@ -75,7 +73,7 @@ func updateConfig(s *C.char, port C.longlong) {
bridge.SendToPort(i, err.Error()) bridge.SendToPort(i, err.Error())
return return
} }
prof := decorationConfig(params.ProfilePath, *params.Config, *params.IsCompatible) prof := decorationConfig(params.ProfilePath, *params.Config)
currentConfig = prof currentConfig = prof
if *params.IsPatch { if *params.IsPatch {
applyConfig(true) applyConfig(true)
@@ -86,39 +84,6 @@ func updateConfig(s *C.char, port C.longlong) {
}() }()
} }
//export clearEffect
func clearEffect(s *C.char) {
path := C.GoString(s)
go func() {
rawCfg := getRawConfigWithPath(&path)
for _, mapping := range rawCfg.RuleProvider {
schema := &ruleProviderSchema{}
decoder := structure.NewDecoder(structure.Option{TagName: "provider", WeaklyTypedInput: true})
if err := decoder.Decode(mapping, schema); err != nil {
return
}
if schema.Type == "http" {
_ = removeFile(constant.Path.Resolve(schema.Path))
}
}
for _, mapping := range rawCfg.ProxyProvider {
schema := &proxyProviderSchema{
HealthCheck: healthCheckSchema{
Lazy: true,
},
}
decoder := structure.NewDecoder(structure.Option{TagName: "provider", WeaklyTypedInput: true})
if err := decoder.Decode(mapping, schema); err != nil {
return
}
if schema.Type == "http" {
_ = removeFile(constant.Path.Resolve(schema.Path))
}
}
_ = removeFile(path)
}()
}
//export getProxies //export getProxies
func getProxies() *C.char { func getProxies() *C.char {
data, err := json.Marshal(tunnel.ProxiesWithProviders()) data, err := json.Marshal(tunnel.ProxiesWithProviders())
@@ -130,28 +95,27 @@ func getProxies() *C.char {
//export changeProxy //export changeProxy
func changeProxy(s *C.char) bool { func changeProxy(s *C.char) bool {
go func() { paramsString := C.GoString(s)
paramsString := C.GoString(s) var params = &ChangeProxyParams{}
var params = &ChangeProxyParams{} err := json.Unmarshal([]byte(paramsString), params)
err := json.Unmarshal([]byte(paramsString), params) if err != nil {
if err != nil { log.Infoln("Unmarshal ChangeProxyParams %v", err)
log.Infoln("Unmarshal ChangeProxyParams %v", err) return false
} }
proxies := tunnel.ProxiesWithProviders() proxies := tunnel.ProxiesWithProviders()
proxy := proxies[*params.GroupName] proxy := proxies[*params.GroupName]
if proxy == nil { if proxy == nil {
return return false
} }
log.Infoln("change proxy %s", proxy.Name()) log.Infoln("change proxy %s", proxy.Name())
adapterProxy := proxy.(*adapter.Proxy) adapterProxy := proxy.(*adapter.Proxy)
selector, ok := adapterProxy.ProxyAdapter.(*outboundgroup.Selector) selector, ok := adapterProxy.ProxyAdapter.(*outboundgroup.Selector)
if !ok { if !ok {
return return false
} }
if err := selector.Set(*params.ProxyName); err != nil { if err := selector.Set(*params.ProxyName); err != nil {
return return false
} }
}()
return true return true
} }
@@ -279,38 +243,17 @@ func getProviders() *C.char {
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';
@@ -27,14 +25,8 @@ runAppWithPreferences(
ChangeNotifierProvider<Config>( ChangeNotifierProvider<Config>(
create: (_) => config, create: (_) => config,
), ),
ChangeNotifierProxyProvider2<Config, ClashConfig, AppState>( ChangeNotifierProvider<AppState>(
create: (_) => appState, create: (_) => appState,
update: (_, config, clashConfig, appState) {
appState?.mode = clashConfig.mode;
appState?.isCompatible = config.isCompatible;
appState?.selectedMap = config.currentSelectedMap;
return appState!;
},
) )
], ],
child: child, child: child,
@@ -51,6 +43,7 @@ class Application extends StatefulWidget {
} }
class ApplicationState extends State<Application> { class ApplicationState extends State<Application> {
late AppController appController;
late SystemColorSchemes systemColorSchemes; late SystemColorSchemes systemColorSchemes;
ColorScheme _getAppColorScheme({ ColorScheme _getAppColorScheme({
@@ -71,11 +64,10 @@ class ApplicationState extends State<Application> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
globalState.appController = AppController(context); appController = AppController(context);
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async { WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
globalState.appController.afterInit(); appController.afterInit();
globalState.appController.initLink(); appController.initLink();
_updateGroups();
}); });
} }
@@ -104,24 +96,10 @@ class ApplicationState extends State<Application> {
); );
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
globalState.appController.updateSystemColorSchemes(systemColorSchemes); appController.updateSystemColorSchemes(systemColorSchemes);
}); });
} }
_updateGroups() {
if (globalState.groupsUpdateTimer != null) {
globalState.groupsUpdateTimer?.cancel();
globalState.groupsUpdateTimer = null;
}
globalState.groupsUpdateTimer ??= Timer.periodic(
appConstant.httpTimeoutDuration,
(timer) async {
await globalState.appController.updateGroups();
globalState.appController.appState.sortNum++;
},
);
}
@override @override
Widget build(context) { Widget build(context) {
return AppStateContainer( return AppStateContainer(
@@ -146,9 +124,9 @@ class ApplicationState extends State<Application> {
GlobalWidgetsLocalizations.delegate GlobalWidgetsLocalizations.delegate
], ],
title: appConstant.name, title: appConstant.name,
locale: other.getLocaleForString(state.locale), locale: Other.getLocaleForString(state.locale),
supportedLocales: supportedLocales:
AppLocalizations.delegate.supportedLocales, AppLocalizations.delegate.supportedLocales,
themeMode: state.themeMode, themeMode: state.themeMode,
theme: ThemeData( theme: ThemeData(
useMaterial3: true, useMaterial3: true,
@@ -181,7 +159,7 @@ class ApplicationState extends State<Application> {
@override @override
Future<void> dispose() async { Future<void> dispose() async {
linkManager.destroy(); linkManager.destroy();
await globalState.appController.savePreferences(); await appController.savePreferences();
super.dispose(); super.dispose();
} }
} }

View File

@@ -5,6 +5,7 @@ import 'dart:io';
import 'dart:isolate'; import 'dart:isolate';
import 'package:ffi/ffi.dart'; import 'package:ffi/ffi.dart';
import 'package:flutter/cupertino.dart';
import '../enum/enum.dart'; import '../enum/enum.dart';
import '../models/models.dart'; import '../models/models.dart';
import '../common/common.dart'; import '../common/common.dart';
@@ -69,7 +70,7 @@ class ClashCore {
final completer = Completer<String>(); final completer = Completer<String>();
final receiver = ReceivePort(); final receiver = ReceivePort();
receiver.listen((message) { receiver.listen((message) {
if (!completer.isCompleted) { if(!completer.isCompleted){
completer.complete(message); completer.complete(message);
receiver.close(); receiver.close();
} }
@@ -97,6 +98,9 @@ class ClashCore {
final groupsRaw = groupNames.map((groupName) { final groupsRaw = groupNames.map((groupName) {
final group = proxies[groupName]; final group = proxies[groupName];
group["all"] = ((group["all"] ?? []) as List) group["all"] = ((group["all"] ?? []) as List)
.where(
(name) => !groupNames.contains(groupNames),
)
.map( .map(
(name) => proxies[name], (name) => proxies[name],
) )
@@ -107,31 +111,6 @@ class ClashCore {
}); });
} }
Future<DelayMap> getDelayMap() {
final proxiesRaw = clashFFI.getProxies();
final proxiesRawString = proxiesRaw.cast<Utf8>().toDartString();
return Isolate.run<DelayMap>(() {
final proxies = json.decode(proxiesRawString) as Map<String, dynamic>;
return proxies.map<String, int?>(
(k, v) {
final history = v["history"] as List<dynamic>;
if (history.isEmpty) {
return MapEntry(
k,
null,
);
} else {
final delay = history.last["delay"];
return MapEntry(
k,
delay != 0 ? delay : -1,
);
}
},
);
});
}
bool changeProxy(ChangeProxyParams changeProxyParams) { bool changeProxy(ChangeProxyParams changeProxyParams) {
final params = json.encode(changeProxyParams); final params = json.encode(changeProxyParams);
return clashFFI.changeProxy(params.toNativeUtf8().cast()) == 1; return clashFFI.changeProxy(params.toNativeUtf8().cast()) == 1;
@@ -146,14 +125,6 @@ class ClashCore {
return true; return true;
} }
clearEffect(String path) {
clashFFI.clearEffect(path.toNativeUtf8().cast());
}
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

@@ -924,20 +924,6 @@ class ClashFFI {
late final _updateConfig = late final _updateConfig =
_updateConfigPtr.asFunction<void Function(ffi.Pointer<ffi.Char>, int)>(); _updateConfigPtr.asFunction<void Function(ffi.Pointer<ffi.Char>, int)>();
void clearEffect(
ffi.Pointer<ffi.Char> s,
) {
return _clearEffect(
s,
);
}
late final _clearEffectPtr =
_lookup<ffi.NativeFunction<ffi.Void Function(ffi.Pointer<ffi.Char>)>>(
'clearEffect');
late final _clearEffect =
_clearEffectPtr.asFunction<void Function(ffi.Pointer<ffi.Char>)>();
ffi.Pointer<ffi.Char> getProxies() { ffi.Pointer<ffi.Char> getProxies() {
return _getProxies(); return _getProxies();
} }
@@ -1054,14 +1040,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

@@ -2,7 +2,6 @@ import 'dart:io';
import 'package:fl_clash/common/common.dart'; import 'package:fl_clash/common/common.dart';
import 'package:fl_clash/models/models.dart'; import 'package:fl_clash/models/models.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'core.dart'; import 'core.dart';
class ClashService { class ClashService {

View File

@@ -8,7 +8,7 @@ export 'num.dart';
export 'navigation.dart'; export 'navigation.dart';
export 'window.dart'; export 'window.dart';
export 'system.dart'; export 'system.dart';
export 'picker.dart'; export 'file.dart';
export 'android.dart'; export 'android.dart';
export 'launch.dart'; export 'launch.dart';
export 'protocol.dart'; export 'protocol.dart';

View File

@@ -2,8 +2,6 @@ import 'dart:ui';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
const appName = "FlClash";
class AppConstant { class AppConstant {
final packageName = "com.follow.clash"; final packageName = "com.follow.clash";
final name = "FlClash"; final name = "FlClash";

View File

@@ -1,7 +1,15 @@
import 'package:fl_clash/application.dart';
import 'package:fl_clash/controller.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';
extension BuildContextExtension on BuildContext { extension BuildContextExtension on BuildContext {
AppController get appController {
final appController =
findAncestorStateOfType<ApplicationState>()?.appController;
assert(appController != null, "only use application environment");
return appController!;
}
CommonScaffoldState? get commonScaffoldState { CommonScaffoldState? get commonScaffoldState {
return findAncestorStateOfType<CommonScaffoldState>(); return findAncestorStateOfType<CommonScaffoldState>();

View File

@@ -1,12 +1,11 @@
import 'dart:io'; import 'dart:io';
import 'package:file_picker/file_picker.dart'; import 'package:file_picker/file_picker.dart';
import 'package:fl_clash/common/common.dart'; import 'package:fl_clash/common/app_localizations.dart';
import 'package:image_picker/image_picker.dart';
import 'package:fl_clash/models/models.dart'; import 'package:fl_clash/models/models.dart';
class Picker { class FileUtil {
Future<Result<PlatformFile>> pickerConfigFile() async { static Future<Result<PlatformFile>> pickerConfig() async {
FilePickerResult? filePickerResult; FilePickerResult? filePickerResult;
if (Platform.isAndroid) { if (Platform.isAndroid) {
filePickerResult = await FilePicker.platform.pickFiles( filePickerResult = await FilePicker.platform.pickFiles(
@@ -27,17 +26,4 @@ class Picker {
} }
return Result.success(data: file); return Result.success(data: file);
} }
Future<Result<String>> pickerConfigQRCode() async {
final xFile = await ImagePicker().pickImage(source: ImageSource.gallery);
final bytes = await xFile?.readAsBytes();
if (bytes == null) return Result.error();
final result = await other.parseQRCode(bytes);
if (result == null || !result.isUrl) {
return Result.error(message: appLocalizations.pleaseUploadValidQrcode);
}
return Result.success(data: result);
}
} }
final picker = Picker();

View File

@@ -1,27 +1,23 @@
import 'dart:io'; import 'dart:io';
import 'dart:isolate';
import 'dart:typed_data';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:zxing2/qrcode.dart';
import 'package:image/image.dart' as img;
class Other { class Other {
Color? getDelayColor(int? delay) { static Color? getDelayColor(int? delay) {
if (delay == null) return null; if (delay == null) return null;
if (delay < 0) return Colors.red; if (delay < 0) return Colors.red;
if (delay < 600) return Colors.green; if (delay < 600) return Colors.green;
return const Color(0xFFC57F0A); return const Color(0xFFC57F0A);
} }
String getDateStringLast2(int value) { static String getDateStringLast2(int value) {
var valueRaw = "0$value"; var valueRaw = "0$value";
return valueRaw.substring( return valueRaw.substring(
valueRaw.length - 2, valueRaw.length - 2,
); );
} }
String getTimeDifference(DateTime dateTime) { static String getTimeDifference(DateTime dateTime) {
var currentDateTime = DateTime.now(); var currentDateTime = DateTime.now();
var difference = currentDateTime.difference(dateTime); var difference = currentDateTime.difference(dateTime);
var inHours = difference.inHours; var inHours = difference.inHours;
@@ -31,7 +27,7 @@ class Other {
return "${getDateStringLast2(inHours)}:${getDateStringLast2(inMinutes)}:${getDateStringLast2(inSeconds)}"; return "${getDateStringLast2(inHours)}:${getDateStringLast2(inMinutes)}:${getDateStringLast2(inSeconds)}";
} }
String getTimeText(int? timeStamp) { static String getTimeText(int? timeStamp) {
if (timeStamp == null) { if (timeStamp == null) {
return '00:00:00'; return '00:00:00';
} }
@@ -43,7 +39,7 @@ class Other {
return "${getDateStringLast2(inHours)}:${getDateStringLast2(inMinutes)}:${getDateStringLast2(inSeconds)}"; return "${getDateStringLast2(inHours)}:${getDateStringLast2(inMinutes)}:${getDateStringLast2(inSeconds)}";
} }
Locale? getLocaleForString(String? localString) { static Locale? getLocaleForString(String? localString) {
if (localString == null) return null; if (localString == null) return null;
var localSplit = localString.split("_"); var localSplit = localString.split("_");
if (localSplit.length == 1) { if (localSplit.length == 1) {
@@ -61,7 +57,7 @@ class Other {
return null; return null;
} }
int sortByChar(String a, String b) { static int sortByChar(String a, String b) {
if (a.isEmpty && b.isEmpty) { if (a.isEmpty && b.isEmpty) {
return 0; return 0;
} }
@@ -81,7 +77,7 @@ class Other {
} }
} }
String getOverwriteLabel(String label) { static String getOverwriteLabel(String label) {
final reg = RegExp(r'\((\d+)\)$'); final reg = RegExp(r'\((\d+)\)$');
final matches = reg.allMatches(label); final matches = reg.allMatches(label);
if (matches.isNotEmpty) { if (matches.isNotEmpty) {
@@ -93,7 +89,21 @@ class Other {
} }
} }
String getTrayIconPath() { // static FutureOr<void> Function(T p) debounce<T>(void Function(T? p) func,
// {Duration? duration}) {
// Timer? timer;
// return ([T? p]) {
// if (timer != null) {
// timer?.cancel();
// }
// timer = Timer(duration ?? const Duration(milliseconds: 300), () {
// func(p);
// });
// };
// }
static String getTrayIconPath() {
if (Platform.isWindows) { if (Platform.isWindows) {
return "assets/images/app_icon.ico"; return "assets/images/app_icon.ico";
} else { } else {
@@ -101,7 +111,7 @@ class Other {
} }
} }
int compareVersions(String version1, String version2) { static int compareVersions(String version1, String version2) {
List<String> v1 = version1.split('+')[0].split('.'); List<String> v1 = version1.split('+')[0].split('.');
List<String> v2 = version2.split('+')[0].split('.'); List<String> v2 = version2.split('+')[0].split('.');
int major1 = int.parse(v1[0]); int major1 = int.parse(v1[0]);
@@ -123,30 +133,4 @@ class Other {
int build2 = version2.contains('+') ? int.parse(version2.split('+')[1]) : 0; int build2 = version2.contains('+') ? int.parse(version2.split('+')[1]) : 0;
return build1.compareTo(build2); return build1.compareTo(build2);
} }
Future<String?> parseQRCode(Uint8List? bytes) {
return Isolate.run<String?>(() {
if (bytes == null) return null;
img.Image? image = img.decodeImage(bytes);
LuminanceSource source = RGBLuminanceSource(
image!.width,
image.height,
image
.convert(numChannels: 4)
.getBytes(order: img.ChannelOrder.abgr)
.buffer
.asInt32List(),
);
final bitmap = BinaryBitmap(GlobalHistogramBinarizer(source));
final reader = QRCodeReader();
try {
final result = reader.decode(bitmap);
return result.text;
} catch (_) {
return null;
}
});
}
} }
final other = Other();

View File

@@ -1,6 +1,7 @@
import 'dart:async'; import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'package:flutter/cupertino.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
import '../models/models.dart'; import '../models/models.dart';
@@ -28,7 +29,8 @@ class Preferences {
try { try {
return ClashConfig.fromJson(clashConfigMap); return ClashConfig.fromJson(clashConfigMap);
} catch (e) { } catch (e) {
throw e.toString(); debugPrint(e.toString());
return null;
} }
} }
@@ -48,7 +50,8 @@ class Preferences {
try { try {
return Config.fromJson(configMap); return Config.fromJson(configMap);
} catch (e) { } catch (e) {
throw e.toString(); debugPrint(e.toString());
return null;
} }
} }

View File

@@ -29,7 +29,7 @@ class Request {
final packageInfo = await appPackage.packageInfoCompleter.future; final packageInfo = await appPackage.packageInfoCompleter.future;
final version = packageInfo.version; final version = packageInfo.version;
final hasUpdate = final hasUpdate =
other.compareVersions(remoteVersion.replaceAll('v', ''), version) > 0; Other.compareVersions(remoteVersion.replaceAll('v', ''), version) > 0;
if (!hasUpdate) return Result.error(); if (!hasUpdate) return Result.error();
return Result.success(data: body['body']); return Result.success(data: body['body']);
} }

View File

@@ -1,4 +1,6 @@
import 'dart:async'; import 'dart:async';
import 'dart:io';
import 'dart:isolate';
import 'package:fl_clash/state.dart'; import 'package:fl_clash/state.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@@ -33,14 +35,13 @@ class AppController {
config: config, config: config,
clashConfig: clashConfig, clashConfig: clashConfig,
); );
updateRunTime(); updateRunTime();
updateTraffic(); updateTraffic();
globalState.updateFunctionLists = [ globalState.updateFunctionLists = [
updateRunTime, updateRunTime,
updateTraffic, updateTraffic,
]; ];
clearShowProxyDelay();
testShowProxyDelay();
} else { } else {
await globalState.stopSystemProxy(); await globalState.stopSystemProxy();
appState.traffics = []; appState.traffics = [];
@@ -55,7 +56,9 @@ class AppController {
updateRunTime() { updateRunTime() {
if (proxyManager.startTime != null) { if (proxyManager.startTime != null) {
final startTimeStamp = proxyManager.startTime!.millisecondsSinceEpoch; final startTimeStamp = proxyManager.startTime!.millisecondsSinceEpoch;
final nowTimeStamp = DateTime.now().millisecondsSinceEpoch; final nowTimeStamp = DateTime
.now()
.millisecondsSinceEpoch;
appState.runTime = nowTimeStamp - startTimeStamp; appState.runTime = nowTimeStamp - startTimeStamp;
} else { } else {
appState.runTime = null; appState.runTime = null;
@@ -87,7 +90,13 @@ class AppController {
config.deleteProfileById(id); config.deleteProfileById(id);
final profilePath = await appPath.getProfilePath(id); final profilePath = await appPath.getProfilePath(id);
if (profilePath == null) return; if (profilePath == null) return;
clashCore.clearEffect(profilePath); final file = File(profilePath);
Isolate.run(() async {
final isExists = await file.exists();
if (isExists) {
file.delete();
}
});
if (config.currentProfileId == id) { if (config.currentProfileId == id) {
if (config.profiles.isNotEmpty) { if (config.profiles.isNotEmpty) {
final updateId = config.profiles.first.id; final updateId = config.profiles.first.id;
@@ -124,7 +133,7 @@ class AppController {
); );
} }
Function? _changeProfileDebounce; Function? _changeProfileDebounce;
changeProfileDebounce(String? profileId) { changeProfileDebounce(String? profileId) {
if (profileId == config.currentProfileId) return; if (profileId == config.currentProfileId) return;
@@ -150,8 +159,8 @@ class AppController {
if (!profile.autoUpdate) return; if (!profile.autoUpdate) return;
final isNotNeedUpdate = profile.lastUpdateDate final isNotNeedUpdate = profile.lastUpdateDate
?.add( ?.add(
profile.autoUpdateDuration, profile.autoUpdateDuration,
) )
.isBeforeNow(); .isBeforeNow();
if (isNotNeedUpdate == false) continue; if (isNotNeedUpdate == false) continue;
await profile.update(); await profile.update();
@@ -166,6 +175,13 @@ class AppController {
appState.systemColorSchemes = systemColorSchemes; appState.systemColorSchemes = systemColorSchemes;
} }
clearCurrentDelay() {
final currentProxyName =
appState.getCurrentProxyName(config.currentProxyName, clashConfig.mode);
if (currentProxyName == null) return;
appState.setDelay(Delay(name: currentProxyName, value: null));
}
savePreferences() async { savePreferences() async {
await saveConfigPreferences(); await saveConfigPreferences();
await saveClashConfigPreferences(); await saveClashConfigPreferences();
@@ -209,40 +225,25 @@ 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) {
appState.setDelay(delay); appState.setDelay(delay);
} }
updateDelayMap() async {
appState.delayMap = await clashCore.getDelayMap();
}
toPage(int index, {bool hasAnimate = false}) { toPage(int index, {bool hasAnimate = false}) {
final nextLabel = globalState.currentNavigationItems[index].label; final nextLabel = globalState.currentNavigationItems[index].label;
appState.currentLabel = nextLabel; appState.currentLabel = nextLabel;
@@ -263,49 +264,20 @@ class AppController {
toProfiles() { toProfiles() {
final index = globalState.currentNavigationItems.indexWhere( final index = globalState.currentNavigationItems.indexWhere(
(element) => element.label == "profiles", (element) => element.label == "profiles",
); );
if (index != -1) { if (index != -1) {
toPage(index); toPage(index);
} }
} }
initLink() {
linkManager.initAppLinksListen(
(url) {
globalState.showMessage(
title: "${appLocalizations.add}${appLocalizations.profile}",
message: TextSpan(
children: [
TextSpan(text: appLocalizations.doYouWantToPass),
TextSpan(
text: " $url ",
style: TextStyle(
color: Theme.of(context).colorScheme.primary,
decoration: TextDecoration.underline,
decorationColor: Theme.of(context).colorScheme.primary,
),
),
TextSpan(
text:
"${appLocalizations.create}${appLocalizations.profile}"),
],
),
onTab: () {
addProfileFormURL(url);
},
);
},
);
}
addProfileFormURL(String url) async { addProfileFormURL(String url) async {
globalState.navigatorKey.currentState?.popUntil((route) => route.isFirst); globalState.navigatorKey.currentState?.popUntil((route) => route.isFirst);
toProfiles(); toProfiles();
final commonScaffoldState = globalState.homeScaffoldKey.currentState; final commonScaffoldState = globalState.homeScaffoldKey.currentState;
if (commonScaffoldState?.mounted != true) return; if (commonScaffoldState?.mounted != true) return;
commonScaffoldState?.loadingRun( commonScaffoldState?.loadingRun(
() async { () async {
await Future.delayed(const Duration(milliseconds: 300)); await Future.delayed(const Duration(milliseconds: 300));
final profile = Profile( final profile = Profile(
url: url, url: url,
@@ -324,8 +296,43 @@ class AppController {
); );
} }
initLink() {
linkManager.initAppLinksListen(
(url) {
globalState.showMessage(
title: "${appLocalizations.add}${appLocalizations.profile}",
message: TextSpan(
children: [
TextSpan(text: appLocalizations.doYouWantToPass),
TextSpan(
text: " $url ",
style: TextStyle(
color: Theme
.of(context)
.colorScheme
.primary,
decoration: TextDecoration.underline,
decorationColor: Theme
.of(context)
.colorScheme
.primary,
),
),
TextSpan(
text:
"${appLocalizations.create}${appLocalizations.profile}"),
],
),
onTab: () {
addProfileFormURL(url);
},
);
},
);
}
addProfileFormFile() async { addProfileFormFile() async {
final result = await picker.pickerConfigFile(); final result = await FileUtil.pickerConfig();
if (result.type == ResultType.error) return; if (result.type == ResultType.error) return;
if (!context.mounted) return; if (!context.mounted) return;
globalState.navigatorKey.currentState?.popUntil((route) => route.isFirst); globalState.navigatorKey.currentState?.popUntil((route) => route.isFirst);
@@ -333,7 +340,7 @@ class AppController {
final commonScaffoldState = globalState.homeScaffoldKey.currentState; final commonScaffoldState = globalState.homeScaffoldKey.currentState;
if (commonScaffoldState?.mounted != true) return; if (commonScaffoldState?.mounted != true) return;
commonScaffoldState?.loadingRun( commonScaffoldState?.loadingRun(
() async { () async {
await Future.delayed(const Duration(milliseconds: 300)); await Future.delayed(const Duration(milliseconds: 300));
final bytes = result.data?.bytes; final bytes = result.data?.bytes;
if (bytes == null) { if (bytes == null) {
@@ -353,36 +360,4 @@ class AppController {
}, },
); );
} }
addProfileFormQrCode() async {
final result = await picker.pickerConfigQRCode();
if (result.type == ResultType.error) {
if(result.message != null){
globalState.showMessage(
title: appLocalizations.tip,
message: TextSpan(
text: result.message,
),
);
}
return;
}
addProfileFormURL(result.data!);
}
clearShowProxyDelay() {
final showProxyDelay = appState.getRealProxyName(appState.showProxyName);
if (showProxyDelay != null) {
appState.setDelay(
Delay(name: showProxyDelay, value: null),
);
}
}
testShowProxyDelay() {
final showProxyDelay = appState.getRealProxyName(appState.showProxyName);
if (showProxyDelay != null) {
globalState.updateCurrentDelay(showProxyDelay);
}
}
} }

View File

@@ -2,8 +2,6 @@
enum GroupType { Selector, URLTest, Fallback } enum GroupType { Selector, URLTest, Fallback }
enum GroupName { GLOBAL, Proxy, Auto, Fallback }
extension GroupTypeExtension on GroupType { extension GroupTypeExtension on GroupType {
static List<String> get valueList => GroupType.values static List<String> get valueList => GroupType.values
.map( .map(
@@ -54,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

@@ -2,7 +2,6 @@ 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/plugins/app.dart'; import 'package:fl_clash/plugins/app.dart';
import 'package:fl_clash/common/common.dart'; import 'package:fl_clash/common/common.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';
@@ -293,9 +292,9 @@ class AccessFragment extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (globalState.appController.appState.packages.isEmpty) { if (context.appController.appState.packages.isEmpty) {
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
globalState.appController.updatePackages(); context.appController.updatePackages();
}); });
} }
return Selector<Config, bool>( return Selector<Config, bool>(

View File

@@ -2,7 +2,6 @@ import 'dart:io';
import 'package:fl_clash/common/common.dart'; import 'package:fl_clash/common/common.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:intl/intl.dart'; import 'package:intl/intl.dart';
@@ -36,26 +35,6 @@ class ApplicationSettingFragment extends StatelessWidget {
); );
}, },
), ),
Selector<Config, bool>(
selector: (_, config) => config.isCompatible,
builder: (_, isCompatible, __) {
return ListItem.switchItem(
leading: const Icon(Icons.expand),
title: Text(appLocalizations.compatible),
subtitle: Text(appLocalizations.compatibleDesc),
delegate: SwitchDelegate(
value: isCompatible,
onChanged: (bool value) async {
final appController = globalState.appController;
appController.config.isCompatible = value;
await appController.updateClashConfig(isPatch: false);
await appController.updateGroups();
appController.changeProxy();
},
),
);
},
),
if (system.isDesktop) if (system.isDesktop)
Selector<Config, bool>( Selector<Config, bool>(
selector: (_, config) => config.autoLaunch, selector: (_, config) => config.autoLaunch,
@@ -121,7 +100,7 @@ class ApplicationSettingFragment extends StatelessWidget {
onChanged: (bool value) { onChanged: (bool value) {
final config = context.read<Config>(); final config = context.read<Config>();
config.openLogs = value; config.openLogs = value;
globalState.appController.updateLogStatus(); context.appController.updateLogStatus();
}, },
), ),
); );

View File

@@ -24,8 +24,8 @@ class _ConfigFragmentState extends State<ConfigFragment> {
try { try {
final mixedPort = int.parse(port); final mixedPort = int.parse(port);
if (mixedPort < 1024 || mixedPort > 49151) throw "Invalid port"; if (mixedPort < 1024 || mixedPort > 49151) throw "Invalid port";
globalState.appController.clashConfig.mixedPort = mixedPort; context.appController.clashConfig.mixedPort = mixedPort;
globalState.appController.updateClashConfigDebounce(); context.appController.updateClashConfigDebounce();
} catch (e) { } catch (e) {
globalState.showMessage( globalState.showMessage(
title: appLocalizations.proxyPort, title: appLocalizations.proxyPort,
@@ -39,9 +39,9 @@ class _ConfigFragmentState extends State<ConfigFragment> {
_updateLoglevel(LogLevel? logLevel) { _updateLoglevel(LogLevel? logLevel) {
if (logLevel == null || if (logLevel == null ||
logLevel == globalState.appController.clashConfig.logLevel) return; logLevel == context.appController.clashConfig.logLevel) return;
globalState.appController.clashConfig.logLevel = logLevel; context.appController.clashConfig.logLevel = logLevel;
globalState.appController.updateClashConfigDebounce(); context.appController.updateClashConfigDebounce();
} }
@override @override
@@ -59,31 +59,12 @@ class _ConfigFragmentState extends State<ConfigFragment> {
onChanged: (bool value) async { onChanged: (bool value) async {
final clashConfig = context.read<ClashConfig>(); final clashConfig = context.read<ClashConfig>();
clashConfig.allowLan = value; clashConfig.allowLan = value;
globalState.appController.updateClashConfigDebounce(); context.appController.updateClashConfigDebounce();
}, },
), ),
); );
}, },
), ),
if (system.isDesktop)
Selector<ClashConfig, bool>(
selector: (_, clashConfig) => clashConfig.tun.enable,
builder: (_, tunEnable, __) {
return ListItem.switchItem(
leading: const Icon(Icons.support),
title: Text(appLocalizations.tun),
subtitle: Text(appLocalizations.tunDesc),
delegate: SwitchDelegate(
value: tunEnable,
onChanged: (bool value) async {
final clashConfig = context.read<ClashConfig>();
clashConfig.tun = Tun(enable: value);
globalState.appController.updateClashConfigDebounce();
},
),
);
},
),
Selector<ClashConfig, int>( Selector<ClashConfig, int>(
selector: (_, clashConfig) => clashConfig.mixedPort, selector: (_, clashConfig) => clashConfig.mixedPort,
builder: (_, mixedPort, __) { builder: (_, mixedPort, __) {
@@ -139,7 +120,7 @@ class _ConfigFragmentState extends State<ConfigFragment> {
return ListView.separated( return ListView.separated(
itemBuilder: (_, index) { itemBuilder: (_, index) {
return Container( return Container(
padding: kMaterialListPadding, height: 84,
alignment: Alignment.center, alignment: Alignment.center,
child: items[index], child: items[index],
); );

View File

@@ -82,7 +82,7 @@ class _NetworkDetectionState extends State<NetworkDetection> {
if (!isCurrent || currentProxyName == null || !isInit) return; if (!isCurrent || currentProxyName == null || !isInit) return;
WidgetsBinding.instance.addPostFrameCallback((timeStamp) { WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
if (delay == null) { if (delay == null) {
globalState.appController.setDelay( context.appController.setDelay(
Delay( Delay(
name: currentProxyName, name: currentProxyName,
value: 0, value: 0,
@@ -95,6 +95,34 @@ class _NetworkDetectionState extends State<NetworkDetection> {
}); });
} }
_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, __) {
_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(
@@ -102,55 +130,58 @@ class _NetworkDetectionState extends State<NetworkDetection> {
iconData: Icons.network_check, iconData: Icons.network_check,
label: appLocalizations.networkDetection, label: appLocalizations.networkDetection,
), ),
child: Selector<AppState, NetworkDetectionSelectorState>( child: _updateCurrentDelayContainer(
selector: (_, appState) { Selector3<AppState, Config, ClashConfig, NetworkDetectionSelectorState>(
return NetworkDetectionSelectorState( selector: (_, appState, config, clashConfig) {
currentProxyName: appState.showProxyName, final proxyName = appState.getCurrentProxyName(
delay: appState.getDelay( config.currentProxyName,
appState.showProxyName, clashConfig.mode,
), );
); return NetworkDetectionSelectorState(
}, isInit: appState.isInit,
builder: (_, state, __) { currentProxyName: proxyName,
return Container( delay: appState.delayMap[proxyName],
padding: const EdgeInsets.all(16).copyWith(top: 0), );
child: Column( },
mainAxisSize: MainAxisSize.min, builder: (_, state, __) {
crossAxisAlignment: CrossAxisAlignment.start, return Container(
children: [ padding: const EdgeInsets.all(16).copyWith(top: 0),
Flexible( child: Column(
flex: 0, mainAxisSize: MainAxisSize.min,
child: TooltipText( crossAxisAlignment: CrossAxisAlignment.start,
text: Text( children: [
state.currentProxyName ?? appLocalizations.noProxy, Flexible(
overflow: TextOverflow.ellipsis, flex: 0,
maxLines: 1, child: TooltipText(
style: Theme.of(context) text: Text(
.textTheme state.currentProxyName ?? appLocalizations.noProxy,
.titleMedium overflow: TextOverflow.ellipsis,
?.toSoftBold(), maxLines: 1,
), style:
), Theme.of(context).textTheme.titleMedium?.toSoftBold(),
),
const SizedBox(
height: 8,
),
Flexible(
child: Container(
height: globalState.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

@@ -1,6 +1,5 @@
import 'package:fl_clash/common/common.dart'; import 'package:fl_clash/common/common.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';
@@ -69,7 +68,7 @@ class _NetworkSpeedState extends State<NetworkSpeed> {
style: bodyMedium, style: bodyMedium,
maxLines: 1, maxLines: 1,
); );
final size = globalState.appController.measure.computeTextSize(valueText); final size = context.appController.measure.computeTextSize(valueText);
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,

View File

@@ -1,7 +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/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:intl/intl.dart'; import 'package:intl/intl.dart';
@@ -11,19 +10,11 @@ class OutboundMode extends StatelessWidget {
const OutboundMode({super.key}); const OutboundMode({super.key});
_changeMode(BuildContext context, Mode? value) async { _changeMode(BuildContext context, Mode? value) async {
final appController = globalState.appController; final appController = context.appController;
final clashConfig = appController.clashConfig; final clashConfig = context.read<ClashConfig>();
final config = appController.config;
if (value == null || clashConfig.mode == value) return; if (value == null || clashConfig.mode == value) return;
clashConfig.mode = value; clashConfig.mode = value;
await appController.updateClashConfig(); await appController.updateClashConfig();
if (!config.isCompatible) {
final proxySelected = config.currentSelectedMap[GroupName.Proxy.name];
final globalSelected = config.currentSelectedMap[GroupName.GLOBAL.name];
if (proxySelected != null && globalSelected == null) {
config.updateCurrentSelectedMap(GroupName.GLOBAL.name, proxySelected);
}
}
appController.changeProxy(); appController.changeProxy();
} }
@@ -63,8 +54,7 @@ class OutboundMode extends StatelessWidget {
), ),
title: Text( title: Text(
Intl.message(item.name), Intl.message(item.name),
style: Theme style: Theme.of(context)
.of(context)
.textTheme .textTheme
.titleMedium .titleMedium
?.toSoftBold(), ?.toSoftBold(),

View File

@@ -1,6 +1,5 @@
import 'package:fl_clash/common/common.dart'; import 'package:fl_clash/common/common.dart';
import 'package:fl_clash/models/models.dart'; import 'package:fl_clash/models/models.dart';
import 'package:fl_clash/state.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
@@ -49,8 +48,11 @@ class _StartButtonState extends State<StartButton>
} }
updateSystemProxy() async { updateSystemProxy() async {
final appController = globalState.appController; final appController = context.appController;
await appController.updateSystemProxy(isStart); await appController.updateSystemProxy(isStart);
if (isStart && mounted) {
appController.clearCurrentDelay();
}
} }
@override @override
@@ -64,17 +66,14 @@ class _StartButtonState extends State<StartButton>
if (!state.isInit || !state.hasProfile) { if (!state.isInit || !state.hasProfile) {
return Container(); return Container();
} }
final textWidth = globalState.appController.measure final textWidth = context.appController.measure.computeTextSize(
.computeTextSize( Text(
Text( Other.getTimeDifference(
other.getTimeDifference( DateTime.now(),
DateTime.now(), ),
), style: Theme.of(context).textTheme.titleMedium?.toSoftBold(),
style: ),
Theme.of(context).textTheme.titleMedium?.toSoftBold(), ).width +
),
)
.width +
16; 16;
return AnimatedBuilder( return AnimatedBuilder(
animation: _controller.view, animation: _controller.view,
@@ -131,7 +130,7 @@ class _StartButtonState extends State<StartButton>
child: Selector<AppState, int?>( child: Selector<AppState, int?>(
selector: (_, appState) => appState.runTime, selector: (_, appState) => appState.runTime,
builder: (_, int? value, __) { builder: (_, int? value, __) {
final text = other.getTimeText(value); final text = Other.getTimeText(value);
return Text( return Text(
text, text,
style: Theme.of(context).textTheme.titleMedium?.toSoftBold(), style: Theme.of(context).textTheme.titleMedium?.toSoftBold(),

View File

@@ -1,3 +1,4 @@
import 'dart:io';
import 'package:fl_clash/common/common.dart'; import 'package:fl_clash/common/common.dart';
import 'package:fl_clash/pages/scan.dart'; import 'package:fl_clash/pages/scan.dart';
import 'package:fl_clash/state.dart'; import 'package:fl_clash/state.dart';
@@ -7,21 +8,17 @@ import 'package:flutter/material.dart';
class AddProfile extends StatelessWidget { class AddProfile extends StatelessWidget {
final BuildContext context; final BuildContext context;
const AddProfile({super.key, required this.context,}); const AddProfile({super.key, required this.context});
_handleAddProfileFormFile() async { _handleAddProfileFormFile() async {
globalState.appController.addProfileFormFile(); context.appController.addProfileFormFile();
} }
_handleAddProfileFormURL(String url) async { _handleAddProfileFormURL(String url) async {
globalState.appController.addProfileFormURL(url); context.appController.addProfileFormURL(url);
} }
_toScan() async { _toScan() async {
if(system.isDesktop){
globalState.appController.addProfileFormQrCode();
return;
}
final url = await Navigator.of(context) final url = await Navigator.of(context)
.push<String>(MaterialPageRoute(builder: (_) => const ScanPage())); .push<String>(MaterialPageRoute(builder: (_) => const ScanPage()));
if (url != null) { if (url != null) {
@@ -42,6 +39,7 @@ class AddProfile extends StatelessWidget {
Widget build(context) { Widget build(context) {
return ListView( return ListView(
children: [ children: [
if (Platform.isAndroid)
ListItem( ListItem(
leading: const Icon(Icons.qr_code), leading: const Icon(Icons.qr_code),
title: Text(appLocalizations.qrcode), title: Text(appLocalizations.qrcode),

View File

@@ -1,6 +1,5 @@
import 'package:fl_clash/common/common.dart'; import 'package:fl_clash/common/common.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';
@@ -39,7 +38,7 @@ class _EditProfileState extends State<EditProfile> {
_handleConfirm() { _handleConfirm() {
if (!_formKey.currentState!.validate()) return; if (!_formKey.currentState!.validate()) return;
final config = widget.context.read<Config>(); final config = context.read<Config>();
final hasUpdate = widget.profile.url != urlController.text; final hasUpdate = widget.profile.url != urlController.text;
widget.profile.url = urlController.text; widget.profile.url = urlController.text;
widget.profile.label = labelController.text; widget.profile.label = labelController.text;
@@ -49,7 +48,7 @@ class _EditProfileState extends State<EditProfile> {
config.setProfile(widget.profile); config.setProfile(widget.profile);
if (hasUpdate) { if (hasUpdate) {
widget.context.findAncestorStateOfType<CommonScaffoldState>()?.loadingRun( widget.context.findAncestorStateOfType<CommonScaffoldState>()?.loadingRun(
() => globalState.appController.updateProfile( () => context.appController.updateProfile(
widget.profile.id, widget.profile.id,
), ),
); );

View File

@@ -1,7 +1,6 @@
import 'package:fl_clash/fragments/profiles/edit_profile.dart'; import 'package:fl_clash/fragments/profiles/edit_profile.dart';
import 'package:fl_clash/models/models.dart'; import 'package:fl_clash/models/models.dart';
import 'package:fl_clash/common/common.dart'; import 'package:fl_clash/common/common.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:flutter_adaptive_scaffold/flutter_adaptive_scaffold.dart'; import 'package:flutter_adaptive_scaffold/flutter_adaptive_scaffold.dart';
@@ -25,6 +24,7 @@ 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);
@@ -50,12 +50,12 @@ class _ProfilesFragmentState extends State<ProfilesFragment> {
} }
_handleDeleteProfile(String id) async { _handleDeleteProfile(String id) async {
globalState.appController.deleteProfile(id); context.appController.deleteProfile(id);
} }
_handleUpdateProfile(String id) async { _handleUpdateProfile(String id) async {
context.findAncestorStateOfType<CommonScaffoldState>()?.loadingRun( context.findAncestorStateOfType<CommonScaffoldState>()?.loadingRun(
() => globalState.appController.updateProfile(id), () => context.appController.updateProfile(id),
); );
} }
@@ -175,9 +175,9 @@ class _ProfilesFragmentState extends State<ProfilesFragment> {
_handleShowAddExtendPage() { _handleShowAddExtendPage() {
showExtendPage( showExtendPage(
globalState.navigatorKey.currentState!.context, context,
body: AddProfile( body: AddProfile(
context: globalState.navigatorKey.currentState!.context, context: context,
), ),
title: "${appLocalizations.add}${appLocalizations.profile}", title: "${appLocalizations.add}${appLocalizations.profile}",
); );
@@ -210,7 +210,7 @@ class _ProfilesFragmentState extends State<ProfilesFragment> {
child: _profileItem( child: _profileItem(
profile: profile, profile: profile,
groupValue: state.currentProfileId, groupValue: state.currentProfileId,
onChanged: globalState.appController.changeProfileDebounce, onChanged: context.appController.changeProfileDebounce,
), ),
), ),
], ],

View File

@@ -1,4 +1,4 @@
import 'package:fl_clash/state.dart'; import 'package:fl_clash/clash/clash.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_adaptive_scaffold/flutter_adaptive_scaffold.dart'; import 'package:flutter_adaptive_scaffold/flutter_adaptive_scaffold.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
@@ -58,99 +58,160 @@ 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.currentGroups; _tabController!.dispose();
final groupNames = currentGroups.map((e) => e.name).toList(); _tabController = null;
return ProxiesSelectorState( }
groupNames: groupNames, _tabController = TabController(
); length: state.groups.length,
}, vsync: this,
shouldRebuild: (prev, next) { initialIndex: state.currentIndex,
if (prev.groupNames.length != next.groupNames.length) { );
_tabController?.dispose(); return Column(
_tabController = null; mainAxisAlignment: MainAxisAlignment.start,
} crossAxisAlignment: CrossAxisAlignment.start,
return prev != next; 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,
); tabAlignment: TabAlignment.start,
return Column( overlayColor:
mainAxisAlignment: MainAxisAlignment.start, const MaterialStatePropertyAll(Colors.transparent),
crossAxisAlignment: CrossAxisAlignment.start, tabs: [
children: [ for (final group in state.groups)
TabBar( Tab(
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();
}
Group 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(
(a, b) => other.sortByChar(a.name, b.name), (a, b) => Other.sortByChar(a.name, b.name),
); );
} }
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;
return proxies = List.of(proxies) return proxies = List.of(proxies)
..sort( ..sort(
(a, b) { (a, b) {
final aDelay = appState.getDelay(a.name); final aDelay = delayMap[a.name];
final bDelay = appState.getDelay(b.name); final bDelay = delayMap[b.name];
if (aDelay == null && bDelay == null) { if (aDelay == null && bDelay == null) {
return 0; return 0;
} }
@@ -166,19 +227,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 = globalState.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 +
@@ -186,13 +266,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 = globalState.appController.measure;
return CommonCard( return CommonCard(
isSelected: isSelected, isSelected: isSelected,
onPressed: onPressed, onPressed: onPressed,
@@ -229,22 +307,12 @@ class ProxiesTabView extends StatelessWidget {
), ),
SizedBox( SizedBox(
height: measure.bodySmallHeight, height: measure.bodySmallHeight,
child: Selector<AppState, String>( child: Text(
selector: (context, appState) => appState.getDesc( proxy.type,
proxy.type, style: context.textTheme.bodySmall?.copyWith(
proxy.name, overflow: TextOverflow.ellipsis,
color: context.textTheme.bodySmall?.color?.toLight(),
), ),
builder: (_, desc, __) {
return TooltipText(
text: Text(
desc,
style: context.textTheme.bodySmall?.copyWith(
overflow: TextOverflow.ellipsis,
color: context.textTheme.bodySmall?.color?.toLight(),
),
),
);
},
), ),
), ),
const SizedBox( const SizedBox(
@@ -253,9 +321,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( selector: (context, appState) => appState.delayMap[proxy.name],
proxy.name,
),
builder: (_, delay, __) { builder: (_, delay, __) {
return FadeBox( return FadeBox(
child: Builder( child: Builder(
@@ -276,7 +342,7 @@ class ProxiesTabView extends StatelessWidget {
delay > 0 ? '$delay ms' : "Timeout", delay > 0 ? '$delay ms' : "Timeout",
style: context.textTheme.labelSmall?.copyWith( style: context.textTheme.labelSmall?.copyWith(
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
color: other.getDelayColor( color: Other.getDelayColor(
delay, delay,
), ),
), ),
@@ -293,215 +359,115 @@ 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: Selector3<AppState, Config, ClashConfig, ProxiesCardSelectorState>(
crossAxisCount: columns, selector: (_, appState, config, clashConfig) =>
mainAxisSpacing: 8, ProxiesCardSelectorState(
crossAxisSpacing: 8, currentGroupName: appState.getCurrentGroupName(
mainAxisExtent: _getItemHeight(context), config.currentGroupName,
), clashConfig.mode,
itemCount: proxies.length, ),
itemBuilder: (_, index) { currentProxyName: appState.getCurrentProxyName(
final proxy = proxies[index]; config.currentProxyName,
return Selector3<AppState, Config, ClashConfig, clashConfig.mode,
ProxiesCardSelectorState>( ),
selector: (_, appState, config, clashConfig) { ),
final group = appState.getGroupWithName(groupName)!; builder: (_, state, __) {
bool isSelected = return AnimateGrid<Proxy>(
config.currentSelectedMap[group.name] == proxy.name || items: _getProxies(group.all, proxiesSortType),
(config.currentSelectedMap[group.name] == null && columns: columns,
group.now == proxy.name); itemHeight: _getItemHeight(),
return ProxiesCardSelectorState( keyBuilder: (item) {
isSelected: isSelected, return ObjectKey(item);
);
},
builder: (_, state, __) {
return _card(
context,
isSelected: state.isSelected,
onPressed: () {
final appController = globalState.appController;
final group =
appController.appState.getGroupWithName(groupName)!;
if (group.type != GroupType.Selector) {
globalState.showSnackBar(
context,
message: appLocalizations.notSelectedTip,
);
return;
}
globalState.appController.config.updateCurrentSelectedMap(
groupName,
proxy.name,
);
globalState.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,
),
),
}, },
builder: (_, proxy) {
final isSelected = group.type == GroupType.Selector
? group.name == state.currentGroupName &&
proxy.name == state.currentProxyName
: group.now == proxy.name;
return _card(
isSelected: isSelected,
onPressed: () {
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 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
{
if(globalState.healthcheckLock) return;
_controller.forward();
globalState.appController.healthcheck();
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.elasticInOut,
),
),
);
_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

@@ -1,6 +1,5 @@
import 'package:fl_clash/common/common.dart'; import 'package:fl_clash/common/common.dart';
import 'package:fl_clash/models/models.dart'; import 'package:fl_clash/models/models.dart';
import 'package:fl_clash/state.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
@@ -29,7 +28,7 @@ class ThemeFragment extends StatelessWidget {
return CommonCard( return CommonCard(
isSelected: isSelected, isSelected: isSelected,
onPressed: () { onPressed: () {
globalState.appController.config.themeMode = themeModeItem.themeMode; context.appController.config.themeMode = themeModeItem.themeMode;
}, },
child: Padding( child: Padding(
padding: const EdgeInsets.symmetric(horizontal:16), padding: const EdgeInsets.symmetric(horizontal:16),
@@ -63,7 +62,7 @@ class ThemeFragment extends StatelessWidget {
isSelected: isSelected, isSelected: isSelected,
primaryColor: color, primaryColor: color,
onPressed: () { onPressed: () {
globalState.appController.config.primaryColor = color?.value; context.appController.config.primaryColor = color?.value;
}, },
); );
} }

View File

@@ -114,7 +114,7 @@ class _ToolboxFragmentState extends State<ToolsFragment> {
selector: (_, config) => config.locale, selector: (_, config) => config.locale,
builder: (_, localeString, __) { builder: (_, localeString, __) {
final subTitle = localeString ?? appLocalizations.defaultText; final subTitle = localeString ?? appLocalizations.defaultText;
final currentLocale = other.getLocaleForString(localeString); final currentLocale = Other.getLocaleForString(localeString);
return ListTile( return ListTile(
leading: const Icon(Icons.language_outlined), leading: const Icon(Icons.language_outlined),
title: Text(appLocalizations.language), title: Text(appLocalizations.language),
@@ -211,23 +211,31 @@ class _ToolboxFragmentState extends State<ToolsFragment> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final items = [ final items = [
Selector<AppState, List<NavigationItem>>( LayoutBuilder(builder: (context, container) {
selector: (_, appState) => appState.navigationItems, final isMobile = context.isMobile;
builder: (_, navigationItems, __) { if (!isMobile) {
final moreNavigationItems = navigationItems return Container(
.where( margin: const EdgeInsets.only(top: 18),
(element) => element.modes.contains(NavigationItemMode.more),
)
.toList();
if (moreNavigationItems.isEmpty) {
return Container();
}
return _buildSection(
title: appLocalizations.more,
content: _buildNavigationMenu(moreNavigationItems),
); );
}, }
), return Selector<AppState, List<NavigationItem>>(
selector: (_, appState) => appState.navigationItems,
builder: (_, navigationItems, __) {
final moreNavigationItems = navigationItems
.where(
(element) => element.modes.contains(NavigationItemMode.more),
)
.toList();
if (moreNavigationItems.isEmpty) {
return Container();
}
return _buildSection(
title: appLocalizations.more,
content: _buildNavigationMenu(moreNavigationItems),
);
},
);
}),
_buildSection( _buildSection(
title: appLocalizations.settings, title: appLocalizations.settings,
content: _getSettingList(), content: _getSettingList(),

View File

@@ -35,7 +35,7 @@
"overrideDesc": "Override Proxy related config", "overrideDesc": "Override Proxy related config",
"allowLan": "AllowLan", "allowLan": "AllowLan",
"allowLanDesc": "Allow access proxy through the LAN", "allowLanDesc": "Allow access proxy through the LAN",
"tun": "Tun mode", "tun": "Tun",
"tunDesc": "only effective in administrator mode", "tunDesc": "only effective in administrator mode",
"minimizeOnExit": "Minimize on exit", "minimizeOnExit": "Minimize on exit",
"minimizeOnExitDesc": "Modify the default system exit event", "minimizeOnExitDesc": "Modify the default system exit event",
@@ -92,7 +92,6 @@
"delaySort": "Sort by delay", "delaySort": "Sort by delay",
"nameSort": "Sort by name", "nameSort": "Sort by name",
"pleaseUploadFile": "Please upload file", "pleaseUploadFile": "Please upload file",
"pleaseUploadValidQrcode": "Please upload a valid QR code",
"blacklistMode": "Blacklist mode", "blacklistMode": "Blacklist mode",
"whitelistMode": "Whitelist mode", "whitelistMode": "Whitelist mode",
"filterSystemApp": "Filter system app", "filterSystemApp": "Filter system app",
@@ -120,9 +119,5 @@
"desc": "A multi-platform proxy client based on ClashMeta, simple and easy to use, open-source and ad-free.", "desc": "A multi-platform proxy client based on ClashMeta, simple and easy to use, open-source and ad-free.",
"startVpn": "Staring VPN...", "startVpn": "Staring VPN...",
"stopVpn": "Stopping VPN...", "stopVpn": "Stopping VPN...",
"discovery": "Discovery a new version", "discovery": "Discovery a new version"
"compatible": "Compatibility mode",
"compatibleDesc": "Opening it will lose part of its application ability and gain the support of full amount of Clash.",
"notSelectedTip": "The current proxy group cannot be selected.",
"tip": "tip"
} }

View File

@@ -35,7 +35,7 @@
"overrideDesc": "覆写代理相关配置", "overrideDesc": "覆写代理相关配置",
"allowLan": "局域网代理", "allowLan": "局域网代理",
"allowLanDesc": "允许通过局域网访问代理", "allowLanDesc": "允许通过局域网访问代理",
"tun": "Tun模式", "tun": "虚拟网络设备",
"tunDesc": "仅在管理员模式生效", "tunDesc": "仅在管理员模式生效",
"minimizeOnExit": "退出时最小化", "minimizeOnExit": "退出时最小化",
"minimizeOnExitDesc": "修改系统默认退出事件", "minimizeOnExitDesc": "修改系统默认退出事件",
@@ -92,7 +92,6 @@
"delaySort": "按延迟排序", "delaySort": "按延迟排序",
"nameSort": "按名称排序", "nameSort": "按名称排序",
"pleaseUploadFile": "请上传文件", "pleaseUploadFile": "请上传文件",
"pleaseUploadValidQrcode": "请上传有效的二维码",
"blacklistMode": "黑名单模式", "blacklistMode": "黑名单模式",
"whitelistMode": "白名单模式", "whitelistMode": "白名单模式",
"filterSystemApp": "过滤系统应用", "filterSystemApp": "过滤系统应用",
@@ -120,9 +119,5 @@
"desc": "基于ClashMeta的多平台代理客户端简单易用开源无广告。", "desc": "基于ClashMeta的多平台代理客户端简单易用开源无广告。",
"startVpn": "正在启动VPN...", "startVpn": "正在启动VPN...",
"stopVpn": "正在停止VPN...", "stopVpn": "正在停止VPN...",
"discovery": "发现新版本", "discovery": "发现新版本"
"compatible": "兼容模式",
"compatibleDesc": "开启将失去部分应用能力获得全量的Clash的支持",
"notSelectedTip": "当前代理组无法选中",
"tip": "提示"
} }

View File

@@ -56,10 +56,6 @@ class MessageLookup extends MessageLookupByLibrary {
"cancelSelectAll": "cancelSelectAll":
MessageLookupByLibrary.simpleMessage("Cancel select all"), MessageLookupByLibrary.simpleMessage("Cancel select all"),
"checkUpdate": MessageLookupByLibrary.simpleMessage("Check update"), "checkUpdate": MessageLookupByLibrary.simpleMessage("Check update"),
"compatible":
MessageLookupByLibrary.simpleMessage("Compatibility mode"),
"compatibleDesc": MessageLookupByLibrary.simpleMessage(
"Opening it will lose part of its application ability and gain the support of full amount of Clash."),
"confirm": MessageLookupByLibrary.simpleMessage("Confirm"), "confirm": MessageLookupByLibrary.simpleMessage("Confirm"),
"core": MessageLookupByLibrary.simpleMessage("Core"), "core": MessageLookupByLibrary.simpleMessage("Core"),
"coreInfo": MessageLookupByLibrary.simpleMessage("Core info"), "coreInfo": MessageLookupByLibrary.simpleMessage("Core info"),
@@ -116,8 +112,6 @@ class MessageLookup extends MessageLookupByLibrary {
"noProxy": MessageLookupByLibrary.simpleMessage("No proxy"), "noProxy": MessageLookupByLibrary.simpleMessage("No proxy"),
"noProxyDesc": MessageLookupByLibrary.simpleMessage( "noProxyDesc": MessageLookupByLibrary.simpleMessage(
"Please create a profile or add a valid profile"), "Please create a profile or add a valid profile"),
"notSelectedTip": MessageLookupByLibrary.simpleMessage(
"The current proxy group cannot be selected."),
"nullCoreInfoDesc": "nullCoreInfoDesc":
MessageLookupByLibrary.simpleMessage("Unable to obtain core info"), MessageLookupByLibrary.simpleMessage("Unable to obtain core info"),
"nullLogsDesc": MessageLookupByLibrary.simpleMessage("No logs"), "nullLogsDesc": MessageLookupByLibrary.simpleMessage("No logs"),
@@ -130,8 +124,6 @@ class MessageLookup extends MessageLookupByLibrary {
"Override Proxy related config"), "Override Proxy related config"),
"pleaseUploadFile": "pleaseUploadFile":
MessageLookupByLibrary.simpleMessage("Please upload file"), MessageLookupByLibrary.simpleMessage("Please upload file"),
"pleaseUploadValidQrcode": MessageLookupByLibrary.simpleMessage(
"Please upload a valid QR code"),
"port": MessageLookupByLibrary.simpleMessage("Port"), "port": MessageLookupByLibrary.simpleMessage("Port"),
"preview": MessageLookupByLibrary.simpleMessage("Preview"), "preview": MessageLookupByLibrary.simpleMessage("Preview"),
"profile": MessageLookupByLibrary.simpleMessage("Profile"), "profile": MessageLookupByLibrary.simpleMessage("Profile"),
@@ -177,10 +169,9 @@ class MessageLookup extends MessageLookupByLibrary {
"themeDesc": MessageLookupByLibrary.simpleMessage( "themeDesc": MessageLookupByLibrary.simpleMessage(
"Set dark mode,adjust the color"), "Set dark mode,adjust the color"),
"themeMode": MessageLookupByLibrary.simpleMessage("Theme mode"), "themeMode": MessageLookupByLibrary.simpleMessage("Theme mode"),
"tip": MessageLookupByLibrary.simpleMessage("tip"),
"tools": MessageLookupByLibrary.simpleMessage("Tools"), "tools": MessageLookupByLibrary.simpleMessage("Tools"),
"trafficUsage": MessageLookupByLibrary.simpleMessage("Traffic usage"), "trafficUsage": MessageLookupByLibrary.simpleMessage("Traffic usage"),
"tun": MessageLookupByLibrary.simpleMessage("Tun mode"), "tun": MessageLookupByLibrary.simpleMessage("Tun"),
"tunDesc": MessageLookupByLibrary.simpleMessage( "tunDesc": MessageLookupByLibrary.simpleMessage(
"only effective in administrator mode"), "only effective in administrator mode"),
"unableToUpdateCurrentProfileDesc": "unableToUpdateCurrentProfileDesc":

View File

@@ -49,9 +49,6 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("取消过滤系统应用"), MessageLookupByLibrary.simpleMessage("取消过滤系统应用"),
"cancelSelectAll": MessageLookupByLibrary.simpleMessage("取消全选"), "cancelSelectAll": MessageLookupByLibrary.simpleMessage("取消全选"),
"checkUpdate": MessageLookupByLibrary.simpleMessage("检查更新"), "checkUpdate": MessageLookupByLibrary.simpleMessage("检查更新"),
"compatible": MessageLookupByLibrary.simpleMessage("兼容模式"),
"compatibleDesc":
MessageLookupByLibrary.simpleMessage("开启将失去部分应用能力获得全量的Clash的支持"),
"confirm": MessageLookupByLibrary.simpleMessage("确定"), "confirm": MessageLookupByLibrary.simpleMessage("确定"),
"core": MessageLookupByLibrary.simpleMessage("内核"), "core": MessageLookupByLibrary.simpleMessage("内核"),
"coreInfo": MessageLookupByLibrary.simpleMessage("内核信息"), "coreInfo": MessageLookupByLibrary.simpleMessage("内核信息"),
@@ -100,7 +97,6 @@ class MessageLookup extends MessageLookupByLibrary {
"noProxy": MessageLookupByLibrary.simpleMessage("暂无代理"), "noProxy": MessageLookupByLibrary.simpleMessage("暂无代理"),
"noProxyDesc": "noProxyDesc":
MessageLookupByLibrary.simpleMessage("请创建配置文件或者添加有效配置文件"), MessageLookupByLibrary.simpleMessage("请创建配置文件或者添加有效配置文件"),
"notSelectedTip": MessageLookupByLibrary.simpleMessage("当前代理组无法选中"),
"nullCoreInfoDesc": MessageLookupByLibrary.simpleMessage("无法获取内核信息"), "nullCoreInfoDesc": MessageLookupByLibrary.simpleMessage("无法获取内核信息"),
"nullLogsDesc": MessageLookupByLibrary.simpleMessage("暂无日志"), "nullLogsDesc": MessageLookupByLibrary.simpleMessage("暂无日志"),
"nullProfileDesc": "nullProfileDesc":
@@ -110,8 +106,6 @@ class MessageLookup extends MessageLookupByLibrary {
"override": MessageLookupByLibrary.simpleMessage("覆写"), "override": MessageLookupByLibrary.simpleMessage("覆写"),
"overrideDesc": MessageLookupByLibrary.simpleMessage("覆写代理相关配置"), "overrideDesc": MessageLookupByLibrary.simpleMessage("覆写代理相关配置"),
"pleaseUploadFile": MessageLookupByLibrary.simpleMessage("请上传文件"), "pleaseUploadFile": MessageLookupByLibrary.simpleMessage("请上传文件"),
"pleaseUploadValidQrcode":
MessageLookupByLibrary.simpleMessage("请上传有效的二维码"),
"port": MessageLookupByLibrary.simpleMessage("端口"), "port": MessageLookupByLibrary.simpleMessage("端口"),
"preview": MessageLookupByLibrary.simpleMessage("预览"), "preview": MessageLookupByLibrary.simpleMessage("预览"),
"profile": MessageLookupByLibrary.simpleMessage("配置"), "profile": MessageLookupByLibrary.simpleMessage("配置"),
@@ -152,10 +146,9 @@ class MessageLookup extends MessageLookupByLibrary {
"themeColor": MessageLookupByLibrary.simpleMessage("主题色彩"), "themeColor": MessageLookupByLibrary.simpleMessage("主题色彩"),
"themeDesc": MessageLookupByLibrary.simpleMessage("设置深色模式,调整色彩"), "themeDesc": MessageLookupByLibrary.simpleMessage("设置深色模式,调整色彩"),
"themeMode": MessageLookupByLibrary.simpleMessage("主题模式"), "themeMode": MessageLookupByLibrary.simpleMessage("主题模式"),
"tip": MessageLookupByLibrary.simpleMessage("提示"),
"tools": MessageLookupByLibrary.simpleMessage("工具"), "tools": MessageLookupByLibrary.simpleMessage("工具"),
"trafficUsage": MessageLookupByLibrary.simpleMessage("流量统计"), "trafficUsage": MessageLookupByLibrary.simpleMessage("流量统计"),
"tun": MessageLookupByLibrary.simpleMessage("Tun模式"), "tun": MessageLookupByLibrary.simpleMessage("虚拟网络设备"),
"tunDesc": MessageLookupByLibrary.simpleMessage("仅在管理员模式生效"), "tunDesc": MessageLookupByLibrary.simpleMessage("仅在管理员模式生效"),
"unableToUpdateCurrentProfileDesc": "unableToUpdateCurrentProfileDesc":
MessageLookupByLibrary.simpleMessage("无法更新当前配置文件"), MessageLookupByLibrary.simpleMessage("无法更新当前配置文件"),

View File

@@ -410,10 +410,10 @@ class AppLocalizations {
); );
} }
/// `Tun mode` /// `Tun`
String get tun { String get tun {
return Intl.message( return Intl.message(
'Tun mode', 'Tun',
name: 'tun', name: 'tun',
desc: '', desc: '',
args: [], args: [],
@@ -980,16 +980,6 @@ class AppLocalizations {
); );
} }
/// `Please upload a valid QR code`
String get pleaseUploadValidQrcode {
return Intl.message(
'Please upload a valid QR code',
name: 'pleaseUploadValidQrcode',
desc: '',
args: [],
);
}
/// `Blacklist mode` /// `Blacklist mode`
String get blacklistMode { String get blacklistMode {
return Intl.message( return Intl.message(
@@ -1269,46 +1259,6 @@ class AppLocalizations {
args: [], args: [],
); );
} }
/// `Compatibility mode`
String get compatible {
return Intl.message(
'Compatibility mode',
name: 'compatible',
desc: '',
args: [],
);
}
/// `Opening it will lose part of its application ability and gain the support of full amount of Clash.`
String get compatibleDesc {
return Intl.message(
'Opening it will lose part of its application ability and gain the support of full amount of Clash.',
name: 'compatibleDesc',
desc: '',
args: [],
);
}
/// `The current proxy group cannot be selected.`
String get notSelectedTip {
return Intl.message(
'The current proxy group cannot be selected.',
name: 'notSelectedTip',
desc: '',
args: [],
);
}
/// `tip`
String get tip {
return Intl.message(
'tip',
name: 'tip',
desc: '',
args: [],
);
}
} }
class AppLocalizationDelegate extends LocalizationsDelegate<AppLocalizations> { class AppLocalizationDelegate extends LocalizationsDelegate<AppLocalizations> {

View File

@@ -17,11 +17,7 @@ Future<void> main() async {
await window?.init(); await window?.init();
final config = await preferences.getConfig() ?? Config(); final config = await preferences.getConfig() ?? Config();
final clashConfig = await preferences.getClashConfig() ?? ClashConfig(); final clashConfig = await preferences.getClashConfig() ?? ClashConfig();
final appState = AppState( final appState = AppState();
mode: clashConfig.mode,
isCompatible: config.isCompatible,
selectedMap: config.currentSelectedMap,
);
await globalState.init( await globalState.init(
appState: appState, appState: appState,
config: config, config: config,
@@ -45,11 +41,7 @@ Future<void> vpnService() async {
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
final config = await preferences.getConfig() ?? Config(); final config = await preferences.getConfig() ?? Config();
final clashConfig = await preferences.getClashConfig() ?? ClashConfig(); final clashConfig = await preferences.getClashConfig() ?? ClashConfig();
final appState = AppState( final appState = AppState();
mode: clashConfig.mode,
isCompatible: config.isCompatible,
selectedMap: config.currentSelectedMap,
);
clashMessage.addListener(ClashMessageListenerWithVpn(onTun: (String fd) { clashMessage.addListener(ClashMessageListenerWithVpn(onTun: (String fd) {
proxyManager.setProtect( proxyManager.setProtect(
int.parse(fd), int.parse(fd),
@@ -62,7 +54,7 @@ Future<void> vpnService() async {
); );
final appLocalizations = await AppLocalizations.load( final appLocalizations = await AppLocalizations.load(
other.getLocaleForString(config.locale) ?? Other.getLocaleForString(config.locale) ??
WidgetsBinding.instance.platformDispatcher.locale, WidgetsBinding.instance.platformDispatcher.locale,
); );

View File

@@ -5,47 +5,33 @@ import 'ffi.dart';
import 'log.dart'; import 'log.dart';
import 'navigation.dart'; import 'navigation.dart';
import 'package.dart'; import 'package.dart';
import 'profile.dart';
import 'proxy.dart'; import 'proxy.dart';
import 'system_color_scheme.dart'; import 'system_color_scheme.dart';
import 'traffic.dart'; import 'traffic.dart';
import 'version.dart'; import 'version.dart';
typedef DelayMap = Map<String, int?>;
class AppState with ChangeNotifier { class AppState with ChangeNotifier {
List<NavigationItem> _navigationItems; List<NavigationItem> _navigationItems;
int? _runTime; int? _runTime;
bool _isInit; bool _isInit;
DelayMap _delayMap;
VersionInfo? _versionInfo; VersionInfo? _versionInfo;
List<Traffic> _traffics; List<Traffic> _traffics;
List<Log> _logs; List<Log> _logs;
List<Package> _packages; List<Package> _packages;
String _currentLabel; String _currentLabel;
SystemColorSchemes _systemColorSchemes; SystemColorSchemes _systemColorSchemes;
num _sortNum;
Mode _mode;
DelayMap _delayMap;
SelectedMap _selectedMap;
bool _isCompatible;
List<Group> _groups; List<Group> _groups;
AppState({ AppState()
required Mode mode, : _navigationItems = [],
required bool isCompatible, _delayMap = {},
required SelectedMap selectedMap,
}) : _navigationItems = [],
_isInit = false, _isInit = false,
_currentLabel = "dashboard", _currentLabel = "dashboard",
_traffics = [], _traffics = [],
_logs = [], _logs = [],
_selectedMap = selectedMap,
_packages = [],
_sortNum = 0,
_mode = mode,
_delayMap = {},
_groups = [], _groups = [],
_isCompatible = isCompatible, _packages = [],
_systemColorSchemes = SystemColorSchemes(); _systemColorSchemes = SystemColorSchemes();
String get currentLabel => _currentLabel; String get currentLabel => _currentLabel;
@@ -84,38 +70,20 @@ class AppState with ChangeNotifier {
} }
} }
String getDesc(String type, String? proxyName) { DelayMap get delayMap => _delayMap;
final groupTypeNamesList = GroupType.values.map((e) => e.name).toList();
if (!groupTypeNamesList.contains(type)) { set delayMap(DelayMap value) {
return type; if (_delayMap != value) {
} else { _delayMap = value;
final index = groups.indexWhere((element) => element.name == proxyName); notifyListeners();
if (index == -1) return type;
return "$type(${groups[index].now})";
} }
} }
String? getRealProxyName(String? proxyName) { setDelay(Delay delay) {
if (proxyName == null) return null; if (_delayMap[delay.name] != delay.value) {
final index = groups.indexWhere((element) => element.name == proxyName); _delayMap = Map.from(_delayMap)..[delay.name] = delay.value;
if (index == -1) return proxyName; notifyListeners();
final group = groups[index];
return getRealProxyName(selectedMap.containsKey(proxyName)
? selectedMap[proxyName]
: group.now);
}
String? get showProxyName {
if (currentGroups.isEmpty) {
return UsedProxy.DIRECT.name;
} }
final firstGroup = currentGroups.first;
final firstGroupName = firstGroup.name;
return selectedMap[firstGroupName] ?? firstGroup.now;
}
int? getDelay(String? proxyName) {
return _delayMap[getRealProxyName(proxyName)];
} }
VersionInfo? get versionInfo => _versionInfo; VersionInfo? get versionInfo => _versionInfo;
@@ -176,101 +144,55 @@ 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; List<Group> getCurrentGroups(Mode mode) {
set sortNum(num value) {
if (_sortNum != value) {
_sortNum = value;
notifyListeners();
}
}
Mode get mode => _mode;
set mode(Mode value) {
if (_mode != value) {
_mode = value;
notifyListeners();
}
}
// String? get currentProxyName {
// if (mode == Mode.direct) return UsedProxy.DIRECT.name;
// if (_currentProxyName != null) return _currentProxyName!;
// return currentGroup?.now;
// }
//
// set currentProxyName(String? value) {
// if (_currentProxyName != value) {
// _currentProxyName = value;
// notifyListeners();
// }
// }
bool get isCompatible {
return _isCompatible;
}
set isCompatible(bool value) {
if (_isCompatible != value) {
_isCompatible = value;
notifyListeners();
}
}
SelectedMap get selectedMap {
return _selectedMap;
}
set selectedMap(SelectedMap value) {
if (!const MapEquality<String, String>().equals(_selectedMap, value)) {
_selectedMap = value;
notifyListeners();
}
}
List<Group> get currentGroups {
switch (mode) { switch (mode) {
case Mode.direct: case Mode.direct:
return []; return [];
case Mode.global: case Mode.global:
return groups return groups
.where((element) => element.name == GroupName.GLOBAL.name) .where((element) => element.name == UsedProxy.GLOBAL.name)
.toList(); .toList();
case Mode.rule: case Mode.rule:
return groups return groups
.where((element) => element.name != GroupName.GLOBAL.name) .where((element) => element.name != UsedProxy.GLOBAL.name)
.toList(); .toList();
} }
} }
DelayMap get delayMap { String? getCurrentGroupNameWithGroups(
return _delayMap; List<Group> groups,
} String? groupName,
Mode mode,
set delayMap(DelayMap value) { ) {
if (!const MapEquality<String, int?>().equals(_delayMap, value)) { switch (mode) {
_delayMap = value; case Mode.direct:
notifyListeners(); return null;
case Mode.global:
return UsedProxy.GLOBAL.name;
case Mode.rule:
return groupName ?? (groups.isNotEmpty ? groups.first.name : null);
} }
} }
setDelay(Delay delay) { String? getCurrentGroupName(String? groupName, Mode mode) {
if (_delayMap[delay.name] != delay.value) { final currentGroups = getCurrentGroups(mode);
_delayMap = Map.from(_delayMap)..[delay.name] = delay.value; return getCurrentGroupNameWithGroups(currentGroups, groupName, mode);
notifyListeners();
}
} }
Group? getGroupWithName(String groupName) { String? getCurrentProxyName(String? proxyName, Mode mode) {
final index = final currentGroups = getCurrentGroups(mode);
currentGroups.indexWhere((element) => element.name == groupName); switch (mode) {
return index != -1 ? currentGroups[index] : null; case Mode.direct:
return UsedProxy.DIRECT.name;
case Mode.global || Mode.rule:
return proxyName ??
(currentGroups.isNotEmpty ? currentGroups.first.now : null);
}
} }
} }

View File

@@ -1,28 +1,37 @@
// ignore_for_file: invalid_annotation_target
import 'package:fl_clash/common/common.dart';
import 'package:fl_clash/common/constant.dart'; import 'package:fl_clash/common/constant.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:json_annotation/json_annotation.dart';
import '../enum/enum.dart'; import '../enum/enum.dart';
part 'generated/clash_config.g.dart'; part 'generated/clash_config.g.dart';
part 'generated/clash_config.freezed.dart'; @JsonSerializable()
class Tun {
bool enable;
String device;
TunStack stack;
@JsonKey(name: "dns-hijack")
List<String> dnsHijack;
Tun() : enable = false,
stack = TunStack.gvisor,
dnsHijack = ["any:53"],
device = appConstant.name;
@freezed factory Tun.fromJson(Map<String, dynamic> json) {
class Tun with _$Tun { return _$TunFromJson(json);
const factory Tun({ }
@Default(false) bool enable,
@Default(appName) String device,
@Default(TunStack.gvisor) TunStack stack,
@JsonKey(name: "dns-hijack") @Default(["any:53"])
List<String> dnsHijack,
}) = _Tun;
factory Tun.fromJson(Map<String, Object?> json) => _$TunFromJson(json); Map<String, dynamic> toJson() {
return _$TunToJson(this);
}
// Tun copyWith({bool? enable, int? fileDescriptor}) {
// return Tun(
// enable: enable ?? this.enable,
// );
// }
} }
@JsonSerializable() @JsonSerializable()
@@ -128,7 +137,7 @@ class ClashConfig extends ChangeNotifier {
_mode = mode ?? Mode.rule, _mode = mode ?? Mode.rule,
_allowLan = allowLan ?? false, _allowLan = allowLan ?? false,
_logLevel = logLevel ?? LogLevel.info, _logLevel = logLevel ?? LogLevel.info,
_tun = tun ?? const Tun(), _tun = tun ?? Tun(),
_dns = dns ?? Dns(), _dns = dns ?? Dns(),
_rules = rules ?? []; _rules = rules ?? [];
@@ -216,4 +225,4 @@ class ClashConfig extends ChangeNotifier {
allowLan: allowLan, allowLan: allowLan,
); );
} }
} }

View File

@@ -61,7 +61,6 @@ class AccessControl {
@JsonSerializable() @JsonSerializable()
class Config extends ChangeNotifier { class Config extends ChangeNotifier {
List<Profile> _profiles; List<Profile> _profiles;
bool _isCompatible;
String? _currentProfileId; String? _currentProfileId;
bool _autoLaunch; bool _autoLaunch;
bool _silentLaunch; bool _silentLaunch;
@@ -83,7 +82,6 @@ class Config extends ChangeNotifier {
_autoRun = false, _autoRun = false,
_themeMode = ThemeMode.system, _themeMode = ThemeMode.system,
_openLog = false, _openLog = false,
_isCompatible = false,
_primaryColor = appConstant.defaultPrimaryColor.value, _primaryColor = appConstant.defaultPrimaryColor.value,
_proxiesSortType = ProxiesSortType.none, _proxiesSortType = ProxiesSortType.none,
_isMinimizeOnExit = true, _isMinimizeOnExit = true,
@@ -112,7 +110,7 @@ class Config extends ChangeNotifier {
(element) => element.label == label && element.id != id) != (element) => element.label == label && element.id != id) !=
-1; -1;
if (hasDup) { if (hasDup) {
return _getLabel(other.getOverwriteLabel(label!), id); return _getLabel(Other.getOverwriteLabel(label!), id);
} else { } else {
return label; return label;
} }
@@ -161,18 +159,9 @@ class Config extends ChangeNotifier {
} }
} }
String? get currentProxyName => currentProfile?.proxyName;
SelectedMap get currentSelectedMap { String? get currentGroupName => currentProfile?.groupName;
return currentProfile?.selectedMap ?? {};
}
updateCurrentSelectedMap(String groupName, String proxyName) {
if (currentProfile?.selectedMap[groupName] != proxyName) {
currentProfile?.selectedMap = Map.from(currentProfile?.selectedMap ?? {})
..[groupName] = proxyName;
notifyListeners();
}
}
@JsonKey(defaultValue: false) @JsonKey(defaultValue: false)
bool get autoLaunch { bool get autoLaunch {
@@ -300,18 +289,6 @@ class Config extends ChangeNotifier {
} }
} }
@JsonKey(defaultValue: false)
bool get isCompatible {
return _isCompatible;
}
set isCompatible(bool value) {
if (_isCompatible != value) {
_isCompatible = value;
notifyListeners();
}
}
update() { update() {
notifyListeners(); notifyListeners();
} }

View File

@@ -13,8 +13,7 @@ class UpdateConfigParams with _$UpdateConfigParams {
const factory UpdateConfigParams({ const factory UpdateConfigParams({
@JsonKey(name: "profile-path") String? profilePath, @JsonKey(name: "profile-path") String? profilePath,
required ClashConfig config, required ClashConfig config,
@JsonKey(name: "is-patch") required bool isPatch, @JsonKey(name: "is-patch") bool? isPatch,
@JsonKey(name: "is-compatible") required bool isCompatible,
}) = _UpdateConfigParams; }) = _UpdateConfigParams;
factory UpdateConfigParams.fromJson(Map<String, Object?> json) => factory UpdateConfigParams.fromJson(Map<String, Object?> json) =>
@@ -53,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

@@ -1,222 +0,0 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of '../clash_config.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
Tun _$TunFromJson(Map<String, dynamic> json) {
return _Tun.fromJson(json);
}
/// @nodoc
mixin _$Tun {
bool get enable => throw _privateConstructorUsedError;
String get device => throw _privateConstructorUsedError;
TunStack get stack => throw _privateConstructorUsedError;
@JsonKey(name: "dns-hijack")
List<String> get dnsHijack => throw _privateConstructorUsedError;
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$TunCopyWith<Tun> get copyWith => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $TunCopyWith<$Res> {
factory $TunCopyWith(Tun value, $Res Function(Tun) then) =
_$TunCopyWithImpl<$Res, Tun>;
@useResult
$Res call(
{bool enable,
String device,
TunStack stack,
@JsonKey(name: "dns-hijack") List<String> dnsHijack});
}
/// @nodoc
class _$TunCopyWithImpl<$Res, $Val extends Tun> implements $TunCopyWith<$Res> {
_$TunCopyWithImpl(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? enable = null,
Object? device = null,
Object? stack = null,
Object? dnsHijack = null,
}) {
return _then(_value.copyWith(
enable: null == enable
? _value.enable
: enable // ignore: cast_nullable_to_non_nullable
as bool,
device: null == device
? _value.device
: device // ignore: cast_nullable_to_non_nullable
as String,
stack: null == stack
? _value.stack
: stack // ignore: cast_nullable_to_non_nullable
as TunStack,
dnsHijack: null == dnsHijack
? _value.dnsHijack
: dnsHijack // ignore: cast_nullable_to_non_nullable
as List<String>,
) as $Val);
}
}
/// @nodoc
abstract class _$$TunImplCopyWith<$Res> implements $TunCopyWith<$Res> {
factory _$$TunImplCopyWith(_$TunImpl value, $Res Function(_$TunImpl) then) =
__$$TunImplCopyWithImpl<$Res>;
@override
@useResult
$Res call(
{bool enable,
String device,
TunStack stack,
@JsonKey(name: "dns-hijack") List<String> dnsHijack});
}
/// @nodoc
class __$$TunImplCopyWithImpl<$Res> extends _$TunCopyWithImpl<$Res, _$TunImpl>
implements _$$TunImplCopyWith<$Res> {
__$$TunImplCopyWithImpl(_$TunImpl _value, $Res Function(_$TunImpl) _then)
: super(_value, _then);
@pragma('vm:prefer-inline')
@override
$Res call({
Object? enable = null,
Object? device = null,
Object? stack = null,
Object? dnsHijack = null,
}) {
return _then(_$TunImpl(
enable: null == enable
? _value.enable
: enable // ignore: cast_nullable_to_non_nullable
as bool,
device: null == device
? _value.device
: device // ignore: cast_nullable_to_non_nullable
as String,
stack: null == stack
? _value.stack
: stack // ignore: cast_nullable_to_non_nullable
as TunStack,
dnsHijack: null == dnsHijack
? _value._dnsHijack
: dnsHijack // ignore: cast_nullable_to_non_nullable
as List<String>,
));
}
}
/// @nodoc
@JsonSerializable()
class _$TunImpl implements _Tun {
const _$TunImpl(
{this.enable = false,
this.device = appName,
this.stack = TunStack.gvisor,
@JsonKey(name: "dns-hijack")
final List<String> dnsHijack = const ["any:53"]})
: _dnsHijack = dnsHijack;
factory _$TunImpl.fromJson(Map<String, dynamic> json) =>
_$$TunImplFromJson(json);
@override
@JsonKey()
final bool enable;
@override
@JsonKey()
final String device;
@override
@JsonKey()
final TunStack stack;
final List<String> _dnsHijack;
@override
@JsonKey(name: "dns-hijack")
List<String> get dnsHijack {
if (_dnsHijack is EqualUnmodifiableListView) return _dnsHijack;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_dnsHijack);
}
@override
String toString() {
return 'Tun(enable: $enable, device: $device, stack: $stack, dnsHijack: $dnsHijack)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$TunImpl &&
(identical(other.enable, enable) || other.enable == enable) &&
(identical(other.device, device) || other.device == device) &&
(identical(other.stack, stack) || other.stack == stack) &&
const DeepCollectionEquality()
.equals(other._dnsHijack, _dnsHijack));
}
@JsonKey(ignore: true)
@override
int get hashCode => Object.hash(runtimeType, enable, device, stack,
const DeepCollectionEquality().hash(_dnsHijack));
@JsonKey(ignore: true)
@override
@pragma('vm:prefer-inline')
_$$TunImplCopyWith<_$TunImpl> get copyWith =>
__$$TunImplCopyWithImpl<_$TunImpl>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$$TunImplToJson(
this,
);
}
}
abstract class _Tun implements Tun {
const factory _Tun(
{final bool enable,
final String device,
final TunStack stack,
@JsonKey(name: "dns-hijack") final List<String> dnsHijack}) = _$TunImpl;
factory _Tun.fromJson(Map<String, dynamic> json) = _$TunImpl.fromJson;
@override
bool get enable;
@override
String get device;
@override
TunStack get stack;
@override
@JsonKey(name: "dns-hijack")
List<String> get dnsHijack;
@override
@JsonKey(ignore: true)
_$$TunImplCopyWith<_$TunImpl> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@@ -6,6 +6,26 @@ part of '../clash_config.dart';
// JsonSerializableGenerator // JsonSerializableGenerator
// ************************************************************************** // **************************************************************************
Tun _$TunFromJson(Map<String, dynamic> json) => Tun()
..enable = json['enable'] as bool
..device = json['device'] as String
..stack = $enumDecode(_$TunStackEnumMap, json['stack'])
..dnsHijack =
(json['dns-hijack'] as List<dynamic>).map((e) => e as String).toList();
Map<String, dynamic> _$TunToJson(Tun instance) => <String, dynamic>{
'enable': instance.enable,
'device': instance.device,
'stack': _$TunStackEnumMap[instance.stack]!,
'dns-hijack': instance.dnsHijack,
};
const _$TunStackEnumMap = {
TunStack.gvisor: 'gvisor',
TunStack.system: 'system',
TunStack.mixed: 'mixed',
};
Dns _$DnsFromJson(Map<String, dynamic> json) => Dns() Dns _$DnsFromJson(Map<String, dynamic> json) => Dns()
..enable = json['enable'] as bool ..enable = json['enable'] as bool
..ipv6 = json['ipv6'] as bool ..ipv6 = json['ipv6'] as bool
@@ -74,27 +94,3 @@ const _$LogLevelEnumMap = {
LogLevel.error: 'error', LogLevel.error: 'error',
LogLevel.silent: 'silent', LogLevel.silent: 'silent',
}; };
_$TunImpl _$$TunImplFromJson(Map<String, dynamic> json) => _$TunImpl(
enable: json['enable'] as bool? ?? false,
device: json['device'] as String? ?? appName,
stack: $enumDecodeNullable(_$TunStackEnumMap, json['stack']) ??
TunStack.gvisor,
dnsHijack: (json['dns-hijack'] as List<dynamic>?)
?.map((e) => e as String)
.toList() ??
const ["any:53"],
);
Map<String, dynamic> _$$TunImplToJson(_$TunImpl instance) => <String, dynamic>{
'enable': instance.enable,
'device': instance.device,
'stack': _$TunStackEnumMap[instance.stack]!,
'dns-hijack': instance.dnsHijack,
};
const _$TunStackEnumMap = {
TunStack.gvisor: 'gvisor',
TunStack.system: 'system',
TunStack.mixed: 'mixed',
};

View File

@@ -55,8 +55,7 @@ Config _$ConfigFromJson(Map<String, dynamic> json) => Config()
..isAccessControl = json['isAccessControl'] as bool? ?? false ..isAccessControl = json['isAccessControl'] as bool? ?? false
..accessControl = ..accessControl =
AccessControl.fromJson(json['accessControl'] as Map<String, dynamic>) AccessControl.fromJson(json['accessControl'] as Map<String, dynamic>)
..isAnimateToPage = json['isAnimateToPage'] as bool? ?? true ..isAnimateToPage = json['isAnimateToPage'] as bool? ?? true;
..isCompatible = json['isCompatible'] as bool? ?? false;
Map<String, dynamic> _$ConfigToJson(Config instance) => <String, dynamic>{ Map<String, dynamic> _$ConfigToJson(Config instance) => <String, dynamic>{
'profiles': instance.profiles, 'profiles': instance.profiles,
@@ -73,7 +72,6 @@ Map<String, dynamic> _$ConfigToJson(Config instance) => <String, dynamic>{
'isAccessControl': instance.isAccessControl, 'isAccessControl': instance.isAccessControl,
'accessControl': instance.accessControl, 'accessControl': instance.accessControl,
'isAnimateToPage': instance.isAnimateToPage, 'isAnimateToPage': instance.isAnimateToPage,
'isCompatible': instance.isCompatible,
}; };
const _$ThemeModeEnumMap = { const _$ThemeModeEnumMap = {

View File

@@ -24,9 +24,7 @@ mixin _$UpdateConfigParams {
String? get profilePath => throw _privateConstructorUsedError; String? get profilePath => throw _privateConstructorUsedError;
ClashConfig get config => throw _privateConstructorUsedError; ClashConfig get config => throw _privateConstructorUsedError;
@JsonKey(name: "is-patch") @JsonKey(name: "is-patch")
bool get isPatch => throw _privateConstructorUsedError; bool? get isPatch => throw _privateConstructorUsedError;
@JsonKey(name: "is-compatible")
bool get isCompatible => throw _privateConstructorUsedError;
Map<String, dynamic> toJson() => throw _privateConstructorUsedError; Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true) @JsonKey(ignore: true)
@@ -43,8 +41,7 @@ abstract class $UpdateConfigParamsCopyWith<$Res> {
$Res call( $Res call(
{@JsonKey(name: "profile-path") String? profilePath, {@JsonKey(name: "profile-path") String? profilePath,
ClashConfig config, ClashConfig config,
@JsonKey(name: "is-patch") bool isPatch, @JsonKey(name: "is-patch") bool? isPatch});
@JsonKey(name: "is-compatible") bool isCompatible});
} }
/// @nodoc /// @nodoc
@@ -62,8 +59,7 @@ class _$UpdateConfigParamsCopyWithImpl<$Res, $Val extends UpdateConfigParams>
$Res call({ $Res call({
Object? profilePath = freezed, Object? profilePath = freezed,
Object? config = null, Object? config = null,
Object? isPatch = null, Object? isPatch = freezed,
Object? isCompatible = null,
}) { }) {
return _then(_value.copyWith( return _then(_value.copyWith(
profilePath: freezed == profilePath profilePath: freezed == profilePath
@@ -74,14 +70,10 @@ class _$UpdateConfigParamsCopyWithImpl<$Res, $Val extends UpdateConfigParams>
? _value.config ? _value.config
: config // ignore: cast_nullable_to_non_nullable : config // ignore: cast_nullable_to_non_nullable
as ClashConfig, as ClashConfig,
isPatch: null == isPatch isPatch: freezed == isPatch
? _value.isPatch ? _value.isPatch
: isPatch // ignore: cast_nullable_to_non_nullable : isPatch // ignore: cast_nullable_to_non_nullable
as bool, as bool?,
isCompatible: null == isCompatible
? _value.isCompatible
: isCompatible // ignore: cast_nullable_to_non_nullable
as bool,
) as $Val); ) as $Val);
} }
} }
@@ -97,8 +89,7 @@ abstract class _$$UpdateConfigParamsImplCopyWith<$Res>
$Res call( $Res call(
{@JsonKey(name: "profile-path") String? profilePath, {@JsonKey(name: "profile-path") String? profilePath,
ClashConfig config, ClashConfig config,
@JsonKey(name: "is-patch") bool isPatch, @JsonKey(name: "is-patch") bool? isPatch});
@JsonKey(name: "is-compatible") bool isCompatible});
} }
/// @nodoc /// @nodoc
@@ -114,8 +105,7 @@ class __$$UpdateConfigParamsImplCopyWithImpl<$Res>
$Res call({ $Res call({
Object? profilePath = freezed, Object? profilePath = freezed,
Object? config = null, Object? config = null,
Object? isPatch = null, Object? isPatch = freezed,
Object? isCompatible = null,
}) { }) {
return _then(_$UpdateConfigParamsImpl( return _then(_$UpdateConfigParamsImpl(
profilePath: freezed == profilePath profilePath: freezed == profilePath
@@ -126,14 +116,10 @@ class __$$UpdateConfigParamsImplCopyWithImpl<$Res>
? _value.config ? _value.config
: config // ignore: cast_nullable_to_non_nullable : config // ignore: cast_nullable_to_non_nullable
as ClashConfig, as ClashConfig,
isPatch: null == isPatch isPatch: freezed == isPatch
? _value.isPatch ? _value.isPatch
: isPatch // ignore: cast_nullable_to_non_nullable : isPatch // ignore: cast_nullable_to_non_nullable
as bool, as bool?,
isCompatible: null == isCompatible
? _value.isCompatible
: isCompatible // ignore: cast_nullable_to_non_nullable
as bool,
)); ));
} }
} }
@@ -144,8 +130,7 @@ class _$UpdateConfigParamsImpl implements _UpdateConfigParams {
const _$UpdateConfigParamsImpl( const _$UpdateConfigParamsImpl(
{@JsonKey(name: "profile-path") this.profilePath, {@JsonKey(name: "profile-path") this.profilePath,
required this.config, required this.config,
@JsonKey(name: "is-patch") required this.isPatch, @JsonKey(name: "is-patch") this.isPatch});
@JsonKey(name: "is-compatible") required this.isCompatible});
factory _$UpdateConfigParamsImpl.fromJson(Map<String, dynamic> json) => factory _$UpdateConfigParamsImpl.fromJson(Map<String, dynamic> json) =>
_$$UpdateConfigParamsImplFromJson(json); _$$UpdateConfigParamsImplFromJson(json);
@@ -157,14 +142,11 @@ class _$UpdateConfigParamsImpl implements _UpdateConfigParams {
final ClashConfig config; final ClashConfig config;
@override @override
@JsonKey(name: "is-patch") @JsonKey(name: "is-patch")
final bool isPatch; final bool? isPatch;
@override
@JsonKey(name: "is-compatible")
final bool isCompatible;
@override @override
String toString() { String toString() {
return 'UpdateConfigParams(profilePath: $profilePath, config: $config, isPatch: $isPatch, isCompatible: $isCompatible)'; return 'UpdateConfigParams(profilePath: $profilePath, config: $config, isPatch: $isPatch)';
} }
@override @override
@@ -175,15 +157,12 @@ class _$UpdateConfigParamsImpl implements _UpdateConfigParams {
(identical(other.profilePath, profilePath) || (identical(other.profilePath, profilePath) ||
other.profilePath == profilePath) && other.profilePath == profilePath) &&
(identical(other.config, config) || other.config == config) && (identical(other.config, config) || other.config == config) &&
(identical(other.isPatch, isPatch) || other.isPatch == isPatch) && (identical(other.isPatch, isPatch) || other.isPatch == isPatch));
(identical(other.isCompatible, isCompatible) ||
other.isCompatible == isCompatible));
} }
@JsonKey(ignore: true) @JsonKey(ignore: true)
@override @override
int get hashCode => int get hashCode => Object.hash(runtimeType, profilePath, config, isPatch);
Object.hash(runtimeType, profilePath, config, isPatch, isCompatible);
@JsonKey(ignore: true) @JsonKey(ignore: true)
@override @override
@@ -204,8 +183,7 @@ abstract class _UpdateConfigParams implements UpdateConfigParams {
const factory _UpdateConfigParams( const factory _UpdateConfigParams(
{@JsonKey(name: "profile-path") final String? profilePath, {@JsonKey(name: "profile-path") final String? profilePath,
required final ClashConfig config, required final ClashConfig config,
@JsonKey(name: "is-patch") required final bool isPatch, @JsonKey(name: "is-patch") final bool? isPatch}) =
@JsonKey(name: "is-compatible") required final bool isCompatible}) =
_$UpdateConfigParamsImpl; _$UpdateConfigParamsImpl;
factory _UpdateConfigParams.fromJson(Map<String, dynamic> json) = factory _UpdateConfigParams.fromJson(Map<String, dynamic> json) =
@@ -218,10 +196,7 @@ abstract class _UpdateConfigParams implements UpdateConfigParams {
ClashConfig get config; ClashConfig get config;
@override @override
@JsonKey(name: "is-patch") @JsonKey(name: "is-patch")
bool get isPatch; bool? get isPatch;
@override
@JsonKey(name: "is-compatible")
bool get isCompatible;
@override @override
@JsonKey(ignore: true) @JsonKey(ignore: true)
_$$UpdateConfigParamsImplCopyWith<_$UpdateConfigParamsImpl> get copyWith => _$$UpdateConfigParamsImplCopyWith<_$UpdateConfigParamsImpl> get copyWith =>
@@ -697,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

@@ -11,8 +11,7 @@ _$UpdateConfigParamsImpl _$$UpdateConfigParamsImplFromJson(
_$UpdateConfigParamsImpl( _$UpdateConfigParamsImpl(
profilePath: json['profile-path'] as String?, profilePath: json['profile-path'] as String?,
config: ClashConfig.fromJson(json['config'] as Map<String, dynamic>), config: ClashConfig.fromJson(json['config'] as Map<String, dynamic>),
isPatch: json['is-patch'] as bool, isPatch: json['is-patch'] as bool?,
isCompatible: json['is-compatible'] as bool,
); );
Map<String, dynamic> _$$UpdateConfigParamsImplToJson( Map<String, dynamic> _$$UpdateConfigParamsImplToJson(
@@ -21,7 +20,6 @@ Map<String, dynamic> _$$UpdateConfigParamsImplToJson(
'profile-path': instance.profilePath, 'profile-path': instance.profilePath,
'config': instance.config, 'config': instance.config,
'is-patch': instance.isPatch, 'is-patch': instance.isPatch,
'is-compatible': instance.isCompatible,
}; };
_$ChangeProxyParamsImpl _$$ChangeProxyParamsImplFromJson( _$ChangeProxyParamsImpl _$$ChangeProxyParamsImplFromJson(
@@ -55,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(
@@ -69,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

@@ -27,13 +27,11 @@ Profile _$ProfileFromJson(Map<String, dynamic> json) => Profile(
userInfo: json['userInfo'] == null userInfo: json['userInfo'] == null
? null ? null
: UserInfo.fromJson(json['userInfo'] as Map<String, dynamic>), : UserInfo.fromJson(json['userInfo'] as Map<String, dynamic>),
groupName: json['groupName'] as String?,
proxyName: json['proxyName'] as String?, proxyName: json['proxyName'] as String?,
lastUpdateDate: json['lastUpdateDate'] == null lastUpdateDate: json['lastUpdateDate'] == null
? null ? null
: DateTime.parse(json['lastUpdateDate'] as String), : DateTime.parse(json['lastUpdateDate'] as String),
selectedMap: (json['selectedMap'] as Map<String, dynamic>?)?.map(
(k, e) => MapEntry(k, e as String),
),
autoUpdateDuration: json['autoUpdateDuration'] == null autoUpdateDuration: json['autoUpdateDuration'] == null
? null ? null
: Duration(microseconds: (json['autoUpdateDuration'] as num).toInt()), : Duration(microseconds: (json['autoUpdateDuration'] as num).toInt()),
@@ -43,11 +41,11 @@ Profile _$ProfileFromJson(Map<String, dynamic> json) => Profile(
Map<String, dynamic> _$ProfileToJson(Profile instance) => <String, dynamic>{ Map<String, dynamic> _$ProfileToJson(Profile instance) => <String, dynamic>{
'id': instance.id, 'id': instance.id,
'label': instance.label, 'label': instance.label,
'groupName': instance.groupName,
'proxyName': instance.proxyName, 'proxyName': instance.proxyName,
'url': instance.url, 'url': instance.url,
'lastUpdateDate': instance.lastUpdateDate?.toIso8601String(), 'lastUpdateDate': instance.lastUpdateDate?.toIso8601String(),
'autoUpdateDuration': instance.autoUpdateDuration.inMicroseconds, 'autoUpdateDuration': instance.autoUpdateDuration.inMicroseconds,
'userInfo': instance.userInfo, 'userInfo': instance.userInfo,
'autoUpdate': instance.autoUpdate, 'autoUpdate': instance.autoUpdate,
'selectedMap': instance.selectedMap,
}; };

View File

@@ -219,7 +219,6 @@ Proxy _$ProxyFromJson(Map<String, dynamic> json) {
mixin _$Proxy { mixin _$Proxy {
String get name => throw _privateConstructorUsedError; String get name => throw _privateConstructorUsedError;
String get type => throw _privateConstructorUsedError; String get type => throw _privateConstructorUsedError;
String? get now => throw _privateConstructorUsedError;
Map<String, dynamic> toJson() => throw _privateConstructorUsedError; Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true) @JsonKey(ignore: true)
@@ -231,7 +230,7 @@ abstract class $ProxyCopyWith<$Res> {
factory $ProxyCopyWith(Proxy value, $Res Function(Proxy) then) = factory $ProxyCopyWith(Proxy value, $Res Function(Proxy) then) =
_$ProxyCopyWithImpl<$Res, Proxy>; _$ProxyCopyWithImpl<$Res, Proxy>;
@useResult @useResult
$Res call({String name, String type, String? now}); $Res call({String name, String type});
} }
/// @nodoc /// @nodoc
@@ -249,7 +248,6 @@ class _$ProxyCopyWithImpl<$Res, $Val extends Proxy>
$Res call({ $Res call({
Object? name = null, Object? name = null,
Object? type = null, Object? type = null,
Object? now = freezed,
}) { }) {
return _then(_value.copyWith( return _then(_value.copyWith(
name: null == name name: null == name
@@ -260,10 +258,6 @@ class _$ProxyCopyWithImpl<$Res, $Val extends Proxy>
? _value.type ? _value.type
: type // ignore: cast_nullable_to_non_nullable : type // ignore: cast_nullable_to_non_nullable
as String, as String,
now: freezed == now
? _value.now
: now // ignore: cast_nullable_to_non_nullable
as String?,
) as $Val); ) as $Val);
} }
} }
@@ -275,7 +269,7 @@ abstract class _$$ProxyImplCopyWith<$Res> implements $ProxyCopyWith<$Res> {
__$$ProxyImplCopyWithImpl<$Res>; __$$ProxyImplCopyWithImpl<$Res>;
@override @override
@useResult @useResult
$Res call({String name, String type, String? now}); $Res call({String name, String type});
} }
/// @nodoc /// @nodoc
@@ -291,7 +285,6 @@ class __$$ProxyImplCopyWithImpl<$Res>
$Res call({ $Res call({
Object? name = null, Object? name = null,
Object? type = null, Object? type = null,
Object? now = freezed,
}) { }) {
return _then(_$ProxyImpl( return _then(_$ProxyImpl(
name: null == name name: null == name
@@ -302,10 +295,6 @@ class __$$ProxyImplCopyWithImpl<$Res>
? _value.type ? _value.type
: type // ignore: cast_nullable_to_non_nullable : type // ignore: cast_nullable_to_non_nullable
as String, as String,
now: freezed == now
? _value.now
: now // ignore: cast_nullable_to_non_nullable
as String?,
)); ));
} }
} }
@@ -313,21 +302,21 @@ class __$$ProxyImplCopyWithImpl<$Res>
/// @nodoc /// @nodoc
@JsonSerializable() @JsonSerializable()
class _$ProxyImpl implements _Proxy { class _$ProxyImpl implements _Proxy {
const _$ProxyImpl({required this.name, required this.type, this.now}); const _$ProxyImpl({this.name = "", this.type = ""});
factory _$ProxyImpl.fromJson(Map<String, dynamic> json) => factory _$ProxyImpl.fromJson(Map<String, dynamic> json) =>
_$$ProxyImplFromJson(json); _$$ProxyImplFromJson(json);
@override @override
@JsonKey()
final String name; final String name;
@override @override
@JsonKey()
final String type; final String type;
@override
final String? now;
@override @override
String toString() { String toString() {
return 'Proxy(name: $name, type: $type, now: $now)'; return 'Proxy(name: $name, type: $type)';
} }
@override @override
@@ -336,13 +325,12 @@ class _$ProxyImpl implements _Proxy {
(other.runtimeType == runtimeType && (other.runtimeType == runtimeType &&
other is _$ProxyImpl && other is _$ProxyImpl &&
(identical(other.name, name) || other.name == name) && (identical(other.name, name) || other.name == name) &&
(identical(other.type, type) || other.type == type) && (identical(other.type, type) || other.type == type));
(identical(other.now, now) || other.now == now));
} }
@JsonKey(ignore: true) @JsonKey(ignore: true)
@override @override
int get hashCode => Object.hash(runtimeType, name, type, now); int get hashCode => Object.hash(runtimeType, name, type);
@JsonKey(ignore: true) @JsonKey(ignore: true)
@override @override
@@ -359,10 +347,7 @@ class _$ProxyImpl implements _Proxy {
} }
abstract class _Proxy implements Proxy { abstract class _Proxy implements Proxy {
const factory _Proxy( const factory _Proxy({final String name, final String type}) = _$ProxyImpl;
{required final String name,
required final String type,
final String? now}) = _$ProxyImpl;
factory _Proxy.fromJson(Map<String, dynamic> json) = _$ProxyImpl.fromJson; factory _Proxy.fromJson(Map<String, dynamic> json) = _$ProxyImpl.fromJson;
@@ -371,8 +356,6 @@ abstract class _Proxy implements Proxy {
@override @override
String get type; String get type;
@override @override
String? get now;
@override
@JsonKey(ignore: true) @JsonKey(ignore: true)
_$$ProxyImplCopyWith<_$ProxyImpl> get copyWith => _$$ProxyImplCopyWith<_$ProxyImpl> get copyWith =>
throw _privateConstructorUsedError; throw _privateConstructorUsedError;

View File

@@ -31,14 +31,12 @@ const _$GroupTypeEnumMap = {
}; };
_$ProxyImpl _$$ProxyImplFromJson(Map<String, dynamic> json) => _$ProxyImpl( _$ProxyImpl _$$ProxyImplFromJson(Map<String, dynamic> json) => _$ProxyImpl(
name: json['name'] as String, name: json['name'] as String? ?? "",
type: json['type'] as String, type: json['type'] as String? ?? "",
now: json['now'] as String?,
); );
Map<String, dynamic> _$$ProxyImplToJson(_$ProxyImpl instance) => Map<String, dynamic> _$$ProxyImplToJson(_$ProxyImpl instance) =>
<String, dynamic>{ <String, dynamic>{
'name': instance.name, 'name': instance.name,
'type': instance.type, 'type': instance.type,
'now': instance.now,
}; };

View File

@@ -349,6 +349,7 @@ abstract class _UpdateCurrentDelaySelectorState
mixin _$NetworkDetectionSelectorState { mixin _$NetworkDetectionSelectorState {
String? get currentProxyName => throw _privateConstructorUsedError; String? get currentProxyName => throw _privateConstructorUsedError;
int? get delay => throw _privateConstructorUsedError; int? get delay => throw _privateConstructorUsedError;
bool get isInit => throw _privateConstructorUsedError;
@JsonKey(ignore: true) @JsonKey(ignore: true)
$NetworkDetectionSelectorStateCopyWith<NetworkDetectionSelectorState> $NetworkDetectionSelectorStateCopyWith<NetworkDetectionSelectorState>
@@ -363,7 +364,7 @@ abstract class $NetworkDetectionSelectorStateCopyWith<$Res> {
_$NetworkDetectionSelectorStateCopyWithImpl<$Res, _$NetworkDetectionSelectorStateCopyWithImpl<$Res,
NetworkDetectionSelectorState>; NetworkDetectionSelectorState>;
@useResult @useResult
$Res call({String? currentProxyName, int? delay}); $Res call({String? currentProxyName, int? delay, bool isInit});
} }
/// @nodoc /// @nodoc
@@ -382,6 +383,7 @@ class _$NetworkDetectionSelectorStateCopyWithImpl<$Res,
$Res call({ $Res call({
Object? currentProxyName = freezed, Object? currentProxyName = freezed,
Object? delay = freezed, Object? delay = freezed,
Object? isInit = null,
}) { }) {
return _then(_value.copyWith( return _then(_value.copyWith(
currentProxyName: freezed == currentProxyName currentProxyName: freezed == currentProxyName
@@ -392,6 +394,10 @@ class _$NetworkDetectionSelectorStateCopyWithImpl<$Res,
? _value.delay ? _value.delay
: delay // ignore: cast_nullable_to_non_nullable : delay // ignore: cast_nullable_to_non_nullable
as int?, as int?,
isInit: null == isInit
? _value.isInit
: isInit // ignore: cast_nullable_to_non_nullable
as bool,
) as $Val); ) as $Val);
} }
} }
@@ -405,7 +411,7 @@ abstract class _$$NetworkDetectionSelectorStateImplCopyWith<$Res>
__$$NetworkDetectionSelectorStateImplCopyWithImpl<$Res>; __$$NetworkDetectionSelectorStateImplCopyWithImpl<$Res>;
@override @override
@useResult @useResult
$Res call({String? currentProxyName, int? delay}); $Res call({String? currentProxyName, int? delay, bool isInit});
} }
/// @nodoc /// @nodoc
@@ -423,6 +429,7 @@ class __$$NetworkDetectionSelectorStateImplCopyWithImpl<$Res>
$Res call({ $Res call({
Object? currentProxyName = freezed, Object? currentProxyName = freezed,
Object? delay = freezed, Object? delay = freezed,
Object? isInit = null,
}) { }) {
return _then(_$NetworkDetectionSelectorStateImpl( return _then(_$NetworkDetectionSelectorStateImpl(
currentProxyName: freezed == currentProxyName currentProxyName: freezed == currentProxyName
@@ -433,6 +440,10 @@ class __$$NetworkDetectionSelectorStateImplCopyWithImpl<$Res>
? _value.delay ? _value.delay
: delay // ignore: cast_nullable_to_non_nullable : delay // ignore: cast_nullable_to_non_nullable
as int?, as int?,
isInit: null == isInit
? _value.isInit
: isInit // ignore: cast_nullable_to_non_nullable
as bool,
)); ));
} }
} }
@@ -442,16 +453,20 @@ class __$$NetworkDetectionSelectorStateImplCopyWithImpl<$Res>
class _$NetworkDetectionSelectorStateImpl class _$NetworkDetectionSelectorStateImpl
implements _NetworkDetectionSelectorState { implements _NetworkDetectionSelectorState {
const _$NetworkDetectionSelectorStateImpl( const _$NetworkDetectionSelectorStateImpl(
{required this.currentProxyName, required this.delay}); {required this.currentProxyName,
required this.delay,
required this.isInit});
@override @override
final String? currentProxyName; final String? currentProxyName;
@override @override
final int? delay; final int? delay;
@override
final bool isInit;
@override @override
String toString() { String toString() {
return 'NetworkDetectionSelectorState(currentProxyName: $currentProxyName, delay: $delay)'; return 'NetworkDetectionSelectorState(currentProxyName: $currentProxyName, delay: $delay, isInit: $isInit)';
} }
@override @override
@@ -461,11 +476,12 @@ class _$NetworkDetectionSelectorStateImpl
other is _$NetworkDetectionSelectorStateImpl && other is _$NetworkDetectionSelectorStateImpl &&
(identical(other.currentProxyName, currentProxyName) || (identical(other.currentProxyName, currentProxyName) ||
other.currentProxyName == currentProxyName) && other.currentProxyName == currentProxyName) &&
(identical(other.delay, delay) || other.delay == delay)); (identical(other.delay, delay) || other.delay == delay) &&
(identical(other.isInit, isInit) || other.isInit == isInit));
} }
@override @override
int get hashCode => Object.hash(runtimeType, currentProxyName, delay); int get hashCode => Object.hash(runtimeType, currentProxyName, delay, isInit);
@JsonKey(ignore: true) @JsonKey(ignore: true)
@override @override
@@ -480,13 +496,16 @@ abstract class _NetworkDetectionSelectorState
implements NetworkDetectionSelectorState { implements NetworkDetectionSelectorState {
const factory _NetworkDetectionSelectorState( const factory _NetworkDetectionSelectorState(
{required final String? currentProxyName, {required final String? currentProxyName,
required final int? delay}) = _$NetworkDetectionSelectorStateImpl; required final int? delay,
required final bool isInit}) = _$NetworkDetectionSelectorStateImpl;
@override @override
String? get currentProxyName; String? get currentProxyName;
@override @override
int? get delay; int? get delay;
@override @override
bool get isInit;
@override
@JsonKey(ignore: true) @JsonKey(ignore: true)
_$$NetworkDetectionSelectorStateImplCopyWith< _$$NetworkDetectionSelectorStateImplCopyWith<
_$NetworkDetectionSelectorStateImpl> _$NetworkDetectionSelectorStateImpl>
@@ -1722,133 +1741,10 @@ abstract class _HomeNavigationSelectorState
get copyWith => throw _privateConstructorUsedError; get copyWith => throw _privateConstructorUsedError;
} }
/// @nodoc
mixin _$ProxiesCardSelectorState {
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({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? isSelected = null,
}) {
return _then(_value.copyWith(
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({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? isSelected = null,
}) {
return _then(_$ProxiesCardSelectorStateImpl(
isSelected: null == isSelected
? _value.isSelected
: isSelected // ignore: cast_nullable_to_non_nullable
as bool,
));
}
}
/// @nodoc
class _$ProxiesCardSelectorStateImpl implements _ProxiesCardSelectorState {
const _$ProxiesCardSelectorStateImpl({required this.isSelected});
@override
final bool isSelected;
@override
String toString() {
return 'ProxiesCardSelectorState(isSelected: $isSelected)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$ProxiesCardSelectorStateImpl &&
(identical(other.isSelected, isSelected) ||
other.isSelected == isSelected));
}
@override
int get hashCode => Object.hash(runtimeType, 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 bool isSelected}) =
_$ProxiesCardSelectorStateImpl;
@override
bool get isSelected;
@override
@JsonKey(ignore: true)
_$$ProxiesCardSelectorStateImplCopyWith<_$ProxiesCardSelectorStateImpl>
get copyWith => throw _privateConstructorUsedError;
}
/// @nodoc /// @nodoc
mixin _$ProxiesSelectorState { mixin _$ProxiesSelectorState {
List<String> get groupNames => throw _privateConstructorUsedError; int get currentIndex => throw _privateConstructorUsedError;
List<Group> get groups => throw _privateConstructorUsedError;
@JsonKey(ignore: true) @JsonKey(ignore: true)
$ProxiesSelectorStateCopyWith<ProxiesSelectorState> get copyWith => $ProxiesSelectorStateCopyWith<ProxiesSelectorState> get copyWith =>
@@ -1861,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({List<String> groupNames}); $Res call({int currentIndex, List<Group> groups});
} }
/// @nodoc /// @nodoc
@@ -1878,13 +1774,18 @@ class _$ProxiesSelectorStateCopyWithImpl<$Res,
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
@override @override
$Res call({ $Res call({
Object? groupNames = null, Object? currentIndex = null,
Object? groups = null,
}) { }) {
return _then(_value.copyWith( return _then(_value.copyWith(
groupNames: null == groupNames currentIndex: null == currentIndex
? _value.groupNames ? _value.currentIndex
: groupNames // ignore: cast_nullable_to_non_nullable : currentIndex // ignore: cast_nullable_to_non_nullable
as List<String>, as int,
groups: null == groups
? _value.groups
: groups // ignore: cast_nullable_to_non_nullable
as List<Group>,
) as $Val); ) as $Val);
} }
} }
@@ -1897,7 +1798,7 @@ abstract class _$$ProxiesSelectorStateImplCopyWith<$Res>
__$$ProxiesSelectorStateImplCopyWithImpl<$Res>; __$$ProxiesSelectorStateImplCopyWithImpl<$Res>;
@override @override
@useResult @useResult
$Res call({List<String> groupNames}); $Res call({int currentIndex, List<Group> groups});
} }
/// @nodoc /// @nodoc
@@ -1911,13 +1812,18 @@ class __$$ProxiesSelectorStateImplCopyWithImpl<$Res>
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
@override @override
$Res call({ $Res call({
Object? groupNames = null, Object? currentIndex = null,
Object? groups = null,
}) { }) {
return _then(_$ProxiesSelectorStateImpl( return _then(_$ProxiesSelectorStateImpl(
groupNames: null == groupNames currentIndex: null == currentIndex
? _value._groupNames ? _value.currentIndex
: groupNames // ignore: cast_nullable_to_non_nullable : currentIndex // ignore: cast_nullable_to_non_nullable
as List<String>, as int,
groups: null == groups
? _value._groups
: groups // ignore: cast_nullable_to_non_nullable
as List<Group>,
)); ));
} }
} }
@@ -1925,20 +1831,23 @@ class __$$ProxiesSelectorStateImplCopyWithImpl<$Res>
/// @nodoc /// @nodoc
class _$ProxiesSelectorStateImpl implements _ProxiesSelectorState { class _$ProxiesSelectorStateImpl implements _ProxiesSelectorState {
const _$ProxiesSelectorStateImpl({required final List<String> groupNames}) const _$ProxiesSelectorStateImpl(
: _groupNames = groupNames; {required this.currentIndex, required final List<Group> groups})
: _groups = groups;
final List<String> _groupNames;
@override @override
List<String> get groupNames { final int currentIndex;
if (_groupNames is EqualUnmodifiableListView) return _groupNames; final List<Group> _groups;
@override
List<Group> get groups {
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(groupNames: $groupNames)'; return 'ProxiesSelectorState(currentIndex: $currentIndex, groups: $groups)';
} }
@override @override
@@ -1946,13 +1855,14 @@ class _$ProxiesSelectorStateImpl implements _ProxiesSelectorState {
return identical(this, other) || return identical(this, other) ||
(other.runtimeType == runtimeType && (other.runtimeType == runtimeType &&
other is _$ProxiesSelectorStateImpl && other is _$ProxiesSelectorStateImpl &&
const DeepCollectionEquality() (identical(other.currentIndex, currentIndex) ||
.equals(other._groupNames, _groupNames)); other.currentIndex == currentIndex) &&
const DeepCollectionEquality().equals(other._groups, _groups));
} }
@override @override
int get hashCode => Object.hash( int get hashCode => Object.hash(
runtimeType, const DeepCollectionEquality().hash(_groupNames)); runtimeType, currentIndex, const DeepCollectionEquality().hash(_groups));
@JsonKey(ignore: true) @JsonKey(ignore: true)
@override @override
@@ -1965,10 +1875,13 @@ class _$ProxiesSelectorStateImpl implements _ProxiesSelectorState {
abstract class _ProxiesSelectorState implements ProxiesSelectorState { abstract class _ProxiesSelectorState implements ProxiesSelectorState {
const factory _ProxiesSelectorState( const factory _ProxiesSelectorState(
{required final List<String> groupNames}) = _$ProxiesSelectorStateImpl; {required final int currentIndex,
required final List<Group> groups}) = _$ProxiesSelectorStateImpl;
@override @override
List<String> get groupNames; int get currentIndex;
@override
List<Group> get groups;
@override @override
@JsonKey(ignore: true) @JsonKey(ignore: true)
_$$ProxiesSelectorStateImplCopyWith<_$ProxiesSelectorStateImpl> _$$ProxiesSelectorStateImplCopyWith<_$ProxiesSelectorStateImpl>
@@ -1976,34 +1889,29 @@ abstract class _ProxiesSelectorState implements ProxiesSelectorState {
} }
/// @nodoc /// @nodoc
mixin _$ProxiesTabViewSelectorState { mixin _$ProxiesCardSelectorState {
ProxiesSortType get proxiesSortType => throw _privateConstructorUsedError; String? get currentGroupName => throw _privateConstructorUsedError;
num get sortNum => throw _privateConstructorUsedError; String? get currentProxyName => throw _privateConstructorUsedError;
Group get group => throw _privateConstructorUsedError;
@JsonKey(ignore: true) @JsonKey(ignore: true)
$ProxiesTabViewSelectorStateCopyWith<ProxiesTabViewSelectorState> $ProxiesCardSelectorStateCopyWith<ProxiesCardSelectorState> get copyWith =>
get copyWith => throw _privateConstructorUsedError; throw _privateConstructorUsedError;
} }
/// @nodoc /// @nodoc
abstract class $ProxiesTabViewSelectorStateCopyWith<$Res> { abstract class $ProxiesCardSelectorStateCopyWith<$Res> {
factory $ProxiesTabViewSelectorStateCopyWith( factory $ProxiesCardSelectorStateCopyWith(ProxiesCardSelectorState value,
ProxiesTabViewSelectorState value, $Res Function(ProxiesCardSelectorState) then) =
$Res Function(ProxiesTabViewSelectorState) then) = _$ProxiesCardSelectorStateCopyWithImpl<$Res, ProxiesCardSelectorState>;
_$ProxiesTabViewSelectorStateCopyWithImpl<$Res,
ProxiesTabViewSelectorState>;
@useResult @useResult
$Res call({ProxiesSortType proxiesSortType, num sortNum, Group group}); $Res call({String? currentGroupName, String? currentProxyName});
$GroupCopyWith<$Res> get group;
} }
/// @nodoc /// @nodoc
class _$ProxiesTabViewSelectorStateCopyWithImpl<$Res, class _$ProxiesCardSelectorStateCopyWithImpl<$Res,
$Val extends ProxiesTabViewSelectorState> $Val extends ProxiesCardSelectorState>
implements $ProxiesTabViewSelectorStateCopyWith<$Res> { implements $ProxiesCardSelectorStateCopyWith<$Res> {
_$ProxiesTabViewSelectorStateCopyWithImpl(this._value, this._then); _$ProxiesCardSelectorStateCopyWithImpl(this._value, this._then);
// ignore: unused_field // ignore: unused_field
final $Val _value; final $Val _value;
@@ -2013,142 +1921,114 @@ class _$ProxiesTabViewSelectorStateCopyWithImpl<$Res,
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
@override @override
$Res call({ $Res call({
Object? proxiesSortType = null, Object? currentGroupName = freezed,
Object? sortNum = null, Object? currentProxyName = freezed,
Object? group = null,
}) { }) {
return _then(_value.copyWith( return _then(_value.copyWith(
proxiesSortType: null == proxiesSortType currentGroupName: freezed == currentGroupName
? _value.proxiesSortType ? _value.currentGroupName
: proxiesSortType // ignore: cast_nullable_to_non_nullable : currentGroupName // ignore: cast_nullable_to_non_nullable
as ProxiesSortType, as String?,
sortNum: null == sortNum currentProxyName: freezed == currentProxyName
? _value.sortNum ? _value.currentProxyName
: sortNum // ignore: cast_nullable_to_non_nullable : currentProxyName // ignore: cast_nullable_to_non_nullable
as num, as String?,
group: null == group
? _value.group
: group // ignore: cast_nullable_to_non_nullable
as Group,
) as $Val); ) 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 /// @nodoc
abstract class _$$ProxiesTabViewSelectorStateImplCopyWith<$Res> abstract class _$$ProxiesCardSelectorStateImplCopyWith<$Res>
implements $ProxiesTabViewSelectorStateCopyWith<$Res> { implements $ProxiesCardSelectorStateCopyWith<$Res> {
factory _$$ProxiesTabViewSelectorStateImplCopyWith( factory _$$ProxiesCardSelectorStateImplCopyWith(
_$ProxiesTabViewSelectorStateImpl value, _$ProxiesCardSelectorStateImpl value,
$Res Function(_$ProxiesTabViewSelectorStateImpl) then) = $Res Function(_$ProxiesCardSelectorStateImpl) then) =
__$$ProxiesTabViewSelectorStateImplCopyWithImpl<$Res>; __$$ProxiesCardSelectorStateImplCopyWithImpl<$Res>;
@override @override
@useResult @useResult
$Res call({ProxiesSortType proxiesSortType, num sortNum, Group group}); $Res call({String? currentGroupName, String? currentProxyName});
@override
$GroupCopyWith<$Res> get group;
} }
/// @nodoc /// @nodoc
class __$$ProxiesTabViewSelectorStateImplCopyWithImpl<$Res> class __$$ProxiesCardSelectorStateImplCopyWithImpl<$Res>
extends _$ProxiesTabViewSelectorStateCopyWithImpl<$Res, extends _$ProxiesCardSelectorStateCopyWithImpl<$Res,
_$ProxiesTabViewSelectorStateImpl> _$ProxiesCardSelectorStateImpl>
implements _$$ProxiesTabViewSelectorStateImplCopyWith<$Res> { implements _$$ProxiesCardSelectorStateImplCopyWith<$Res> {
__$$ProxiesTabViewSelectorStateImplCopyWithImpl( __$$ProxiesCardSelectorStateImplCopyWithImpl(
_$ProxiesTabViewSelectorStateImpl _value, _$ProxiesCardSelectorStateImpl _value,
$Res Function(_$ProxiesTabViewSelectorStateImpl) _then) $Res Function(_$ProxiesCardSelectorStateImpl) _then)
: super(_value, _then); : super(_value, _then);
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
@override @override
$Res call({ $Res call({
Object? proxiesSortType = null, Object? currentGroupName = freezed,
Object? sortNum = null, Object? currentProxyName = freezed,
Object? group = null,
}) { }) {
return _then(_$ProxiesTabViewSelectorStateImpl( return _then(_$ProxiesCardSelectorStateImpl(
proxiesSortType: null == proxiesSortType currentGroupName: freezed == currentGroupName
? _value.proxiesSortType ? _value.currentGroupName
: proxiesSortType // ignore: cast_nullable_to_non_nullable : currentGroupName // ignore: cast_nullable_to_non_nullable
as ProxiesSortType, as String?,
sortNum: null == sortNum currentProxyName: freezed == currentProxyName
? _value.sortNum ? _value.currentProxyName
: sortNum // ignore: cast_nullable_to_non_nullable : currentProxyName // ignore: cast_nullable_to_non_nullable
as num, as String?,
group: null == group
? _value.group
: group // ignore: cast_nullable_to_non_nullable
as Group,
)); ));
} }
} }
/// @nodoc /// @nodoc
class _$ProxiesTabViewSelectorStateImpl class _$ProxiesCardSelectorStateImpl implements _ProxiesCardSelectorState {
implements _ProxiesTabViewSelectorState { const _$ProxiesCardSelectorStateImpl(
const _$ProxiesTabViewSelectorStateImpl( {required this.currentGroupName, required this.currentProxyName});
{required this.proxiesSortType,
required this.sortNum,
required this.group});
@override @override
final ProxiesSortType proxiesSortType; final String? currentGroupName;
@override @override
final num sortNum; final String? currentProxyName;
@override
final Group group;
@override @override
String toString() { String toString() {
return 'ProxiesTabViewSelectorState(proxiesSortType: $proxiesSortType, sortNum: $sortNum, group: $group)'; return 'ProxiesCardSelectorState(currentGroupName: $currentGroupName, currentProxyName: $currentProxyName)';
} }
@override @override
bool operator ==(Object other) { bool operator ==(Object other) {
return identical(this, other) || return identical(this, other) ||
(other.runtimeType == runtimeType && (other.runtimeType == runtimeType &&
other is _$ProxiesTabViewSelectorStateImpl && other is _$ProxiesCardSelectorStateImpl &&
(identical(other.proxiesSortType, proxiesSortType) || (identical(other.currentGroupName, currentGroupName) ||
other.proxiesSortType == proxiesSortType) && other.currentGroupName == currentGroupName) &&
(identical(other.sortNum, sortNum) || other.sortNum == sortNum) && (identical(other.currentProxyName, currentProxyName) ||
(identical(other.group, group) || other.group == group)); other.currentProxyName == currentProxyName));
} }
@override @override
int get hashCode => Object.hash(runtimeType, proxiesSortType, sortNum, group); int get hashCode =>
Object.hash(runtimeType, currentGroupName, currentProxyName);
@JsonKey(ignore: true) @JsonKey(ignore: true)
@override @override
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
_$$ProxiesTabViewSelectorStateImplCopyWith<_$ProxiesTabViewSelectorStateImpl> _$$ProxiesCardSelectorStateImplCopyWith<_$ProxiesCardSelectorStateImpl>
get copyWith => __$$ProxiesTabViewSelectorStateImplCopyWithImpl< get copyWith => __$$ProxiesCardSelectorStateImplCopyWithImpl<
_$ProxiesTabViewSelectorStateImpl>(this, _$identity); _$ProxiesCardSelectorStateImpl>(this, _$identity);
} }
abstract class _ProxiesTabViewSelectorState abstract class _ProxiesCardSelectorState implements ProxiesCardSelectorState {
implements ProxiesTabViewSelectorState { const factory _ProxiesCardSelectorState(
const factory _ProxiesTabViewSelectorState( {required final String? currentGroupName,
{required final ProxiesSortType proxiesSortType, required final String? currentProxyName}) =
required final num sortNum, _$ProxiesCardSelectorStateImpl;
required final Group group}) = _$ProxiesTabViewSelectorStateImpl;
@override @override
ProxiesSortType get proxiesSortType; String? get currentGroupName;
@override @override
num get sortNum; String? get currentProxyName;
@override
Group get group;
@override @override
@JsonKey(ignore: true) @JsonKey(ignore: true)
_$$ProxiesTabViewSelectorStateImplCopyWith<_$ProxiesTabViewSelectorStateImpl> _$$ProxiesCardSelectorStateImplCopyWith<_$ProxiesCardSelectorStateImpl>
get copyWith => throw _privateConstructorUsedError; get copyWith => throw _privateConstructorUsedError;
} }

View File

@@ -12,8 +12,6 @@ import 'common.dart';
part 'generated/profile.g.dart'; part 'generated/profile.g.dart';
typedef SelectedMap = Map<String, String>;
@JsonSerializable() @JsonSerializable()
class UserInfo { class UserInfo {
int upload; int upload;
@@ -64,28 +62,27 @@ class UserInfo {
class Profile { class Profile {
String id; String id;
String? label; String? label;
String? groupName;
String? proxyName; String? proxyName;
String? url; String? url;
DateTime? lastUpdateDate; DateTime? lastUpdateDate;
Duration autoUpdateDuration; Duration autoUpdateDuration;
UserInfo? userInfo; UserInfo? userInfo;
bool autoUpdate; bool autoUpdate;
SelectedMap selectedMap;
Profile({ Profile({
String? id, String? id,
this.label, this.label,
this.url, this.url,
this.userInfo, this.userInfo,
this.groupName,
this.proxyName, this.proxyName,
this.lastUpdateDate, this.lastUpdateDate,
SelectedMap? selectedMap,
Duration? autoUpdateDuration, Duration? autoUpdateDuration,
this.autoUpdate = true, this.autoUpdate = true,
}) : id = id ?? DateTime.now().millisecondsSinceEpoch.toString(), }) : id = id ?? DateTime.now().millisecondsSinceEpoch.toString(),
autoUpdateDuration = autoUpdateDuration =
autoUpdateDuration ?? appConstant.defaultUpdateDuration, autoUpdateDuration ?? appConstant.defaultUpdateDuration;
selectedMap = selectedMap ?? {};
ProfileType get type => url == null ? ProfileType.file : ProfileType.url; ProfileType get type => url == null ? ProfileType.file : ProfileType.url;
@@ -161,6 +158,7 @@ class Profile {
runtimeType == other.runtimeType && runtimeType == other.runtimeType &&
id == other.id && id == other.id &&
label == other.label && label == other.label &&
groupName == other.groupName &&
proxyName == other.proxyName && proxyName == other.proxyName &&
url == other.url && url == other.url &&
lastUpdateDate == other.lastUpdateDate && lastUpdateDate == other.lastUpdateDate &&
@@ -172,6 +170,7 @@ class Profile {
int get hashCode => int get hashCode =>
id.hashCode ^ id.hashCode ^
label.hashCode ^ label.hashCode ^
groupName.hashCode ^
proxyName.hashCode ^ proxyName.hashCode ^
url.hashCode ^ url.hashCode ^
lastUpdateDate.hashCode ^ lastUpdateDate.hashCode ^
@@ -181,7 +180,7 @@ class Profile {
@override @override
String toString() { String toString() {
return 'Profile{id: $id, label: $label, proxyName: $proxyName, url: $url, lastUpdateDate: $lastUpdateDate, autoUpdateDuration: $autoUpdateDuration, userInfo: $userInfo, autoUpdate: $autoUpdate}'; return 'Profile{id: $id, label: $label, groupName: $groupName, proxyName: $proxyName, url: $url, lastUpdateDate: $lastUpdateDate, autoUpdateDuration: $autoUpdateDuration, userInfo: $userInfo, autoUpdate: $autoUpdate}';
} }
Profile copyWith({ Profile copyWith({
@@ -193,15 +192,14 @@ class Profile {
DateTime? lastUpdateDate, DateTime? lastUpdateDate,
Duration? autoUpdateDuration, Duration? autoUpdateDuration,
bool? autoUpdate, bool? autoUpdate,
SelectedMap? selectedMap,
}) { }) {
return Profile( return Profile(
id: id, id: id,
label: label ?? this.label, label: label ?? this.label,
url: url ?? this.url, url: url ?? this.url,
groupName: groupName ?? this.groupName,
proxyName: proxyName ?? this.proxyName, proxyName: proxyName ?? this.proxyName,
userInfo: userInfo ?? this.userInfo, userInfo: userInfo ?? this.userInfo,
selectedMap: selectedMap ?? this.selectedMap,
lastUpdateDate: lastUpdateDate ?? this.lastUpdateDate, lastUpdateDate: lastUpdateDate ?? this.lastUpdateDate,
autoUpdateDuration: autoUpdateDuration ?? this.autoUpdateDuration, autoUpdateDuration: autoUpdateDuration ?? this.autoUpdateDuration,
autoUpdate: autoUpdate ?? this.autoUpdate, autoUpdate: autoUpdate ?? this.autoUpdate,

View File

@@ -6,7 +6,7 @@ part 'generated/proxy.g.dart';
part 'generated/proxy.freezed.dart'; part 'generated/proxy.freezed.dart';
typedef ProxyMap = Map<String, Proxy>; typedef DelayMap = Map<String, int?>;
@freezed @freezed
class Group with _$Group { class Group with _$Group {
@@ -23,9 +23,8 @@ class Group with _$Group {
@freezed @freezed
class Proxy with _$Proxy { class Proxy with _$Proxy {
const factory Proxy({ const factory Proxy({
required String name, @Default("") String name,
required String type, @Default("") String type,
String? now,
}) = _Proxy; }) = _Proxy;
factory Proxy.fromJson(Map<String, Object?> json) => _$ProxyFromJson(json); factory Proxy.fromJson(Map<String, Object?> json) => _$ProxyFromJson(json);

View File

@@ -32,6 +32,7 @@ class NetworkDetectionSelectorState with _$NetworkDetectionSelectorState {
const factory NetworkDetectionSelectorState({ const factory NetworkDetectionSelectorState({
required String? currentProxyName, required String? currentProxyName,
required int? delay, required int? delay,
required bool isInit,
}) = _NetworkDetectionSelectorState; }) = _NetworkDetectionSelectorState;
} }
@@ -102,25 +103,18 @@ class HomeNavigationSelectorState with _$HomeNavigationSelectorState{
}) = _HomeNavigationSelectorState; }) = _HomeNavigationSelectorState;
} }
@freezed
class ProxiesCardSelectorState with _$ProxiesCardSelectorState{
const factory ProxiesCardSelectorState({
required bool isSelected,
}) = _ProxiesCardSelectorState;
}
@freezed @freezed
class ProxiesSelectorState with _$ProxiesSelectorState{ class ProxiesSelectorState with _$ProxiesSelectorState{
const factory ProxiesSelectorState({ const factory ProxiesSelectorState({
required List<String> groupNames, required int currentIndex,
required List<Group> groups,
}) = _ProxiesSelectorState; }) = _ProxiesSelectorState;
} }
@freezed @freezed
class ProxiesTabViewSelectorState with _$ProxiesTabViewSelectorState{ class ProxiesCardSelectorState with _$ProxiesCardSelectorState{
const factory ProxiesTabViewSelectorState({ const factory ProxiesCardSelectorState({
required ProxiesSortType proxiesSortType, required String? currentGroupName,
required num sortNum, required String? currentProxyName,
required Group group, }) = _ProxiesCardSelectorState;
}) = _ProxiesTabViewSelectorState;
} }

View File

@@ -1,3 +1,4 @@
import 'package:fl_clash/common/common.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/state.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@@ -27,7 +28,7 @@ class HomePage extends StatelessWidget {
builder: (context, currentIndex, __) { builder: (context, currentIndex, __) {
if (globalState.pageController != null) { if (globalState.pageController != null) {
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
globalState.appController.toPage(currentIndex, hasAnimate: true); context.appController.toPage(currentIndex, hasAnimate: true);
}); });
} else { } else {
globalState.pageController = PageController( globalState.pageController = PageController(
@@ -66,7 +67,7 @@ class HomePage extends StatelessWidget {
}, },
builder: (context, state, __) { builder: (context, state, __) {
return AdaptiveScaffold.standardNavigationRail( return AdaptiveScaffold.standardNavigationRail(
onDestinationSelected: globalState.appController.toPage, onDestinationSelected: context.appController.toPage,
destinations: navigationItems destinations: navigationItems
.map( .map(
(e) => NavigationRailDestination( (e) => NavigationRailDestination(
@@ -112,7 +113,7 @@ class HomePage extends StatelessWidget {
.toList(); .toList();
return AdaptiveScaffold.standardBottomNavigationBar( return AdaptiveScaffold.standardBottomNavigationBar(
destinations: mobileDestinations, destinations: mobileDestinations,
onDestinationSelected: globalState.appController.toPage, onDestinationSelected: context.appController.toPage,
currentIndex: state.currentIndex, currentIndex: state.currentIndex,
); );
}, },

View File

@@ -1,6 +1,5 @@
import 'dart:async'; import 'dart:async';
import 'dart:math'; import 'dart:math';
import 'package:fl_clash/state.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:mobile_scanner/mobile_scanner.dart'; import 'package:mobile_scanner/mobile_scanner.dart';
@@ -91,12 +90,6 @@ class _ScanPageState extends State<ScanPage> with WidgetsBindingObserver {
}, },
icon: const Icon(Icons.close), icon: const Icon(Icons.close),
), ),
actions: [
IconButton(
onPressed: globalState.appController.addProfileFormQrCode,
icon: const Icon(Icons.add_photo_alternate_outlined),
)
],
), ),
Container( Container(
margin: const EdgeInsets.only(bottom: 32), margin: const EdgeInsets.only(bottom: 32),
@@ -122,7 +115,7 @@ class _ScanPageState extends State<ScanPage> with WidgetsBindingObserver {
icon: icon, icon: icon,
style: ButtonStyle( style: ButtonStyle(
foregroundColor: foregroundColor:
const MaterialStatePropertyAll(Colors.white), const MaterialStatePropertyAll(Colors.white),
backgroundColor: MaterialStatePropertyAll(backgroundColor), backgroundColor: MaterialStatePropertyAll(backgroundColor),
), ),
padding: const EdgeInsets.all(16), padding: const EdgeInsets.all(16),
@@ -204,4 +197,4 @@ class ScannerOverlay extends CustomPainter {
return scanWindow != oldDelegate.scanWindow || return scanWindow != oldDelegate.scanWindow ||
borderRadius != oldDelegate.borderRadius; borderRadius != oldDelegate.borderRadius;
} }
} }

View File

@@ -9,24 +9,20 @@ 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';
import 'controller.dart';
import 'models/models.dart'; import 'models/models.dart';
import 'common/common.dart'; import 'common/common.dart';
class GlobalState { class GlobalState {
Timer? timer; Timer? timer;
Function? healthcheckLockDebounce; Timer? currentDelayTimer;
Timer? groupsUpdateTimer;
Function? updateCurrentDelayDebounce; Function? updateCurrentDelayDebounce;
PageController? pageController; PageController? pageController;
final navigatorKey = GlobalKey<NavigatorState>(); final navigatorKey = GlobalKey<NavigatorState>();
final Map<int, String?> packageNameMap = {}; final Map<int, String?> packageNameMap = {};
late AppController appController;
GlobalKey<CommonScaffoldState> homeScaffoldKey = GlobalKey(); GlobalKey<CommonScaffoldState> homeScaffoldKey = GlobalKey();
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;
@@ -53,7 +49,6 @@ class GlobalState {
profilePath: profilePath, profilePath: profilePath,
config: clashConfig, config: clashConfig,
isPatch: isPatch, isPatch: isPatch,
isCompatible: config.isCompatible,
)); ));
} }
@@ -79,6 +74,19 @@ class GlobalState {
stopListenUpdate(); stopListenUpdate();
} }
void updateCurrentDelay(
String? proxyName,
) {
updateCurrentDelayDebounce ??= debounce<Function(String?)>((proxyName) {
if (proxyName != null) {
clashCore.delay(
proxyName,
);
}
});
updateCurrentDelayDebounce!([proxyName]);
}
applyProfile({ applyProfile({
required AppState appState, required AppState appState,
required Config config, required Config config,
@@ -124,20 +132,29 @@ class GlobalState {
required Config config, required Config config,
required ClashConfig clashConfig, required ClashConfig clashConfig,
}) { }) {
WidgetsBinding.instance.addPostFrameCallback((_) { final currentGroupName =
if (config.profiles.isEmpty) { appState.getCurrentGroupName(config.currentGroupName, clashConfig.mode);
stopSystemProxy(); final currentProxyName =
return; appState.getCurrentProxyName(config.currentProxyName, clashConfig.mode);
} if (config.profiles.isEmpty || currentProxyName == null) {
config.currentSelectedMap.forEach((key, value) { stopSystemProxy();
clashCore.changeProxy( return;
ChangeProxyParams( }
groupName: key, if (currentGroupName == null) return;
proxyName: value, final groupIndex = appState.groups.indexWhere(
), (element) => element.name == currentGroupName,
); );
}); if (groupIndex == -1) return;
}); final proxyIndex = appState.groups[groupIndex].all.indexWhere(
(element) => element.name == currentProxyName,
);
if (proxyIndex == -1) return;
clashCore.changeProxy(
ChangeProxyParams(
groupName: currentGroupName,
proxyName: currentProxyName,
),
);
} }
updatePackages(AppState appState) async { updatePackages(AppState appState) async {
@@ -153,11 +170,11 @@ class GlobalState {
required Config config, required Config config,
required ClashConfig clashConfig, required ClashConfig clashConfig,
}) { }) {
final group = appState.currentGroups; final hasGroups = appState.getCurrentGroups(clashConfig.mode).isNotEmpty;
final hasProfile = config.profiles.isNotEmpty; final hasProfile = config.profiles.isNotEmpty;
appState.navigationItems = navigation.getItems( appState.navigationItems = navigation.getItems(
openLogs: config.openLogs, openLogs: config.openLogs,
hasProxies: group.isNotEmpty && hasProfile, hasProxies: hasGroups && hasProfile,
); );
} }
@@ -241,52 +258,6 @@ class GlobalState {
); );
} }
} }
showSnackBar(
BuildContext context, {
required String message,
SnackBarAction? action,
}) {
final width = context.width;
EdgeInsets margin;
if (width < 600) {
margin = const EdgeInsets.only(
bottom: 96,
right: 16,
left: 16,
);
} else {
margin = EdgeInsets.only(
bottom: 16,
left: 16,
right: width - 316,
);
}
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
action: action,
content: Text(message),
behavior: SnackBarBehavior.floating,
duration: const Duration(milliseconds: 1500),
margin: margin,
),
);
}
void updateCurrentDelay(
String? proxyName,
) {
updateCurrentDelayDebounce ??= debounce<Function(String?)>((proxyName) {
if (proxyName != null) {
debugPrint("[delay]=====> $proxyName");
clashCore.delay(
proxyName,
);
}
});
updateCurrentDelayDebounce!([proxyName]);
}
} }
final globalState = GlobalState(); final globalState = GlobalState();

View File

@@ -1,4 +1,4 @@
import 'package:fl_clash/state.dart'; import 'package:fl_clash/common/common.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
@@ -27,7 +27,7 @@ class _AndroidContainerState extends State<AndroidContainer>
Future<void> didChangeAppLifecycleState(AppLifecycleState state) async { Future<void> didChangeAppLifecycleState(AppLifecycleState state) async {
final isPaused = state == AppLifecycleState.paused; final isPaused = state == AppLifecycleState.paused;
if (isPaused) { if (isPaused) {
await globalState.appController.savePreferences(); await context.appController.savePreferences();
} }
} }

View File

@@ -1,6 +1,5 @@
import 'package:fl_clash/common/common.dart'; import 'package:fl_clash/common/common.dart';
import 'package:fl_clash/models/models.dart'; import 'package:fl_clash/models/models.dart';
import 'package:fl_clash/state.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
@@ -24,19 +23,20 @@ class AppStateContainer extends StatelessWidget {
} }
_updateNavigationsContainer(Widget child) { _updateNavigationsContainer(Widget child) {
return Selector2<AppState, Config, UpdateNavigationsSelector>( return Selector3<AppState, Config, ClashConfig, UpdateNavigationsSelector>(
selector: (_, appState, config) { selector: (_, appState, config, clashConfig) {
final group = appState.currentGroups; final hasGroups =
appState.getCurrentGroups(clashConfig.mode).isNotEmpty;
final hasProfile = config.profiles.isNotEmpty; final hasProfile = config.profiles.isNotEmpty;
return UpdateNavigationsSelector( return UpdateNavigationsSelector(
openLogs: config.openLogs, openLogs: config.openLogs,
hasProxies: group.isNotEmpty && hasProfile, hasProxies: hasGroups && hasProfile,
); );
}, },
builder: (context, state, child) { builder: (context, state, child) {
WidgetsBinding.instance.addPostFrameCallback( WidgetsBinding.instance.addPostFrameCallback(
(_) { (_) {
globalState.appController.appState.navigationItems = context.appController.appState.navigationItems =
navigation.getItems( navigation.getItems(
openLogs: state.openLogs, openLogs: state.openLogs,
hasProxies: state.hasProxies, hasProxies: state.hasProxies,

View File

@@ -38,22 +38,14 @@ class _ClashMessageContainerState extends State<ClashMessageContainer>
@override @override
void onDelay(Delay delay) { void onDelay(Delay delay) {
globalState.healthcheckLock = true; context.appController.setDelay(delay);
final appController = globalState.appController;
appController.setDelay(delay);
globalState.healthcheckLockDebounce ??= debounce<Function()>(
() async {
globalState.healthcheckLock = false;
},
milliseconds: 5000,
);
globalState.healthcheckLockDebounce!();
super.onDelay(delay); super.onDelay(delay);
} }
@override @override
void onLog(Log log) { void onLog(Log log) {
globalState.appController.appState.addLog(log); debugPrint("$log");
context.appController.appState.addLog(log);
super.onLog(log); super.onLog(log);
} }

View File

@@ -1,4 +1,4 @@
import 'package:fl_clash/state.dart'; import 'package:fl_clash/common/common.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'card.dart'; import 'card.dart';
import 'grid.dart'; import 'grid.dart';
@@ -25,7 +25,7 @@ class ColorSchemeBox extends StatelessWidget {
); );
} else { } else {
return Theme.of(context).copyWith( return Theme.of(context).copyWith(
colorScheme: globalState.appController.appState.systemColorSchemes colorScheme: context.appController.appState.systemColorSchemes
.getSystemColorSchemeForBrightness(Theme.of(context).brightness), .getSystemColorSchemeForBrightness(Theme.of(context).brightness),
); );
} }

View File

@@ -16,6 +16,28 @@ showExtendPage(
key: globalKey, key: globalKey,
child: body, child: body,
); );
// Flexible(
// flex: 0,
// child: Row(
// children: [
// Expanded(
// child: Padding(
// padding: kTabLabelPadding,
// child: Text(
// title,
// style: Theme.of(context).textTheme.titleMedium,
// ),
// ),
// ),
// const SizedBox(
// height: kToolbarHeight,
// width: kToolbarHeight,
// child: CloseButton(),
// ),
// ],
// ),
// )
navigator.push( navigator.push(
ModalSideSheetRoute( ModalSideSheetRoute(
modalBarrierColor: Colors.black38, modalBarrierColor: Colors.black38,

View File

@@ -1,7 +1,7 @@
import 'dart:io'; import 'dart:io';
import 'package:fl_clash/state.dart'; import 'package:fl_clash/common/common.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
class PopContainer extends StatefulWidget { class PopContainer extends StatefulWidget {
@@ -24,7 +24,7 @@ class _PopContainerState extends State<PopContainer> {
if (canPop) { if (canPop) {
Navigator.pop(context); Navigator.pop(context);
} else { } else {
await globalState.appController.handleBackOrExit(); await context.appController.handleBackOrExit();
} }
}, },
child: widget.child, child: widget.child,

View File

@@ -1,4 +1,3 @@
import 'package:fl_clash/common/system.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
@@ -70,10 +69,8 @@ class CommonScaffoldState extends State<CommonScaffold> {
} }
} }
_platformContainer({required Widget child}) { @override
if (system.isDesktop) { Widget build(BuildContext context) {
return child;
}
return AnnotatedRegion( return AnnotatedRegion(
value: SystemUiOverlayStyle( value: SystemUiOverlayStyle(
statusBarColor: Colors.transparent, statusBarColor: Colors.transparent,
@@ -83,13 +80,6 @@ class CommonScaffoldState extends State<CommonScaffold> {
systemNavigationBarColor: Colors.transparent, systemNavigationBarColor: Colors.transparent,
systemNavigationBarDividerColor: Colors.transparent, systemNavigationBarDividerColor: Colors.transparent,
), ),
child: child,
);
}
@override
Widget build(BuildContext context) {
return _platformContainer(
child: Scaffold( child: Scaffold(
appBar: PreferredSize( appBar: PreferredSize(
preferredSize: const Size.fromHeight(kToolbarHeight), preferredSize: const Size.fromHeight(kToolbarHeight),
@@ -124,23 +114,3 @@ class CommonScaffoldState extends State<CommonScaffold> {
); );
} }
} }
class AppIcon extends StatelessWidget {
const AppIcon({super.key});
@override
Widget build(BuildContext context) {
return Container(
margin: const EdgeInsets.symmetric(
horizontal: 16,
vertical: 16,
),
width: 30,
height: 30,
child: const CircleAvatar(
foregroundImage: AssetImage("assets/images/launch_icon.png"),
backgroundColor: Colors.transparent,
),
);
}
}

View File

@@ -1,7 +1,6 @@
import 'package:fl_clash/common/common.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../state.dart';
class TooltipText extends StatelessWidget { class TooltipText extends StatelessWidget {
final Text text; final Text text;
@@ -15,7 +14,7 @@ class TooltipText extends StatelessWidget {
return LayoutBuilder( return LayoutBuilder(
builder: (context, container) { builder: (context, container) {
final maxWidth = container.maxWidth; final maxWidth = container.maxWidth;
final size = globalState.appController.measure.computeTextSize( final size = context.appController.measure.computeTextSize(
text, text,
); );
if (maxWidth < size.width) { if (maxWidth < size.width) {

View File

@@ -1,5 +1,5 @@
import 'package:fl_clash/common/common.dart';
import 'package:fl_clash/plugins/tile.dart'; import 'package:fl_clash/plugins/tile.dart';
import 'package:fl_clash/state.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class TileContainer extends StatefulWidget { class TileContainer extends StatefulWidget {
@@ -24,13 +24,13 @@ class _TileContainerState extends State<TileContainer> with TileListener {
@override @override
void onStart() { void onStart() {
globalState.appController.updateSystemProxy(true); context.appController.updateSystemProxy(true);
super.onStart(); super.onStart();
} }
@override @override
void onStop() { void onStop() {
globalState.appController.updateSystemProxy(false); context.appController.updateSystemProxy(false);
super.onStop(); super.onStop();
} }

View File

@@ -3,7 +3,6 @@ import 'dart:io';
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/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:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
@@ -33,7 +32,7 @@ class _TrayContainerState extends State<TrayContainer> with TrayListener {
_updateOtherTray() async { _updateOtherTray() async {
if (isTrayInit == false) { if (isTrayInit == false) {
await trayManager.setIcon( await trayManager.setIcon(
other.getTrayIconPath(), Other.getTrayIconPath(),
); );
isTrayInit = true; isTrayInit = true;
} }
@@ -42,7 +41,7 @@ class _TrayContainerState extends State<TrayContainer> with TrayListener {
_updateLinuxTray() async { _updateLinuxTray() async {
await trayManager.destroy(); await trayManager.destroy();
await trayManager.setIcon( await trayManager.setIcon(
other.getTrayIconPath(), Other.getTrayIconPath(),
); );
} }
@@ -69,11 +68,11 @@ class _TrayContainerState extends State<TrayContainer> with TrayListener {
// label: proxy.name, // label: proxy.name,
// checked: isCurrentGroup && isCurrentProxy, // checked: isCurrentGroup && isCurrentProxy,
// onClick: (_) { // onClick: (_) {
// final config = globalState.appController.config; // final config = context.appController.config;
// config.currentProfile?.groupName = group.name; // config.currentProfile?.groupName = group.name;
// config.currentProfile?.proxyName = proxy.name; // config.currentProfile?.proxyName = proxy.name;
// config.update(); // config.update();
// globalState.appController.changeProxy(); // context.appController.changeProxy();
// }), // }),
// ); // );
// } // }
@@ -94,7 +93,7 @@ class _TrayContainerState extends State<TrayContainer> with TrayListener {
MenuItem.checkbox( MenuItem.checkbox(
label: Intl.message(mode.name), label: Intl.message(mode.name),
onClick: (_) { onClick: (_) {
globalState.appController.clashConfig.mode = mode; context.appController.clashConfig.mode = mode;
}, },
checked: mode == state.mode, checked: mode == state.mode,
), ),
@@ -104,7 +103,7 @@ class _TrayContainerState extends State<TrayContainer> with TrayListener {
final proxyMenuItem = MenuItem.checkbox( final proxyMenuItem = MenuItem.checkbox(
label: appLocalizations.systemProxy, label: appLocalizations.systemProxy,
onClick: (_) async { onClick: (_) async {
globalState.appController.updateSystemProxy(!state.isRun); context.appController.updateSystemProxy(!state.isRun);
}, },
checked: state.isRun, checked: state.isRun,
); );
@@ -112,8 +111,8 @@ class _TrayContainerState extends State<TrayContainer> with TrayListener {
final autoStartMenuItem = MenuItem.checkbox( final autoStartMenuItem = MenuItem.checkbox(
label: appLocalizations.autoLaunch, label: appLocalizations.autoLaunch,
onClick: (_) async { onClick: (_) async {
globalState.appController.config.autoLaunch = context.appController.config.autoLaunch =
!globalState.appController.config.autoLaunch; !context.appController.config.autoLaunch;
}, },
checked: state.autoLaunch, checked: state.autoLaunch,
); );
@@ -122,7 +121,7 @@ class _TrayContainerState extends State<TrayContainer> with TrayListener {
final exitMenuItem = MenuItem( final exitMenuItem = MenuItem(
label: appLocalizations.exit, label: appLocalizations.exit,
onClick: (_) async { onClick: (_) async {
await globalState.appController.handleExit(); await context.appController.handleExit();
}, },
); );
menuItems.add(exitMenuItem); menuItems.add(exitMenuItem);

View File

@@ -1,4 +1,4 @@
import 'package:fl_clash/state.dart'; import 'package:fl_clash/common/common.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:window_manager/window_manager.dart'; import 'package:window_manager/window_manager.dart';
@@ -29,13 +29,13 @@ class _WindowContainerState extends State<WindowContainer>
@override @override
void onWindowClose() async { void onWindowClose() async {
await globalState.appController.handleBackOrExit(); await context.appController.handleBackOrExit();
super.onWindowClose(); super.onWindowClose();
} }
@override @override
void onWindowMinimize() async { void onWindowMinimize() async {
await globalState.appController.savePreferences(); await context.appController.savePreferences();
super.onWindowMinimize(); super.onWindowMinimize();
} }

View File

@@ -7,7 +7,6 @@
#include "generated_plugin_registrant.h" #include "generated_plugin_registrant.h"
#include <dynamic_color/dynamic_color_plugin.h> #include <dynamic_color/dynamic_color_plugin.h>
#include <file_selector_linux/file_selector_plugin.h>
#include <gtk/gtk_plugin.h> #include <gtk/gtk_plugin.h>
#include <screen_retriever/screen_retriever_plugin.h> #include <screen_retriever/screen_retriever_plugin.h>
#include <tray_manager/tray_manager_plugin.h> #include <tray_manager/tray_manager_plugin.h>
@@ -18,9 +17,6 @@ void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) dynamic_color_registrar = g_autoptr(FlPluginRegistrar) dynamic_color_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "DynamicColorPlugin"); fl_plugin_registry_get_registrar_for_plugin(registry, "DynamicColorPlugin");
dynamic_color_plugin_register_with_registrar(dynamic_color_registrar); dynamic_color_plugin_register_with_registrar(dynamic_color_registrar);
g_autoptr(FlPluginRegistrar) file_selector_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "FileSelectorPlugin");
file_selector_plugin_register_with_registrar(file_selector_linux_registrar);
g_autoptr(FlPluginRegistrar) gtk_registrar = g_autoptr(FlPluginRegistrar) gtk_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "GtkPlugin"); fl_plugin_registry_get_registrar_for_plugin(registry, "GtkPlugin");
gtk_plugin_register_with_registrar(gtk_registrar); gtk_plugin_register_with_registrar(gtk_registrar);

View File

@@ -4,7 +4,6 @@
list(APPEND FLUTTER_PLUGIN_LIST list(APPEND FLUTTER_PLUGIN_LIST
dynamic_color dynamic_color
file_selector_linux
gtk gtk
screen_retriever screen_retriever
tray_manager tray_manager

View File

@@ -7,7 +7,6 @@ import Foundation
import app_links import app_links
import dynamic_color import dynamic_color
import file_selector_macos
import mobile_scanner import mobile_scanner
import package_info_plus import package_info_plus
import path_provider_foundation import path_provider_foundation
@@ -20,7 +19,6 @@ import window_manager
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
AppLinksMacosPlugin.register(with: registry.registrar(forPlugin: "AppLinksMacosPlugin")) AppLinksMacosPlugin.register(with: registry.registrar(forPlugin: "AppLinksMacosPlugin"))
DynamicColorPlugin.register(with: registry.registrar(forPlugin: "DynamicColorPlugin")) DynamicColorPlugin.register(with: registry.registrar(forPlugin: "DynamicColorPlugin"))
FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
MobileScannerPlugin.register(with: registry.registrar(forPlugin: "MobileScannerPlugin")) MobileScannerPlugin.register(with: registry.registrar(forPlugin: "MobileScannerPlugin"))
FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin")) FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))

View File

@@ -33,14 +33,6 @@ packages:
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "3.5.1" version: "3.5.1"
archive:
dependency: transitive
description:
name: archive
sha256: ecf4273855368121b1caed0d10d4513c7241dfc813f7d3c8933b36622ae9b265
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.5.1"
args: args:
dependency: "direct dev" dependency: "direct dev"
description: description:
@@ -137,14 +129,6 @@ packages:
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.3.0" version: "1.3.0"
charcode:
dependency: transitive
description:
name: charcode
sha256: fb98c0f6d12c920a02ee2d998da788bca066ca5f148492b7085ee23372b12306
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.3.1"
checked_yaml: checked_yaml:
dependency: transitive dependency: transitive
description: description:
@@ -193,14 +177,6 @@ packages:
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "3.1.1" version: "3.1.1"
cross_file:
dependency: transitive
description:
name: cross_file
sha256: "55d7b444feb71301ef6b8838dbc1ae02e63dd48c8773f3810ff53bb1e2945b32"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.3.4+1"
crypto: crypto:
dependency: transitive dependency: transitive
description: description:
@@ -265,38 +241,6 @@ packages:
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "6.2.1" version: "6.2.1"
file_selector_linux:
dependency: transitive
description:
name: file_selector_linux
sha256: "045d372bf19b02aeb69cacf8b4009555fb5f6f0b7ad8016e5f46dd1387ddd492"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.9.2+1"
file_selector_macos:
dependency: transitive
description:
name: file_selector_macos
sha256: f42eacb83b318e183b1ae24eead1373ab1334084404c8c16e0354f9a3e55d385
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.9.4"
file_selector_platform_interface:
dependency: transitive
description:
name: file_selector_platform_interface
sha256: a3994c26f10378a039faa11de174d7b78eb8f79e4dd0af2a451410c1a5c3f66b
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.6.2"
file_selector_windows:
dependency: transitive
description:
name: file_selector_windows
sha256: d3547240c20cabf205c7c7f01a50ecdbc413755814d6677f3cb366f04abcead0
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.9.3+1"
fixnum: fixnum:
dependency: transitive dependency: transitive
description: description:
@@ -335,10 +279,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: flutter_plugin_android_lifecycle name: flutter_plugin_android_lifecycle
sha256: "592dc01a18961a51c24ae5d963b724b2b7fa4a95c100fe8eb6ca8a5a4732cadf" sha256: "8cf40eebf5dec866a6d1956ad7b4f7016e6c0cc69847ab946833b7d43743809f"
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.0.18" version: "2.0.19"
flutter_test: flutter_test:
dependency: "direct dev" dependency: "direct dev"
description: flutter description: flutter
@@ -421,86 +365,14 @@ packages:
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "4.0.2" version: "4.0.2"
image:
dependency: "direct main"
description:
name: image
sha256: "4c68bfd5ae83e700b5204c1e74451e7bf3cf750e6843c6e158289cf56bda018e"
url: "https://pub.flutter-io.cn"
source: hosted
version: "4.1.7"
image_picker:
dependency: "direct main"
description:
name: image_picker
sha256: "33974eca2e87e8b4e3727f1b94fa3abcb25afe80b6bc2c4d449a0e150aedf720"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.1"
image_picker_android:
dependency: transitive
description:
name: image_picker_android
sha256: "79455f6cff4cbef583b2b524bbf0d4ec424e5959f4d464e36ef5323715b98370"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.8.12"
image_picker_for_web:
dependency: transitive
description:
name: image_picker_for_web
sha256: "6a1704fdd75022272e7e7a897a9068e9c2ff3cd6a66820bf3ded810633eac954"
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.0.3"
image_picker_ios:
dependency: transitive
description:
name: image_picker_ios
sha256: cb0db0ec0d3e2cd49674f2e6053be25ccdb959832607c1cbd215dd6cf10fb0dd
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.8.11"
image_picker_linux:
dependency: transitive
description:
name: image_picker_linux
sha256: "4ed1d9bb36f7cd60aa6e6cd479779cc56a4cb4e4de8f49d487b1aaad831300fa"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.2.1+1"
image_picker_macos:
dependency: transitive
description:
name: image_picker_macos
sha256: "3f5ad1e8112a9a6111c46d0b57a7be2286a9a07fc6e1976fdf5be2bd31d4ff62"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.2.1+1"
image_picker_platform_interface:
dependency: transitive
description:
name: image_picker_platform_interface
sha256: "9ec26d410ff46f483c5519c29c02ef0e02e13a543f882b152d4bfd2f06802f80"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.10.0"
image_picker_windows:
dependency: transitive
description:
name: image_picker_windows
sha256: "6ad07afc4eb1bc25f3a01084d28520496c4a3bb0cb13685435838167c9dcedeb"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.2.1+1"
intl: intl:
dependency: "direct main" dependency: "direct main"
description: description:
name: intl name: intl
sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d"
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.19.0" version: "0.18.1"
io: io:
dependency: transitive dependency: transitive
description: description:
@@ -545,26 +417,26 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: leak_tracker name: leak_tracker
sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a" sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa"
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "10.0.4" version: "10.0.0"
leak_tracker_flutter_testing: leak_tracker_flutter_testing:
dependency: transitive dependency: transitive
description: description:
name: leak_tracker_flutter_testing name: leak_tracker_flutter_testing
sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8" sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "3.0.3" version: "2.0.1"
leak_tracker_testing: leak_tracker_testing:
dependency: transitive dependency: transitive
description: description:
name: leak_tracker_testing name: leak_tracker_testing
sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "3.0.1" version: "2.0.1"
lints: lints:
dependency: transitive dependency: transitive
description: description:
@@ -609,10 +481,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: meta name: meta
sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136" sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.12.0" version: "1.11.0"
mime: mime:
dependency: transitive dependency: transitive
description: description:
@@ -717,14 +589,6 @@ packages:
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.2.1" version: "2.2.1"
petitparser:
dependency: transitive
description:
name: petitparser
sha256: c15605cd28af66339f8eb6fbe0e541bfe2d1b72d5825efc6598f3e0a31b9ad27
url: "https://pub.flutter-io.cn"
source: hosted
version: "6.0.2"
platform: platform:
dependency: transitive dependency: transitive
description: description:
@@ -808,10 +672,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: shared_preferences_android name: shared_preferences_android
sha256: "8568a389334b6e83415b6aae55378e158fbc2314e074983362d20c562780fb06" sha256: "1ee8bf911094a1b592de7ab29add6f826a7331fb854273d55918693d5364a1f2"
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.2.1" version: "2.2.2"
shared_preferences_foundation: shared_preferences_foundation:
dependency: transitive dependency: transitive
description: description:
@@ -949,10 +813,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: test_api name: test_api
sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f" sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.7.0" version: "0.6.1"
timing: timing:
dependency: transitive dependency: transitive
description: description:
@@ -1053,10 +917,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: vm_service name: vm_service
sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec" sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "14.2.1" version: "13.0.0"
watcher: watcher:
dependency: transitive dependency: transitive
description: description:
@@ -1121,14 +985,6 @@ packages:
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.0.4" version: "1.0.4"
xml:
dependency: transitive
description:
name: xml
sha256: b015a8ad1c488f66851d762d3090a21c600e479dc75e68328c52774040cf9226
url: "https://pub.flutter-io.cn"
source: hosted
version: "6.5.0"
yaml: yaml:
dependency: transitive dependency: transitive
description: description:
@@ -1145,14 +1001,6 @@ packages:
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.2.1" version: "2.2.1"
zxing2:
dependency: "direct main"
description:
name: zxing2
sha256: "6cf995abd3c86f01ba882968dedffa7bc130185e382f2300239d2e857fc7912c"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.2.3"
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.8.3 version: 0.7.8
environment: environment:
sdk: '>=3.1.0 <4.0.0' sdk: '>=3.1.0 <4.0.0'
@@ -10,7 +10,7 @@ dependencies:
sdk: flutter sdk: flutter
flutter_localizations: flutter_localizations:
sdk: flutter sdk: flutter
intl: ^0.19.0 intl: ^0.18.1
path_provider: ^2.1.0 path_provider: ^2.1.0
path: ^1.8.3 path: ^1.8.3
shared_preferences: ^2.2.0 shared_preferences: ^2.2.0
@@ -35,9 +35,6 @@ dependencies:
url_launcher: ^6.2.6 url_launcher: ^6.2.6
flutter_adaptive_scaffold: ^0.1.10+1 flutter_adaptive_scaffold: ^0.1.10+1
freezed_annotation: ^2.4.1 freezed_annotation: ^2.4.1
image_picker: ^1.1.1
zxing2: ^0.2.3
image: ^4.1.7
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
sdk: flutter sdk: flutter

View File

@@ -8,7 +8,6 @@
#include <app_links/app_links_plugin_c_api.h> #include <app_links/app_links_plugin_c_api.h>
#include <dynamic_color/dynamic_color_plugin_c_api.h> #include <dynamic_color/dynamic_color_plugin_c_api.h>
#include <file_selector_windows/file_selector_windows.h>
#include <proxy/proxy_plugin_c_api.h> #include <proxy/proxy_plugin_c_api.h>
#include <screen_retriever/screen_retriever_plugin.h> #include <screen_retriever/screen_retriever_plugin.h>
#include <tray_manager/tray_manager_plugin.h> #include <tray_manager/tray_manager_plugin.h>
@@ -21,8 +20,6 @@ void RegisterPlugins(flutter::PluginRegistry* registry) {
registry->GetRegistrarForPlugin("AppLinksPluginCApi")); registry->GetRegistrarForPlugin("AppLinksPluginCApi"));
DynamicColorPluginCApiRegisterWithRegistrar( DynamicColorPluginCApiRegisterWithRegistrar(
registry->GetRegistrarForPlugin("DynamicColorPluginCApi")); registry->GetRegistrarForPlugin("DynamicColorPluginCApi"));
FileSelectorWindowsRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FileSelectorWindows"));
ProxyPluginCApiRegisterWithRegistrar( ProxyPluginCApiRegisterWithRegistrar(
registry->GetRegistrarForPlugin("ProxyPluginCApi")); registry->GetRegistrarForPlugin("ProxyPluginCApi"));
ScreenRetrieverPluginRegisterWithRegistrar( ScreenRetrieverPluginRegisterWithRegistrar(

View File

@@ -5,7 +5,6 @@
list(APPEND FLUTTER_PLUGIN_LIST list(APPEND FLUTTER_PLUGIN_LIST
app_links app_links
dynamic_color dynamic_color
file_selector_windows
proxy proxy
screen_retriever screen_retriever
tray_manager tray_manager