Compare commits
23 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
35f7279fcb | ||
|
|
86572cc960 | ||
|
|
ee22709d49 | ||
|
|
0a2ad63f38 | ||
|
|
2ec12c9363 | ||
|
|
a3c2dc786c | ||
|
|
7acf9c6db3 | ||
|
|
8074547fb4 | ||
|
|
8a01e04871 | ||
|
|
7ddcdd9828 | ||
|
|
d89ed076fd | ||
|
|
f4c3b06cd5 | ||
|
|
c65746709d | ||
|
|
d2d9bdab02 | ||
|
|
d0f8444b6d | ||
|
|
fccabfbe27 | ||
|
|
e9bb97c6ce | ||
|
|
068fe14d89 | ||
|
|
43c397007c | ||
|
|
5e801d5f5e | ||
|
|
52d61b15fd | ||
|
|
fea3c14608 | ||
|
|
84be01a38a |
7
.github/workflows/build.yml
vendored
@@ -21,6 +21,12 @@ jobs:
|
||||
os: macos-13
|
||||
|
||||
steps:
|
||||
- name: Check Matrix
|
||||
run: |
|
||||
echo "Running on ${{ matrix.os }}"
|
||||
echo "Arch: ${{ runner.arch }}"
|
||||
gcc --version
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
@@ -82,6 +88,7 @@ jobs:
|
||||
|
||||
|
||||
upload-release:
|
||||
if: ${{ !contains(github.ref, '+') }}
|
||||
permissions: write-all
|
||||
needs: [ build ]
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
2
.gitignore
vendored
@@ -31,6 +31,7 @@ migrate_working_dir/
|
||||
.pub-cache/
|
||||
.pub/
|
||||
/build/
|
||||
/dist/
|
||||
|
||||
# Symbolication related
|
||||
app.*.symbols
|
||||
@@ -44,6 +45,7 @@ app.*.map.json
|
||||
/android/app/release
|
||||
|
||||
|
||||
|
||||
#libclash
|
||||
/libclash/
|
||||
|
||||
|
||||
2
.gitmodules
vendored
@@ -5,4 +5,4 @@
|
||||
[submodule "plugins/flutter_distributor"]
|
||||
path = plugins/flutter_distributor
|
||||
url = git@github.com:chen08209/flutter_distributor.git
|
||||
branch = main
|
||||
branch = FlClash
|
||||
|
||||
@@ -62,7 +62,7 @@ android {
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.follow.clash"
|
||||
minSdkVersion 21
|
||||
minSdkVersion 24
|
||||
targetSdkVersion 34
|
||||
versionCode flutterVersionCode.toInteger()
|
||||
versionName flutterVersionName
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<uses-feature
|
||||
android:name="android.software.leanback"
|
||||
android:required="false" />
|
||||
<uses-feature
|
||||
android:name="android.hardware.touchscreen"
|
||||
android:required="false" />
|
||||
@@ -17,12 +14,15 @@
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
|
||||
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" tools:ignore="QueryAllPackagesPermission"/>
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE"
|
||||
tools:ignore="SystemPermissionTypo" />
|
||||
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"
|
||||
tools:ignore="QueryAllPackagesPermission" />
|
||||
|
||||
<application
|
||||
android:name="${applicationName}"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:extractNativeLibs="true"
|
||||
android:networkSecurityConfig="@xml/network_security_config"
|
||||
android:label="FlClash">
|
||||
<activity
|
||||
@@ -73,7 +73,8 @@
|
||||
<service
|
||||
android:name=".services.FlClashTileService"
|
||||
android:exported="true"
|
||||
android:icon="@drawable/tile_icon"
|
||||
android:icon="@drawable/icon"
|
||||
android:foregroundServiceType="specialUse"
|
||||
android:label="FlClash"
|
||||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
|
||||
<intent-filter>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.follow.clash
|
||||
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.follow.clash.plugins.AppPlugin
|
||||
import com.follow.clash.plugins.TilePlugin
|
||||
import io.flutter.embedding.engine.FlutterEngine
|
||||
import java.util.Date
|
||||
@@ -18,6 +19,9 @@ class GlobalState {
|
||||
var flutterEngine: FlutterEngine? = null
|
||||
fun getCurrentTilePlugin(): TilePlugin? =
|
||||
flutterEngine?.plugins?.get(TilePlugin::class.java) as TilePlugin?
|
||||
|
||||
fun getCurrentAppPlugin(): AppPlugin? =
|
||||
flutterEngine?.plugins?.get(AppPlugin::class.java) as AppPlugin?
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,3 +10,9 @@ data class AccessControl(
|
||||
val acceptList: List<String>,
|
||||
val rejectList: List<String>,
|
||||
)
|
||||
|
||||
data class Props(
|
||||
val accessControl: AccessControl?,
|
||||
val allowBypass: Boolean?,
|
||||
val systemProxy: Boolean?,
|
||||
)
|
||||
@@ -143,7 +143,7 @@ class AppPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware
|
||||
}
|
||||
|
||||
private suspend fun getPackages(): String {
|
||||
return withContext(Dispatchers.Default){
|
||||
return withContext(Dispatchers.Default) {
|
||||
val packageManager = context?.packageManager
|
||||
val packages: List<Package>? =
|
||||
packageManager?.getInstalledPackages(PackageManager.GET_META_DATA)?.filter {
|
||||
@@ -162,6 +162,10 @@ class AppPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware
|
||||
}
|
||||
}
|
||||
|
||||
fun requestGc() {
|
||||
channel.invokeMethod("gc",null)
|
||||
}
|
||||
|
||||
override fun onAttachedToActivity(binding: ActivityPluginBinding) {
|
||||
activity = binding.activity;
|
||||
scope = CoroutineScope(Dispatchers.Default)
|
||||
|
||||
@@ -17,6 +17,7 @@ import androidx.core.content.ContextCompat
|
||||
import com.follow.clash.GlobalState
|
||||
import com.follow.clash.RunState
|
||||
import com.follow.clash.models.AccessControl
|
||||
import com.follow.clash.models.Props
|
||||
import com.follow.clash.services.FlClashVpnService
|
||||
import com.google.gson.Gson
|
||||
import io.flutter.embedding.android.FlutterActivity
|
||||
@@ -41,7 +42,7 @@ class ProxyPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAwar
|
||||
private var flClashVpnService: FlClashVpnService? = null
|
||||
private var isBound = false
|
||||
private var port: Int? = null
|
||||
private var accessControl: AccessControl? = null
|
||||
private var props: Props? = null
|
||||
private lateinit var title: String
|
||||
private lateinit var content: String
|
||||
|
||||
@@ -73,8 +74,8 @@ class ProxyPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAwar
|
||||
"StartProxy" -> {
|
||||
port = call.argument<Int>("port")
|
||||
val args = call.argument<String>("args")
|
||||
accessControl =
|
||||
if (args != null) Gson().fromJson(args, AccessControl::class.java) else null
|
||||
props =
|
||||
if (args != null) Gson().fromJson(args, Props::class.java) else null
|
||||
handleStartVpn()
|
||||
result.success(true)
|
||||
}
|
||||
@@ -121,7 +122,7 @@ class ProxyPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAwar
|
||||
|
||||
private fun startVpn(port: Int) {
|
||||
if (GlobalState.runState.value == RunState.START) return;
|
||||
flClashVpnService?.start(port, accessControl)
|
||||
flClashVpnService?.start(port, props)
|
||||
GlobalState.runState.value = RunState.START
|
||||
GlobalState.runTime = Date()
|
||||
startAfter()
|
||||
|
||||
@@ -19,7 +19,6 @@ import io.flutter.embedding.engine.FlutterEngine
|
||||
import io.flutter.embedding.engine.dart.DartExecutor
|
||||
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
class FlClashTileService : TileService() {
|
||||
|
||||
private val observer = Observer<RunState> { runState ->
|
||||
@@ -43,19 +42,27 @@ class FlClashTileService : TileService() {
|
||||
GlobalState.runState.observeForever(observer)
|
||||
}
|
||||
|
||||
@SuppressLint("StartActivityAndCollapseDeprecated")
|
||||
private fun activityTransfer() {
|
||||
val intent = Intent(this, TempActivity::class.java)
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
if (Build.VERSION.SDK_INT >= 34) {
|
||||
val pendingIntent = PendingIntent.getActivity(
|
||||
val pendingIntent = if (Build.VERSION.SDK_INT >= 31) {
|
||||
PendingIntent.getActivity(
|
||||
this,
|
||||
0,
|
||||
intent,
|
||||
PendingIntent.FLAG_IMMUTABLE
|
||||
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
|
||||
)
|
||||
startActivityAndCollapse(pendingIntent)
|
||||
} else {
|
||||
PendingIntent.getActivity(
|
||||
this,
|
||||
0,
|
||||
intent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT
|
||||
)
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
|
||||
startActivityAndCollapse(pendingIntent)
|
||||
}else{
|
||||
startActivityAndCollapse(intent)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package com.follow.clash.services
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Notification.FOREGROUND_SERVICE_IMMEDIATE
|
||||
import android.app.NotificationChannel
|
||||
import android.app.NotificationManager
|
||||
import android.app.PendingIntent
|
||||
import android.app.Service
|
||||
import android.content.Intent
|
||||
import android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE
|
||||
import android.net.ProxyInfo
|
||||
@@ -13,15 +12,13 @@ import android.os.Binder
|
||||
import android.os.Build
|
||||
import android.os.IBinder
|
||||
import androidx.core.app.NotificationCompat
|
||||
import androidx.core.app.NotificationCompat.FOREGROUND_SERVICE_IMMEDIATE
|
||||
import androidx.core.graphics.drawable.IconCompat
|
||||
import com.follow.clash.GlobalState
|
||||
import com.follow.clash.MainActivity
|
||||
import com.follow.clash.models.AccessControl
|
||||
import com.follow.clash.R
|
||||
import com.follow.clash.models.AccessControlMode
|
||||
import com.follow.clash.models.Props
|
||||
|
||||
|
||||
@SuppressLint("WrongConstant")
|
||||
class FlClashVpnService : VpnService() {
|
||||
|
||||
|
||||
@@ -54,12 +51,12 @@ class FlClashVpnService : VpnService() {
|
||||
return START_STICKY
|
||||
}
|
||||
|
||||
fun start(port: Int, accessControl: AccessControl?) {
|
||||
fun start(port: Int, props: Props?) {
|
||||
fd = with(Builder()) {
|
||||
addAddress("172.16.0.1", 30)
|
||||
setMtu(9000)
|
||||
addRoute("0.0.0.0", 0)
|
||||
if (accessControl != null) {
|
||||
props?.accessControl?.let { accessControl ->
|
||||
when (accessControl.mode) {
|
||||
AccessControlMode.acceptSelected -> {
|
||||
(accessControl.acceptList + packageName).forEach {
|
||||
@@ -80,8 +77,10 @@ class FlClashVpnService : VpnService() {
|
||||
if (Build.VERSION.SDK_INT >= 29) {
|
||||
setMetered(false)
|
||||
}
|
||||
allowBypass()
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
if (props?.allowBypass == true) {
|
||||
allowBypass()
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && props?.systemProxy == true) {
|
||||
setHttpProxy(
|
||||
ProxyInfo.buildDirectProxy(
|
||||
"127.0.0.1",
|
||||
@@ -100,10 +99,10 @@ class FlClashVpnService : VpnService() {
|
||||
}
|
||||
|
||||
|
||||
private val notificationBuilder by lazy {
|
||||
private val notificationBuilder: NotificationCompat.Builder by lazy {
|
||||
val intent = Intent(this, MainActivity::class.java)
|
||||
|
||||
val pendingIntent = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
val pendingIntent = if (Build.VERSION.SDK_INT >= 31) {
|
||||
PendingIntent.getActivity(
|
||||
this,
|
||||
0,
|
||||
@@ -119,34 +118,40 @@ class FlClashVpnService : VpnService() {
|
||||
)
|
||||
}
|
||||
|
||||
val icon = IconCompat.createWithResource(this, this.applicationInfo.icon)
|
||||
|
||||
with(NotificationCompat.Builder(this, CHANNEL)) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
setSmallIcon(icon)
|
||||
}
|
||||
setSmallIcon(R.drawable.ic_stat_name)
|
||||
setContentTitle("FlClash")
|
||||
foregroundServiceBehavior = FOREGROUND_SERVICE_IMMEDIATE
|
||||
setContentIntent(pendingIntent)
|
||||
setCategory(NotificationCompat.CATEGORY_SERVICE)
|
||||
priority = NotificationCompat.PRIORITY_LOW
|
||||
priority = NotificationCompat.PRIORITY_MIN
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
foregroundServiceBehavior = FOREGROUND_SERVICE_IMMEDIATE
|
||||
}
|
||||
setOngoing(true)
|
||||
setShowWhen(false)
|
||||
setOnlyAlertOnce(true)
|
||||
setAutoCancel(true);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("ForegroundServiceType", "WrongConstant")
|
||||
override fun onTrimMemory(level: Int) {
|
||||
super.onTrimMemory(level)
|
||||
GlobalState.getCurrentAppPlugin()?.requestGc()
|
||||
}
|
||||
|
||||
fun startForeground(title: String, content: String) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
val channel =
|
||||
NotificationChannel(CHANNEL, "FlClash", NotificationManager.IMPORTANCE_LOW)
|
||||
val manager = getSystemService(NotificationManager::class.java)
|
||||
manager.createNotificationChannel(channel)
|
||||
var channel = manager?.getNotificationChannel(CHANNEL)
|
||||
if (channel == null) {
|
||||
channel =
|
||||
NotificationChannel(CHANNEL, "FlClash", NotificationManager.IMPORTANCE_LOW)
|
||||
manager?.createNotificationChannel(channel)
|
||||
}
|
||||
}
|
||||
val notification =
|
||||
notificationBuilder.setContentTitle(title).setContentText(content).build()
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
startForeground(notificationId, notification, FOREGROUND_SERVICE_TYPE_SPECIAL_USE)
|
||||
} else {
|
||||
startForeground(notificationId, notification)
|
||||
@@ -155,7 +160,7 @@ class FlClashVpnService : VpnService() {
|
||||
|
||||
private fun stopForeground() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
stopForeground(Service.STOP_FOREGROUND_REMOVE)
|
||||
stopForeground(STOP_FOREGROUND_REMOVE)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BIN
android/app/src/main/res/drawable-hdpi/ic_stat_name.png
Normal file
|
After Width: | Height: | Size: 763 B |
BIN
android/app/src/main/res/drawable-mdpi/ic_stat_name.png
Normal file
|
After Width: | Height: | Size: 520 B |
BIN
android/app/src/main/res/drawable-xhdpi/ic_stat_name.png
Normal file
|
After Width: | Height: | Size: 1.0 KiB |
BIN
android/app/src/main/res/drawable-xxhdpi/ic_stat_name.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
android/app/src/main/res/drawable-xxxhdpi/ic_stat_name.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
android/app/src/main/res/drawable/icon.png
Normal file
|
After Width: | Height: | Size: 118 KiB |
|
Before Width: | Height: | Size: 105 KiB |
@@ -4,7 +4,6 @@
|
||||
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
|
||||
<!-- Show a splash screen on the activity. Automatically removed when
|
||||
the Flutter engine draws its first frame -->
|
||||
<item name="android:windowBackground">@mipmap/ic_launcher_foreground</item>
|
||||
</style>
|
||||
<!-- Theme applied to the Android Window as soon as the process has started.
|
||||
This theme determines the color of the Android Window while your
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
<style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
|
||||
<!-- Show a splash screen on the activity. Automatically removed when
|
||||
the Flutter engine draws its first frame -->
|
||||
<item name="android:windowBackground">@mipmap/ic_launcher_foreground</item>
|
||||
</style>
|
||||
<!-- Theme applied to the Android Window as soon as the process has started.
|
||||
This theme determines the color of the Android Window while your
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/metacubex/mihomo/config"
|
||||
"github.com/metacubex/mihomo/constant/provider"
|
||||
"github.com/metacubex/mihomo/dns"
|
||||
"github.com/metacubex/mihomo/hub"
|
||||
"github.com/metacubex/mihomo/hub/executor"
|
||||
"github.com/metacubex/mihomo/listener"
|
||||
"github.com/metacubex/mihomo/log"
|
||||
@@ -321,21 +322,26 @@ func generateProxyGroupAndRule(proxyGroup *[]map[string]any, rule *[]string) {
|
||||
}
|
||||
|
||||
func overwriteConfig(targetConfig *config.RawConfig, patchConfig config.RawConfig, compatible bool) {
|
||||
targetConfig.ExternalController = ""
|
||||
targetConfig.ExternalController = patchConfig.ExternalController
|
||||
targetConfig.ExternalUI = ""
|
||||
targetConfig.Interface = ""
|
||||
targetConfig.ExternalUIURL = ""
|
||||
//targetConfig.IPv6 = patchConfig.IPv6
|
||||
targetConfig.TCPConcurrent = patchConfig.TCPConcurrent
|
||||
targetConfig.UnifiedDelay = patchConfig.UnifiedDelay
|
||||
targetConfig.GeodataMode = false
|
||||
targetConfig.IPv6 = patchConfig.IPv6
|
||||
targetConfig.LogLevel = patchConfig.LogLevel
|
||||
targetConfig.Port = 0
|
||||
targetConfig.SocksPort = 0
|
||||
targetConfig.MixedPort = patchConfig.MixedPort
|
||||
targetConfig.FindProcessMode = process.FindProcessAlways
|
||||
targetConfig.AllowLan = patchConfig.AllowLan
|
||||
targetConfig.MixedPort = patchConfig.MixedPort
|
||||
targetConfig.Mode = patchConfig.Mode
|
||||
targetConfig.Tun.Enable = patchConfig.Tun.Enable
|
||||
targetConfig.Tun.Device = patchConfig.Tun.Device
|
||||
targetConfig.Tun.DNSHijack = patchConfig.Tun.DNSHijack
|
||||
targetConfig.Tun.Stack = patchConfig.Tun.Stack
|
||||
targetConfig.GeodataLoader = "standard"
|
||||
//targetConfig.Tun.DNSHijack = patchConfig.Tun.DNSHijack
|
||||
//targetConfig.Tun.Stack = patchConfig.Tun.Stack
|
||||
targetConfig.GeodataLoader = patchConfig.GeodataLoader
|
||||
targetConfig.Profile.StoreSelected = false
|
||||
if targetConfig.DNS.Enable == false {
|
||||
targetConfig.DNS = patchConfig.DNS
|
||||
@@ -350,7 +356,6 @@ func overwriteConfig(targetConfig *config.RawConfig, patchConfig config.RawConfi
|
||||
targetConfig.RuleProvider = make(map[string]map[string]any)
|
||||
generateProxyGroupAndRule(&targetConfig.ProxyGroup, &targetConfig.Rule)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func patchConfig(general *config.General) {
|
||||
@@ -408,7 +413,7 @@ func applyConfig(isPatch bool) {
|
||||
if isPatch {
|
||||
patchConfig(cfg.General)
|
||||
} else {
|
||||
executor.ApplyConfig(cfg, true)
|
||||
healthcheck()
|
||||
hub.UltraApplyConfig(cfg, true)
|
||||
hcCompatibleProvider(tunnel.Providers())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ require (
|
||||
github.com/RyuaNerin/go-krypto v1.2.4 // indirect
|
||||
github.com/Yawning/aez v0.0.0-20211027044916-e49e68abd344 // indirect
|
||||
github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da // indirect
|
||||
github.com/ajg/form v1.5.1 // indirect
|
||||
github.com/andybalholm/brotli v1.0.6 // indirect
|
||||
github.com/bahlo/generic-list-go v0.2.0 // indirect
|
||||
github.com/buger/jsonparser v1.1.1 // indirect
|
||||
@@ -30,6 +31,9 @@ require (
|
||||
github.com/ericlagergren/subtle v0.0.0-20220507045147-890d697da010 // indirect
|
||||
github.com/fsnotify/fsnotify v1.7.0 // indirect
|
||||
github.com/gaukas/godicttls v0.0.4 // indirect
|
||||
github.com/go-chi/chi/v5 v5.0.12 // indirect
|
||||
github.com/go-chi/cors v1.2.1 // indirect
|
||||
github.com/go-chi/render v1.0.3 // indirect
|
||||
github.com/go-ole/go-ole v1.3.0 // indirect
|
||||
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
|
||||
github.com/gobwas/httphead v0.1.0 // indirect
|
||||
|
||||
@@ -9,6 +9,8 @@ github.com/Yawning/aez v0.0.0-20211027044916-e49e68abd344 h1:cDVUiFo+npB0ZASqnw4
|
||||
github.com/Yawning/aez v0.0.0-20211027044916-e49e68abd344/go.mod h1:9pIqrY6SXNL8vjRQE5Hd/OL5GyK/9MrGUWs87z/eFfk=
|
||||
github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da h1:KjTM2ks9d14ZYCvmHS9iAKVt9AyzRSqNU1qabPih5BY=
|
||||
github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da/go.mod h1:eHEWzANqSiWQsof+nXEI9bUVUyV6F53Fp89EuCh2EAA=
|
||||
github.com/ajg/form v1.5.1 h1:t9c7v8JUKu/XxOGBU0yjNpaMloxGEJhUkqFRq0ibGeU=
|
||||
github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY=
|
||||
github.com/andybalholm/brotli v1.0.6 h1:Yf9fFpf49Zrxb9NlQaluyE92/+X7UVHlhMNJN2sxfOI=
|
||||
github.com/andybalholm/brotli v1.0.6/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
|
||||
github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk=
|
||||
@@ -46,6 +48,12 @@ github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nos
|
||||
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
|
||||
github.com/gaukas/godicttls v0.0.4 h1:NlRaXb3J6hAnTmWdsEKb9bcSBD6BvcIjdGdeb0zfXbk=
|
||||
github.com/gaukas/godicttls v0.0.4/go.mod h1:l6EenT4TLWgTdwslVb4sEMOCf7Bv0JAK67deKr9/NCI=
|
||||
github.com/go-chi/chi/v5 v5.0.12 h1:9euLV5sTrTNTRUU9POmDUvfxyj6LAABLUcEWO+JJb4s=
|
||||
github.com/go-chi/chi/v5 v5.0.12/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
|
||||
github.com/go-chi/cors v1.2.1 h1:xEC8UT3Rlp2QuWNEr4Fs/c2EAGVKBwy/1vHx3bppil4=
|
||||
github.com/go-chi/cors v1.2.1/go.mod h1:sSbTewc+6wYHBBCW7ytsFSn836hqM7JxpglAy2Vzc58=
|
||||
github.com/go-chi/render v1.0.3 h1:AsXqd2a1/INaIfUSKq3G5uA8weYx20FOsM7uSoCyyt4=
|
||||
github.com/go-chi/render v1.0.3/go.mod h1:/gr3hVkmYR0YlEy3LxCuVRFzEu9Ruok+gFqbIofjao0=
|
||||
github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ=
|
||||
github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
|
||||
|
||||
40
core/hub.go
@@ -60,17 +60,20 @@ func shutdownClash() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
//export forceGc
|
||||
func forceGc() {
|
||||
go func() {
|
||||
log.Infoln("[APP] request force GC")
|
||||
runtime.GC()
|
||||
}()
|
||||
}
|
||||
|
||||
//export validateConfig
|
||||
func validateConfig(s *C.char, port C.longlong) {
|
||||
i := int64(port)
|
||||
go func() {
|
||||
bytes := []byte(C.GoString(s))
|
||||
rawConfig, err := config.UnmarshalRawConfig(bytes)
|
||||
if err != nil {
|
||||
bridge.SendToPort(i, err.Error())
|
||||
return
|
||||
}
|
||||
_, err = config.ParseRawConfig(rawConfig)
|
||||
_, err := config.UnmarshalRawConfig(bytes)
|
||||
if err != nil {
|
||||
bridge.SendToPort(i, err.Error())
|
||||
return
|
||||
@@ -186,7 +189,8 @@ func getTraffic() *C.char {
|
||||
}
|
||||
|
||||
//export asyncTestDelay
|
||||
func asyncTestDelay(s *C.char) {
|
||||
func asyncTestDelay(s *C.char, port C.longlong) {
|
||||
i := int64(port)
|
||||
go func() {
|
||||
paramsString := C.GoString(s)
|
||||
var params = &TestDelayParams{}
|
||||
@@ -210,26 +214,25 @@ func asyncTestDelay(s *C.char) {
|
||||
Name: params.ProxyName,
|
||||
}
|
||||
|
||||
message := bridge.Message{
|
||||
Type: bridge.Delay,
|
||||
Data: delayData,
|
||||
}
|
||||
|
||||
if proxy == nil {
|
||||
delayData.Value = -1
|
||||
bridge.SendMessage(message)
|
||||
data, _ := json.Marshal(delayData)
|
||||
bridge.SendToPort(i, string(data))
|
||||
return
|
||||
}
|
||||
|
||||
delay, err := proxy.URLTest(ctx, constant.DefaultTestURL, expectedStatus)
|
||||
if err != nil || delay == 0 {
|
||||
delayData.Value = -1
|
||||
bridge.SendMessage(message)
|
||||
data, _ := json.Marshal(delayData)
|
||||
bridge.SendToPort(i, string(data))
|
||||
return
|
||||
}
|
||||
|
||||
delayData.Value = int32(delay)
|
||||
bridge.SendMessage(message)
|
||||
data, _ := json.Marshal(delayData)
|
||||
bridge.SendToPort(i, string(data))
|
||||
return
|
||||
}()
|
||||
}
|
||||
|
||||
@@ -237,7 +240,7 @@ func asyncTestDelay(s *C.char) {
|
||||
func getVersionInfo() *C.char {
|
||||
versionInfo := map[string]string{
|
||||
"clashName": constant.Name,
|
||||
"version": "v1.18.5",
|
||||
"version": "1.18.5",
|
||||
}
|
||||
data, err := json.Marshal(versionInfo)
|
||||
if err != nil {
|
||||
@@ -379,11 +382,6 @@ func updateExternalProvider(providerName *C.char, providerType *C.char, port C.l
|
||||
}()
|
||||
}
|
||||
|
||||
//export healthcheck
|
||||
func healthcheck() {
|
||||
hcCompatibleProvider(tunnel.Providers())
|
||||
}
|
||||
|
||||
//export initNativeApiBridge
|
||||
func initNativeApiBridge(api unsafe.Pointer, port C.longlong) {
|
||||
bridge.InitDartApi(api)
|
||||
|
||||
61
core/tun.go
@@ -17,36 +17,35 @@ var tunLock sync.Mutex
|
||||
var tun *t.Tun
|
||||
|
||||
//export startTUN
|
||||
func startTUN(fd C.int) bool {
|
||||
tunLock.Lock()
|
||||
defer tunLock.Unlock()
|
||||
func startTUN(fd C.int) {
|
||||
go func() {
|
||||
tunLock.Lock()
|
||||
defer tunLock.Unlock()
|
||||
|
||||
if tun != nil {
|
||||
tun.Close()
|
||||
tun = nil
|
||||
}
|
||||
f := int(fd)
|
||||
gateway := "172.16.0.1/30"
|
||||
portal := "172.16.0.2"
|
||||
dns := "0.0.0.0"
|
||||
if tun != nil {
|
||||
tun.Close()
|
||||
tun = nil
|
||||
}
|
||||
f := int(fd)
|
||||
gateway := "172.16.0.1/30"
|
||||
portal := "172.16.0.2"
|
||||
dns := "0.0.0.0"
|
||||
|
||||
tempTun := &t.Tun{Closed: false, Limit: semaphore.NewWeighted(4)}
|
||||
tempTun := &t.Tun{Closed: false, Limit: semaphore.NewWeighted(4)}
|
||||
|
||||
closer, err := t.Start(f, gateway, portal, dns)
|
||||
closer, err := t.Start(f, gateway, portal, dns)
|
||||
|
||||
applyConfig(true)
|
||||
applyConfig(true)
|
||||
|
||||
if err != nil {
|
||||
log.Errorln("startTUN error: %v", err)
|
||||
tempTun.Close()
|
||||
return false
|
||||
}
|
||||
if err != nil {
|
||||
log.Errorln("startTUN error: %v", err)
|
||||
tempTun.Close()
|
||||
}
|
||||
|
||||
tempTun.Closer = closer
|
||||
tempTun.Closer = closer
|
||||
|
||||
tun = tempTun
|
||||
|
||||
return true
|
||||
tun = tempTun
|
||||
}()
|
||||
}
|
||||
|
||||
//export updateMarkSocketPort
|
||||
@@ -61,14 +60,16 @@ func updateMarkSocketPort(markSocketPort C.longlong) bool {
|
||||
|
||||
//export stopTun
|
||||
func stopTun() {
|
||||
tunLock.Lock()
|
||||
defer tunLock.Unlock()
|
||||
go func() {
|
||||
tunLock.Lock()
|
||||
defer tunLock.Unlock()
|
||||
|
||||
if tun != nil {
|
||||
tun.Close()
|
||||
applyConfig(true)
|
||||
tun = nil
|
||||
}
|
||||
if tun != nil {
|
||||
tun.Close()
|
||||
applyConfig(true)
|
||||
tun = nil
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
||||
@@ -82,7 +82,7 @@ class ApplicationState extends State<Application> {
|
||||
super.initState();
|
||||
globalState.appController = AppController(context);
|
||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
|
||||
globalState.appController.afterInit();
|
||||
await globalState.appController.init();
|
||||
globalState.appController.initLink();
|
||||
_updateGroups();
|
||||
});
|
||||
@@ -160,8 +160,9 @@ class ApplicationState extends State<Application> {
|
||||
AppLocalizations.delegate.supportedLocales,
|
||||
themeMode: state.themeMode,
|
||||
theme: ThemeData(
|
||||
pageTransitionsTheme: _pageTransitionsTheme,
|
||||
useMaterial3: true,
|
||||
fontFamily: '',
|
||||
pageTransitionsTheme: _pageTransitionsTheme,
|
||||
colorScheme: _getAppColorScheme(
|
||||
brightness: Brightness.light,
|
||||
systemColorSchemes: systemColorSchemes,
|
||||
@@ -170,6 +171,7 @@ class ApplicationState extends State<Application> {
|
||||
),
|
||||
darkTheme: ThemeData(
|
||||
useMaterial3: true,
|
||||
fontFamily: '',
|
||||
pageTransitionsTheme: _pageTransitionsTheme,
|
||||
colorScheme: _getAppColorScheme(
|
||||
brightness: Brightness.dark,
|
||||
|
||||
@@ -156,23 +156,36 @@ class ClashCore {
|
||||
return clashFFI.changeProxy(params.toNativeUtf8().cast()) == 1;
|
||||
}
|
||||
|
||||
bool delay(String proxyName) {
|
||||
Future<Delay> getDelay(String proxyName) {
|
||||
final delayParams = {
|
||||
"proxy-name": proxyName,
|
||||
"timeout": httpTimeoutDuration.inMilliseconds,
|
||||
};
|
||||
clashFFI.asyncTestDelay(json.encode(delayParams).toNativeUtf8().cast());
|
||||
return true;
|
||||
final completer = Completer<Delay>();
|
||||
final receiver = ReceivePort();
|
||||
receiver.listen((message) {
|
||||
if (!completer.isCompleted) {
|
||||
completer.complete(Delay.fromJson(json.decode(message)));
|
||||
receiver.close();
|
||||
}
|
||||
});
|
||||
clashFFI.asyncTestDelay(
|
||||
json.encode(delayParams).toNativeUtf8().cast(),
|
||||
receiver.sendPort.nativePort,
|
||||
);
|
||||
Future.delayed(httpTimeoutDuration + moreDuration, () {
|
||||
receiver.close();
|
||||
completer.complete(
|
||||
Delay(name: proxyName, value: -1),
|
||||
);
|
||||
});
|
||||
return completer.future;
|
||||
}
|
||||
|
||||
clearEffect(String path) {
|
||||
clashFFI.clearEffect(path.toNativeUtf8().cast());
|
||||
}
|
||||
|
||||
healthcheck() {
|
||||
clashFFI.healthcheck();
|
||||
}
|
||||
|
||||
VersionInfo getVersionInfo() {
|
||||
final versionInfoRaw = clashFFI.getVersionInfo();
|
||||
final versionInfo = json.decode(versionInfoRaw.cast<Utf8>().toDartString());
|
||||
@@ -197,6 +210,10 @@ class ClashCore {
|
||||
clashFFI.startTUN(fd);
|
||||
}
|
||||
|
||||
requestGc(){
|
||||
clashFFI.forceGc();
|
||||
}
|
||||
|
||||
void stopTun() {
|
||||
clashFFI.stopTun();
|
||||
}
|
||||
|
||||
@@ -893,6 +893,14 @@ class ClashFFI {
|
||||
_lookup<ffi.NativeFunction<GoUint8 Function()>>('shutdownClash');
|
||||
late final _shutdownClash = _shutdownClashPtr.asFunction<int Function()>();
|
||||
|
||||
void forceGc() {
|
||||
return _forceGc();
|
||||
}
|
||||
|
||||
late final _forceGcPtr =
|
||||
_lookup<ffi.NativeFunction<ffi.Void Function()>>('forceGc');
|
||||
late final _forceGc = _forceGcPtr.asFunction<void Function()>();
|
||||
|
||||
void validateConfig(
|
||||
ffi.Pointer<ffi.Char> s,
|
||||
int port,
|
||||
@@ -977,17 +985,20 @@ class ClashFFI {
|
||||
|
||||
void asyncTestDelay(
|
||||
ffi.Pointer<ffi.Char> s,
|
||||
int port,
|
||||
) {
|
||||
return _asyncTestDelay(
|
||||
s,
|
||||
port,
|
||||
);
|
||||
}
|
||||
|
||||
late final _asyncTestDelayPtr =
|
||||
_lookup<ffi.NativeFunction<ffi.Void Function(ffi.Pointer<ffi.Char>)>>(
|
||||
'asyncTestDelay');
|
||||
late final _asyncTestDelay =
|
||||
_asyncTestDelayPtr.asFunction<void Function(ffi.Pointer<ffi.Char>)>();
|
||||
late final _asyncTestDelayPtr = _lookup<
|
||||
ffi.NativeFunction<
|
||||
ffi.Void Function(
|
||||
ffi.Pointer<ffi.Char>, ffi.LongLong)>>('asyncTestDelay');
|
||||
late final _asyncTestDelay = _asyncTestDelayPtr
|
||||
.asFunction<void Function(ffi.Pointer<ffi.Char>, int)>();
|
||||
|
||||
ffi.Pointer<ffi.Char> getVersionInfo() {
|
||||
return _getVersionInfo();
|
||||
@@ -1086,14 +1097,6 @@ class ClashFFI {
|
||||
late final _updateExternalProvider = _updateExternalProviderPtr.asFunction<
|
||||
void Function(ffi.Pointer<ffi.Char>, ffi.Pointer<ffi.Char>, int)>();
|
||||
|
||||
void healthcheck() {
|
||||
return _healthcheck();
|
||||
}
|
||||
|
||||
late final _healthcheckPtr =
|
||||
_lookup<ffi.NativeFunction<ffi.Void Function()>>('healthcheck');
|
||||
late final _healthcheck = _healthcheckPtr.asFunction<void Function()>();
|
||||
|
||||
void initNativeApiBridge(
|
||||
ffi.Pointer<ffi.Void> api,
|
||||
int port,
|
||||
@@ -1127,7 +1130,7 @@ class ClashFFI {
|
||||
_lookup<ffi.NativeFunction<ffi.Void Function()>>('stopLog');
|
||||
late final _stopLog = _stopLogPtr.asFunction<void Function()>();
|
||||
|
||||
int startTUN(
|
||||
void startTUN(
|
||||
int fd,
|
||||
) {
|
||||
return _startTUN(
|
||||
@@ -1136,8 +1139,8 @@ class ClashFFI {
|
||||
}
|
||||
|
||||
late final _startTUNPtr =
|
||||
_lookup<ffi.NativeFunction<GoUint8 Function(ffi.Int)>>('startTUN');
|
||||
late final _startTUN = _startTUNPtr.asFunction<int Function(int)>();
|
||||
_lookup<ffi.NativeFunction<ffi.Void Function(ffi.Int)>>('startTUN');
|
||||
late final _startTUN = _startTUNPtr.asFunction<void Function(int)>();
|
||||
|
||||
int updateMarkSocketPort(
|
||||
int markSocketPort,
|
||||
|
||||
@@ -18,8 +18,11 @@ const configKey = "config";
|
||||
const listItemPadding = EdgeInsets.symmetric(horizontal: 16);
|
||||
const double dialogCommonWidth = 300;
|
||||
const repository = "chen08209/FlClash";
|
||||
const defaultExternalController = "127.0.0.1:9090";
|
||||
const maxMobileWidth = 600;
|
||||
const maxLaptopWidth = 840;
|
||||
const geodataLoaderMemconservative = "memconservative";
|
||||
const geodataLoaderStandard = "standard";
|
||||
final filter = ImageFilter.blur(
|
||||
sigmaX: 5,
|
||||
sigmaY: 5,
|
||||
|
||||
@@ -35,4 +35,8 @@ extension DateTimeExtension on DateTime {
|
||||
}
|
||||
return appLocalizations.just;
|
||||
}
|
||||
}
|
||||
|
||||
String get show {
|
||||
return toIso8601String().substring(0, 10);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,10 +23,11 @@ class Measure {
|
||||
double? _bodyMediumHeight;
|
||||
double? _bodySmallHeight;
|
||||
double? _labelSmallHeight;
|
||||
double? _labelMediumHeight;
|
||||
double? _titleLargeHeight;
|
||||
double? _titleMediumHeight;
|
||||
|
||||
|
||||
double get bodyMediumHeight{
|
||||
double get bodyMediumHeight {
|
||||
_bodyMediumHeight ??= computeTextSize(
|
||||
Text(
|
||||
"",
|
||||
@@ -36,7 +37,7 @@ class Measure {
|
||||
return _bodyMediumHeight!;
|
||||
}
|
||||
|
||||
double get bodySmallHeight{
|
||||
double get bodySmallHeight {
|
||||
_bodySmallHeight ??= computeTextSize(
|
||||
Text(
|
||||
"",
|
||||
@@ -46,7 +47,7 @@ class Measure {
|
||||
return _bodySmallHeight!;
|
||||
}
|
||||
|
||||
double get labelSmallHeight{
|
||||
double get labelSmallHeight {
|
||||
_labelSmallHeight ??= computeTextSize(
|
||||
Text(
|
||||
"",
|
||||
@@ -56,7 +57,17 @@ class Measure {
|
||||
return _labelSmallHeight!;
|
||||
}
|
||||
|
||||
double get titleLargeHeight{
|
||||
double get labelMediumHeight {
|
||||
_labelMediumHeight ??= computeTextSize(
|
||||
Text(
|
||||
"",
|
||||
style: context.textTheme.labelMedium,
|
||||
),
|
||||
).height;
|
||||
return _labelMediumHeight!;
|
||||
}
|
||||
|
||||
double get titleLargeHeight {
|
||||
_titleLargeHeight ??= computeTextSize(
|
||||
Text(
|
||||
"",
|
||||
@@ -65,4 +76,14 @@ class Measure {
|
||||
).height;
|
||||
return _titleLargeHeight!;
|
||||
}
|
||||
|
||||
double get titleMediumHeight {
|
||||
_titleMediumHeight ??= computeTextSize(
|
||||
Text(
|
||||
"",
|
||||
style: context.textTheme.titleMedium,
|
||||
),
|
||||
).height;
|
||||
return _titleMediumHeight!;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,7 @@ class Picker {
|
||||
if (Platform.isAndroid) {
|
||||
filePickerResult = await FilePicker.platform.pickFiles(
|
||||
withData: true,
|
||||
type: FileType.custom,
|
||||
allowedExtensions: ['txt', 'conf'],
|
||||
allowMultiple: false,
|
||||
);
|
||||
} else {
|
||||
filePickerResult = await FilePicker.platform.pickFiles(
|
||||
|
||||
@@ -3,18 +3,17 @@ import 'dart:io';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:dio/io.dart';
|
||||
import 'package:fl_clash/common/common.dart';
|
||||
import 'package:fl_clash/models/ip.dart';
|
||||
import 'package:fl_clash/state.dart';
|
||||
|
||||
class Request {
|
||||
late final Dio _dio;
|
||||
int? _port;
|
||||
bool _isStart = false;
|
||||
|
||||
Request() {
|
||||
_dio = Dio(
|
||||
BaseOptions(
|
||||
connectTimeout: httpTimeoutDuration,
|
||||
sendTimeout: httpTimeoutDuration,
|
||||
receiveTimeout: httpTimeoutDuration,
|
||||
headers: {"User-Agent": coreName},
|
||||
),
|
||||
);
|
||||
@@ -26,13 +25,16 @@ class Request {
|
||||
));
|
||||
}
|
||||
|
||||
_syncProxy(){
|
||||
_syncProxy() {
|
||||
final port = globalState.appController.clashConfig.mixedPort;
|
||||
if (_port != port) {
|
||||
final isStart = globalState.appController.appState.isStart;
|
||||
if (_port != port || isStart != _isStart) {
|
||||
_port = port;
|
||||
_isStart = isStart;
|
||||
_dio.httpClientAdapter = IOHttpClientAdapter(
|
||||
createHttpClient: () {
|
||||
final client = HttpClient();
|
||||
if (!_isStart) return client;
|
||||
client.findProxy = (url) {
|
||||
return "PROXY localhost:$_port;DIRECT";
|
||||
};
|
||||
@@ -45,14 +47,14 @@ class Request {
|
||||
Future<Response> getFileResponseForUrl(String url) async {
|
||||
final response = await _dio
|
||||
.get(
|
||||
url,
|
||||
options: Options(
|
||||
responseType: ResponseType.bytes,
|
||||
),
|
||||
)
|
||||
url,
|
||||
options: Options(
|
||||
responseType: ResponseType.bytes,
|
||||
),
|
||||
)
|
||||
.timeout(
|
||||
httpTimeoutDuration,
|
||||
);
|
||||
httpTimeoutDuration * 2,
|
||||
);
|
||||
return response;
|
||||
}
|
||||
|
||||
@@ -73,6 +75,31 @@ class Request {
|
||||
if (!hasUpdate) return null;
|
||||
return data;
|
||||
}
|
||||
|
||||
final Map<String, IpInfo Function(Map<String, dynamic>)> _ipInfoSources = {
|
||||
"https://ipwho.is/": IpInfo.fromIpwhoIsJson,
|
||||
"https://api.ip.sb/geoip/": IpInfo.fromIpSbJson,
|
||||
"https://ipapi.co/json/": IpInfo.fromIpApiCoJson,
|
||||
"https://ipinfo.io/json/": IpInfo.fromIpInfoIoJson,
|
||||
};
|
||||
|
||||
Future<IpInfo?> checkIp(CancelToken? cancelToken) async {
|
||||
for (final source in _ipInfoSources.entries) {
|
||||
try {
|
||||
final response = await _dio
|
||||
.get<Map<String, dynamic>>(source.key, cancelToken: cancelToken)
|
||||
.timeout(
|
||||
httpTimeoutDuration,
|
||||
);
|
||||
if (response.statusCode == 200 && response.data != null) {
|
||||
return source.value(response.data!);
|
||||
}
|
||||
} catch (e) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
final request = Request();
|
||||
|
||||
@@ -6,6 +6,11 @@ extension TextStyleExtension on TextStyle {
|
||||
return copyWith(color: color?.toLight());
|
||||
}
|
||||
|
||||
toLighter() {
|
||||
return copyWith(color: color?.toLighter());
|
||||
}
|
||||
|
||||
|
||||
toSoftBold() {
|
||||
return copyWith(fontWeight: FontWeight.w500);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:fl_clash/enum/enum.dart';
|
||||
import 'package:fl_clash/state.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
@@ -39,8 +40,6 @@ class AppController {
|
||||
updateRunTime,
|
||||
updateTraffic,
|
||||
];
|
||||
clearShowProxyDelay();
|
||||
testShowProxyDelay();
|
||||
} else {
|
||||
await globalState.stopSystemProxy();
|
||||
appState.traffics = [];
|
||||
@@ -98,10 +97,12 @@ class AppController {
|
||||
}
|
||||
}
|
||||
|
||||
updateProfile(String id) async {
|
||||
Future<void> updateProfile(String id) async {
|
||||
final profile = config.getCurrentProfileForId(id);
|
||||
if (profile != null) {
|
||||
await profile.update();
|
||||
final tempProfile = profile.copyWith();
|
||||
await tempProfile.update();
|
||||
config.setProfile(tempProfile);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,16 +136,25 @@ class AppController {
|
||||
|
||||
autoUpdateProfiles() async {
|
||||
for (final profile in config.profiles) {
|
||||
if (!profile.autoUpdate) return;
|
||||
if (!profile.autoUpdate) continue;
|
||||
final isNotNeedUpdate = profile.lastUpdateDate
|
||||
?.add(
|
||||
profile.autoUpdateDuration,
|
||||
)
|
||||
.isBeforeNow;
|
||||
if (isNotNeedUpdate == false ||
|
||||
profile.url == null ||
|
||||
profile.url!.isEmpty) continue;
|
||||
await profile.update();
|
||||
if (isNotNeedUpdate == false || profile.type == ProfileType.file) {
|
||||
continue;
|
||||
}
|
||||
await updateProfile(profile.id);
|
||||
}
|
||||
}
|
||||
|
||||
updateProfiles() async {
|
||||
for (final profile in config.profiles) {
|
||||
if (profile.type == ProfileType.file) {
|
||||
continue;
|
||||
}
|
||||
await updateProfile(profile.id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -246,6 +256,29 @@ class AppController {
|
||||
}
|
||||
}
|
||||
|
||||
init() async {
|
||||
if (!config.silentLaunch) {
|
||||
window?.show();
|
||||
}
|
||||
final commonScaffoldState = globalState.homeScaffoldKey.currentState;
|
||||
if(commonScaffoldState?.mounted == true){
|
||||
await commonScaffoldState?.loadingRun(() async {
|
||||
await globalState.applyProfile(
|
||||
appState: appState,
|
||||
config: config,
|
||||
clashConfig: clashConfig,
|
||||
);
|
||||
});
|
||||
}else{
|
||||
await globalState.applyProfile(
|
||||
appState: appState,
|
||||
config: config,
|
||||
clashConfig: clashConfig,
|
||||
);
|
||||
}
|
||||
await afterInit();
|
||||
}
|
||||
|
||||
afterInit() async {
|
||||
if (config.autoRun) {
|
||||
await updateSystemProxy(true);
|
||||
@@ -255,25 +288,9 @@ class AppController {
|
||||
}
|
||||
autoUpdateProfiles();
|
||||
updateLogStatus();
|
||||
if (!config.silentLaunch) {
|
||||
window?.show();
|
||||
}
|
||||
autoCheckUpdate();
|
||||
}
|
||||
|
||||
healthcheck() {
|
||||
if (globalState.healthcheckLock) return;
|
||||
for (final delay in appState.delayMap.entries) {
|
||||
setDelay(
|
||||
Delay(
|
||||
name: delay.key,
|
||||
value: 0,
|
||||
),
|
||||
);
|
||||
}
|
||||
clashCore.healthcheck();
|
||||
}
|
||||
|
||||
setDelay(Delay delay) {
|
||||
appState.setDelay(delay);
|
||||
}
|
||||
@@ -383,22 +400,6 @@ class AppController {
|
||||
addProfileFormURL(url);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
updateViewWidth(double width) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
appState.viewWidth = width;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// ignore_for_file: constant_identifier_names
|
||||
|
||||
enum GroupType { Selector, URLTest, Fallback }
|
||||
enum GroupType { Selector, URLTest, Fallback, LoadBalance, Relay }
|
||||
|
||||
enum GroupName { GLOBAL, Proxy, Auto, Fallback }
|
||||
|
||||
|
||||
@@ -8,6 +8,13 @@ import 'package:fl_clash/widgets/widgets.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
extension AccessControlExtension on AccessControl {
|
||||
List<String> get currentList => switch (mode) {
|
||||
AccessControlMode.acceptSelected => acceptList,
|
||||
AccessControlMode.rejectSelected => rejectList,
|
||||
};
|
||||
}
|
||||
|
||||
class AccessFragment extends StatefulWidget {
|
||||
const AccessFragment({super.key});
|
||||
|
||||
@@ -83,136 +90,70 @@ class _AccessFragmentState extends State<AccessFragment> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSelectedAllButton({
|
||||
required bool isSelectedAll,
|
||||
required List<String> allValueList,
|
||||
}) {
|
||||
return Builder(
|
||||
builder: (context) {
|
||||
final tooltip = isSelectedAll
|
||||
? appLocalizations.cancelSelectAll
|
||||
: appLocalizations.selectAll;
|
||||
return IconButton(
|
||||
tooltip: tooltip,
|
||||
onPressed: () {
|
||||
final config = globalState.appController.config;
|
||||
final isAccept =
|
||||
config.accessControl.mode == AccessControlMode.acceptSelected;
|
||||
|
||||
if (isSelectedAll) {
|
||||
config.accessControl = switch (isAccept) {
|
||||
true => config.accessControl.copyWith(
|
||||
acceptList: [],
|
||||
),
|
||||
false => config.accessControl.copyWith(
|
||||
rejectList: [],
|
||||
),
|
||||
};
|
||||
} else {
|
||||
config.accessControl = switch (isAccept) {
|
||||
true => config.accessControl.copyWith(
|
||||
acceptList: allValueList,
|
||||
),
|
||||
false => config.accessControl.copyWith(
|
||||
rejectList: allValueList,
|
||||
),
|
||||
};
|
||||
}
|
||||
},
|
||||
icon: isSelectedAll
|
||||
? const Icon(Icons.deselect)
|
||||
: const Icon(Icons.select_all),
|
||||
);
|
||||
Widget _buildSearchButton(List<Package> packages) {
|
||||
return IconButton(
|
||||
tooltip: appLocalizations.search,
|
||||
onPressed: () {
|
||||
showSearch(
|
||||
context: context,
|
||||
delegate: AccessControlSearchDelegate(
|
||||
packages: packages,
|
||||
),
|
||||
).then((_) => {setState(() {})});
|
||||
},
|
||||
icon: const Icon(Icons.search),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _actionHeader({
|
||||
_buildSelectedAllButton({
|
||||
required bool isAccessControl,
|
||||
required List<String> valueList,
|
||||
required String describe,
|
||||
required List<String> packageNameList,
|
||||
required bool isSelectedAll,
|
||||
required List<String> allValueList,
|
||||
}) {
|
||||
return AbsorbPointer(
|
||||
absorbing: !isAccessControl,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 4,
|
||||
bottom: 4,
|
||||
left: 16,
|
||||
right: 8,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Expanded(
|
||||
child: IntrinsicHeight(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Row(
|
||||
children: [
|
||||
Flexible(
|
||||
child: Text(
|
||||
appLocalizations.selected,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.labelLarge
|
||||
?.copyWith(
|
||||
color:
|
||||
Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
),
|
||||
),
|
||||
const Flexible(
|
||||
child: SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
child: Text(
|
||||
"${valueList.length}",
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.labelLarge
|
||||
?.copyWith(
|
||||
color:
|
||||
Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
final tooltip = isSelectedAll
|
||||
? appLocalizations.cancelSelectAll
|
||||
: appLocalizations.selectAll;
|
||||
final commonScaffoldState =
|
||||
context.findAncestorStateOfType<CommonScaffoldState>();
|
||||
commonScaffoldState?.floatingActionButton = DisabledMask(
|
||||
status: !isAccessControl,
|
||||
child: AbsorbPointer(
|
||||
absorbing: !isAccessControl,
|
||||
child: FloatingActionButton (
|
||||
tooltip: tooltip,
|
||||
onPressed: () {
|
||||
final config = globalState.appController.config;
|
||||
final isAccept =
|
||||
config.accessControl.mode == AccessControlMode.acceptSelected;
|
||||
|
||||
if (isSelectedAll) {
|
||||
config.accessControl = switch (isAccept) {
|
||||
true => config.accessControl.copyWith(
|
||||
acceptList: [],
|
||||
),
|
||||
Flexible(
|
||||
child: Text(describe),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Flexible(
|
||||
child: _buildSelectedAllButton(
|
||||
isSelectedAll: const ListEquality<String>()
|
||||
.equals(valueList, packageNameList),
|
||||
allValueList: packageNameList,
|
||||
),
|
||||
),
|
||||
Flexible(child: _buildFilterSystemAppButton()),
|
||||
Flexible(child: _buildAppProxyModePopup()),
|
||||
],
|
||||
),
|
||||
],
|
||||
false => config.accessControl.copyWith(
|
||||
rejectList: [],
|
||||
),
|
||||
};
|
||||
} else {
|
||||
config.accessControl = switch (isAccept) {
|
||||
true => config.accessControl.copyWith(
|
||||
acceptList: allValueList,
|
||||
),
|
||||
false => config.accessControl.copyWith(
|
||||
rejectList: allValueList,
|
||||
),
|
||||
};
|
||||
}
|
||||
},
|
||||
child: isSelectedAll
|
||||
? const Icon(Icons.deselect)
|
||||
: const Icon(Icons.select_all),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Widget _buildPackageList() {
|
||||
@@ -252,14 +193,11 @@ class _AccessFragmentState extends State<AccessFragment> {
|
||||
accessControlMode == AccessControlMode.acceptSelected
|
||||
? acceptPackages
|
||||
: rejectPackages;
|
||||
final currentList =
|
||||
accessControlMode == AccessControlMode.acceptSelected
|
||||
? accessControl.acceptList
|
||||
: accessControl.rejectList;
|
||||
final currentList = accessControl.currentList;
|
||||
final currentPackages = isFilterSystemApp
|
||||
? packages
|
||||
.where((element) => element.isSystem == false)
|
||||
.toList()
|
||||
.where((element) => element.isSystem == false)
|
||||
.toList()
|
||||
: packages;
|
||||
final packageNameList =
|
||||
currentPackages.map((e) => e.packageName).toList();
|
||||
@@ -268,15 +206,91 @@ class _AccessFragmentState extends State<AccessFragment> {
|
||||
accessControlMode == AccessControlMode.acceptSelected
|
||||
? appLocalizations.accessControlAllowDesc
|
||||
: appLocalizations.accessControlNotAllowDesc;
|
||||
_buildSelectedAllButton(
|
||||
isAccessControl: isAccessControl,
|
||||
isSelectedAll: valueList.length == packageNameList.length,
|
||||
allValueList: packageNameList,
|
||||
);
|
||||
return DisabledMask(
|
||||
status: !isAccessControl,
|
||||
child: Column(
|
||||
children: [
|
||||
_actionHeader(
|
||||
isAccessControl: isAccessControl,
|
||||
valueList: valueList,
|
||||
describe: describe,
|
||||
packageNameList: packageNameList,
|
||||
AbsorbPointer(
|
||||
absorbing: !isAccessControl,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 4,
|
||||
bottom: 4,
|
||||
left: 16,
|
||||
right: 8,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Expanded(
|
||||
child: IntrinsicHeight(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Row(
|
||||
children: [
|
||||
Flexible(
|
||||
child: Text(
|
||||
appLocalizations.selected,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.labelLarge
|
||||
?.copyWith(
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.primary,
|
||||
),
|
||||
),
|
||||
),
|
||||
const Flexible(
|
||||
child: SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
child: Text(
|
||||
"${valueList.length}",
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.labelLarge
|
||||
?.copyWith(
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.primary,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
child: Text(describe),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Flexible(
|
||||
child: _buildSearchButton(currentPackages)),
|
||||
Flexible(child: _buildFilterSystemAppButton()),
|
||||
Flexible(child: _buildAppProxyModePopup()),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
@@ -429,3 +443,111 @@ class PackageListItem extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class AccessControlSearchDelegate extends SearchDelegate {
|
||||
final List<Package> packages;
|
||||
|
||||
AccessControlSearchDelegate({
|
||||
required this.packages,
|
||||
});
|
||||
|
||||
List<Package> get _results {
|
||||
final lowQuery = query.toLowerCase();
|
||||
return packages
|
||||
.where(
|
||||
(package) =>
|
||||
package.label.toLowerCase().contains(lowQuery) ||
|
||||
package.packageName.contains(lowQuery),
|
||||
)
|
||||
.toList();
|
||||
}
|
||||
|
||||
@override
|
||||
List<Widget>? buildActions(BuildContext context) {
|
||||
return [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
if (query.isEmpty) {
|
||||
close(context, null);
|
||||
return;
|
||||
}
|
||||
query = '';
|
||||
},
|
||||
icon: const Icon(Icons.clear),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
)
|
||||
];
|
||||
}
|
||||
|
||||
@override
|
||||
Widget? buildLeading(BuildContext context) {
|
||||
return IconButton(
|
||||
onPressed: () {
|
||||
close(context, null);
|
||||
},
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _packageList(List<Package> packages) {
|
||||
return Selector<Config, PackageListSelectorState>(
|
||||
selector: (_, config) => PackageListSelectorState(
|
||||
accessControl: config.accessControl,
|
||||
isAccessControl: config.isAccessControl,
|
||||
),
|
||||
builder: (context, state, __) {
|
||||
final accessControl = state.accessControl;
|
||||
final isAccessControl = state.isAccessControl;
|
||||
final accessControlMode = accessControl.mode;
|
||||
final currentList = accessControl.currentList;
|
||||
final packageNameList =
|
||||
this.packages.map((e) => e.packageName).toList();
|
||||
final valueList = currentList.intersection(packageNameList);
|
||||
return DisabledMask(
|
||||
status: !isAccessControl,
|
||||
child: ListView.builder(
|
||||
itemCount: packages.length,
|
||||
itemBuilder: (_, index) {
|
||||
final package = packages[index];
|
||||
return PackageListItem(
|
||||
key: Key(package.packageName),
|
||||
package: package,
|
||||
value: valueList.contains(package.packageName),
|
||||
isActive: isAccessControl,
|
||||
onChanged: (value) {
|
||||
if (value == true) {
|
||||
valueList.add(package.packageName);
|
||||
} else {
|
||||
valueList.remove(package.packageName);
|
||||
}
|
||||
final config = globalState.appController.config;
|
||||
if (accessControlMode == AccessControlMode.acceptSelected) {
|
||||
config.accessControl = config.accessControl.copyWith(
|
||||
acceptList: valueList,
|
||||
);
|
||||
} else {
|
||||
config.accessControl = config.accessControl.copyWith(
|
||||
rejectList: valueList,
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildResults(BuildContext context) {
|
||||
return buildSuggestions(context);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildSuggestions(BuildContext context) {
|
||||
return _packageList(_results);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:fl_clash/common/common.dart';
|
||||
import 'package:fl_clash/enum/enum.dart';
|
||||
import 'package:fl_clash/models/models.dart';
|
||||
@@ -44,9 +46,110 @@ class _ConfigFragmentState extends State<ConfigFragment> {
|
||||
globalState.appController.updateClashConfigDebounce();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
List<Widget> items = [
|
||||
_buildAppSection() {
|
||||
final items = [
|
||||
if (Platform.isAndroid)
|
||||
Selector<Config, bool>(
|
||||
selector: (_, config) => config.allowBypass,
|
||||
builder: (_, allowBypass, __) {
|
||||
return ListItem.switchItem(
|
||||
leading: const Icon(Icons.arrow_forward_outlined),
|
||||
title: Text(appLocalizations.allowBypass),
|
||||
subtitle: Text(appLocalizations.allowBypassDesc),
|
||||
delegate: SwitchDelegate(
|
||||
value: allowBypass,
|
||||
onChanged: (bool value) async {
|
||||
final appController = globalState.appController;
|
||||
appController.config.allowBypass = value;
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
if (Platform.isAndroid)
|
||||
Selector<Config, bool>(
|
||||
selector: (_, config) => config.systemProxy,
|
||||
builder: (_, systemProxy, __) {
|
||||
return ListItem.switchItem(
|
||||
leading: const Icon(Icons.settings_ethernet),
|
||||
title: Text(appLocalizations.systemProxy),
|
||||
subtitle: Text(appLocalizations.systemProxyDesc),
|
||||
delegate: SwitchDelegate(
|
||||
value: systemProxy,
|
||||
onChanged: (bool value) async {
|
||||
final appController = globalState.appController;
|
||||
appController.config.systemProxy = value;
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
Selector<Config, bool>(
|
||||
selector: (_, config) => config.isCompatible,
|
||||
builder: (_, isCompatible, __) {
|
||||
return ListItem.switchItem(
|
||||
leading: const Icon(Icons.expand_outlined),
|
||||
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();
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
];
|
||||
return Section(
|
||||
title: appLocalizations.app,
|
||||
child: Column(
|
||||
children: [
|
||||
for (final item in items) ...[
|
||||
item,
|
||||
if (items.last != item)
|
||||
const Divider(
|
||||
height: 0,
|
||||
)
|
||||
]
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
_buildGeneralSection() {
|
||||
final items = [
|
||||
Padding(
|
||||
padding: kMaterialListPadding,
|
||||
child: Selector<ClashConfig, LogLevel>(
|
||||
selector: (_, clashConfig) => clashConfig.logLevel,
|
||||
builder: (_, value, __) {
|
||||
return ListItem(
|
||||
leading: const Icon(Icons.info_outline),
|
||||
title: Text(appLocalizations.logLevel),
|
||||
trailing: SizedBox(
|
||||
height: 48,
|
||||
child: DropdownMenu<LogLevel>(
|
||||
width: 124,
|
||||
initialSelection: value,
|
||||
dropdownMenuEntries: [
|
||||
for (final logLevel in LogLevel.values)
|
||||
DropdownMenuEntry<LogLevel>(
|
||||
value: logLevel,
|
||||
label: logLevel.name,
|
||||
)
|
||||
],
|
||||
onSelected: _updateLoglevel,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
Selector<ClashConfig, int>(
|
||||
selector: (_, clashConfig) => clashConfig.mixedPort,
|
||||
builder: (_, mixedPort, __) {
|
||||
@@ -54,9 +157,9 @@ class _ConfigFragmentState extends State<ConfigFragment> {
|
||||
onTab: () {
|
||||
_modifyMixedPort(mixedPort);
|
||||
},
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16,vertical: 4),
|
||||
leading: const Icon(Icons.adjust),
|
||||
leading: const Icon(Icons.adjust_outlined),
|
||||
title: Text(appLocalizations.proxyPort),
|
||||
subtitle: Text(appLocalizations.proxyPortDesc),
|
||||
trailing: FilledButton.tonal(
|
||||
onPressed: () {
|
||||
_modifyMixedPort(mixedPort);
|
||||
@@ -68,6 +171,24 @@ class _ConfigFragmentState extends State<ConfigFragment> {
|
||||
);
|
||||
},
|
||||
),
|
||||
Selector<ClashConfig, bool>(
|
||||
selector: (_, clashConfig) => clashConfig.ipv6,
|
||||
builder: (_, ipv6, __) {
|
||||
return ListItem.switchItem(
|
||||
leading: const Icon(Icons.water_outlined),
|
||||
title: const Text("Ipv6"),
|
||||
subtitle: Text(appLocalizations.ipv6Desc),
|
||||
delegate: SwitchDelegate(
|
||||
value: ipv6,
|
||||
onChanged: (bool value) async {
|
||||
final appController = globalState.appController;
|
||||
appController.clashConfig.ipv6 = value;
|
||||
appController.updateClashConfigDebounce();
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
Selector<ClashConfig, bool>(
|
||||
selector: (_, clashConfig) => clashConfig.allowLan,
|
||||
builder: (_, allowLan, __) {
|
||||
@@ -86,92 +207,113 @@ class _ConfigFragmentState extends State<ConfigFragment> {
|
||||
);
|
||||
},
|
||||
),
|
||||
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<Config, bool>(
|
||||
selector: (_, config) => config.isCompatible,
|
||||
builder: (_, isCompatible, __) {
|
||||
Selector<ClashConfig, bool>(
|
||||
selector: (_, clashConfig) => clashConfig.unifiedDelay,
|
||||
builder: (_, unifiedDelay, __) {
|
||||
return ListItem.switchItem(
|
||||
leading: const Icon(Icons.expand),
|
||||
title: Text(appLocalizations.compatible),
|
||||
subtitle: Text(appLocalizations.compatibleDesc),
|
||||
leading: const Icon(Icons.compress_outlined),
|
||||
title: Text(appLocalizations.unifiedDelay),
|
||||
subtitle: Text(appLocalizations.unifiedDelayDesc),
|
||||
delegate: SwitchDelegate(
|
||||
value: isCompatible,
|
||||
value: unifiedDelay,
|
||||
onChanged: (bool value) async {
|
||||
final appController = globalState.appController;
|
||||
appController.config.isCompatible = value;
|
||||
await appController.updateClashConfig(isPatch: false);
|
||||
await appController.updateGroups();
|
||||
appController.changeProxy();
|
||||
appController.clashConfig.unifiedDelay = value;
|
||||
appController.updateClashConfigDebounce();
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
Padding(
|
||||
padding: kMaterialListPadding,
|
||||
child: Selector<ClashConfig, LogLevel>(
|
||||
selector: (_, clashConfig) => clashConfig.logLevel,
|
||||
builder: (_, value, __) {
|
||||
return ListItem(
|
||||
leading: const Icon(Icons.feedback),
|
||||
title: Text(appLocalizations.logLevel),
|
||||
trailing: SizedBox(
|
||||
height: 48,
|
||||
child: DropdownMenu<LogLevel>(
|
||||
width: 124,
|
||||
inputDecorationTheme: const InputDecorationTheme(
|
||||
filled: true,
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 5,
|
||||
horizontal: 16,
|
||||
),
|
||||
),
|
||||
initialSelection: value,
|
||||
dropdownMenuEntries: [
|
||||
for (final logLevel in LogLevel.values)
|
||||
DropdownMenuEntry<LogLevel>(
|
||||
value: logLevel,
|
||||
label: logLevel.name,
|
||||
)
|
||||
],
|
||||
onSelected: _updateLoglevel,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
Selector<ClashConfig, bool>(
|
||||
selector: (_, clashConfig) => clashConfig.tcpConcurrent,
|
||||
builder: (_, tcpConcurrent, __) {
|
||||
return ListItem.switchItem(
|
||||
leading: const Icon(Icons.double_arrow_outlined),
|
||||
title: Text(appLocalizations.tcpConcurrent),
|
||||
subtitle: Text(appLocalizations.tcpConcurrentDesc),
|
||||
delegate: SwitchDelegate(
|
||||
value: tcpConcurrent,
|
||||
onChanged: (bool value) async {
|
||||
final appController = globalState.appController;
|
||||
appController.clashConfig.tcpConcurrent = value;
|
||||
appController.updateClashConfigDebounce();
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
Selector<ClashConfig, bool>(
|
||||
selector: (_, clashConfig) =>
|
||||
clashConfig.geodataLoader == geodataLoaderMemconservative,
|
||||
builder: (_, memconservative, __) {
|
||||
return ListItem.switchItem(
|
||||
leading: const Icon(Icons.memory),
|
||||
title: Text(appLocalizations.geodataLoader),
|
||||
subtitle: Text(appLocalizations.geodataLoaderDesc),
|
||||
delegate: SwitchDelegate(
|
||||
value: memconservative,
|
||||
onChanged: (bool value) async {
|
||||
final appController = globalState.appController;
|
||||
appController.clashConfig.geodataLoader = value
|
||||
? geodataLoaderMemconservative
|
||||
: geodataLoaderStandard;
|
||||
appController.updateClashConfigDebounce;
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
Selector<ClashConfig, bool>(
|
||||
selector: (_, clashConfig) => clashConfig.externalController.isNotEmpty,
|
||||
builder: (_, hasExternalController, __) {
|
||||
return ListItem.switchItem(
|
||||
leading: const Icon(Icons.api_outlined),
|
||||
title: Text(appLocalizations.externalController),
|
||||
subtitle: Text(appLocalizations.externalControllerDesc),
|
||||
delegate: SwitchDelegate(
|
||||
value: hasExternalController,
|
||||
onChanged: (bool value) async {
|
||||
final appController = globalState.appController;
|
||||
appController.clashConfig.externalController =
|
||||
value ? defaultExternalController : '';
|
||||
appController.updateClashConfigDebounce;
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
];
|
||||
return ListView.separated(
|
||||
return Section(
|
||||
title: appLocalizations.general,
|
||||
child: Column(
|
||||
children: [
|
||||
for (final item in items) ...[
|
||||
item,
|
||||
if (items.last != item)
|
||||
const Divider(
|
||||
height: 0,
|
||||
)
|
||||
]
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
List<Widget> items = [
|
||||
_buildAppSection(),
|
||||
_buildGeneralSection(),
|
||||
];
|
||||
return ListView.builder(
|
||||
padding: const EdgeInsets.only(bottom: 16),
|
||||
itemBuilder: (_, index) {
|
||||
return Container(
|
||||
alignment: Alignment.center,
|
||||
child: items[index],
|
||||
);
|
||||
},
|
||||
separatorBuilder: (_, __) {
|
||||
return const Divider(
|
||||
height: 0,
|
||||
);
|
||||
},
|
||||
itemCount: items.length,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'package:country_flags/country_flags.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:fl_clash/common/common.dart';
|
||||
import 'package:fl_clash/models/models.dart';
|
||||
import 'package:fl_clash/state.dart';
|
||||
@@ -13,118 +15,162 @@ class NetworkDetection extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _NetworkDetectionState extends State<NetworkDetection> {
|
||||
Widget _buildDescription(String? currentProxyName, int? delay) {
|
||||
if (currentProxyName == null) {
|
||||
return TooltipText(
|
||||
text: Text(
|
||||
appLocalizations.noProxyDesc,
|
||||
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
);
|
||||
final ipInfoNotifier = ValueNotifier<IpInfo?>(null);
|
||||
final timeoutNotifier = ValueNotifier<bool>(false);
|
||||
bool? _preIsStart;
|
||||
CancelToken? cancelToken;
|
||||
|
||||
_checkIp(
|
||||
bool isInit,
|
||||
bool isStart,
|
||||
) async {
|
||||
if (!isInit) return;
|
||||
timeoutNotifier.value = false;
|
||||
if (_preIsStart == false && _preIsStart == isStart) return;
|
||||
if (cancelToken != null) {
|
||||
cancelToken!.cancel();
|
||||
cancelToken = null;
|
||||
}
|
||||
if (delay == 0 || delay == null) {
|
||||
return const AspectRatio(
|
||||
aspectRatio: 1,
|
||||
child: CircularProgressIndicator(
|
||||
strokeCap: StrokeCap.round,
|
||||
),
|
||||
);
|
||||
ipInfoNotifier.value = null;
|
||||
final ipInfo = await request.checkIp(cancelToken);
|
||||
if (ipInfo == null) {
|
||||
timeoutNotifier.value = true;
|
||||
return;
|
||||
} else {
|
||||
timeoutNotifier.value = false;
|
||||
}
|
||||
if (delay > 0) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
TooltipText(
|
||||
text: Text(
|
||||
"$delay",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 1,
|
||||
style: context.textTheme.titleLarge
|
||||
?.copyWith(
|
||||
color: context.colorScheme.primary,
|
||||
)
|
||||
.toSoftBold(),
|
||||
),
|
||||
),
|
||||
const Flexible(
|
||||
child: SizedBox(
|
||||
width: 4,
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
flex: 0,
|
||||
child: Text(
|
||||
'ms',
|
||||
style: Theme.of(context).textTheme.bodyMedium?.toLight(),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
return Text(
|
||||
"Timeout",
|
||||
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
||||
color: Colors.red,
|
||||
),
|
||||
_preIsStart = isStart;
|
||||
ipInfoNotifier.value = ipInfo;
|
||||
}
|
||||
|
||||
_checkIpContainer(Widget child) {
|
||||
return Selector2<AppState, Config, CheckIpSelectorState>(
|
||||
selector: (_, appState, config) {
|
||||
return CheckIpSelectorState(
|
||||
isInit: appState.isInit,
|
||||
selectedMap: appState.selectedMap,
|
||||
isStart: appState.isStart,
|
||||
);
|
||||
},
|
||||
builder: (_, state, __) {
|
||||
_checkIp(state.isInit, state.isStart);
|
||||
return child;
|
||||
},
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CommonCard(
|
||||
info: Info(
|
||||
iconData: Icons.network_check,
|
||||
label: appLocalizations.networkDetection,
|
||||
),
|
||||
child: Selector<AppState, NetworkDetectionSelectorState>(
|
||||
selector: (_, appState) {
|
||||
return NetworkDetectionSelectorState(
|
||||
currentProxyName: appState.showProxyName,
|
||||
delay: appState.getDelay(
|
||||
appState.showProxyName,
|
||||
),
|
||||
);
|
||||
},
|
||||
builder: (_, state, __) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16).copyWith(top: 0),
|
||||
return _checkIpContainer(
|
||||
ValueListenableBuilder<IpInfo?>(
|
||||
valueListenable: ipInfoNotifier,
|
||||
builder: (_, ipInfo, __) {
|
||||
return CommonCard(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Flexible(
|
||||
flex: 0,
|
||||
child: TooltipText(
|
||||
text: Text(
|
||||
state.currentProxyName ?? appLocalizations.noProxy,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
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,
|
||||
),
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.network_check,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: FadeBox(
|
||||
child: ipInfo != null
|
||||
? CountryFlag.fromCountryCode(
|
||||
ipInfo.countryCode,
|
||||
width: 24,
|
||||
height: 24,
|
||||
)
|
||||
: ValueListenableBuilder(
|
||||
valueListenable: timeoutNotifier,
|
||||
builder: (_, timeout, __) {
|
||||
if (timeout) {
|
||||
return Text(
|
||||
appLocalizations.checkError,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.titleMedium,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
);
|
||||
}
|
||||
return TooltipText(
|
||||
text: Text(
|
||||
appLocalizations.checking,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.titleMedium,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
height:
|
||||
globalState.appController.measure.titleLargeHeight + 24,
|
||||
alignment: Alignment.centerLeft,
|
||||
padding: const EdgeInsets.all(16).copyWith(top: 0),
|
||||
child: FadeBox(
|
||||
child: ipInfo != null
|
||||
? Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: TooltipText(
|
||||
text: Text(
|
||||
ipInfo.ip,
|
||||
style: context.textTheme.titleLarge
|
||||
?.toSoftBold(),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
: ValueListenableBuilder(
|
||||
valueListenable: timeoutNotifier,
|
||||
builder: (_, timeout, __) {
|
||||
if (timeout) {
|
||||
return Text(
|
||||
"timeout",
|
||||
style: context.textTheme.titleMedium
|
||||
?.copyWith(color: Colors.red)
|
||||
.toSoftBold(),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
);
|
||||
}
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(2),
|
||||
child: const AspectRatio(
|
||||
aspectRatio: 1,
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@@ -19,7 +19,7 @@ class _StartButtonState extends State<StartButton>
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
isStart = context.read<AppState>().runTime != null;
|
||||
isStart = globalState.appController.appState.isStart;
|
||||
_controller = AnimationController(
|
||||
vsync: this,
|
||||
value: isStart ? 1 : 0,
|
||||
@@ -48,9 +48,11 @@ class _StartButtonState extends State<StartButton>
|
||||
}
|
||||
}
|
||||
|
||||
updateSystemProxy() async {
|
||||
final appController = globalState.appController;
|
||||
await appController.updateSystemProxy(isStart);
|
||||
updateSystemProxy() {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||
final appController = globalState.appController;
|
||||
await appController.updateSystemProxy(isStart);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -56,6 +56,9 @@ class _LogsFragmentState extends State<LogsFragment> {
|
||||
);
|
||||
},
|
||||
icon: const Icon(Icons.search),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
)
|
||||
];
|
||||
});
|
||||
@@ -139,6 +142,9 @@ class LogsSearchDelegate extends SearchDelegate {
|
||||
},
|
||||
icon: const Icon(Icons.clear),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
)
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:fl_clash/common/common.dart';
|
||||
import 'package:fl_clash/enum/enum.dart';
|
||||
import 'package:fl_clash/models/models.dart';
|
||||
import 'package:fl_clash/state.dart';
|
||||
import 'package:fl_clash/widgets/widgets.dart';
|
||||
@@ -40,7 +41,7 @@ class _EditProfileState extends State<EditProfile> {
|
||||
_handleConfirm() {
|
||||
if (!_formKey.currentState!.validate()) return;
|
||||
final config = widget.context.read<Config>();
|
||||
final hasUpdate = widget.profile.url != urlController.text;
|
||||
final hasUpdate = urlController.text.isNotEmpty && widget.profile.url != urlController.text;
|
||||
widget.profile.url = urlController.text;
|
||||
widget.profile.label = labelController.text;
|
||||
widget.profile.autoUpdate = autoUpdate;
|
||||
@@ -82,7 +83,7 @@ class _EditProfileState extends State<EditProfile> {
|
||||
},
|
||||
),
|
||||
),
|
||||
if (widget.profile.url != null)...[
|
||||
if (widget.profile.type == ProfileType.url)...[
|
||||
ListItem(
|
||||
title: TextFormField(
|
||||
controller: urlController,
|
||||
@@ -151,6 +152,7 @@ class _EditProfileState extends State<EditProfile> {
|
||||
vertical: 16,
|
||||
),
|
||||
child: ListView.separated(
|
||||
primary: true,
|
||||
itemBuilder: (_, index) {
|
||||
return items[index];
|
||||
},
|
||||
|
||||
@@ -25,15 +25,7 @@ class ProfilesFragment extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _ProfilesFragmentState extends State<ProfilesFragment> {
|
||||
_handleDeleteProfile(String id) async {
|
||||
globalState.appController.deleteProfile(id);
|
||||
}
|
||||
|
||||
_handleUpdateProfile(String id) async {
|
||||
context.findAncestorStateOfType<CommonScaffoldState>()?.loadingRun(
|
||||
() => globalState.appController.updateProfile(id),
|
||||
);
|
||||
}
|
||||
final hasPadding = ValueNotifier<bool>(false);
|
||||
|
||||
_handleShowAddExtendPage() {
|
||||
showExtendPage(
|
||||
@@ -45,76 +37,6 @@ class _ProfilesFragmentState extends State<ProfilesFragment> {
|
||||
);
|
||||
}
|
||||
|
||||
_handleShowEditExtendPage(Profile profile) {
|
||||
showExtendPage(
|
||||
context,
|
||||
body: EditProfile(
|
||||
profile: profile.copyWith(),
|
||||
context: context,
|
||||
),
|
||||
title: "${appLocalizations.edit}${appLocalizations.profile}",
|
||||
);
|
||||
}
|
||||
|
||||
_buildGrid({
|
||||
required ProfilesSelectorState state,
|
||||
int crossAxisCount = 1,
|
||||
}) {
|
||||
return SingleChildScrollView(
|
||||
padding: crossAxisCount > 1
|
||||
? const EdgeInsets.symmetric(horizontal: 16)
|
||||
: EdgeInsets.zero,
|
||||
child: Grid.baseGap(
|
||||
crossAxisCount: crossAxisCount,
|
||||
children: [
|
||||
for (final profile in state.profiles)
|
||||
GridItem(
|
||||
child: ProfileItem(
|
||||
profile: profile,
|
||||
commonPopupMenu: CommonPopupMenu<ProfileActions>(
|
||||
items: [
|
||||
CommonPopupMenuItem(
|
||||
action: ProfileActions.edit,
|
||||
label: appLocalizations.edit,
|
||||
iconData: Icons.edit,
|
||||
),
|
||||
if (profile.url != null)
|
||||
CommonPopupMenuItem(
|
||||
action: ProfileActions.update,
|
||||
label: appLocalizations.update,
|
||||
iconData: Icons.sync,
|
||||
),
|
||||
CommonPopupMenuItem(
|
||||
action: ProfileActions.delete,
|
||||
label: appLocalizations.delete,
|
||||
iconData: Icons.delete,
|
||||
),
|
||||
],
|
||||
onSelected: (ProfileActions? action) async {
|
||||
switch (action) {
|
||||
case ProfileActions.edit:
|
||||
_handleShowEditExtendPage(profile);
|
||||
break;
|
||||
case ProfileActions.delete:
|
||||
_handleDeleteProfile(profile.id);
|
||||
break;
|
||||
case ProfileActions.update:
|
||||
_handleUpdateProfile(profile.id);
|
||||
break;
|
||||
case null:
|
||||
break;
|
||||
}
|
||||
},
|
||||
),
|
||||
groupValue: state.currentProfileId,
|
||||
onChanged: globalState.appController.changeProfile,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
_getColumns(ViewMode viewMode) {
|
||||
switch (viewMode) {
|
||||
case ViewMode.mobile:
|
||||
@@ -126,33 +48,104 @@ class _ProfilesFragmentState extends State<ProfilesFragment> {
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return FloatLayout(
|
||||
floatingWidget: Container(
|
||||
margin: const EdgeInsets.all(kFloatingActionButtonMargin),
|
||||
child: FloatingActionButton(
|
||||
_initScaffoldState() {
|
||||
WidgetsBinding.instance.addPostFrameCallback(
|
||||
(_) {
|
||||
final commonScaffoldState =
|
||||
context.findAncestorStateOfType<CommonScaffoldState>();
|
||||
commonScaffoldState?.actions = [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
commonScaffoldState.loadingRun<void>(
|
||||
() async {
|
||||
await globalState.appController.updateProfiles();
|
||||
},
|
||||
);
|
||||
},
|
||||
icon: const Icon(Icons.sync),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
)
|
||||
];
|
||||
commonScaffoldState?.floatingActionButton = FloatingActionButton(
|
||||
heroTag: null,
|
||||
onPressed: _handleShowAddExtendPage,
|
||||
child: const Icon(Icons.add),
|
||||
),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.add,
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Selector<AppState, bool>(
|
||||
selector: (_, appState) => appState.currentLabel == 'profiles',
|
||||
builder: (_, isCurrent, child) {
|
||||
if (isCurrent) {
|
||||
_initScaffoldState();
|
||||
}
|
||||
return child!;
|
||||
},
|
||||
child: Selector2<AppState, Config, ProfilesSelectorState>(
|
||||
selector: (_, appState, config) => ProfilesSelectorState(
|
||||
profiles: config.profiles,
|
||||
currentProfileId: config.currentProfileId,
|
||||
viewMode: appState.viewMode),
|
||||
profiles: config.profiles,
|
||||
currentProfileId: config.currentProfileId,
|
||||
viewMode: appState.viewMode,
|
||||
),
|
||||
builder: (context, state, child) {
|
||||
if (state.profiles.isEmpty) {
|
||||
return NullStatus(
|
||||
label: appLocalizations.nullProfileDesc,
|
||||
);
|
||||
}
|
||||
final columns = _getColumns(state.viewMode);
|
||||
final isMobile = state.viewMode == ViewMode.mobile;
|
||||
return Align(
|
||||
alignment: Alignment.topCenter,
|
||||
child: _buildGrid(
|
||||
state: state,
|
||||
crossAxisCount: _getColumns(state.viewMode),
|
||||
child: NotificationListener<ScrollNotification>(
|
||||
onNotification: (scrollNotification) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
hasPadding.value =
|
||||
scrollNotification.metrics.maxScrollExtent > 0;
|
||||
});
|
||||
return true;
|
||||
},
|
||||
child: ValueListenableBuilder(
|
||||
valueListenable: hasPadding,
|
||||
builder: (_, hasPadding, __) {
|
||||
return SingleChildScrollView(
|
||||
padding: !isMobile
|
||||
? EdgeInsets.only(
|
||||
left: 16,
|
||||
right: 16,
|
||||
top: 16,
|
||||
bottom: 16 + (hasPadding ? 56 : 0),
|
||||
)
|
||||
: EdgeInsets.only(
|
||||
bottom: 0 + (hasPadding ? 56 : 0),
|
||||
),
|
||||
child: Grid(
|
||||
mainAxisSpacing: isMobile ? 8 : 16,
|
||||
crossAxisSpacing: 16,
|
||||
crossAxisCount: columns,
|
||||
children: [
|
||||
for (final profile in state.profiles)
|
||||
GridItem(
|
||||
child: ProfileItem(
|
||||
profile: profile,
|
||||
groupValue: state.currentProfileId,
|
||||
onChanged:
|
||||
globalState.appController.changeProfile,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
@@ -161,92 +154,188 @@ class _ProfilesFragmentState extends State<ProfilesFragment> {
|
||||
}
|
||||
}
|
||||
|
||||
class ProfileItem extends StatelessWidget {
|
||||
class ProfileItem extends StatefulWidget {
|
||||
final Profile profile;
|
||||
final String? groupValue;
|
||||
final CommonPopupMenu commonPopupMenu;
|
||||
final void Function(String? value) onChanged;
|
||||
|
||||
const ProfileItem({
|
||||
super.key,
|
||||
required this.profile,
|
||||
required this.commonPopupMenu,
|
||||
required this.groupValue,
|
||||
required this.onChanged,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
String useShow;
|
||||
String totalShow;
|
||||
double progress;
|
||||
final userInfo = profile.userInfo;
|
||||
if (userInfo == null) {
|
||||
useShow = "Infinite";
|
||||
totalShow = "Infinite";
|
||||
progress = 1;
|
||||
} else {
|
||||
final use = userInfo.upload + userInfo.download;
|
||||
final total = userInfo.total;
|
||||
useShow = TrafficValue(value: use).show;
|
||||
totalShow = TrafficValue(value: total).show;
|
||||
progress = total == 0 ? 0.0 : use / total;
|
||||
}
|
||||
return ListItem.radio(
|
||||
horizontalTitleGap: 16,
|
||||
delegate: RadioDelegate<String?>(
|
||||
value: profile.id,
|
||||
groupValue: groupValue,
|
||||
onChanged: onChanged,
|
||||
State<ProfileItem> createState() => _ProfileItemState();
|
||||
}
|
||||
|
||||
class _ProfileItemState extends State<ProfileItem> {
|
||||
final isUpdating = ValueNotifier<bool>(false);
|
||||
|
||||
_handleDeleteProfile(String id) async {
|
||||
globalState.appController.deleteProfile(id);
|
||||
}
|
||||
|
||||
_handleUpdateProfile(String id) async {
|
||||
isUpdating.value = true;
|
||||
await globalState.safeRun<void>(() async {
|
||||
await globalState.appController.updateProfile(id);
|
||||
});
|
||||
isUpdating.value = false;
|
||||
}
|
||||
|
||||
_handleShowEditExtendPage(
|
||||
Profile profile,
|
||||
) {
|
||||
showExtendPage(
|
||||
context,
|
||||
body: EditProfile(
|
||||
profile: profile.copyWith(),
|
||||
context: context,
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
trailing: commonPopupMenu,
|
||||
title: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
title: "${appLocalizations.edit}${appLocalizations.profile}",
|
||||
);
|
||||
}
|
||||
|
||||
_buildTitle(Profile profile) {
|
||||
final textTheme = context.textTheme;
|
||||
final userInfo = profile.userInfo ?? UserInfo();
|
||||
final use = userInfo.upload + userInfo.download;
|
||||
final total = userInfo.total;
|
||||
final useShow = TrafficValue(value: use).show;
|
||||
final totalShow = TrafficValue(value: total).show;
|
||||
final progress = total == 0 ? 0.0 : use / total;
|
||||
final expireShow = userInfo.expire == 0
|
||||
? "长期有效"
|
||||
: DateTime.fromMillisecondsSinceEpoch(userInfo.expire * 1000).show;
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Flexible(
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Flexible(
|
||||
child: Text(
|
||||
profile.label ?? profile.id,
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
child: Text(
|
||||
profile.lastUpdateDate?.lastUpdateTimeDesc ?? '',
|
||||
style: Theme.of(context).textTheme.labelMedium?.toLight(),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
child: Container(
|
||||
margin: const EdgeInsets.symmetric(
|
||||
vertical: 8,
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
profile.label ?? profile.id,
|
||||
style: textTheme.titleMedium,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
child: LinearProgressIndicator(
|
||||
minHeight: 6,
|
||||
value: progress,
|
||||
Text(
|
||||
profile.lastUpdateDate?.lastUpdateTimeDesc ?? '',
|
||||
style: textTheme.labelMedium?.toLight(),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Flexible(
|
||||
child: Text(
|
||||
"$useShow / $totalShow",
|
||||
style: Theme.of(context).textTheme.labelMedium?.toLight(),
|
||||
),
|
||||
Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
margin: const EdgeInsets.symmetric(
|
||||
vertical: 8,
|
||||
),
|
||||
child: LinearProgressIndicator(
|
||||
minHeight: 6,
|
||||
value: progress,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"$useShow / $totalShow",
|
||||
style: textTheme.labelMedium?.toLight(),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 2,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
"到期时间:",
|
||||
style: textTheme.labelMedium?.toLighter(),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 4,
|
||||
),
|
||||
Text(
|
||||
expireShow,
|
||||
style: textTheme.labelMedium?.toLighter(),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final profile = widget.profile;
|
||||
final groupValue = widget.groupValue;
|
||||
final onChanged = widget.onChanged;
|
||||
return Selector<AppState, ViewMode>(
|
||||
selector: (_, appState) => appState.viewMode,
|
||||
builder: (_, viewMode, child) {
|
||||
if (viewMode == ViewMode.mobile) {
|
||||
return child!;
|
||||
}
|
||||
return CommonCard(
|
||||
child: child!,
|
||||
);
|
||||
},
|
||||
child: ListItem.radio(
|
||||
key: Key(profile.id),
|
||||
horizontalTitleGap: 16,
|
||||
delegate: RadioDelegate<String?>(
|
||||
value: profile.id,
|
||||
groupValue: groupValue,
|
||||
onChanged: onChanged,
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
trailing: CommonPopupMenu<ProfileActions>(
|
||||
items: [
|
||||
CommonPopupMenuItem(
|
||||
action: ProfileActions.edit,
|
||||
label: appLocalizations.edit,
|
||||
iconData: Icons.edit,
|
||||
),
|
||||
if (profile.type == ProfileType.url)
|
||||
CommonPopupMenuItem(
|
||||
action: ProfileActions.update,
|
||||
label: appLocalizations.update,
|
||||
iconData: Icons.sync,
|
||||
),
|
||||
CommonPopupMenuItem(
|
||||
action: ProfileActions.delete,
|
||||
label: appLocalizations.delete,
|
||||
iconData: Icons.delete,
|
||||
),
|
||||
],
|
||||
onSelected: (ProfileActions? action) async {
|
||||
switch (action) {
|
||||
case ProfileActions.edit:
|
||||
_handleShowEditExtendPage(profile);
|
||||
break;
|
||||
case ProfileActions.delete:
|
||||
_handleDeleteProfile(profile.id);
|
||||
break;
|
||||
case ProfileActions.update:
|
||||
_handleUpdateProfile(profile.id);
|
||||
break;
|
||||
case null:
|
||||
break;
|
||||
}
|
||||
},
|
||||
),
|
||||
title: _buildTitle(profile),
|
||||
tileTitleAlignment: ListTileTitleAlignment.titleHeight,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:fl_clash/clash/clash.dart';
|
||||
import 'package:fl_clash/state.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
@@ -50,6 +51,9 @@ class _ProxiesFragmentState extends State<ProxiesFragment>
|
||||
selectedValue: proxiesSortType,
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
)
|
||||
];
|
||||
});
|
||||
@@ -57,72 +61,69 @@ class _ProxiesFragmentState extends State<ProxiesFragment>
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return DelayTestButtonContainer(
|
||||
child: Selector<AppState, bool>(
|
||||
selector: (_, appState) => appState.currentLabel == 'proxies',
|
||||
builder: (_, isCurrent, child) {
|
||||
if (isCurrent) {
|
||||
_initActions();
|
||||
}
|
||||
return child!;
|
||||
return Selector<AppState, bool>(
|
||||
selector: (_, appState) => appState.currentLabel == 'proxies',
|
||||
builder: (_, isCurrent, child) {
|
||||
if (isCurrent) {
|
||||
_initActions();
|
||||
}
|
||||
return child!;
|
||||
},
|
||||
child: Selector3<AppState, Config, ClashConfig, ProxiesSelectorState>(
|
||||
selector: (_, appState, config, clashConfig) {
|
||||
final currentGroups = appState.currentGroups;
|
||||
final groupNames = currentGroups.map((e) => e.name).toList();
|
||||
return ProxiesSelectorState(
|
||||
groupNames: groupNames,
|
||||
);
|
||||
},
|
||||
child: Selector3<AppState, Config, ClashConfig, ProxiesSelectorState>(
|
||||
selector: (_, appState, config, clashConfig) {
|
||||
final currentGroups = appState.currentGroups;
|
||||
final groupNames = currentGroups.map((e) => e.name).toList();
|
||||
return ProxiesSelectorState(
|
||||
groupNames: groupNames,
|
||||
);
|
||||
},
|
||||
shouldRebuild: (prev, next) {
|
||||
if (prev.groupNames.length != next.groupNames.length) {
|
||||
_tabController?.dispose();
|
||||
_tabController = null;
|
||||
}
|
||||
return prev != next;
|
||||
},
|
||||
builder: (_, state, __) {
|
||||
_tabController ??= TabController(
|
||||
length: state.groupNames.length,
|
||||
vsync: this,
|
||||
);
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
TabBar(
|
||||
shouldRebuild: (prev, next) {
|
||||
if (prev.groupNames.length != next.groupNames.length) {
|
||||
_tabController?.dispose();
|
||||
_tabController = null;
|
||||
}
|
||||
return prev != next;
|
||||
},
|
||||
builder: (_, state, __) {
|
||||
_tabController ??= TabController(
|
||||
length: state.groupNames.length,
|
||||
vsync: this,
|
||||
);
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
TabBar(
|
||||
controller: _tabController,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
dividerColor: Colors.transparent,
|
||||
isScrollable: true,
|
||||
tabAlignment: TabAlignment.start,
|
||||
overlayColor: const WidgetStatePropertyAll(Colors.transparent),
|
||||
tabs: [
|
||||
for (final groupName in state.groupNames)
|
||||
Tab(
|
||||
text: groupName,
|
||||
),
|
||||
],
|
||||
),
|
||||
Expanded(
|
||||
child: TabBarView(
|
||||
controller: _tabController,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
dividerColor: Colors.transparent,
|
||||
isScrollable: true,
|
||||
tabAlignment: TabAlignment.start,
|
||||
overlayColor:
|
||||
const WidgetStatePropertyAll(Colors.transparent),
|
||||
tabs: [
|
||||
children: [
|
||||
for (final groupName in state.groupNames)
|
||||
Tab(
|
||||
text: groupName,
|
||||
KeepContainer(
|
||||
key: ObjectKey(groupName),
|
||||
child: ProxiesTabView(
|
||||
groupName: groupName,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Expanded(
|
||||
child: TabBarView(
|
||||
controller: _tabController,
|
||||
children: [
|
||||
for (final groupName in state.groupNames)
|
||||
KeepContainer(
|
||||
key: ObjectKey(groupName),
|
||||
child: ProxiesTabView(
|
||||
groupName: groupName,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -196,6 +197,23 @@ class ProxiesTabView extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
_delayTest(List<Proxy> proxies) async {
|
||||
for (final proxy in proxies) {
|
||||
final appController = globalState.appController;
|
||||
final proxyName = appController.appState.getRealProxyName(proxy.name) ?? proxy.name;
|
||||
globalState.appController.setDelay(
|
||||
Delay(
|
||||
name: proxyName,
|
||||
value: 0,
|
||||
),
|
||||
);
|
||||
clashCore.getDelay(proxyName).then((delay) {
|
||||
globalState.appController.setDelay(delay);
|
||||
});
|
||||
}
|
||||
await Future.delayed(httpTimeoutDuration + moreDuration);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Selector2<AppState, Config, ProxiesTabViewSelectorState>(
|
||||
@@ -213,25 +231,32 @@ class ProxiesTabView extends StatelessWidget {
|
||||
state.group.all,
|
||||
state.proxiesSortType,
|
||||
);
|
||||
return Align(
|
||||
alignment: Alignment.topCenter,
|
||||
child: GridView.builder(
|
||||
padding: const EdgeInsets.all(16),
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: _getColumns(state.viewMode),
|
||||
mainAxisSpacing: 8,
|
||||
crossAxisSpacing: 8,
|
||||
mainAxisExtent: _getItemHeight(context),
|
||||
return DelayTestButtonContainer(
|
||||
onClick: () async {
|
||||
await _delayTest(
|
||||
state.group.all,
|
||||
);
|
||||
},
|
||||
child: Align(
|
||||
alignment: Alignment.topCenter,
|
||||
child: GridView.builder(
|
||||
padding: const EdgeInsets.all(16),
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: _getColumns(state.viewMode),
|
||||
mainAxisSpacing: 8,
|
||||
crossAxisSpacing: 8,
|
||||
mainAxisExtent: _getItemHeight(context),
|
||||
),
|
||||
itemCount: proxies.length,
|
||||
itemBuilder: (_, index) {
|
||||
final proxy = proxies[index];
|
||||
return ProxyCard(
|
||||
key: ValueKey('$groupName.${proxy.name}'),
|
||||
proxy: proxy,
|
||||
groupName: groupName,
|
||||
);
|
||||
},
|
||||
),
|
||||
itemCount: proxies.length,
|
||||
itemBuilder: (_, index) {
|
||||
final proxy = proxies[index];
|
||||
return ProxyCard(
|
||||
key: ValueKey('$groupName.${proxy.name}'),
|
||||
proxy: proxy,
|
||||
groupName: groupName,
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
@@ -384,10 +409,12 @@ class ProxyCard extends StatelessWidget {
|
||||
|
||||
class DelayTestButtonContainer extends StatefulWidget {
|
||||
final Widget child;
|
||||
final Future Function() onClick;
|
||||
|
||||
const DelayTestButtonContainer({
|
||||
super.key,
|
||||
required this.child,
|
||||
required this.onClick,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -401,12 +428,9 @@ class _DelayTestButtonContainerState extends State<DelayTestButtonContainer>
|
||||
late Animation<double> _scale;
|
||||
|
||||
_healthcheck() async {
|
||||
if (globalState.healthcheckLock) return;
|
||||
_controller.forward();
|
||||
globalState.appController.healthcheck();
|
||||
Future.delayed(httpTimeoutDuration + moreDuration, () {
|
||||
_controller.reverse();
|
||||
});
|
||||
await widget.onClick();
|
||||
_controller.reverse();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -415,7 +439,7 @@ class _DelayTestButtonContainerState extends State<DelayTestButtonContainer>
|
||||
_controller = AnimationController(
|
||||
vsync: this,
|
||||
duration: const Duration(
|
||||
milliseconds: 600,
|
||||
milliseconds: 200,
|
||||
),
|
||||
);
|
||||
_scale = Tween<double>(
|
||||
@@ -427,7 +451,6 @@ class _DelayTestButtonContainerState extends State<DelayTestButtonContainer>
|
||||
curve: const Interval(
|
||||
0,
|
||||
1,
|
||||
curve: Curves.elasticInOut,
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -441,6 +464,7 @@ class _DelayTestButtonContainerState extends State<DelayTestButtonContainer>
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
_controller.reverse();
|
||||
return FloatLayout(
|
||||
floatingWidget: FloatWrapper(
|
||||
child: AnimatedBuilder(
|
||||
|
||||
@@ -166,6 +166,7 @@ class _ToolboxFragmentState extends State<ToolsFragment> {
|
||||
delegate: OpenDelegate(
|
||||
title: appLocalizations.override,
|
||||
widget: const ConfigFragment(),
|
||||
extendPageWidth: 360,
|
||||
),
|
||||
),
|
||||
ListItem.open(
|
||||
|
||||
@@ -111,6 +111,7 @@
|
||||
"noMoreInfoDesc": "No more info",
|
||||
"profileParseErrorDesc": "profile parse error",
|
||||
"proxyPort": "ProxyPort",
|
||||
"proxyPortDesc": "Set the clash listening port",
|
||||
"port": "Port",
|
||||
"logLevel": "LogLevel",
|
||||
"show": "Show",
|
||||
@@ -156,5 +157,24 @@
|
||||
"goDownload": "Go to download",
|
||||
"unknown": "Unknown",
|
||||
"geoData": "GeoData",
|
||||
"externalResources": "External resources"
|
||||
"externalResources": "External resources",
|
||||
"checking": "Checking...",
|
||||
"country": "Country",
|
||||
"checkError": "Check error",
|
||||
"ipCheckTimeout": "Ip check timeout",
|
||||
"search": "Search",
|
||||
"allowBypass": "Allow applications to bypass VPN",
|
||||
"allowBypassDesc": "Some apps can bypass VPN when turned on",
|
||||
"externalController": "ExternalController",
|
||||
"externalControllerDesc": "Once enabled, the clash kernel can be controlled on port 9090",
|
||||
"ipv6Desc": "When turned on it will be able to receive ipv6 traffic",
|
||||
"app": "App",
|
||||
"general": "General",
|
||||
"systemProxyDesc": "Attach HTTP proxy to VpnService",
|
||||
"unifiedDelay": "Unified delay",
|
||||
"unifiedDelayDesc": "Remove extra delays such as handshaking",
|
||||
"tcpConcurrent": "Tcp concurrent",
|
||||
"tcpConcurrentDesc": "Enabling it will allow tcp concurrency",
|
||||
"geodataLoader": "Geo Low Memory Mode",
|
||||
"geodataLoaderDesc": "Enabling will use the Geo low memory loader"
|
||||
}
|
||||
@@ -111,6 +111,7 @@
|
||||
"noMoreInfoDesc": "暂无更多信息",
|
||||
"profileParseErrorDesc": "配置文件解析错误",
|
||||
"proxyPort": "代理端口",
|
||||
"proxyPortDesc": "设置clash监听端口",
|
||||
"port": "端口",
|
||||
"logLevel": "日志等级",
|
||||
"show": "显示",
|
||||
@@ -156,5 +157,24 @@
|
||||
"goDownload": "前往下载",
|
||||
"unknown": "未知",
|
||||
"geoData": "地理数据",
|
||||
"externalResources": "外部资源"
|
||||
"externalResources": "外部资源",
|
||||
"checking": "检测中...",
|
||||
"country": "区域",
|
||||
"checkError": "检测失败",
|
||||
"ipCheckTimeout": "Ip检测超时",
|
||||
"search": "搜索",
|
||||
"allowBypass": "允许应用绕过vpn",
|
||||
"allowBypassDesc": "开启后部分应用可绕过VPN",
|
||||
"externalController": "外部控制器",
|
||||
"externalControllerDesc": "开启后将可以通过9090端口控制clash内核",
|
||||
"ipv6Desc": "开启后将可以接收ipv6流量",
|
||||
"app": "应用",
|
||||
"general": "基础",
|
||||
"systemProxyDesc": "为VpnService附加HTTP代理",
|
||||
"unifiedDelay": "统一延迟",
|
||||
"unifiedDelayDesc": "去除握手等额外延迟",
|
||||
"tcpConcurrent": "TCP并发",
|
||||
"tcpConcurrentDesc": "开启后允许tcp并发",
|
||||
"geodataLoader": "Geo低内存模式",
|
||||
"geodataLoaderDesc": "开启将使用Geo低内存加载器"
|
||||
}
|
||||
@@ -40,9 +40,14 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"addressTip": MessageLookupByLibrary.simpleMessage(
|
||||
"Please enter a valid WebDAV address"),
|
||||
"ago": MessageLookupByLibrary.simpleMessage(" Ago"),
|
||||
"allowBypass": MessageLookupByLibrary.simpleMessage(
|
||||
"Allow applications to bypass VPN"),
|
||||
"allowBypassDesc": MessageLookupByLibrary.simpleMessage(
|
||||
"Some apps can bypass VPN when turned on"),
|
||||
"allowLan": MessageLookupByLibrary.simpleMessage("AllowLan"),
|
||||
"allowLanDesc": MessageLookupByLibrary.simpleMessage(
|
||||
"Allow access proxy through the LAN"),
|
||||
"app": MessageLookupByLibrary.simpleMessage("App"),
|
||||
"appAccessControl":
|
||||
MessageLookupByLibrary.simpleMessage("App access control"),
|
||||
"application": MessageLookupByLibrary.simpleMessage("Application"),
|
||||
@@ -76,10 +81,12 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
MessageLookupByLibrary.simpleMessage("Cancel filter system app"),
|
||||
"cancelSelectAll":
|
||||
MessageLookupByLibrary.simpleMessage("Cancel select all"),
|
||||
"checkError": MessageLookupByLibrary.simpleMessage("Check error"),
|
||||
"checkUpdate":
|
||||
MessageLookupByLibrary.simpleMessage("Check for updates"),
|
||||
"checkUpdateError": MessageLookupByLibrary.simpleMessage(
|
||||
"The current application is already the latest version"),
|
||||
"checking": MessageLookupByLibrary.simpleMessage("Checking..."),
|
||||
"compatible":
|
||||
MessageLookupByLibrary.simpleMessage("Compatibility mode"),
|
||||
"compatibleDesc": MessageLookupByLibrary.simpleMessage(
|
||||
@@ -88,6 +95,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"connectivity": MessageLookupByLibrary.simpleMessage("Connectivity:"),
|
||||
"core": MessageLookupByLibrary.simpleMessage("Core"),
|
||||
"coreInfo": MessageLookupByLibrary.simpleMessage("Core info"),
|
||||
"country": MessageLookupByLibrary.simpleMessage("Country"),
|
||||
"create": MessageLookupByLibrary.simpleMessage("Create"),
|
||||
"dark": MessageLookupByLibrary.simpleMessage("Dark"),
|
||||
"dashboard": MessageLookupByLibrary.simpleMessage("Dashboard"),
|
||||
@@ -109,6 +117,10 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"edit": MessageLookupByLibrary.simpleMessage("Edit"),
|
||||
"en": MessageLookupByLibrary.simpleMessage("English"),
|
||||
"exit": MessageLookupByLibrary.simpleMessage("Exit"),
|
||||
"externalController":
|
||||
MessageLookupByLibrary.simpleMessage("ExternalController"),
|
||||
"externalControllerDesc": MessageLookupByLibrary.simpleMessage(
|
||||
"Once enabled, the clash kernel can be controlled on port 9090"),
|
||||
"externalResources":
|
||||
MessageLookupByLibrary.simpleMessage("External resources"),
|
||||
"file": MessageLookupByLibrary.simpleMessage("File"),
|
||||
@@ -116,12 +128,21 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
MessageLookupByLibrary.simpleMessage("Directly upload profile"),
|
||||
"filterSystemApp":
|
||||
MessageLookupByLibrary.simpleMessage("Filter system app"),
|
||||
"general": MessageLookupByLibrary.simpleMessage("General"),
|
||||
"geoData": MessageLookupByLibrary.simpleMessage("GeoData"),
|
||||
"geodataLoader":
|
||||
MessageLookupByLibrary.simpleMessage("Geo Low Memory Mode"),
|
||||
"geodataLoaderDesc": MessageLookupByLibrary.simpleMessage(
|
||||
"Enabling will use the Geo low memory loader"),
|
||||
"global": MessageLookupByLibrary.simpleMessage("Global"),
|
||||
"goDownload": MessageLookupByLibrary.simpleMessage("Go to download"),
|
||||
"hours": MessageLookupByLibrary.simpleMessage("Hours"),
|
||||
"importFromURL":
|
||||
MessageLookupByLibrary.simpleMessage("Import from URL"),
|
||||
"ipCheckTimeout":
|
||||
MessageLookupByLibrary.simpleMessage("Ip check timeout"),
|
||||
"ipv6Desc": MessageLookupByLibrary.simpleMessage(
|
||||
"When turned on it will be able to receive ipv6 traffic"),
|
||||
"just": MessageLookupByLibrary.simpleMessage("Just"),
|
||||
"language": MessageLookupByLibrary.simpleMessage("Language"),
|
||||
"light": MessageLookupByLibrary.simpleMessage("Light"),
|
||||
@@ -190,6 +211,8 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"project": MessageLookupByLibrary.simpleMessage("Project"),
|
||||
"proxies": MessageLookupByLibrary.simpleMessage("Proxies"),
|
||||
"proxyPort": MessageLookupByLibrary.simpleMessage("ProxyPort"),
|
||||
"proxyPortDesc": MessageLookupByLibrary.simpleMessage(
|
||||
"Set the clash listening port"),
|
||||
"qrcode": MessageLookupByLibrary.simpleMessage("QR code"),
|
||||
"qrcodeDesc": MessageLookupByLibrary.simpleMessage(
|
||||
"Scan QR code to obtain profile"),
|
||||
@@ -207,6 +230,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"External resource related info"),
|
||||
"rule": MessageLookupByLibrary.simpleMessage("Rule"),
|
||||
"save": MessageLookupByLibrary.simpleMessage("Save"),
|
||||
"search": MessageLookupByLibrary.simpleMessage("Search"),
|
||||
"selectAll": MessageLookupByLibrary.simpleMessage("Select all"),
|
||||
"selected": MessageLookupByLibrary.simpleMessage("Selected"),
|
||||
"settings": MessageLookupByLibrary.simpleMessage("Settings"),
|
||||
@@ -218,9 +242,14 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"stopVpn": MessageLookupByLibrary.simpleMessage("Stopping VPN..."),
|
||||
"submit": MessageLookupByLibrary.simpleMessage("Submit"),
|
||||
"systemProxy": MessageLookupByLibrary.simpleMessage("SystemProxy"),
|
||||
"systemProxyDesc": MessageLookupByLibrary.simpleMessage(
|
||||
"Attach HTTP proxy to VpnService"),
|
||||
"tabAnimation": MessageLookupByLibrary.simpleMessage("Tab animation"),
|
||||
"tabAnimationDesc": MessageLookupByLibrary.simpleMessage(
|
||||
"When enabled, the home tab will add a toggle animation"),
|
||||
"tcpConcurrent": MessageLookupByLibrary.simpleMessage("Tcp concurrent"),
|
||||
"tcpConcurrentDesc": MessageLookupByLibrary.simpleMessage(
|
||||
"Enabling it will allow tcp concurrency"),
|
||||
"theme": MessageLookupByLibrary.simpleMessage("Theme"),
|
||||
"themeColor": MessageLookupByLibrary.simpleMessage("Theme color"),
|
||||
"themeDesc": MessageLookupByLibrary.simpleMessage(
|
||||
@@ -235,6 +264,9 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"unableToUpdateCurrentProfileDesc":
|
||||
MessageLookupByLibrary.simpleMessage(
|
||||
"unable to update current profile"),
|
||||
"unifiedDelay": MessageLookupByLibrary.simpleMessage("Unified delay"),
|
||||
"unifiedDelayDesc": MessageLookupByLibrary.simpleMessage(
|
||||
"Remove extra delays such as handshaking"),
|
||||
"unknown": MessageLookupByLibrary.simpleMessage("Unknown"),
|
||||
"update": MessageLookupByLibrary.simpleMessage("Update"),
|
||||
"upload": MessageLookupByLibrary.simpleMessage("Upload"),
|
||||
|
||||
@@ -36,8 +36,12 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"addressHelp": MessageLookupByLibrary.simpleMessage("WebDAV服务器地址"),
|
||||
"addressTip": MessageLookupByLibrary.simpleMessage("请输入有效的WebDAV地址"),
|
||||
"ago": MessageLookupByLibrary.simpleMessage("前"),
|
||||
"allowBypass": MessageLookupByLibrary.simpleMessage("允许应用绕过vpn"),
|
||||
"allowBypassDesc":
|
||||
MessageLookupByLibrary.simpleMessage("开启后部分应用可绕过VPN"),
|
||||
"allowLan": MessageLookupByLibrary.simpleMessage("局域网代理"),
|
||||
"allowLanDesc": MessageLookupByLibrary.simpleMessage("允许通过局域网访问代理"),
|
||||
"app": MessageLookupByLibrary.simpleMessage("应用"),
|
||||
"appAccessControl": MessageLookupByLibrary.simpleMessage("应用访问控制"),
|
||||
"application": MessageLookupByLibrary.simpleMessage("应用程序"),
|
||||
"applicationDesc": MessageLookupByLibrary.simpleMessage("修改应用程序相关设置"),
|
||||
@@ -63,8 +67,10 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"cancelFilterSystemApp":
|
||||
MessageLookupByLibrary.simpleMessage("取消过滤系统应用"),
|
||||
"cancelSelectAll": MessageLookupByLibrary.simpleMessage("取消全选"),
|
||||
"checkError": MessageLookupByLibrary.simpleMessage("检测失败"),
|
||||
"checkUpdate": MessageLookupByLibrary.simpleMessage("检查更新"),
|
||||
"checkUpdateError": MessageLookupByLibrary.simpleMessage("当前应用已经是最新版了"),
|
||||
"checking": MessageLookupByLibrary.simpleMessage("检测中..."),
|
||||
"compatible": MessageLookupByLibrary.simpleMessage("兼容模式"),
|
||||
"compatibleDesc":
|
||||
MessageLookupByLibrary.simpleMessage("开启将失去部分应用能力,获得全量的Clash的支持"),
|
||||
@@ -72,6 +78,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"connectivity": MessageLookupByLibrary.simpleMessage("连通性:"),
|
||||
"core": MessageLookupByLibrary.simpleMessage("内核"),
|
||||
"coreInfo": MessageLookupByLibrary.simpleMessage("内核信息"),
|
||||
"country": MessageLookupByLibrary.simpleMessage("区域"),
|
||||
"create": MessageLookupByLibrary.simpleMessage("创建"),
|
||||
"dark": MessageLookupByLibrary.simpleMessage("深色"),
|
||||
"dashboard": MessageLookupByLibrary.simpleMessage("仪表盘"),
|
||||
@@ -90,15 +97,24 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"edit": MessageLookupByLibrary.simpleMessage("编辑"),
|
||||
"en": MessageLookupByLibrary.simpleMessage("英语"),
|
||||
"exit": MessageLookupByLibrary.simpleMessage("退出"),
|
||||
"externalController": MessageLookupByLibrary.simpleMessage("外部控制器"),
|
||||
"externalControllerDesc":
|
||||
MessageLookupByLibrary.simpleMessage("开启后将可以通过9090端口控制clash内核"),
|
||||
"externalResources": MessageLookupByLibrary.simpleMessage("外部资源"),
|
||||
"file": MessageLookupByLibrary.simpleMessage("文件"),
|
||||
"fileDesc": MessageLookupByLibrary.simpleMessage("直接上传配置文件"),
|
||||
"filterSystemApp": MessageLookupByLibrary.simpleMessage("过滤系统应用"),
|
||||
"general": MessageLookupByLibrary.simpleMessage("基础"),
|
||||
"geoData": MessageLookupByLibrary.simpleMessage("地理数据"),
|
||||
"geodataLoader": MessageLookupByLibrary.simpleMessage("Geo低内存模式"),
|
||||
"geodataLoaderDesc":
|
||||
MessageLookupByLibrary.simpleMessage("开启将使用Geo低内存加载器"),
|
||||
"global": MessageLookupByLibrary.simpleMessage("全局"),
|
||||
"goDownload": MessageLookupByLibrary.simpleMessage("前往下载"),
|
||||
"hours": MessageLookupByLibrary.simpleMessage("小时"),
|
||||
"importFromURL": MessageLookupByLibrary.simpleMessage("从URL导入"),
|
||||
"ipCheckTimeout": MessageLookupByLibrary.simpleMessage("Ip检测超时"),
|
||||
"ipv6Desc": MessageLookupByLibrary.simpleMessage("开启后将可以接收ipv6流量"),
|
||||
"just": MessageLookupByLibrary.simpleMessage("刚刚"),
|
||||
"language": MessageLookupByLibrary.simpleMessage("语言"),
|
||||
"light": MessageLookupByLibrary.simpleMessage("浅色"),
|
||||
@@ -156,6 +172,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"project": MessageLookupByLibrary.simpleMessage("项目"),
|
||||
"proxies": MessageLookupByLibrary.simpleMessage("代理"),
|
||||
"proxyPort": MessageLookupByLibrary.simpleMessage("代理端口"),
|
||||
"proxyPortDesc": MessageLookupByLibrary.simpleMessage("设置clash监听端口"),
|
||||
"qrcode": MessageLookupByLibrary.simpleMessage("二维码"),
|
||||
"qrcodeDesc": MessageLookupByLibrary.simpleMessage("扫描二维码获取配置文件"),
|
||||
"recovery": MessageLookupByLibrary.simpleMessage("恢复"),
|
||||
@@ -167,6 +184,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"resourcesDesc": MessageLookupByLibrary.simpleMessage("外部资源相关信息"),
|
||||
"rule": MessageLookupByLibrary.simpleMessage("规则"),
|
||||
"save": MessageLookupByLibrary.simpleMessage("保存"),
|
||||
"search": MessageLookupByLibrary.simpleMessage("搜索"),
|
||||
"selectAll": MessageLookupByLibrary.simpleMessage("全选"),
|
||||
"selected": MessageLookupByLibrary.simpleMessage("已选择"),
|
||||
"settings": MessageLookupByLibrary.simpleMessage("设置"),
|
||||
@@ -177,9 +195,13 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"stopVpn": MessageLookupByLibrary.simpleMessage("正在停止VPN..."),
|
||||
"submit": MessageLookupByLibrary.simpleMessage("提交"),
|
||||
"systemProxy": MessageLookupByLibrary.simpleMessage("系统代理"),
|
||||
"systemProxyDesc":
|
||||
MessageLookupByLibrary.simpleMessage("为VpnService附加HTTP代理"),
|
||||
"tabAnimation": MessageLookupByLibrary.simpleMessage("选项卡动画"),
|
||||
"tabAnimationDesc":
|
||||
MessageLookupByLibrary.simpleMessage("开启后,主页选项卡将添加切换动画"),
|
||||
"tcpConcurrent": MessageLookupByLibrary.simpleMessage("TCP并发"),
|
||||
"tcpConcurrentDesc": MessageLookupByLibrary.simpleMessage("开启后允许tcp并发"),
|
||||
"theme": MessageLookupByLibrary.simpleMessage("主题"),
|
||||
"themeColor": MessageLookupByLibrary.simpleMessage("主题色彩"),
|
||||
"themeDesc": MessageLookupByLibrary.simpleMessage("设置深色模式,调整色彩"),
|
||||
@@ -191,6 +213,8 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"tunDesc": MessageLookupByLibrary.simpleMessage("仅在管理员模式生效"),
|
||||
"unableToUpdateCurrentProfileDesc":
|
||||
MessageLookupByLibrary.simpleMessage("无法更新当前配置文件"),
|
||||
"unifiedDelay": MessageLookupByLibrary.simpleMessage("统一延迟"),
|
||||
"unifiedDelayDesc": MessageLookupByLibrary.simpleMessage("去除握手等额外延迟"),
|
||||
"unknown": MessageLookupByLibrary.simpleMessage("未知"),
|
||||
"update": MessageLookupByLibrary.simpleMessage("更新"),
|
||||
"upload": MessageLookupByLibrary.simpleMessage("上传"),
|
||||
|
||||
@@ -1170,6 +1170,16 @@ class AppLocalizations {
|
||||
);
|
||||
}
|
||||
|
||||
/// `Set the clash listening port`
|
||||
String get proxyPortDesc {
|
||||
return Intl.message(
|
||||
'Set the clash listening port',
|
||||
name: 'proxyPortDesc',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Port`
|
||||
String get port {
|
||||
return Intl.message(
|
||||
@@ -1629,6 +1639,196 @@ class AppLocalizations {
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Checking...`
|
||||
String get checking {
|
||||
return Intl.message(
|
||||
'Checking...',
|
||||
name: 'checking',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Country`
|
||||
String get country {
|
||||
return Intl.message(
|
||||
'Country',
|
||||
name: 'country',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Check error`
|
||||
String get checkError {
|
||||
return Intl.message(
|
||||
'Check error',
|
||||
name: 'checkError',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Ip check timeout`
|
||||
String get ipCheckTimeout {
|
||||
return Intl.message(
|
||||
'Ip check timeout',
|
||||
name: 'ipCheckTimeout',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Search`
|
||||
String get search {
|
||||
return Intl.message(
|
||||
'Search',
|
||||
name: 'search',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Allow applications to bypass VPN`
|
||||
String get allowBypass {
|
||||
return Intl.message(
|
||||
'Allow applications to bypass VPN',
|
||||
name: 'allowBypass',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Some apps can bypass VPN when turned on`
|
||||
String get allowBypassDesc {
|
||||
return Intl.message(
|
||||
'Some apps can bypass VPN when turned on',
|
||||
name: 'allowBypassDesc',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `ExternalController`
|
||||
String get externalController {
|
||||
return Intl.message(
|
||||
'ExternalController',
|
||||
name: 'externalController',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Once enabled, the clash kernel can be controlled on port 9090`
|
||||
String get externalControllerDesc {
|
||||
return Intl.message(
|
||||
'Once enabled, the clash kernel can be controlled on port 9090',
|
||||
name: 'externalControllerDesc',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `When turned on it will be able to receive ipv6 traffic`
|
||||
String get ipv6Desc {
|
||||
return Intl.message(
|
||||
'When turned on it will be able to receive ipv6 traffic',
|
||||
name: 'ipv6Desc',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `App`
|
||||
String get app {
|
||||
return Intl.message(
|
||||
'App',
|
||||
name: 'app',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `General`
|
||||
String get general {
|
||||
return Intl.message(
|
||||
'General',
|
||||
name: 'general',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Attach HTTP proxy to VpnService`
|
||||
String get systemProxyDesc {
|
||||
return Intl.message(
|
||||
'Attach HTTP proxy to VpnService',
|
||||
name: 'systemProxyDesc',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Unified delay`
|
||||
String get unifiedDelay {
|
||||
return Intl.message(
|
||||
'Unified delay',
|
||||
name: 'unifiedDelay',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Remove extra delays such as handshaking`
|
||||
String get unifiedDelayDesc {
|
||||
return Intl.message(
|
||||
'Remove extra delays such as handshaking',
|
||||
name: 'unifiedDelayDesc',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Tcp concurrent`
|
||||
String get tcpConcurrent {
|
||||
return Intl.message(
|
||||
'Tcp concurrent',
|
||||
name: 'tcpConcurrent',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Enabling it will allow tcp concurrency`
|
||||
String get tcpConcurrentDesc {
|
||||
return Intl.message(
|
||||
'Enabling it will allow tcp concurrency',
|
||||
name: 'tcpConcurrentDesc',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Geo Low Memory Mode`
|
||||
String get geodataLoader {
|
||||
return Intl.message(
|
||||
'Geo Low Memory Mode',
|
||||
name: 'geodataLoader',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Enabling will use the Geo low memory loader`
|
||||
String get geodataLoaderDesc {
|
||||
return Intl.message(
|
||||
'Enabling will use the Geo low memory loader',
|
||||
name: 'geodataLoaderDesc',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class AppLocalizationDelegate extends LocalizationsDelegate<AppLocalizations> {
|
||||
|
||||
@@ -22,16 +22,16 @@ Future<void> main() async {
|
||||
isCompatible: config.isCompatible,
|
||||
selectedMap: config.currentSelectedMap,
|
||||
);
|
||||
appState.navigationItems = navigation.getItems(
|
||||
openLogs: config.openLogs,
|
||||
hasProxies: false,
|
||||
);
|
||||
await globalState.init(
|
||||
appState: appState,
|
||||
config: config,
|
||||
clashConfig: clashConfig,
|
||||
);
|
||||
globalState.updateNavigationItems(
|
||||
appState: appState,
|
||||
config: config,
|
||||
clashConfig: clashConfig,
|
||||
);
|
||||
|
||||
runAppWithPreferences(
|
||||
const Application(),
|
||||
appState: appState,
|
||||
@@ -61,6 +61,16 @@ Future<void> vpnService() async {
|
||||
clashConfig: clashConfig,
|
||||
);
|
||||
|
||||
if (appState.isInit) {
|
||||
await globalState.applyProfile(
|
||||
appState: appState,
|
||||
config: config,
|
||||
clashConfig: clashConfig,
|
||||
);
|
||||
} else {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
final appLocalizations = await AppLocalizations.load(
|
||||
other.getLocaleForString(config.locale) ??
|
||||
WidgetsBinding.instance.platformDispatcher.locale,
|
||||
|
||||
@@ -89,6 +89,8 @@ class AppState with ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
bool get isStart => _runTime != null;
|
||||
|
||||
int? get runTime => _runTime;
|
||||
|
||||
set runTime(int? value) {
|
||||
@@ -105,7 +107,7 @@ class AppState with ChangeNotifier {
|
||||
} else {
|
||||
final index = groups.indexWhere((element) => element.name == proxyName);
|
||||
if (index == -1) return type;
|
||||
return "$type(${groups[index].now})";
|
||||
return "$type(${groups[index].now ?? '*'})";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,7 +168,7 @@ class AppState with ChangeNotifier {
|
||||
|
||||
addLog(Log log) {
|
||||
_logs.add(log);
|
||||
if(_logs.length > 60){
|
||||
if (_logs.length > 60) {
|
||||
_logs = _logs.sublist(_logs.length - 60);
|
||||
}
|
||||
notifyListeners();
|
||||
|
||||
@@ -108,8 +108,13 @@ class Dns {
|
||||
class ClashConfig extends ChangeNotifier {
|
||||
int _mixedPort;
|
||||
bool _allowLan;
|
||||
Mode _mode;
|
||||
bool _ipv6;
|
||||
String _geodataLoader;
|
||||
LogLevel _logLevel;
|
||||
String _externalController;
|
||||
Mode _mode;
|
||||
bool _unifiedDelay;
|
||||
bool _tcpConcurrent;
|
||||
Tun _tun;
|
||||
Dns _dns;
|
||||
List<String> _rules;
|
||||
@@ -118,15 +123,25 @@ class ClashConfig extends ChangeNotifier {
|
||||
int? mixedPort,
|
||||
Mode? mode,
|
||||
bool? allowLan,
|
||||
bool? ipv6,
|
||||
LogLevel? logLevel,
|
||||
String? externalController,
|
||||
String? geodataLoader,
|
||||
bool? unifiedDelay,
|
||||
Tun? tun,
|
||||
Dns? dns,
|
||||
bool? tcpConcurrent,
|
||||
List<String>? rules,
|
||||
}) : _mixedPort = mixedPort ?? 7890,
|
||||
_mode = mode ?? Mode.rule,
|
||||
_ipv6 = ipv6 ?? false,
|
||||
_allowLan = allowLan ?? false,
|
||||
_tcpConcurrent = tcpConcurrent ?? false,
|
||||
_logLevel = logLevel ?? LogLevel.info,
|
||||
_tun = tun ?? const Tun(),
|
||||
_unifiedDelay = unifiedDelay ?? false,
|
||||
_geodataLoader = geodataLoader ?? geodataLoaderMemconservative,
|
||||
_externalController = externalController ?? '',
|
||||
_dns = dns ?? Dns(),
|
||||
_rules = rules ?? [];
|
||||
|
||||
@@ -169,6 +184,56 @@ class ClashConfig extends ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
@JsonKey(name: "external-controller", defaultValue: '')
|
||||
String get externalController => _externalController;
|
||||
|
||||
set externalController(String value) {
|
||||
if (_externalController != value) {
|
||||
_externalController = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
@JsonKey(defaultValue: false)
|
||||
bool get ipv6 => _ipv6;
|
||||
|
||||
set ipv6(bool value) {
|
||||
if (_ipv6 != value) {
|
||||
_ipv6 = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
@JsonKey(name: "geodata-loader", defaultValue: geodataLoaderMemconservative)
|
||||
String get geodataLoader => _geodataLoader;
|
||||
|
||||
set geodataLoader(String value) {
|
||||
if (_geodataLoader != value) {
|
||||
_geodataLoader = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
@JsonKey(name: "unified-delay", defaultValue: false)
|
||||
bool get unifiedDelay => _unifiedDelay;
|
||||
|
||||
set unifiedDelay(bool value) {
|
||||
if (_unifiedDelay != value) {
|
||||
_unifiedDelay = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
@JsonKey(name: "tcp-concurrent", defaultValue: false)
|
||||
bool get tcpConcurrent => _tcpConcurrent;
|
||||
|
||||
set tcpConcurrent(bool value) {
|
||||
if (_tcpConcurrent != value) {
|
||||
_tcpConcurrent = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
Tun get tun => _tun;
|
||||
|
||||
set tun(Tun value) {
|
||||
|
||||
@@ -8,6 +8,7 @@ import '../common/common.dart';
|
||||
import 'models.dart';
|
||||
|
||||
part 'generated/config.g.dart';
|
||||
|
||||
part 'generated/config.freezed.dart';
|
||||
|
||||
@freezed
|
||||
@@ -23,6 +24,18 @@ class AccessControl with _$AccessControl {
|
||||
_$AccessControlFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
class Props with _$Props {
|
||||
const factory Props({
|
||||
AccessControl? accessControl,
|
||||
bool? allowBypass,
|
||||
bool? systemProxy,
|
||||
}) = _Props;
|
||||
|
||||
factory Props.fromJson(Map<String, Object?> json) =>
|
||||
_$PropsFromJson(json);
|
||||
}
|
||||
|
||||
@JsonSerializable()
|
||||
class Config extends ChangeNotifier {
|
||||
List<Profile> _profiles;
|
||||
@@ -41,6 +54,8 @@ class Config extends ChangeNotifier {
|
||||
AccessControl _accessControl;
|
||||
bool _isAnimateToPage;
|
||||
bool _autoCheckUpdate;
|
||||
bool _allowBypass;
|
||||
bool _systemProxy;
|
||||
DAV? _dav;
|
||||
|
||||
Config()
|
||||
@@ -56,8 +71,10 @@ class Config extends ChangeNotifier {
|
||||
_isMinimizeOnExit = true,
|
||||
_isAccessControl = false,
|
||||
_autoCheckUpdate = true,
|
||||
_systemProxy = false,
|
||||
_accessControl = const AccessControl(),
|
||||
_isAnimateToPage = true;
|
||||
_isAnimateToPage = true,
|
||||
_allowBypass = true;
|
||||
|
||||
deleteProfileById(String id) {
|
||||
_profiles = profiles.where((element) => element.id != id).toList();
|
||||
@@ -305,8 +322,34 @@ class Config extends ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
update(
|
||||
[Config? config, RecoveryOption recoveryOptions = RecoveryOption.all]) {
|
||||
@JsonKey(defaultValue: true)
|
||||
bool get allowBypass {
|
||||
return _allowBypass;
|
||||
}
|
||||
|
||||
set allowBypass(bool value) {
|
||||
if (_allowBypass != value) {
|
||||
_allowBypass = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
@JsonKey(defaultValue: true)
|
||||
bool get systemProxy {
|
||||
return _systemProxy;
|
||||
}
|
||||
|
||||
set systemProxy(bool value) {
|
||||
if (_systemProxy != value) {
|
||||
_systemProxy = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
update([
|
||||
Config? config,
|
||||
RecoveryOption recoveryOptions = RecoveryOption.all,
|
||||
]) {
|
||||
if (config != null) {
|
||||
_profiles = config._profiles;
|
||||
for (final profile in config._profiles) {
|
||||
@@ -325,6 +368,7 @@ class Config extends ChangeNotifier {
|
||||
_openLog = config._openLog;
|
||||
_themeMode = config._themeMode;
|
||||
_locale = config._locale;
|
||||
_allowBypass = config._allowBypass;
|
||||
_primaryColor = config._primaryColor;
|
||||
_proxiesSortType = config._proxiesSortType;
|
||||
_isMinimizeOnExit = config._isMinimizeOnExit;
|
||||
|
||||
@@ -39,13 +39,18 @@ ClashConfig _$ClashConfigFromJson(Map<String, dynamic> json) => ClashConfig(
|
||||
mixedPort: (json['mixed-port'] as num?)?.toInt(),
|
||||
mode: $enumDecodeNullable(_$ModeEnumMap, json['mode']),
|
||||
allowLan: json['allow-lan'] as bool?,
|
||||
ipv6: json['ipv6'] as bool? ?? false,
|
||||
logLevel: $enumDecodeNullable(_$LogLevelEnumMap, json['log-level']),
|
||||
externalController: json['external-controller'] as String? ?? '',
|
||||
geodataLoader: json['geodata-loader'] as String? ?? 'memconservative',
|
||||
unifiedDelay: json['unified-delay'] as bool? ?? false,
|
||||
tun: json['tun'] == null
|
||||
? null
|
||||
: Tun.fromJson(json['tun'] as Map<String, dynamic>),
|
||||
dns: json['dns'] == null
|
||||
? null
|
||||
: Dns.fromJson(json['dns'] as Map<String, dynamic>),
|
||||
tcpConcurrent: json['tcp-concurrent'] as bool? ?? false,
|
||||
rules:
|
||||
(json['rules'] as List<dynamic>?)?.map((e) => e as String).toList(),
|
||||
);
|
||||
@@ -56,6 +61,11 @@ Map<String, dynamic> _$ClashConfigToJson(ClashConfig instance) =>
|
||||
'mode': _$ModeEnumMap[instance.mode]!,
|
||||
'allow-lan': instance.allowLan,
|
||||
'log-level': _$LogLevelEnumMap[instance.logLevel]!,
|
||||
'external-controller': instance.externalController,
|
||||
'ipv6': instance.ipv6,
|
||||
'geodata-loader': instance.geodataLoader,
|
||||
'unified-delay': instance.unifiedDelay,
|
||||
'tcp-concurrent': instance.tcpConcurrent,
|
||||
'tun': instance.tun,
|
||||
'dns': instance.dns,
|
||||
'rules': instance.rules,
|
||||
|
||||
@@ -239,3 +239,193 @@ abstract class _AccessControl implements AccessControl {
|
||||
_$$AccessControlImplCopyWith<_$AccessControlImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
Props _$PropsFromJson(Map<String, dynamic> json) {
|
||||
return _Props.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$Props {
|
||||
AccessControl? get accessControl => throw _privateConstructorUsedError;
|
||||
bool? get allowBypass => throw _privateConstructorUsedError;
|
||||
bool? get systemProxy => throw _privateConstructorUsedError;
|
||||
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
@JsonKey(ignore: true)
|
||||
$PropsCopyWith<Props> get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $PropsCopyWith<$Res> {
|
||||
factory $PropsCopyWith(Props value, $Res Function(Props) then) =
|
||||
_$PropsCopyWithImpl<$Res, Props>;
|
||||
@useResult
|
||||
$Res call(
|
||||
{AccessControl? accessControl, bool? allowBypass, bool? systemProxy});
|
||||
|
||||
$AccessControlCopyWith<$Res>? get accessControl;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$PropsCopyWithImpl<$Res, $Val extends Props>
|
||||
implements $PropsCopyWith<$Res> {
|
||||
_$PropsCopyWithImpl(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? accessControl = freezed,
|
||||
Object? allowBypass = freezed,
|
||||
Object? systemProxy = freezed,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
accessControl: freezed == accessControl
|
||||
? _value.accessControl
|
||||
: accessControl // ignore: cast_nullable_to_non_nullable
|
||||
as AccessControl?,
|
||||
allowBypass: freezed == allowBypass
|
||||
? _value.allowBypass
|
||||
: allowBypass // ignore: cast_nullable_to_non_nullable
|
||||
as bool?,
|
||||
systemProxy: freezed == systemProxy
|
||||
? _value.systemProxy
|
||||
: systemProxy // ignore: cast_nullable_to_non_nullable
|
||||
as bool?,
|
||||
) as $Val);
|
||||
}
|
||||
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$AccessControlCopyWith<$Res>? get accessControl {
|
||||
if (_value.accessControl == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $AccessControlCopyWith<$Res>(_value.accessControl!, (value) {
|
||||
return _then(_value.copyWith(accessControl: value) as $Val);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$PropsImplCopyWith<$Res> implements $PropsCopyWith<$Res> {
|
||||
factory _$$PropsImplCopyWith(
|
||||
_$PropsImpl value, $Res Function(_$PropsImpl) then) =
|
||||
__$$PropsImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call(
|
||||
{AccessControl? accessControl, bool? allowBypass, bool? systemProxy});
|
||||
|
||||
@override
|
||||
$AccessControlCopyWith<$Res>? get accessControl;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$PropsImplCopyWithImpl<$Res>
|
||||
extends _$PropsCopyWithImpl<$Res, _$PropsImpl>
|
||||
implements _$$PropsImplCopyWith<$Res> {
|
||||
__$$PropsImplCopyWithImpl(
|
||||
_$PropsImpl _value, $Res Function(_$PropsImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? accessControl = freezed,
|
||||
Object? allowBypass = freezed,
|
||||
Object? systemProxy = freezed,
|
||||
}) {
|
||||
return _then(_$PropsImpl(
|
||||
accessControl: freezed == accessControl
|
||||
? _value.accessControl
|
||||
: accessControl // ignore: cast_nullable_to_non_nullable
|
||||
as AccessControl?,
|
||||
allowBypass: freezed == allowBypass
|
||||
? _value.allowBypass
|
||||
: allowBypass // ignore: cast_nullable_to_non_nullable
|
||||
as bool?,
|
||||
systemProxy: freezed == systemProxy
|
||||
? _value.systemProxy
|
||||
: systemProxy // ignore: cast_nullable_to_non_nullable
|
||||
as bool?,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$PropsImpl implements _Props {
|
||||
const _$PropsImpl({this.accessControl, this.allowBypass, this.systemProxy});
|
||||
|
||||
factory _$PropsImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$PropsImplFromJson(json);
|
||||
|
||||
@override
|
||||
final AccessControl? accessControl;
|
||||
@override
|
||||
final bool? allowBypass;
|
||||
@override
|
||||
final bool? systemProxy;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Props(accessControl: $accessControl, allowBypass: $allowBypass, systemProxy: $systemProxy)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$PropsImpl &&
|
||||
(identical(other.accessControl, accessControl) ||
|
||||
other.accessControl == accessControl) &&
|
||||
(identical(other.allowBypass, allowBypass) ||
|
||||
other.allowBypass == allowBypass) &&
|
||||
(identical(other.systemProxy, systemProxy) ||
|
||||
other.systemProxy == systemProxy));
|
||||
}
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
int get hashCode =>
|
||||
Object.hash(runtimeType, accessControl, allowBypass, systemProxy);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$PropsImplCopyWith<_$PropsImpl> get copyWith =>
|
||||
__$$PropsImplCopyWithImpl<_$PropsImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$PropsImplToJson(
|
||||
this,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _Props implements Props {
|
||||
const factory _Props(
|
||||
{final AccessControl? accessControl,
|
||||
final bool? allowBypass,
|
||||
final bool? systemProxy}) = _$PropsImpl;
|
||||
|
||||
factory _Props.fromJson(Map<String, dynamic> json) = _$PropsImpl.fromJson;
|
||||
|
||||
@override
|
||||
AccessControl? get accessControl;
|
||||
@override
|
||||
bool? get allowBypass;
|
||||
@override
|
||||
bool? get systemProxy;
|
||||
@override
|
||||
@JsonKey(ignore: true)
|
||||
_$$PropsImplCopyWith<_$PropsImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
@@ -31,8 +31,10 @@ Config _$ConfigFromJson(Map<String, dynamic> json) => Config()
|
||||
? null
|
||||
: DAV.fromJson(json['dav'] as Map<String, dynamic>)
|
||||
..isAnimateToPage = json['isAnimateToPage'] as bool? ?? true
|
||||
..isCompatible = json['isCompatible'] as bool? ?? false
|
||||
..autoCheckUpdate = json['autoCheckUpdate'] as bool? ?? true;
|
||||
..isCompatible = json['isCompatible'] as bool? ?? true
|
||||
..autoCheckUpdate = json['autoCheckUpdate'] as bool? ?? true
|
||||
..allowBypass = json['allowBypass'] as bool? ?? true
|
||||
..systemProxy = json['systemProxy'] as bool? ?? true;
|
||||
|
||||
Map<String, dynamic> _$ConfigToJson(Config instance) => <String, dynamic>{
|
||||
'profiles': instance.profiles,
|
||||
@@ -52,6 +54,8 @@ Map<String, dynamic> _$ConfigToJson(Config instance) => <String, dynamic>{
|
||||
'isAnimateToPage': instance.isAnimateToPage,
|
||||
'isCompatible': instance.isCompatible,
|
||||
'autoCheckUpdate': instance.autoCheckUpdate,
|
||||
'allowBypass': instance.allowBypass,
|
||||
'systemProxy': instance.systemProxy,
|
||||
};
|
||||
|
||||
const _$ThemeModeEnumMap = {
|
||||
@@ -93,3 +97,19 @@ const _$AccessControlModeEnumMap = {
|
||||
AccessControlMode.acceptSelected: 'acceptSelected',
|
||||
AccessControlMode.rejectSelected: 'rejectSelected',
|
||||
};
|
||||
|
||||
_$PropsImpl _$$PropsImplFromJson(Map<String, dynamic> json) => _$PropsImpl(
|
||||
accessControl: json['accessControl'] == null
|
||||
? null
|
||||
: AccessControl.fromJson(
|
||||
json['accessControl'] as Map<String, dynamic>),
|
||||
allowBypass: json['allowBypass'] as bool?,
|
||||
systemProxy: json['systemProxy'] as bool?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$PropsImplToJson(_$PropsImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'accessControl': instance.accessControl,
|
||||
'allowBypass': instance.allowBypass,
|
||||
'systemProxy': instance.systemProxy,
|
||||
};
|
||||
|
||||
@@ -28,6 +28,8 @@ const _$GroupTypeEnumMap = {
|
||||
GroupType.Selector: 'Selector',
|
||||
GroupType.URLTest: 'URLTest',
|
||||
GroupType.Fallback: 'Fallback',
|
||||
GroupType.LoadBalance: 'LoadBalance',
|
||||
GroupType.Relay: 'Relay',
|
||||
};
|
||||
|
||||
_$ProxyImpl _$$ProxyImplFromJson(Map<String, dynamic> json) => _$ProxyImpl(
|
||||
|
||||
@@ -157,34 +157,30 @@ abstract class _StartButtonSelectorState implements StartButtonSelectorState {
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$UpdateCurrentDelaySelectorState {
|
||||
String? get currentProxyName => throw _privateConstructorUsedError;
|
||||
bool get isCurrent => throw _privateConstructorUsedError;
|
||||
int? get delay => throw _privateConstructorUsedError;
|
||||
mixin _$CheckIpSelectorState {
|
||||
bool get isInit => throw _privateConstructorUsedError;
|
||||
bool get isStart => throw _privateConstructorUsedError;
|
||||
Map<String, String> get selectedMap => throw _privateConstructorUsedError;
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
$UpdateCurrentDelaySelectorStateCopyWith<UpdateCurrentDelaySelectorState>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
$CheckIpSelectorStateCopyWith<CheckIpSelectorState> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $UpdateCurrentDelaySelectorStateCopyWith<$Res> {
|
||||
factory $UpdateCurrentDelaySelectorStateCopyWith(
|
||||
UpdateCurrentDelaySelectorState value,
|
||||
$Res Function(UpdateCurrentDelaySelectorState) then) =
|
||||
_$UpdateCurrentDelaySelectorStateCopyWithImpl<$Res,
|
||||
UpdateCurrentDelaySelectorState>;
|
||||
abstract class $CheckIpSelectorStateCopyWith<$Res> {
|
||||
factory $CheckIpSelectorStateCopyWith(CheckIpSelectorState value,
|
||||
$Res Function(CheckIpSelectorState) then) =
|
||||
_$CheckIpSelectorStateCopyWithImpl<$Res, CheckIpSelectorState>;
|
||||
@useResult
|
||||
$Res call(
|
||||
{String? currentProxyName, bool isCurrent, int? delay, bool isInit});
|
||||
$Res call({bool isInit, bool isStart, Map<String, String> selectedMap});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$UpdateCurrentDelaySelectorStateCopyWithImpl<$Res,
|
||||
$Val extends UpdateCurrentDelaySelectorState>
|
||||
implements $UpdateCurrentDelaySelectorStateCopyWith<$Res> {
|
||||
_$UpdateCurrentDelaySelectorStateCopyWithImpl(this._value, this._then);
|
||||
class _$CheckIpSelectorStateCopyWithImpl<$Res,
|
||||
$Val extends CheckIpSelectorState>
|
||||
implements $CheckIpSelectorStateCopyWith<$Res> {
|
||||
_$CheckIpSelectorStateCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
@@ -194,154 +190,136 @@ class _$UpdateCurrentDelaySelectorStateCopyWithImpl<$Res,
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? currentProxyName = freezed,
|
||||
Object? isCurrent = null,
|
||||
Object? delay = freezed,
|
||||
Object? isInit = null,
|
||||
Object? isStart = null,
|
||||
Object? selectedMap = null,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
currentProxyName: freezed == currentProxyName
|
||||
? _value.currentProxyName
|
||||
: currentProxyName // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
isCurrent: null == isCurrent
|
||||
? _value.isCurrent
|
||||
: isCurrent // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
delay: freezed == delay
|
||||
? _value.delay
|
||||
: delay // ignore: cast_nullable_to_non_nullable
|
||||
as int?,
|
||||
isInit: null == isInit
|
||||
? _value.isInit
|
||||
: isInit // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
isStart: null == isStart
|
||||
? _value.isStart
|
||||
: isStart // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
selectedMap: null == selectedMap
|
||||
? _value.selectedMap
|
||||
: selectedMap // ignore: cast_nullable_to_non_nullable
|
||||
as Map<String, String>,
|
||||
) as $Val);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$UpdateCurrentDelaySelectorStateImplCopyWith<$Res>
|
||||
implements $UpdateCurrentDelaySelectorStateCopyWith<$Res> {
|
||||
factory _$$UpdateCurrentDelaySelectorStateImplCopyWith(
|
||||
_$UpdateCurrentDelaySelectorStateImpl value,
|
||||
$Res Function(_$UpdateCurrentDelaySelectorStateImpl) then) =
|
||||
__$$UpdateCurrentDelaySelectorStateImplCopyWithImpl<$Res>;
|
||||
abstract class _$$CheckIpSelectorStateImplCopyWith<$Res>
|
||||
implements $CheckIpSelectorStateCopyWith<$Res> {
|
||||
factory _$$CheckIpSelectorStateImplCopyWith(_$CheckIpSelectorStateImpl value,
|
||||
$Res Function(_$CheckIpSelectorStateImpl) then) =
|
||||
__$$CheckIpSelectorStateImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call(
|
||||
{String? currentProxyName, bool isCurrent, int? delay, bool isInit});
|
||||
$Res call({bool isInit, bool isStart, Map<String, String> selectedMap});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$UpdateCurrentDelaySelectorStateImplCopyWithImpl<$Res>
|
||||
extends _$UpdateCurrentDelaySelectorStateCopyWithImpl<$Res,
|
||||
_$UpdateCurrentDelaySelectorStateImpl>
|
||||
implements _$$UpdateCurrentDelaySelectorStateImplCopyWith<$Res> {
|
||||
__$$UpdateCurrentDelaySelectorStateImplCopyWithImpl(
|
||||
_$UpdateCurrentDelaySelectorStateImpl _value,
|
||||
$Res Function(_$UpdateCurrentDelaySelectorStateImpl) _then)
|
||||
class __$$CheckIpSelectorStateImplCopyWithImpl<$Res>
|
||||
extends _$CheckIpSelectorStateCopyWithImpl<$Res, _$CheckIpSelectorStateImpl>
|
||||
implements _$$CheckIpSelectorStateImplCopyWith<$Res> {
|
||||
__$$CheckIpSelectorStateImplCopyWithImpl(_$CheckIpSelectorStateImpl _value,
|
||||
$Res Function(_$CheckIpSelectorStateImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? currentProxyName = freezed,
|
||||
Object? isCurrent = null,
|
||||
Object? delay = freezed,
|
||||
Object? isInit = null,
|
||||
Object? isStart = null,
|
||||
Object? selectedMap = null,
|
||||
}) {
|
||||
return _then(_$UpdateCurrentDelaySelectorStateImpl(
|
||||
currentProxyName: freezed == currentProxyName
|
||||
? _value.currentProxyName
|
||||
: currentProxyName // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
isCurrent: null == isCurrent
|
||||
? _value.isCurrent
|
||||
: isCurrent // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
delay: freezed == delay
|
||||
? _value.delay
|
||||
: delay // ignore: cast_nullable_to_non_nullable
|
||||
as int?,
|
||||
return _then(_$CheckIpSelectorStateImpl(
|
||||
isInit: null == isInit
|
||||
? _value.isInit
|
||||
: isInit // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
isStart: null == isStart
|
||||
? _value.isStart
|
||||
: isStart // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
selectedMap: null == selectedMap
|
||||
? _value._selectedMap
|
||||
: selectedMap // ignore: cast_nullable_to_non_nullable
|
||||
as Map<String, String>,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$UpdateCurrentDelaySelectorStateImpl
|
||||
implements _UpdateCurrentDelaySelectorState {
|
||||
const _$UpdateCurrentDelaySelectorStateImpl(
|
||||
{required this.currentProxyName,
|
||||
required this.isCurrent,
|
||||
required this.delay,
|
||||
required this.isInit});
|
||||
class _$CheckIpSelectorStateImpl implements _CheckIpSelectorState {
|
||||
const _$CheckIpSelectorStateImpl(
|
||||
{required this.isInit,
|
||||
required this.isStart,
|
||||
required final Map<String, String> selectedMap})
|
||||
: _selectedMap = selectedMap;
|
||||
|
||||
@override
|
||||
final String? currentProxyName;
|
||||
@override
|
||||
final bool isCurrent;
|
||||
@override
|
||||
final int? delay;
|
||||
@override
|
||||
final bool isInit;
|
||||
@override
|
||||
final bool isStart;
|
||||
final Map<String, String> _selectedMap;
|
||||
@override
|
||||
Map<String, String> get selectedMap {
|
||||
if (_selectedMap is EqualUnmodifiableMapView) return _selectedMap;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableMapView(_selectedMap);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'UpdateCurrentDelaySelectorState(currentProxyName: $currentProxyName, isCurrent: $isCurrent, delay: $delay, isInit: $isInit)';
|
||||
return 'CheckIpSelectorState(isInit: $isInit, isStart: $isStart, selectedMap: $selectedMap)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$UpdateCurrentDelaySelectorStateImpl &&
|
||||
(identical(other.currentProxyName, currentProxyName) ||
|
||||
other.currentProxyName == currentProxyName) &&
|
||||
(identical(other.isCurrent, isCurrent) ||
|
||||
other.isCurrent == isCurrent) &&
|
||||
(identical(other.delay, delay) || other.delay == delay) &&
|
||||
(identical(other.isInit, isInit) || other.isInit == isInit));
|
||||
other is _$CheckIpSelectorStateImpl &&
|
||||
(identical(other.isInit, isInit) || other.isInit == isInit) &&
|
||||
(identical(other.isStart, isStart) || other.isStart == isStart) &&
|
||||
const DeepCollectionEquality()
|
||||
.equals(other._selectedMap, _selectedMap));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
Object.hash(runtimeType, currentProxyName, isCurrent, delay, isInit);
|
||||
int get hashCode => Object.hash(runtimeType, isInit, isStart,
|
||||
const DeepCollectionEquality().hash(_selectedMap));
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$UpdateCurrentDelaySelectorStateImplCopyWith<
|
||||
_$UpdateCurrentDelaySelectorStateImpl>
|
||||
get copyWith => __$$UpdateCurrentDelaySelectorStateImplCopyWithImpl<
|
||||
_$UpdateCurrentDelaySelectorStateImpl>(this, _$identity);
|
||||
_$$CheckIpSelectorStateImplCopyWith<_$CheckIpSelectorStateImpl>
|
||||
get copyWith =>
|
||||
__$$CheckIpSelectorStateImplCopyWithImpl<_$CheckIpSelectorStateImpl>(
|
||||
this, _$identity);
|
||||
}
|
||||
|
||||
abstract class _UpdateCurrentDelaySelectorState
|
||||
implements UpdateCurrentDelaySelectorState {
|
||||
const factory _UpdateCurrentDelaySelectorState(
|
||||
{required final String? currentProxyName,
|
||||
required final bool isCurrent,
|
||||
required final int? delay,
|
||||
required final bool isInit}) = _$UpdateCurrentDelaySelectorStateImpl;
|
||||
abstract class _CheckIpSelectorState implements CheckIpSelectorState {
|
||||
const factory _CheckIpSelectorState(
|
||||
{required final bool isInit,
|
||||
required final bool isStart,
|
||||
required final Map<String, String> selectedMap}) =
|
||||
_$CheckIpSelectorStateImpl;
|
||||
|
||||
@override
|
||||
String? get currentProxyName;
|
||||
@override
|
||||
bool get isCurrent;
|
||||
@override
|
||||
int? get delay;
|
||||
@override
|
||||
bool get isInit;
|
||||
@override
|
||||
bool get isStart;
|
||||
@override
|
||||
Map<String, String> get selectedMap;
|
||||
@override
|
||||
@JsonKey(ignore: true)
|
||||
_$$UpdateCurrentDelaySelectorStateImplCopyWith<
|
||||
_$UpdateCurrentDelaySelectorStateImpl>
|
||||
_$$CheckIpSelectorStateImplCopyWith<_$CheckIpSelectorStateImpl>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
|
||||
70
lib/models/ip.dart
Normal file
@@ -0,0 +1,70 @@
|
||||
class IpInfo {
|
||||
final String ip;
|
||||
final String countryCode;
|
||||
|
||||
const IpInfo({
|
||||
required this.ip,
|
||||
required this.countryCode,
|
||||
});
|
||||
|
||||
static IpInfo fromIpInfoIoJson(Map<String, dynamic> json) {
|
||||
return switch (json) {
|
||||
{
|
||||
"ip": final String ip,
|
||||
"country": final String country,
|
||||
} =>
|
||||
IpInfo(
|
||||
ip: ip,
|
||||
countryCode: country,
|
||||
),
|
||||
_ => throw const FormatException("invalid json"),
|
||||
};
|
||||
}
|
||||
|
||||
static IpInfo fromIpApiCoJson(Map<String, dynamic> json) {
|
||||
return switch (json) {
|
||||
{
|
||||
"ip": final String ip,
|
||||
"country_code": final String countryCode,
|
||||
} =>
|
||||
IpInfo(
|
||||
ip: ip,
|
||||
countryCode: countryCode,
|
||||
),
|
||||
_ => throw const FormatException("invalid json"),
|
||||
};
|
||||
}
|
||||
|
||||
static IpInfo fromIpSbJson(Map<String, dynamic> json) {
|
||||
return switch (json) {
|
||||
{
|
||||
"ip": final String ip,
|
||||
"country_code": final String countryCode,
|
||||
} =>
|
||||
IpInfo(
|
||||
ip: ip,
|
||||
countryCode: countryCode,
|
||||
),
|
||||
_ => throw const FormatException("invalid json"),
|
||||
};
|
||||
}
|
||||
|
||||
static IpInfo fromIpwhoIsJson(Map<String, dynamic> json) {
|
||||
return switch (json) {
|
||||
{
|
||||
"ip": final String ip,
|
||||
"country_code": final String countryCode,
|
||||
} =>
|
||||
IpInfo(
|
||||
ip: ip,
|
||||
countryCode: countryCode,
|
||||
),
|
||||
_ => throw const FormatException("invalid json"),
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'IpInfo{ip: $ip, countryCode: $countryCode}';
|
||||
}
|
||||
}
|
||||
@@ -12,4 +12,5 @@ export 'package.dart';
|
||||
export 'ffi.dart';
|
||||
export 'selector.dart';
|
||||
export 'navigation.dart';
|
||||
export 'dav.dart';
|
||||
export 'dav.dart';
|
||||
export 'ip.dart';
|
||||
@@ -16,16 +16,17 @@ class UserInfo {
|
||||
int upload;
|
||||
int download;
|
||||
int total;
|
||||
int? expire;
|
||||
int expire;
|
||||
|
||||
UserInfo({
|
||||
int? upload,
|
||||
int? download,
|
||||
int? total,
|
||||
this.expire,
|
||||
int? expire,
|
||||
}) : upload = upload ?? 0,
|
||||
download = download ?? 0,
|
||||
total = total ?? 0;
|
||||
total = total ?? 0,
|
||||
expire = expire ?? 0;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$UserInfoToJson(this);
|
||||
@@ -37,10 +38,10 @@ class UserInfo {
|
||||
|
||||
factory UserInfo.formHString(String? info) {
|
||||
if (info == null) return UserInfo();
|
||||
var list = info.split(";");
|
||||
final list = info.split(";");
|
||||
Map<String, int?> map = {};
|
||||
for (var i in list) {
|
||||
var keyValue = i.trim().split("=");
|
||||
for (final i in list) {
|
||||
final keyValue = i.trim().split("=");
|
||||
map[keyValue[0]] = int.tryParse(keyValue[1]);
|
||||
}
|
||||
return UserInfo(
|
||||
@@ -83,7 +84,8 @@ class Profile {
|
||||
autoUpdateDuration = autoUpdateDuration ?? defaultUpdateDuration,
|
||||
selectedMap = selectedMap ?? {};
|
||||
|
||||
ProfileType get type => url == null ? ProfileType.file : ProfileType.url;
|
||||
ProfileType get type =>
|
||||
url == null || url?.isEmpty == true ? ProfileType.file : ProfileType.url;
|
||||
|
||||
Future<void> checkAndUpdate() async {
|
||||
final isExists = await check();
|
||||
@@ -95,9 +97,6 @@ class Profile {
|
||||
}
|
||||
|
||||
Future<void> update() async {
|
||||
if (url == null) {
|
||||
throw appLocalizations.unableToUpdateCurrentProfileDesc;
|
||||
}
|
||||
final response = await request.getFileResponseForUrl(url!);
|
||||
final disposition = response.headers.value("content-disposition");
|
||||
label ??= other.getFileNameForDisposition(disposition) ?? id;
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
import 'package:fl_clash/enum/enum.dart';
|
||||
import 'package:fl_clash/models/models.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'config.dart';
|
||||
import 'navigation.dart';
|
||||
import 'profile.dart';
|
||||
import 'proxy.dart';
|
||||
|
||||
part 'generated/selector.freezed.dart';
|
||||
|
||||
@@ -17,13 +14,12 @@ class StartButtonSelectorState with _$StartButtonSelectorState {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class UpdateCurrentDelaySelectorState with _$UpdateCurrentDelaySelectorState {
|
||||
const factory UpdateCurrentDelaySelectorState({
|
||||
required String? currentProxyName,
|
||||
required bool isCurrent,
|
||||
required int? delay,
|
||||
class CheckIpSelectorState with _$CheckIpSelectorState {
|
||||
const factory CheckIpSelectorState({
|
||||
required bool isInit,
|
||||
}) = _UpdateCurrentDelaySelectorState;
|
||||
required bool isStart,
|
||||
required SelectedMap selectedMap,
|
||||
}) = _CheckIpSelectorState;
|
||||
}
|
||||
|
||||
@freezed
|
||||
@@ -53,24 +49,23 @@ class ApplicationSelectorState with _$ApplicationSelectorState {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class TrayContainerSelectorState with _$TrayContainerSelectorState{
|
||||
class TrayContainerSelectorState with _$TrayContainerSelectorState {
|
||||
const factory TrayContainerSelectorState({
|
||||
required Mode mode,
|
||||
required bool autoLaunch,
|
||||
required bool isRun,
|
||||
required String? locale,
|
||||
})=_TrayContainerSelectorState;
|
||||
}) = _TrayContainerSelectorState;
|
||||
}
|
||||
|
||||
@freezed
|
||||
class UpdateNavigationsSelector with _$UpdateNavigationsSelector{
|
||||
class UpdateNavigationsSelector with _$UpdateNavigationsSelector {
|
||||
const factory UpdateNavigationsSelector({
|
||||
required bool openLogs,
|
||||
required bool hasProxies,
|
||||
}) = _UpdateNavigationsSelector;
|
||||
}
|
||||
|
||||
|
||||
@freezed
|
||||
class HomeSelectorState with _$HomeSelectorState {
|
||||
const factory HomeSelectorState({
|
||||
@@ -89,21 +84,21 @@ class HomeBodySelectorState with _$HomeBodySelectorState {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class ProxiesCardSelectorState with _$ProxiesCardSelectorState{
|
||||
class ProxiesCardSelectorState with _$ProxiesCardSelectorState {
|
||||
const factory ProxiesCardSelectorState({
|
||||
required bool isSelected,
|
||||
}) = _ProxiesCardSelectorState;
|
||||
}
|
||||
|
||||
@freezed
|
||||
class ProxiesSelectorState with _$ProxiesSelectorState{
|
||||
class ProxiesSelectorState with _$ProxiesSelectorState {
|
||||
const factory ProxiesSelectorState({
|
||||
required List<String> groupNames,
|
||||
}) = _ProxiesSelectorState;
|
||||
}
|
||||
|
||||
@freezed
|
||||
class ProxiesTabViewSelectorState with _$ProxiesTabViewSelectorState{
|
||||
class ProxiesTabViewSelectorState with _$ProxiesTabViewSelectorState {
|
||||
const factory ProxiesTabViewSelectorState({
|
||||
required ProxiesSortType proxiesSortType,
|
||||
required num sortNum,
|
||||
@@ -125,4 +120,4 @@ class PackageListSelectorState with _$PackageListSelectorState {
|
||||
required AccessControl accessControl,
|
||||
required bool isAccessControl,
|
||||
}) = _PackageListSelectorState;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,6 +107,9 @@ class _ScanPageState extends State<ScanPage> with WidgetsBindingObserver {
|
||||
case TorchState.unavailable:
|
||||
icon = const Icon(Icons.flash_off);
|
||||
backgroundColor = Colors.transparent;
|
||||
case TorchState.auto:
|
||||
icon = const Icon(Icons.flash_auto);
|
||||
backgroundColor = Colors.orange;
|
||||
}
|
||||
return Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 8),
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'dart:isolate';
|
||||
|
||||
import 'package:fl_clash/clash/clash.dart';
|
||||
import 'package:fl_clash/models/models.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
@@ -17,10 +18,8 @@ class App {
|
||||
methodChannel = const MethodChannel("app");
|
||||
methodChannel!.setMethodCallHandler((call) async {
|
||||
switch (call.method) {
|
||||
case "exit":
|
||||
if (onExit != null) {
|
||||
await onExit!();
|
||||
}
|
||||
case "gc":
|
||||
clashCore.requestGc();
|
||||
break;
|
||||
default:
|
||||
throw MissingPluginException();
|
||||
@@ -29,10 +28,6 @@ class App {
|
||||
}
|
||||
}
|
||||
|
||||
setOnExit(Function() onExit) {
|
||||
this.onExit = onExit;
|
||||
}
|
||||
|
||||
factory App() {
|
||||
_instance ??= App._internal();
|
||||
return _instance!;
|
||||
|
||||
@@ -13,7 +13,6 @@ import 'common/common.dart';
|
||||
|
||||
class GlobalState {
|
||||
Timer? timer;
|
||||
Function? healthcheckLockDebounce;
|
||||
Timer? groupsUpdateTimer;
|
||||
Function? updateCurrentDelayDebounce;
|
||||
PageController? pageController;
|
||||
@@ -22,7 +21,6 @@ class GlobalState {
|
||||
late AppController appController;
|
||||
GlobalKey<CommonScaffoldState> homeScaffoldKey = GlobalKey();
|
||||
List<Function> updateFunctionLists = [];
|
||||
bool healthcheckLock = false;
|
||||
|
||||
startListenUpdate() {
|
||||
if (timer != null && timer!.isActive == true) return;
|
||||
@@ -63,8 +61,14 @@ class GlobalState {
|
||||
required Config config,
|
||||
required ClashConfig clashConfig,
|
||||
}) async {
|
||||
final args =
|
||||
config.isAccessControl ? json.encode(config.accessControl) : null;
|
||||
final args = config.isAccessControl
|
||||
? json.encode(
|
||||
Props(
|
||||
accessControl: config.accessControl,
|
||||
allowBypass: config.allowBypass,
|
||||
),
|
||||
)
|
||||
: null;
|
||||
await proxyManager.startProxy(
|
||||
port: clashConfig.mixedPort,
|
||||
args: args,
|
||||
@@ -107,12 +111,6 @@ class GlobalState {
|
||||
clashConfig: clashConfig,
|
||||
);
|
||||
}
|
||||
if (!appState.isInit) return;
|
||||
await applyProfile(
|
||||
appState: appState,
|
||||
config: config,
|
||||
clashConfig: clashConfig,
|
||||
);
|
||||
updateCoreVersionInfo(appState);
|
||||
}
|
||||
|
||||
@@ -121,35 +119,20 @@ class GlobalState {
|
||||
required Config config,
|
||||
required ClashConfig clashConfig,
|
||||
}) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (config.profiles.isEmpty) {
|
||||
stopSystemProxy();
|
||||
return;
|
||||
}
|
||||
config.currentSelectedMap.forEach((key, value) {
|
||||
clashCore.changeProxy(
|
||||
ChangeProxyParams(
|
||||
groupName: key,
|
||||
proxyName: value,
|
||||
),
|
||||
);
|
||||
});
|
||||
if (config.profiles.isEmpty) {
|
||||
stopSystemProxy();
|
||||
return;
|
||||
}
|
||||
config.currentSelectedMap.forEach((key, value) {
|
||||
clashCore.changeProxy(
|
||||
ChangeProxyParams(
|
||||
groupName: key,
|
||||
proxyName: value,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
updateNavigationItems({
|
||||
required AppState appState,
|
||||
required Config config,
|
||||
required ClashConfig clashConfig,
|
||||
}) {
|
||||
final group = appState.currentGroups;
|
||||
final hasProfile = config.profiles.isNotEmpty;
|
||||
appState.navigationItems = navigation.getItems(
|
||||
openLogs: config.openLogs,
|
||||
hasProxies: group.isNotEmpty && hasProfile,
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> updateGroups(AppState appState) async {
|
||||
appState.groups = await clashCore.getProxiesGroups();
|
||||
}
|
||||
@@ -255,20 +238,6 @@ class GlobalState {
|
||||
);
|
||||
}
|
||||
|
||||
void updateCurrentDelay(
|
||||
String? proxyName,
|
||||
) {
|
||||
updateCurrentDelayDebounce ??= debounce<Function(String?)>((proxyName) {
|
||||
if (proxyName != null) {
|
||||
debugPrint("[delay]=====> $proxyName");
|
||||
clashCore.delay(
|
||||
proxyName,
|
||||
);
|
||||
}
|
||||
});
|
||||
updateCurrentDelayDebounce!([proxyName]);
|
||||
}
|
||||
|
||||
Future<T?> safeRun<T>(
|
||||
FutureOr<T> Function() futureFunction, {
|
||||
String? title,
|
||||
|
||||
@@ -38,16 +38,8 @@ class _ClashMessageContainerState extends State<ClashMessageContainer>
|
||||
|
||||
@override
|
||||
void onDelay(Delay delay) {
|
||||
globalState.healthcheckLock = true;
|
||||
final appController = globalState.appController;
|
||||
appController.setDelay(delay);
|
||||
globalState.healthcheckLockDebounce ??= debounce<Function()>(
|
||||
() async {
|
||||
globalState.healthcheckLock = false;
|
||||
},
|
||||
milliseconds: 5000,
|
||||
);
|
||||
globalState.healthcheckLockDebounce!();
|
||||
super.onDelay(delay);
|
||||
}
|
||||
|
||||
|
||||
@@ -71,6 +71,7 @@ class ListItem<T> extends StatelessWidget {
|
||||
final Widget title;
|
||||
final Widget? subtitle;
|
||||
final EdgeInsets padding;
|
||||
final ListTileTitleAlignment tileTitleAlignment;
|
||||
final bool? prue;
|
||||
final Widget? trailing;
|
||||
final Delegate delegate;
|
||||
@@ -87,6 +88,7 @@ class ListItem<T> extends StatelessWidget {
|
||||
this.horizontalTitleGap,
|
||||
this.prue,
|
||||
this.onTab,
|
||||
this.tileTitleAlignment = ListTileTitleAlignment.center,
|
||||
}) : delegate = const Delegate();
|
||||
|
||||
const ListItem.open({
|
||||
@@ -99,6 +101,7 @@ class ListItem<T> extends StatelessWidget {
|
||||
required OpenDelegate this.delegate,
|
||||
this.horizontalTitleGap,
|
||||
this.prue,
|
||||
this.tileTitleAlignment = ListTileTitleAlignment.center,
|
||||
}) : onTab = null;
|
||||
|
||||
const ListItem.next({
|
||||
@@ -111,6 +114,7 @@ class ListItem<T> extends StatelessWidget {
|
||||
required NextDelegate this.delegate,
|
||||
this.horizontalTitleGap,
|
||||
this.prue,
|
||||
this.tileTitleAlignment = ListTileTitleAlignment.center,
|
||||
}) : onTab = null;
|
||||
|
||||
const ListItem.checkbox({
|
||||
@@ -122,6 +126,7 @@ class ListItem<T> extends StatelessWidget {
|
||||
required CheckboxDelegate this.delegate,
|
||||
this.horizontalTitleGap,
|
||||
this.prue,
|
||||
this.tileTitleAlignment = ListTileTitleAlignment.center,
|
||||
}) : trailing = null,
|
||||
onTab = null;
|
||||
|
||||
@@ -134,6 +139,7 @@ class ListItem<T> extends StatelessWidget {
|
||||
required SwitchDelegate this.delegate,
|
||||
this.horizontalTitleGap,
|
||||
this.prue,
|
||||
this.tileTitleAlignment = ListTileTitleAlignment.center,
|
||||
}) : trailing = null,
|
||||
onTab = null;
|
||||
|
||||
@@ -146,6 +152,7 @@ class ListItem<T> extends StatelessWidget {
|
||||
required RadioDelegate<T> this.delegate,
|
||||
this.horizontalTitleGap = 8,
|
||||
this.prue,
|
||||
this.tileTitleAlignment = ListTileTitleAlignment.center,
|
||||
}) : leading = null,
|
||||
onTab = null;
|
||||
|
||||
@@ -193,6 +200,7 @@ class ListItem<T> extends StatelessWidget {
|
||||
horizontalTitleGap: horizontalTitleGap,
|
||||
title: title,
|
||||
subtitle: subtitle,
|
||||
titleAlignment: tileTitleAlignment,
|
||||
onTap: onTab,
|
||||
trailing: trailing ?? this.trailing,
|
||||
contentPadding: padding,
|
||||
|
||||
@@ -49,6 +49,7 @@ class CommonScaffold extends StatefulWidget {
|
||||
|
||||
class CommonScaffoldState extends State<CommonScaffold> {
|
||||
final ValueNotifier<List<Widget>> _actions = ValueNotifier([]);
|
||||
final ValueNotifier<Widget?> _floatingActionButton = ValueNotifier(null);
|
||||
|
||||
final ValueNotifier<bool> _loading = ValueNotifier(false);
|
||||
|
||||
@@ -58,11 +59,16 @@ class CommonScaffoldState extends State<CommonScaffold> {
|
||||
}
|
||||
}
|
||||
|
||||
set floatingActionButton(Widget? actions) {
|
||||
if (_floatingActionButton.value != actions) {
|
||||
_floatingActionButton.value = actions;
|
||||
}
|
||||
}
|
||||
|
||||
Future<T?> loadingRun<T>(
|
||||
Future<T> Function() futureFunction, {
|
||||
String? title,
|
||||
}) async {
|
||||
if (_loading.value == true) return null;
|
||||
_loading.value = true;
|
||||
try {
|
||||
final res = await futureFunction();
|
||||
@@ -85,6 +91,7 @@ class CommonScaffoldState extends State<CommonScaffold> {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
if (oldWidget.title != widget.title) {
|
||||
_actions.value = [];
|
||||
_floatingActionButton.value = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,6 +116,12 @@ class CommonScaffoldState extends State<CommonScaffold> {
|
||||
Widget build(BuildContext context) {
|
||||
return _platformContainer(
|
||||
child: Scaffold(
|
||||
floatingActionButton: ValueListenableBuilder(
|
||||
valueListenable: _floatingActionButton,
|
||||
builder: (_, floatingActionButton, __) {
|
||||
return floatingActionButton ?? Container();
|
||||
},
|
||||
),
|
||||
appBar: PreferredSize(
|
||||
preferredSize: const Size.fromHeight(kToolbarHeight),
|
||||
child: Stack(
|
||||
|
||||
442
pubspec.lock
@@ -1,7 +1,7 @@
|
||||
name: fl_clash
|
||||
description: A multi-platform proxy client based on ClashMeta, simple and easy to use, open-source and ad-free.
|
||||
publish_to: 'none'
|
||||
version: 0.8.10
|
||||
version: 0.8.21
|
||||
environment:
|
||||
sdk: '>=3.1.0 <4.0.0'
|
||||
|
||||
@@ -17,14 +17,14 @@ dependencies:
|
||||
provider: ^6.0.5
|
||||
window_manager: ^0.3.8
|
||||
ffi: ^2.1.0
|
||||
dynamic_color: ^1.7.0
|
||||
dynamic_color: ^1.6.0
|
||||
proxy:
|
||||
path: plugins/proxy
|
||||
launch_at_startup: ^0.2.2
|
||||
windows_single_instance: ^1.0.1
|
||||
json_annotation: ^4.9.0
|
||||
file_picker: ^8.0.3
|
||||
mobile_scanner: 5.0.1
|
||||
mobile_scanner: ^5.1.1
|
||||
app_links: ^3.5.0
|
||||
win32_registry: ^1.1.2
|
||||
tray_manager: ^0.2.1
|
||||
@@ -38,6 +38,7 @@ dependencies:
|
||||
image: ^4.1.7
|
||||
webdav_client: ^1.2.2
|
||||
dio: ^5.4.3+1
|
||||
country_flags: ^2.2.0
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
|
||||
17
setup.dart
@@ -12,10 +12,7 @@ enum PlatformType {
|
||||
macos,
|
||||
}
|
||||
|
||||
enum Arch {
|
||||
amd64,
|
||||
arm64,
|
||||
}
|
||||
enum Arch { amd64, arm64, arm }
|
||||
|
||||
class BuildLibItem {
|
||||
PlatformType platform;
|
||||
@@ -64,6 +61,11 @@ class Build {
|
||||
arch: Arch.amd64,
|
||||
archName: 'amd64',
|
||||
),
|
||||
BuildLibItem(
|
||||
platform: PlatformType.android,
|
||||
arch: Arch.arm,
|
||||
archName: 'armeabi-v7a',
|
||||
),
|
||||
BuildLibItem(
|
||||
platform: PlatformType.android,
|
||||
arch: Arch.arm64,
|
||||
@@ -334,7 +336,7 @@ class BuildCommand extends Command {
|
||||
final archName = argResults?['arch'];
|
||||
final currentArches =
|
||||
arches.where((element) => element.name == archName).toList();
|
||||
final arch = currentArches.isEmpty ? null : arches.first;
|
||||
final arch = currentArches.isEmpty ? null : currentArches.first;
|
||||
await _buildLib(arch);
|
||||
if (build != "all") {
|
||||
return;
|
||||
@@ -357,10 +359,11 @@ class BuildCommand extends Command {
|
||||
break;
|
||||
case PlatformType.android:
|
||||
final targetMap = {
|
||||
Arch.arm: "android-arm",
|
||||
Arch.arm64: "android-arm64",
|
||||
Arch.amd64: "android-x64",
|
||||
Arch.arm64: "android-arm64"
|
||||
};
|
||||
final defaultArches = [Arch.amd64, Arch.arm64];
|
||||
final defaultArches = [Arch.arm, Arch.arm64, Arch.amd64];
|
||||
final defaultTargets = defaultArches
|
||||
.where((element) => arch == null ? true : element == arch)
|
||||
.map((e) => targetMap[e])
|
||||
|
||||