Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f6d9ed11d9 | ||
|
|
c38a671d57 | ||
|
|
75af47aead | ||
|
|
8dafe3b0ec | ||
|
|
813198a21d | ||
|
|
68dd262fef | ||
|
|
5ef020db73 | ||
|
|
e3c9035903 | ||
|
|
7fc54c5295 | ||
|
|
00a78b5fb4 |
11
.github/workflows/build.yml
vendored
11
.github/workflows/build.yml
vendored
@@ -87,7 +87,7 @@ jobs:
|
|||||||
- name: Setup Flutter
|
- name: Setup Flutter
|
||||||
uses: subosito/flutter-action@v2
|
uses: subosito/flutter-action@v2
|
||||||
with:
|
with:
|
||||||
flutter-version: '3.x'
|
flutter-version: 3.22.x
|
||||||
channel: 'stable'
|
channel: 'stable'
|
||||||
cache: true
|
cache: true
|
||||||
|
|
||||||
@@ -136,18 +136,25 @@ jobs:
|
|||||||
gitchangelog "${pre}.." >> release.md 2>&1 || echo "Error in gitchangelog"
|
gitchangelog "${pre}.." >> release.md 2>&1 || echo "Error in gitchangelog"
|
||||||
echo -e "\n\n</details>" >> release.md
|
echo -e "\n\n</details>" >> release.md
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Release
|
- name: Release
|
||||||
uses: softprops/action-gh-release@v2
|
uses: softprops/action-gh-release@v2
|
||||||
with:
|
with:
|
||||||
files: ./dist/*
|
files: ./dist/*
|
||||||
body_path: './release.md'
|
body_path: './release.md'
|
||||||
|
|
||||||
|
- name: Create Fdroid Source Dir
|
||||||
|
run: |
|
||||||
|
mkdir -p ./tmp
|
||||||
|
cp ./dist/*android-arm64-v8a* ./tmp/ || true
|
||||||
|
echo "Files copied successfully"
|
||||||
|
|
||||||
- name: Push to fdroid repo
|
- name: Push to fdroid repo
|
||||||
uses: cpina/github-action-push-to-another-repository@v1.7.2
|
uses: cpina/github-action-push-to-another-repository@v1.7.2
|
||||||
env:
|
env:
|
||||||
SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }}
|
SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }}
|
||||||
with:
|
with:
|
||||||
source-directory: ./dist/
|
source-directory: ./tmp/
|
||||||
destination-github-username: chen08209
|
destination-github-username: chen08209
|
||||||
destination-repository-name: FlClash-fdroid-repo
|
destination-repository-name: FlClash-fdroid-repo
|
||||||
user-name: 'github-actions[bot]'
|
user-name: 'github-actions[bot]'
|
||||||
|
|||||||
@@ -102,6 +102,9 @@ flutter {
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation 'androidx.core:core-splashscreen:1.0.1'
|
implementation 'androidx.core:core-splashscreen:1.0.1'
|
||||||
implementation 'com.google.code.gson:gson:2.10'
|
implementation 'com.google.code.gson:gson:2.10'
|
||||||
|
implementation("com.android.tools.smali:smali-dexlib2:3.0.7") {
|
||||||
|
exclude group: "com.google.guava", module: "guava"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,11 +2,11 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools">
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
<uses-feature
|
<uses-feature
|
||||||
android:name="android.hardware.touchscreen"
|
android:name="android.hardware.touchscreen"
|
||||||
android:required="false" />
|
android:required="false" />
|
||||||
<uses-feature
|
<uses-feature
|
||||||
android:name="android.hardware.camera"
|
android:name="android.hardware.camera"
|
||||||
android:required="false" />
|
android:required="false" />
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||||
@@ -14,18 +14,20 @@
|
|||||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
<uses-permission android:name="android.permission.CHANGE_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.FOREGROUND_SERVICE_SPECIAL_USE"
|
||||||
tools:ignore="SystemPermissionTypo" />
|
tools:ignore="SystemPermissionTypo" />
|
||||||
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"
|
<uses-permission
|
||||||
|
android:name="android.permission.QUERY_ALL_PACKAGES"
|
||||||
tools:ignore="QueryAllPackagesPermission" />
|
tools:ignore="QueryAllPackagesPermission" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:name="${applicationName}"
|
android:name="${applicationName}"
|
||||||
android:icon="@mipmap/ic_launcher"
|
|
||||||
android:networkSecurityConfig="@xml/network_security_config"
|
|
||||||
android:extractNativeLibs="true"
|
|
||||||
android:enableOnBackInvokedCallback="true"
|
android:enableOnBackInvokedCallback="true"
|
||||||
|
android:extractNativeLibs="true"
|
||||||
|
android:icon="@mipmap/ic_launcher"
|
||||||
android:label="FlClash"
|
android:label="FlClash"
|
||||||
|
android:networkSecurityConfig="@xml/network_security_config"
|
||||||
tools:targetApi="tiramisu">
|
tools:targetApi="tiramisu">
|
||||||
<activity
|
<activity
|
||||||
android:name="com.follow.clash.MainActivity"
|
android:name="com.follow.clash.MainActivity"
|
||||||
@@ -56,17 +58,17 @@
|
|||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
<category android:name="android.intent.category.BROWSABLE" />
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
|
|
||||||
<data android:scheme="clash"/>
|
<data android:scheme="clash" />
|
||||||
<data android:scheme="clashmeta"/>
|
<data android:scheme="clashmeta" />
|
||||||
<data android:scheme="flclash"/>
|
<data android:scheme="flclash" />
|
||||||
|
|
||||||
<data android:host="install-config"/>
|
<data android:host="install-config" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<!-- <meta-data-->
|
<!-- <meta-data-->
|
||||||
<!-- android:name="io.flutter.embedding.android.EnableImpeller"-->
|
<!-- android:name="io.flutter.embedding.android.EnableImpeller"-->
|
||||||
<!-- android:value="true" />-->
|
<!-- android:value="true" />-->
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".TempActivity"
|
android:name=".TempActivity"
|
||||||
@@ -75,11 +77,10 @@
|
|||||||
<service
|
<service
|
||||||
android:name=".services.FlClashTileService"
|
android:name=".services.FlClashTileService"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:icon="@drawable/ic_stat_name"
|
|
||||||
android:foregroundServiceType="specialUse"
|
android:foregroundServiceType="specialUse"
|
||||||
|
android:icon="@drawable/ic_stat_name"
|
||||||
android:label="FlClash"
|
android:label="FlClash"
|
||||||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
|
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
|
||||||
>
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.service.quicksettings.action.QS_TILE" />
|
<action android:name="android.service.quicksettings.action.QS_TILE" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
@@ -114,13 +115,17 @@
|
|||||||
android:name=".services.FlClashVpnService"
|
android:name=".services.FlClashVpnService"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:foregroundServiceType="specialUse"
|
android:foregroundServiceType="specialUse"
|
||||||
android:permission="android.permission.BIND_VPN_SERVICE"
|
android:permission="android.permission.BIND_VPN_SERVICE">
|
||||||
>
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.net.VpnService" />
|
<action android:name="android.net.VpnService" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
|
<service
|
||||||
|
android:name=".services.FlClashService"
|
||||||
|
android:exported="false"
|
||||||
|
android:foregroundServiceType="specialUse" />
|
||||||
|
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="flutterEmbedding"
|
android:name="flutterEmbedding"
|
||||||
android:value="2" />
|
android:value="2" />
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.follow.clash
|
||||||
|
|
||||||
|
import com.follow.clash.models.Props
|
||||||
|
|
||||||
|
interface BaseServiceInterface {
|
||||||
|
fun start(port: Int, props: Props?): Int?
|
||||||
|
fun stop()
|
||||||
|
fun startForeground(title: String, content: String)
|
||||||
|
}
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
package com.follow.clash
|
package com.follow.clash
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.Log
|
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import com.follow.clash.plugins.AppPlugin
|
import com.follow.clash.plugins.AppPlugin
|
||||||
import com.follow.clash.plugins.ProxyPlugin
|
import com.follow.clash.plugins.ServicePlugin
|
||||||
|
import com.follow.clash.plugins.VpnPlugin
|
||||||
import com.follow.clash.plugins.TilePlugin
|
import com.follow.clash.plugins.TilePlugin
|
||||||
import io.flutter.FlutterInjector
|
import io.flutter.FlutterInjector
|
||||||
import io.flutter.embedding.engine.FlutterEngine
|
import io.flutter.embedding.engine.FlutterEngine
|
||||||
@@ -22,6 +22,7 @@ enum class RunState {
|
|||||||
object GlobalState {
|
object GlobalState {
|
||||||
|
|
||||||
private val lock = ReentrantLock()
|
private val lock = ReentrantLock()
|
||||||
|
val runLock = ReentrantLock()
|
||||||
|
|
||||||
val runState: MutableLiveData<RunState> = MutableLiveData<RunState>(RunState.STOP)
|
val runState: MutableLiveData<RunState> = MutableLiveData<RunState>(RunState.STOP)
|
||||||
var flutterEngine: FlutterEngine? = null
|
var flutterEngine: FlutterEngine? = null
|
||||||
@@ -37,6 +38,11 @@ object GlobalState {
|
|||||||
return currentEngine?.plugins?.get(TilePlugin::class.java) as TilePlugin?
|
return currentEngine?.plugins?.get(TilePlugin::class.java) as TilePlugin?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getCurrentVPNPlugin(): VpnPlugin? {
|
||||||
|
val currentEngine = if (serviceEngine != null) serviceEngine else flutterEngine
|
||||||
|
return currentEngine?.plugins?.get(VpnPlugin::class.java) as VpnPlugin?
|
||||||
|
}
|
||||||
|
|
||||||
fun destroyServiceEngine() {
|
fun destroyServiceEngine() {
|
||||||
serviceEngine?.destroy()
|
serviceEngine?.destroy()
|
||||||
serviceEngine = null
|
serviceEngine = null
|
||||||
@@ -47,9 +53,10 @@ object GlobalState {
|
|||||||
lock.withLock {
|
lock.withLock {
|
||||||
destroyServiceEngine()
|
destroyServiceEngine()
|
||||||
serviceEngine = FlutterEngine(context)
|
serviceEngine = FlutterEngine(context)
|
||||||
serviceEngine?.plugins?.add(ProxyPlugin())
|
serviceEngine?.plugins?.add(VpnPlugin())
|
||||||
serviceEngine?.plugins?.add(AppPlugin())
|
serviceEngine?.plugins?.add(AppPlugin())
|
||||||
serviceEngine?.plugins?.add(TilePlugin())
|
serviceEngine?.plugins?.add(TilePlugin())
|
||||||
|
serviceEngine?.plugins?.add(ServicePlugin())
|
||||||
val vpnService = DartExecutor.DartEntrypoint(
|
val vpnService = DartExecutor.DartEntrypoint(
|
||||||
FlutterInjector.instance().flutterLoader().findAppBundlePath(),
|
FlutterInjector.instance().flutterLoader().findAppBundlePath(),
|
||||||
"vpnService"
|
"vpnService"
|
||||||
|
|||||||
@@ -2,7 +2,8 @@ package com.follow.clash
|
|||||||
|
|
||||||
|
|
||||||
import com.follow.clash.plugins.AppPlugin
|
import com.follow.clash.plugins.AppPlugin
|
||||||
import com.follow.clash.plugins.ProxyPlugin
|
import com.follow.clash.plugins.ServicePlugin
|
||||||
|
import com.follow.clash.plugins.VpnPlugin
|
||||||
import com.follow.clash.plugins.TilePlugin
|
import com.follow.clash.plugins.TilePlugin
|
||||||
import io.flutter.embedding.android.FlutterActivity
|
import io.flutter.embedding.android.FlutterActivity
|
||||||
import io.flutter.embedding.engine.FlutterEngine
|
import io.flutter.embedding.engine.FlutterEngine
|
||||||
@@ -12,7 +13,8 @@ class MainActivity : FlutterActivity() {
|
|||||||
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
|
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
|
||||||
super.configureFlutterEngine(flutterEngine)
|
super.configureFlutterEngine(flutterEngine)
|
||||||
flutterEngine.plugins.add(AppPlugin())
|
flutterEngine.plugins.add(AppPlugin())
|
||||||
flutterEngine.plugins.add(ProxyPlugin())
|
flutterEngine.plugins.add(VpnPlugin())
|
||||||
|
flutterEngine.plugins.add(ServicePlugin())
|
||||||
flutterEngine.plugins.add(TilePlugin())
|
flutterEngine.plugins.add(TilePlugin())
|
||||||
GlobalState.flutterEngine = flutterEngine
|
GlobalState.flutterEngine = flutterEngine
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,28 @@
|
|||||||
package com.follow.clash.extensions
|
package com.follow.clash.extensions
|
||||||
|
|
||||||
|
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.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
|
import android.os.Build
|
||||||
import android.system.OsConstants.IPPROTO_TCP
|
import android.system.OsConstants.IPPROTO_TCP
|
||||||
import android.system.OsConstants.IPPROTO_UDP
|
import android.system.OsConstants.IPPROTO_UDP
|
||||||
import android.util.Base64
|
import android.util.Base64
|
||||||
import java.net.URL
|
import androidx.core.app.NotificationCompat
|
||||||
import androidx.core.graphics.drawable.toBitmap
|
import androidx.core.graphics.drawable.toBitmap
|
||||||
|
import com.follow.clash.MainActivity
|
||||||
|
import com.follow.clash.R
|
||||||
import com.follow.clash.models.Metadata
|
import com.follow.clash.models.Metadata
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import java.io.ByteArrayOutputStream
|
import java.io.ByteArrayOutputStream
|
||||||
import java.net.InetAddress
|
|
||||||
import java.net.InetSocketAddress
|
|
||||||
|
|
||||||
|
|
||||||
suspend fun Drawable.getBase64(): String {
|
suspend fun Drawable.getBase64(): String {
|
||||||
@@ -31,7 +41,6 @@ fun Metadata.getProtocol(): Int? {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
fun String.getInetSocketAddress(): InetSocketAddress {
|
private val CHANNEL = "FlClash"
|
||||||
val url = URL("https://$this")
|
|
||||||
return InetSocketAddress(InetAddress.getByName(url.host), url.port)
|
private val notificationId: Int = 1
|
||||||
}
|
|
||||||
@@ -1,7 +1,10 @@
|
|||||||
package com.follow.clash.models
|
package com.follow.clash.models
|
||||||
|
|
||||||
|
import java.util.Date
|
||||||
|
|
||||||
data class Package(
|
data class Package(
|
||||||
val packageName: String,
|
val packageName: String,
|
||||||
val label: String,
|
val label: String,
|
||||||
val isSystem:Boolean
|
val isSystem: Boolean,
|
||||||
|
val firstInstallTime: Long,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ data class AccessControl(
|
|||||||
)
|
)
|
||||||
|
|
||||||
data class Props(
|
data class Props(
|
||||||
|
val enable: Boolean?,
|
||||||
val accessControl: AccessControl?,
|
val accessControl: AccessControl?,
|
||||||
val allowBypass: Boolean?,
|
val allowBypass: Boolean?,
|
||||||
val systemProxy: Boolean?,
|
val systemProxy: Boolean?,
|
||||||
|
|||||||
@@ -6,11 +6,16 @@ import android.app.ActivityManager
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.pm.ApplicationInfo
|
import android.content.pm.ApplicationInfo
|
||||||
|
import android.content.pm.ComponentInfo
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import android.net.ConnectivityManager
|
import android.net.ConnectivityManager
|
||||||
|
import android.net.VpnService
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
|
import androidx.core.app.ActivityCompat
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.content.ContextCompat.getSystemService
|
import androidx.core.content.ContextCompat.getSystemService
|
||||||
|
import com.android.tools.smali.dexlib2.dexbacked.DexBackedDexFile
|
||||||
import androidx.core.content.FileProvider
|
import androidx.core.content.FileProvider
|
||||||
import androidx.core.content.getSystemService
|
import androidx.core.content.getSystemService
|
||||||
import com.follow.clash.GlobalState
|
import com.follow.clash.GlobalState
|
||||||
@@ -19,6 +24,7 @@ import com.follow.clash.extensions.getProtocol
|
|||||||
import com.follow.clash.models.Package
|
import com.follow.clash.models.Package
|
||||||
import com.follow.clash.models.Process
|
import com.follow.clash.models.Process
|
||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
|
import io.flutter.embedding.android.FlutterActivity
|
||||||
import io.flutter.embedding.engine.plugins.FlutterPlugin
|
import io.flutter.embedding.engine.plugins.FlutterPlugin
|
||||||
import io.flutter.embedding.engine.plugins.activity.ActivityAware
|
import io.flutter.embedding.engine.plugins.activity.ActivityAware
|
||||||
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding
|
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding
|
||||||
@@ -32,7 +38,7 @@ import kotlinx.coroutines.launch
|
|||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.net.InetSocketAddress
|
import java.net.InetSocketAddress
|
||||||
|
import java.util.zip.ZipFile
|
||||||
|
|
||||||
class AppPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware {
|
class AppPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware {
|
||||||
|
|
||||||
@@ -40,7 +46,7 @@ class AppPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware
|
|||||||
|
|
||||||
private var toast: Toast? = null
|
private var toast: Toast? = null
|
||||||
|
|
||||||
private var context: Context? = null
|
private lateinit var context: Context
|
||||||
|
|
||||||
private lateinit var channel: MethodChannel
|
private lateinit var channel: MethodChannel
|
||||||
|
|
||||||
@@ -48,14 +54,78 @@ class AppPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware
|
|||||||
|
|
||||||
private var connectivity: ConnectivityManager? = null
|
private var connectivity: ConnectivityManager? = null
|
||||||
|
|
||||||
|
private var vpnCallBack: (() -> Unit)? = null
|
||||||
|
|
||||||
private val iconMap = mutableMapOf<String, String?>()
|
private val iconMap = mutableMapOf<String, String?>()
|
||||||
|
private val packages = mutableListOf<Package>()
|
||||||
|
|
||||||
|
private val skipPrefixList = listOf(
|
||||||
|
"com.google",
|
||||||
|
"com.android.chrome",
|
||||||
|
"com.android.vending",
|
||||||
|
"com.microsoft",
|
||||||
|
"com.apple",
|
||||||
|
"com.zhiliaoapp.musically", // Banned by China
|
||||||
|
)
|
||||||
|
|
||||||
|
private val chinaAppPrefixList = listOf(
|
||||||
|
"com.tencent",
|
||||||
|
"com.alibaba",
|
||||||
|
"com.umeng",
|
||||||
|
"com.qihoo",
|
||||||
|
"com.ali",
|
||||||
|
"com.alipay",
|
||||||
|
"com.amap",
|
||||||
|
"com.sina",
|
||||||
|
"com.weibo",
|
||||||
|
"com.vivo",
|
||||||
|
"com.xiaomi",
|
||||||
|
"com.huawei",
|
||||||
|
"com.taobao",
|
||||||
|
"com.secneo",
|
||||||
|
"s.h.e.l.l",
|
||||||
|
"com.stub",
|
||||||
|
"com.kiwisec",
|
||||||
|
"com.secshell",
|
||||||
|
"com.wrapper",
|
||||||
|
"cn.securitystack",
|
||||||
|
"com.mogosec",
|
||||||
|
"com.secoen",
|
||||||
|
"com.netease",
|
||||||
|
"com.mx",
|
||||||
|
"com.qq.e",
|
||||||
|
"com.baidu",
|
||||||
|
"com.bytedance",
|
||||||
|
"com.bugly",
|
||||||
|
"com.miui",
|
||||||
|
"com.oppo",
|
||||||
|
"com.coloros",
|
||||||
|
"com.iqoo",
|
||||||
|
"com.meizu",
|
||||||
|
"com.gionee",
|
||||||
|
"cn.nubia",
|
||||||
|
"com.oplus",
|
||||||
|
"andes.oplus",
|
||||||
|
"com.unionpay",
|
||||||
|
"cn.wps"
|
||||||
|
)
|
||||||
|
|
||||||
|
private val chinaAppRegex by lazy {
|
||||||
|
("(" + chinaAppPrefixList.joinToString("|").replace(".", "\\.") + ").*").toRegex()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
val VPN_PERMISSION_REQUEST_CODE = 1001
|
||||||
|
|
||||||
|
val NOTIFICATION_PERMISSION_REQUEST_CODE = 1002
|
||||||
|
|
||||||
|
private var isBlockNotification: Boolean = false
|
||||||
|
|
||||||
override fun onAttachedToEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
|
override fun onAttachedToEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
|
||||||
scope = CoroutineScope(Dispatchers.Default)
|
scope = CoroutineScope(Dispatchers.Default)
|
||||||
context = flutterPluginBinding.applicationContext;
|
context = flutterPluginBinding.applicationContext;
|
||||||
channel = MethodChannel(flutterPluginBinding.binaryMessenger, "app")
|
channel = MethodChannel(flutterPluginBinding.binaryMessenger, "app")
|
||||||
channel.setMethodCallHandler(this)
|
channel.setMethodCallHandler(this)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDetachedFromEngine(binding: FlutterPlugin.FlutterPluginBinding) {
|
override fun onDetachedFromEngine(binding: FlutterPlugin.FlutterPluginBinding) {
|
||||||
@@ -88,7 +158,13 @@ class AppPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware
|
|||||||
|
|
||||||
"getPackages" -> {
|
"getPackages" -> {
|
||||||
scope.launch {
|
scope.launch {
|
||||||
result.success(getPackages())
|
result.success(getPackagesToJson())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
"getChinaPackageNames" -> {
|
||||||
|
scope.launch {
|
||||||
|
result.success(getChinaPackageNames())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,7 +183,7 @@ class AppPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware
|
|||||||
}
|
}
|
||||||
if (iconMap["default"] == null) {
|
if (iconMap["default"] == null) {
|
||||||
iconMap["default"] =
|
iconMap["default"] =
|
||||||
context?.packageManager?.defaultActivityIcon?.getBase64()
|
context.packageManager?.defaultActivityIcon?.getBase64()
|
||||||
}
|
}
|
||||||
result.success(iconMap["default"])
|
result.success(iconMap["default"])
|
||||||
return@launch
|
return@launch
|
||||||
@@ -134,12 +210,8 @@ class AppPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware
|
|||||||
result.success(null)
|
result.success(null)
|
||||||
return@withContext
|
return@withContext
|
||||||
}
|
}
|
||||||
if (context == null) {
|
|
||||||
result.success(null)
|
|
||||||
return@withContext
|
|
||||||
}
|
|
||||||
if (connectivity == null) {
|
if (connectivity == null) {
|
||||||
connectivity = context!!.getSystemService<ConnectivityManager>()
|
connectivity = context.getSystemService<ConnectivityManager>()
|
||||||
}
|
}
|
||||||
val src = InetSocketAddress(metadata.sourceIP, metadata.sourcePort)
|
val src = InetSocketAddress(metadata.sourceIP, metadata.sourcePort)
|
||||||
val dst = InetSocketAddress(
|
val dst = InetSocketAddress(
|
||||||
@@ -155,7 +227,7 @@ class AppPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware
|
|||||||
result.success(null)
|
result.success(null)
|
||||||
return@withContext
|
return@withContext
|
||||||
}
|
}
|
||||||
val packages = context?.packageManager?.getPackagesForUid(uid)
|
val packages = context.packageManager?.getPackagesForUid(uid)
|
||||||
result.success(packages?.first())
|
result.success(packages?.first())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -180,46 +252,43 @@ class AppPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun openFile(path: String) {
|
private fun openFile(path: String) {
|
||||||
context?.let {
|
val file = File(path)
|
||||||
val file = File(path)
|
val uri = FileProvider.getUriForFile(
|
||||||
val uri = FileProvider.getUriForFile(
|
context,
|
||||||
it,
|
"${context.packageName}.fileProvider",
|
||||||
"${it.packageName}.fileProvider",
|
file
|
||||||
file
|
)
|
||||||
)
|
|
||||||
|
|
||||||
val intent = Intent(Intent.ACTION_VIEW).setDataAndType(
|
val intent = Intent(Intent.ACTION_VIEW).setDataAndType(
|
||||||
|
uri,
|
||||||
|
"text/plain"
|
||||||
|
)
|
||||||
|
|
||||||
|
val flags =
|
||||||
|
Intent.FLAG_GRANT_WRITE_URI_PERMISSION or Intent.FLAG_GRANT_READ_URI_PERMISSION
|
||||||
|
|
||||||
|
val resInfoList = context.packageManager.queryIntentActivities(
|
||||||
|
intent, PackageManager.MATCH_DEFAULT_ONLY
|
||||||
|
)
|
||||||
|
|
||||||
|
for (resolveInfo in resInfoList) {
|
||||||
|
val packageName = resolveInfo.activityInfo.packageName
|
||||||
|
context.grantUriPermission(
|
||||||
|
packageName,
|
||||||
uri,
|
uri,
|
||||||
"text/plain"
|
flags
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
val flags =
|
try {
|
||||||
Intent.FLAG_GRANT_WRITE_URI_PERMISSION or Intent.FLAG_GRANT_READ_URI_PERMISSION
|
activity?.startActivity(intent)
|
||||||
|
} catch (e: Exception) {
|
||||||
val resInfoList = it.packageManager.queryIntentActivities(
|
println(e)
|
||||||
intent, PackageManager.MATCH_DEFAULT_ONLY
|
|
||||||
)
|
|
||||||
|
|
||||||
for (resolveInfo in resInfoList) {
|
|
||||||
val packageName = resolveInfo.activityInfo.packageName
|
|
||||||
it.grantUriPermission(
|
|
||||||
packageName,
|
|
||||||
uri,
|
|
||||||
flags
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
activity?.startActivity(intent)
|
|
||||||
} catch (e: Exception) {
|
|
||||||
println(e)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateExcludeFromRecents(value: Boolean?) {
|
private fun updateExcludeFromRecents(value: Boolean?) {
|
||||||
if (context == null) return
|
val am = getSystemService(context, ActivityManager::class.java)
|
||||||
val am = getSystemService(context!!, ActivityManager::class.java)
|
|
||||||
val task = am?.appTasks?.firstOrNull {
|
val task = am?.appTasks?.firstOrNull {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||||
it.taskInfo.taskId == activity?.taskId
|
it.taskInfo.taskId == activity?.taskId
|
||||||
@@ -236,7 +305,7 @@ class AppPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware
|
|||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun getPackageIcon(packageName: String): String? {
|
private suspend fun getPackageIcon(packageName: String): String? {
|
||||||
val packageManager = context?.packageManager
|
val packageManager = context.packageManager
|
||||||
if (iconMap[packageName] == null) {
|
if (iconMap[packageName] == null) {
|
||||||
iconMap[packageName] = try {
|
iconMap[packageName] = try {
|
||||||
packageManager?.getApplicationIcon(packageName)?.getBase64()
|
packageManager?.getApplicationIcon(packageName)?.getBase64()
|
||||||
@@ -248,32 +317,144 @@ class AppPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware
|
|||||||
return iconMap[packageName]
|
return iconMap[packageName]
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun getPackages(): String {
|
private fun getPackages(): List<Package> {
|
||||||
return withContext(Dispatchers.Default) {
|
val packageManager = context.packageManager
|
||||||
val packageManager = context?.packageManager
|
if (packages.isNotEmpty()) return packages;
|
||||||
val packages: List<Package>? =
|
packageManager?.getInstalledPackages(PackageManager.GET_META_DATA)?.filter {
|
||||||
packageManager?.getInstalledPackages(PackageManager.GET_META_DATA)?.filter {
|
it.packageName != context.packageName
|
||||||
it.packageName != context?.packageName
|
|| it.requestedPermissions?.contains(Manifest.permission.INTERNET) == true
|
||||||
|| it.requestedPermissions?.contains(Manifest.permission.INTERNET) == true
|
|| it.packageName == "android"
|
||||||
|| it.packageName == "android"
|
|
||||||
|
|
||||||
}?.map {
|
}?.map {
|
||||||
Package(
|
Package(
|
||||||
packageName = it.packageName,
|
packageName = it.packageName,
|
||||||
label = it.applicationInfo.loadLabel(packageManager).toString(),
|
label = it.applicationInfo.loadLabel(packageManager).toString(),
|
||||||
isSystem = (it.applicationInfo.flags and ApplicationInfo.FLAG_SYSTEM) == 1
|
isSystem = (it.applicationInfo.flags and ApplicationInfo.FLAG_SYSTEM) == 1,
|
||||||
)
|
firstInstallTime = it.firstInstallTime
|
||||||
}
|
)
|
||||||
|
}?.let { packages.addAll(it) }
|
||||||
|
return packages;
|
||||||
|
}
|
||||||
|
|
||||||
|
private suspend fun getPackagesToJson(): String {
|
||||||
|
return withContext(Dispatchers.Default) {
|
||||||
|
Gson().toJson(getPackages())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private suspend fun getChinaPackageNames(): String {
|
||||||
|
return withContext(Dispatchers.Default) {
|
||||||
|
val packages: List<String> =
|
||||||
|
getPackages().map { it.packageName }.filter { isChinaPackage(it) }
|
||||||
Gson().toJson(packages)
|
Gson().toJson(packages)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun requestVpnPermission(context: Context, callBack: () -> Unit) {
|
||||||
|
vpnCallBack = callBack
|
||||||
|
val intent = VpnService.prepare(context)
|
||||||
|
if (intent != null) {
|
||||||
|
activity?.startActivityForResult(intent, VPN_PERMISSION_REQUEST_CODE)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
vpnCallBack?.invoke()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun requestNotificationsPermission(context: Context) {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||||
|
val permission = ContextCompat.checkSelfPermission(
|
||||||
|
context,
|
||||||
|
Manifest.permission.POST_NOTIFICATIONS
|
||||||
|
)
|
||||||
|
if (permission != PackageManager.PERMISSION_GRANTED) {
|
||||||
|
if (isBlockNotification) return
|
||||||
|
if (activity == null) return
|
||||||
|
ActivityCompat.requestPermissions(
|
||||||
|
activity!!,
|
||||||
|
arrayOf(Manifest.permission.POST_NOTIFICATIONS),
|
||||||
|
NOTIFICATION_PERMISSION_REQUEST_CODE
|
||||||
|
)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun isChinaPackage(packageName: String): Boolean {
|
||||||
|
val packageManager = context.packageManager ?: return false
|
||||||
|
skipPrefixList.forEach {
|
||||||
|
if (packageName == it || packageName.startsWith("$it.")) return false
|
||||||
|
}
|
||||||
|
val packageManagerFlags = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
|
PackageManager.MATCH_UNINSTALLED_PACKAGES or PackageManager.GET_ACTIVITIES or PackageManager.GET_SERVICES or PackageManager.GET_RECEIVERS or PackageManager.GET_PROVIDERS
|
||||||
|
} else {
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
|
PackageManager.GET_UNINSTALLED_PACKAGES or PackageManager.GET_ACTIVITIES or PackageManager.GET_SERVICES or PackageManager.GET_RECEIVERS or PackageManager.GET_PROVIDERS
|
||||||
|
}
|
||||||
|
if (packageName.matches(chinaAppRegex)) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
val packageInfo = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||||
|
packageManager.getPackageInfo(
|
||||||
|
packageName,
|
||||||
|
PackageManager.PackageInfoFlags.of(packageManagerFlags.toLong())
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
@Suppress("DEPRECATION") packageManager.getPackageInfo(
|
||||||
|
packageName, packageManagerFlags
|
||||||
|
)
|
||||||
|
}
|
||||||
|
mutableListOf<ComponentInfo>().apply {
|
||||||
|
packageInfo.services?.let { addAll(it) }
|
||||||
|
packageInfo.activities?.let { addAll(it) }
|
||||||
|
packageInfo.receivers?.let { addAll(it) }
|
||||||
|
packageInfo.providers?.let { addAll(it) }
|
||||||
|
}.forEach {
|
||||||
|
if (it.name.matches(chinaAppRegex)) return true
|
||||||
|
}
|
||||||
|
ZipFile(File(packageInfo.applicationInfo.publicSourceDir)).use {
|
||||||
|
for (packageEntry in it.entries()) {
|
||||||
|
if (packageEntry.name.startsWith("firebase-")) return false
|
||||||
|
}
|
||||||
|
for (packageEntry in it.entries()) {
|
||||||
|
if (!(packageEntry.name.startsWith("classes") && packageEntry.name.endsWith(
|
||||||
|
".dex"
|
||||||
|
))
|
||||||
|
) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if (packageEntry.size > 15000000) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
val input = it.getInputStream(packageEntry).buffered()
|
||||||
|
val dexFile = try {
|
||||||
|
DexBackedDexFile.fromInputStream(null, input)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
for (clazz in dexFile.classes) {
|
||||||
|
val clazzName =
|
||||||
|
clazz.type.substring(1, clazz.type.length - 1).replace("/", ".")
|
||||||
|
.replace("$", ".")
|
||||||
|
if (clazzName.matches(chinaAppRegex)) return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (_: Exception) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
fun requestGc() {
|
fun requestGc() {
|
||||||
channel.invokeMethod("gc", null)
|
channel.invokeMethod("gc", null)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onAttachedToActivity(binding: ActivityPluginBinding) {
|
override fun onAttachedToActivity(binding: ActivityPluginBinding) {
|
||||||
activity = binding.activity;
|
activity = binding.activity;
|
||||||
|
binding.addActivityResultListener(::onActivityResult)
|
||||||
|
binding.addRequestPermissionsResultListener(::onRequestPermissionsResultListener)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDetachedFromActivityForConfigChanges() {
|
override fun onDetachedFromActivityForConfigChanges() {
|
||||||
@@ -288,4 +469,25 @@ class AppPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware
|
|||||||
channel.invokeMethod("exit", null)
|
channel.invokeMethod("exit", null)
|
||||||
activity = null
|
activity = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?): Boolean {
|
||||||
|
if (requestCode == VPN_PERMISSION_REQUEST_CODE) {
|
||||||
|
if (resultCode == FlutterActivity.RESULT_OK) {
|
||||||
|
GlobalState.initServiceEngine(context)
|
||||||
|
vpnCallBack?.invoke()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun onRequestPermissionsResultListener(
|
||||||
|
requestCode: Int,
|
||||||
|
permissions: Array<String>,
|
||||||
|
grantResults: IntArray
|
||||||
|
): Boolean {
|
||||||
|
if (requestCode == NOTIFICATION_PERMISSION_REQUEST_CODE) {
|
||||||
|
isBlockNotification = true
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,220 +0,0 @@
|
|||||||
package com.follow.clash.plugins
|
|
||||||
|
|
||||||
import android.Manifest
|
|
||||||
import android.app.Activity
|
|
||||||
import android.content.ComponentName
|
|
||||||
import android.content.Context
|
|
||||||
import android.content.Intent
|
|
||||||
import android.content.ServiceConnection
|
|
||||||
import android.content.pm.PackageManager
|
|
||||||
import android.net.VpnService
|
|
||||||
import android.os.Build
|
|
||||||
import android.os.IBinder
|
|
||||||
import android.util.Log
|
|
||||||
import androidx.core.app.ActivityCompat
|
|
||||||
import androidx.core.content.ContextCompat
|
|
||||||
import com.follow.clash.GlobalState
|
|
||||||
import com.follow.clash.RunState
|
|
||||||
import com.follow.clash.models.Props
|
|
||||||
import com.follow.clash.services.FlClashVpnService
|
|
||||||
import com.google.gson.Gson
|
|
||||||
import io.flutter.embedding.android.FlutterActivity
|
|
||||||
import io.flutter.embedding.engine.plugins.FlutterPlugin
|
|
||||||
import io.flutter.embedding.engine.plugins.activity.ActivityAware
|
|
||||||
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding
|
|
||||||
import io.flutter.plugin.common.MethodCall
|
|
||||||
import io.flutter.plugin.common.MethodChannel
|
|
||||||
|
|
||||||
|
|
||||||
class ProxyPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware {
|
|
||||||
|
|
||||||
private lateinit var flutterMethodChannel: MethodChannel
|
|
||||||
|
|
||||||
val VPN_PERMISSION_REQUEST_CODE = 1001
|
|
||||||
val NOTIFICATION_PERMISSION_REQUEST_CODE = 1002
|
|
||||||
|
|
||||||
private var activity: Activity? = null
|
|
||||||
private var context: Context? = null
|
|
||||||
private var flClashVpnService: FlClashVpnService? = null
|
|
||||||
private var port: Int = 7890
|
|
||||||
private var props: Props? = null
|
|
||||||
private var isBlockNotification: Boolean = false
|
|
||||||
private var isStart: Boolean = false
|
|
||||||
|
|
||||||
private val connection = object : ServiceConnection {
|
|
||||||
override fun onServiceConnected(className: ComponentName, service: IBinder) {
|
|
||||||
val binder = service as FlClashVpnService.LocalBinder
|
|
||||||
flClashVpnService = binder.getService()
|
|
||||||
if (isStart) {
|
|
||||||
startVpn()
|
|
||||||
} else {
|
|
||||||
flClashVpnService?.initServiceEngine()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onServiceDisconnected(arg: ComponentName) {
|
|
||||||
flClashVpnService = null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onAttachedToEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
|
|
||||||
context = flutterPluginBinding.applicationContext
|
|
||||||
flutterMethodChannel = MethodChannel(flutterPluginBinding.binaryMessenger, "proxy")
|
|
||||||
flutterMethodChannel.setMethodCallHandler(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onDetachedFromEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
|
|
||||||
flutterMethodChannel.setMethodCallHandler(null)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) = when (call.method) {
|
|
||||||
"initService" -> {
|
|
||||||
isStart = false
|
|
||||||
initService()
|
|
||||||
requestNotificationsPermission()
|
|
||||||
result.success(true)
|
|
||||||
}
|
|
||||||
|
|
||||||
"startProxy" -> {
|
|
||||||
isStart = true
|
|
||||||
port = call.argument<Int>("port")!!
|
|
||||||
val args = call.argument<String>("args")
|
|
||||||
props =
|
|
||||||
if (args != null) Gson().fromJson(args, Props::class.java) else null
|
|
||||||
startVpn()
|
|
||||||
result.success(true)
|
|
||||||
}
|
|
||||||
|
|
||||||
"stopProxy" -> {
|
|
||||||
stopVpn()
|
|
||||||
result.success(true)
|
|
||||||
}
|
|
||||||
|
|
||||||
"setProtect" -> {
|
|
||||||
val fd = call.argument<Int>("fd")
|
|
||||||
if (fd != null) {
|
|
||||||
flClashVpnService?.protect(fd)
|
|
||||||
result.success(true)
|
|
||||||
} else {
|
|
||||||
result.success(false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
"startForeground" -> {
|
|
||||||
val title = call.argument<String>("title") as String
|
|
||||||
val content = call.argument<String>("content") as String
|
|
||||||
startForeground(title, content)
|
|
||||||
result.success(true)
|
|
||||||
}
|
|
||||||
|
|
||||||
else -> {
|
|
||||||
result.notImplemented()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun initService() {
|
|
||||||
val intent = VpnService.prepare(context)
|
|
||||||
if (intent != null) {
|
|
||||||
activity?.startActivityForResult(intent, VPN_PERMISSION_REQUEST_CODE)
|
|
||||||
} else {
|
|
||||||
if (flClashVpnService != null) {
|
|
||||||
flClashVpnService!!.initServiceEngine()
|
|
||||||
} else {
|
|
||||||
bindService()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun startVpn() {
|
|
||||||
if (flClashVpnService == null) {
|
|
||||||
bindService()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (GlobalState.runState.value == RunState.START) return
|
|
||||||
GlobalState.runState.value = RunState.START
|
|
||||||
val intent = VpnService.prepare(context)
|
|
||||||
if (intent != null) {
|
|
||||||
stopVpn()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
val fd = flClashVpnService?.start(port, props)
|
|
||||||
flutterMethodChannel.invokeMethod("started", fd)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun stopVpn() {
|
|
||||||
if (GlobalState.runState.value == RunState.STOP) return
|
|
||||||
GlobalState.runState.value = RunState.STOP
|
|
||||||
flClashVpnService?.stop()
|
|
||||||
GlobalState.destroyServiceEngine()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun startForeground(title: String, content: String) {
|
|
||||||
if (GlobalState.runState.value != RunState.START) return
|
|
||||||
flClashVpnService?.startForeground(title, content)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onAttachedToActivity(binding: ActivityPluginBinding) {
|
|
||||||
activity = binding.activity
|
|
||||||
binding.addActivityResultListener(::onActivityResult)
|
|
||||||
binding.addRequestPermissionsResultListener(::onRequestPermissionsResultListener)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?): Boolean {
|
|
||||||
if (requestCode == VPN_PERMISSION_REQUEST_CODE) {
|
|
||||||
if (resultCode == FlutterActivity.RESULT_OK) {
|
|
||||||
bindService()
|
|
||||||
} else {
|
|
||||||
stopVpn()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun onRequestPermissionsResultListener(
|
|
||||||
requestCode: Int,
|
|
||||||
permissions: Array<String>,
|
|
||||||
grantResults: IntArray
|
|
||||||
): Boolean {
|
|
||||||
if (requestCode == NOTIFICATION_PERMISSION_REQUEST_CODE) {
|
|
||||||
isBlockNotification = true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun requestNotificationsPermission() {
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
|
||||||
val permission = context?.let {
|
|
||||||
ContextCompat.checkSelfPermission(
|
|
||||||
it,
|
|
||||||
Manifest.permission.POST_NOTIFICATIONS
|
|
||||||
)
|
|
||||||
}
|
|
||||||
if (permission != PackageManager.PERMISSION_GRANTED) {
|
|
||||||
if (isBlockNotification) return
|
|
||||||
if (activity == null) return
|
|
||||||
ActivityCompat.requestPermissions(
|
|
||||||
activity!!,
|
|
||||||
arrayOf(Manifest.permission.POST_NOTIFICATIONS),
|
|
||||||
NOTIFICATION_PERMISSION_REQUEST_CODE
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onDetachedFromActivityForConfigChanges() {
|
|
||||||
activity = null
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onReattachedToActivityForConfigChanges(binding: ActivityPluginBinding) {
|
|
||||||
activity = binding.activity
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onDetachedFromActivity() {
|
|
||||||
activity = null
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun bindService() {
|
|
||||||
val intent = Intent(context, FlClashVpnService::class.java)
|
|
||||||
context?.bindService(intent, connection, Context.BIND_AUTO_CREATE)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
package com.follow.clash.plugins
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import com.follow.clash.GlobalState
|
||||||
|
import io.flutter.embedding.engine.plugins.FlutterPlugin
|
||||||
|
import io.flutter.plugin.common.MethodCall
|
||||||
|
import io.flutter.plugin.common.MethodChannel
|
||||||
|
|
||||||
|
|
||||||
|
class ServicePlugin : FlutterPlugin, MethodChannel.MethodCallHandler {
|
||||||
|
|
||||||
|
private lateinit var flutterMethodChannel: MethodChannel
|
||||||
|
|
||||||
|
private lateinit var context: Context
|
||||||
|
|
||||||
|
override fun onAttachedToEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
|
||||||
|
context = flutterPluginBinding.applicationContext
|
||||||
|
flutterMethodChannel = MethodChannel(flutterPluginBinding.binaryMessenger, "service")
|
||||||
|
flutterMethodChannel.setMethodCallHandler(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDetachedFromEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
|
||||||
|
flutterMethodChannel.setMethodCallHandler(null)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) = when (call.method) {
|
||||||
|
"init" -> {
|
||||||
|
GlobalState.getCurrentAppPlugin()?.requestNotificationsPermission(context)
|
||||||
|
GlobalState.initServiceEngine(context)
|
||||||
|
result.success(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
"destroy" -> {
|
||||||
|
handleDestroy()
|
||||||
|
result.success(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> {
|
||||||
|
result.notImplemented()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun handleDestroy() {
|
||||||
|
GlobalState.getCurrentVPNPlugin()?.stop()
|
||||||
|
GlobalState.destroyServiceEngine()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,143 @@
|
|||||||
|
package com.follow.clash.plugins
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
|
import android.content.ComponentName
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.content.ServiceConnection
|
||||||
|
import android.os.IBinder
|
||||||
|
import android.util.Log
|
||||||
|
import com.follow.clash.BaseServiceInterface
|
||||||
|
import com.follow.clash.GlobalState
|
||||||
|
import com.follow.clash.RunState
|
||||||
|
import com.follow.clash.models.Props
|
||||||
|
import com.follow.clash.services.FlClashService
|
||||||
|
import com.follow.clash.services.FlClashVpnService
|
||||||
|
import com.google.gson.Gson
|
||||||
|
import io.flutter.embedding.engine.plugins.FlutterPlugin
|
||||||
|
import io.flutter.plugin.common.MethodCall
|
||||||
|
import io.flutter.plugin.common.MethodChannel
|
||||||
|
import kotlin.concurrent.withLock
|
||||||
|
|
||||||
|
|
||||||
|
class VpnPlugin : FlutterPlugin, MethodChannel.MethodCallHandler {
|
||||||
|
private lateinit var flutterMethodChannel: MethodChannel
|
||||||
|
private lateinit var context: Context
|
||||||
|
private var flClashService: BaseServiceInterface? = null
|
||||||
|
private var port: Int = 7890
|
||||||
|
private var props: Props? = null
|
||||||
|
|
||||||
|
private val connection = object : ServiceConnection {
|
||||||
|
override fun onServiceConnected(className: ComponentName, service: IBinder) {
|
||||||
|
flClashService = when (service) {
|
||||||
|
is FlClashVpnService.LocalBinder -> service.getService()
|
||||||
|
is FlClashService.LocalBinder -> service.getService()
|
||||||
|
else -> throw Exception("invalid binder")
|
||||||
|
}
|
||||||
|
start()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onServiceDisconnected(arg: ComponentName) {
|
||||||
|
flClashService = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onAttachedToEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
|
||||||
|
context = flutterPluginBinding.applicationContext
|
||||||
|
flutterMethodChannel = MethodChannel(flutterPluginBinding.binaryMessenger, "vpn")
|
||||||
|
flutterMethodChannel.setMethodCallHandler(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDetachedFromEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
|
||||||
|
flutterMethodChannel.setMethodCallHandler(null)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) = when (call.method) {
|
||||||
|
|
||||||
|
"start" -> {
|
||||||
|
port = call.argument<Int>("port")!!
|
||||||
|
val args = call.argument<String>("args")
|
||||||
|
props =
|
||||||
|
if (args != null) Gson().fromJson(args, Props::class.java) else null
|
||||||
|
when (props?.enable == true) {
|
||||||
|
true -> handleStartVpn()
|
||||||
|
false -> start()
|
||||||
|
}
|
||||||
|
result.success(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
"stop" -> {
|
||||||
|
stop()
|
||||||
|
result.success(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
"setProtect" -> {
|
||||||
|
val fd = call.argument<Int>("fd")
|
||||||
|
if (fd != null) {
|
||||||
|
if (flClashService is FlClashVpnService) {
|
||||||
|
(flClashService as FlClashVpnService).protect(fd)
|
||||||
|
}
|
||||||
|
result.success(true)
|
||||||
|
} else {
|
||||||
|
result.success(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
"startForeground" -> {
|
||||||
|
val title = call.argument<String>("title") as String
|
||||||
|
val content = call.argument<String>("content") as String
|
||||||
|
startForeground(title, content)
|
||||||
|
result.success(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> {
|
||||||
|
result.notImplemented()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("ForegroundServiceType")
|
||||||
|
fun handleStartVpn() {
|
||||||
|
GlobalState.getCurrentAppPlugin()?.requestVpnPermission(context) {
|
||||||
|
start()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("ForegroundServiceType")
|
||||||
|
private fun startForeground(title: String, content: String) {
|
||||||
|
GlobalState.runLock.withLock {
|
||||||
|
if (GlobalState.runState.value != RunState.START) return
|
||||||
|
flClashService?.startForeground(title, content)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun start() {
|
||||||
|
if (flClashService == null) {
|
||||||
|
bindService()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
GlobalState.runLock.withLock {
|
||||||
|
if (GlobalState.runState.value == RunState.START) return
|
||||||
|
GlobalState.runState.value = RunState.START
|
||||||
|
val fd = flClashService?.start(port, props)
|
||||||
|
flutterMethodChannel.invokeMethod("started", fd)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun stop() {
|
||||||
|
GlobalState.runLock.withLock {
|
||||||
|
if (GlobalState.runState.value == RunState.STOP) return
|
||||||
|
GlobalState.runState.value = RunState.STOP
|
||||||
|
flClashService?.stop()
|
||||||
|
}
|
||||||
|
GlobalState.destroyServiceEngine()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun bindService() {
|
||||||
|
val intent = when (props?.enable == true) {
|
||||||
|
true -> Intent(context, FlClashVpnService::class.java)
|
||||||
|
false -> Intent(context, FlClashService::class.java)
|
||||||
|
}
|
||||||
|
context.bindService(intent, connection, Context.BIND_AUTO_CREATE)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,104 @@
|
|||||||
|
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.os.Binder
|
||||||
|
import android.os.Build
|
||||||
|
import android.os.IBinder
|
||||||
|
import android.util.Log
|
||||||
|
import androidx.core.app.NotificationCompat
|
||||||
|
import com.follow.clash.BaseServiceInterface
|
||||||
|
import com.follow.clash.MainActivity
|
||||||
|
import com.follow.clash.models.Props
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressLint("WrongConstant")
|
||||||
|
class FlClashService : Service(), BaseServiceInterface {
|
||||||
|
|
||||||
|
private val binder = LocalBinder()
|
||||||
|
|
||||||
|
inner class LocalBinder : Binder() {
|
||||||
|
fun getService(): FlClashService = this@FlClashService
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onBind(intent: Intent): IBinder {
|
||||||
|
return binder
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onUnbind(intent: Intent?): Boolean {
|
||||||
|
return super.onUnbind(intent)
|
||||||
|
}
|
||||||
|
|
||||||
|
private val CHANNEL = "FlClash"
|
||||||
|
|
||||||
|
private val notificationId: Int = 1
|
||||||
|
|
||||||
|
private val notificationBuilder: NotificationCompat.Builder by lazy {
|
||||||
|
val intent = Intent(this, MainActivity::class.java)
|
||||||
|
|
||||||
|
val pendingIntent = if (Build.VERSION.SDK_INT >= 31) {
|
||||||
|
PendingIntent.getActivity(
|
||||||
|
this,
|
||||||
|
0,
|
||||||
|
intent,
|
||||||
|
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
PendingIntent.getActivity(
|
||||||
|
this,
|
||||||
|
0,
|
||||||
|
intent,
|
||||||
|
PendingIntent.FLAG_UPDATE_CURRENT
|
||||||
|
)
|
||||||
|
}
|
||||||
|
with(NotificationCompat.Builder(this, CHANNEL)) {
|
||||||
|
setSmallIcon(com.follow.clash.R.drawable.ic_stat_name)
|
||||||
|
setContentTitle("FlClash")
|
||||||
|
setContentIntent(pendingIntent)
|
||||||
|
setCategory(NotificationCompat.CATEGORY_SERVICE)
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun start(port: Int, props: Props?): Int? = null
|
||||||
|
|
||||||
|
override fun stop() {
|
||||||
|
stopSelf()
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||||
|
stopForeground(STOP_FOREGROUND_REMOVE)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("ForegroundServiceType", "WrongConstant")
|
||||||
|
override fun startForeground(title: String, content: String) {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
|
val manager = getSystemService(NotificationManager::class.java)
|
||||||
|
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) {
|
||||||
|
startForeground(notificationId, notification, FOREGROUND_SERVICE_TYPE_SPECIAL_USE)
|
||||||
|
} else {
|
||||||
|
startForeground(notificationId, notification)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.follow.clash.services
|
package com.follow.clash.services
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.app.Notification.FOREGROUND_SERVICE_IMMEDIATE
|
import android.app.Notification.FOREGROUND_SERVICE_IMMEDIATE
|
||||||
import android.app.NotificationChannel
|
import android.app.NotificationChannel
|
||||||
import android.app.NotificationManager
|
import android.app.NotificationManager
|
||||||
@@ -15,6 +16,7 @@ import android.os.Parcel
|
|||||||
import android.os.RemoteException
|
import android.os.RemoteException
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.core.app.NotificationCompat
|
import androidx.core.app.NotificationCompat
|
||||||
|
import com.follow.clash.BaseServiceInterface
|
||||||
import com.follow.clash.GlobalState
|
import com.follow.clash.GlobalState
|
||||||
import com.follow.clash.MainActivity
|
import com.follow.clash.MainActivity
|
||||||
import com.follow.clash.R
|
import com.follow.clash.R
|
||||||
@@ -25,10 +27,8 @@ import kotlinx.coroutines.Dispatchers
|
|||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
|
|
||||||
class FlClashVpnService : VpnService() {
|
@SuppressLint("WrongConstant")
|
||||||
private val CHANNEL = "FlClash"
|
class FlClashVpnService : VpnService(), BaseServiceInterface {
|
||||||
|
|
||||||
private val notificationId: Int = 1
|
|
||||||
|
|
||||||
private val passList = listOf(
|
private val passList = listOf(
|
||||||
"*zhihu.com",
|
"*zhihu.com",
|
||||||
@@ -52,10 +52,10 @@ class FlClashVpnService : VpnService() {
|
|||||||
|
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
super.onCreate()
|
super.onCreate()
|
||||||
initServiceEngine()
|
GlobalState.initServiceEngine(applicationContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun start(port: Int, props: Props?): Int? {
|
override fun start(port: Int, props: Props?): Int? {
|
||||||
return with(Builder()) {
|
return with(Builder()) {
|
||||||
addAddress("172.16.0.1", 30)
|
addAddress("172.16.0.1", 30)
|
||||||
setMtu(9000)
|
setMtu(9000)
|
||||||
@@ -97,11 +97,18 @@ class FlClashVpnService : VpnService() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun stop() {
|
|
||||||
|
override fun stop() {
|
||||||
stopSelf()
|
stopSelf()
|
||||||
stopForeground()
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||||
|
stopForeground(STOP_FOREGROUND_REMOVE)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val CHANNEL = "FlClash"
|
||||||
|
|
||||||
|
private val notificationId: Int = 1
|
||||||
|
|
||||||
private val notificationBuilder: NotificationCompat.Builder by lazy {
|
private val notificationBuilder: NotificationCompat.Builder by lazy {
|
||||||
val intent = Intent(this, MainActivity::class.java)
|
val intent = Intent(this, MainActivity::class.java)
|
||||||
|
|
||||||
@@ -136,16 +143,8 @@ class FlClashVpnService : VpnService() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun initServiceEngine() {
|
@SuppressLint("ForegroundServiceType", "WrongConstant")
|
||||||
GlobalState.initServiceEngine(applicationContext)
|
override fun startForeground(title: String, content: String) {
|
||||||
}
|
|
||||||
|
|
||||||
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) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
val manager = getSystemService(NotificationManager::class.java)
|
val manager = getSystemService(NotificationManager::class.java)
|
||||||
var channel = manager?.getNotificationChannel(CHANNEL)
|
var channel = manager?.getNotificationChannel(CHANNEL)
|
||||||
@@ -157,17 +156,16 @@ class FlClashVpnService : VpnService() {
|
|||||||
}
|
}
|
||||||
val notification =
|
val notification =
|
||||||
notificationBuilder.setContentTitle(title).setContentText(content).build()
|
notificationBuilder.setContentTitle(title).setContentText(content).build()
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
|
||||||
startForeground(notificationId, notification, FOREGROUND_SERVICE_TYPE_SPECIAL_USE)
|
startForeground(notificationId, notification, FOREGROUND_SERVICE_TYPE_SPECIAL_USE)
|
||||||
} else {
|
} else {
|
||||||
startForeground(notificationId, notification)
|
startForeground(notificationId, notification)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun stopForeground() {
|
override fun onTrimMemory(level: Int) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
super.onTrimMemory(level)
|
||||||
stopForeground(STOP_FOREGROUND_REMOVE)
|
GlobalState.getCurrentAppPlugin()?.requestGc()
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private val binder = LocalBinder()
|
private val binder = LocalBinder()
|
||||||
@@ -190,7 +188,6 @@ class FlClashVpnService : VpnService() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun onBind(intent: Intent): IBinder {
|
override fun onBind(intent: Intent): IBinder {
|
||||||
return binder
|
return binder
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
assets/fonts/Twemoji.Mozilla.ttf
Normal file
BIN
assets/fonts/Twemoji.Mozilla.ttf
Normal file
Binary file not shown.
Submodule core/Clash.Meta updated: 3d773d7fa5...0125a90a77
264
core/common.go
264
core/common.go
@@ -2,20 +2,9 @@ package main
|
|||||||
|
|
||||||
import "C"
|
import "C"
|
||||||
import (
|
import (
|
||||||
"github.com/metacubex/mihomo/adapter"
|
"context"
|
||||||
"github.com/metacubex/mihomo/adapter/inbound"
|
"errors"
|
||||||
"github.com/metacubex/mihomo/adapter/outboundgroup"
|
"math"
|
||||||
ap "github.com/metacubex/mihomo/adapter/provider"
|
|
||||||
"github.com/metacubex/mihomo/component/dialer"
|
|
||||||
"github.com/metacubex/mihomo/component/resolver"
|
|
||||||
"github.com/metacubex/mihomo/config"
|
|
||||||
"github.com/metacubex/mihomo/constant"
|
|
||||||
"github.com/metacubex/mihomo/hub"
|
|
||||||
"github.com/metacubex/mihomo/hub/executor"
|
|
||||||
"github.com/metacubex/mihomo/hub/route"
|
|
||||||
"github.com/metacubex/mihomo/listener"
|
|
||||||
"github.com/metacubex/mihomo/log"
|
|
||||||
"github.com/metacubex/mihomo/tunnel"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@@ -24,43 +13,27 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/metacubex/mihomo/adapter"
|
||||||
|
"github.com/metacubex/mihomo/adapter/inbound"
|
||||||
|
"github.com/metacubex/mihomo/adapter/outboundgroup"
|
||||||
|
"github.com/metacubex/mihomo/adapter/provider"
|
||||||
|
"github.com/metacubex/mihomo/common/batch"
|
||||||
|
"github.com/metacubex/mihomo/component/dialer"
|
||||||
|
"github.com/metacubex/mihomo/component/resolver"
|
||||||
|
"github.com/metacubex/mihomo/component/sniffer"
|
||||||
|
"github.com/metacubex/mihomo/config"
|
||||||
|
"github.com/metacubex/mihomo/constant"
|
||||||
|
cp "github.com/metacubex/mihomo/constant/provider"
|
||||||
|
"github.com/metacubex/mihomo/hub"
|
||||||
|
"github.com/metacubex/mihomo/hub/executor"
|
||||||
|
"github.com/metacubex/mihomo/hub/route"
|
||||||
|
"github.com/metacubex/mihomo/listener"
|
||||||
|
"github.com/metacubex/mihomo/log"
|
||||||
|
rp "github.com/metacubex/mihomo/rules/provider"
|
||||||
|
"github.com/metacubex/mihomo/tunnel"
|
||||||
)
|
)
|
||||||
|
|
||||||
type healthCheckSchema struct {
|
|
||||||
Enable bool `provider:"enable"`
|
|
||||||
URL string `provider:"url"`
|
|
||||||
Interval int `provider:"interval"`
|
|
||||||
TestTimeout int `provider:"timeout,omitempty"`
|
|
||||||
Lazy bool `provider:"lazy,omitempty"`
|
|
||||||
ExpectedStatus string `provider:"expected-status,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type proxyProviderSchema struct {
|
|
||||||
Type string `provider:"type"`
|
|
||||||
Path string `provider:"path,omitempty"`
|
|
||||||
URL string `provider:"url,omitempty"`
|
|
||||||
Proxy string `provider:"proxy,omitempty"`
|
|
||||||
Interval int `provider:"interval,omitempty"`
|
|
||||||
Filter string `provider:"filter,omitempty"`
|
|
||||||
ExcludeFilter string `provider:"exclude-filter,omitempty"`
|
|
||||||
ExcludeType string `provider:"exclude-type,omitempty"`
|
|
||||||
DialerProxy string `provider:"dialer-proxy,omitempty"`
|
|
||||||
|
|
||||||
HealthCheck healthCheckSchema `provider:"health-check,omitempty"`
|
|
||||||
Override ap.OverrideSchema `provider:"override,omitempty"`
|
|
||||||
Header map[string][]string `provider:"header,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ruleProviderSchema struct {
|
|
||||||
Type string `provider:"type"`
|
|
||||||
Behavior string `provider:"behavior"`
|
|
||||||
Path string `provider:"path,omitempty"`
|
|
||||||
URL string `provider:"url,omitempty"`
|
|
||||||
Proxy string `provider:"proxy,omitempty"`
|
|
||||||
Format string `provider:"format,omitempty"`
|
|
||||||
Interval int `provider:"interval,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ConfigExtendedParams struct {
|
type ConfigExtendedParams struct {
|
||||||
IsPatch bool `json:"is-patch"`
|
IsPatch bool `json:"is-patch"`
|
||||||
IsCompatible bool `json:"is-compatible"`
|
IsCompatible bool `json:"is-compatible"`
|
||||||
@@ -69,9 +42,9 @@ type ConfigExtendedParams struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type GenerateConfigParams struct {
|
type GenerateConfigParams struct {
|
||||||
ProfilePath *string `json:"profile-path"`
|
ProfileId string `json:"profile-id"`
|
||||||
Config config.RawConfig `json:"config" `
|
Config config.RawConfig `json:"config" `
|
||||||
Params ConfigExtendedParams `json:"params"`
|
Params ConfigExtendedParams `json:"params"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ChangeProxyParams struct {
|
type ChangeProxyParams struct {
|
||||||
@@ -93,9 +66,19 @@ type ExternalProvider struct {
|
|||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
VehicleType string `json:"vehicle-type"`
|
VehicleType string `json:"vehicle-type"`
|
||||||
|
Count int `json:"count"`
|
||||||
|
Path string `json:"path"`
|
||||||
UpdateAt time.Time `json:"update-at"`
|
UpdateAt time.Time `json:"update-at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ExternalProviders []ExternalProvider
|
||||||
|
|
||||||
|
func (a ExternalProviders) Len() int { return len(a) }
|
||||||
|
func (a ExternalProviders) Less(i, j int) bool { return a[i].Name < a[j].Name }
|
||||||
|
func (a ExternalProviders) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
||||||
|
|
||||||
|
var b, _ = batch.New[bool](context.Background(), batch.WithConcurrencyNum[bool](50))
|
||||||
|
|
||||||
func restartExecutable(execPath string) {
|
func restartExecutable(execPath string) {
|
||||||
var err error
|
var err error
|
||||||
executor.Shutdown()
|
executor.Shutdown()
|
||||||
@@ -145,26 +128,108 @@ func removeFile(path string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getRawConfigWithPath(path *string) *config.RawConfig {
|
func getProfilePath(id string) string {
|
||||||
if path == nil {
|
return filepath.Join(constant.Path.HomeDir(), "profiles", id+".yaml")
|
||||||
|
}
|
||||||
|
|
||||||
|
func getProfileProvidersPath(id string) string {
|
||||||
|
return filepath.Join(constant.Path.HomeDir(), "providers", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
func getRawConfigWithId(id string) *config.RawConfig {
|
||||||
|
path := getProfilePath(id)
|
||||||
|
bytes, err := readFile(path)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorln("profile is not exist")
|
||||||
return config.DefaultRawConfig()
|
return config.DefaultRawConfig()
|
||||||
} else {
|
}
|
||||||
bytes, err := readFile(*path)
|
prof, err := config.UnmarshalRawConfig(bytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorln("getProfile readFile error %v", err)
|
log.Errorln("unmarshalRawConfig error %v", err)
|
||||||
return config.DefaultRawConfig()
|
return config.DefaultRawConfig()
|
||||||
|
}
|
||||||
|
for _, mapping := range prof.ProxyProvider {
|
||||||
|
value, exist := mapping["path"].(string)
|
||||||
|
if !exist {
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
prof, err := config.UnmarshalRawConfig(bytes)
|
mapping["path"] = filepath.Join(getProfileProvidersPath(id), value)
|
||||||
if err != nil {
|
}
|
||||||
log.Errorln("getProfile UnmarshalRawConfig error %v", err)
|
for _, mapping := range prof.RuleProvider {
|
||||||
return config.DefaultRawConfig()
|
value, exist := mapping["path"].(string)
|
||||||
|
if !exist {
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
return prof
|
mapping["path"] = filepath.Join(getProfileProvidersPath(id), value)
|
||||||
|
}
|
||||||
|
return prof
|
||||||
|
}
|
||||||
|
|
||||||
|
func getExternalProvidersRaw() map[string]cp.Provider {
|
||||||
|
eps := make(map[string]cp.Provider)
|
||||||
|
for n, p := range tunnel.Providers() {
|
||||||
|
if p.VehicleType() != cp.Compatible {
|
||||||
|
eps[n] = p
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for n, p := range tunnel.RuleProviders() {
|
||||||
|
if p.VehicleType() != cp.Compatible {
|
||||||
|
eps[n] = p
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return eps
|
||||||
|
}
|
||||||
|
|
||||||
|
func toExternalProvider(p cp.Provider) (*ExternalProvider, error) {
|
||||||
|
switch p.(type) {
|
||||||
|
case *provider.ProxySetProvider:
|
||||||
|
psp := p.(*provider.ProxySetProvider)
|
||||||
|
return &ExternalProvider{
|
||||||
|
Name: psp.Name(),
|
||||||
|
Type: psp.Type().String(),
|
||||||
|
VehicleType: psp.VehicleType().String(),
|
||||||
|
Count: psp.Count(),
|
||||||
|
Path: psp.Vehicle().Path(),
|
||||||
|
UpdateAt: psp.UpdatedAt,
|
||||||
|
}, nil
|
||||||
|
case *rp.RuleSetProvider:
|
||||||
|
rsp := p.(*rp.RuleSetProvider)
|
||||||
|
return &ExternalProvider{
|
||||||
|
Name: rsp.Name(),
|
||||||
|
Type: rsp.Type().String(),
|
||||||
|
VehicleType: rsp.VehicleType().String(),
|
||||||
|
Count: rsp.Count(),
|
||||||
|
Path: rsp.Vehicle().Path(),
|
||||||
|
UpdateAt: rsp.UpdatedAt,
|
||||||
|
}, nil
|
||||||
|
default:
|
||||||
|
return nil, errors.New("not external provider")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func decorationConfig(profilePath *string, cfg config.RawConfig) *config.RawConfig {
|
func sideUpdateExternalProvider(p cp.Provider, bytes []byte) error {
|
||||||
prof := getRawConfigWithPath(profilePath)
|
switch p.(type) {
|
||||||
|
case *provider.ProxySetProvider:
|
||||||
|
psp := p.(*provider.ProxySetProvider)
|
||||||
|
elm, same, err := psp.SideUpdate(bytes)
|
||||||
|
if err == nil && !same {
|
||||||
|
psp.OnUpdate(elm)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
case rp.RuleSetProvider:
|
||||||
|
rsp := p.(*rp.RuleSetProvider)
|
||||||
|
elm, same, err := rsp.SideUpdate(bytes)
|
||||||
|
if err == nil && !same {
|
||||||
|
rsp.OnUpdate(elm)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
default:
|
||||||
|
return errors.New("not external provider")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func decorationConfig(profileId string, cfg config.RawConfig) *config.RawConfig {
|
||||||
|
prof := getRawConfigWithId(profileId)
|
||||||
overwriteConfig(prof, cfg)
|
overwriteConfig(prof, cfg)
|
||||||
return prof
|
return prof
|
||||||
}
|
}
|
||||||
@@ -327,6 +392,7 @@ func overwriteConfig(targetConfig *config.RawConfig, patchConfig config.RawConfi
|
|||||||
targetConfig.LogLevel = patchConfig.LogLevel
|
targetConfig.LogLevel = patchConfig.LogLevel
|
||||||
targetConfig.Port = 0
|
targetConfig.Port = 0
|
||||||
targetConfig.SocksPort = 0
|
targetConfig.SocksPort = 0
|
||||||
|
targetConfig.KeepAliveInterval = patchConfig.KeepAliveInterval
|
||||||
targetConfig.MixedPort = patchConfig.MixedPort
|
targetConfig.MixedPort = patchConfig.MixedPort
|
||||||
targetConfig.FindProcessMode = patchConfig.FindProcessMode
|
targetConfig.FindProcessMode = patchConfig.FindProcessMode
|
||||||
targetConfig.AllowLan = patchConfig.AllowLan
|
targetConfig.AllowLan = patchConfig.AllowLan
|
||||||
@@ -357,30 +423,65 @@ func overwriteConfig(targetConfig *config.RawConfig, patchConfig config.RawConfi
|
|||||||
func patchConfig(general *config.General) {
|
func patchConfig(general *config.General) {
|
||||||
log.Infoln("[Apply] patch")
|
log.Infoln("[Apply] patch")
|
||||||
route.ReStartServer(general.ExternalController)
|
route.ReStartServer(general.ExternalController)
|
||||||
|
if sniffer.Dispatcher != nil {
|
||||||
|
tunnel.SetSniffing(general.Sniffing)
|
||||||
|
}
|
||||||
|
tunnel.SetFindProcessMode(general.FindProcessMode)
|
||||||
|
dialer.SetTcpConcurrent(general.TCPConcurrent)
|
||||||
|
dialer.DefaultInterface.Store(general.Interface)
|
||||||
|
adapter.UnifiedDelay.Store(general.UnifiedDelay)
|
||||||
|
tunnel.SetMode(general.Mode)
|
||||||
|
log.SetLevel(general.LogLevel)
|
||||||
|
resolver.DisableIPv6 = !general.IPv6
|
||||||
|
}
|
||||||
|
|
||||||
|
var isRunning = false
|
||||||
|
|
||||||
|
var runLock sync.Mutex
|
||||||
|
|
||||||
|
func updateListeners(general *config.General, listeners map[string]constant.InboundListener) {
|
||||||
|
listener.PatchInboundListeners(listeners, tunnel.Tunnel, true)
|
||||||
listener.SetAllowLan(general.AllowLan)
|
listener.SetAllowLan(general.AllowLan)
|
||||||
inbound.SetSkipAuthPrefixes(general.SkipAuthPrefixes)
|
inbound.SetSkipAuthPrefixes(general.SkipAuthPrefixes)
|
||||||
inbound.SetAllowedIPs(general.LanAllowedIPs)
|
inbound.SetAllowedIPs(general.LanAllowedIPs)
|
||||||
inbound.SetDisAllowedIPs(general.LanDisAllowedIPs)
|
inbound.SetDisAllowedIPs(general.LanDisAllowedIPs)
|
||||||
listener.SetBindAddress(general.BindAddress)
|
listener.SetBindAddress(general.BindAddress)
|
||||||
tunnel.SetSniffing(general.Sniffing)
|
|
||||||
tunnel.SetFindProcessMode(general.FindProcessMode)
|
|
||||||
dialer.SetTcpConcurrent(general.TCPConcurrent)
|
|
||||||
dialer.DefaultInterface.Store(general.Interface)
|
|
||||||
adapter.UnifiedDelay.Store(general.UnifiedDelay)
|
|
||||||
listener.ReCreateHTTP(general.Port, tunnel.Tunnel)
|
listener.ReCreateHTTP(general.Port, tunnel.Tunnel)
|
||||||
listener.ReCreateSocks(general.SocksPort, tunnel.Tunnel)
|
listener.ReCreateSocks(general.SocksPort, tunnel.Tunnel)
|
||||||
listener.ReCreateRedir(general.RedirPort, tunnel.Tunnel)
|
listener.ReCreateRedir(general.RedirPort, tunnel.Tunnel)
|
||||||
listener.ReCreateAutoRedir(general.EBpf.AutoRedir, tunnel.Tunnel)
|
listener.ReCreateAutoRedir(general.EBpf.AutoRedir, tunnel.Tunnel)
|
||||||
listener.ReCreateTProxy(general.TProxyPort, tunnel.Tunnel)
|
listener.ReCreateTProxy(general.TProxyPort, tunnel.Tunnel)
|
||||||
listener.ReCreateTun(general.Tun, tunnel.Tunnel)
|
|
||||||
listener.ReCreateMixed(general.MixedPort, tunnel.Tunnel)
|
listener.ReCreateMixed(general.MixedPort, tunnel.Tunnel)
|
||||||
listener.ReCreateShadowSocks(general.ShadowSocksConfig, tunnel.Tunnel)
|
listener.ReCreateShadowSocks(general.ShadowSocksConfig, tunnel.Tunnel)
|
||||||
listener.ReCreateVmess(general.VmessConfig, tunnel.Tunnel)
|
listener.ReCreateVmess(general.VmessConfig, tunnel.Tunnel)
|
||||||
listener.ReCreateTuic(general.TuicServer, tunnel.Tunnel)
|
listener.ReCreateTuic(general.TuicServer, tunnel.Tunnel)
|
||||||
tunnel.SetMode(general.Mode)
|
listener.ReCreateTun(general.Tun, tunnel.Tunnel)
|
||||||
log.SetLevel(general.LogLevel)
|
listener.ReCreateRedirToTun(general.EBpf.RedirectToTun)
|
||||||
|
}
|
||||||
|
|
||||||
|
func stopListeners() {
|
||||||
|
listener.StopListener()
|
||||||
|
}
|
||||||
|
|
||||||
|
func hcCompatibleProvider(proxyProviders map[string]cp.ProxyProvider) {
|
||||||
|
wg := sync.WaitGroup{}
|
||||||
|
ch := make(chan struct{}, math.MaxInt)
|
||||||
|
for _, proxyProvider := range proxyProviders {
|
||||||
|
proxyProvider := proxyProvider
|
||||||
|
if proxyProvider.VehicleType() == cp.Compatible {
|
||||||
|
log.Infoln("Start initial Compatible provider %s", proxyProvider.Name())
|
||||||
|
wg.Add(1)
|
||||||
|
ch <- struct{}{}
|
||||||
|
go func() {
|
||||||
|
defer func() { <-ch; wg.Done() }()
|
||||||
|
if err := proxyProvider.Initial(); err != nil {
|
||||||
|
log.Errorln("initial Compatible provider %s error: %v", proxyProvider.Name(), err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
resolver.DisableIPv6 = !general.IPv6
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func patchSelectGroup() {
|
func patchSelectGroup() {
|
||||||
@@ -408,12 +509,8 @@ func patchSelectGroup() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var applyLock sync.Mutex
|
|
||||||
|
|
||||||
func applyConfig() error {
|
func applyConfig() error {
|
||||||
applyLock.Lock()
|
cfg, err := config.ParseRawConfig(currentRawConfig)
|
||||||
defer applyLock.Unlock()
|
|
||||||
cfg, err := config.ParseRawConfig(currentConfig)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cfg, _ = config.ParseRawConfig(config.DefaultRawConfig())
|
cfg, _ = config.ParseRawConfig(config.DefaultRawConfig())
|
||||||
}
|
}
|
||||||
@@ -425,8 +522,13 @@ func applyConfig() error {
|
|||||||
} else {
|
} else {
|
||||||
closeConnections()
|
closeConnections()
|
||||||
runtime.GC()
|
runtime.GC()
|
||||||
hub.UltraApplyConfig(cfg, true)
|
hub.UltraApplyConfig(cfg)
|
||||||
patchSelectGroup()
|
patchSelectGroup()
|
||||||
}
|
}
|
||||||
|
if isRunning {
|
||||||
|
updateListeners(cfg.General, cfg.Listeners)
|
||||||
|
hcCompatibleProvider(cfg.Providers)
|
||||||
|
}
|
||||||
|
externalProviders = getExternalProvidersRaw()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
227
core/hub.go
227
core/hub.go
@@ -8,10 +8,16 @@ import (
|
|||||||
bridge "core/dart-bridge"
|
bridge "core/dart-bridge"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"runtime"
|
||||||
|
"sort"
|
||||||
|
"sync"
|
||||||
|
"time"
|
||||||
|
"unsafe"
|
||||||
|
|
||||||
"github.com/metacubex/mihomo/adapter"
|
"github.com/metacubex/mihomo/adapter"
|
||||||
"github.com/metacubex/mihomo/adapter/outboundgroup"
|
"github.com/metacubex/mihomo/adapter/outboundgroup"
|
||||||
"github.com/metacubex/mihomo/adapter/provider"
|
"github.com/metacubex/mihomo/adapter/provider"
|
||||||
"github.com/metacubex/mihomo/common/structure"
|
|
||||||
"github.com/metacubex/mihomo/common/utils"
|
"github.com/metacubex/mihomo/common/utils"
|
||||||
"github.com/metacubex/mihomo/component/updater"
|
"github.com/metacubex/mihomo/component/updater"
|
||||||
"github.com/metacubex/mihomo/config"
|
"github.com/metacubex/mihomo/config"
|
||||||
@@ -19,23 +25,33 @@ import (
|
|||||||
cp "github.com/metacubex/mihomo/constant/provider"
|
cp "github.com/metacubex/mihomo/constant/provider"
|
||||||
"github.com/metacubex/mihomo/hub/executor"
|
"github.com/metacubex/mihomo/hub/executor"
|
||||||
"github.com/metacubex/mihomo/log"
|
"github.com/metacubex/mihomo/log"
|
||||||
rp "github.com/metacubex/mihomo/rules/provider"
|
|
||||||
"github.com/metacubex/mihomo/tunnel"
|
"github.com/metacubex/mihomo/tunnel"
|
||||||
"github.com/metacubex/mihomo/tunnel/statistic"
|
"github.com/metacubex/mihomo/tunnel/statistic"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
"os"
|
|
||||||
"runtime"
|
|
||||||
"time"
|
|
||||||
"unsafe"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var currentConfig = config.DefaultRawConfig()
|
var currentRawConfig = config.DefaultRawConfig()
|
||||||
|
|
||||||
var configParams = ConfigExtendedParams{}
|
var configParams = ConfigExtendedParams{}
|
||||||
|
|
||||||
|
var externalProviders = map[string]cp.Provider{}
|
||||||
|
|
||||||
var isInit = false
|
var isInit = false
|
||||||
|
|
||||||
var currentProfileName = ""
|
//export start
|
||||||
|
func start() {
|
||||||
|
runLock.Lock()
|
||||||
|
defer runLock.Unlock()
|
||||||
|
isRunning = true
|
||||||
|
}
|
||||||
|
|
||||||
|
//export stop
|
||||||
|
func stop() {
|
||||||
|
runLock.Lock()
|
||||||
|
defer runLock.Unlock()
|
||||||
|
isRunning = false
|
||||||
|
stopListeners()
|
||||||
|
}
|
||||||
|
|
||||||
//export initClash
|
//export initClash
|
||||||
func initClash(homeDirStr *C.char) bool {
|
func initClash(homeDirStr *C.char) bool {
|
||||||
@@ -60,10 +76,10 @@ func restartClash() bool {
|
|||||||
|
|
||||||
//export shutdownClash
|
//export shutdownClash
|
||||||
func shutdownClash() bool {
|
func shutdownClash() bool {
|
||||||
|
stopListeners()
|
||||||
executor.Shutdown()
|
executor.Shutdown()
|
||||||
runtime.GC()
|
runtime.GC()
|
||||||
isInit = false
|
isInit = false
|
||||||
currentConfig = nil
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,16 +91,6 @@ func forceGc() {
|
|||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
//export setCurrentProfileName
|
|
||||||
func setCurrentProfileName(s *C.char) {
|
|
||||||
currentProfileName = C.GoString(s)
|
|
||||||
}
|
|
||||||
|
|
||||||
//export getCurrentProfileName
|
|
||||||
func getCurrentProfileName() *C.char {
|
|
||||||
return C.CString(currentProfileName)
|
|
||||||
}
|
|
||||||
|
|
||||||
//export validateConfig
|
//export validateConfig
|
||||||
func validateConfig(s *C.char, port C.longlong) {
|
func validateConfig(s *C.char, port C.longlong) {
|
||||||
i := int64(port)
|
i := int64(port)
|
||||||
@@ -99,11 +105,15 @@ func validateConfig(s *C.char, port C.longlong) {
|
|||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var updateLock sync.Mutex
|
||||||
|
|
||||||
//export updateConfig
|
//export updateConfig
|
||||||
func updateConfig(s *C.char, port C.longlong) {
|
func updateConfig(s *C.char, port C.longlong) {
|
||||||
i := int64(port)
|
i := int64(port)
|
||||||
paramsString := C.GoString(s)
|
paramsString := C.GoString(s)
|
||||||
go func() {
|
go func() {
|
||||||
|
updateLock.Lock()
|
||||||
|
defer updateLock.Unlock()
|
||||||
var params = &GenerateConfigParams{}
|
var params = &GenerateConfigParams{}
|
||||||
err := json.Unmarshal([]byte(paramsString), params)
|
err := json.Unmarshal([]byte(paramsString), params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -111,8 +121,8 @@ func updateConfig(s *C.char, port C.longlong) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
configParams = params.Params
|
configParams = params.Params
|
||||||
prof := decorationConfig(params.ProfilePath, params.Config)
|
prof := decorationConfig(params.ProfileId, params.Config)
|
||||||
currentConfig = prof
|
currentRawConfig = prof
|
||||||
err = applyConfig()
|
err = applyConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
bridge.SendToPort(i, err.Error())
|
bridge.SendToPort(i, err.Error())
|
||||||
@@ -124,34 +134,10 @@ func updateConfig(s *C.char, port C.longlong) {
|
|||||||
|
|
||||||
//export clearEffect
|
//export clearEffect
|
||||||
func clearEffect(s *C.char) {
|
func clearEffect(s *C.char) {
|
||||||
path := C.GoString(s)
|
id := C.GoString(s)
|
||||||
go func() {
|
go func() {
|
||||||
rawCfg := getRawConfigWithPath(&path)
|
_ = removeFile(getProfilePath(id))
|
||||||
for _, mapping := range rawCfg.RuleProvider {
|
_ = removeFile(getProfileProvidersPath(id))
|
||||||
schema := &ruleProviderSchema{}
|
|
||||||
decoder := structure.NewDecoder(structure.Option{TagName: "provider", WeaklyTypedInput: true})
|
|
||||||
if err := decoder.Decode(mapping, schema); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if schema.Type == "http" {
|
|
||||||
_ = removeFile(constant.Path.Resolve(schema.Path))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for _, mapping := range rawCfg.ProxyProvider {
|
|
||||||
schema := &proxyProviderSchema{
|
|
||||||
HealthCheck: healthCheckSchema{
|
|
||||||
Lazy: true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
decoder := structure.NewDecoder(structure.Option{TagName: "provider", WeaklyTypedInput: true})
|
|
||||||
if err := decoder.Decode(mapping, schema); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if schema.Type == "http" {
|
|
||||||
_ = removeFile(constant.Path.Resolve(schema.Path))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ = removeFile(path)
|
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,10 +170,13 @@ func changeProxy(s *C.char) {
|
|||||||
if !ok {
|
if !ok {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if proxyName == "" {
|
||||||
err = selector.Set(proxyName)
|
selector.ForceSet(proxyName)
|
||||||
|
} else {
|
||||||
|
err = selector.Set(proxyName)
|
||||||
|
}
|
||||||
if err == nil {
|
if err == nil {
|
||||||
log.Infoln("[Selector] %s selected %s", groupName, proxyName)
|
log.Infoln("[SelectAble] %s selected %s", groupName, proxyName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,16 +219,16 @@ func resetTraffic() {
|
|||||||
func asyncTestDelay(s *C.char, port C.longlong) {
|
func asyncTestDelay(s *C.char, port C.longlong) {
|
||||||
i := int64(port)
|
i := int64(port)
|
||||||
paramsString := C.GoString(s)
|
paramsString := C.GoString(s)
|
||||||
go func() {
|
b.Go(paramsString, func() (bool, error) {
|
||||||
var params = &TestDelayParams{}
|
var params = &TestDelayParams{}
|
||||||
err := json.Unmarshal([]byte(paramsString), params)
|
err := json.Unmarshal([]byte(paramsString), params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
expectedStatus, err := utils.NewUnsignedRanges[uint16]("")
|
expectedStatus, err := utils.NewUnsignedRanges[uint16]("")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond*time.Duration(params.Timeout))
|
ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond*time.Duration(params.Timeout))
|
||||||
@@ -256,7 +245,7 @@ func asyncTestDelay(s *C.char, port C.longlong) {
|
|||||||
delayData.Value = -1
|
delayData.Value = -1
|
||||||
data, _ := json.Marshal(delayData)
|
data, _ := json.Marshal(delayData)
|
||||||
bridge.SendToPort(i, string(data))
|
bridge.SendToPort(i, string(data))
|
||||||
return
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
delay, err := proxy.URLTest(ctx, constant.DefaultTestURL, expectedStatus)
|
delay, err := proxy.URLTest(ctx, constant.DefaultTestURL, expectedStatus)
|
||||||
@@ -264,14 +253,14 @@ func asyncTestDelay(s *C.char, port C.longlong) {
|
|||||||
delayData.Value = -1
|
delayData.Value = -1
|
||||||
data, _ := json.Marshal(delayData)
|
data, _ := json.Marshal(delayData)
|
||||||
bridge.SendToPort(i, string(data))
|
bridge.SendToPort(i, string(data))
|
||||||
return
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
delayData.Value = int32(delay)
|
delayData.Value = int32(delay)
|
||||||
data, _ := json.Marshal(delayData)
|
data, _ := json.Marshal(delayData)
|
||||||
bridge.SendToPort(i, string(data))
|
bridge.SendToPort(i, string(data))
|
||||||
return
|
return false, nil
|
||||||
}()
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
//export getVersionInfo
|
//export getVersionInfo
|
||||||
@@ -345,78 +334,67 @@ func getProvider(name *C.char) *C.char {
|
|||||||
|
|
||||||
//export getExternalProviders
|
//export getExternalProviders
|
||||||
func getExternalProviders() *C.char {
|
func getExternalProviders() *C.char {
|
||||||
externalProviders := make([]ExternalProvider, 0)
|
eps := make([]ExternalProvider, 0)
|
||||||
providers := tunnel.Providers()
|
for _, p := range externalProviders {
|
||||||
for n, p := range providers {
|
externalProvider, err := toExternalProvider(p)
|
||||||
if p.VehicleType() != cp.Compatible {
|
if err != nil {
|
||||||
p := p.(*provider.ProxySetProvider)
|
continue
|
||||||
externalProviders = append(externalProviders, ExternalProvider{
|
|
||||||
Name: n,
|
|
||||||
Type: p.Type().String(),
|
|
||||||
VehicleType: p.VehicleType().String(),
|
|
||||||
UpdateAt: p.UpdatedAt,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
eps = append(eps, *externalProvider)
|
||||||
}
|
}
|
||||||
for n, p := range tunnel.RuleProviders() {
|
sort.Sort(ExternalProviders(eps))
|
||||||
if p.VehicleType() != cp.Compatible {
|
data, err := json.Marshal(eps)
|
||||||
p := p.(*rp.RuleSetProvider)
|
|
||||||
externalProviders = append(externalProviders, ExternalProvider{
|
|
||||||
Name: n,
|
|
||||||
Type: p.Type().String(),
|
|
||||||
VehicleType: p.VehicleType().String(),
|
|
||||||
UpdateAt: p.UpdatedAt,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
data, err := json.Marshal(externalProviders)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return C.CString("")
|
return C.CString("")
|
||||||
}
|
}
|
||||||
return C.CString(string(data))
|
return C.CString(string(data))
|
||||||
}
|
}
|
||||||
|
|
||||||
//export updateExternalProvider
|
//export getExternalProvider
|
||||||
func updateExternalProvider(providerName *C.char, providerType *C.char, port C.longlong) {
|
func getExternalProvider(name *C.char) *C.char {
|
||||||
|
externalProviderName := C.GoString(name)
|
||||||
|
externalProvider, exist := externalProviders[externalProviderName]
|
||||||
|
if !exist {
|
||||||
|
return C.CString("")
|
||||||
|
}
|
||||||
|
e, err := toExternalProvider(externalProvider)
|
||||||
|
if err != nil {
|
||||||
|
return C.CString("")
|
||||||
|
}
|
||||||
|
data, err := json.Marshal(e)
|
||||||
|
if err != nil {
|
||||||
|
return C.CString("")
|
||||||
|
}
|
||||||
|
return C.CString(string(data))
|
||||||
|
}
|
||||||
|
|
||||||
|
//export updateGeoData
|
||||||
|
func updateGeoData(geoType *C.char, geoName *C.char, port C.longlong) {
|
||||||
i := int64(port)
|
i := int64(port)
|
||||||
providerNameString := C.GoString(providerName)
|
geoTypeString := C.GoString(geoType)
|
||||||
providerTypeString := C.GoString(providerType)
|
geoNameString := C.GoString(geoName)
|
||||||
go func() {
|
go func() {
|
||||||
switch providerTypeString {
|
switch geoTypeString {
|
||||||
case "Proxy":
|
|
||||||
providers := tunnel.Providers()
|
|
||||||
err := providers[providerNameString].Update()
|
|
||||||
if err != nil {
|
|
||||||
bridge.SendToPort(i, err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
case "Rule":
|
|
||||||
providers := tunnel.RuleProviders()
|
|
||||||
err := providers[providerNameString].Update()
|
|
||||||
if err != nil {
|
|
||||||
bridge.SendToPort(i, err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
case "MMDB":
|
case "MMDB":
|
||||||
err := updater.UpdateMMDB(constant.Path.Resolve(providerNameString))
|
err := updater.UpdateMMDB(constant.Path.Resolve(geoNameString))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
bridge.SendToPort(i, err.Error())
|
bridge.SendToPort(i, err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case "ASN":
|
case "ASN":
|
||||||
err := updater.UpdateASN(constant.Path.Resolve(providerNameString))
|
err := updater.UpdateASN(constant.Path.Resolve(geoNameString))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
bridge.SendToPort(i, err.Error())
|
bridge.SendToPort(i, err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case "GeoIp":
|
case "GeoIp":
|
||||||
err := updater.UpdateGeoIp(constant.Path.Resolve(providerNameString))
|
err := updater.UpdateGeoIp(constant.Path.Resolve(geoNameString))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
bridge.SendToPort(i, err.Error())
|
bridge.SendToPort(i, err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case "GeoSite":
|
case "GeoSite":
|
||||||
err := updater.UpdateGeoSite(constant.Path.Resolve(providerNameString))
|
err := updater.UpdateGeoSite(constant.Path.Resolve(geoNameString))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
bridge.SendToPort(i, err.Error())
|
bridge.SendToPort(i, err.Error())
|
||||||
return
|
return
|
||||||
@@ -426,6 +404,45 @@ func updateExternalProvider(providerName *C.char, providerType *C.char, port C.l
|
|||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//export updateExternalProvider
|
||||||
|
func updateExternalProvider(providerName *C.char, port C.longlong) {
|
||||||
|
i := int64(port)
|
||||||
|
providerNameString := C.GoString(providerName)
|
||||||
|
go func() {
|
||||||
|
externalProvider, exist := externalProviders[providerNameString]
|
||||||
|
if !exist {
|
||||||
|
bridge.SendToPort(i, "external provider is not exist")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err := externalProvider.Update()
|
||||||
|
if err != nil {
|
||||||
|
bridge.SendToPort(i, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
bridge.SendToPort(i, "")
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
|
//export sideLoadExternalProvider
|
||||||
|
func sideLoadExternalProvider(providerName *C.char, data *C.char, port C.longlong) {
|
||||||
|
i := int64(port)
|
||||||
|
bytes := []byte(C.GoString(data))
|
||||||
|
providerNameString := C.GoString(providerName)
|
||||||
|
go func() {
|
||||||
|
externalProvider, exist := externalProviders[providerNameString]
|
||||||
|
if !exist {
|
||||||
|
bridge.SendToPort(i, "external provider is not exist")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err := sideUpdateExternalProvider(externalProvider, bytes)
|
||||||
|
if err != nil {
|
||||||
|
bridge.SendToPort(i, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
bridge.SendToPort(i, "")
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
//export initNativeApiBridge
|
//export initNativeApiBridge
|
||||||
func initNativeApiBridge(api unsafe.Pointer) {
|
func initNativeApiBridge(api unsafe.Pointer) {
|
||||||
bridge.InitDartApi(api)
|
bridge.InitDartApi(api)
|
||||||
@@ -463,7 +480,7 @@ func init() {
|
|||||||
Data: c,
|
Data: c,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
executor.DefaultProxyProviderLoadedHook = func(providerName string) {
|
executor.DefaultProviderLoadedHook = func(providerName string) {
|
||||||
SendMessage(Message{
|
SendMessage(Message{
|
||||||
Type: LoadedMessage,
|
Type: LoadedMessage,
|
||||||
Data: providerName,
|
Data: providerName,
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ type AccessControl struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type AndroidProps struct {
|
type AndroidProps struct {
|
||||||
|
Enable bool `json:"enable"`
|
||||||
AccessControl *AccessControl `json:"accessControl"`
|
AccessControl *AccessControl `json:"accessControl"`
|
||||||
AllowBypass bool `json:"allowBypass"`
|
AllowBypass bool `json:"allowBypass"`
|
||||||
SystemProxy bool `json:"systemProxy"`
|
SystemProxy bool `json:"systemProxy"`
|
||||||
@@ -21,8 +22,9 @@ type AndroidProps struct {
|
|||||||
|
|
||||||
type State struct {
|
type State struct {
|
||||||
AndroidProps
|
AndroidProps
|
||||||
MixedPort int `json:"mixedPort"`
|
CurrentProfileName string `json:"currentProfileName"`
|
||||||
OnlyProxy bool `json:"onlyProxy"`
|
MixedPort int `json:"mixedPort"`
|
||||||
|
OnlyProxy bool `json:"onlyProxy"`
|
||||||
}
|
}
|
||||||
|
|
||||||
var state State
|
var state State
|
||||||
|
|||||||
27
core/tun.go
27
core/tun.go
@@ -7,14 +7,15 @@ import (
|
|||||||
"core/platform"
|
"core/platform"
|
||||||
t "core/tun"
|
t "core/tun"
|
||||||
"errors"
|
"errors"
|
||||||
"github.com/metacubex/mihomo/component/dialer"
|
|
||||||
"github.com/metacubex/mihomo/log"
|
|
||||||
"golang.org/x/sync/semaphore"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/metacubex/mihomo/component/dialer"
|
||||||
|
"github.com/metacubex/mihomo/log"
|
||||||
|
"golang.org/x/sync/semaphore"
|
||||||
)
|
)
|
||||||
|
|
||||||
var tunLock sync.Mutex
|
var tunLock sync.Mutex
|
||||||
@@ -40,6 +41,18 @@ var fdMap FdMap
|
|||||||
func startTUN(fd C.int, port C.longlong) {
|
func startTUN(fd C.int, port C.longlong) {
|
||||||
i := int64(port)
|
i := int64(port)
|
||||||
ServicePort = i
|
ServicePort = i
|
||||||
|
if fd == 0 {
|
||||||
|
tunLock.Lock()
|
||||||
|
defer tunLock.Unlock()
|
||||||
|
now := time.Now()
|
||||||
|
runTime = &now
|
||||||
|
SendMessage(Message{
|
||||||
|
Type: StartedMessage,
|
||||||
|
Data: strconv.FormatInt(runTime.UnixMilli(), 10),
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
initSocketHook()
|
||||||
go func() {
|
go func() {
|
||||||
tunLock.Lock()
|
tunLock.Lock()
|
||||||
defer tunLock.Unlock()
|
defer tunLock.Unlock()
|
||||||
@@ -88,6 +101,7 @@ func getRunTime() *C.char {
|
|||||||
|
|
||||||
//export stopTun
|
//export stopTun
|
||||||
func stopTun() {
|
func stopTun() {
|
||||||
|
removeSocketHook()
|
||||||
go func() {
|
go func() {
|
||||||
tunLock.Lock()
|
tunLock.Lock()
|
||||||
defer tunLock.Unlock()
|
defer tunLock.Unlock()
|
||||||
@@ -95,6 +109,7 @@ func stopTun() {
|
|||||||
runTime = nil
|
runTime = nil
|
||||||
|
|
||||||
if tun != nil {
|
if tun != nil {
|
||||||
|
log.Errorln("[Tun] stopTun")
|
||||||
tun.Close()
|
tun.Close()
|
||||||
tun = nil
|
tun = nil
|
||||||
}
|
}
|
||||||
@@ -125,7 +140,7 @@ func markSocket(fd Fd) {
|
|||||||
|
|
||||||
var fdCounter int64 = 0
|
var fdCounter int64 = 0
|
||||||
|
|
||||||
func init() {
|
func initSocketHook() {
|
||||||
dialer.DefaultSocketHook = func(network, address string, conn syscall.RawConn) error {
|
dialer.DefaultSocketHook = func(network, address string, conn syscall.RawConn) error {
|
||||||
if platform.ShouldBlockConnection() {
|
if platform.ShouldBlockConnection() {
|
||||||
return errBlocked
|
return errBlocked
|
||||||
@@ -159,3 +174,7 @@ func init() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func removeSocketHook() {
|
||||||
|
dialer.DefaultSocketHook = nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import 'package:dynamic_color/dynamic_color.dart';
|
|||||||
import 'package:fl_clash/l10n/l10n.dart';
|
import 'package:fl_clash/l10n/l10n.dart';
|
||||||
import 'package:fl_clash/common/common.dart';
|
import 'package:fl_clash/common/common.dart';
|
||||||
import 'package:fl_clash/state.dart';
|
import 'package:fl_clash/state.dart';
|
||||||
|
import 'package:fl_clash/widgets/proxy_container.dart';
|
||||||
import 'package:fl_clash/widgets/widgets.dart';
|
import 'package:fl_clash/widgets/widgets.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||||
@@ -88,7 +89,6 @@ class ApplicationState extends State<Application> {
|
|||||||
}
|
}
|
||||||
await globalState.appController.init();
|
await globalState.appController.init();
|
||||||
globalState.appController.initLink();
|
globalState.appController.initLink();
|
||||||
_updateGroups();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,7 +96,9 @@ class ApplicationState extends State<Application> {
|
|||||||
if (system.isDesktop) {
|
if (system.isDesktop) {
|
||||||
return WindowContainer(
|
return WindowContainer(
|
||||||
child: TrayContainer(
|
child: TrayContainer(
|
||||||
child: app,
|
child: ProxyContainer(
|
||||||
|
child: app,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -120,74 +122,67 @@ class ApplicationState extends State<Application> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_updateGroups() {
|
|
||||||
if (globalState.groupsUpdateTimer != null) {
|
|
||||||
globalState.groupsUpdateTimer?.cancel();
|
|
||||||
globalState.groupsUpdateTimer = null;
|
|
||||||
}
|
|
||||||
globalState.groupsUpdateTimer ??= Timer.periodic(
|
|
||||||
httpTimeoutDuration,
|
|
||||||
(timer) async {
|
|
||||||
await globalState.appController.updateGroupDebounce();
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(context) {
|
Widget build(context) {
|
||||||
return AppStateContainer(
|
return _buildApp(
|
||||||
child: ClashContainer(
|
AppStateContainer(
|
||||||
child: Selector2<AppState, Config, ApplicationSelectorState>(
|
child: ClashContainer(
|
||||||
selector: (_, appState, config) => ApplicationSelectorState(
|
child: Selector2<AppState, Config, ApplicationSelectorState>(
|
||||||
locale: config.locale,
|
selector: (_, appState, config) => ApplicationSelectorState(
|
||||||
themeMode: config.themeMode,
|
locale: config.locale,
|
||||||
primaryColor: config.primaryColor,
|
themeMode: config.themeMode,
|
||||||
|
primaryColor: config.primaryColor,
|
||||||
|
prueBlack: config.prueBlack,
|
||||||
|
),
|
||||||
|
builder: (_, state, child) {
|
||||||
|
return DynamicColorBuilder(
|
||||||
|
builder: (lightDynamic, darkDynamic) {
|
||||||
|
_updateSystemColorSchemes(lightDynamic, darkDynamic);
|
||||||
|
return MaterialApp(
|
||||||
|
navigatorKey: globalState.navigatorKey,
|
||||||
|
localizationsDelegates: const [
|
||||||
|
AppLocalizations.delegate,
|
||||||
|
GlobalMaterialLocalizations.delegate,
|
||||||
|
GlobalCupertinoLocalizations.delegate,
|
||||||
|
GlobalWidgetsLocalizations.delegate
|
||||||
|
],
|
||||||
|
builder: (_, child) {
|
||||||
|
if (system.isDesktop) {
|
||||||
|
return WindowHeaderContainer(child: child!);
|
||||||
|
}
|
||||||
|
return child!;
|
||||||
|
},
|
||||||
|
scrollBehavior: BaseScrollBehavior(),
|
||||||
|
title: appName,
|
||||||
|
locale: other.getLocaleForString(state.locale),
|
||||||
|
supportedLocales:
|
||||||
|
AppLocalizations.delegate.supportedLocales,
|
||||||
|
themeMode: state.themeMode,
|
||||||
|
theme: ThemeData(
|
||||||
|
useMaterial3: true,
|
||||||
|
pageTransitionsTheme: _pageTransitionsTheme,
|
||||||
|
colorScheme: _getAppColorScheme(
|
||||||
|
brightness: Brightness.light,
|
||||||
|
systemColorSchemes: systemColorSchemes,
|
||||||
|
primaryColor: state.primaryColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
darkTheme: ThemeData(
|
||||||
|
useMaterial3: true,
|
||||||
|
pageTransitionsTheme: _pageTransitionsTheme,
|
||||||
|
colorScheme: _getAppColorScheme(
|
||||||
|
brightness: Brightness.dark,
|
||||||
|
systemColorSchemes: systemColorSchemes,
|
||||||
|
primaryColor: state.primaryColor,
|
||||||
|
).toPrueBlack(state.prueBlack),
|
||||||
|
),
|
||||||
|
home: child,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: const HomePage(),
|
||||||
),
|
),
|
||||||
builder: (_, state, child) {
|
|
||||||
return DynamicColorBuilder(
|
|
||||||
builder: (lightDynamic, darkDynamic) {
|
|
||||||
_updateSystemColorSchemes(lightDynamic, darkDynamic);
|
|
||||||
return MaterialApp(
|
|
||||||
debugShowCheckedModeBanner: false,
|
|
||||||
navigatorKey: globalState.navigatorKey,
|
|
||||||
localizationsDelegates: const [
|
|
||||||
AppLocalizations.delegate,
|
|
||||||
GlobalMaterialLocalizations.delegate,
|
|
||||||
GlobalCupertinoLocalizations.delegate,
|
|
||||||
GlobalWidgetsLocalizations.delegate
|
|
||||||
],
|
|
||||||
builder: (_, child) {
|
|
||||||
return _buildApp(child!);
|
|
||||||
},
|
|
||||||
scrollBehavior: BaseScrollBehavior(),
|
|
||||||
title: appName,
|
|
||||||
locale: other.getLocaleForString(state.locale),
|
|
||||||
supportedLocales: AppLocalizations.delegate.supportedLocales,
|
|
||||||
themeMode: state.themeMode,
|
|
||||||
theme: ThemeData(
|
|
||||||
useMaterial3: true,
|
|
||||||
pageTransitionsTheme: _pageTransitionsTheme,
|
|
||||||
colorScheme: _getAppColorScheme(
|
|
||||||
brightness: Brightness.light,
|
|
||||||
systemColorSchemes: systemColorSchemes,
|
|
||||||
primaryColor: state.primaryColor,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
darkTheme: ThemeData(
|
|
||||||
useMaterial3: true,
|
|
||||||
pageTransitionsTheme: _pageTransitionsTheme,
|
|
||||||
colorScheme: _getAppColorScheme(
|
|
||||||
brightness: Brightness.dark,
|
|
||||||
systemColorSchemes: systemColorSchemes,
|
|
||||||
primaryColor: state.primaryColor,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
home: child,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
child: const HomePage(),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -100,22 +100,6 @@ class ClashCore {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
setProfileName(String profileName) {
|
|
||||||
final profileNameChar = profileName.toNativeUtf8().cast<Char>();
|
|
||||||
clashFFI.setCurrentProfileName(
|
|
||||||
profileNameChar,
|
|
||||||
);
|
|
||||||
malloc.free(profileNameChar);
|
|
||||||
}
|
|
||||||
|
|
||||||
getProfileName() {
|
|
||||||
final currentProfileNameRaw = clashFFI.getCurrentProfileName();
|
|
||||||
final currentProfileName =
|
|
||||||
currentProfileNameRaw.cast<Utf8>().toDartString();
|
|
||||||
clashFFI.freeCString(currentProfileNameRaw);
|
|
||||||
return currentProfileName;
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<List<Group>> getProxiesGroups() {
|
Future<List<Group>> getProxiesGroups() {
|
||||||
final proxiesRaw = clashFFI.getProxies();
|
final proxiesRaw = clashFFI.getProxies();
|
||||||
final proxiesRawString = proxiesRaw.cast<Utf8>().toDartString();
|
final proxiesRawString = proxiesRaw.cast<Utf8>().toDartString();
|
||||||
@@ -165,9 +149,46 @@ class ClashCore {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String> updateExternalProvider({
|
ExternalProvider? getExternalProvider(String externalProviderName) {
|
||||||
|
final externalProviderNameChar =
|
||||||
|
externalProviderName.toNativeUtf8().cast<Char>();
|
||||||
|
final externalProviderRaw =
|
||||||
|
clashFFI.getExternalProvider(externalProviderNameChar);
|
||||||
|
malloc.free(externalProviderNameChar);
|
||||||
|
final externalProviderRawString =
|
||||||
|
externalProviderRaw.cast<Utf8>().toDartString();
|
||||||
|
clashFFI.freeCString(externalProviderRaw);
|
||||||
|
if(externalProviderRawString.isEmpty) return null;
|
||||||
|
return ExternalProvider.fromJson(json.decode(externalProviderRawString));
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<String> updateGeoData({
|
||||||
|
required String geoType,
|
||||||
|
required String geoName,
|
||||||
|
}) {
|
||||||
|
final completer = Completer<String>();
|
||||||
|
final receiver = ReceivePort();
|
||||||
|
receiver.listen((message) {
|
||||||
|
if (!completer.isCompleted) {
|
||||||
|
completer.complete(message);
|
||||||
|
receiver.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
final geoTypeChar = geoType.toNativeUtf8().cast<Char>();
|
||||||
|
final geoNameChar = geoName.toNativeUtf8().cast<Char>();
|
||||||
|
clashFFI.updateGeoData(
|
||||||
|
geoTypeChar,
|
||||||
|
geoNameChar,
|
||||||
|
receiver.sendPort.nativePort,
|
||||||
|
);
|
||||||
|
malloc.free(geoTypeChar);
|
||||||
|
malloc.free(geoNameChar);
|
||||||
|
return completer.future;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<String> sideLoadExternalProvider({
|
||||||
required String providerName,
|
required String providerName,
|
||||||
required String providerType,
|
required String data,
|
||||||
}) {
|
}) {
|
||||||
final completer = Completer<String>();
|
final completer = Completer<String>();
|
||||||
final receiver = ReceivePort();
|
final receiver = ReceivePort();
|
||||||
@@ -178,14 +199,34 @@ class ClashCore {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
final providerNameChar = providerName.toNativeUtf8().cast<Char>();
|
final providerNameChar = providerName.toNativeUtf8().cast<Char>();
|
||||||
final providerTypeChar = providerType.toNativeUtf8().cast<Char>();
|
final dataChar = data.toNativeUtf8().cast<Char>();
|
||||||
clashFFI.updateExternalProvider(
|
clashFFI.sideLoadExternalProvider(
|
||||||
|
providerNameChar,
|
||||||
|
dataChar,
|
||||||
|
receiver.sendPort.nativePort,
|
||||||
|
);
|
||||||
|
malloc.free(providerNameChar);
|
||||||
|
malloc.free(dataChar);
|
||||||
|
return completer.future;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<String> updateExternalProvider({
|
||||||
|
required String providerName,
|
||||||
|
}) {
|
||||||
|
final completer = Completer<String>();
|
||||||
|
final receiver = ReceivePort();
|
||||||
|
receiver.listen((message) {
|
||||||
|
if (!completer.isCompleted) {
|
||||||
|
completer.complete(message);
|
||||||
|
receiver.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
final providerNameChar = providerName.toNativeUtf8().cast<Char>();
|
||||||
|
clashFFI.updateExternalProvider(
|
||||||
providerNameChar,
|
providerNameChar,
|
||||||
providerTypeChar,
|
|
||||||
receiver.sendPort.nativePort,
|
receiver.sendPort.nativePort,
|
||||||
);
|
);
|
||||||
malloc.free(providerNameChar);
|
malloc.free(providerNameChar);
|
||||||
malloc.free(providerTypeChar);
|
|
||||||
return completer.future;
|
return completer.future;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,6 +237,14 @@ class ClashCore {
|
|||||||
malloc.free(paramsChar);
|
malloc.free(paramsChar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
start() {
|
||||||
|
clashFFI.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
stop() {
|
||||||
|
clashFFI.stop();
|
||||||
|
}
|
||||||
|
|
||||||
Future<Delay> getDelay(String proxyName) {
|
Future<Delay> getDelay(String proxyName) {
|
||||||
final delayParams = {
|
final delayParams = {
|
||||||
"proxy-name": proxyName,
|
"proxy-name": proxyName,
|
||||||
@@ -216,21 +265,13 @@ class ClashCore {
|
|||||||
receiver.sendPort.nativePort,
|
receiver.sendPort.nativePort,
|
||||||
);
|
);
|
||||||
malloc.free(delayParamsChar);
|
malloc.free(delayParamsChar);
|
||||||
Future.delayed(httpTimeoutDuration + moreDuration, () {
|
|
||||||
receiver.close();
|
|
||||||
if (!completer.isCompleted) {
|
|
||||||
completer.complete(
|
|
||||||
Delay(name: proxyName, value: -1),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return completer.future;
|
return completer.future;
|
||||||
}
|
}
|
||||||
|
|
||||||
clearEffect(String path) {
|
clearEffect(String profileId) {
|
||||||
final pathChar = path.toNativeUtf8().cast<Char>();
|
final profileIdChar = profileId.toNativeUtf8().cast<Char>();
|
||||||
clashFFI.clearEffect(pathChar);
|
clashFFI.clearEffect(profileIdChar);
|
||||||
malloc.free(pathChar);
|
malloc.free(profileIdChar);
|
||||||
}
|
}
|
||||||
|
|
||||||
VersionInfo getVersionInfo() {
|
VersionInfo getVersionInfo() {
|
||||||
|
|||||||
@@ -5144,6 +5144,22 @@ class ClashFFI {
|
|||||||
late final __FCmulcr =
|
late final __FCmulcr =
|
||||||
__FCmulcrPtr.asFunction<_Fcomplex Function(_Fcomplex, double)>();
|
__FCmulcrPtr.asFunction<_Fcomplex Function(_Fcomplex, double)>();
|
||||||
|
|
||||||
|
void start() {
|
||||||
|
return _start();
|
||||||
|
}
|
||||||
|
|
||||||
|
late final _startPtr =
|
||||||
|
_lookup<ffi.NativeFunction<ffi.Void Function()>>('start');
|
||||||
|
late final _start = _startPtr.asFunction<void Function()>();
|
||||||
|
|
||||||
|
void stop() {
|
||||||
|
return _stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
late final _stopPtr =
|
||||||
|
_lookup<ffi.NativeFunction<ffi.Void Function()>>('stop');
|
||||||
|
late final _stop = _stopPtr.asFunction<void Function()>();
|
||||||
|
|
||||||
int initClash(
|
int initClash(
|
||||||
ffi.Pointer<ffi.Char> homeDirStr,
|
ffi.Pointer<ffi.Char> homeDirStr,
|
||||||
) {
|
) {
|
||||||
@@ -5190,30 +5206,6 @@ class ClashFFI {
|
|||||||
_lookup<ffi.NativeFunction<ffi.Void Function()>>('forceGc');
|
_lookup<ffi.NativeFunction<ffi.Void Function()>>('forceGc');
|
||||||
late final _forceGc = _forceGcPtr.asFunction<void Function()>();
|
late final _forceGc = _forceGcPtr.asFunction<void Function()>();
|
||||||
|
|
||||||
void setCurrentProfileName(
|
|
||||||
ffi.Pointer<ffi.Char> s,
|
|
||||||
) {
|
|
||||||
return _setCurrentProfileName(
|
|
||||||
s,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
late final _setCurrentProfileNamePtr =
|
|
||||||
_lookup<ffi.NativeFunction<ffi.Void Function(ffi.Pointer<ffi.Char>)>>(
|
|
||||||
'setCurrentProfileName');
|
|
||||||
late final _setCurrentProfileName = _setCurrentProfileNamePtr
|
|
||||||
.asFunction<void Function(ffi.Pointer<ffi.Char>)>();
|
|
||||||
|
|
||||||
ffi.Pointer<ffi.Char> getCurrentProfileName() {
|
|
||||||
return _getCurrentProfileName();
|
|
||||||
}
|
|
||||||
|
|
||||||
late final _getCurrentProfileNamePtr =
|
|
||||||
_lookup<ffi.NativeFunction<ffi.Pointer<ffi.Char> Function()>>(
|
|
||||||
'getCurrentProfileName');
|
|
||||||
late final _getCurrentProfileName =
|
|
||||||
_getCurrentProfileNamePtr.asFunction<ffi.Pointer<ffi.Char> Function()>();
|
|
||||||
|
|
||||||
void validateConfig(
|
void validateConfig(
|
||||||
ffi.Pointer<ffi.Char> s,
|
ffi.Pointer<ffi.Char> s,
|
||||||
int port,
|
int port,
|
||||||
@@ -5409,24 +5401,76 @@ class ClashFFI {
|
|||||||
late final _getExternalProviders =
|
late final _getExternalProviders =
|
||||||
_getExternalProvidersPtr.asFunction<ffi.Pointer<ffi.Char> Function()>();
|
_getExternalProvidersPtr.asFunction<ffi.Pointer<ffi.Char> Function()>();
|
||||||
|
|
||||||
|
ffi.Pointer<ffi.Char> getExternalProvider(
|
||||||
|
ffi.Pointer<ffi.Char> name,
|
||||||
|
) {
|
||||||
|
return _getExternalProvider(
|
||||||
|
name,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
late final _getExternalProviderPtr = _lookup<
|
||||||
|
ffi.NativeFunction<
|
||||||
|
ffi.Pointer<ffi.Char> Function(
|
||||||
|
ffi.Pointer<ffi.Char>)>>('getExternalProvider');
|
||||||
|
late final _getExternalProvider = _getExternalProviderPtr
|
||||||
|
.asFunction<ffi.Pointer<ffi.Char> Function(ffi.Pointer<ffi.Char>)>();
|
||||||
|
|
||||||
|
void updateGeoData(
|
||||||
|
ffi.Pointer<ffi.Char> geoType,
|
||||||
|
ffi.Pointer<ffi.Char> geoName,
|
||||||
|
int port,
|
||||||
|
) {
|
||||||
|
return _updateGeoData(
|
||||||
|
geoType,
|
||||||
|
geoName,
|
||||||
|
port,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
late final _updateGeoDataPtr = _lookup<
|
||||||
|
ffi.NativeFunction<
|
||||||
|
ffi.Void Function(ffi.Pointer<ffi.Char>, ffi.Pointer<ffi.Char>,
|
||||||
|
ffi.LongLong)>>('updateGeoData');
|
||||||
|
late final _updateGeoData = _updateGeoDataPtr.asFunction<
|
||||||
|
void Function(ffi.Pointer<ffi.Char>, ffi.Pointer<ffi.Char>, int)>();
|
||||||
|
|
||||||
void updateExternalProvider(
|
void updateExternalProvider(
|
||||||
ffi.Pointer<ffi.Char> providerName,
|
ffi.Pointer<ffi.Char> providerName,
|
||||||
ffi.Pointer<ffi.Char> providerType,
|
|
||||||
int port,
|
int port,
|
||||||
) {
|
) {
|
||||||
return _updateExternalProvider(
|
return _updateExternalProvider(
|
||||||
providerName,
|
providerName,
|
||||||
providerType,
|
|
||||||
port,
|
port,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
late final _updateExternalProviderPtr = _lookup<
|
late final _updateExternalProviderPtr = _lookup<
|
||||||
|
ffi.NativeFunction<
|
||||||
|
ffi.Void Function(
|
||||||
|
ffi.Pointer<ffi.Char>, ffi.LongLong)>>('updateExternalProvider');
|
||||||
|
late final _updateExternalProvider = _updateExternalProviderPtr
|
||||||
|
.asFunction<void Function(ffi.Pointer<ffi.Char>, int)>();
|
||||||
|
|
||||||
|
void sideLoadExternalProvider(
|
||||||
|
ffi.Pointer<ffi.Char> providerName,
|
||||||
|
ffi.Pointer<ffi.Char> data,
|
||||||
|
int port,
|
||||||
|
) {
|
||||||
|
return _sideLoadExternalProvider(
|
||||||
|
providerName,
|
||||||
|
data,
|
||||||
|
port,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
late final _sideLoadExternalProviderPtr = _lookup<
|
||||||
ffi.NativeFunction<
|
ffi.NativeFunction<
|
||||||
ffi.Void Function(ffi.Pointer<ffi.Char>, ffi.Pointer<ffi.Char>,
|
ffi.Void Function(ffi.Pointer<ffi.Char>, ffi.Pointer<ffi.Char>,
|
||||||
ffi.LongLong)>>('updateExternalProvider');
|
ffi.LongLong)>>('sideLoadExternalProvider');
|
||||||
late final _updateExternalProvider = _updateExternalProviderPtr.asFunction<
|
late final _sideLoadExternalProvider =
|
||||||
void Function(ffi.Pointer<ffi.Char>, ffi.Pointer<ffi.Char>, int)>();
|
_sideLoadExternalProviderPtr.asFunction<
|
||||||
|
void Function(ffi.Pointer<ffi.Char>, ffi.Pointer<ffi.Char>, int)>();
|
||||||
|
|
||||||
void initNativeApiBridge(
|
void initNativeApiBridge(
|
||||||
ffi.Pointer<ffi.Void> api,
|
ffi.Pointer<ffi.Void> api,
|
||||||
|
|||||||
28
lib/common/archive.dart
Normal file
28
lib/common/archive.dart
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
import 'dart:io';
|
||||||
|
import 'package:archive/archive_io.dart';
|
||||||
|
import 'package:path/path.dart';
|
||||||
|
|
||||||
|
extension ArchiveExt on Archive {
|
||||||
|
addDirectoryToArchive(String dirPath, String parentPath) {
|
||||||
|
final dir = Directory(dirPath);
|
||||||
|
final entities = dir.listSync(recursive: false);
|
||||||
|
for (final entity in entities) {
|
||||||
|
final relativePath = relative(entity.path, from: parentPath);
|
||||||
|
if (entity is File) {
|
||||||
|
final data = entity.readAsBytesSync();
|
||||||
|
final archiveFile = ArchiveFile(relativePath, data.length, data);
|
||||||
|
addFile(archiveFile);
|
||||||
|
} else if (entity is Directory) {
|
||||||
|
addDirectoryToArchive(entity.path, parentPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
add<T>(String name, T raw) {
|
||||||
|
final data = json.encode(raw);
|
||||||
|
addFile(
|
||||||
|
ArchiveFile(name, data.length, data),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,4 +16,21 @@ extension ColorExtension on Color {
|
|||||||
toLittle() {
|
toLittle() {
|
||||||
return withOpacity(0.03);
|
return withOpacity(0.03);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
Color darken([double amount = .1]) {
|
||||||
|
assert(amount >= 0 && amount <= 1);
|
||||||
|
final hsl = HSLColor.fromColor(this);
|
||||||
|
final hslDark = hsl.withLightness((hsl.lightness - amount).clamp(0.0, 1.0));
|
||||||
|
return hslDark.toColor();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension ColorSchemeExtension on ColorScheme {
|
||||||
|
ColorScheme toPrueBlack(bool isPrueBlack) => isPrueBlack
|
||||||
|
? copyWith(
|
||||||
|
surface: Colors.black,
|
||||||
|
background: Colors.black,
|
||||||
|
surfaceContainer: surfaceContainer.darken(0.05),
|
||||||
|
)
|
||||||
|
: this;
|
||||||
|
}
|
||||||
|
|||||||
@@ -23,6 +23,6 @@ export 'app_localizations.dart';
|
|||||||
export 'function.dart';
|
export 'function.dart';
|
||||||
export 'package.dart';
|
export 'package.dart';
|
||||||
export 'measure.dart';
|
export 'measure.dart';
|
||||||
export 'service.dart';
|
export 'windows.dart';
|
||||||
export 'iterable.dart';
|
export 'iterable.dart';
|
||||||
export 'scroll.dart';
|
export 'scroll.dart';
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
import 'dart:io';
|
|
||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'package:fl_clash/enum/enum.dart';
|
import 'package:fl_clash/enum/enum.dart';
|
||||||
@@ -17,7 +16,7 @@ const mmdbFileName = "geoip.metadb";
|
|||||||
const asnFileName = "ASN.mmdb";
|
const asnFileName = "ASN.mmdb";
|
||||||
const geoIpFileName = "GeoIP.dat";
|
const geoIpFileName = "GeoIP.dat";
|
||||||
const geoSiteFileName = "GeoSite.dat";
|
const geoSiteFileName = "GeoSite.dat";
|
||||||
final double kHeaderHeight = system.isDesktop ? (Platform.isMacOS ? 28 : 40) : 0;
|
final double kHeaderHeight = system.isDesktop ? 40 : 0;
|
||||||
const GeoXMap defaultGeoXMap = {
|
const GeoXMap defaultGeoXMap = {
|
||||||
"mmdb":
|
"mmdb":
|
||||||
"https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geoip.metadb",
|
"https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geoip.metadb",
|
||||||
|
|||||||
@@ -1,11 +1,8 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:typed_data';
|
||||||
|
|
||||||
import 'package:fl_clash/common/common.dart';
|
import 'package:fl_clash/common/common.dart';
|
||||||
import 'package:fl_clash/enum/enum.dart';
|
|
||||||
import 'package:fl_clash/models/models.dart';
|
import 'package:fl_clash/models/models.dart';
|
||||||
import 'package:fl_clash/state.dart';
|
|
||||||
import 'package:path/path.dart';
|
|
||||||
import 'package:webdav_client/webdav_client.dart';
|
import 'package:webdav_client/webdav_client.dart';
|
||||||
|
|
||||||
class DAVClient {
|
class DAVClient {
|
||||||
@@ -33,8 +30,6 @@ class DAVClient {
|
|||||||
Future<bool> _ping() async {
|
Future<bool> _ping() async {
|
||||||
try {
|
try {
|
||||||
await client.ping();
|
await client.ping();
|
||||||
await client.mkdir("/$appName");
|
|
||||||
await client.mkdir("/$appName/$profilesDirectoryName");
|
|
||||||
return true;
|
return true;
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
return false;
|
return false;
|
||||||
@@ -43,65 +38,17 @@ class DAVClient {
|
|||||||
|
|
||||||
get root => "/$appName";
|
get root => "/$appName";
|
||||||
|
|
||||||
get remoteConfig => "$root/$configKey.json";
|
get backupFile => "$root/backup.zip";
|
||||||
|
|
||||||
get remoteClashConfig => "$root/$clashConfigKey.json";
|
backup(Uint8List data) async {
|
||||||
|
|
||||||
get remoteProfiles => "$root/$profilesDirectoryName";
|
|
||||||
|
|
||||||
backup() async {
|
|
||||||
final appController = globalState.appController;
|
|
||||||
final config = appController.config;
|
|
||||||
final clashConfig = appController.clashConfig;
|
|
||||||
await client.mkdir("$root");
|
await client.mkdir("$root");
|
||||||
client.write(
|
await client.write("$backupFile", data);
|
||||||
remoteConfig,
|
|
||||||
utf8.encode(
|
|
||||||
json.encode(config.toJson()),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
client.write(
|
|
||||||
remoteClashConfig,
|
|
||||||
utf8.encode(
|
|
||||||
json.encode(clashConfig.toJson()),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
await client.remove(remoteProfiles);
|
|
||||||
for (final profile in config.profiles) {
|
|
||||||
final path = await appPath.getProfilePath(profile.id);
|
|
||||||
if (path == null) continue;
|
|
||||||
await client.writeFromFile(
|
|
||||||
path,
|
|
||||||
"$remoteProfiles/${basename(path)}",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
recovery({required RecoveryOption recoveryOption}) async {
|
Future<List<int>> recovery() async {
|
||||||
final profiles = await client.readDir(remoteProfiles);
|
await client.mkdir("$root");
|
||||||
final profilesPath = await appPath.getProfilesPath();
|
final data = await client.read(backupFile);
|
||||||
for (final file in profiles) {
|
return data;
|
||||||
await client.read2File(
|
|
||||||
"$remoteProfiles/${file.name}",
|
|
||||||
join(
|
|
||||||
profilesPath,
|
|
||||||
file.name,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
final configRaw = utf8.decode((await client.read(remoteConfig)));
|
|
||||||
final clashConfigRaw = utf8.decode(await client.read(remoteClashConfig));
|
|
||||||
final config = Config.fromJson(json.decode(configRaw));
|
|
||||||
final clashConfig = ClashConfig.fromJson(json.decode(clashConfigRaw));
|
|
||||||
if(recoveryOption == RecoveryOption.onlyProfiles){
|
|
||||||
globalState.appController.config.update(config, RecoveryOption.onlyProfiles);
|
|
||||||
}else{
|
|
||||||
globalState.appController.config.update(config, RecoveryOption.all);
|
|
||||||
globalState.appController.clashConfig.update(clashConfig);
|
|
||||||
}
|
|
||||||
await globalState.appController.applyProfile();
|
|
||||||
globalState.appController.savePreferences();
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
import 'package:fl_clash/models/models.dart' hide Process;
|
||||||
import 'package:launch_at_startup/launch_at_startup.dart';
|
import 'package:launch_at_startup/launch_at_startup.dart';
|
||||||
|
|
||||||
import 'constant.dart';
|
import 'constant.dart';
|
||||||
import 'system.dart';
|
import 'system.dart';
|
||||||
|
import 'windows.dart';
|
||||||
|
|
||||||
class AutoLaunch {
|
class AutoLaunch {
|
||||||
static AutoLaunch? _instance;
|
static AutoLaunch? _instance;
|
||||||
@@ -24,18 +26,77 @@ class AutoLaunch {
|
|||||||
return await launchAtStartup.isEnabled();
|
return await launchAtStartup.isEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<bool> get windowsIsEnable async {
|
||||||
|
final res = await Process.run(
|
||||||
|
'schtasks',
|
||||||
|
['/Query', '/TN', appName, '/V', "/FO", "LIST"],
|
||||||
|
runInShell: true,
|
||||||
|
);
|
||||||
|
return res.stdout.toString().contains(Platform.resolvedExecutable);
|
||||||
|
}
|
||||||
|
|
||||||
Future<bool> enable() async {
|
Future<bool> enable() async {
|
||||||
|
if (Platform.isWindows) {
|
||||||
|
await windowsDisable();
|
||||||
|
}
|
||||||
return await launchAtStartup.enable();
|
return await launchAtStartup.enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
windowsDisable() async {
|
||||||
|
final res = await Process.run(
|
||||||
|
'schtasks',
|
||||||
|
[
|
||||||
|
'/Delete',
|
||||||
|
'/TN',
|
||||||
|
appName,
|
||||||
|
'/F',
|
||||||
|
],
|
||||||
|
runInShell: true,
|
||||||
|
);
|
||||||
|
return res.exitCode == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<bool> windowsEnable() async {
|
||||||
|
await disable();
|
||||||
|
return windows?.runas(
|
||||||
|
'schtasks',
|
||||||
|
[
|
||||||
|
'/Create',
|
||||||
|
'/SC',
|
||||||
|
'ONLOGON',
|
||||||
|
'/TN',
|
||||||
|
appName,
|
||||||
|
'/TR',
|
||||||
|
Platform.resolvedExecutable,
|
||||||
|
'/RL',
|
||||||
|
'HIGHEST',
|
||||||
|
'/F'
|
||||||
|
].join(" "),
|
||||||
|
) ??
|
||||||
|
false;
|
||||||
|
}
|
||||||
|
|
||||||
Future<bool> disable() async {
|
Future<bool> disable() async {
|
||||||
return await launchAtStartup.disable();
|
return await launchAtStartup.disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
updateStatus(bool value) async {
|
updateStatus(AutoLaunchState state) async {
|
||||||
final isEnable = await this.isEnable;
|
final isOpenTun = state.isOpenTun;
|
||||||
if (isEnable == value) return;
|
final isAutoLaunch = state.isAutoLaunch;
|
||||||
if (value == true) {
|
if (Platform.isWindows && isOpenTun) {
|
||||||
|
if (await windowsIsEnable == isAutoLaunch) return;
|
||||||
|
if (isAutoLaunch) {
|
||||||
|
final isEnable = await windowsEnable();
|
||||||
|
if (!isEnable) {
|
||||||
|
enable();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
windowsDisable();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (await isEnable == isAutoLaunch) return;
|
||||||
|
if (isAutoLaunch == true) {
|
||||||
enable();
|
enable();
|
||||||
} else {
|
} else {
|
||||||
disable();
|
disable();
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class Navigation {
|
|||||||
modes: [NavigationItemMode.desktop, NavigationItemMode.more],
|
modes: [NavigationItemMode.desktop, NavigationItemMode.more],
|
||||||
),
|
),
|
||||||
const NavigationItem(
|
const NavigationItem(
|
||||||
icon: Icon(Icons.swap_vert_circle),
|
icon: Icon(Icons.storage),
|
||||||
label: "resources",
|
label: "resources",
|
||||||
description: "resourcesDesc",
|
description: "resourcesDesc",
|
||||||
keep: false,
|
keep: false,
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'dart:isolate';
|
import 'dart:isolate';
|
||||||
|
import 'dart:math';
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
|
|
||||||
import 'package:fl_clash/common/app_localizations.dart';
|
import 'package:fl_clash/common/common.dart';
|
||||||
import 'package:fl_clash/common/constant.dart';
|
|
||||||
import 'package:fl_clash/enum/enum.dart';
|
import 'package:fl_clash/enum/enum.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:zxing2/qrcode.dart';
|
import 'package:zxing2/qrcode.dart';
|
||||||
@@ -83,7 +83,7 @@ class Other {
|
|||||||
if (charA == charB) {
|
if (charA == charB) {
|
||||||
return sortByChar(a.substring(1), b.substring(1));
|
return sortByChar(a.substring(1), b.substring(1));
|
||||||
} else {
|
} else {
|
||||||
return charA.compareTo(charB);
|
return charA.compareToLower(charB);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,22 +191,21 @@ class Other {
|
|||||||
return ViewMode.desktop;
|
return ViewMode.desktop;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getColumns(ViewMode viewMode, int currentColumns) {
|
int getProxiesColumns(double viewWidth, ProxiesLayout proxiesLayout) {
|
||||||
final targetColumnsArray = viewModeColumnsMap[viewMode]!;
|
final columns = max((viewWidth / 300).ceil(), 2);
|
||||||
if (targetColumnsArray.contains(currentColumns)) {
|
return switch (proxiesLayout) {
|
||||||
return currentColumns;
|
ProxiesLayout.tight => columns - 1,
|
||||||
}
|
ProxiesLayout.standard => columns,
|
||||||
return targetColumnsArray.first;
|
ProxiesLayout.loose => columns + 1,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
String getColumnsTextForInt(int number){
|
int getProfilesColumns(double viewWidth) {
|
||||||
return switch(number){
|
return max((viewWidth / 400).floor(), 1);
|
||||||
1 => appLocalizations.oneColumn,
|
}
|
||||||
2 => appLocalizations.twoColumns,
|
|
||||||
3 => appLocalizations.threeColumns,
|
String getBackupFileName() {
|
||||||
4 => appLocalizations.fourColumns,
|
return "${appName}_backup_${DateTime.now().show}.zip";
|
||||||
int() => throw UnimplementedError(),
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import 'constant.dart';
|
|||||||
class AppPath {
|
class AppPath {
|
||||||
static AppPath? _instance;
|
static AppPath? _instance;
|
||||||
Completer<Directory> cacheDir = Completer();
|
Completer<Directory> cacheDir = Completer();
|
||||||
|
Completer<Directory> downloadDir = Completer();
|
||||||
|
|
||||||
// Future<Directory> _createDesktopCacheDir() async {
|
// Future<Directory> _createDesktopCacheDir() async {
|
||||||
// final path = join(dirname(Platform.resolvedExecutable), 'cache');
|
// final path = join(dirname(Platform.resolvedExecutable), 'cache');
|
||||||
@@ -23,6 +24,9 @@ class AppPath {
|
|||||||
getApplicationSupportDirectory().then((value) {
|
getApplicationSupportDirectory().then((value) {
|
||||||
cacheDir.complete(value);
|
cacheDir.complete(value);
|
||||||
});
|
});
|
||||||
|
getDownloadsDirectory().then((value) {
|
||||||
|
downloadDir.complete(value);
|
||||||
|
});
|
||||||
// if (Platform.isAndroid) {
|
// if (Platform.isAndroid) {
|
||||||
// getApplicationSupportDirectory().then((value) {
|
// getApplicationSupportDirectory().then((value) {
|
||||||
// cacheDir.complete(value);
|
// cacheDir.complete(value);
|
||||||
@@ -39,6 +43,11 @@ class AppPath {
|
|||||||
return _instance!;
|
return _instance!;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<String> getDownloadDirPath() async {
|
||||||
|
final directory = await downloadDir.future;
|
||||||
|
return directory.path;
|
||||||
|
}
|
||||||
|
|
||||||
Future<String> getHomeDirPath() async {
|
Future<String> getHomeDirPath() async {
|
||||||
final directory = await cacheDir.future;
|
final directory = await cacheDir.future;
|
||||||
return directory.path;
|
return directory.path;
|
||||||
|
|||||||
@@ -1,22 +1,31 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
import 'dart:typed_data';
|
||||||
|
|
||||||
import 'package:file_picker/file_picker.dart';
|
import 'package:file_picker/file_picker.dart';
|
||||||
import 'package:fl_clash/common/common.dart';
|
import 'package:fl_clash/common/common.dart';
|
||||||
import 'package:image_picker/image_picker.dart';
|
import 'package:image_picker/image_picker.dart';
|
||||||
|
|
||||||
class Picker {
|
class Picker {
|
||||||
Future<PlatformFile?> pickerConfigFile() async {
|
Future<PlatformFile?> pickerFile() async {
|
||||||
final filePickerResult = await FilePicker.platform.pickFiles(
|
final filePickerResult = await FilePicker.platform.pickFiles(
|
||||||
withData: true,
|
withData: true,
|
||||||
allowMultiple: false,
|
allowMultiple: false,
|
||||||
|
initialDirectory: await appPath.getDownloadDirPath(),
|
||||||
);
|
);
|
||||||
return filePickerResult?.files.first;
|
return filePickerResult?.files.first;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<PlatformFile?> pickerGeoDataFile() async {
|
Future<String?> saveFile(String fileName, Uint8List bytes) async {
|
||||||
final filePickerResult = await FilePicker.platform.pickFiles(
|
final path = await FilePicker.platform.saveFile(
|
||||||
withData: true,
|
fileName: fileName,
|
||||||
allowMultiple: false,
|
initialDirectory: await appPath.getDownloadDirPath(),
|
||||||
|
bytes: Platform.isAndroid ? bytes : null,
|
||||||
);
|
);
|
||||||
return filePickerResult?.files.first;
|
if (!Platform.isAndroid && path != null) {
|
||||||
|
final file = await File(path).create(recursive: true);
|
||||||
|
await file.writeAsBytes(bytes);
|
||||||
|
}
|
||||||
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String?> pickerConfigQRCode() async {
|
Future<String?> pickerConfigQRCode() async {
|
||||||
|
|||||||
@@ -1,37 +1,4 @@
|
|||||||
import 'package:fl_clash/common/datetime.dart';
|
import 'package:fl_clash/common/system.dart';
|
||||||
import 'package:fl_clash/plugins/proxy.dart';
|
import 'package:proxy/proxy.dart';
|
||||||
import 'package:proxy/proxy.dart' as proxy_plugin;
|
|
||||||
import 'package:proxy/proxy_platform_interface.dart';
|
|
||||||
|
|
||||||
class ProxyManager {
|
final proxy = system.isDesktop ? Proxy() : null;
|
||||||
static ProxyManager? _instance;
|
|
||||||
late ProxyPlatform _proxy;
|
|
||||||
|
|
||||||
ProxyManager._internal() {
|
|
||||||
_proxy = proxy ?? proxy_plugin.Proxy();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool get isStart => startTime != null && startTime!.isBeforeNow;
|
|
||||||
|
|
||||||
DateTime? get startTime => _proxy.startTime;
|
|
||||||
|
|
||||||
Future<bool?> startProxy({required int port}) async {
|
|
||||||
return await _proxy.startProxy(port);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<bool?> stopProxy() async {
|
|
||||||
return await _proxy.stopProxy();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<DateTime?> updateStartTime() async {
|
|
||||||
if (_proxy is! Proxy) return null;
|
|
||||||
return await (_proxy as Proxy).updateStartTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
factory ProxyManager() {
|
|
||||||
_instance ??= ProxyManager._internal();
|
|
||||||
return _instance!;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final proxyManager = ProxyManager();
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
import 'package:dio/io.dart';
|
import 'package:dio/io.dart';
|
||||||
@@ -13,9 +14,6 @@ class Request {
|
|||||||
|
|
||||||
Request() {
|
Request() {
|
||||||
_dio = Dio();
|
_dio = Dio();
|
||||||
_dio.options = BaseOptions(
|
|
||||||
headers: {"User-Agent": globalState.appController.clashConfig.globalUa},
|
|
||||||
);
|
|
||||||
_dio.interceptors.add(
|
_dio.interceptors.add(
|
||||||
InterceptorsWrapper(
|
InterceptorsWrapper(
|
||||||
onRequest: (options, handler) {
|
onRequest: (options, handler) {
|
||||||
@@ -52,11 +50,14 @@ class Request {
|
|||||||
.get(
|
.get(
|
||||||
url,
|
url,
|
||||||
options: Options(
|
options: Options(
|
||||||
|
headers: {
|
||||||
|
"User-Agent": globalState.appController.clashConfig.globalUa
|
||||||
|
},
|
||||||
responseType: ResponseType.bytes,
|
responseType: ResponseType.bytes,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.timeout(
|
.timeout(
|
||||||
httpTimeoutDuration * 2,
|
httpTimeoutDuration * 6,
|
||||||
);
|
);
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
@@ -86,10 +87,13 @@ class Request {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Future<IpInfo?> checkIp({CancelToken? cancelToken}) async {
|
Future<IpInfo?> checkIp({CancelToken? cancelToken}) async {
|
||||||
for (final source in _ipInfoSources.entries) {
|
for (final source in _ipInfoSources.entries.toList()..shuffle(Random())) {
|
||||||
try {
|
try {
|
||||||
final response = await _dio
|
final response = await _dio
|
||||||
.get<Map<String, dynamic>>(source.key, cancelToken: cancelToken)
|
.get<Map<String, dynamic>>(
|
||||||
|
source.key,
|
||||||
|
cancelToken: cancelToken,
|
||||||
|
)
|
||||||
.timeout(
|
.timeout(
|
||||||
httpTimeoutDuration,
|
httpTimeoutDuration,
|
||||||
);
|
);
|
||||||
@@ -97,6 +101,9 @@ class Request {
|
|||||||
return source.value(response.data!);
|
return source.value(response.data!);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
if(cancelToken?.isCancelled == true){
|
||||||
|
throw "cancelled";
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,110 +0,0 @@
|
|||||||
import 'dart:ffi';
|
|
||||||
import 'dart:io';
|
|
||||||
import 'package:ffi/ffi.dart';
|
|
||||||
import 'package:win32/win32.dart';
|
|
||||||
|
|
||||||
typedef CreateServiceNative = IntPtr Function(
|
|
||||||
IntPtr hSCManager,
|
|
||||||
Pointer<Utf16> lpServiceName,
|
|
||||||
Pointer<Utf16> lpDisplayName,
|
|
||||||
Uint32 dwDesiredAccess,
|
|
||||||
Uint32 dwServiceType,
|
|
||||||
Uint32 dwStartType,
|
|
||||||
Uint32 dwErrorControl,
|
|
||||||
Pointer<Utf16> lpBinaryPathName,
|
|
||||||
Pointer<Utf16> lpLoadOrderGroup,
|
|
||||||
Pointer<Uint32> lpdwTagId,
|
|
||||||
Pointer<Utf16> lpDependencies,
|
|
||||||
Pointer<Utf16> lpServiceStartName,
|
|
||||||
Pointer<Utf16> lpPassword,
|
|
||||||
);
|
|
||||||
|
|
||||||
typedef CreateServiceDart = int Function(
|
|
||||||
int hSCManager,
|
|
||||||
Pointer<Utf16> lpServiceName,
|
|
||||||
Pointer<Utf16> lpDisplayName,
|
|
||||||
int dwDesiredAccess,
|
|
||||||
int dwServiceType,
|
|
||||||
int dwStartType,
|
|
||||||
int dwErrorControl,
|
|
||||||
Pointer<Utf16> lpBinaryPathName,
|
|
||||||
Pointer<Utf16> lpLoadOrderGroup,
|
|
||||||
Pointer<Uint32> lpdwTagId,
|
|
||||||
Pointer<Utf16> lpDependencies,
|
|
||||||
Pointer<Utf16> lpServiceStartName,
|
|
||||||
Pointer<Utf16> lpPassword,
|
|
||||||
);
|
|
||||||
|
|
||||||
const _SERVICE_ALL_ACCESS = 0xF003F;
|
|
||||||
|
|
||||||
const _SERVICE_WIN32_OWN_PROCESS = 0x00000010;
|
|
||||||
|
|
||||||
const _SERVICE_AUTO_START = 0x00000002;
|
|
||||||
|
|
||||||
const _SERVICE_ERROR_NORMAL = 0x00000001;
|
|
||||||
|
|
||||||
typedef GetLastErrorNative = Uint32 Function();
|
|
||||||
typedef GetLastErrorDart = int Function();
|
|
||||||
|
|
||||||
class Service {
|
|
||||||
static Service? _instance;
|
|
||||||
late DynamicLibrary _advapi32;
|
|
||||||
|
|
||||||
Service._internal() {
|
|
||||||
_advapi32 = DynamicLibrary.open('advapi32.dll');
|
|
||||||
}
|
|
||||||
|
|
||||||
factory Service() {
|
|
||||||
_instance ??= Service._internal();
|
|
||||||
return _instance!;
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> createService() async {
|
|
||||||
final int scManager = OpenSCManager(nullptr, nullptr, _SERVICE_ALL_ACCESS);
|
|
||||||
if (scManager == 0) return;
|
|
||||||
final serviceName = 'FlClash Service'.toNativeUtf16();
|
|
||||||
final displayName = 'FlClash Service'.toNativeUtf16();
|
|
||||||
final binaryPathName = "C:\\Application\\Clash.Verge_1.6.6_x64_portable\\resources\\clash-verge-service.exe".toNativeUtf16();
|
|
||||||
final createService =
|
|
||||||
_advapi32.lookupFunction<CreateServiceNative, CreateServiceDart>(
|
|
||||||
'CreateServiceW',
|
|
||||||
);
|
|
||||||
final getLastError = DynamicLibrary.open('kernel32.dll')
|
|
||||||
.lookupFunction<GetLastErrorNative, GetLastErrorDart>('GetLastError');
|
|
||||||
|
|
||||||
final serviceHandle = createService(
|
|
||||||
scManager,
|
|
||||||
serviceName,
|
|
||||||
displayName,
|
|
||||||
_SERVICE_ALL_ACCESS,
|
|
||||||
_SERVICE_WIN32_OWN_PROCESS,
|
|
||||||
_SERVICE_AUTO_START,
|
|
||||||
_SERVICE_ERROR_NORMAL,
|
|
||||||
binaryPathName,
|
|
||||||
nullptr,
|
|
||||||
nullptr,
|
|
||||||
nullptr,
|
|
||||||
nullptr,
|
|
||||||
nullptr,
|
|
||||||
);
|
|
||||||
|
|
||||||
print("serviceHandle $serviceHandle");
|
|
||||||
|
|
||||||
final errorCode = GetLastError();
|
|
||||||
print('Error code: $errorCode');
|
|
||||||
|
|
||||||
final result = StartService(serviceHandle, 0, nullptr);
|
|
||||||
|
|
||||||
if (result == 0) {
|
|
||||||
print('Failed to start the service.');
|
|
||||||
} else {
|
|
||||||
print('Service started successfully.');
|
|
||||||
}
|
|
||||||
|
|
||||||
calloc.free(serviceName);
|
|
||||||
calloc.free(displayName);
|
|
||||||
calloc.free(binaryPathName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final service = Platform.isWindows ? Service() : null;
|
|
||||||
@@ -2,4 +2,10 @@ extension StringExtension on String {
|
|||||||
bool get isUrl {
|
bool get isUrl {
|
||||||
return RegExp(r'^(http|https|ftp)://').hasMatch(this);
|
return RegExp(r'^(http|https|ftp)://').hasMatch(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int compareToLower(String other) {
|
||||||
|
return toLowerCase().compareTo(
|
||||||
|
other.toLowerCase(),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,12 @@ class System {
|
|||||||
bool get isDesktop =>
|
bool get isDesktop =>
|
||||||
Platform.isWindows || Platform.isMacOS || Platform.isLinux;
|
Platform.isWindows || Platform.isMacOS || Platform.isLinux;
|
||||||
|
|
||||||
|
get isAdmin async {
|
||||||
|
if (!Platform.isWindows) return false;
|
||||||
|
final result = await Process.run('net', ['session'], runInShell: true);
|
||||||
|
return result.exitCode == 0;
|
||||||
|
}
|
||||||
|
|
||||||
back() async {
|
back() async {
|
||||||
await app?.moveTaskToBack();
|
await app?.moveTaskToBack();
|
||||||
await window?.hide();
|
await window?.hide();
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ class Window {
|
|||||||
WindowOptions windowOptions = WindowOptions(
|
WindowOptions windowOptions = WindowOptions(
|
||||||
size: Size(props.width, props.height),
|
size: Size(props.width, props.height),
|
||||||
minimumSize: const Size(380, 500),
|
minimumSize: const Size(380, 500),
|
||||||
|
windowButtonVisibility: false,
|
||||||
titleBarStyle: TitleBarStyle.hidden,
|
titleBarStyle: TitleBarStyle.hidden,
|
||||||
);
|
);
|
||||||
if (props.left != null || props.top != null) {
|
if (props.left != null || props.top != null) {
|
||||||
@@ -33,7 +34,7 @@ class Window {
|
|||||||
// await windowManager.setTitleBarStyle(TitleBarStyle.hidden);
|
// await windowManager.setTitleBarStyle(TitleBarStyle.hidden);
|
||||||
// }
|
// }
|
||||||
await windowManager.waitUntilReadyToShow(windowOptions, () async {
|
await windowManager.waitUntilReadyToShow(windowOptions, () async {
|
||||||
await windowManager.setPreventClose(true);
|
// await windowManager.setPreventClose(true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
59
lib/common/windows.dart
Normal file
59
lib/common/windows.dart
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
import 'dart:ffi';
|
||||||
|
import 'dart:io';
|
||||||
|
import 'package:ffi/ffi.dart';
|
||||||
|
|
||||||
|
class Windows {
|
||||||
|
static Windows? _instance;
|
||||||
|
late DynamicLibrary _shell32;
|
||||||
|
|
||||||
|
Windows._internal() {
|
||||||
|
_shell32 = DynamicLibrary.open('shell32.dll');
|
||||||
|
}
|
||||||
|
|
||||||
|
factory Windows() {
|
||||||
|
_instance ??= Windows._internal();
|
||||||
|
return _instance!;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool runas(String command, String arguments) {
|
||||||
|
final commandPtr = command.toNativeUtf16();
|
||||||
|
final argumentsPtr = arguments.toNativeUtf16();
|
||||||
|
final operationPtr = 'runas'.toNativeUtf16();
|
||||||
|
|
||||||
|
final shellExecute = _shell32.lookupFunction<
|
||||||
|
Int32 Function(
|
||||||
|
Pointer<Utf16> hwnd,
|
||||||
|
Pointer<Utf16> lpOperation,
|
||||||
|
Pointer<Utf16> lpFile,
|
||||||
|
Pointer<Utf16> lpParameters,
|
||||||
|
Pointer<Utf16> lpDirectory,
|
||||||
|
Int32 nShowCmd),
|
||||||
|
int Function(
|
||||||
|
Pointer<Utf16> hwnd,
|
||||||
|
Pointer<Utf16> lpOperation,
|
||||||
|
Pointer<Utf16> lpFile,
|
||||||
|
Pointer<Utf16> lpParameters,
|
||||||
|
Pointer<Utf16> lpDirectory,
|
||||||
|
int nShowCmd)>('ShellExecuteW');
|
||||||
|
|
||||||
|
final result = shellExecute(
|
||||||
|
nullptr,
|
||||||
|
operationPtr,
|
||||||
|
commandPtr,
|
||||||
|
argumentsPtr,
|
||||||
|
nullptr,
|
||||||
|
1,
|
||||||
|
);
|
||||||
|
|
||||||
|
calloc.free(commandPtr);
|
||||||
|
calloc.free(argumentsPtr);
|
||||||
|
calloc.free(operationPtr);
|
||||||
|
|
||||||
|
if (result <= 32) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final windows = Platform.isWindows ? Windows() : null;
|
||||||
@@ -1,9 +1,15 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
import 'dart:isolate';
|
||||||
|
|
||||||
|
import 'package:archive/archive.dart';
|
||||||
|
import 'package:fl_clash/common/archive.dart';
|
||||||
import 'package:fl_clash/enum/enum.dart';
|
import 'package:fl_clash/enum/enum.dart';
|
||||||
import 'package:fl_clash/state.dart';
|
import 'package:fl_clash/state.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:lpinyin/lpinyin.dart';
|
||||||
|
import 'package:path/path.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
@@ -20,6 +26,7 @@ class AppController {
|
|||||||
late Function updateClashConfigDebounce;
|
late Function updateClashConfigDebounce;
|
||||||
late Function updateGroupDebounce;
|
late Function updateGroupDebounce;
|
||||||
late Function addCheckIpNumDebounce;
|
late Function addCheckIpNumDebounce;
|
||||||
|
late Function applyProfileDebounce;
|
||||||
|
|
||||||
AppController(this.context) {
|
AppController(this.context) {
|
||||||
appState = context.read<AppState>();
|
appState = context.read<AppState>();
|
||||||
@@ -28,6 +35,9 @@ class AppController {
|
|||||||
updateClashConfigDebounce = debounce<Function()>(() async {
|
updateClashConfigDebounce = debounce<Function()>(() async {
|
||||||
await updateClashConfig();
|
await updateClashConfig();
|
||||||
});
|
});
|
||||||
|
applyProfileDebounce = debounce<Function()>(() async {
|
||||||
|
await applyProfile(isPrue: true);
|
||||||
|
});
|
||||||
addCheckIpNumDebounce = debounce(() {
|
addCheckIpNumDebounce = debounce(() {
|
||||||
appState.checkIpNum++;
|
appState.checkIpNum++;
|
||||||
});
|
});
|
||||||
@@ -37,10 +47,9 @@ class AppController {
|
|||||||
measure = Measure.of(context);
|
measure = Measure.of(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> updateSystemProxy(bool isStart) async {
|
updateStatus(bool isStart) async {
|
||||||
if (isStart) {
|
if (isStart) {
|
||||||
await globalState.startSystemProxy(
|
await globalState.handleStart(
|
||||||
appState: appState,
|
|
||||||
config: config,
|
config: config,
|
||||||
clashConfig: clashConfig,
|
clashConfig: clashConfig,
|
||||||
);
|
);
|
||||||
@@ -50,10 +59,9 @@ class AppController {
|
|||||||
updateRunTime,
|
updateRunTime,
|
||||||
updateTraffic,
|
updateTraffic,
|
||||||
];
|
];
|
||||||
if (Platform.isAndroid) return;
|
applyProfileDebounce();
|
||||||
await applyProfile(isPrue: true);
|
|
||||||
} else {
|
} else {
|
||||||
await globalState.stopSystemProxy();
|
await globalState.handleStop();
|
||||||
clashCore.resetTraffic();
|
clashCore.resetTraffic();
|
||||||
appState.traffics = [];
|
appState.traffics = [];
|
||||||
appState.totalTraffic = Traffic();
|
appState.totalTraffic = Traffic();
|
||||||
@@ -67,8 +75,9 @@ class AppController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateRunTime() {
|
updateRunTime() {
|
||||||
if (proxyManager.startTime != null) {
|
final startTime = globalState.startTime;
|
||||||
final startTimeStamp = proxyManager.startTime!.millisecondsSinceEpoch;
|
if (startTime != null) {
|
||||||
|
final startTimeStamp = startTime.millisecondsSinceEpoch;
|
||||||
final nowTimeStamp = DateTime.now().millisecondsSinceEpoch;
|
final nowTimeStamp = DateTime.now().millisecondsSinceEpoch;
|
||||||
appState.runTime = nowTimeStamp - startTimeStamp;
|
appState.runTime = nowTimeStamp - startTimeStamp;
|
||||||
} else {
|
} else {
|
||||||
@@ -90,22 +99,22 @@ class AppController {
|
|||||||
|
|
||||||
deleteProfile(String id) async {
|
deleteProfile(String id) async {
|
||||||
config.deleteProfileById(id);
|
config.deleteProfileById(id);
|
||||||
final profilePath = await appPath.getProfilePath(id);
|
clashCore.clearEffect(id);
|
||||||
if (profilePath == null) return;
|
|
||||||
clashCore.clearEffect(profilePath);
|
|
||||||
if (config.currentProfileId == id) {
|
if (config.currentProfileId == id) {
|
||||||
if (config.profiles.isNotEmpty) {
|
if (config.profiles.isNotEmpty) {
|
||||||
final updateId = config.profiles.first.id;
|
final updateId = config.profiles.first.id;
|
||||||
changeProfile(updateId);
|
changeProfile(updateId);
|
||||||
} else {
|
} else {
|
||||||
updateSystemProxy(false);
|
updateStatus(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> updateProfile(Profile profile) async {
|
Future<void> updateProfile(Profile profile) async {
|
||||||
await profile.update();
|
final newProfile = await profile.update();
|
||||||
config.setProfile(await profile.update());
|
config.setProfile(
|
||||||
|
newProfile.copyWith(isUpdating: false),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> updateClashConfig({bool isPatch = true}) async {
|
Future<void> updateClashConfig({bool isPatch = true}) async {
|
||||||
@@ -140,9 +149,6 @@ class AppController {
|
|||||||
changeProfile(String? value) async {
|
changeProfile(String? value) async {
|
||||||
if (value == config.currentProfileId) return;
|
if (value == config.currentProfileId) return;
|
||||||
config.currentProfileId = value;
|
config.currentProfileId = value;
|
||||||
await applyProfile();
|
|
||||||
appState.delayMap = {};
|
|
||||||
saveConfigPreferences();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
autoUpdateProfiles() async {
|
autoUpdateProfiles() async {
|
||||||
@@ -225,7 +231,7 @@ class AppController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleExit() async {
|
handleExit() async {
|
||||||
await updateSystemProxy(false);
|
await updateStatus(false);
|
||||||
await savePreferences();
|
await savePreferences();
|
||||||
clashCore.shutdown();
|
clashCore.shutdown();
|
||||||
system.exit();
|
system.exit();
|
||||||
@@ -294,31 +300,13 @@ class AppController {
|
|||||||
if (!config.silentLaunch) {
|
if (!config.silentLaunch) {
|
||||||
window?.show();
|
window?.show();
|
||||||
}
|
}
|
||||||
final commonScaffoldState = globalState.homeScaffoldKey.currentState;
|
if (Platform.isAndroid) {
|
||||||
if (commonScaffoldState?.mounted == true) {
|
globalState.updateStartTime();
|
||||||
await commonScaffoldState?.loadingRun(() async {
|
|
||||||
await globalState.applyProfile(
|
|
||||||
appState: appState,
|
|
||||||
config: config,
|
|
||||||
clashConfig: clashConfig,
|
|
||||||
);
|
|
||||||
}, title: appLocalizations.init);
|
|
||||||
} else {
|
|
||||||
await globalState.applyProfile(
|
|
||||||
appState: appState,
|
|
||||||
config: config,
|
|
||||||
clashConfig: clashConfig,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
await afterInit();
|
if (globalState.isStart) {
|
||||||
}
|
await updateStatus(true);
|
||||||
|
|
||||||
afterInit() async {
|
|
||||||
await proxyManager.updateStartTime();
|
|
||||||
if (proxyManager.isStart) {
|
|
||||||
await updateSystemProxy(true);
|
|
||||||
} else {
|
} else {
|
||||||
await updateSystemProxy(config.autoRun);
|
await updateStatus(config.autoRun);
|
||||||
}
|
}
|
||||||
autoUpdateProfiles();
|
autoUpdateProfiles();
|
||||||
autoCheckUpdate();
|
autoCheckUpdate();
|
||||||
@@ -382,6 +370,10 @@ class AppController {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
showSnackBar(String message) {
|
||||||
|
globalState.showSnackBar(context, message: message);
|
||||||
|
}
|
||||||
|
|
||||||
addProfileFormURL(String url) async {
|
addProfileFormURL(String url) async {
|
||||||
if (globalState.navigatorKey.currentState?.canPop() ?? false) {
|
if (globalState.navigatorKey.currentState?.canPop() ?? false) {
|
||||||
globalState.navigatorKey.currentState?.popUntil((route) => route.isFirst);
|
globalState.navigatorKey.currentState?.popUntil((route) => route.isFirst);
|
||||||
@@ -403,7 +395,7 @@ class AppController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addProfileFormFile() async {
|
addProfileFormFile() async {
|
||||||
final platformFile = await globalState.safeRun(picker.pickerConfigFile);
|
final platformFile = await globalState.safeRun(picker.pickerFile);
|
||||||
final bytes = platformFile?.bytes;
|
final bytes = platformFile?.bytes;
|
||||||
if (bytes == null) {
|
if (bytes == null) {
|
||||||
return null;
|
return null;
|
||||||
@@ -431,8 +423,6 @@ class AppController {
|
|||||||
addProfileFormURL(url);
|
addProfileFormURL(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
int get columns => other.getColumns(appState.viewMode, config.proxiesColumns);
|
|
||||||
|
|
||||||
updateViewWidth(double width) {
|
updateViewWidth(double width) {
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
appState.viewWidth = width;
|
appState.viewWidth = width;
|
||||||
@@ -442,7 +432,10 @@ class AppController {
|
|||||||
List<Proxy> _sortOfName(List<Proxy> proxies) {
|
List<Proxy> _sortOfName(List<Proxy> proxies) {
|
||||||
return List.of(proxies)
|
return List.of(proxies)
|
||||||
..sort(
|
..sort(
|
||||||
(a, b) => other.sortByChar(a.name, b.name),
|
(a, b) => other.sortByChar(
|
||||||
|
PinyinHelper.getPinyin(a.name),
|
||||||
|
PinyinHelper.getPinyin(b.name),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -480,4 +473,63 @@ class AppController {
|
|||||||
config.currentSelectedMap[groupName] ?? '') ??
|
config.currentSelectedMap[groupName] ?? '') ??
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<List<int>> backupData() async {
|
||||||
|
final homeDirPath = await appPath.getHomeDirPath();
|
||||||
|
final profilesPath = await appPath.getProfilesPath();
|
||||||
|
final configJson = config.toJson();
|
||||||
|
final clashConfigJson = clashConfig.toJson();
|
||||||
|
return Isolate.run<List<int>>(() async {
|
||||||
|
final archive = Archive();
|
||||||
|
archive.add("config.json", configJson);
|
||||||
|
archive.add("clashConfig.json", clashConfigJson);
|
||||||
|
await archive.addDirectoryToArchive(profilesPath, homeDirPath);
|
||||||
|
final zipEncoder = ZipEncoder();
|
||||||
|
return zipEncoder.encode(archive) ?? [];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
recoveryData(
|
||||||
|
List<int> data,
|
||||||
|
RecoveryOption recoveryOption,
|
||||||
|
) async {
|
||||||
|
final archive = await Isolate.run<Archive>(() {
|
||||||
|
final zipDecoder = ZipDecoder();
|
||||||
|
return zipDecoder.decodeBytes(data);
|
||||||
|
});
|
||||||
|
final homeDirPath = await appPath.getHomeDirPath();
|
||||||
|
final configs =
|
||||||
|
archive.files.where((item) => item.name.endsWith(".json")).toList();
|
||||||
|
final profiles =
|
||||||
|
archive.files.where((item) => !item.name.endsWith(".json"));
|
||||||
|
final configIndex =
|
||||||
|
configs.indexWhere((config) => config.name == "config.json");
|
||||||
|
final clashConfigIndex =
|
||||||
|
configs.indexWhere((config) => config.name == "clashConfig.json");
|
||||||
|
if (configIndex == -1 || clashConfigIndex == -1) throw "invalid backup.zip";
|
||||||
|
final configFile = configs[configIndex];
|
||||||
|
final clashConfigFile = configs[clashConfigIndex];
|
||||||
|
final tempConfig = Config.fromJson(
|
||||||
|
json.decode(
|
||||||
|
utf8.decode(configFile.content),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
final tempClashConfig = ClashConfig.fromJson(
|
||||||
|
json.decode(
|
||||||
|
utf8.decode(clashConfigFile.content),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
for (final profile in profiles) {
|
||||||
|
final filePath = join(homeDirPath, profile.name);
|
||||||
|
final file = File(filePath);
|
||||||
|
await file.create(recursive: true);
|
||||||
|
await file.writeAsBytes(profile.content);
|
||||||
|
}
|
||||||
|
if (recoveryOption == RecoveryOption.onlyProfiles) {
|
||||||
|
config.update(tempConfig, RecoveryOption.onlyProfiles);
|
||||||
|
} else {
|
||||||
|
config.update(tempConfig, RecoveryOption.all);
|
||||||
|
clashConfig.update(tempClashConfig);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,6 +52,8 @@ enum TunStack { gvisor, system, mixed }
|
|||||||
|
|
||||||
enum AccessControlMode { acceptSelected, rejectSelected }
|
enum AccessControlMode { acceptSelected, rejectSelected }
|
||||||
|
|
||||||
|
enum AccessSortType { none, name, time }
|
||||||
|
|
||||||
enum ProfileType { file, url }
|
enum ProfileType { file, url }
|
||||||
|
|
||||||
enum ResultType { success, error }
|
enum ResultType { success, error }
|
||||||
@@ -84,4 +86,6 @@ enum CommonCardType { plain, filled }
|
|||||||
|
|
||||||
enum ProxiesType { tab, list }
|
enum ProxiesType { tab, list }
|
||||||
|
|
||||||
|
enum ProxiesLayout{ loose, standard, tight }
|
||||||
|
|
||||||
enum ProxyCardType { expand, shrink, min }
|
enum ProxyCardType { expand, shrink, min }
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import 'package:collection/collection.dart';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:fl_clash/enum/enum.dart';
|
import 'package:fl_clash/enum/enum.dart';
|
||||||
import 'package:fl_clash/models/models.dart';
|
import 'package:fl_clash/models/models.dart';
|
||||||
import 'package:fl_clash/plugins/app.dart';
|
import 'package:fl_clash/plugins/app.dart';
|
||||||
@@ -6,15 +7,9 @@ import 'package:fl_clash/common/common.dart';
|
|||||||
import 'package:fl_clash/state.dart';
|
import 'package:fl_clash/state.dart';
|
||||||
import 'package:fl_clash/widgets/widgets.dart';
|
import 'package:fl_clash/widgets/widgets.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
import 'package:provider/provider.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 {
|
class AccessFragment extends StatefulWidget {
|
||||||
const AccessFragment({super.key});
|
const AccessFragment({super.key});
|
||||||
|
|
||||||
@@ -23,319 +18,100 @@ class AccessFragment extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _AccessFragmentState extends State<AccessFragment> {
|
class _AccessFragmentState extends State<AccessFragment> {
|
||||||
final packagesListenable = ValueNotifier<List<Package>>([]);
|
List<String> acceptList = [];
|
||||||
|
List<String> rejectList = [];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
_updateInitList();
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
Future.delayed(const Duration(milliseconds: 300), () async {
|
final appState = globalState.appController.appState;
|
||||||
packagesListenable.value = await app?.getPackages() ?? [];
|
if (appState.packages.isEmpty) {
|
||||||
});
|
Future.delayed(const Duration(milliseconds: 300), () async {
|
||||||
|
appState.packages = await app?.getPackages() ?? [];
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
_updateInitList() {
|
||||||
void dispose() {
|
final accessControl = globalState.appController.config.accessControl;
|
||||||
super.dispose();
|
acceptList = accessControl.acceptList;
|
||||||
packagesListenable.dispose();
|
rejectList = accessControl.rejectList;
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildAppProxyModePopup() {
|
Widget _buildSearchButton() {
|
||||||
final items = [
|
|
||||||
CommonPopupMenuItem(
|
|
||||||
action: AccessControlMode.rejectSelected,
|
|
||||||
label: appLocalizations.blacklistMode,
|
|
||||||
),
|
|
||||||
CommonPopupMenuItem(
|
|
||||||
action: AccessControlMode.acceptSelected,
|
|
||||||
label: appLocalizations.whitelistMode,
|
|
||||||
),
|
|
||||||
];
|
|
||||||
return Selector<Config, AccessControlMode>(
|
|
||||||
selector: (_, config) => config.accessControl.mode,
|
|
||||||
builder: (context, mode, __) {
|
|
||||||
return CommonPopupMenu<AccessControlMode>.radio(
|
|
||||||
icon: Icon(
|
|
||||||
Icons.mode_standby,
|
|
||||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
|
||||||
),
|
|
||||||
items: items,
|
|
||||||
onSelected: (value) {
|
|
||||||
final config = context.read<Config>();
|
|
||||||
config.accessControl = config.accessControl.copyWith(
|
|
||||||
mode: value,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
selectedValue: mode,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildFilterSystemAppButton() {
|
|
||||||
return Selector<Config, bool>(
|
|
||||||
selector: (_, config) => config.accessControl.isFilterSystemApp,
|
|
||||||
builder: (context, isFilterSystemApp, __) {
|
|
||||||
final tooltip = isFilterSystemApp
|
|
||||||
? appLocalizations.cancelFilterSystemApp
|
|
||||||
: appLocalizations.filterSystemApp;
|
|
||||||
return IconButton(
|
|
||||||
tooltip: tooltip,
|
|
||||||
onPressed: () {
|
|
||||||
final config = context.read<Config>();
|
|
||||||
config.accessControl = config.accessControl.copyWith(
|
|
||||||
isFilterSystemApp: !isFilterSystemApp,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
icon: isFilterSystemApp
|
|
||||||
? const Icon(Icons.filter_list_off)
|
|
||||||
: const Icon(Icons.filter_list),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildSearchButton(List<Package> packages) {
|
|
||||||
return IconButton(
|
return IconButton(
|
||||||
tooltip: appLocalizations.search,
|
tooltip: appLocalizations.search,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
showSearch(
|
showSearch(
|
||||||
context: context,
|
context: context,
|
||||||
delegate: AccessControlSearchDelegate(
|
delegate: AccessControlSearchDelegate(
|
||||||
packages: packages,
|
acceptList: acceptList,
|
||||||
|
rejectList: rejectList,
|
||||||
),
|
),
|
||||||
).then((_) => {setState(() {})});
|
).then((_) => setState(() {
|
||||||
|
_updateInitList();
|
||||||
|
}));
|
||||||
},
|
},
|
||||||
icon: const Icon(Icons.search),
|
icon: const Icon(Icons.search),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Widget _buildSelectedAllButton({
|
Widget _buildSelectedAllButton({
|
||||||
// required bool isAccessControl,
|
required bool isSelectedAll,
|
||||||
// required bool isSelectedAll,
|
required List<String> allValueList,
|
||||||
// required List<String> allValueList,
|
}) {
|
||||||
// }) {
|
final tooltip = isSelectedAll
|
||||||
// final tooltip = isSelectedAll
|
? appLocalizations.cancelSelectAll
|
||||||
// ? appLocalizations.cancelSelectAll
|
: appLocalizations.selectAll;
|
||||||
// : appLocalizations.selectAll;
|
return IconButton(
|
||||||
// return AbsorbPointer(
|
tooltip: tooltip,
|
||||||
// absorbing: !isAccessControl,
|
onPressed: () {
|
||||||
// child: FloatingActionButton(
|
final config = globalState.appController.config;
|
||||||
// tooltip: tooltip,
|
final isAccept =
|
||||||
// onPressed: () {
|
config.accessControl.mode == AccessControlMode.acceptSelected;
|
||||||
// final config = globalState.appController.config;
|
if (isSelectedAll) {
|
||||||
// final isAccept =
|
config.accessControl = switch (isAccept) {
|
||||||
// config.accessControl.mode == AccessControlMode.acceptSelected;
|
true => config.accessControl.copyWith(
|
||||||
//
|
acceptList: [],
|
||||||
// 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,
|
|
||||||
// ),
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
// child: isSelectedAll
|
|
||||||
// ? const Icon(Icons.deselect)
|
|
||||||
// : const Icon(Icons.select_all),
|
|
||||||
// ),
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
|
|
||||||
Widget _buildPackageList() {
|
|
||||||
return ValueListenableBuilder(
|
|
||||||
valueListenable: packagesListenable,
|
|
||||||
builder: (_, packages, ___) {
|
|
||||||
final accessControl = globalState.appController.config.accessControl;
|
|
||||||
final acceptList = accessControl.acceptList;
|
|
||||||
final rejectList = accessControl.rejectList;
|
|
||||||
final acceptPackages = packages.sorted((a, b) {
|
|
||||||
final isSelectA = acceptList.contains(a.packageName);
|
|
||||||
final isSelectB = acceptList.contains(b.packageName);
|
|
||||||
if (isSelectA && isSelectB) return 0;
|
|
||||||
if (isSelectA) return -1;
|
|
||||||
if (isSelectB) return 1;
|
|
||||||
return 0;
|
|
||||||
});
|
|
||||||
final rejectPackages = packages.sorted((a, b) {
|
|
||||||
final isSelectA = rejectList.contains(a.packageName);
|
|
||||||
final isSelectB = rejectList.contains(b.packageName);
|
|
||||||
if (isSelectA && isSelectB) return 0;
|
|
||||||
if (isSelectA) return -1;
|
|
||||||
if (isSelectB) return 1;
|
|
||||||
return 0;
|
|
||||||
});
|
|
||||||
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 isFilterSystemApp = accessControl.isFilterSystemApp;
|
|
||||||
final accessControlMode = accessControl.mode;
|
|
||||||
final packages =
|
|
||||||
accessControlMode == AccessControlMode.acceptSelected
|
|
||||||
? acceptPackages
|
|
||||||
: rejectPackages;
|
|
||||||
final currentList = accessControl.currentList;
|
|
||||||
final currentPackages = isFilterSystemApp
|
|
||||||
? packages
|
|
||||||
.where((element) => element.isSystem == false)
|
|
||||||
.toList()
|
|
||||||
: packages;
|
|
||||||
final packageNameList =
|
|
||||||
currentPackages.map((e) => e.packageName).toList();
|
|
||||||
final valueList = currentList.intersection(packageNameList);
|
|
||||||
final describe =
|
|
||||||
accessControlMode == AccessControlMode.acceptSelected
|
|
||||||
? appLocalizations.accessControlAllowDesc
|
|
||||||
: appLocalizations.accessControlNotAllowDesc;
|
|
||||||
return DisabledMask(
|
|
||||||
status: !isAccessControl,
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
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,
|
|
||||||
child: FadeBox(
|
|
||||||
key: const Key("fade_box"),
|
|
||||||
child: currentPackages.isEmpty
|
|
||||||
? const Center(
|
|
||||||
child: CircularProgressIndicator(),
|
|
||||||
)
|
|
||||||
: ListView.builder(
|
|
||||||
itemCount: currentPackages.length,
|
|
||||||
itemBuilder: (_, index) {
|
|
||||||
final package = currentPackages[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,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
|
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 _buildSettingButton() {
|
||||||
|
return IconButton(
|
||||||
|
onPressed: () {
|
||||||
|
showSheet(
|
||||||
|
title: appLocalizations.proxiesSetting,
|
||||||
|
context: context,
|
||||||
|
builder: (_) {
|
||||||
|
return AccessControlWidget(
|
||||||
|
context: context,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
icon: const Icon(Icons.tune),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -372,7 +148,170 @@ class _AccessFragmentState extends State<AccessFragment> {
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
child: _buildPackageList(),
|
child: Selector<AppState, List<Package>>(
|
||||||
|
selector: (_, appState) => appState.packages,
|
||||||
|
builder: (_, packages, ___) {
|
||||||
|
return Selector2<AppState, Config, PackageListSelectorState>(
|
||||||
|
selector: (_, appState, config) => PackageListSelectorState(
|
||||||
|
accessControl: config.accessControl,
|
||||||
|
isAccessControl: config.isAccessControl,
|
||||||
|
packages: appState.packages,
|
||||||
|
),
|
||||||
|
builder: (context, state, __) {
|
||||||
|
final accessControl = state.accessControl;
|
||||||
|
final isAccessControl = state.isAccessControl;
|
||||||
|
final accessControlMode = accessControl.mode;
|
||||||
|
final packages = state.getList(
|
||||||
|
accessControlMode == AccessControlMode.acceptSelected
|
||||||
|
? acceptList
|
||||||
|
: rejectList,
|
||||||
|
);
|
||||||
|
final currentList = accessControl.currentList;
|
||||||
|
final packageNameList =
|
||||||
|
packages.map((e) => e.packageName).toList();
|
||||||
|
final valueList = currentList.intersection(packageNameList);
|
||||||
|
final describe =
|
||||||
|
accessControlMode == AccessControlMode.acceptSelected
|
||||||
|
? appLocalizations.accessControlAllowDesc
|
||||||
|
: appLocalizations.accessControlNotAllowDesc;
|
||||||
|
return DisabledMask(
|
||||||
|
status: !isAccessControl,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
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(),
|
||||||
|
),
|
||||||
|
Flexible(
|
||||||
|
child: _buildSelectedAllButton(
|
||||||
|
isSelectedAll: valueList.length ==
|
||||||
|
packageNameList.length,
|
||||||
|
allValueList: packageNameList,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Flexible(
|
||||||
|
child: _buildSettingButton(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
flex: 1,
|
||||||
|
child: packages.isEmpty
|
||||||
|
? const Center(
|
||||||
|
child: CircularProgressIndicator(),
|
||||||
|
)
|
||||||
|
: 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,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -439,23 +378,14 @@ class PackageListItem extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class AccessControlSearchDelegate extends SearchDelegate {
|
class AccessControlSearchDelegate extends SearchDelegate {
|
||||||
final List<Package> packages;
|
List<String> acceptList = [];
|
||||||
|
List<String> rejectList = [];
|
||||||
|
|
||||||
AccessControlSearchDelegate({
|
AccessControlSearchDelegate({
|
||||||
required this.packages,
|
required this.acceptList,
|
||||||
|
required this.rejectList,
|
||||||
});
|
});
|
||||||
|
|
||||||
List<Package> get _results {
|
|
||||||
final lowQuery = query.toLowerCase();
|
|
||||||
return packages
|
|
||||||
.where(
|
|
||||||
(package) =>
|
|
||||||
package.label.toLowerCase().contains(lowQuery) ||
|
|
||||||
package.packageName.contains(lowQuery),
|
|
||||||
)
|
|
||||||
.toList();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Widget>? buildActions(BuildContext context) {
|
List<Widget>? buildActions(BuildContext context) {
|
||||||
return [
|
return [
|
||||||
@@ -485,26 +415,39 @@ class AccessControlSearchDelegate extends SearchDelegate {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _packageList(List<Package> packages) {
|
Widget _packageList() {
|
||||||
return Selector<Config, PackageListSelectorState>(
|
final lowQuery = query.toLowerCase();
|
||||||
selector: (_, config) => PackageListSelectorState(
|
return Selector2<AppState, Config, PackageListSelectorState>(
|
||||||
|
selector: (_, appState, config) => PackageListSelectorState(
|
||||||
|
packages: appState.packages,
|
||||||
accessControl: config.accessControl,
|
accessControl: config.accessControl,
|
||||||
isAccessControl: config.isAccessControl,
|
isAccessControl: config.isAccessControl,
|
||||||
),
|
),
|
||||||
builder: (context, state, __) {
|
builder: (context, state, __) {
|
||||||
final accessControl = state.accessControl;
|
final accessControl = state.accessControl;
|
||||||
final isAccessControl = state.isAccessControl;
|
|
||||||
final accessControlMode = accessControl.mode;
|
final accessControlMode = accessControl.mode;
|
||||||
|
final packages = state.getList(
|
||||||
|
accessControlMode == AccessControlMode.acceptSelected
|
||||||
|
? acceptList
|
||||||
|
: rejectList,
|
||||||
|
);
|
||||||
|
final queryPackages = packages
|
||||||
|
.where(
|
||||||
|
(package) =>
|
||||||
|
package.label.toLowerCase().contains(lowQuery) ||
|
||||||
|
package.packageName.contains(lowQuery),
|
||||||
|
)
|
||||||
|
.toList();
|
||||||
|
final isAccessControl = state.isAccessControl;
|
||||||
final currentList = accessControl.currentList;
|
final currentList = accessControl.currentList;
|
||||||
final packageNameList =
|
final packageNameList = packages.map((e) => e.packageName).toList();
|
||||||
this.packages.map((e) => e.packageName).toList();
|
|
||||||
final valueList = currentList.intersection(packageNameList);
|
final valueList = currentList.intersection(packageNameList);
|
||||||
return DisabledMask(
|
return DisabledMask(
|
||||||
status: !isAccessControl,
|
status: !isAccessControl,
|
||||||
child: ListView.builder(
|
child: ListView.builder(
|
||||||
itemCount: packages.length,
|
itemCount: queryPackages.length,
|
||||||
itemBuilder: (_, index) {
|
itemBuilder: (_, index) {
|
||||||
final package = packages[index];
|
final package = queryPackages[index];
|
||||||
return PackageListItem(
|
return PackageListItem(
|
||||||
key: Key(package.packageName),
|
key: Key(package.packageName),
|
||||||
package: package,
|
package: package,
|
||||||
@@ -542,6 +485,268 @@ class AccessControlSearchDelegate extends SearchDelegate {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget buildSuggestions(BuildContext context) {
|
Widget buildSuggestions(BuildContext context) {
|
||||||
return _packageList(_results);
|
return _packageList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class AccessControlWidget extends StatelessWidget {
|
||||||
|
final BuildContext context;
|
||||||
|
|
||||||
|
const AccessControlWidget({
|
||||||
|
super.key,
|
||||||
|
required this.context,
|
||||||
|
});
|
||||||
|
|
||||||
|
IconData _getIconWithAccessControlMode(AccessControlMode mode) {
|
||||||
|
return switch (mode) {
|
||||||
|
AccessControlMode.acceptSelected => Icons.adjust_outlined,
|
||||||
|
AccessControlMode.rejectSelected => Icons.block_outlined,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
String _getTextWithAccessControlMode(AccessControlMode mode) {
|
||||||
|
return switch (mode) {
|
||||||
|
AccessControlMode.acceptSelected => appLocalizations.whitelistMode,
|
||||||
|
AccessControlMode.rejectSelected => appLocalizations.blacklistMode,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
String _getTextWithAccessSortType(AccessSortType type) {
|
||||||
|
return switch (type) {
|
||||||
|
AccessSortType.none => appLocalizations.defaultText,
|
||||||
|
AccessSortType.name => appLocalizations.name,
|
||||||
|
AccessSortType.time => appLocalizations.time,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
IconData _getIconWithProxiesSortType(AccessSortType type) {
|
||||||
|
return switch (type) {
|
||||||
|
AccessSortType.none => Icons.sort,
|
||||||
|
AccessSortType.name => Icons.sort_by_alpha,
|
||||||
|
AccessSortType.time => Icons.timeline,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
String _getTextWithIsFilterSystemApp(bool isFilterSystemApp) {
|
||||||
|
return switch (isFilterSystemApp) {
|
||||||
|
true => appLocalizations.onlyOtherApps,
|
||||||
|
false => appLocalizations.allApps,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Widget> _buildModeSetting() {
|
||||||
|
return generateSection(
|
||||||
|
title: appLocalizations.mode,
|
||||||
|
items: [
|
||||||
|
SingleChildScrollView(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
child: Selector<Config, AccessControlMode>(
|
||||||
|
selector: (_, config) => config.accessControl.mode,
|
||||||
|
builder: (_, accessControlMode, __) {
|
||||||
|
return Wrap(
|
||||||
|
spacing: 16,
|
||||||
|
children: [
|
||||||
|
for (final item in AccessControlMode.values)
|
||||||
|
SettingInfoCard(
|
||||||
|
Info(
|
||||||
|
label: _getTextWithAccessControlMode(item),
|
||||||
|
iconData: _getIconWithAccessControlMode(item),
|
||||||
|
),
|
||||||
|
isSelected: accessControlMode == item,
|
||||||
|
onPressed: () {
|
||||||
|
final config = globalState.appController.config;
|
||||||
|
config.accessControl = config.accessControl.copyWith(
|
||||||
|
mode: item,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Widget> _buildSortSetting() {
|
||||||
|
return generateSection(
|
||||||
|
title: appLocalizations.sort,
|
||||||
|
items: [
|
||||||
|
SingleChildScrollView(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
child: Selector<Config, AccessSortType>(
|
||||||
|
selector: (_, config) => config.accessControl.sort,
|
||||||
|
builder: (_, accessSortType, __) {
|
||||||
|
return Wrap(
|
||||||
|
spacing: 16,
|
||||||
|
children: [
|
||||||
|
for (final item in AccessSortType.values)
|
||||||
|
SettingInfoCard(
|
||||||
|
Info(
|
||||||
|
label: _getTextWithAccessSortType(item),
|
||||||
|
iconData: _getIconWithProxiesSortType(item),
|
||||||
|
),
|
||||||
|
isSelected: accessSortType == item,
|
||||||
|
onPressed: () {
|
||||||
|
final config = globalState.appController.config;
|
||||||
|
config.accessControl = config.accessControl.copyWith(
|
||||||
|
sort: item,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Widget> _buildSourceSetting() {
|
||||||
|
return generateSection(
|
||||||
|
title: appLocalizations.source,
|
||||||
|
items: [
|
||||||
|
SingleChildScrollView(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
child: Selector<Config, bool>(
|
||||||
|
selector: (_, config) => config.accessControl.isFilterSystemApp,
|
||||||
|
builder: (_, isFilterSystemApp, __) {
|
||||||
|
return Wrap(
|
||||||
|
spacing: 16,
|
||||||
|
children: [
|
||||||
|
for (final item in [false, true])
|
||||||
|
SettingTextCard(
|
||||||
|
_getTextWithIsFilterSystemApp(item),
|
||||||
|
isSelected: isFilterSystemApp == item,
|
||||||
|
onPressed: () {
|
||||||
|
final config = globalState.appController.config;
|
||||||
|
config.accessControl = config.accessControl.copyWith(
|
||||||
|
isFilterSystemApp: item,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
_intelligentSelected() async {
|
||||||
|
final appState = globalState.appController.appState;
|
||||||
|
final config = globalState.appController.config;
|
||||||
|
final accessControl = config.accessControl;
|
||||||
|
final packageNames = appState.packages
|
||||||
|
.where(
|
||||||
|
(item) =>
|
||||||
|
accessControl.isFilterSystemApp ? item.isSystem == false : true,
|
||||||
|
)
|
||||||
|
.map((item) => item.packageName);
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
final commonScaffoldState = context.commonScaffoldState;
|
||||||
|
if (commonScaffoldState?.mounted != true) return;
|
||||||
|
final selectedPackageNames =
|
||||||
|
(await commonScaffoldState?.loadingRun<List<String>>(
|
||||||
|
() async {
|
||||||
|
return await app?.getChinaPackageNames() ?? [];
|
||||||
|
},
|
||||||
|
))
|
||||||
|
?.toSet() ??
|
||||||
|
{};
|
||||||
|
final acceptList = packageNames
|
||||||
|
.where((item) => !selectedPackageNames.contains(item))
|
||||||
|
.toList();
|
||||||
|
final rejectList = packageNames
|
||||||
|
.where((item) => selectedPackageNames.contains(item))
|
||||||
|
.toList();
|
||||||
|
config.accessControl = accessControl.copyWith(
|
||||||
|
acceptList: acceptList,
|
||||||
|
rejectList: rejectList,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
_copyToClipboard() async {
|
||||||
|
await globalState.safeRun(() {
|
||||||
|
final data = globalState.appController.config.accessControl.toJson();
|
||||||
|
Clipboard.setData(
|
||||||
|
ClipboardData(
|
||||||
|
text: json.encode(data),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
if (!context.mounted) return;
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
_pasteToClipboard() async {
|
||||||
|
await globalState.safeRun(() async {
|
||||||
|
final config = globalState.appController.config;
|
||||||
|
final data = await Clipboard.getData('text/plain');
|
||||||
|
final text = data?.text;
|
||||||
|
if (text == null) return;
|
||||||
|
config.accessControl = AccessControl.fromJson(
|
||||||
|
json.decode(text),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
if (!context.mounted) return;
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Widget> _buildActionSetting() {
|
||||||
|
return generateSection(
|
||||||
|
title: appLocalizations.action,
|
||||||
|
items: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 16,
|
||||||
|
),
|
||||||
|
child: Wrap(
|
||||||
|
runSpacing: 16,
|
||||||
|
spacing: 16,
|
||||||
|
children: [
|
||||||
|
CommonChip(
|
||||||
|
avatar: const Icon(Icons.auto_awesome),
|
||||||
|
label: appLocalizations.intelligentSelected,
|
||||||
|
onPressed: _intelligentSelected,
|
||||||
|
),
|
||||||
|
CommonChip(
|
||||||
|
avatar: const Icon(Icons.paste),
|
||||||
|
label: appLocalizations.clipboardImport,
|
||||||
|
onPressed: _pasteToClipboard,
|
||||||
|
),
|
||||||
|
CommonChip(
|
||||||
|
avatar: const Icon(Icons.content_copy),
|
||||||
|
label: appLocalizations.clipboardExport,
|
||||||
|
onPressed: _copyToClipboard,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.only(bottom: 32),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
..._buildModeSetting(),
|
||||||
|
..._buildSortSetting(),
|
||||||
|
..._buildSourceSetting(),
|
||||||
|
..._buildActionSetting(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ class ApplicationSettingFragment extends StatelessWidget {
|
|||||||
selector: (_, config) => config.autoRun,
|
selector: (_, config) => config.autoRun,
|
||||||
builder: (_, autoRun, child) {
|
builder: (_, autoRun, child) {
|
||||||
return ListItem.switchItem(
|
return ListItem.switchItem(
|
||||||
leading: const Icon(Icons.start),
|
leading: const Icon(Icons.not_started),
|
||||||
title: Text(appLocalizations.autoRun),
|
title: Text(appLocalizations.autoRun),
|
||||||
subtitle: Text(appLocalizations.autoRunDesc),
|
subtitle: Text(appLocalizations.autoRunDesc),
|
||||||
delegate: SwitchDelegate(
|
delegate: SwitchDelegate(
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:typed_data';
|
||||||
|
|
||||||
import 'package:fl_clash/common/common.dart';
|
import 'package:fl_clash/common/common.dart';
|
||||||
import 'package:fl_clash/common/dav_client.dart';
|
import 'package:fl_clash/common/dav_client.dart';
|
||||||
import 'package:fl_clash/enum/enum.dart';
|
import 'package:fl_clash/enum/enum.dart';
|
||||||
@@ -10,16 +12,9 @@ import 'package:fl_clash/widgets/text.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class BackupAndRecovery extends StatefulWidget {
|
class BackupAndRecovery extends StatelessWidget {
|
||||||
const BackupAndRecovery({super.key});
|
const BackupAndRecovery({super.key});
|
||||||
|
|
||||||
@override
|
|
||||||
State<BackupAndRecovery> createState() => _BackupAndRecoveryState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _BackupAndRecoveryState extends State<BackupAndRecovery> {
|
|
||||||
DAVClient? _client;
|
|
||||||
|
|
||||||
_showAddWebDAV(DAV? dav) async {
|
_showAddWebDAV(DAV? dav) async {
|
||||||
await globalState.showCommonDialog<String>(
|
await globalState.showCommonDialog<String>(
|
||||||
child: WebDAVFormDialog(
|
child: WebDAVFormDialog(
|
||||||
@@ -28,11 +23,15 @@ class _BackupAndRecoveryState extends State<BackupAndRecovery> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
_backup() async {
|
_backupOnWebDAV(BuildContext context, DAVClient client) async {
|
||||||
final commonScaffoldState = context.commonScaffoldState;
|
final commonScaffoldState = context.commonScaffoldState;
|
||||||
final res = await commonScaffoldState?.loadingRun<bool>(() async {
|
final res = await commonScaffoldState?.loadingRun<bool>(
|
||||||
return await _client?.backup();
|
() async {
|
||||||
});
|
final backupData = await globalState.appController.backupData();
|
||||||
|
return await client.backup(Uint8List.fromList(backupData));
|
||||||
|
},
|
||||||
|
title: appLocalizations.backup,
|
||||||
|
);
|
||||||
if (res != true) return;
|
if (res != true) return;
|
||||||
globalState.showMessage(
|
globalState.showMessage(
|
||||||
title: appLocalizations.backup,
|
title: appLocalizations.backup,
|
||||||
@@ -40,11 +39,20 @@ class _BackupAndRecoveryState extends State<BackupAndRecovery> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
_recovery(RecoveryOption recoveryOption) async {
|
_recoveryOnWebDAV(
|
||||||
|
BuildContext context,
|
||||||
|
DAVClient client,
|
||||||
|
RecoveryOption recoveryOption,
|
||||||
|
) async {
|
||||||
final commonScaffoldState = context.commonScaffoldState;
|
final commonScaffoldState = context.commonScaffoldState;
|
||||||
final res = await commonScaffoldState?.loadingRun<bool>(() async {
|
final res = await commonScaffoldState?.loadingRun<bool>(
|
||||||
return await _client?.recovery(recoveryOption: recoveryOption);
|
() async {
|
||||||
});
|
final data = await client.recovery();
|
||||||
|
await globalState.appController.recoveryData(data, recoveryOption);
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
title: appLocalizations.recovery,
|
||||||
|
);
|
||||||
if (res != true) return;
|
if (res != true) return;
|
||||||
globalState.showMessage(
|
globalState.showMessage(
|
||||||
title: appLocalizations.recovery,
|
title: appLocalizations.recovery,
|
||||||
@@ -52,12 +60,66 @@ class _BackupAndRecoveryState extends State<BackupAndRecovery> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
_handleRecovery() async {
|
_handleRecoveryOnWebDAV(BuildContext context, DAVClient client) async {
|
||||||
final recoveryOption = await globalState.showCommonDialog<RecoveryOption>(
|
final recoveryOption = await globalState.showCommonDialog<RecoveryOption>(
|
||||||
child: const RecoveryOptionsDialog(),
|
child: const RecoveryOptionsDialog(),
|
||||||
);
|
);
|
||||||
if (recoveryOption == null) return;
|
if (recoveryOption == null || !context.mounted) return;
|
||||||
_recovery(recoveryOption);
|
_recoveryOnWebDAV(context, client, recoveryOption);
|
||||||
|
}
|
||||||
|
|
||||||
|
_backupOnLocal(BuildContext context) async {
|
||||||
|
final commonScaffoldState = context.commonScaffoldState;
|
||||||
|
final res = await commonScaffoldState?.loadingRun<bool>(
|
||||||
|
() async {
|
||||||
|
final backupData = await globalState.appController.backupData();
|
||||||
|
final value = await picker.saveFile(
|
||||||
|
other.getBackupFileName(),
|
||||||
|
Uint8List.fromList(backupData),
|
||||||
|
);
|
||||||
|
if(value == null) return false;
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
title: appLocalizations.backup,
|
||||||
|
);
|
||||||
|
if (res != true) return;
|
||||||
|
globalState.showMessage(
|
||||||
|
title: appLocalizations.backup,
|
||||||
|
message: TextSpan(text: appLocalizations.backupSuccess),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
_recoveryOnLocal(
|
||||||
|
BuildContext context,
|
||||||
|
RecoveryOption recoveryOption,
|
||||||
|
) async {
|
||||||
|
final file = await picker.pickerFile();
|
||||||
|
final data = file?.bytes;
|
||||||
|
if (data == null || !context.mounted) return;
|
||||||
|
final commonScaffoldState = context.commonScaffoldState;
|
||||||
|
final res = await commonScaffoldState?.loadingRun<bool>(
|
||||||
|
() async {
|
||||||
|
await globalState.appController.recoveryData(
|
||||||
|
List<int>.from(data),
|
||||||
|
recoveryOption,
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
title: appLocalizations.recovery,
|
||||||
|
);
|
||||||
|
if (res != true) return;
|
||||||
|
globalState.showMessage(
|
||||||
|
title: appLocalizations.recovery,
|
||||||
|
message: TextSpan(text: appLocalizations.recoverySuccess),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
_handleRecoveryOnLocal(BuildContext context) async {
|
||||||
|
final recoveryOption = await globalState.showCommonDialog<RecoveryOption>(
|
||||||
|
child: const RecoveryOptionsDialog(),
|
||||||
|
);
|
||||||
|
if (recoveryOption == null || !context.mounted) return;
|
||||||
|
_recoveryOnLocal(context, recoveryOption);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -65,12 +127,11 @@ class _BackupAndRecoveryState extends State<BackupAndRecovery> {
|
|||||||
return Selector<Config, DAV?>(
|
return Selector<Config, DAV?>(
|
||||||
selector: (_, config) => config.dav,
|
selector: (_, config) => config.dav,
|
||||||
builder: (_, dav, __) {
|
builder: (_, dav, __) {
|
||||||
if (dav == null) {
|
final client = dav != null ? DAVClient(dav) : null;
|
||||||
return ListView(
|
return ListView(
|
||||||
children: [
|
children: [
|
||||||
ListHeader(
|
ListHeader(title: appLocalizations.remote),
|
||||||
title: appLocalizations.account,
|
if (dav == null)
|
||||||
),
|
|
||||||
ListItem(
|
ListItem(
|
||||||
leading: const Icon(Icons.account_box),
|
leading: const Icon(Icons.account_box),
|
||||||
title: Text(appLocalizations.noInfo),
|
title: Text(appLocalizations.noInfo),
|
||||||
@@ -83,95 +144,95 @@ class _BackupAndRecoveryState extends State<BackupAndRecovery> {
|
|||||||
appLocalizations.bind,
|
appLocalizations.bind,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
)
|
||||||
|
else ...[
|
||||||
|
ListItem(
|
||||||
|
leading: const Icon(Icons.account_box),
|
||||||
|
title: TooltipText(
|
||||||
|
text: Text(
|
||||||
|
dav.user,
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
subtitle: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||||
|
child: Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Text(appLocalizations.connectivity),
|
||||||
|
FutureBuilder<bool>(
|
||||||
|
future: client!.pingCompleter.future,
|
||||||
|
builder: (_, snapshot) {
|
||||||
|
return Center(
|
||||||
|
child: FadeBox(
|
||||||
|
child: snapshot.connectionState ==
|
||||||
|
ConnectionState.waiting
|
||||||
|
? const SizedBox(
|
||||||
|
width: 12,
|
||||||
|
height: 12,
|
||||||
|
child: CircularProgressIndicator(
|
||||||
|
strokeWidth: 1,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
color: snapshot.data == true
|
||||||
|
? Colors.green
|
||||||
|
: Colors.red,
|
||||||
|
),
|
||||||
|
width: 12,
|
||||||
|
height: 12,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
trailing: FilledButton.tonal(
|
||||||
|
onPressed: () {
|
||||||
|
_showAddWebDAV(dav);
|
||||||
|
},
|
||||||
|
child: Text(
|
||||||
|
appLocalizations.edit,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 4,
|
||||||
|
),
|
||||||
|
ListItem(
|
||||||
|
onTap: () {
|
||||||
|
_backupOnWebDAV(context, client);
|
||||||
|
},
|
||||||
|
title: Text(appLocalizations.backup),
|
||||||
|
subtitle: Text(appLocalizations.remoteBackupDesc),
|
||||||
|
),
|
||||||
|
ListItem(
|
||||||
|
onTap: () {
|
||||||
|
_handleRecoveryOnWebDAV(context, client);
|
||||||
|
},
|
||||||
|
title: Text(appLocalizations.recovery),
|
||||||
|
subtitle: Text(appLocalizations.remoteRecoveryDesc),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
ListHeader(title: appLocalizations.local),
|
||||||
}
|
|
||||||
_client = DAVClient(dav);
|
|
||||||
final pingFuture = _client!.pingCompleter.future;
|
|
||||||
return ListView(
|
|
||||||
children: [
|
|
||||||
ListHeader(title: appLocalizations.account),
|
|
||||||
ListItem(
|
ListItem(
|
||||||
leading: const Icon(Icons.account_box),
|
onTap: () {
|
||||||
title: TooltipText(
|
_backupOnLocal(context);
|
||||||
text: Text(
|
|
||||||
dav.user,
|
|
||||||
maxLines: 1,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
subtitle: Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(vertical: 4),
|
|
||||||
child: Row(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Text(appLocalizations.connectivity),
|
|
||||||
FutureBuilder<bool>(
|
|
||||||
future: pingFuture,
|
|
||||||
builder: (_, snapshot) {
|
|
||||||
return Center(
|
|
||||||
child: FadeBox(
|
|
||||||
key: const Key("fade_box_1"),
|
|
||||||
child: snapshot.connectionState == ConnectionState.waiting
|
|
||||||
? const SizedBox(
|
|
||||||
width: 12,
|
|
||||||
height: 12,
|
|
||||||
child: CircularProgressIndicator(
|
|
||||||
strokeWidth: 1,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: Container(
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
shape: BoxShape.circle,
|
|
||||||
color: snapshot.data == true
|
|
||||||
? Colors.green
|
|
||||||
: Colors.red,
|
|
||||||
),
|
|
||||||
width: 12,
|
|
||||||
height: 12,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
trailing: FilledButton.tonal(
|
|
||||||
onPressed: () {
|
|
||||||
_showAddWebDAV(dav);
|
|
||||||
},
|
|
||||||
child: Text(
|
|
||||||
appLocalizations.edit,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
FutureBuilder<bool>(
|
|
||||||
future: pingFuture,
|
|
||||||
builder: (_, snapshot) {
|
|
||||||
return FadeBox(
|
|
||||||
key: const Key("fade_box_2"),
|
|
||||||
child: snapshot.data == true
|
|
||||||
? Column(
|
|
||||||
children: [
|
|
||||||
ListHeader(
|
|
||||||
title: appLocalizations.backupAndRecovery),
|
|
||||||
ListItem(
|
|
||||||
onTap: _backup,
|
|
||||||
title: Text(appLocalizations.backup),
|
|
||||||
subtitle: Text(appLocalizations.backupDesc),
|
|
||||||
),
|
|
||||||
ListItem(
|
|
||||||
onTap: _handleRecovery,
|
|
||||||
title: Text(appLocalizations.recovery),
|
|
||||||
subtitle: Text(appLocalizations.recoveryDesc),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
: Container(),
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
|
title: Text(appLocalizations.backup),
|
||||||
|
subtitle: Text(appLocalizations.localBackupDesc),
|
||||||
|
),
|
||||||
|
ListItem(
|
||||||
|
onTap: () {
|
||||||
|
_handleRecoveryOnLocal(context);
|
||||||
|
},
|
||||||
|
title: Text(appLocalizations.recovery),
|
||||||
|
subtitle: Text(appLocalizations.localRecoveryDesc),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
@@ -180,6 +241,50 @@ class _BackupAndRecoveryState extends State<BackupAndRecovery> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class RecoveryOptionsDialog extends StatefulWidget {
|
||||||
|
const RecoveryOptionsDialog({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<RecoveryOptionsDialog> createState() => _RecoveryOptionsDialogState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _RecoveryOptionsDialogState extends State<RecoveryOptionsDialog> {
|
||||||
|
_handleOnTab(RecoveryOption? value) {
|
||||||
|
if (value == null) return;
|
||||||
|
Navigator.of(context).pop(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return AlertDialog(
|
||||||
|
title: Text(appLocalizations.recovery),
|
||||||
|
contentPadding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 8,
|
||||||
|
vertical: 16,
|
||||||
|
),
|
||||||
|
content: SizedBox(
|
||||||
|
width: 250,
|
||||||
|
child: Wrap(
|
||||||
|
children: [
|
||||||
|
ListItem(
|
||||||
|
onTap: () {
|
||||||
|
_handleOnTab(RecoveryOption.onlyProfiles);
|
||||||
|
},
|
||||||
|
title: Text(appLocalizations.recoveryProfiles),
|
||||||
|
),
|
||||||
|
ListItem(
|
||||||
|
onTap: () {
|
||||||
|
_handleOnTab(RecoveryOption.all);
|
||||||
|
},
|
||||||
|
title: Text(appLocalizations.recoveryAll),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class WebDAVFormDialog extends StatefulWidget {
|
class WebDAVFormDialog extends StatefulWidget {
|
||||||
final DAV? dav;
|
final DAV? dav;
|
||||||
|
|
||||||
@@ -238,7 +343,7 @@ class _WebDAVFormDialogState extends State<WebDAVFormDialog> {
|
|||||||
children: [
|
children: [
|
||||||
TextFormField(
|
TextFormField(
|
||||||
controller: uriController,
|
controller: uriController,
|
||||||
maxLines: 2,
|
maxLines: 5,
|
||||||
minLines: 1,
|
minLines: 1,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
prefixIcon: const Icon(Icons.link),
|
prefixIcon: const Icon(Icons.link),
|
||||||
@@ -313,47 +418,3 @@ class _WebDAVFormDialogState extends State<WebDAVFormDialog> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class RecoveryOptionsDialog extends StatefulWidget {
|
|
||||||
const RecoveryOptionsDialog({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<RecoveryOptionsDialog> createState() => _RecoveryOptionsDialogState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _RecoveryOptionsDialogState extends State<RecoveryOptionsDialog> {
|
|
||||||
_handleOnTab(RecoveryOption? value) {
|
|
||||||
if (value == null) return;
|
|
||||||
Navigator.of(context).pop(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return AlertDialog(
|
|
||||||
title: Text(appLocalizations.recovery),
|
|
||||||
contentPadding: const EdgeInsets.symmetric(
|
|
||||||
horizontal: 8,
|
|
||||||
vertical: 16,
|
|
||||||
),
|
|
||||||
content: SizedBox(
|
|
||||||
width: 250,
|
|
||||||
child: Wrap(
|
|
||||||
children: [
|
|
||||||
ListItem(
|
|
||||||
onTap: () {
|
|
||||||
_handleOnTab(RecoveryOption.onlyProfiles);
|
|
||||||
},
|
|
||||||
title: Text(appLocalizations.recoveryProfiles),
|
|
||||||
),
|
|
||||||
ListItem(
|
|
||||||
onTap: () {
|
|
||||||
_handleOnTab(RecoveryOption.all);
|
|
||||||
},
|
|
||||||
title: Text(appLocalizations.recoveryAll),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ class _ConfigFragmentState extends State<ConfigFragment> {
|
|||||||
final mixedPort = int.parse(port);
|
final mixedPort = int.parse(port);
|
||||||
if (mixedPort < 1024 || mixedPort > 49151) throw "Invalid port";
|
if (mixedPort < 1024 || mixedPort > 49151) throw "Invalid port";
|
||||||
globalState.appController.clashConfig.mixedPort = mixedPort;
|
globalState.appController.clashConfig.mixedPort = mixedPort;
|
||||||
globalState.appController.updateClashConfigDebounce();
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
globalState.showMessage(
|
globalState.showMessage(
|
||||||
title: appLocalizations.proxyPort,
|
title: appLocalizations.proxyPort,
|
||||||
@@ -62,7 +61,6 @@ class _ConfigFragmentState extends State<ConfigFragment> {
|
|||||||
}
|
}
|
||||||
final appController = globalState.appController;
|
final appController = globalState.appController;
|
||||||
appController.clashConfig.logLevel = value;
|
appController.clashConfig.logLevel = value;
|
||||||
appController.updateClashConfigDebounce();
|
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@@ -100,7 +98,6 @@ class _ConfigFragmentState extends State<ConfigFragment> {
|
|||||||
onChanged: (String? value) {
|
onChanged: (String? value) {
|
||||||
final appController = globalState.appController;
|
final appController = globalState.appController;
|
||||||
appController.clashConfig.globalRealUa = value;
|
appController.clashConfig.globalRealUa = value;
|
||||||
appController.updateClashConfigDebounce();
|
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@@ -125,6 +122,34 @@ class _ConfigFragmentState extends State<ConfigFragment> {
|
|||||||
throw "Invalid url";
|
throw "Invalid url";
|
||||||
}
|
}
|
||||||
globalState.appController.config.testUrl = newTestUrl;
|
globalState.appController.config.testUrl = newTestUrl;
|
||||||
|
} catch (e) {
|
||||||
|
globalState.showMessage(
|
||||||
|
title: appLocalizations.testUrl,
|
||||||
|
message: TextSpan(
|
||||||
|
text: e.toString(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_updateKeepAliveInterval(int keepAliveInterval) async {
|
||||||
|
final newKeepAliveIntervalString =
|
||||||
|
await globalState.showCommonDialog<String>(
|
||||||
|
child: KeepAliveIntervalFormDialog(
|
||||||
|
keepAliveInterval: keepAliveInterval,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
if (newKeepAliveIntervalString != null &&
|
||||||
|
newKeepAliveIntervalString != "$keepAliveInterval" &&
|
||||||
|
mounted) {
|
||||||
|
try {
|
||||||
|
final newKeepAliveInterval = int.parse(newKeepAliveIntervalString);
|
||||||
|
if (newKeepAliveInterval <= 0) {
|
||||||
|
throw "Invalid keepAliveInterval";
|
||||||
|
}
|
||||||
|
globalState.appController.clashConfig.keepAliveInterval =
|
||||||
|
newKeepAliveInterval;
|
||||||
globalState.appController.updateClashConfigDebounce();
|
globalState.appController.updateClashConfigDebounce();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
globalState.showMessage(
|
globalState.showMessage(
|
||||||
@@ -141,9 +166,9 @@ class _ConfigFragmentState extends State<ConfigFragment> {
|
|||||||
return generateSection(
|
return generateSection(
|
||||||
title: appLocalizations.app,
|
title: appLocalizations.app,
|
||||||
items: [
|
items: [
|
||||||
if (Platform.isAndroid)...[
|
if (Platform.isAndroid) ...[
|
||||||
Selector<Config, bool>(
|
Selector<Config, bool>(
|
||||||
selector: (_, config) => config.allowBypass,
|
selector: (_, config) => config.vpnProps.allowBypass,
|
||||||
builder: (_, allowBypass, __) {
|
builder: (_, allowBypass, __) {
|
||||||
return ListItem.switchItem(
|
return ListItem.switchItem(
|
||||||
leading: const Icon(Icons.arrow_forward_outlined),
|
leading: const Icon(Icons.arrow_forward_outlined),
|
||||||
@@ -152,15 +177,18 @@ class _ConfigFragmentState extends State<ConfigFragment> {
|
|||||||
delegate: SwitchDelegate(
|
delegate: SwitchDelegate(
|
||||||
value: allowBypass,
|
value: allowBypass,
|
||||||
onChanged: (bool value) async {
|
onChanged: (bool value) async {
|
||||||
final appController = globalState.appController;
|
final config = globalState.appController.config;
|
||||||
appController.config.allowBypass = value;
|
final vpnProps = config.vpnProps;
|
||||||
|
config.vpnProps = vpnProps.copyWith(
|
||||||
|
allowBypass: value,
|
||||||
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
Selector<Config, bool>(
|
Selector<Config, bool>(
|
||||||
selector: (_, config) => config.systemProxy,
|
selector: (_, config) => config.vpnProps.systemProxy,
|
||||||
builder: (_, systemProxy, __) {
|
builder: (_, systemProxy, __) {
|
||||||
return ListItem.switchItem(
|
return ListItem.switchItem(
|
||||||
leading: const Icon(Icons.settings_ethernet),
|
leading: const Icon(Icons.settings_ethernet),
|
||||||
@@ -169,8 +197,11 @@ class _ConfigFragmentState extends State<ConfigFragment> {
|
|||||||
delegate: SwitchDelegate(
|
delegate: SwitchDelegate(
|
||||||
value: systemProxy,
|
value: systemProxy,
|
||||||
onChanged: (bool value) async {
|
onChanged: (bool value) async {
|
||||||
final appController = globalState.appController;
|
final config = globalState.appController.config;
|
||||||
appController.config.systemProxy = value;
|
final vpnProps = config.vpnProps;
|
||||||
|
config.vpnProps = vpnProps.copyWith(
|
||||||
|
systemProxy: value,
|
||||||
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -263,6 +294,19 @@ class _ConfigFragmentState extends State<ConfigFragment> {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
Selector<ClashConfig, int>(
|
||||||
|
selector: (_, config) => config.keepAliveInterval,
|
||||||
|
builder: (_, value, __) {
|
||||||
|
return ListItem(
|
||||||
|
leading: const Icon(Icons.timer_outlined),
|
||||||
|
title: Text(appLocalizations.keepAliveIntervalDesc),
|
||||||
|
subtitle: Text("$value ${appLocalizations.seconds}"),
|
||||||
|
onTap: () {
|
||||||
|
_updateKeepAliveInterval(value);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
Selector<Config, String>(
|
Selector<Config, String>(
|
||||||
selector: (_, config) => config.testUrl,
|
selector: (_, config) => config.testUrl,
|
||||||
builder: (_, value, __) {
|
builder: (_, value, __) {
|
||||||
@@ -309,7 +353,6 @@ class _ConfigFragmentState extends State<ConfigFragment> {
|
|||||||
onChanged: (bool value) async {
|
onChanged: (bool value) async {
|
||||||
final appController = globalState.appController;
|
final appController = globalState.appController;
|
||||||
appController.clashConfig.ipv6 = value;
|
appController.clashConfig.ipv6 = value;
|
||||||
appController.updateClashConfigDebounce();
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -327,7 +370,6 @@ class _ConfigFragmentState extends State<ConfigFragment> {
|
|||||||
onChanged: (bool value) async {
|
onChanged: (bool value) async {
|
||||||
final clashConfig = context.read<ClashConfig>();
|
final clashConfig = context.read<ClashConfig>();
|
||||||
clashConfig.allowLan = value;
|
clashConfig.allowLan = value;
|
||||||
globalState.appController.updateClashConfigDebounce();
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -345,7 +387,6 @@ class _ConfigFragmentState extends State<ConfigFragment> {
|
|||||||
onChanged: (bool value) async {
|
onChanged: (bool value) async {
|
||||||
final appController = globalState.appController;
|
final appController = globalState.appController;
|
||||||
appController.clashConfig.unifiedDelay = value;
|
appController.clashConfig.unifiedDelay = value;
|
||||||
appController.updateClashConfigDebounce();
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -365,7 +406,6 @@ class _ConfigFragmentState extends State<ConfigFragment> {
|
|||||||
final appController = globalState.appController;
|
final appController = globalState.appController;
|
||||||
appController.clashConfig.findProcessMode =
|
appController.clashConfig.findProcessMode =
|
||||||
value ? FindProcessMode.always : FindProcessMode.off;
|
value ? FindProcessMode.always : FindProcessMode.off;
|
||||||
appController.updateClashConfigDebounce();
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -383,7 +423,6 @@ class _ConfigFragmentState extends State<ConfigFragment> {
|
|||||||
onChanged: (bool value) async {
|
onChanged: (bool value) async {
|
||||||
final appController = globalState.appController;
|
final appController = globalState.appController;
|
||||||
appController.clashConfig.tcpConcurrent = value;
|
appController.clashConfig.tcpConcurrent = value;
|
||||||
appController.updateClashConfigDebounce();
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -404,7 +443,6 @@ class _ConfigFragmentState extends State<ConfigFragment> {
|
|||||||
appController.clashConfig.geodataLoader = value
|
appController.clashConfig.geodataLoader = value
|
||||||
? geodataLoaderMemconservative
|
? geodataLoaderMemconservative
|
||||||
: geodataLoaderStandard;
|
: geodataLoaderStandard;
|
||||||
appController.updateClashConfigDebounce();
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -424,7 +462,6 @@ class _ConfigFragmentState extends State<ConfigFragment> {
|
|||||||
final appController = globalState.appController;
|
final appController = globalState.appController;
|
||||||
appController.clashConfig.externalController =
|
appController.clashConfig.externalController =
|
||||||
value ? defaultExternalController : '';
|
value ? defaultExternalController : '';
|
||||||
appController.updateClashConfigDebounce();
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -451,7 +488,6 @@ class _ConfigFragmentState extends State<ConfigFragment> {
|
|||||||
onChanged: (bool value) async {
|
onChanged: (bool value) async {
|
||||||
final clashConfig = context.read<ClashConfig>();
|
final clashConfig = context.read<ClashConfig>();
|
||||||
clashConfig.tun = Tun(enable: value);
|
clashConfig.tun = Tun(enable: value);
|
||||||
globalState.appController.updateClashConfigDebounce();
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -589,3 +625,65 @@ class _TestUrlFormDialogState extends State<TestUrlFormDialog> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class KeepAliveIntervalFormDialog extends StatefulWidget {
|
||||||
|
final int keepAliveInterval;
|
||||||
|
|
||||||
|
const KeepAliveIntervalFormDialog({
|
||||||
|
super.key,
|
||||||
|
required this.keepAliveInterval,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<KeepAliveIntervalFormDialog> createState() =>
|
||||||
|
_KeepAliveIntervalFormDialogState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _KeepAliveIntervalFormDialogState
|
||||||
|
extends State<KeepAliveIntervalFormDialog> {
|
||||||
|
late TextEditingController keepAliveIntervalController;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
keepAliveIntervalController = TextEditingController(
|
||||||
|
text: "${widget.keepAliveInterval}",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
_handleUpdate() async {
|
||||||
|
final keepAliveInterval = keepAliveIntervalController.value.text;
|
||||||
|
if (keepAliveInterval.isEmpty) return;
|
||||||
|
Navigator.of(context).pop<String>(keepAliveInterval);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return AlertDialog(
|
||||||
|
title: Text(appLocalizations.keepAliveIntervalDesc),
|
||||||
|
content: SizedBox(
|
||||||
|
width: 300,
|
||||||
|
child: Wrap(
|
||||||
|
runSpacing: 16,
|
||||||
|
children: [
|
||||||
|
TextField(
|
||||||
|
maxLines: 1,
|
||||||
|
minLines: 1,
|
||||||
|
controller: keepAliveIntervalController,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
border: const OutlineInputBorder(),
|
||||||
|
suffixText: appLocalizations.seconds,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: _handleUpdate,
|
||||||
|
child: Text(appLocalizations.submit),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
|
import 'dart:io';
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
|
import 'package:fl_clash/common/common.dart';
|
||||||
import 'package:fl_clash/fragments/dashboard/intranet_ip.dart';
|
import 'package:fl_clash/fragments/dashboard/intranet_ip.dart';
|
||||||
|
import 'package:fl_clash/fragments/dashboard/status_switch.dart';
|
||||||
import 'package:fl_clash/models/models.dart';
|
import 'package:fl_clash/models/models.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:fl_clash/widgets/widgets.dart';
|
import 'package:fl_clash/widgets/widgets.dart';
|
||||||
@@ -28,34 +31,51 @@ class _DashboardFragmentState extends State<DashboardFragment> {
|
|||||||
child: Align(
|
child: Align(
|
||||||
alignment: Alignment.topCenter,
|
alignment: Alignment.topCenter,
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16).copyWith(
|
||||||
|
bottom: 88,
|
||||||
|
),
|
||||||
child: Selector<AppState, double>(
|
child: Selector<AppState, double>(
|
||||||
selector: (_, appState) => appState.viewWidth,
|
selector: (_, appState) => appState.viewWidth,
|
||||||
builder: (_, viewWidth, ___) {
|
builder: (_, viewWidth, ___) {
|
||||||
// final viewMode = other.getViewMode(viewWidth);
|
final columns = max(4 * ((viewWidth / 350).ceil()), 8);
|
||||||
// final isDesktop = viewMode == ViewMode.desktop;
|
final int switchCount = (4 / columns) * viewWidth < 200 ? 8 : 4;
|
||||||
return Grid(
|
return Grid(
|
||||||
crossAxisCount: max(4 * ((viewWidth / 350).ceil()), 8),
|
crossAxisCount: columns,
|
||||||
crossAxisSpacing: 16,
|
crossAxisSpacing: 16,
|
||||||
mainAxisSpacing: 16,
|
mainAxisSpacing: 16,
|
||||||
children: const [
|
children: [
|
||||||
GridItem(
|
const GridItem(
|
||||||
crossAxisCellCount: 8,
|
crossAxisCellCount: 8,
|
||||||
child: NetworkSpeed(),
|
child: NetworkSpeed(),
|
||||||
),
|
),
|
||||||
GridItem(
|
if (Platform.isAndroid)
|
||||||
|
GridItem(
|
||||||
|
crossAxisCellCount: switchCount,
|
||||||
|
child: const VPNSwitch(),
|
||||||
|
),
|
||||||
|
if (system.isDesktop) ...[
|
||||||
|
GridItem(
|
||||||
|
crossAxisCellCount: switchCount,
|
||||||
|
child: const TUNSwitch(),
|
||||||
|
),
|
||||||
|
GridItem(
|
||||||
|
crossAxisCellCount: switchCount,
|
||||||
|
child: const ProxySwitch(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
const GridItem(
|
||||||
crossAxisCellCount: 4,
|
crossAxisCellCount: 4,
|
||||||
child: OutboundMode(),
|
child: OutboundMode(),
|
||||||
),
|
),
|
||||||
GridItem(
|
const GridItem(
|
||||||
crossAxisCellCount: 4,
|
crossAxisCellCount: 4,
|
||||||
child: NetworkDetection(),
|
child: NetworkDetection(),
|
||||||
),
|
),
|
||||||
GridItem(
|
const GridItem(
|
||||||
crossAxisCellCount: 4,
|
crossAxisCellCount: 4,
|
||||||
child: TrafficUsage(),
|
child: TrafficUsage(),
|
||||||
),
|
),
|
||||||
GridItem(
|
const GridItem(
|
||||||
crossAxisCellCount: 4,
|
crossAxisCellCount: 4,
|
||||||
child: IntranetIP(),
|
child: IntranetIP(),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import 'package:country_flags/country_flags.dart';
|
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
import 'package:fl_clash/common/common.dart';
|
import 'package:fl_clash/common/common.dart';
|
||||||
import 'package:fl_clash/models/models.dart';
|
import 'package:fl_clash/models/models.dart';
|
||||||
@@ -15,28 +14,41 @@ class NetworkDetection extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _NetworkDetectionState extends State<NetworkDetection> {
|
class _NetworkDetectionState extends State<NetworkDetection> {
|
||||||
final ipInfoNotifier = ValueNotifier<IpInfo?>(null);
|
final networkDetectionState = ValueNotifier<NetworkDetectionState>(
|
||||||
final timeoutNotifier = ValueNotifier<bool>(false);
|
const NetworkDetectionState(
|
||||||
|
isTesting: true,
|
||||||
|
ipInfo: null,
|
||||||
|
),
|
||||||
|
);
|
||||||
bool? _preIsStart;
|
bool? _preIsStart;
|
||||||
Function? _checkIpDebounce;
|
Function? _checkIpDebounce;
|
||||||
|
CancelToken? cancelToken;
|
||||||
|
|
||||||
_checkIp() async {
|
_checkIp() async {
|
||||||
final appState = globalState.appController.appState;
|
final appState = globalState.appController.appState;
|
||||||
final isInit = appState.isInit;
|
final isInit = appState.isInit;
|
||||||
final isStart = appState.isStart;
|
|
||||||
if (!isInit) return;
|
if (!isInit) return;
|
||||||
timeoutNotifier.value = false;
|
final isStart = appState.isStart;
|
||||||
if (_preIsStart == false && _preIsStart == isStart) return;
|
if (_preIsStart == false && _preIsStart == isStart) return;
|
||||||
|
networkDetectionState.value = networkDetectionState.value.copyWith(
|
||||||
|
isTesting: true,
|
||||||
|
ipInfo: null,
|
||||||
|
);
|
||||||
_preIsStart = isStart;
|
_preIsStart = isStart;
|
||||||
ipInfoNotifier.value = null;
|
if (cancelToken != null) {
|
||||||
final ipInfo = await request.checkIp();
|
cancelToken!.cancel();
|
||||||
if (ipInfo == null) {
|
cancelToken = null;
|
||||||
timeoutNotifier.value = true;
|
}
|
||||||
return;
|
cancelToken = CancelToken();
|
||||||
} else {
|
try {
|
||||||
timeoutNotifier.value = false;
|
final ipInfo = await request.checkIp(cancelToken: cancelToken);
|
||||||
|
networkDetectionState.value = networkDetectionState.value.copyWith(
|
||||||
|
isTesting: false,
|
||||||
|
ipInfo: ipInfo,
|
||||||
|
);
|
||||||
|
} catch (_) {
|
||||||
|
|
||||||
}
|
}
|
||||||
ipInfoNotifier.value = ipInfo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_checkIpContainer(Widget child) {
|
_checkIpContainer(Widget child) {
|
||||||
@@ -57,17 +69,28 @@ class _NetworkDetectionState extends State<NetworkDetection> {
|
|||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
super.dispose();
|
super.dispose();
|
||||||
ipInfoNotifier.dispose();
|
networkDetectionState.dispose();
|
||||||
timeoutNotifier.dispose();
|
}
|
||||||
|
|
||||||
|
String countryCodeToEmoji(String countryCode) {
|
||||||
|
final String code = countryCode.toUpperCase();
|
||||||
|
if (code.length != 2) {
|
||||||
|
return countryCode;
|
||||||
|
}
|
||||||
|
final int firstLetter = code.codeUnitAt(0) - 0x41 + 0x1F1E6;
|
||||||
|
final int secondLetter = code.codeUnitAt(1) - 0x41 + 0x1F1E6;
|
||||||
|
return String.fromCharCode(firstLetter) + String.fromCharCode(secondLetter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
_checkIpDebounce = debounce(_checkIp);
|
_checkIpDebounce ??= debounce(_checkIp);
|
||||||
return _checkIpContainer(
|
return _checkIpContainer(
|
||||||
ValueListenableBuilder<IpInfo?>(
|
ValueListenableBuilder<NetworkDetectionState>(
|
||||||
valueListenable: ipInfoNotifier,
|
valueListenable: networkDetectionState,
|
||||||
builder: (_, ipInfo, __) {
|
builder: (_, state, __) {
|
||||||
|
final ipInfo = state.ipInfo;
|
||||||
|
final isTesting = state.isTesting;
|
||||||
return CommonCard(
|
return CommonCard(
|
||||||
onPressed: () {},
|
onPressed: () {},
|
||||||
child: Column(
|
child: Column(
|
||||||
@@ -88,37 +111,38 @@ class _NetworkDetectionState extends State<NetworkDetection> {
|
|||||||
Flexible(
|
Flexible(
|
||||||
flex: 1,
|
flex: 1,
|
||||||
child: FadeBox(
|
child: FadeBox(
|
||||||
child: ipInfo != null
|
child: isTesting
|
||||||
? CountryFlag.fromCountryCode(
|
? Text(
|
||||||
ipInfo.countryCode,
|
appLocalizations.checking,
|
||||||
width: 24,
|
maxLines: 1,
|
||||||
height: 24,
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style:
|
||||||
|
Theme.of(context).textTheme.titleMedium,
|
||||||
)
|
)
|
||||||
: ValueListenableBuilder(
|
: ipInfo != null
|
||||||
valueListenable: timeoutNotifier,
|
? Container(
|
||||||
builder: (_, timeout, __) {
|
alignment: Alignment.centerLeft,
|
||||||
if (timeout) {
|
height: globalState.appController
|
||||||
return Text(
|
.measure.titleMediumHeight,
|
||||||
appLocalizations.checkError,
|
child: Text(
|
||||||
|
countryCodeToEmoji(
|
||||||
|
ipInfo.countryCode),
|
||||||
style: Theme.of(context)
|
style: Theme.of(context)
|
||||||
.textTheme
|
.textTheme
|
||||||
.titleMedium,
|
.titleLarge
|
||||||
maxLines: 1,
|
?.copyWith(
|
||||||
overflow: TextOverflow.ellipsis,
|
fontFamily: "Twemoji",
|
||||||
);
|
),
|
||||||
}
|
|
||||||
return TooltipText(
|
|
||||||
text: Text(
|
|
||||||
appLocalizations.checking,
|
|
||||||
maxLines: 1,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: Theme.of(context)
|
|
||||||
.textTheme
|
|
||||||
.titleMedium,
|
|
||||||
),
|
),
|
||||||
);
|
)
|
||||||
},
|
: Text(
|
||||||
),
|
appLocalizations.checkError,
|
||||||
|
style: Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.titleMedium,
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -151,28 +175,24 @@ class _NetworkDetectionState extends State<NetworkDetection> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
: ValueListenableBuilder(
|
: FadeBox(
|
||||||
valueListenable: timeoutNotifier,
|
child: isTesting == false && ipInfo == null
|
||||||
builder: (_, timeout, __) {
|
? Text(
|
||||||
if (timeout) {
|
"timeout",
|
||||||
return Text(
|
style: context.textTheme.titleLarge
|
||||||
"timeout",
|
?.copyWith(color: Colors.red)
|
||||||
style: context.textTheme.titleLarge
|
.toSoftBold
|
||||||
?.copyWith(color: Colors.red)
|
.toMinus,
|
||||||
.toSoftBold
|
maxLines: 1,
|
||||||
.toMinus,
|
overflow: TextOverflow.ellipsis,
|
||||||
maxLines: 1,
|
)
|
||||||
overflow: TextOverflow.ellipsis,
|
: Container(
|
||||||
);
|
padding: const EdgeInsets.all(2),
|
||||||
}
|
child: const AspectRatio(
|
||||||
return Container(
|
aspectRatio: 1,
|
||||||
padding: const EdgeInsets.all(2),
|
child: CircularProgressIndicator(),
|
||||||
child: const AspectRatio(
|
),
|
||||||
aspectRatio: 1,
|
),
|
||||||
child: CircularProgressIndicator(),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ class _NetworkSpeedState extends State<NetworkSpeed> {
|
|||||||
onPressed: () {},
|
onPressed: () {},
|
||||||
info: Info(
|
info: Info(
|
||||||
label: appLocalizations.networkSpeed,
|
label: appLocalizations.networkSpeed,
|
||||||
iconData: Icons.speed,
|
iconData: Icons.speed_sharp,
|
||||||
),
|
),
|
||||||
child: Selector<AppState, List<Traffic>>(
|
child: Selector<AppState, List<Traffic>>(
|
||||||
selector: (_, appState) => appState.traffics,
|
selector: (_, appState) => appState.traffics,
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ class OutboundMode extends StatelessWidget {
|
|||||||
final clashConfig = appController.clashConfig;
|
final clashConfig = appController.clashConfig;
|
||||||
if (value == null || clashConfig.mode == value) return;
|
if (value == null || clashConfig.mode == value) return;
|
||||||
clashConfig.mode = value;
|
clashConfig.mode = value;
|
||||||
await appController.updateClashConfig();
|
|
||||||
appController.addCheckIpNumDebounce();
|
appController.addCheckIpNumDebounce();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,7 +27,7 @@ class OutboundMode extends StatelessWidget {
|
|||||||
onPressed: () {},
|
onPressed: () {},
|
||||||
info: Info(
|
info: Info(
|
||||||
label: appLocalizations.outboundMode,
|
label: appLocalizations.outboundMode,
|
||||||
iconData: Icons.call_split,
|
iconData: Icons.call_split_sharp,
|
||||||
),
|
),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.only(bottom: 16),
|
padding: const EdgeInsets.only(bottom: 16),
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class _StartButtonState extends State<StartButton>
|
|||||||
if (isStart == appController.appState.isStart) {
|
if (isStart == appController.appState.isStart) {
|
||||||
isStart = !isStart;
|
isStart = !isStart;
|
||||||
updateController();
|
updateController();
|
||||||
appController.updateSystemProxy(isStart);
|
appController.updateStatus(isStart);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ class _StartButtonState extends State<StartButton>
|
|||||||
return Selector<AppState, bool>(
|
return Selector<AppState, bool>(
|
||||||
selector: (_, appState) => appState.isStart,
|
selector: (_, appState) => appState.isStart,
|
||||||
builder: (_, isStart, child) {
|
builder: (_, isStart, child) {
|
||||||
if(isStart != this.isStart){
|
if (isStart != this.isStart) {
|
||||||
this.isStart = isStart;
|
this.isStart = isStart;
|
||||||
updateController();
|
updateController();
|
||||||
}
|
}
|
||||||
|
|||||||
121
lib/fragments/dashboard/status_switch.dart
Normal file
121
lib/fragments/dashboard/status_switch.dart
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
import 'package:fl_clash/common/app_localizations.dart';
|
||||||
|
import 'package:fl_clash/models/models.dart';
|
||||||
|
import 'package:fl_clash/state.dart';
|
||||||
|
import 'package:fl_clash/widgets/widgets.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
class VPNSwitch extends StatelessWidget {
|
||||||
|
const VPNSwitch({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return SwitchContainer(
|
||||||
|
info: const Info(
|
||||||
|
label: "VPN",
|
||||||
|
iconData: Icons.stacked_line_chart,
|
||||||
|
),
|
||||||
|
child: Selector<Config, bool>(
|
||||||
|
selector: (_, config) => config.vpnProps.enable,
|
||||||
|
builder: (_, enable, __) {
|
||||||
|
return Switch(
|
||||||
|
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||||
|
value: enable,
|
||||||
|
onChanged: (value) {
|
||||||
|
final config = globalState.appController.config;
|
||||||
|
config.vpnProps = config.vpnProps.copyWith(
|
||||||
|
enable: value,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class TUNSwitch extends StatelessWidget {
|
||||||
|
const TUNSwitch({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return SwitchContainer(
|
||||||
|
info: Info(
|
||||||
|
label: appLocalizations.tun,
|
||||||
|
iconData: Icons.stacked_line_chart,
|
||||||
|
),
|
||||||
|
child: Selector<ClashConfig, bool>(
|
||||||
|
selector: (_, clashConfig) => clashConfig.tun.enable,
|
||||||
|
builder: (_, enable, __) {
|
||||||
|
return Switch(
|
||||||
|
value: enable,
|
||||||
|
onChanged: (value) {
|
||||||
|
final clashConfig = globalState.appController.clashConfig;
|
||||||
|
clashConfig.tun = clashConfig.tun.copyWith(
|
||||||
|
enable: value,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ProxySwitch extends StatelessWidget {
|
||||||
|
const ProxySwitch({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return SwitchContainer(
|
||||||
|
info: Info(
|
||||||
|
label: appLocalizations.systemProxy,
|
||||||
|
iconData: Icons.shuffle,
|
||||||
|
),
|
||||||
|
child: Selector<Config, bool>(
|
||||||
|
selector: (_, config) => config.desktopProps.systemProxy,
|
||||||
|
builder: (_, systemProxy, __) {
|
||||||
|
return Switch(
|
||||||
|
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||||
|
value: systemProxy,
|
||||||
|
onChanged: (value) {
|
||||||
|
final config = globalState.appController.config;
|
||||||
|
config.desktopProps =
|
||||||
|
config.desktopProps.copyWith(systemProxy: value);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class SwitchContainer extends StatelessWidget {
|
||||||
|
final Info info;
|
||||||
|
final Widget child;
|
||||||
|
|
||||||
|
const SwitchContainer({
|
||||||
|
super.key,
|
||||||
|
required this.info,
|
||||||
|
required this.child,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return CommonCard(
|
||||||
|
onPressed: () {},
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
InfoHeader(
|
||||||
|
info: info,
|
||||||
|
actions: [
|
||||||
|
child,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -89,8 +89,11 @@ class _EditProfileState extends State<EditProfile> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<FileInfo> _getFileInfo(path) async {
|
Future<FileInfo?> _getFileInfo(path) async {
|
||||||
final file = File(path);
|
final file = File(path);
|
||||||
|
if (!await file.exists()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
final lastModified = await file.lastModified();
|
final lastModified = await file.lastModified();
|
||||||
final size = await file.length();
|
final size = await file.length();
|
||||||
return FileInfo(
|
return FileInfo(
|
||||||
@@ -118,7 +121,7 @@ class _EditProfileState extends State<EditProfile> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_uploadProfileFile() async {
|
_uploadProfileFile() async {
|
||||||
final platformFile = await globalState.safeRun(picker.pickerConfigFile);
|
final platformFile = await globalState.safeRun(picker.pickerFile);
|
||||||
if (platformFile?.bytes == null) return;
|
if (platformFile?.bytes == null) return;
|
||||||
fileData = platformFile?.bytes;
|
fileData = platformFile?.bytes;
|
||||||
fileInfoNotifier.value = fileInfoNotifier.value?.copyWith(
|
fileInfoNotifier.value = fileInfoNotifier.value?.copyWith(
|
||||||
@@ -127,59 +130,6 @@ class _EditProfileState extends State<EditProfile> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildSubtitle() {
|
|
||||||
return Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
const SizedBox(
|
|
||||||
height: 4,
|
|
||||||
),
|
|
||||||
ValueListenableBuilder<FileInfo?>(
|
|
||||||
valueListenable: fileInfoNotifier,
|
|
||||||
builder: (_, fileInfo, __) {
|
|
||||||
final height =
|
|
||||||
globalState.appController.measure.bodyMediumHeight + 4;
|
|
||||||
return SizedBox(
|
|
||||||
height: height,
|
|
||||||
child: FadeBox(
|
|
||||||
child: fileInfo == null
|
|
||||||
? SizedBox(
|
|
||||||
width: height,
|
|
||||||
height: height,
|
|
||||||
child: const CircularProgressIndicator(
|
|
||||||
strokeWidth: 2,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: Text(
|
|
||||||
fileInfo.desc,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 8,
|
|
||||||
),
|
|
||||||
Wrap(
|
|
||||||
runSpacing: 6,
|
|
||||||
spacing: 12,
|
|
||||||
children: [
|
|
||||||
CommonChip(
|
|
||||||
avatar: const Icon(Icons.edit),
|
|
||||||
label: appLocalizations.edit,
|
|
||||||
onPressed: _editProfileFile,
|
|
||||||
),
|
|
||||||
CommonChip(
|
|
||||||
avatar: const Icon(Icons.upload),
|
|
||||||
label: appLocalizations.upload,
|
|
||||||
onPressed: _uploadProfileFile,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final items = [
|
final items = [
|
||||||
@@ -250,9 +200,49 @@ class _EditProfileState extends State<EditProfile> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
ListItem(
|
ValueListenableBuilder<FileInfo?>(
|
||||||
title: Text(appLocalizations.profile),
|
valueListenable: fileInfoNotifier,
|
||||||
subtitle: _buildSubtitle(),
|
builder: (_, fileInfo, __) {
|
||||||
|
return FadeBox(
|
||||||
|
child: fileInfo == null
|
||||||
|
? Container()
|
||||||
|
: ListItem(
|
||||||
|
title: Text(
|
||||||
|
appLocalizations.profile,
|
||||||
|
),
|
||||||
|
subtitle: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
const SizedBox(
|
||||||
|
height: 4,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
fileInfo.desc,
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 8,
|
||||||
|
),
|
||||||
|
Wrap(
|
||||||
|
runSpacing: 6,
|
||||||
|
spacing: 12,
|
||||||
|
children: [
|
||||||
|
CommonChip(
|
||||||
|
avatar: const Icon(Icons.edit),
|
||||||
|
label: appLocalizations.edit,
|
||||||
|
onPressed: _editProfileFile,
|
||||||
|
),
|
||||||
|
CommonChip(
|
||||||
|
avatar: const Icon(Icons.upload),
|
||||||
|
label: appLocalizations.upload,
|
||||||
|
onPressed: _uploadProfileFile,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
return FloatLayout(
|
return FloatLayout(
|
||||||
@@ -270,23 +260,19 @@ class _EditProfileState extends State<EditProfile> {
|
|||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
vertical: 16,
|
vertical: 16,
|
||||||
),
|
),
|
||||||
child: ScrollOverBuilder(
|
child: ListView.separated(
|
||||||
builder: (isOver) {
|
padding: kMaterialListPadding.copyWith(
|
||||||
return ListView.separated(
|
bottom: 72,
|
||||||
padding: kMaterialListPadding.copyWith(
|
),
|
||||||
bottom: isOver ? 72 : 36,
|
itemBuilder: (_, index) {
|
||||||
),
|
return items[index];
|
||||||
itemBuilder: (_, index) {
|
},
|
||||||
return items[index];
|
separatorBuilder: (_, __) {
|
||||||
},
|
return const SizedBox(
|
||||||
separatorBuilder: (_, __) {
|
height: 24,
|
||||||
return const SizedBox(
|
|
||||||
height: 24,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
itemCount: items.length,
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
itemCount: items.length,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'package:fl_clash/enum/enum.dart';
|
import 'package:fl_clash/enum/enum.dart';
|
||||||
import 'package:fl_clash/fragments/profiles/edit_profile.dart';
|
import 'package:fl_clash/fragments/profiles/edit_profile.dart';
|
||||||
import 'package:fl_clash/models/models.dart';
|
import 'package:fl_clash/models/models.dart';
|
||||||
@@ -27,8 +29,6 @@ class ProfilesFragment extends StatefulWidget {
|
|||||||
class _ProfilesFragmentState extends State<ProfilesFragment> {
|
class _ProfilesFragmentState extends State<ProfilesFragment> {
|
||||||
Function? applyConfigDebounce;
|
Function? applyConfigDebounce;
|
||||||
|
|
||||||
List<GlobalObjectKey<_ProfileItemState>> profileItemKeys = [];
|
|
||||||
|
|
||||||
_handleShowAddExtendPage() {
|
_handleShowAddExtendPage() {
|
||||||
showExtendPage(
|
showExtendPage(
|
||||||
globalState.navigatorKey.currentState!.context,
|
globalState.navigatorKey.currentState!.context,
|
||||||
@@ -39,29 +39,52 @@ class _ProfilesFragmentState extends State<ProfilesFragment> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
_getColumns(ViewMode viewMode) {
|
|
||||||
switch (viewMode) {
|
|
||||||
case ViewMode.mobile:
|
|
||||||
return 1;
|
|
||||||
case ViewMode.laptop:
|
|
||||||
return 1;
|
|
||||||
case ViewMode.desktop:
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_updateProfiles() async {
|
_updateProfiles() async {
|
||||||
final updateProfiles = profileItemKeys.map<Future>(
|
final appController = globalState.appController;
|
||||||
(key) async => await key.currentState?.updateProfile(false));
|
final config = appController.config;
|
||||||
|
final profiles = appController.config.profiles;
|
||||||
|
final messages = [];
|
||||||
|
final updateProfiles = profiles.map<Future>(
|
||||||
|
(profile) async {
|
||||||
|
config.setProfile(
|
||||||
|
profile.copyWith(isUpdating: true),
|
||||||
|
);
|
||||||
|
try {
|
||||||
|
await appController.updateProfile(profile);
|
||||||
|
if (profile.id == appController.config.currentProfile?.id) {
|
||||||
|
appController.applyProfileDebounce();
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
messages.add("${profile.label ?? profile.id}: $e \n");
|
||||||
|
config.setProfile(
|
||||||
|
profile.copyWith(
|
||||||
|
isUpdating: false,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
final titleMedium = context.textTheme.titleMedium;
|
||||||
await Future.wait(updateProfiles);
|
await Future.wait(updateProfiles);
|
||||||
|
if (messages.isNotEmpty) {
|
||||||
|
globalState.showMessage(
|
||||||
|
title: appLocalizations.tip,
|
||||||
|
message: TextSpan(
|
||||||
|
children: [
|
||||||
|
for (final message in messages)
|
||||||
|
TextSpan(text: message, style: titleMedium)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_initScaffoldState() {
|
_initScaffoldState() {
|
||||||
WidgetsBinding.instance.addPostFrameCallback(
|
WidgetsBinding.instance.addPostFrameCallback(
|
||||||
(_) {
|
(_) {
|
||||||
|
if (!mounted) return;
|
||||||
final commonScaffoldState =
|
final commonScaffoldState =
|
||||||
context.findAncestorStateOfType<CommonScaffoldState>();
|
context.findAncestorStateOfType<CommonScaffoldState>();
|
||||||
if (!context.mounted) return;
|
|
||||||
commonScaffoldState?.actions = [
|
commonScaffoldState?.actions = [
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
@@ -69,24 +92,29 @@ class _ProfilesFragmentState extends State<ProfilesFragment> {
|
|||||||
},
|
},
|
||||||
icon: const Icon(Icons.sync),
|
icon: const Icon(Icons.sync),
|
||||||
),
|
),
|
||||||
|
const SizedBox(
|
||||||
|
width: 8,
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
onPressed: () {
|
||||||
|
final profiles = globalState.appController.config.profiles;
|
||||||
|
showSheet(
|
||||||
|
title: appLocalizations.profilesSort,
|
||||||
|
context: context,
|
||||||
|
builder: (_) => SizedBox(
|
||||||
|
height: 400,
|
||||||
|
child: ReorderableProfiles(profiles: profiles),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
icon: const Icon(Icons.sort),
|
||||||
|
iconSize: 26,
|
||||||
|
),
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
_changeProfile(String? id) async {
|
|
||||||
final appController = globalState.appController;
|
|
||||||
final config = appController.config;
|
|
||||||
if (id == config.currentProfileId) return;
|
|
||||||
config.currentProfileId = id;
|
|
||||||
applyConfigDebounce ??= debounce<Function()>(() async {
|
|
||||||
await appController.applyProfile();
|
|
||||||
appController.appState.delayMap = {};
|
|
||||||
appController.saveConfigPreferences();
|
|
||||||
});
|
|
||||||
applyConfigDebounce!();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return FloatLayout(
|
return FloatLayout(
|
||||||
@@ -111,7 +139,7 @@ class _ProfilesFragmentState extends State<ProfilesFragment> {
|
|||||||
selector: (_, appState, config) => ProfilesSelectorState(
|
selector: (_, appState, config) => ProfilesSelectorState(
|
||||||
profiles: config.profiles,
|
profiles: config.profiles,
|
||||||
currentProfileId: config.currentProfileId,
|
currentProfileId: config.currentProfileId,
|
||||||
viewMode: appState.viewMode,
|
columns: other.getProfilesColumns(appState.viewWidth),
|
||||||
),
|
),
|
||||||
builder: (context, state, child) {
|
builder: (context, state, child) {
|
||||||
if (state.profiles.isEmpty) {
|
if (state.profiles.isEmpty) {
|
||||||
@@ -119,40 +147,31 @@ class _ProfilesFragmentState extends State<ProfilesFragment> {
|
|||||||
label: appLocalizations.nullProfileDesc,
|
label: appLocalizations.nullProfileDesc,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
profileItemKeys = state.profiles
|
|
||||||
.map(
|
|
||||||
(profile) => GlobalObjectKey<_ProfileItemState>(profile.id))
|
|
||||||
.toList();
|
|
||||||
final columns = _getColumns(state.viewMode);
|
|
||||||
return Align(
|
return Align(
|
||||||
alignment: Alignment.topCenter,
|
alignment: Alignment.topCenter,
|
||||||
child: ScrollOverBuilder(
|
child: SingleChildScrollView(
|
||||||
builder: (isOver) {
|
padding: const EdgeInsets.only(
|
||||||
return SingleChildScrollView(
|
left: 16,
|
||||||
padding: EdgeInsets.only(
|
right: 16,
|
||||||
left: 16,
|
top: 16,
|
||||||
right: 16,
|
bottom: 88,
|
||||||
top: 16,
|
),
|
||||||
bottom: 16 + (isOver ? 72 : 0),
|
child: Grid(
|
||||||
),
|
mainAxisSpacing: 16,
|
||||||
child: Grid(
|
crossAxisSpacing: 16,
|
||||||
mainAxisSpacing: 16,
|
crossAxisCount: state.columns,
|
||||||
crossAxisSpacing: 16,
|
children: [
|
||||||
crossAxisCount: columns,
|
for (int i = 0; i < state.profiles.length; i++)
|
||||||
children: [
|
GridItem(
|
||||||
for (int i = 0; i < state.profiles.length; i++)
|
child: ProfileItem(
|
||||||
GridItem(
|
key: Key(state.profiles[i].id),
|
||||||
child: ProfileItem(
|
profile: state.profiles[i],
|
||||||
key: profileItemKeys[i],
|
groupValue: state.currentProfileId,
|
||||||
profile: state.profiles[i],
|
onChanged: globalState.appController.changeProfile,
|
||||||
groupValue: state.currentProfileId,
|
),
|
||||||
onChanged: _changeProfile,
|
),
|
||||||
),
|
],
|
||||||
),
|
),
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -162,7 +181,7 @@ class _ProfilesFragmentState extends State<ProfilesFragment> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ProfileItem extends StatefulWidget {
|
class ProfileItem extends StatelessWidget {
|
||||||
final Profile profile;
|
final Profile profile;
|
||||||
final String? groupValue;
|
final String? groupValue;
|
||||||
final void Function(String? value) onChanged;
|
final void Function(String? value) onChanged;
|
||||||
@@ -174,22 +193,15 @@ class ProfileItem extends StatefulWidget {
|
|||||||
required this.onChanged,
|
required this.onChanged,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
_handleDeleteProfile(BuildContext context) async {
|
||||||
State<ProfileItem> createState() => _ProfileItemState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _ProfileItemState extends State<ProfileItem> {
|
|
||||||
final isUpdating = ValueNotifier<bool>(false);
|
|
||||||
|
|
||||||
_handleDeleteProfile() async {
|
|
||||||
globalState.showMessage(
|
globalState.showMessage(
|
||||||
title: appLocalizations.tip,
|
title: appLocalizations.tip,
|
||||||
message: TextSpan(
|
message: TextSpan(
|
||||||
text: appLocalizations.deleteProfileTip,
|
text: appLocalizations.deleteProfileTip,
|
||||||
),
|
),
|
||||||
onTab: () async {
|
onTab: () async {
|
||||||
await globalState.appController.deleteProfile(widget.profile.id);
|
await globalState.appController.deleteProfile(profile.id);
|
||||||
if(mounted){
|
if (context.mounted) {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -200,122 +212,102 @@ class _ProfileItemState extends State<ProfileItem> {
|
|||||||
await globalState.safeRun<void>(updateProfile);
|
await globalState.safeRun<void>(updateProfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future updateProfile([isSingle = true]) async {
|
Future updateProfile() async {
|
||||||
isUpdating.value = true;
|
final appController = globalState.appController;
|
||||||
try {
|
final config = appController.config;
|
||||||
final appController = globalState.appController;
|
if (profile.type == ProfileType.file) return;
|
||||||
await appController.updateProfile(widget.profile);
|
await globalState.safeRun(() async {
|
||||||
if (widget.profile.id == appController.config.currentProfile?.id) {
|
try {
|
||||||
globalState.appController.applyProfile(isPrue: true);
|
config.setProfile(
|
||||||
}
|
profile.copyWith(
|
||||||
} catch (e) {
|
isUpdating: true,
|
||||||
isUpdating.value = false;
|
),
|
||||||
if (!isSingle) {
|
);
|
||||||
return e.toString();
|
await appController.updateProfile(profile);
|
||||||
} else {
|
if (profile.id == appController.config.currentProfile?.id) {
|
||||||
|
appController.applyProfileDebounce();
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
config.setProfile(
|
||||||
|
profile.copyWith(
|
||||||
|
isUpdating: false,
|
||||||
|
),
|
||||||
|
);
|
||||||
rethrow;
|
rethrow;
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
isUpdating.value = false;
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_handleShowEditExtendPage() {
|
_handleShowEditExtendPage(BuildContext context) {
|
||||||
showExtendPage(
|
showExtendPage(
|
||||||
context,
|
context,
|
||||||
body: EditProfile(
|
body: EditProfile(
|
||||||
profile: widget.profile,
|
profile: profile,
|
||||||
context: context,
|
context: context,
|
||||||
),
|
),
|
||||||
title: "${appLocalizations.edit}${appLocalizations.profile}",
|
title: "${appLocalizations.edit}${appLocalizations.profile}",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
_buildTitle(Profile profile) {
|
List<Widget> _buildUserInfo(BuildContext context, UserInfo userInfo) {
|
||||||
final textTheme = context.textTheme;
|
final use = userInfo.upload + userInfo.download;
|
||||||
return Container(
|
final total = userInfo.total;
|
||||||
padding: const EdgeInsets.symmetric(vertical: 4),
|
if (total == 0) {
|
||||||
child: Column(
|
return [];
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
}
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
final useShow = TrafficValue(value: use).show;
|
||||||
children: [
|
final totalShow = TrafficValue(value: total).show;
|
||||||
Row(
|
final progress = total == 0 ? 0.0 : use / total;
|
||||||
mainAxisSize: MainAxisSize.max,
|
final expireShow = userInfo.expire == 0
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
? appLocalizations.infiniteTime
|
||||||
children: [
|
: DateTime.fromMillisecondsSinceEpoch(userInfo.expire * 1000).show;
|
||||||
Flexible(
|
return [
|
||||||
child: Text(
|
LinearProgressIndicator(
|
||||||
profile.label ?? profile.id,
|
minHeight: 6,
|
||||||
style: textTheme.titleMedium,
|
value: progress,
|
||||||
maxLines: 1,
|
backgroundColor: context.colorScheme.primary.toSoft(),
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
profile.lastUpdateDate?.lastUpdateTimeDesc ?? '',
|
|
||||||
style: textTheme.labelMedium?.toLight,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Builder(builder: (context) {
|
|
||||||
final userInfo = profile.userInfo ?? const 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
|
|
||||||
? appLocalizations.infiniteTime
|
|
||||||
: DateTime.fromMillisecondsSinceEpoch(userInfo.expire * 1000)
|
|
||||||
.show;
|
|
||||||
return 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(
|
|
||||||
expireShow,
|
|
||||||
style: textTheme.labelMedium?.toLight,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
);
|
const SizedBox(
|
||||||
|
height: 8,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
"$useShow / $totalShow · $expireShow",
|
||||||
|
style: context.textTheme.labelMedium?.toLight,
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 4,
|
||||||
|
),
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
List<Widget> _buildUrlProfileInfo(BuildContext context) {
|
||||||
void dispose() {
|
final userInfo = profile.userInfo;
|
||||||
isUpdating.dispose();
|
return [
|
||||||
super.dispose();
|
const SizedBox(
|
||||||
|
height: 8,
|
||||||
|
),
|
||||||
|
if (userInfo != null) ..._buildUserInfo(context, userInfo),
|
||||||
|
Text(
|
||||||
|
profile.lastUpdateDate?.lastUpdateTimeDesc ?? "",
|
||||||
|
style: context.textTheme.labelMedium?.toLight,
|
||||||
|
),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Widget> _buildFileProfileInfo(BuildContext context) {
|
||||||
|
return [
|
||||||
|
const SizedBox(
|
||||||
|
height: 8,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
profile.lastUpdateDate?.lastUpdateTimeDesc ?? "",
|
||||||
|
style: context.textTheme.labelMedium?.toLight,
|
||||||
|
),
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final profile = widget.profile;
|
|
||||||
final groupValue = widget.groupValue;
|
|
||||||
final onChanged = widget.onChanged;
|
|
||||||
return CommonCard(
|
return CommonCard(
|
||||||
isSelected: profile.id == groupValue,
|
isSelected: profile.id == groupValue,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
@@ -328,57 +320,203 @@ class _ProfileItemState extends State<ProfileItem> {
|
|||||||
trailing: SizedBox(
|
trailing: SizedBox(
|
||||||
height: 40,
|
height: 40,
|
||||||
width: 40,
|
width: 40,
|
||||||
child: ValueListenableBuilder(
|
child: FadeBox(
|
||||||
valueListenable: isUpdating,
|
child: profile.isUpdating
|
||||||
builder: (_, isUpdating, ___) {
|
? const Padding(
|
||||||
return FadeBox(
|
padding: EdgeInsets.all(8),
|
||||||
child: isUpdating
|
child: CircularProgressIndicator(),
|
||||||
? const Padding(
|
)
|
||||||
padding: EdgeInsets.all(8),
|
: CommonPopupMenu<ProfileActions>(
|
||||||
child: CircularProgressIndicator(),
|
items: [
|
||||||
)
|
CommonPopupMenuItem(
|
||||||
: CommonPopupMenu<ProfileActions>(
|
action: ProfileActions.edit,
|
||||||
items: [
|
label: appLocalizations.edit,
|
||||||
CommonPopupMenuItem(
|
iconData: Icons.edit,
|
||||||
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();
|
|
||||||
break;
|
|
||||||
case ProfileActions.delete:
|
|
||||||
_handleDeleteProfile();
|
|
||||||
break;
|
|
||||||
case ProfileActions.update:
|
|
||||||
_handleUpdateProfile();
|
|
||||||
break;
|
|
||||||
case null:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
);
|
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(context);
|
||||||
|
break;
|
||||||
|
case ProfileActions.delete:
|
||||||
|
_handleDeleteProfile(context);
|
||||||
|
break;
|
||||||
|
case ProfileActions.update:
|
||||||
|
_handleUpdateProfile();
|
||||||
|
break;
|
||||||
|
case null:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
title: Container(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
profile.label ?? profile.id,
|
||||||
|
style: context.textTheme.titleMedium,
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
...switch (profile.type) {
|
||||||
|
ProfileType.file => _buildFileProfileInfo(context),
|
||||||
|
ProfileType.url => _buildUrlProfileInfo(context),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
title: _buildTitle(profile),
|
|
||||||
tileTitleAlignment: ListTileTitleAlignment.titleHeight,
|
tileTitleAlignment: ListTileTitleAlignment.titleHeight,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ReorderableProfiles extends StatefulWidget {
|
||||||
|
final List<Profile> profiles;
|
||||||
|
|
||||||
|
const ReorderableProfiles({
|
||||||
|
super.key,
|
||||||
|
required this.profiles,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<ReorderableProfiles> createState() => _ReorderableProfilesState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ReorderableProfilesState extends State<ReorderableProfiles> {
|
||||||
|
late List<Profile> profiles;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
profiles = List.from(widget.profiles);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget proxyDecorator(
|
||||||
|
Widget child,
|
||||||
|
int index,
|
||||||
|
Animation<double> animation,
|
||||||
|
) {
|
||||||
|
final profile = profiles[index];
|
||||||
|
return AnimatedBuilder(
|
||||||
|
animation: animation,
|
||||||
|
builder: (_, Widget? child) {
|
||||||
|
final double animValue = Curves.easeInOut.transform(animation.value);
|
||||||
|
final double scale = lerpDouble(1, 1.02, animValue)!;
|
||||||
|
return Transform.scale(
|
||||||
|
scale: scale,
|
||||||
|
child: child,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
key: Key(profile.id),
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||||
|
child: CommonCard(
|
||||||
|
type: CommonCardType.filled,
|
||||||
|
child: ListTile(
|
||||||
|
contentPadding: const EdgeInsets.only(
|
||||||
|
right: 44,
|
||||||
|
left: 16,
|
||||||
|
),
|
||||||
|
title: Text(profile.label ?? profile.id),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
flex: 1,
|
||||||
|
child: ReorderableListView.builder(
|
||||||
|
buildDefaultDragHandles: false,
|
||||||
|
padding: const EdgeInsets.all(12),
|
||||||
|
proxyDecorator: proxyDecorator,
|
||||||
|
onReorder: (int oldIndex, int newIndex) {
|
||||||
|
if (oldIndex == newIndex) return;
|
||||||
|
setState(() {
|
||||||
|
if (oldIndex < newIndex) {
|
||||||
|
newIndex -= 1;
|
||||||
|
}
|
||||||
|
final profile = profiles.removeAt(oldIndex);
|
||||||
|
profiles.insert(newIndex, profile);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
itemBuilder: (_, index) {
|
||||||
|
final profile = profiles[index];
|
||||||
|
return Container(
|
||||||
|
key: Key(profile.id),
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||||
|
child: CommonCard(
|
||||||
|
type: CommonCardType.filled,
|
||||||
|
child: ListTile(
|
||||||
|
contentPadding: const EdgeInsets.only(
|
||||||
|
right: 16,
|
||||||
|
left: 16,
|
||||||
|
),
|
||||||
|
title: Text(profile.label ?? profile.id),
|
||||||
|
trailing: ReorderableDragStartListener(
|
||||||
|
index: index,
|
||||||
|
child: const Icon(Icons.drag_handle),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
itemCount: profiles.length,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
vertical: 8,
|
||||||
|
horizontal: 12,
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
IconButton(
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
globalState.appController.config.profiles = profiles;
|
||||||
|
},
|
||||||
|
icon: const Icon(
|
||||||
|
Icons.check,
|
||||||
|
),
|
||||||
|
iconSize: 32,
|
||||||
|
padding: const EdgeInsets.all(8),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
232
lib/fragments/profiles/view_profile.dart
Normal file
232
lib/fragments/profiles/view_profile.dart
Normal file
@@ -0,0 +1,232 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:fl_clash/common/common.dart';
|
||||||
|
import 'package:fl_clash/models/models.dart';
|
||||||
|
import 'package:fl_clash/state.dart';
|
||||||
|
import 'package:fl_clash/widgets/scaffold.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:re_editor/re_editor.dart';
|
||||||
|
import 'package:re_highlight/languages/yaml.dart';
|
||||||
|
import 'package:re_highlight/styles/atom-one-light.dart';
|
||||||
|
|
||||||
|
class ViewProfile extends StatefulWidget {
|
||||||
|
final Profile profile;
|
||||||
|
|
||||||
|
const ViewProfile({
|
||||||
|
super.key,
|
||||||
|
required this.profile,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<ViewProfile> createState() => _ViewProfileState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ViewProfileState extends State<ViewProfile> {
|
||||||
|
bool readOnly = true;
|
||||||
|
final CodeLineEditingController _controller = CodeLineEditingController();
|
||||||
|
final key = GlobalKey<CommonScaffoldState>();
|
||||||
|
final _focusNode = FocusNode();
|
||||||
|
String? rawText;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
appPath.getProfilePath(widget.profile.id).then((path) async {
|
||||||
|
if (path == null) return;
|
||||||
|
final file = File(path);
|
||||||
|
rawText = await file.readAsString();
|
||||||
|
_controller.text = rawText ?? "";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
super.dispose();
|
||||||
|
_controller.dispose();
|
||||||
|
_focusNode.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
Profile get profile => widget.profile;
|
||||||
|
|
||||||
|
_handleChangeReadOnly() async {
|
||||||
|
if (readOnly == true) {
|
||||||
|
setState(() {
|
||||||
|
readOnly = false;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
if (_controller.text == rawText) return;
|
||||||
|
final newProfile = await key.currentState?.loadingRun<Profile>(() async {
|
||||||
|
return await profile.saveFileWithString(_controller.text);
|
||||||
|
});
|
||||||
|
if (newProfile == null) return;
|
||||||
|
globalState.appController.config.setProfile(newProfile);
|
||||||
|
setState(() {
|
||||||
|
readOnly = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return CommonScaffold(
|
||||||
|
key: key,
|
||||||
|
actions: [
|
||||||
|
IconButton(
|
||||||
|
onPressed: _controller.undo,
|
||||||
|
icon: const Icon(Icons.undo),
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
onPressed: _controller.redo,
|
||||||
|
icon: const Icon(Icons.redo),
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
onPressed: _handleChangeReadOnly,
|
||||||
|
icon: readOnly ? const Icon(Icons.edit) : const Icon(Icons.save),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
body: CodeEditor(
|
||||||
|
readOnly: readOnly,
|
||||||
|
focusNode: _focusNode,
|
||||||
|
scrollbarBuilder: (context, child, details) {
|
||||||
|
return Scrollbar(
|
||||||
|
controller: details.controller,
|
||||||
|
thickness: 8,
|
||||||
|
radius: const Radius.circular(2),
|
||||||
|
interactive: true,
|
||||||
|
child: child,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
showCursorWhenReadOnly: false,
|
||||||
|
controller: _controller,
|
||||||
|
shortcutsActivatorsBuilder:
|
||||||
|
const DefaultCodeShortcutsActivatorsBuilder(),
|
||||||
|
indicatorBuilder: (
|
||||||
|
context,
|
||||||
|
editingController,
|
||||||
|
chunkController,
|
||||||
|
notifier,
|
||||||
|
) {
|
||||||
|
return Row(
|
||||||
|
children: [
|
||||||
|
DefaultCodeLineNumber(
|
||||||
|
controller: editingController,
|
||||||
|
notifier: notifier,
|
||||||
|
),
|
||||||
|
DefaultCodeChunkIndicator(
|
||||||
|
width: 20,
|
||||||
|
controller: chunkController,
|
||||||
|
notifier: notifier,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
toolbarController:
|
||||||
|
!readOnly ? ContextMenuControllerImpl(_focusNode) : null,
|
||||||
|
style: CodeEditorStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
codeTheme: CodeHighlightTheme(
|
||||||
|
languages: {
|
||||||
|
'yaml': CodeHighlightThemeMode(
|
||||||
|
mode: langYaml,
|
||||||
|
)
|
||||||
|
},
|
||||||
|
theme: atomOneLightTheme,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
title: widget.profile.label ?? widget.profile.id,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ContextMenuItemWidget extends PopupMenuItem<void> {
|
||||||
|
ContextMenuItemWidget({
|
||||||
|
super.key,
|
||||||
|
required String text,
|
||||||
|
required VoidCallback super.onTap,
|
||||||
|
}) : super(child: Text(text));
|
||||||
|
}
|
||||||
|
|
||||||
|
class ContextMenuControllerImpl implements SelectionToolbarController {
|
||||||
|
OverlayEntry? _overlayEntry;
|
||||||
|
|
||||||
|
final FocusNode focusNode;
|
||||||
|
|
||||||
|
ContextMenuControllerImpl(
|
||||||
|
this.focusNode,
|
||||||
|
);
|
||||||
|
|
||||||
|
_removeOverLayEntry() {
|
||||||
|
_overlayEntry?.remove();
|
||||||
|
_overlayEntry = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void hide(BuildContext context) {
|
||||||
|
// _removeOverLayEntry();
|
||||||
|
}
|
||||||
|
|
||||||
|
_handleCut(CodeLineEditingController controller) {
|
||||||
|
controller.cut();
|
||||||
|
_removeOverLayEntry();
|
||||||
|
}
|
||||||
|
|
||||||
|
_handleCopy(CodeLineEditingController controller) async {
|
||||||
|
await controller.copy();
|
||||||
|
_removeOverLayEntry();
|
||||||
|
}
|
||||||
|
|
||||||
|
_handlePaste(CodeLineEditingController controller) {
|
||||||
|
controller.paste();
|
||||||
|
_removeOverLayEntry();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void show({
|
||||||
|
required BuildContext context,
|
||||||
|
required CodeLineEditingController controller,
|
||||||
|
required TextSelectionToolbarAnchors anchors,
|
||||||
|
Rect? renderRect,
|
||||||
|
required LayerLink layerLink,
|
||||||
|
required ValueNotifier<bool> visibility,
|
||||||
|
}) {
|
||||||
|
if (controller.selectedText.isEmpty) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_removeOverLayEntry();
|
||||||
|
final relativeRect = RelativeRect.fromSize(
|
||||||
|
(anchors.primaryAnchor) &
|
||||||
|
const Size(150, double.infinity),
|
||||||
|
MediaQuery.of(context).size,
|
||||||
|
);
|
||||||
|
_overlayEntry ??= OverlayEntry(
|
||||||
|
builder: (context) => ValueListenableBuilder<CodeLineEditingValue>(
|
||||||
|
valueListenable: controller,
|
||||||
|
builder: (_, __, child) {
|
||||||
|
if (controller.selectedText.isEmpty) {
|
||||||
|
_removeOverLayEntry();
|
||||||
|
}
|
||||||
|
return child!;
|
||||||
|
},
|
||||||
|
child: Positioned(
|
||||||
|
left: relativeRect.left,
|
||||||
|
top: relativeRect.top,
|
||||||
|
child: Material(
|
||||||
|
color: Colors.transparent,
|
||||||
|
child: GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
FocusScope.of(context).requestFocus(focusNode);
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
width: 200,
|
||||||
|
height: 200,
|
||||||
|
color: Colors.green,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
Overlay.of(context).insert(_overlayEntry!);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -69,23 +69,21 @@ class ProxyCard extends StatelessWidget {
|
|||||||
if (type == ProxyCardType.min) {
|
if (type == ProxyCardType.min) {
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
height: measure.bodyMediumHeight * 1,
|
height: measure.bodyMediumHeight * 1,
|
||||||
child: Text(
|
child: EmojiText(
|
||||||
proxy.name,
|
proxy.name,
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
style: context.textTheme.bodyMedium?.copyWith(
|
overflow: TextOverflow.ellipsis,
|
||||||
overflow: TextOverflow.ellipsis,
|
style: context.textTheme.bodyMedium,
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
height: measure.bodyMediumHeight * 2,
|
height: measure.bodyMediumHeight * 2,
|
||||||
child: Text(
|
child: EmojiText(
|
||||||
proxy.name,
|
proxy.name,
|
||||||
maxLines: 2,
|
maxLines: 2,
|
||||||
style: context.textTheme.bodyMedium?.copyWith(
|
overflow: TextOverflow.ellipsis,
|
||||||
overflow: TextOverflow.ellipsis,
|
style: context.textTheme.bodyMedium,
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -155,14 +153,12 @@ class ProxyCard extends StatelessWidget {
|
|||||||
proxy.name,
|
proxy.name,
|
||||||
),
|
),
|
||||||
builder: (_, desc, __) {
|
builder: (_, desc, __) {
|
||||||
return TooltipText(
|
return EmojiText(
|
||||||
text: Text(
|
desc,
|
||||||
desc,
|
overflow: TextOverflow.ellipsis,
|
||||||
style: context.textTheme.bodySmall?.copyWith(
|
style: context.textTheme.bodySmall?.copyWith(
|
||||||
overflow: TextOverflow.ellipsis,
|
color: context.textTheme.bodySmall?.color
|
||||||
color: context.textTheme.bodySmall?.color
|
?.toLight(),
|
||||||
?.toLight(),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:fl_clash/clash/clash.dart';
|
import 'package:fl_clash/clash/clash.dart';
|
||||||
import 'package:fl_clash/common/constant.dart';
|
import 'package:fl_clash/common/other.dart';
|
||||||
import 'package:fl_clash/enum/enum.dart';
|
import 'package:fl_clash/enum/enum.dart';
|
||||||
import 'package:fl_clash/models/models.dart';
|
import 'package:fl_clash/models/models.dart';
|
||||||
import 'package:fl_clash/state.dart';
|
import 'package:fl_clash/state.dart';
|
||||||
@@ -42,7 +42,7 @@ double getItemHeight(ProxyCardType proxyCardType) {
|
|||||||
|
|
||||||
delayTest(List<Proxy> proxies) async {
|
delayTest(List<Proxy> proxies) async {
|
||||||
final appController = globalState.appController;
|
final appController = globalState.appController;
|
||||||
for (final proxy in proxies) {
|
final delayProxies = proxies.map<Future>((proxy) async {
|
||||||
final proxyName = appController.appState.getRealProxyName(proxy.name);
|
final proxyName = appController.appState.getRealProxyName(proxy.name);
|
||||||
globalState.appController.setDelay(
|
globalState.appController.setDelay(
|
||||||
Delay(
|
Delay(
|
||||||
@@ -50,11 +50,9 @@ delayTest(List<Proxy> proxies) async {
|
|||||||
value: 0,
|
value: 0,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
clashCore.getDelay(proxyName).then((delay) {
|
globalState.appController.setDelay(await clashCore.getDelay(proxyName));
|
||||||
globalState.appController.setDelay(delay);
|
});
|
||||||
});
|
await Future.wait(delayProxies);
|
||||||
}
|
|
||||||
await Future.delayed(httpTimeoutDuration + moreDuration);
|
|
||||||
appController.appState.sortNum++;
|
appController.appState.sortNum++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,7 +61,10 @@ double getScrollToSelectedOffset({
|
|||||||
required List<Proxy> proxies,
|
required List<Proxy> proxies,
|
||||||
}) {
|
}) {
|
||||||
final appController = globalState.appController;
|
final appController = globalState.appController;
|
||||||
final columns = appController.columns;
|
final columns = other.getProxiesColumns(
|
||||||
|
appController.appState.viewWidth,
|
||||||
|
appController.config.proxiesLayout,
|
||||||
|
);
|
||||||
final proxyCardType = appController.config.proxyCardType;
|
final proxyCardType = appController.config.proxyCardType;
|
||||||
final selectedName = appController.getCurrentSelectedName(groupName);
|
final selectedName = appController.getCurrentSelectedName(groupName);
|
||||||
final findSelectedIndex = proxies.indexWhere(
|
final findSelectedIndex = proxies.indexWhere(
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import 'package:fl_clash/enum/enum.dart';
|
|||||||
import 'package:fl_clash/models/models.dart';
|
import 'package:fl_clash/models/models.dart';
|
||||||
import 'package:fl_clash/state.dart';
|
import 'package:fl_clash/state.dart';
|
||||||
import 'package:fl_clash/widgets/card.dart';
|
import 'package:fl_clash/widgets/card.dart';
|
||||||
|
import 'package:fl_clash/widgets/text.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
@@ -237,7 +238,10 @@ class _ProxiesListFragmentState extends State<ProxiesListFragment> {
|
|||||||
currentUnfoldSet: config.currentUnfoldSet,
|
currentUnfoldSet: config.currentUnfoldSet,
|
||||||
proxyCardType: config.proxyCardType,
|
proxyCardType: config.proxyCardType,
|
||||||
proxiesSortType: config.proxiesSortType,
|
proxiesSortType: config.proxiesSortType,
|
||||||
columns: globalState.appController.columns,
|
columns: other.getProxiesColumns(
|
||||||
|
appState.viewWidth,
|
||||||
|
config.proxiesLayout,
|
||||||
|
),
|
||||||
sortNum: appState.sortNum,
|
sortNum: appState.sortNum,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -450,7 +454,7 @@ class _ListHeaderState extends State<ListHeader>
|
|||||||
if (currentGroupName.isNotEmpty) ...[
|
if (currentGroupName.isNotEmpty) ...[
|
||||||
Flexible(
|
Flexible(
|
||||||
flex: 1,
|
flex: 1,
|
||||||
child: Text(
|
child: EmojiText(
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
" · $currentGroupName",
|
" · $currentGroupName",
|
||||||
style: context
|
style: context
|
||||||
|
|||||||
208
lib/fragments/proxies/providers.dart
Normal file
208
lib/fragments/proxies/providers.dart
Normal file
@@ -0,0 +1,208 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:fl_clash/clash/clash.dart';
|
||||||
|
import 'package:fl_clash/common/common.dart';
|
||||||
|
import 'package:fl_clash/models/app.dart';
|
||||||
|
import 'package:fl_clash/models/ffi.dart';
|
||||||
|
import 'package:fl_clash/state.dart';
|
||||||
|
import 'package:fl_clash/widgets/widgets.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
typedef UpdatingMap = Map<String, bool>;
|
||||||
|
|
||||||
|
class Providers extends StatefulWidget {
|
||||||
|
const Providers({
|
||||||
|
super.key,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<Providers> createState() => _ProvidersState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ProvidersState extends State<Providers> {
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback(
|
||||||
|
(_) {
|
||||||
|
final commonScaffoldState =
|
||||||
|
context.findAncestorStateOfType<CommonScaffoldState>();
|
||||||
|
commonScaffoldState?.actions = [
|
||||||
|
IconButton(
|
||||||
|
onPressed: () {
|
||||||
|
_updateProviders();
|
||||||
|
},
|
||||||
|
icon: const Icon(
|
||||||
|
Icons.sync,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
];
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
_updateProviders() async {
|
||||||
|
final appState = globalState.appController.appState;
|
||||||
|
final providers = globalState.appController.appState.providers;
|
||||||
|
final updateProviders = providers.map<Future>(
|
||||||
|
(provider) async {
|
||||||
|
appState.setProvider(
|
||||||
|
provider.copyWith(isUpdating: true),
|
||||||
|
);
|
||||||
|
await clashCore.updateExternalProvider(
|
||||||
|
providerName: provider.name,
|
||||||
|
);
|
||||||
|
appState.setProvider(
|
||||||
|
clashCore.getExternalProvider(provider.name),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
await Future.wait(updateProviders);
|
||||||
|
await globalState.appController.updateGroupDebounce();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Selector<AppState, List<ExternalProvider>>(
|
||||||
|
selector: (_, appState) => appState.providers,
|
||||||
|
builder: (_, providers, ___) {
|
||||||
|
return ListView.separated(
|
||||||
|
itemBuilder: (_, index) {
|
||||||
|
return ProviderItem(
|
||||||
|
provider: providers[index],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
separatorBuilder: (_, index) {
|
||||||
|
return const Divider(
|
||||||
|
height: 0,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
itemCount: providers.length,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ProviderItem extends StatelessWidget {
|
||||||
|
final ExternalProvider provider;
|
||||||
|
|
||||||
|
const ProviderItem({
|
||||||
|
super.key,
|
||||||
|
required this.provider,
|
||||||
|
});
|
||||||
|
|
||||||
|
_handleUpdateProvider() async {
|
||||||
|
await globalState.safeRun<void>(() async {
|
||||||
|
final appState = globalState.appController.appState;
|
||||||
|
if (provider.vehicleType != "HTTP") return;
|
||||||
|
await globalState.safeRun(() async {
|
||||||
|
appState.setProvider(
|
||||||
|
provider.copyWith(
|
||||||
|
isUpdating: true,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
final message = await clashCore.updateExternalProvider(
|
||||||
|
providerName: provider.name,
|
||||||
|
);
|
||||||
|
if (message.isNotEmpty) throw message;
|
||||||
|
});
|
||||||
|
appState.setProvider(
|
||||||
|
clashCore.getExternalProvider(provider.name),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
await globalState.appController.updateGroupDebounce();
|
||||||
|
}
|
||||||
|
|
||||||
|
_handleSideLoadProvider() async {
|
||||||
|
await globalState.safeRun<void>(() async {
|
||||||
|
final platformFile = await picker.pickerFile();
|
||||||
|
final appState = globalState.appController.appState;
|
||||||
|
final bytes = platformFile?.bytes;
|
||||||
|
if (bytes == null) return;
|
||||||
|
final file = await File(provider.path).create(recursive: true);
|
||||||
|
await file.writeAsBytes(bytes);
|
||||||
|
final providerName = provider.name;
|
||||||
|
var message = await clashCore.sideLoadExternalProvider(
|
||||||
|
providerName: providerName,
|
||||||
|
data: utf8.decode(bytes),
|
||||||
|
);
|
||||||
|
if (message.isNotEmpty) throw message;
|
||||||
|
appState.setProvider(
|
||||||
|
clashCore.getExternalProvider(provider.name),
|
||||||
|
);
|
||||||
|
if (message.isNotEmpty) throw message;
|
||||||
|
});
|
||||||
|
await globalState.appController.updateGroupDebounce();
|
||||||
|
}
|
||||||
|
|
||||||
|
String _buildProviderDesc() {
|
||||||
|
final baseInfo =
|
||||||
|
"${provider.type}(${provider.vehicleType}) · ${provider.updateAt.lastUpdateTimeDesc}";
|
||||||
|
final count = provider.count;
|
||||||
|
return switch (count == 0) {
|
||||||
|
true => baseInfo,
|
||||||
|
false => "$baseInfo · $count${appLocalizations.entries}",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return ListItem(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 16,
|
||||||
|
vertical: 4,
|
||||||
|
),
|
||||||
|
title: Text(provider.name),
|
||||||
|
subtitle: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
const SizedBox(
|
||||||
|
height: 4,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
_buildProviderDesc(),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
provider.path,
|
||||||
|
style: context.textTheme.bodyMedium?.toLight,
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 8,
|
||||||
|
),
|
||||||
|
Wrap(
|
||||||
|
runSpacing: 6,
|
||||||
|
spacing: 12,
|
||||||
|
children: [
|
||||||
|
CommonChip(
|
||||||
|
avatar: const Icon(Icons.upload),
|
||||||
|
label: appLocalizations.upload,
|
||||||
|
onPressed: _handleSideLoadProvider,
|
||||||
|
),
|
||||||
|
if (provider.vehicleType == "HTTP")
|
||||||
|
CommonChip(
|
||||||
|
avatar: const Icon(Icons.sync),
|
||||||
|
label: appLocalizations.sync,
|
||||||
|
onPressed: _handleUpdateProvider,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
trailing: SizedBox(
|
||||||
|
height: 48,
|
||||||
|
width: 48,
|
||||||
|
child: FadeBox(
|
||||||
|
child: provider.isUpdating
|
||||||
|
? const Padding(
|
||||||
|
padding: EdgeInsets.all(8),
|
||||||
|
child: CircularProgressIndicator(),
|
||||||
|
)
|
||||||
|
: const SizedBox(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@ import 'package:fl_clash/widgets/widgets.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
import 'providers.dart';
|
||||||
import 'setting.dart';
|
import 'setting.dart';
|
||||||
import 'tab.dart';
|
import 'tab.dart';
|
||||||
|
|
||||||
@@ -19,18 +20,37 @@ class ProxiesFragment extends StatefulWidget {
|
|||||||
class _ProxiesFragmentState extends State<ProxiesFragment> {
|
class _ProxiesFragmentState extends State<ProxiesFragment> {
|
||||||
final GlobalKey<ProxiesTabFragmentState> _proxiesTabKey = GlobalKey();
|
final GlobalKey<ProxiesTabFragmentState> _proxiesTabKey = GlobalKey();
|
||||||
|
|
||||||
_initActions(ProxiesType proxiesType) {
|
_initActions(ProxiesType proxiesType, bool hasProvider) {
|
||||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
||||||
final commonScaffoldState =
|
final commonScaffoldState =
|
||||||
context.findAncestorStateOfType<CommonScaffoldState>();
|
context.findAncestorStateOfType<CommonScaffoldState>();
|
||||||
commonScaffoldState?.actions = [
|
commonScaffoldState?.actions = [
|
||||||
|
if (hasProvider) ...[
|
||||||
|
IconButton(
|
||||||
|
onPressed: () {
|
||||||
|
showExtendPage(
|
||||||
|
forceNotSide: true,
|
||||||
|
extendPageWidth: 360,
|
||||||
|
context,
|
||||||
|
body: const Providers(),
|
||||||
|
title: appLocalizations.externalResources,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
icon: const Icon(
|
||||||
|
Icons.swap_vert_circle_outlined,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
width: 8,
|
||||||
|
),
|
||||||
|
],
|
||||||
if (proxiesType == ProxiesType.tab) ...[
|
if (proxiesType == ProxiesType.tab) ...[
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
_proxiesTabKey.currentState?.scrollToGroupSelected();
|
_proxiesTabKey.currentState?.scrollToGroupSelected();
|
||||||
},
|
},
|
||||||
icon: const Icon(
|
icon: const Icon(
|
||||||
Icons.gps_fixed,
|
Icons.adjust_outlined,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
@@ -60,18 +80,18 @@ class _ProxiesFragmentState extends State<ProxiesFragment> {
|
|||||||
return Selector<Config, ProxiesType>(
|
return Selector<Config, ProxiesType>(
|
||||||
selector: (_, config) => config.proxiesType,
|
selector: (_, config) => config.proxiesType,
|
||||||
builder: (_, proxiesType, __) {
|
builder: (_, proxiesType, __) {
|
||||||
return Selector<AppState, bool>(
|
return ProxiesActionsBuilder(
|
||||||
selector: (_, appState) => appState.currentLabel == 'proxies',
|
builder: (state, child) {
|
||||||
builder: (_, isCurrent, child) {
|
if (state.isCurrent) {
|
||||||
if (isCurrent) {
|
_initActions(proxiesType, state.hasProvider);
|
||||||
_initActions(proxiesType);
|
|
||||||
}
|
}
|
||||||
return switch (proxiesType) {
|
return child!;
|
||||||
ProxiesType.tab => ProxiesTabFragment(
|
},
|
||||||
key: _proxiesTabKey,
|
child: switch (proxiesType) {
|
||||||
),
|
ProxiesType.tab => ProxiesTabFragment(
|
||||||
ProxiesType.list => const ProxiesListFragment(),
|
key: _proxiesTabKey,
|
||||||
};
|
),
|
||||||
|
ProxiesType.list => const ProxiesListFragment(),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -33,6 +33,14 @@ class ProxiesSettingWidget extends StatelessWidget {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String getTextForProxiesLayout(ProxiesLayout proxiesLayout) {
|
||||||
|
return switch (proxiesLayout) {
|
||||||
|
ProxiesLayout.tight => appLocalizations.tight,
|
||||||
|
ProxiesLayout.standard => appLocalizations.standard,
|
||||||
|
ProxiesLayout.loose => appLocalizations.loose,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
List<Widget> _buildStyleSetting() {
|
List<Widget> _buildStyleSetting() {
|
||||||
return generateSection(
|
return generateSection(
|
||||||
title: appLocalizations.style,
|
title: appLocalizations.style,
|
||||||
@@ -132,36 +140,28 @@ class ProxiesSettingWidget extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Widget> _buildColumnsSetting() {
|
List<Widget> _buildLayoutSetting() {
|
||||||
return generateSection(
|
return generateSection(
|
||||||
title: appLocalizations.columns,
|
title: appLocalizations.layout,
|
||||||
items: [
|
items: [
|
||||||
SingleChildScrollView(
|
SingleChildScrollView(
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
horizontal: 16,
|
horizontal: 16,
|
||||||
),
|
),
|
||||||
scrollDirection: Axis.horizontal,
|
scrollDirection: Axis.horizontal,
|
||||||
child: Selector2<AppState, Config, ColumnsSelectorState>(
|
child: Selector< Config, ProxiesLayout>(
|
||||||
selector: (_, appState, config) => ColumnsSelectorState(
|
selector: (_, config) => config.proxiesLayout,
|
||||||
columns: config.proxiesColumns,
|
builder: (_, proxiesLayout, __) {
|
||||||
viewMode: appState.viewMode,
|
|
||||||
),
|
|
||||||
builder: (_, state, __) {
|
|
||||||
final config = globalState.appController.config;
|
final config = globalState.appController.config;
|
||||||
final targetColumnsArray = viewModeColumnsMap[state.viewMode]!;
|
|
||||||
final currentColumns = other.getColumns(
|
|
||||||
state.viewMode,
|
|
||||||
state.columns,
|
|
||||||
);
|
|
||||||
return Wrap(
|
return Wrap(
|
||||||
spacing: 16,
|
spacing: 16,
|
||||||
children: [
|
children: [
|
||||||
for (final item in targetColumnsArray)
|
for (final item in ProxiesLayout.values)
|
||||||
SettingTextCard(
|
SettingTextCard(
|
||||||
other.getColumnsTextForInt(item),
|
getTextForProxiesLayout(item),
|
||||||
isSelected: item == currentColumns,
|
isSelected: item == proxiesLayout,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
config.proxiesColumns = item;
|
config.proxiesLayout = item;
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
@@ -183,80 +183,10 @@ class ProxiesSettingWidget extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
..._buildStyleSetting(),
|
..._buildStyleSetting(),
|
||||||
..._buildSortSetting(),
|
..._buildSortSetting(),
|
||||||
..._buildColumnsSetting(),
|
..._buildLayoutSetting(),
|
||||||
..._buildSizeSetting(),
|
..._buildSizeSetting(),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class SettingInfoCard extends StatelessWidget {
|
|
||||||
final Info info;
|
|
||||||
final bool? isSelected;
|
|
||||||
final VoidCallback onPressed;
|
|
||||||
|
|
||||||
const SettingInfoCard(
|
|
||||||
this.info, {
|
|
||||||
super.key,
|
|
||||||
this.isSelected,
|
|
||||||
required this.onPressed,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return CommonCard(
|
|
||||||
isSelected: isSelected,
|
|
||||||
onPressed: onPressed,
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(12),
|
|
||||||
child: Row(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Flexible(
|
|
||||||
child: Icon(info.iconData),
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
width: 8,
|
|
||||||
),
|
|
||||||
Flexible(
|
|
||||||
child: Text(
|
|
||||||
info.label,
|
|
||||||
style: context.textTheme.bodyMedium,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class SettingTextCard extends StatelessWidget {
|
|
||||||
final String text;
|
|
||||||
final bool? isSelected;
|
|
||||||
final VoidCallback onPressed;
|
|
||||||
|
|
||||||
const SettingTextCard(
|
|
||||||
this.text, {
|
|
||||||
super.key,
|
|
||||||
this.isSelected,
|
|
||||||
required this.onPressed,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return CommonCard(
|
|
||||||
onPressed: onPressed,
|
|
||||||
isSelected: isSelected,
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(12),
|
|
||||||
child: Text(
|
|
||||||
text,
|
|
||||||
style: context.textTheme.bodyMedium,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
import 'package:fl_clash/common/common.dart';
|
import 'package:fl_clash/common/common.dart';
|
||||||
import 'package:fl_clash/enum/enum.dart';
|
import 'package:fl_clash/enum/enum.dart';
|
||||||
import 'package:fl_clash/fragments/proxies/setting.dart';
|
|
||||||
import 'package:fl_clash/models/models.dart';
|
import 'package:fl_clash/models/models.dart';
|
||||||
import 'package:fl_clash/state.dart';
|
import 'package:fl_clash/state.dart';
|
||||||
import 'package:fl_clash/widgets/widgets.dart';
|
import 'package:fl_clash/widgets/widgets.dart';
|
||||||
@@ -285,7 +284,10 @@ class ProxyGroupViewState extends State<ProxyGroupView> {
|
|||||||
return ProxyGroupSelectorState(
|
return ProxyGroupSelectorState(
|
||||||
proxyCardType: config.proxyCardType,
|
proxyCardType: config.proxyCardType,
|
||||||
proxiesSortType: config.proxiesSortType,
|
proxiesSortType: config.proxiesSortType,
|
||||||
columns: globalState.appController.columns,
|
columns: other.getProxiesColumns(
|
||||||
|
appState.viewWidth,
|
||||||
|
config.proxiesLayout,
|
||||||
|
),
|
||||||
sortNum: appState.sortNum,
|
sortNum: appState.sortNum,
|
||||||
proxies: group.all,
|
proxies: group.all,
|
||||||
groupType: group.type,
|
groupType: group.type,
|
||||||
|
|||||||
@@ -22,80 +22,11 @@ class GeoItem {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
class Resources extends StatefulWidget {
|
class Resources extends StatelessWidget {
|
||||||
const Resources({super.key});
|
const Resources({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<Resources> createState() => _ResourcesState();
|
Widget build(BuildContext context) {
|
||||||
}
|
|
||||||
|
|
||||||
class _ResourcesState extends State<Resources> {
|
|
||||||
List<ExternalProvider> externalProviders = [];
|
|
||||||
|
|
||||||
List<GlobalObjectKey<_ProviderItemState>> providerItemKeys = [];
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
||||||
_syncExternalProviders();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
_syncExternalProviders() async {
|
|
||||||
externalProviders = await clashCore.getExternalProviders();
|
|
||||||
if (mounted) {
|
|
||||||
setState(() {});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_updateProviders() async {
|
|
||||||
final updateProviders = providerItemKeys.map<Future>(
|
|
||||||
(key) async => await key.currentState?.updateProvider(false),
|
|
||||||
);
|
|
||||||
await Future.wait(updateProviders);
|
|
||||||
_syncExternalProviders();
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Widget> _buildExternalProviderSection() {
|
|
||||||
List<GlobalObjectKey<_ProviderItemState>> keys = [];
|
|
||||||
final res = generateInfoSection(
|
|
||||||
info: Info(
|
|
||||||
iconData: Icons.source,
|
|
||||||
label: appLocalizations.externalResources,
|
|
||||||
),
|
|
||||||
actions: [
|
|
||||||
IconButton.filledTonal(
|
|
||||||
onPressed: () {
|
|
||||||
_updateProviders();
|
|
||||||
},
|
|
||||||
padding: const EdgeInsets.all(4),
|
|
||||||
iconSize: 20,
|
|
||||||
icon: const Icon(
|
|
||||||
Icons.sync,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
items: externalProviders.map(
|
|
||||||
(externalProvider) {
|
|
||||||
final key =
|
|
||||||
GlobalObjectKey<_ProviderItemState>(externalProvider.name);
|
|
||||||
keys.add(key);
|
|
||||||
return ProviderItem(
|
|
||||||
key: key,
|
|
||||||
provider: externalProvider,
|
|
||||||
onUpdated: () {
|
|
||||||
_syncExternalProviders();
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
providerItemKeys = keys;
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Widget> _buildGeoDataSection() {
|
|
||||||
const geoItems = <GeoItem>[
|
const geoItems = <GeoItem>[
|
||||||
GeoItem(
|
GeoItem(
|
||||||
label: "GeoIp",
|
label: "GeoIp",
|
||||||
@@ -111,26 +42,19 @@ class _ResourcesState extends State<Resources> {
|
|||||||
GeoItem(label: "ASN", fileName: asnFileName, key: "asn"),
|
GeoItem(label: "ASN", fileName: asnFileName, key: "asn"),
|
||||||
];
|
];
|
||||||
|
|
||||||
return generateInfoSection(
|
return ListView.separated(
|
||||||
info: Info(
|
itemBuilder: (_, index) {
|
||||||
iconData: Icons.storage,
|
final geoItem = geoItems[index];
|
||||||
label: appLocalizations.geoData,
|
return GeoDataListItem(
|
||||||
),
|
|
||||||
items: geoItems.map(
|
|
||||||
(geoItem) => GeoDataListItem(
|
|
||||||
geoItem: geoItem,
|
geoItem: geoItem,
|
||||||
),
|
);
|
||||||
),
|
},
|
||||||
);
|
separatorBuilder: (BuildContext context, int index) {
|
||||||
}
|
return const Divider(
|
||||||
|
height: 0,
|
||||||
@override
|
);
|
||||||
Widget build(BuildContext context) {
|
},
|
||||||
return generateListView(
|
itemCount: geoItems.length,
|
||||||
[
|
|
||||||
..._buildGeoDataSection(),
|
|
||||||
..._buildExternalProviderSection(),
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -167,7 +91,6 @@ class _GeoDataListItemState extends State<GeoDataListItem> {
|
|||||||
final appController = globalState.appController;
|
final appController = globalState.appController;
|
||||||
appController.clashConfig.geoXUrl =
|
appController.clashConfig.geoXUrl =
|
||||||
Map.from(appController.clashConfig.geoXUrl)..[geoItem.key] = newUrl;
|
Map.from(appController.clashConfig.geoXUrl)..[geoItem.key] = newUrl;
|
||||||
appController.updateClashConfigDebounce();
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
globalState.showMessage(
|
globalState.showMessage(
|
||||||
title: geoItem.label,
|
title: geoItem.label,
|
||||||
@@ -226,9 +149,6 @@ class _GeoDataListItemState extends State<GeoDataListItem> {
|
|||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 8,
|
height: 8,
|
||||||
),
|
),
|
||||||
const SizedBox(
|
|
||||||
height: 8,
|
|
||||||
),
|
|
||||||
Wrap(
|
Wrap(
|
||||||
runSpacing: 6,
|
runSpacing: 6,
|
||||||
spacing: 12,
|
spacing: 12,
|
||||||
@@ -261,9 +181,9 @@ class _GeoDataListItemState extends State<GeoDataListItem> {
|
|||||||
updateGeoDateItem() async {
|
updateGeoDateItem() async {
|
||||||
isUpdating.value = true;
|
isUpdating.value = true;
|
||||||
try {
|
try {
|
||||||
final message = await clashCore.updateExternalProvider(
|
final message = await clashCore.updateGeoData(
|
||||||
providerName: geoItem.fileName,
|
geoName: geoItem.fileName,
|
||||||
providerType: geoItem.label,
|
geoType: geoItem.label,
|
||||||
);
|
);
|
||||||
if (message.isNotEmpty) throw message;
|
if (message.isNotEmpty) throw message;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -315,117 +235,6 @@ class _GeoDataListItemState extends State<GeoDataListItem> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ProviderItem extends StatefulWidget {
|
|
||||||
final ExternalProvider provider;
|
|
||||||
final Function onUpdated;
|
|
||||||
|
|
||||||
const ProviderItem({
|
|
||||||
super.key,
|
|
||||||
required this.provider,
|
|
||||||
required this.onUpdated,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<ProviderItem> createState() => _ProviderItemState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _ProviderItemState extends State<ProviderItem> {
|
|
||||||
final isUpdating = ValueNotifier<bool>(false);
|
|
||||||
|
|
||||||
ExternalProvider get provider => widget.provider;
|
|
||||||
|
|
||||||
_handleUpdateProfile() async {
|
|
||||||
await globalState.safeRun<void>(updateProvider);
|
|
||||||
widget.onUpdated();
|
|
||||||
}
|
|
||||||
|
|
||||||
updateProvider([isSingle = true]) async {
|
|
||||||
if (provider.vehicleType != "HTTP") return;
|
|
||||||
isUpdating.value = true;
|
|
||||||
try {
|
|
||||||
final message = await clashCore.updateExternalProvider(
|
|
||||||
providerName: provider.name,
|
|
||||||
providerType: provider.type,
|
|
||||||
);
|
|
||||||
if (message.isNotEmpty) throw message;
|
|
||||||
} catch (e) {
|
|
||||||
isUpdating.value = false;
|
|
||||||
if (!isSingle) {
|
|
||||||
return e.toString();
|
|
||||||
} else {
|
|
||||||
rethrow;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
isUpdating.value = false;
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
String _buildProviderDesc() {
|
|
||||||
return "${provider.type} (${provider.vehicleType}) · ${provider.updateAt.lastUpdateTimeDesc}";
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
super.dispose();
|
|
||||||
isUpdating.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildSubtitle() {
|
|
||||||
return Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
const SizedBox(
|
|
||||||
height: 4,
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
_buildProviderDesc(),
|
|
||||||
),
|
|
||||||
if (provider.vehicleType == "HTTP") ...[
|
|
||||||
const SizedBox(
|
|
||||||
height: 8,
|
|
||||||
),
|
|
||||||
CommonChip(
|
|
||||||
avatar: const Icon(Icons.sync),
|
|
||||||
label: appLocalizations.sync,
|
|
||||||
onPressed: () {
|
|
||||||
_handleUpdateProfile();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return ListItem(
|
|
||||||
padding: const EdgeInsets.symmetric(
|
|
||||||
horizontal: 16,
|
|
||||||
vertical: 4,
|
|
||||||
),
|
|
||||||
title: Text(provider.name),
|
|
||||||
subtitle: _buildSubtitle(),
|
|
||||||
trailing: SizedBox(
|
|
||||||
height: 48,
|
|
||||||
width: 48,
|
|
||||||
child: ValueListenableBuilder(
|
|
||||||
valueListenable: isUpdating,
|
|
||||||
builder: (_, isUpdating, ___) {
|
|
||||||
return FadeBox(
|
|
||||||
child: isUpdating
|
|
||||||
? const Padding(
|
|
||||||
padding: EdgeInsets.all(8),
|
|
||||||
child: CircularProgressIndicator(),
|
|
||||||
)
|
|
||||||
: const SizedBox(),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class UpdateGeoUrlFormDialog extends StatefulWidget {
|
class UpdateGeoUrlFormDialog extends StatefulWidget {
|
||||||
final String title;
|
final String title;
|
||||||
final String url;
|
final String url;
|
||||||
|
|||||||
@@ -26,9 +26,7 @@ class ThemeFragment extends StatelessWidget {
|
|||||||
final previewCard = Padding(
|
final previewCard = Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
child: CommonCard(
|
child: CommonCard(
|
||||||
onPressed: (){
|
onPressed: () {},
|
||||||
|
|
||||||
},
|
|
||||||
info: Info(
|
info: Info(
|
||||||
label: appLocalizations.preview,
|
label: appLocalizations.preview,
|
||||||
iconData: Icons.looks,
|
iconData: Icons.looks,
|
||||||
@@ -87,7 +85,6 @@ class ThemeColorsBox extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _ThemeColorsBoxState extends State<ThemeColorsBox> {
|
class _ThemeColorsBoxState extends State<ThemeColorsBox> {
|
||||||
|
|
||||||
Widget _themeModeCheckBox({
|
Widget _themeModeCheckBox({
|
||||||
bool? isSelected,
|
bool? isSelected,
|
||||||
required ThemeModeItem themeModeItem,
|
required ThemeModeItem themeModeItem,
|
||||||
@@ -229,6 +226,27 @@ class _ThemeColorsBoxState extends State<ThemeColorsBox> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||||
|
child: Selector<Config, bool>(
|
||||||
|
selector: (_, config) => config.prueBlack,
|
||||||
|
builder: (_, value, ___) {
|
||||||
|
return ListItem.switchItem(
|
||||||
|
leading: Icon(
|
||||||
|
Icons.contrast,
|
||||||
|
color: context.colorScheme.primary,
|
||||||
|
),
|
||||||
|
title: Text(appLocalizations.prueBlackMode),
|
||||||
|
delegate: SwitchDelegate(
|
||||||
|
value: value,
|
||||||
|
onChanged: (value){
|
||||||
|
globalState.appController.config.prueBlack = value;
|
||||||
|
}
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
)
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@
|
|||||||
"overrideDesc": "Override Proxy related config",
|
"overrideDesc": "Override Proxy related config",
|
||||||
"allowLan": "AllowLan",
|
"allowLan": "AllowLan",
|
||||||
"allowLanDesc": "Allow access proxy through the LAN",
|
"allowLanDesc": "Allow access proxy through the LAN",
|
||||||
"tun": "TUN mode",
|
"tun": "TUN",
|
||||||
"tunDesc": "only effective in administrator mode",
|
"tunDesc": "only effective in administrator mode",
|
||||||
"minimizeOnExit": "Minimize on exit",
|
"minimizeOnExit": "Minimize on exit",
|
||||||
"minimizeOnExitDesc": "Modify the default system exit event",
|
"minimizeOnExitDesc": "Modify the default system exit event",
|
||||||
@@ -66,6 +66,7 @@
|
|||||||
"hours": "Hours",
|
"hours": "Hours",
|
||||||
"days": "Days",
|
"days": "Days",
|
||||||
"minutes": "Minutes",
|
"minutes": "Minutes",
|
||||||
|
"seconds": "Seconds",
|
||||||
"ago": " Ago",
|
"ago": " Ago",
|
||||||
"just": "Just",
|
"just": "Just",
|
||||||
"qrcode": "QR code",
|
"qrcode": "QR code",
|
||||||
@@ -116,7 +117,7 @@
|
|||||||
"logLevel": "LogLevel",
|
"logLevel": "LogLevel",
|
||||||
"show": "Show",
|
"show": "Show",
|
||||||
"exit": "Exit",
|
"exit": "Exit",
|
||||||
"systemProxy": "SystemProxy",
|
"systemProxy": "System proxy",
|
||||||
"project": "Project",
|
"project": "Project",
|
||||||
"core": "Core",
|
"core": "Core",
|
||||||
"tabAnimation": "Tab animation",
|
"tabAnimation": "Tab animation",
|
||||||
@@ -130,12 +131,10 @@
|
|||||||
"notSelectedTip": "The current proxy group cannot be selected.",
|
"notSelectedTip": "The current proxy group cannot be selected.",
|
||||||
"tip": "tip",
|
"tip": "tip",
|
||||||
"backupAndRecovery": "Backup and Recovery",
|
"backupAndRecovery": "Backup and Recovery",
|
||||||
"backupAndRecoveryDesc": "Sync data by WebDAV",
|
"backupAndRecoveryDesc": "Sync data via WebDAV or file",
|
||||||
"account": "Account",
|
"account": "Account",
|
||||||
"backup": "Backup",
|
"backup": "Backup",
|
||||||
"backupDesc": "Backup local data to WebDAV",
|
|
||||||
"recovery": "Recovery",
|
"recovery": "Recovery",
|
||||||
"recoveryDesc": "Recovery data from WebDAV",
|
|
||||||
"recoveryProfiles": "Only recovery profiles",
|
"recoveryProfiles": "Only recovery profiles",
|
||||||
"recoveryAll": "Recovery all data",
|
"recoveryAll": "Recovery all data",
|
||||||
"recoverySuccess": "Recovery success",
|
"recoverySuccess": "Recovery success",
|
||||||
@@ -219,5 +218,30 @@
|
|||||||
"autoCloseConnectionsDesc": "Auto close connections after change node",
|
"autoCloseConnectionsDesc": "Auto close connections after change node",
|
||||||
"onlyStatisticsProxy": "Only statistics proxy",
|
"onlyStatisticsProxy": "Only statistics proxy",
|
||||||
"onlyStatisticsProxyDesc": "When turned on, only statistics proxy traffic",
|
"onlyStatisticsProxyDesc": "When turned on, only statistics proxy traffic",
|
||||||
"deleteProfileTip": "Sure you want to delete the current profile?"
|
"deleteProfileTip": "Sure you want to delete the current profile?",
|
||||||
|
"prueBlackMode": "Prue black mode",
|
||||||
|
"keepAliveIntervalDesc": "Tcp keep alive interval",
|
||||||
|
"entries": " entries",
|
||||||
|
"local": "Local",
|
||||||
|
"remote": "Remote",
|
||||||
|
"remoteBackupDesc": "Backup local data to WebDAV",
|
||||||
|
"remoteRecoveryDesc": "Recovery data from WebDAV",
|
||||||
|
"localBackupDesc": "Backup local data to local",
|
||||||
|
"localRecoveryDesc": "Recovery data from file",
|
||||||
|
"mode": "Mode",
|
||||||
|
"time": "Time",
|
||||||
|
"source": "Source",
|
||||||
|
"allApps": "All apps",
|
||||||
|
"onlyOtherApps": "Only third-party apps",
|
||||||
|
"action": "Action",
|
||||||
|
"intelligentSelected": "Intelligent selection",
|
||||||
|
"clipboardImport": "Clipboard import",
|
||||||
|
"clipboardExport": "Export clipboard",
|
||||||
|
"layout": "Layout",
|
||||||
|
"tight": "Tight",
|
||||||
|
"standard": "Standard",
|
||||||
|
"loose": "Loose",
|
||||||
|
"profilesSort": "Profiles sort",
|
||||||
|
"start": "Start",
|
||||||
|
"stop": "Stop"
|
||||||
}
|
}
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
"overrideDesc": "覆写代理相关配置",
|
"overrideDesc": "覆写代理相关配置",
|
||||||
"allowLan": "局域网代理",
|
"allowLan": "局域网代理",
|
||||||
"allowLanDesc": "允许通过局域网访问代理",
|
"allowLanDesc": "允许通过局域网访问代理",
|
||||||
"tun": "TUN模式",
|
"tun": "虚拟网卡",
|
||||||
"tunDesc": "仅在管理员模式生效",
|
"tunDesc": "仅在管理员模式生效",
|
||||||
"minimizeOnExit": "退出时最小化",
|
"minimizeOnExit": "退出时最小化",
|
||||||
"minimizeOnExitDesc": "修改系统默认退出事件",
|
"minimizeOnExitDesc": "修改系统默认退出事件",
|
||||||
@@ -66,6 +66,7 @@
|
|||||||
"hours": "小时",
|
"hours": "小时",
|
||||||
"days": "天",
|
"days": "天",
|
||||||
"minutes": "分钟",
|
"minutes": "分钟",
|
||||||
|
"seconds": "秒",
|
||||||
"ago": "前",
|
"ago": "前",
|
||||||
"just": "刚刚",
|
"just": "刚刚",
|
||||||
"qrcode": "二维码",
|
"qrcode": "二维码",
|
||||||
@@ -130,12 +131,10 @@
|
|||||||
"notSelectedTip": "当前代理组无法选中",
|
"notSelectedTip": "当前代理组无法选中",
|
||||||
"tip": "提示",
|
"tip": "提示",
|
||||||
"backupAndRecovery": "备份与恢复",
|
"backupAndRecovery": "备份与恢复",
|
||||||
"backupAndRecoveryDesc": "通过WebDAV同步数据",
|
"backupAndRecoveryDesc": "通过WebDAV或者文件同步数据",
|
||||||
"account": "账号",
|
"account": "账号",
|
||||||
"backup": "备份",
|
"backup": "备份",
|
||||||
"backupDesc": "备份数据到WebDAV",
|
|
||||||
"recovery": "恢复",
|
"recovery": "恢复",
|
||||||
"recoveryDesc": "从WebDAV恢复数据",
|
|
||||||
"recoveryProfiles": "仅恢复配置文件",
|
"recoveryProfiles": "仅恢复配置文件",
|
||||||
"recoveryAll": "恢复所有数据",
|
"recoveryAll": "恢复所有数据",
|
||||||
"recoverySuccess": "恢复成功",
|
"recoverySuccess": "恢复成功",
|
||||||
@@ -219,5 +218,30 @@
|
|||||||
"autoCloseConnectionsDesc": "切换节点后自动关闭连接",
|
"autoCloseConnectionsDesc": "切换节点后自动关闭连接",
|
||||||
"onlyStatisticsProxy": "仅统计代理",
|
"onlyStatisticsProxy": "仅统计代理",
|
||||||
"onlyStatisticsProxyDesc": "开启后,将只统计代理流量",
|
"onlyStatisticsProxyDesc": "开启后,将只统计代理流量",
|
||||||
"deleteProfileTip": "确定要删除当前配置吗?"
|
"deleteProfileTip": "确定要删除当前配置吗?",
|
||||||
|
"prueBlackMode": "纯黑模式",
|
||||||
|
"keepAliveIntervalDesc": "TCP保持活动间隔",
|
||||||
|
"entries": "个条目",
|
||||||
|
"local": "本地",
|
||||||
|
"remote": "远程",
|
||||||
|
"remoteBackupDesc": "备份数据到WebDAV",
|
||||||
|
"remoteRecoveryDesc": "通过WebDAV恢复数据",
|
||||||
|
"localBackupDesc": "备份数据到本地",
|
||||||
|
"localRecoveryDesc": "通过文件恢复数据",
|
||||||
|
"mode": "模式",
|
||||||
|
"time": "时间",
|
||||||
|
"source": "来源",
|
||||||
|
"allApps": "所有应用",
|
||||||
|
"onlyOtherApps": "仅第三方应用",
|
||||||
|
"action": "操作",
|
||||||
|
"intelligentSelected": "智能选择",
|
||||||
|
"clipboardImport": "剪贴板导入",
|
||||||
|
"clipboardExport": "导出剪贴板",
|
||||||
|
"layout": "布局",
|
||||||
|
"tight": "宽松",
|
||||||
|
"standard": "标准",
|
||||||
|
"loose": "紧凑",
|
||||||
|
"profilesSort": "配置排序",
|
||||||
|
"start": "启动",
|
||||||
|
"stop": "暂停"
|
||||||
}
|
}
|
||||||
@@ -33,6 +33,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
"account": MessageLookupByLibrary.simpleMessage("Account"),
|
"account": MessageLookupByLibrary.simpleMessage("Account"),
|
||||||
"accountTip":
|
"accountTip":
|
||||||
MessageLookupByLibrary.simpleMessage("Account cannot be empty"),
|
MessageLookupByLibrary.simpleMessage("Account cannot be empty"),
|
||||||
|
"action": MessageLookupByLibrary.simpleMessage("Action"),
|
||||||
"add": MessageLookupByLibrary.simpleMessage("Add"),
|
"add": MessageLookupByLibrary.simpleMessage("Add"),
|
||||||
"address": MessageLookupByLibrary.simpleMessage("Address"),
|
"address": MessageLookupByLibrary.simpleMessage("Address"),
|
||||||
"addressHelp":
|
"addressHelp":
|
||||||
@@ -40,6 +41,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
"addressTip": MessageLookupByLibrary.simpleMessage(
|
"addressTip": MessageLookupByLibrary.simpleMessage(
|
||||||
"Please enter a valid WebDAV address"),
|
"Please enter a valid WebDAV address"),
|
||||||
"ago": MessageLookupByLibrary.simpleMessage(" Ago"),
|
"ago": MessageLookupByLibrary.simpleMessage(" Ago"),
|
||||||
|
"allApps": MessageLookupByLibrary.simpleMessage("All apps"),
|
||||||
"allowBypass": MessageLookupByLibrary.simpleMessage(
|
"allowBypass": MessageLookupByLibrary.simpleMessage(
|
||||||
"Allow applications to bypass VPN"),
|
"Allow applications to bypass VPN"),
|
||||||
"allowBypassDesc": MessageLookupByLibrary.simpleMessage(
|
"allowBypassDesc": MessageLookupByLibrary.simpleMessage(
|
||||||
@@ -74,10 +76,8 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
"backup": MessageLookupByLibrary.simpleMessage("Backup"),
|
"backup": MessageLookupByLibrary.simpleMessage("Backup"),
|
||||||
"backupAndRecovery":
|
"backupAndRecovery":
|
||||||
MessageLookupByLibrary.simpleMessage("Backup and Recovery"),
|
MessageLookupByLibrary.simpleMessage("Backup and Recovery"),
|
||||||
"backupAndRecoveryDesc":
|
"backupAndRecoveryDesc": MessageLookupByLibrary.simpleMessage(
|
||||||
MessageLookupByLibrary.simpleMessage("Sync data by WebDAV"),
|
"Sync data via WebDAV or file"),
|
||||||
"backupDesc":
|
|
||||||
MessageLookupByLibrary.simpleMessage("Backup local data to WebDAV"),
|
|
||||||
"backupSuccess": MessageLookupByLibrary.simpleMessage("Backup success"),
|
"backupSuccess": MessageLookupByLibrary.simpleMessage("Backup success"),
|
||||||
"bind": MessageLookupByLibrary.simpleMessage("Bind"),
|
"bind": MessageLookupByLibrary.simpleMessage("Bind"),
|
||||||
"blacklistMode": MessageLookupByLibrary.simpleMessage("Blacklist mode"),
|
"blacklistMode": MessageLookupByLibrary.simpleMessage("Blacklist mode"),
|
||||||
@@ -91,6 +91,10 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
"checkUpdateError": MessageLookupByLibrary.simpleMessage(
|
"checkUpdateError": MessageLookupByLibrary.simpleMessage(
|
||||||
"The current application is already the latest version"),
|
"The current application is already the latest version"),
|
||||||
"checking": MessageLookupByLibrary.simpleMessage("Checking..."),
|
"checking": MessageLookupByLibrary.simpleMessage("Checking..."),
|
||||||
|
"clipboardExport":
|
||||||
|
MessageLookupByLibrary.simpleMessage("Export clipboard"),
|
||||||
|
"clipboardImport":
|
||||||
|
MessageLookupByLibrary.simpleMessage("Clipboard import"),
|
||||||
"columns": MessageLookupByLibrary.simpleMessage("Columns"),
|
"columns": MessageLookupByLibrary.simpleMessage("Columns"),
|
||||||
"compatible":
|
"compatible":
|
||||||
MessageLookupByLibrary.simpleMessage("Compatibility mode"),
|
MessageLookupByLibrary.simpleMessage("Compatibility mode"),
|
||||||
@@ -129,6 +133,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
"download": MessageLookupByLibrary.simpleMessage("Download"),
|
"download": MessageLookupByLibrary.simpleMessage("Download"),
|
||||||
"edit": MessageLookupByLibrary.simpleMessage("Edit"),
|
"edit": MessageLookupByLibrary.simpleMessage("Edit"),
|
||||||
"en": MessageLookupByLibrary.simpleMessage("English"),
|
"en": MessageLookupByLibrary.simpleMessage("English"),
|
||||||
|
"entries": MessageLookupByLibrary.simpleMessage(" entries"),
|
||||||
"exclude":
|
"exclude":
|
||||||
MessageLookupByLibrary.simpleMessage("Hidden from recent tasks"),
|
MessageLookupByLibrary.simpleMessage("Hidden from recent tasks"),
|
||||||
"excludeDesc": MessageLookupByLibrary.simpleMessage(
|
"excludeDesc": MessageLookupByLibrary.simpleMessage(
|
||||||
@@ -168,25 +173,37 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
"infiniteTime":
|
"infiniteTime":
|
||||||
MessageLookupByLibrary.simpleMessage("Long term effective"),
|
MessageLookupByLibrary.simpleMessage("Long term effective"),
|
||||||
"init": MessageLookupByLibrary.simpleMessage("Init"),
|
"init": MessageLookupByLibrary.simpleMessage("Init"),
|
||||||
|
"intelligentSelected":
|
||||||
|
MessageLookupByLibrary.simpleMessage("Intelligent selection"),
|
||||||
"intranetIP": MessageLookupByLibrary.simpleMessage("Intranet IP"),
|
"intranetIP": MessageLookupByLibrary.simpleMessage("Intranet IP"),
|
||||||
"ipv6Desc": MessageLookupByLibrary.simpleMessage(
|
"ipv6Desc": MessageLookupByLibrary.simpleMessage(
|
||||||
"When turned on it will be able to receive IPv6 traffic"),
|
"When turned on it will be able to receive IPv6 traffic"),
|
||||||
"just": MessageLookupByLibrary.simpleMessage("Just"),
|
"just": MessageLookupByLibrary.simpleMessage("Just"),
|
||||||
|
"keepAliveIntervalDesc":
|
||||||
|
MessageLookupByLibrary.simpleMessage("Tcp keep alive interval"),
|
||||||
"language": MessageLookupByLibrary.simpleMessage("Language"),
|
"language": MessageLookupByLibrary.simpleMessage("Language"),
|
||||||
|
"layout": MessageLookupByLibrary.simpleMessage("Layout"),
|
||||||
"light": MessageLookupByLibrary.simpleMessage("Light"),
|
"light": MessageLookupByLibrary.simpleMessage("Light"),
|
||||||
"list": MessageLookupByLibrary.simpleMessage("List"),
|
"list": MessageLookupByLibrary.simpleMessage("List"),
|
||||||
|
"local": MessageLookupByLibrary.simpleMessage("Local"),
|
||||||
|
"localBackupDesc":
|
||||||
|
MessageLookupByLibrary.simpleMessage("Backup local data to local"),
|
||||||
|
"localRecoveryDesc":
|
||||||
|
MessageLookupByLibrary.simpleMessage("Recovery data from file"),
|
||||||
"logLevel": MessageLookupByLibrary.simpleMessage("LogLevel"),
|
"logLevel": MessageLookupByLibrary.simpleMessage("LogLevel"),
|
||||||
"logcat": MessageLookupByLibrary.simpleMessage("Logcat"),
|
"logcat": MessageLookupByLibrary.simpleMessage("Logcat"),
|
||||||
"logcatDesc": MessageLookupByLibrary.simpleMessage(
|
"logcatDesc": MessageLookupByLibrary.simpleMessage(
|
||||||
"Disabling will hide the log entry"),
|
"Disabling will hide the log entry"),
|
||||||
"logs": MessageLookupByLibrary.simpleMessage("Logs"),
|
"logs": MessageLookupByLibrary.simpleMessage("Logs"),
|
||||||
"logsDesc": MessageLookupByLibrary.simpleMessage("Log capture records"),
|
"logsDesc": MessageLookupByLibrary.simpleMessage("Log capture records"),
|
||||||
|
"loose": MessageLookupByLibrary.simpleMessage("Loose"),
|
||||||
"min": MessageLookupByLibrary.simpleMessage("Min"),
|
"min": MessageLookupByLibrary.simpleMessage("Min"),
|
||||||
"minimizeOnExit":
|
"minimizeOnExit":
|
||||||
MessageLookupByLibrary.simpleMessage("Minimize on exit"),
|
MessageLookupByLibrary.simpleMessage("Minimize on exit"),
|
||||||
"minimizeOnExitDesc": MessageLookupByLibrary.simpleMessage(
|
"minimizeOnExitDesc": MessageLookupByLibrary.simpleMessage(
|
||||||
"Modify the default system exit event"),
|
"Modify the default system exit event"),
|
||||||
"minutes": MessageLookupByLibrary.simpleMessage("Minutes"),
|
"minutes": MessageLookupByLibrary.simpleMessage("Minutes"),
|
||||||
|
"mode": MessageLookupByLibrary.simpleMessage("Mode"),
|
||||||
"months": MessageLookupByLibrary.simpleMessage("Months"),
|
"months": MessageLookupByLibrary.simpleMessage("Months"),
|
||||||
"more": MessageLookupByLibrary.simpleMessage("More"),
|
"more": MessageLookupByLibrary.simpleMessage("More"),
|
||||||
"name": MessageLookupByLibrary.simpleMessage("Name"),
|
"name": MessageLookupByLibrary.simpleMessage("Name"),
|
||||||
@@ -210,6 +227,8 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
"No profile, Please add a profile"),
|
"No profile, Please add a profile"),
|
||||||
"nullRequestsDesc": MessageLookupByLibrary.simpleMessage("No requests"),
|
"nullRequestsDesc": MessageLookupByLibrary.simpleMessage("No requests"),
|
||||||
"oneColumn": MessageLookupByLibrary.simpleMessage("One column"),
|
"oneColumn": MessageLookupByLibrary.simpleMessage("One column"),
|
||||||
|
"onlyOtherApps":
|
||||||
|
MessageLookupByLibrary.simpleMessage("Only third-party apps"),
|
||||||
"onlyStatisticsProxy":
|
"onlyStatisticsProxy":
|
||||||
MessageLookupByLibrary.simpleMessage("Only statistics proxy"),
|
MessageLookupByLibrary.simpleMessage("Only statistics proxy"),
|
||||||
"onlyStatisticsProxyDesc": MessageLookupByLibrary.simpleMessage(
|
"onlyStatisticsProxyDesc": MessageLookupByLibrary.simpleMessage(
|
||||||
@@ -249,6 +268,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
"profileUrlNullValidationDesc": MessageLookupByLibrary.simpleMessage(
|
"profileUrlNullValidationDesc": MessageLookupByLibrary.simpleMessage(
|
||||||
"Please input the profile URL"),
|
"Please input the profile URL"),
|
||||||
"profiles": MessageLookupByLibrary.simpleMessage("Profiles"),
|
"profiles": MessageLookupByLibrary.simpleMessage("Profiles"),
|
||||||
|
"profilesSort": MessageLookupByLibrary.simpleMessage("Profiles sort"),
|
||||||
"project": MessageLookupByLibrary.simpleMessage("Project"),
|
"project": MessageLookupByLibrary.simpleMessage("Project"),
|
||||||
"proxies": MessageLookupByLibrary.simpleMessage("Proxies"),
|
"proxies": MessageLookupByLibrary.simpleMessage("Proxies"),
|
||||||
"proxiesSetting":
|
"proxiesSetting":
|
||||||
@@ -257,18 +277,23 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
"proxyPort": MessageLookupByLibrary.simpleMessage("ProxyPort"),
|
"proxyPort": MessageLookupByLibrary.simpleMessage("ProxyPort"),
|
||||||
"proxyPortDesc": MessageLookupByLibrary.simpleMessage(
|
"proxyPortDesc": MessageLookupByLibrary.simpleMessage(
|
||||||
"Set the Clash listening port"),
|
"Set the Clash listening port"),
|
||||||
|
"prueBlackMode":
|
||||||
|
MessageLookupByLibrary.simpleMessage("Prue black mode"),
|
||||||
"qrcode": MessageLookupByLibrary.simpleMessage("QR code"),
|
"qrcode": MessageLookupByLibrary.simpleMessage("QR code"),
|
||||||
"qrcodeDesc": MessageLookupByLibrary.simpleMessage(
|
"qrcodeDesc": MessageLookupByLibrary.simpleMessage(
|
||||||
"Scan QR code to obtain profile"),
|
"Scan QR code to obtain profile"),
|
||||||
"recovery": MessageLookupByLibrary.simpleMessage("Recovery"),
|
"recovery": MessageLookupByLibrary.simpleMessage("Recovery"),
|
||||||
"recoveryAll":
|
"recoveryAll":
|
||||||
MessageLookupByLibrary.simpleMessage("Recovery all data"),
|
MessageLookupByLibrary.simpleMessage("Recovery all data"),
|
||||||
"recoveryDesc":
|
|
||||||
MessageLookupByLibrary.simpleMessage("Recovery data from WebDAV"),
|
|
||||||
"recoveryProfiles":
|
"recoveryProfiles":
|
||||||
MessageLookupByLibrary.simpleMessage("Only recovery profiles"),
|
MessageLookupByLibrary.simpleMessage("Only recovery profiles"),
|
||||||
"recoverySuccess":
|
"recoverySuccess":
|
||||||
MessageLookupByLibrary.simpleMessage("Recovery success"),
|
MessageLookupByLibrary.simpleMessage("Recovery success"),
|
||||||
|
"remote": MessageLookupByLibrary.simpleMessage("Remote"),
|
||||||
|
"remoteBackupDesc":
|
||||||
|
MessageLookupByLibrary.simpleMessage("Backup local data to WebDAV"),
|
||||||
|
"remoteRecoveryDesc":
|
||||||
|
MessageLookupByLibrary.simpleMessage("Recovery data from WebDAV"),
|
||||||
"requests": MessageLookupByLibrary.simpleMessage("Requests"),
|
"requests": MessageLookupByLibrary.simpleMessage("Requests"),
|
||||||
"requestsDesc": MessageLookupByLibrary.simpleMessage(
|
"requestsDesc": MessageLookupByLibrary.simpleMessage(
|
||||||
"View recently request records"),
|
"View recently request records"),
|
||||||
@@ -278,6 +303,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
"rule": MessageLookupByLibrary.simpleMessage("Rule"),
|
"rule": MessageLookupByLibrary.simpleMessage("Rule"),
|
||||||
"save": MessageLookupByLibrary.simpleMessage("Save"),
|
"save": MessageLookupByLibrary.simpleMessage("Save"),
|
||||||
"search": MessageLookupByLibrary.simpleMessage("Search"),
|
"search": MessageLookupByLibrary.simpleMessage("Search"),
|
||||||
|
"seconds": MessageLookupByLibrary.simpleMessage("Seconds"),
|
||||||
"selectAll": MessageLookupByLibrary.simpleMessage("Select all"),
|
"selectAll": MessageLookupByLibrary.simpleMessage("Select all"),
|
||||||
"selected": MessageLookupByLibrary.simpleMessage("Selected"),
|
"selected": MessageLookupByLibrary.simpleMessage("Selected"),
|
||||||
"settings": MessageLookupByLibrary.simpleMessage("Settings"),
|
"settings": MessageLookupByLibrary.simpleMessage("Settings"),
|
||||||
@@ -288,12 +314,16 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
MessageLookupByLibrary.simpleMessage("Start in the background"),
|
MessageLookupByLibrary.simpleMessage("Start in the background"),
|
||||||
"size": MessageLookupByLibrary.simpleMessage("Size"),
|
"size": MessageLookupByLibrary.simpleMessage("Size"),
|
||||||
"sort": MessageLookupByLibrary.simpleMessage("Sort"),
|
"sort": MessageLookupByLibrary.simpleMessage("Sort"),
|
||||||
|
"source": MessageLookupByLibrary.simpleMessage("Source"),
|
||||||
|
"standard": MessageLookupByLibrary.simpleMessage("Standard"),
|
||||||
|
"start": MessageLookupByLibrary.simpleMessage("Start"),
|
||||||
"startVpn": MessageLookupByLibrary.simpleMessage("Staring VPN..."),
|
"startVpn": MessageLookupByLibrary.simpleMessage("Staring VPN..."),
|
||||||
|
"stop": MessageLookupByLibrary.simpleMessage("Stop"),
|
||||||
"stopVpn": MessageLookupByLibrary.simpleMessage("Stopping VPN..."),
|
"stopVpn": MessageLookupByLibrary.simpleMessage("Stopping VPN..."),
|
||||||
"style": MessageLookupByLibrary.simpleMessage("Style"),
|
"style": MessageLookupByLibrary.simpleMessage("Style"),
|
||||||
"submit": MessageLookupByLibrary.simpleMessage("Submit"),
|
"submit": MessageLookupByLibrary.simpleMessage("Submit"),
|
||||||
"sync": MessageLookupByLibrary.simpleMessage("Sync"),
|
"sync": MessageLookupByLibrary.simpleMessage("Sync"),
|
||||||
"systemProxy": MessageLookupByLibrary.simpleMessage("SystemProxy"),
|
"systemProxy": MessageLookupByLibrary.simpleMessage("System proxy"),
|
||||||
"systemProxyDesc": MessageLookupByLibrary.simpleMessage(
|
"systemProxyDesc": MessageLookupByLibrary.simpleMessage(
|
||||||
"Attach HTTP proxy to VpnService"),
|
"Attach HTTP proxy to VpnService"),
|
||||||
"tab": MessageLookupByLibrary.simpleMessage("Tab"),
|
"tab": MessageLookupByLibrary.simpleMessage("Tab"),
|
||||||
@@ -310,10 +340,12 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
"Set dark mode,adjust the color"),
|
"Set dark mode,adjust the color"),
|
||||||
"themeMode": MessageLookupByLibrary.simpleMessage("Theme mode"),
|
"themeMode": MessageLookupByLibrary.simpleMessage("Theme mode"),
|
||||||
"threeColumns": MessageLookupByLibrary.simpleMessage("Three columns"),
|
"threeColumns": MessageLookupByLibrary.simpleMessage("Three columns"),
|
||||||
|
"tight": MessageLookupByLibrary.simpleMessage("Tight"),
|
||||||
|
"time": MessageLookupByLibrary.simpleMessage("Time"),
|
||||||
"tip": MessageLookupByLibrary.simpleMessage("tip"),
|
"tip": MessageLookupByLibrary.simpleMessage("tip"),
|
||||||
"tools": MessageLookupByLibrary.simpleMessage("Tools"),
|
"tools": MessageLookupByLibrary.simpleMessage("Tools"),
|
||||||
"trafficUsage": MessageLookupByLibrary.simpleMessage("Traffic usage"),
|
"trafficUsage": MessageLookupByLibrary.simpleMessage("Traffic usage"),
|
||||||
"tun": MessageLookupByLibrary.simpleMessage("TUN mode"),
|
"tun": MessageLookupByLibrary.simpleMessage("TUN"),
|
||||||
"tunDesc": MessageLookupByLibrary.simpleMessage(
|
"tunDesc": MessageLookupByLibrary.simpleMessage(
|
||||||
"only effective in administrator mode"),
|
"only effective in administrator mode"),
|
||||||
"twoColumns": MessageLookupByLibrary.simpleMessage("Two columns"),
|
"twoColumns": MessageLookupByLibrary.simpleMessage("Two columns"),
|
||||||
|
|||||||
@@ -31,11 +31,13 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
MessageLookupByLibrary.simpleMessage("选中应用将会被排除在VPN之外"),
|
MessageLookupByLibrary.simpleMessage("选中应用将会被排除在VPN之外"),
|
||||||
"account": MessageLookupByLibrary.simpleMessage("账号"),
|
"account": MessageLookupByLibrary.simpleMessage("账号"),
|
||||||
"accountTip": MessageLookupByLibrary.simpleMessage("账号不能为空"),
|
"accountTip": MessageLookupByLibrary.simpleMessage("账号不能为空"),
|
||||||
|
"action": MessageLookupByLibrary.simpleMessage("操作"),
|
||||||
"add": MessageLookupByLibrary.simpleMessage("添加"),
|
"add": MessageLookupByLibrary.simpleMessage("添加"),
|
||||||
"address": MessageLookupByLibrary.simpleMessage("地址"),
|
"address": MessageLookupByLibrary.simpleMessage("地址"),
|
||||||
"addressHelp": MessageLookupByLibrary.simpleMessage("WebDAV服务器地址"),
|
"addressHelp": MessageLookupByLibrary.simpleMessage("WebDAV服务器地址"),
|
||||||
"addressTip": MessageLookupByLibrary.simpleMessage("请输入有效的WebDAV地址"),
|
"addressTip": MessageLookupByLibrary.simpleMessage("请输入有效的WebDAV地址"),
|
||||||
"ago": MessageLookupByLibrary.simpleMessage("前"),
|
"ago": MessageLookupByLibrary.simpleMessage("前"),
|
||||||
|
"allApps": MessageLookupByLibrary.simpleMessage("所有应用"),
|
||||||
"allowBypass": MessageLookupByLibrary.simpleMessage("允许应用绕过VPN"),
|
"allowBypass": MessageLookupByLibrary.simpleMessage("允许应用绕过VPN"),
|
||||||
"allowBypassDesc":
|
"allowBypassDesc":
|
||||||
MessageLookupByLibrary.simpleMessage("开启后部分应用可绕过VPN"),
|
MessageLookupByLibrary.simpleMessage("开启后部分应用可绕过VPN"),
|
||||||
@@ -62,8 +64,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
"backup": MessageLookupByLibrary.simpleMessage("备份"),
|
"backup": MessageLookupByLibrary.simpleMessage("备份"),
|
||||||
"backupAndRecovery": MessageLookupByLibrary.simpleMessage("备份与恢复"),
|
"backupAndRecovery": MessageLookupByLibrary.simpleMessage("备份与恢复"),
|
||||||
"backupAndRecoveryDesc":
|
"backupAndRecoveryDesc":
|
||||||
MessageLookupByLibrary.simpleMessage("通过WebDAV同步数据"),
|
MessageLookupByLibrary.simpleMessage("通过WebDAV或者文件同步数据"),
|
||||||
"backupDesc": MessageLookupByLibrary.simpleMessage("备份数据到WebDAV"),
|
|
||||||
"backupSuccess": MessageLookupByLibrary.simpleMessage("备份成功"),
|
"backupSuccess": MessageLookupByLibrary.simpleMessage("备份成功"),
|
||||||
"bind": MessageLookupByLibrary.simpleMessage("绑定"),
|
"bind": MessageLookupByLibrary.simpleMessage("绑定"),
|
||||||
"blacklistMode": MessageLookupByLibrary.simpleMessage("黑名单模式"),
|
"blacklistMode": MessageLookupByLibrary.simpleMessage("黑名单模式"),
|
||||||
@@ -74,6 +75,8 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
"checkUpdate": MessageLookupByLibrary.simpleMessage("检查更新"),
|
"checkUpdate": MessageLookupByLibrary.simpleMessage("检查更新"),
|
||||||
"checkUpdateError": MessageLookupByLibrary.simpleMessage("当前应用已经是最新版了"),
|
"checkUpdateError": MessageLookupByLibrary.simpleMessage("当前应用已经是最新版了"),
|
||||||
"checking": MessageLookupByLibrary.simpleMessage("检测中..."),
|
"checking": MessageLookupByLibrary.simpleMessage("检测中..."),
|
||||||
|
"clipboardExport": MessageLookupByLibrary.simpleMessage("导出剪贴板"),
|
||||||
|
"clipboardImport": MessageLookupByLibrary.simpleMessage("剪贴板导入"),
|
||||||
"columns": MessageLookupByLibrary.simpleMessage("列数"),
|
"columns": MessageLookupByLibrary.simpleMessage("列数"),
|
||||||
"compatible": MessageLookupByLibrary.simpleMessage("兼容模式"),
|
"compatible": MessageLookupByLibrary.simpleMessage("兼容模式"),
|
||||||
"compatibleDesc":
|
"compatibleDesc":
|
||||||
@@ -106,6 +109,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
"download": MessageLookupByLibrary.simpleMessage("下载"),
|
"download": MessageLookupByLibrary.simpleMessage("下载"),
|
||||||
"edit": MessageLookupByLibrary.simpleMessage("编辑"),
|
"edit": MessageLookupByLibrary.simpleMessage("编辑"),
|
||||||
"en": MessageLookupByLibrary.simpleMessage("英语"),
|
"en": MessageLookupByLibrary.simpleMessage("英语"),
|
||||||
|
"entries": MessageLookupByLibrary.simpleMessage("个条目"),
|
||||||
"exclude": MessageLookupByLibrary.simpleMessage("从最近任务中隐藏"),
|
"exclude": MessageLookupByLibrary.simpleMessage("从最近任务中隐藏"),
|
||||||
"excludeDesc":
|
"excludeDesc":
|
||||||
MessageLookupByLibrary.simpleMessage("应用在后台时,从最近任务中隐藏应用"),
|
MessageLookupByLibrary.simpleMessage("应用在后台时,从最近任务中隐藏应用"),
|
||||||
@@ -136,22 +140,31 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
"importFromURL": MessageLookupByLibrary.simpleMessage("从URL导入"),
|
"importFromURL": MessageLookupByLibrary.simpleMessage("从URL导入"),
|
||||||
"infiniteTime": MessageLookupByLibrary.simpleMessage("长期有效"),
|
"infiniteTime": MessageLookupByLibrary.simpleMessage("长期有效"),
|
||||||
"init": MessageLookupByLibrary.simpleMessage("初始化"),
|
"init": MessageLookupByLibrary.simpleMessage("初始化"),
|
||||||
|
"intelligentSelected": MessageLookupByLibrary.simpleMessage("智能选择"),
|
||||||
"intranetIP": MessageLookupByLibrary.simpleMessage("内网 IP"),
|
"intranetIP": MessageLookupByLibrary.simpleMessage("内网 IP"),
|
||||||
"ipv6Desc": MessageLookupByLibrary.simpleMessage("开启后将可以接收IPv6流量"),
|
"ipv6Desc": MessageLookupByLibrary.simpleMessage("开启后将可以接收IPv6流量"),
|
||||||
"just": MessageLookupByLibrary.simpleMessage("刚刚"),
|
"just": MessageLookupByLibrary.simpleMessage("刚刚"),
|
||||||
|
"keepAliveIntervalDesc":
|
||||||
|
MessageLookupByLibrary.simpleMessage("TCP保持活动间隔"),
|
||||||
"language": MessageLookupByLibrary.simpleMessage("语言"),
|
"language": MessageLookupByLibrary.simpleMessage("语言"),
|
||||||
|
"layout": MessageLookupByLibrary.simpleMessage("布局"),
|
||||||
"light": MessageLookupByLibrary.simpleMessage("浅色"),
|
"light": MessageLookupByLibrary.simpleMessage("浅色"),
|
||||||
"list": MessageLookupByLibrary.simpleMessage("列表"),
|
"list": MessageLookupByLibrary.simpleMessage("列表"),
|
||||||
|
"local": MessageLookupByLibrary.simpleMessage("本地"),
|
||||||
|
"localBackupDesc": MessageLookupByLibrary.simpleMessage("备份数据到本地"),
|
||||||
|
"localRecoveryDesc": MessageLookupByLibrary.simpleMessage("通过文件恢复数据"),
|
||||||
"logLevel": MessageLookupByLibrary.simpleMessage("日志等级"),
|
"logLevel": MessageLookupByLibrary.simpleMessage("日志等级"),
|
||||||
"logcat": MessageLookupByLibrary.simpleMessage("日志捕获"),
|
"logcat": MessageLookupByLibrary.simpleMessage("日志捕获"),
|
||||||
"logcatDesc": MessageLookupByLibrary.simpleMessage("禁用将会隐藏日志入口"),
|
"logcatDesc": MessageLookupByLibrary.simpleMessage("禁用将会隐藏日志入口"),
|
||||||
"logs": MessageLookupByLibrary.simpleMessage("日志"),
|
"logs": MessageLookupByLibrary.simpleMessage("日志"),
|
||||||
"logsDesc": MessageLookupByLibrary.simpleMessage("日志捕获记录"),
|
"logsDesc": MessageLookupByLibrary.simpleMessage("日志捕获记录"),
|
||||||
|
"loose": MessageLookupByLibrary.simpleMessage("紧凑"),
|
||||||
"min": MessageLookupByLibrary.simpleMessage("最小"),
|
"min": MessageLookupByLibrary.simpleMessage("最小"),
|
||||||
"minimizeOnExit": MessageLookupByLibrary.simpleMessage("退出时最小化"),
|
"minimizeOnExit": MessageLookupByLibrary.simpleMessage("退出时最小化"),
|
||||||
"minimizeOnExitDesc":
|
"minimizeOnExitDesc":
|
||||||
MessageLookupByLibrary.simpleMessage("修改系统默认退出事件"),
|
MessageLookupByLibrary.simpleMessage("修改系统默认退出事件"),
|
||||||
"minutes": MessageLookupByLibrary.simpleMessage("分钟"),
|
"minutes": MessageLookupByLibrary.simpleMessage("分钟"),
|
||||||
|
"mode": MessageLookupByLibrary.simpleMessage("模式"),
|
||||||
"months": MessageLookupByLibrary.simpleMessage("月"),
|
"months": MessageLookupByLibrary.simpleMessage("月"),
|
||||||
"more": MessageLookupByLibrary.simpleMessage("更多"),
|
"more": MessageLookupByLibrary.simpleMessage("更多"),
|
||||||
"name": MessageLookupByLibrary.simpleMessage("名称"),
|
"name": MessageLookupByLibrary.simpleMessage("名称"),
|
||||||
@@ -171,6 +184,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
MessageLookupByLibrary.simpleMessage("没有配置文件,请先添加配置文件"),
|
MessageLookupByLibrary.simpleMessage("没有配置文件,请先添加配置文件"),
|
||||||
"nullRequestsDesc": MessageLookupByLibrary.simpleMessage("暂无请求"),
|
"nullRequestsDesc": MessageLookupByLibrary.simpleMessage("暂无请求"),
|
||||||
"oneColumn": MessageLookupByLibrary.simpleMessage("一列"),
|
"oneColumn": MessageLookupByLibrary.simpleMessage("一列"),
|
||||||
|
"onlyOtherApps": MessageLookupByLibrary.simpleMessage("仅第三方应用"),
|
||||||
"onlyStatisticsProxy": MessageLookupByLibrary.simpleMessage("仅统计代理"),
|
"onlyStatisticsProxy": MessageLookupByLibrary.simpleMessage("仅统计代理"),
|
||||||
"onlyStatisticsProxyDesc":
|
"onlyStatisticsProxyDesc":
|
||||||
MessageLookupByLibrary.simpleMessage("开启后,将只统计代理流量"),
|
MessageLookupByLibrary.simpleMessage("开启后,将只统计代理流量"),
|
||||||
@@ -202,19 +216,24 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
"profileUrlNullValidationDesc":
|
"profileUrlNullValidationDesc":
|
||||||
MessageLookupByLibrary.simpleMessage("请输入配置URL"),
|
MessageLookupByLibrary.simpleMessage("请输入配置URL"),
|
||||||
"profiles": MessageLookupByLibrary.simpleMessage("配置"),
|
"profiles": MessageLookupByLibrary.simpleMessage("配置"),
|
||||||
|
"profilesSort": MessageLookupByLibrary.simpleMessage("配置排序"),
|
||||||
"project": MessageLookupByLibrary.simpleMessage("项目"),
|
"project": MessageLookupByLibrary.simpleMessage("项目"),
|
||||||
"proxies": MessageLookupByLibrary.simpleMessage("代理"),
|
"proxies": MessageLookupByLibrary.simpleMessage("代理"),
|
||||||
"proxiesSetting": MessageLookupByLibrary.simpleMessage("代理设置"),
|
"proxiesSetting": MessageLookupByLibrary.simpleMessage("代理设置"),
|
||||||
"proxyGroup": MessageLookupByLibrary.simpleMessage("代理组"),
|
"proxyGroup": MessageLookupByLibrary.simpleMessage("代理组"),
|
||||||
"proxyPort": MessageLookupByLibrary.simpleMessage("代理端口"),
|
"proxyPort": MessageLookupByLibrary.simpleMessage("代理端口"),
|
||||||
"proxyPortDesc": MessageLookupByLibrary.simpleMessage("设置Clash监听端口"),
|
"proxyPortDesc": MessageLookupByLibrary.simpleMessage("设置Clash监听端口"),
|
||||||
|
"prueBlackMode": MessageLookupByLibrary.simpleMessage("纯黑模式"),
|
||||||
"qrcode": MessageLookupByLibrary.simpleMessage("二维码"),
|
"qrcode": MessageLookupByLibrary.simpleMessage("二维码"),
|
||||||
"qrcodeDesc": MessageLookupByLibrary.simpleMessage("扫描二维码获取配置文件"),
|
"qrcodeDesc": MessageLookupByLibrary.simpleMessage("扫描二维码获取配置文件"),
|
||||||
"recovery": MessageLookupByLibrary.simpleMessage("恢复"),
|
"recovery": MessageLookupByLibrary.simpleMessage("恢复"),
|
||||||
"recoveryAll": MessageLookupByLibrary.simpleMessage("恢复所有数据"),
|
"recoveryAll": MessageLookupByLibrary.simpleMessage("恢复所有数据"),
|
||||||
"recoveryDesc": MessageLookupByLibrary.simpleMessage("从WebDAV恢复数据"),
|
|
||||||
"recoveryProfiles": MessageLookupByLibrary.simpleMessage("仅恢复配置文件"),
|
"recoveryProfiles": MessageLookupByLibrary.simpleMessage("仅恢复配置文件"),
|
||||||
"recoverySuccess": MessageLookupByLibrary.simpleMessage("恢复成功"),
|
"recoverySuccess": MessageLookupByLibrary.simpleMessage("恢复成功"),
|
||||||
|
"remote": MessageLookupByLibrary.simpleMessage("远程"),
|
||||||
|
"remoteBackupDesc": MessageLookupByLibrary.simpleMessage("备份数据到WebDAV"),
|
||||||
|
"remoteRecoveryDesc":
|
||||||
|
MessageLookupByLibrary.simpleMessage("通过WebDAV恢复数据"),
|
||||||
"requests": MessageLookupByLibrary.simpleMessage("请求"),
|
"requests": MessageLookupByLibrary.simpleMessage("请求"),
|
||||||
"requestsDesc": MessageLookupByLibrary.simpleMessage("查看最近请求记录"),
|
"requestsDesc": MessageLookupByLibrary.simpleMessage("查看最近请求记录"),
|
||||||
"resources": MessageLookupByLibrary.simpleMessage("资源"),
|
"resources": MessageLookupByLibrary.simpleMessage("资源"),
|
||||||
@@ -222,6 +241,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
"rule": MessageLookupByLibrary.simpleMessage("规则"),
|
"rule": MessageLookupByLibrary.simpleMessage("规则"),
|
||||||
"save": MessageLookupByLibrary.simpleMessage("保存"),
|
"save": MessageLookupByLibrary.simpleMessage("保存"),
|
||||||
"search": MessageLookupByLibrary.simpleMessage("搜索"),
|
"search": MessageLookupByLibrary.simpleMessage("搜索"),
|
||||||
|
"seconds": MessageLookupByLibrary.simpleMessage("秒"),
|
||||||
"selectAll": MessageLookupByLibrary.simpleMessage("全选"),
|
"selectAll": MessageLookupByLibrary.simpleMessage("全选"),
|
||||||
"selected": MessageLookupByLibrary.simpleMessage("已选择"),
|
"selected": MessageLookupByLibrary.simpleMessage("已选择"),
|
||||||
"settings": MessageLookupByLibrary.simpleMessage("设置"),
|
"settings": MessageLookupByLibrary.simpleMessage("设置"),
|
||||||
@@ -231,7 +251,11 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
"silentLaunchDesc": MessageLookupByLibrary.simpleMessage("后台启动"),
|
"silentLaunchDesc": MessageLookupByLibrary.simpleMessage("后台启动"),
|
||||||
"size": MessageLookupByLibrary.simpleMessage("尺寸"),
|
"size": MessageLookupByLibrary.simpleMessage("尺寸"),
|
||||||
"sort": MessageLookupByLibrary.simpleMessage("排序"),
|
"sort": MessageLookupByLibrary.simpleMessage("排序"),
|
||||||
|
"source": MessageLookupByLibrary.simpleMessage("来源"),
|
||||||
|
"standard": MessageLookupByLibrary.simpleMessage("标准"),
|
||||||
|
"start": MessageLookupByLibrary.simpleMessage("启动"),
|
||||||
"startVpn": MessageLookupByLibrary.simpleMessage("正在启动VPN..."),
|
"startVpn": MessageLookupByLibrary.simpleMessage("正在启动VPN..."),
|
||||||
|
"stop": MessageLookupByLibrary.simpleMessage("暂停"),
|
||||||
"stopVpn": MessageLookupByLibrary.simpleMessage("正在停止VPN..."),
|
"stopVpn": MessageLookupByLibrary.simpleMessage("正在停止VPN..."),
|
||||||
"style": MessageLookupByLibrary.simpleMessage("风格"),
|
"style": MessageLookupByLibrary.simpleMessage("风格"),
|
||||||
"submit": MessageLookupByLibrary.simpleMessage("提交"),
|
"submit": MessageLookupByLibrary.simpleMessage("提交"),
|
||||||
@@ -251,10 +275,12 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
"themeDesc": MessageLookupByLibrary.simpleMessage("设置深色模式,调整色彩"),
|
"themeDesc": MessageLookupByLibrary.simpleMessage("设置深色模式,调整色彩"),
|
||||||
"themeMode": MessageLookupByLibrary.simpleMessage("主题模式"),
|
"themeMode": MessageLookupByLibrary.simpleMessage("主题模式"),
|
||||||
"threeColumns": MessageLookupByLibrary.simpleMessage("三列"),
|
"threeColumns": MessageLookupByLibrary.simpleMessage("三列"),
|
||||||
|
"tight": MessageLookupByLibrary.simpleMessage("宽松"),
|
||||||
|
"time": MessageLookupByLibrary.simpleMessage("时间"),
|
||||||
"tip": MessageLookupByLibrary.simpleMessage("提示"),
|
"tip": MessageLookupByLibrary.simpleMessage("提示"),
|
||||||
"tools": MessageLookupByLibrary.simpleMessage("工具"),
|
"tools": MessageLookupByLibrary.simpleMessage("工具"),
|
||||||
"trafficUsage": MessageLookupByLibrary.simpleMessage("流量统计"),
|
"trafficUsage": MessageLookupByLibrary.simpleMessage("流量统计"),
|
||||||
"tun": MessageLookupByLibrary.simpleMessage("TUN模式"),
|
"tun": MessageLookupByLibrary.simpleMessage("虚拟网卡"),
|
||||||
"tunDesc": MessageLookupByLibrary.simpleMessage("仅在管理员模式生效"),
|
"tunDesc": MessageLookupByLibrary.simpleMessage("仅在管理员模式生效"),
|
||||||
"twoColumns": MessageLookupByLibrary.simpleMessage("两列"),
|
"twoColumns": MessageLookupByLibrary.simpleMessage("两列"),
|
||||||
"unableToUpdateCurrentProfileDesc":
|
"unableToUpdateCurrentProfileDesc":
|
||||||
|
|||||||
@@ -430,10 +430,10 @@ class AppLocalizations {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `TUN mode`
|
/// `TUN`
|
||||||
String get tun {
|
String get tun {
|
||||||
return Intl.message(
|
return Intl.message(
|
||||||
'TUN mode',
|
'TUN',
|
||||||
name: 'tun',
|
name: 'tun',
|
||||||
desc: '',
|
desc: '',
|
||||||
args: [],
|
args: [],
|
||||||
@@ -720,6 +720,16 @@ class AppLocalizations {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// `Seconds`
|
||||||
|
String get seconds {
|
||||||
|
return Intl.message(
|
||||||
|
'Seconds',
|
||||||
|
name: 'seconds',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/// ` Ago`
|
/// ` Ago`
|
||||||
String get ago {
|
String get ago {
|
||||||
return Intl.message(
|
return Intl.message(
|
||||||
@@ -1220,10 +1230,10 @@ class AppLocalizations {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `SystemProxy`
|
/// `System proxy`
|
||||||
String get systemProxy {
|
String get systemProxy {
|
||||||
return Intl.message(
|
return Intl.message(
|
||||||
'SystemProxy',
|
'System proxy',
|
||||||
name: 'systemProxy',
|
name: 'systemProxy',
|
||||||
desc: '',
|
desc: '',
|
||||||
args: [],
|
args: [],
|
||||||
@@ -1360,10 +1370,10 @@ class AppLocalizations {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `Sync data by WebDAV`
|
/// `Sync data via WebDAV or file`
|
||||||
String get backupAndRecoveryDesc {
|
String get backupAndRecoveryDesc {
|
||||||
return Intl.message(
|
return Intl.message(
|
||||||
'Sync data by WebDAV',
|
'Sync data via WebDAV or file',
|
||||||
name: 'backupAndRecoveryDesc',
|
name: 'backupAndRecoveryDesc',
|
||||||
desc: '',
|
desc: '',
|
||||||
args: [],
|
args: [],
|
||||||
@@ -1390,16 +1400,6 @@ class AppLocalizations {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `Backup local data to WebDAV`
|
|
||||||
String get backupDesc {
|
|
||||||
return Intl.message(
|
|
||||||
'Backup local data to WebDAV',
|
|
||||||
name: 'backupDesc',
|
|
||||||
desc: '',
|
|
||||||
args: [],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// `Recovery`
|
/// `Recovery`
|
||||||
String get recovery {
|
String get recovery {
|
||||||
return Intl.message(
|
return Intl.message(
|
||||||
@@ -1410,16 +1410,6 @@ class AppLocalizations {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `Recovery data from WebDAV`
|
|
||||||
String get recoveryDesc {
|
|
||||||
return Intl.message(
|
|
||||||
'Recovery data from WebDAV',
|
|
||||||
name: 'recoveryDesc',
|
|
||||||
desc: '',
|
|
||||||
args: [],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// `Only recovery profiles`
|
/// `Only recovery profiles`
|
||||||
String get recoveryProfiles {
|
String get recoveryProfiles {
|
||||||
return Intl.message(
|
return Intl.message(
|
||||||
@@ -2259,6 +2249,256 @@ class AppLocalizations {
|
|||||||
args: [],
|
args: [],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// `Prue black mode`
|
||||||
|
String get prueBlackMode {
|
||||||
|
return Intl.message(
|
||||||
|
'Prue black mode',
|
||||||
|
name: 'prueBlackMode',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Tcp keep alive interval`
|
||||||
|
String get keepAliveIntervalDesc {
|
||||||
|
return Intl.message(
|
||||||
|
'Tcp keep alive interval',
|
||||||
|
name: 'keepAliveIntervalDesc',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// ` entries`
|
||||||
|
String get entries {
|
||||||
|
return Intl.message(
|
||||||
|
' entries',
|
||||||
|
name: 'entries',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Local`
|
||||||
|
String get local {
|
||||||
|
return Intl.message(
|
||||||
|
'Local',
|
||||||
|
name: 'local',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Remote`
|
||||||
|
String get remote {
|
||||||
|
return Intl.message(
|
||||||
|
'Remote',
|
||||||
|
name: 'remote',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Backup local data to WebDAV`
|
||||||
|
String get remoteBackupDesc {
|
||||||
|
return Intl.message(
|
||||||
|
'Backup local data to WebDAV',
|
||||||
|
name: 'remoteBackupDesc',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Recovery data from WebDAV`
|
||||||
|
String get remoteRecoveryDesc {
|
||||||
|
return Intl.message(
|
||||||
|
'Recovery data from WebDAV',
|
||||||
|
name: 'remoteRecoveryDesc',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Backup local data to local`
|
||||||
|
String get localBackupDesc {
|
||||||
|
return Intl.message(
|
||||||
|
'Backup local data to local',
|
||||||
|
name: 'localBackupDesc',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Recovery data from file`
|
||||||
|
String get localRecoveryDesc {
|
||||||
|
return Intl.message(
|
||||||
|
'Recovery data from file',
|
||||||
|
name: 'localRecoveryDesc',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Mode`
|
||||||
|
String get mode {
|
||||||
|
return Intl.message(
|
||||||
|
'Mode',
|
||||||
|
name: 'mode',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Time`
|
||||||
|
String get time {
|
||||||
|
return Intl.message(
|
||||||
|
'Time',
|
||||||
|
name: 'time',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Source`
|
||||||
|
String get source {
|
||||||
|
return Intl.message(
|
||||||
|
'Source',
|
||||||
|
name: 'source',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `All apps`
|
||||||
|
String get allApps {
|
||||||
|
return Intl.message(
|
||||||
|
'All apps',
|
||||||
|
name: 'allApps',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Only third-party apps`
|
||||||
|
String get onlyOtherApps {
|
||||||
|
return Intl.message(
|
||||||
|
'Only third-party apps',
|
||||||
|
name: 'onlyOtherApps',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Action`
|
||||||
|
String get action {
|
||||||
|
return Intl.message(
|
||||||
|
'Action',
|
||||||
|
name: 'action',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Intelligent selection`
|
||||||
|
String get intelligentSelected {
|
||||||
|
return Intl.message(
|
||||||
|
'Intelligent selection',
|
||||||
|
name: 'intelligentSelected',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Clipboard import`
|
||||||
|
String get clipboardImport {
|
||||||
|
return Intl.message(
|
||||||
|
'Clipboard import',
|
||||||
|
name: 'clipboardImport',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Export clipboard`
|
||||||
|
String get clipboardExport {
|
||||||
|
return Intl.message(
|
||||||
|
'Export clipboard',
|
||||||
|
name: 'clipboardExport',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Layout`
|
||||||
|
String get layout {
|
||||||
|
return Intl.message(
|
||||||
|
'Layout',
|
||||||
|
name: 'layout',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Tight`
|
||||||
|
String get tight {
|
||||||
|
return Intl.message(
|
||||||
|
'Tight',
|
||||||
|
name: 'tight',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Standard`
|
||||||
|
String get standard {
|
||||||
|
return Intl.message(
|
||||||
|
'Standard',
|
||||||
|
name: 'standard',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Loose`
|
||||||
|
String get loose {
|
||||||
|
return Intl.message(
|
||||||
|
'Loose',
|
||||||
|
name: 'loose',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Profiles sort`
|
||||||
|
String get profilesSort {
|
||||||
|
return Intl.message(
|
||||||
|
'Profiles sort',
|
||||||
|
name: 'profilesSort',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Start`
|
||||||
|
String get start {
|
||||||
|
return Intl.message(
|
||||||
|
'Start',
|
||||||
|
name: 'start',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Stop`
|
||||||
|
String get stop {
|
||||||
|
return Intl.message(
|
||||||
|
'Stop',
|
||||||
|
name: 'stop',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class AppLocalizationDelegate extends LocalizationsDelegate<AppLocalizations> {
|
class AppLocalizationDelegate extends LocalizationsDelegate<AppLocalizations> {
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ import 'dart:io';
|
|||||||
|
|
||||||
import 'package:fl_clash/clash/clash.dart';
|
import 'package:fl_clash/clash/clash.dart';
|
||||||
import 'package:fl_clash/plugins/app.dart';
|
import 'package:fl_clash/plugins/app.dart';
|
||||||
import 'package:fl_clash/plugins/proxy.dart';
|
|
||||||
import 'package:fl_clash/plugins/tile.dart';
|
import 'package:fl_clash/plugins/tile.dart';
|
||||||
|
import 'package:fl_clash/plugins/vpn.dart';
|
||||||
import 'package:fl_clash/state.dart';
|
import 'package:fl_clash/state.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:package_info_plus/package_info_plus.dart';
|
import 'package:package_info_plus/package_info_plus.dart';
|
||||||
@@ -18,6 +18,7 @@ Future<void> main() async {
|
|||||||
clashCore.initMessage();
|
clashCore.initMessage();
|
||||||
globalState.packageInfo = await PackageInfo.fromPlatform();
|
globalState.packageInfo = await PackageInfo.fromPlatform();
|
||||||
final config = await preferences.getConfig() ?? Config();
|
final config = await preferences.getConfig() ?? Config();
|
||||||
|
globalState.autoRun = config.autoRun;
|
||||||
final clashConfig = await preferences.getClashConfig() ?? ClashConfig();
|
final clashConfig = await preferences.getClashConfig() ?? ClashConfig();
|
||||||
await android?.init();
|
await android?.init();
|
||||||
await window?.init(config.windowProps);
|
await window?.init(config.windowProps);
|
||||||
@@ -61,14 +62,14 @@ Future<void> vpnService() async {
|
|||||||
clashConfig: clashConfig,
|
clashConfig: clashConfig,
|
||||||
);
|
);
|
||||||
|
|
||||||
proxy?.setServiceMessageHandler(
|
vpn?.setServiceMessageHandler(
|
||||||
ServiceMessageHandler(
|
ServiceMessageHandler(
|
||||||
onProtect: (Fd fd) async {
|
onProtect: (Fd fd) async {
|
||||||
await proxy?.setProtect(fd.value);
|
await vpn?.setProtect(fd.value);
|
||||||
clashCore.setFdMap(fd.id);
|
clashCore.setFdMap(fd.id);
|
||||||
},
|
},
|
||||||
onProcess: (Process process) async {
|
onProcess: (Process process) async {
|
||||||
var packageName = await app?.resolverProcess(process);
|
final packageName = await app?.resolverProcess(process);
|
||||||
clashCore.setProcessMap(
|
clashCore.setProcessMap(
|
||||||
ProcessMapItem(
|
ProcessMapItem(
|
||||||
id: process.id,
|
id: process.id,
|
||||||
@@ -76,8 +77,8 @@ Future<void> vpnService() async {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
onStarted: (String runTime) {
|
onStarted: (String runTime) async {
|
||||||
globalState.applyProfile(
|
await globalState.applyProfile(
|
||||||
appState: appState,
|
appState: appState,
|
||||||
config: config,
|
config: config,
|
||||||
clashConfig: clashConfig,
|
clashConfig: clashConfig,
|
||||||
@@ -100,8 +101,7 @@ Future<void> vpnService() async {
|
|||||||
WidgetsBinding.instance.platformDispatcher.locale,
|
WidgetsBinding.instance.platformDispatcher.locale,
|
||||||
);
|
);
|
||||||
await app?.tip(appLocalizations.startVpn);
|
await app?.tip(appLocalizations.startVpn);
|
||||||
await globalState.startSystemProxy(
|
await globalState.handleStart(
|
||||||
appState: appState,
|
|
||||||
config: config,
|
config: config,
|
||||||
clashConfig: clashConfig,
|
clashConfig: clashConfig,
|
||||||
);
|
);
|
||||||
@@ -110,7 +110,7 @@ Future<void> vpnService() async {
|
|||||||
TileListenerWithVpn(
|
TileListenerWithVpn(
|
||||||
onStop: () async {
|
onStop: () async {
|
||||||
await app?.tip(appLocalizations.stopVpn);
|
await app?.tip(appLocalizations.stopVpn);
|
||||||
await globalState.stopSystemProxy();
|
await globalState.handleStop();
|
||||||
clashCore.shutdown();
|
clashCore.shutdown();
|
||||||
exit(0);
|
exit(0);
|
||||||
},
|
},
|
||||||
@@ -130,13 +130,13 @@ class ServiceMessageHandler with ServiceMessageListener {
|
|||||||
final Function(Fd fd) _onProtect;
|
final Function(Fd fd) _onProtect;
|
||||||
final Function(Process process) _onProcess;
|
final Function(Process process) _onProcess;
|
||||||
final Function(String runTime) _onStarted;
|
final Function(String runTime) _onStarted;
|
||||||
final Function(String groupName) _onLoaded;
|
final Function(String providerName) _onLoaded;
|
||||||
|
|
||||||
const ServiceMessageHandler({
|
const ServiceMessageHandler({
|
||||||
required Function(Fd fd) onProtect,
|
required Function(Fd fd) onProtect,
|
||||||
required Function(Process process) onProcess,
|
required Function(Process process) onProcess,
|
||||||
required Function(String runTime) onStarted,
|
required Function(String runTime) onStarted,
|
||||||
required Function(String groupName) onLoaded,
|
required Function(String providerName) onLoaded,
|
||||||
}) : _onProtect = onProtect,
|
}) : _onProtect = onProtect,
|
||||||
_onProcess = onProcess,
|
_onProcess = onProcess,
|
||||||
_onStarted = onStarted,
|
_onStarted = onStarted,
|
||||||
@@ -158,8 +158,8 @@ class ServiceMessageHandler with ServiceMessageListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
onLoaded(String groupName) {
|
onLoaded(String providerName) {
|
||||||
_onLoaded(groupName);
|
_onLoaded(providerName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import 'connection.dart';
|
|||||||
import 'ffi.dart';
|
import 'ffi.dart';
|
||||||
import 'log.dart';
|
import 'log.dart';
|
||||||
import 'navigation.dart';
|
import 'navigation.dart';
|
||||||
|
import 'package.dart';
|
||||||
import 'profile.dart';
|
import 'profile.dart';
|
||||||
import 'proxy.dart';
|
import 'proxy.dart';
|
||||||
import 'system_color_scheme.dart';
|
import 'system_color_scheme.dart';
|
||||||
@@ -35,6 +36,8 @@ class AppState with ChangeNotifier {
|
|||||||
double _viewWidth;
|
double _viewWidth;
|
||||||
List<Connection> _requests;
|
List<Connection> _requests;
|
||||||
num _checkIpNum;
|
num _checkIpNum;
|
||||||
|
List<ExternalProvider> _providers;
|
||||||
|
List<Package> _packages;
|
||||||
|
|
||||||
AppState({
|
AppState({
|
||||||
required Mode mode,
|
required Mode mode,
|
||||||
@@ -54,6 +57,8 @@ class AppState with ChangeNotifier {
|
|||||||
_totalTraffic = Traffic(),
|
_totalTraffic = Traffic(),
|
||||||
_delayMap = {},
|
_delayMap = {},
|
||||||
_groups = [],
|
_groups = [],
|
||||||
|
_providers = [],
|
||||||
|
_packages = [],
|
||||||
_isCompatible = isCompatible,
|
_isCompatible = isCompatible,
|
||||||
_systemColorSchemes = const SystemColorSchemes();
|
_systemColorSchemes = const SystemColorSchemes();
|
||||||
|
|
||||||
@@ -330,6 +335,32 @@ class AppState with ChangeNotifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<Package> get packages => _packages;
|
||||||
|
|
||||||
|
set packages(List<Package> value) {
|
||||||
|
if (!const ListEquality<Package>().equals(_packages, value)) {
|
||||||
|
_packages = value;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<ExternalProvider> get providers => _providers;
|
||||||
|
|
||||||
|
set providers(List<ExternalProvider> value) {
|
||||||
|
if (!const ListEquality<ExternalProvider>().equals(_providers, value)) {
|
||||||
|
_providers = value;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setProvider(ExternalProvider? provider) {
|
||||||
|
if(provider == null) return;
|
||||||
|
final index = _providers.indexWhere((item) => item.name == provider.name);
|
||||||
|
if (index == -1) return;
|
||||||
|
_providers = List.from(_providers)..[index] = provider;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
Group? getGroupWithName(String groupName) {
|
Group? getGroupWithName(String groupName) {
|
||||||
final index =
|
final index =
|
||||||
currentGroups.indexWhere((element) => element.name == groupName);
|
currentGroups.indexWhere((element) => element.name == groupName);
|
||||||
|
|||||||
@@ -119,6 +119,7 @@ class ClashConfig extends ChangeNotifier {
|
|||||||
String _externalController;
|
String _externalController;
|
||||||
Mode _mode;
|
Mode _mode;
|
||||||
FindProcessMode _findProcessMode;
|
FindProcessMode _findProcessMode;
|
||||||
|
int _keepAliveInterval;
|
||||||
bool _unifiedDelay;
|
bool _unifiedDelay;
|
||||||
bool _tcpConcurrent;
|
bool _tcpConcurrent;
|
||||||
Tun _tun;
|
Tun _tun;
|
||||||
@@ -139,6 +140,7 @@ class ClashConfig extends ChangeNotifier {
|
|||||||
_unifiedDelay = false,
|
_unifiedDelay = false,
|
||||||
_geodataLoader = geodataLoaderMemconservative,
|
_geodataLoader = geodataLoaderMemconservative,
|
||||||
_externalController = '',
|
_externalController = '',
|
||||||
|
_keepAliveInterval = 30,
|
||||||
_dns = Dns(),
|
_dns = Dns(),
|
||||||
_geoXUrl = defaultGeoXMap,
|
_geoXUrl = defaultGeoXMap,
|
||||||
_rules = [];
|
_rules = [];
|
||||||
@@ -203,6 +205,16 @@ class ClashConfig extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonKey(name: "keep-alive-interval", defaultValue: 30)
|
||||||
|
int get keepAliveInterval => _keepAliveInterval;
|
||||||
|
|
||||||
|
set keepAliveInterval(int value) {
|
||||||
|
if (_keepAliveInterval != value) {
|
||||||
|
_keepAliveInterval = value;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@JsonKey(defaultValue: false)
|
@JsonKey(defaultValue: false)
|
||||||
bool get ipv6 => _ipv6;
|
bool get ipv6 => _ipv6;
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ class AccessControl with _$AccessControl {
|
|||||||
@Default(AccessControlMode.rejectSelected) AccessControlMode mode,
|
@Default(AccessControlMode.rejectSelected) AccessControlMode mode,
|
||||||
@Default([]) List<String> acceptList,
|
@Default([]) List<String> acceptList,
|
||||||
@Default([]) List<String> rejectList,
|
@Default([]) List<String> rejectList,
|
||||||
|
@Default(AccessSortType.none) AccessSortType sort,
|
||||||
@Default(true) bool isFilterSystemApp,
|
@Default(true) bool isFilterSystemApp,
|
||||||
}) = _AccessControl;
|
}) = _AccessControl;
|
||||||
|
|
||||||
@@ -25,17 +26,27 @@ class AccessControl with _$AccessControl {
|
|||||||
_$AccessControlFromJson(json);
|
_$AccessControlFromJson(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension AccessControlExt on AccessControl {
|
||||||
|
List<String> get currentList => switch (mode) {
|
||||||
|
AccessControlMode.acceptSelected => acceptList,
|
||||||
|
AccessControlMode.rejectSelected => rejectList,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
@freezed
|
@freezed
|
||||||
class CoreState with _$CoreState {
|
class CoreState with _$CoreState {
|
||||||
const factory CoreState({
|
const factory CoreState({
|
||||||
AccessControl? accessControl,
|
AccessControl? accessControl,
|
||||||
|
required String currentProfileName,
|
||||||
|
required bool enable,
|
||||||
required bool allowBypass,
|
required bool allowBypass,
|
||||||
required bool systemProxy,
|
required bool systemProxy,
|
||||||
required int mixedPort,
|
required int mixedPort,
|
||||||
required bool onlyProxy,
|
required bool onlyProxy,
|
||||||
}) = _CoreState;
|
}) = _CoreState;
|
||||||
|
|
||||||
factory CoreState.fromJson(Map<String, Object?> json) => _$CoreStateFromJson(json);
|
factory CoreState.fromJson(Map<String, Object?> json) =>
|
||||||
|
_$CoreStateFromJson(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
@freezed
|
@freezed
|
||||||
@@ -48,10 +59,30 @@ class WindowProps with _$WindowProps {
|
|||||||
}) = _WindowProps;
|
}) = _WindowProps;
|
||||||
|
|
||||||
factory WindowProps.fromJson(Map<String, Object?>? json) =>
|
factory WindowProps.fromJson(Map<String, Object?>? json) =>
|
||||||
json == null ? defaultWindowProps : _$WindowPropsFromJson(json);
|
json == null ? const WindowProps() : _$WindowPropsFromJson(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultWindowProps = WindowProps();
|
@freezed
|
||||||
|
class VpnProps with _$VpnProps {
|
||||||
|
const factory VpnProps({
|
||||||
|
@Default(true) bool enable,
|
||||||
|
@Default(false) bool systemProxy,
|
||||||
|
@Default(true) bool allowBypass,
|
||||||
|
}) = _VpnProps;
|
||||||
|
|
||||||
|
factory VpnProps.fromJson(Map<String, Object?>? json) =>
|
||||||
|
json == null ? const VpnProps() : _$VpnPropsFromJson(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
@freezed
|
||||||
|
class DesktopProps with _$DesktopProps {
|
||||||
|
const factory DesktopProps({
|
||||||
|
@Default(true) bool systemProxy,
|
||||||
|
}) = _DesktopProps;
|
||||||
|
|
||||||
|
factory DesktopProps.fromJson(Map<String, Object?>? json) =>
|
||||||
|
json == null ? const DesktopProps() : _$DesktopPropsFromJson(json);
|
||||||
|
}
|
||||||
|
|
||||||
@JsonSerializable()
|
@JsonSerializable()
|
||||||
class Config extends ChangeNotifier {
|
class Config extends ChangeNotifier {
|
||||||
@@ -71,17 +102,19 @@ class Config extends ChangeNotifier {
|
|||||||
AccessControl _accessControl;
|
AccessControl _accessControl;
|
||||||
bool _isAnimateToPage;
|
bool _isAnimateToPage;
|
||||||
bool _autoCheckUpdate;
|
bool _autoCheckUpdate;
|
||||||
bool _allowBypass;
|
|
||||||
bool _systemProxy;
|
|
||||||
bool _isExclude;
|
bool _isExclude;
|
||||||
DAV? _dav;
|
DAV? _dav;
|
||||||
bool _isCloseConnections;
|
bool _isCloseConnections;
|
||||||
ProxiesType _proxiesType;
|
ProxiesType _proxiesType;
|
||||||
ProxyCardType _proxyCardType;
|
ProxyCardType _proxyCardType;
|
||||||
int _proxiesColumns;
|
ProxiesLayout _proxiesLayout;
|
||||||
String _testUrl;
|
String _testUrl;
|
||||||
WindowProps _windowProps;
|
WindowProps _windowProps;
|
||||||
bool _onlyProxy;
|
bool _onlyProxy;
|
||||||
|
bool _prueBlack;
|
||||||
|
VpnProps _vpnProps;
|
||||||
|
DesktopProps _desktopProps;
|
||||||
|
bool _showLabel;
|
||||||
|
|
||||||
Config()
|
Config()
|
||||||
: _profiles = [],
|
: _profiles = [],
|
||||||
@@ -97,17 +130,19 @@ class Config extends ChangeNotifier {
|
|||||||
_isMinimizeOnExit = true,
|
_isMinimizeOnExit = true,
|
||||||
_isAccessControl = false,
|
_isAccessControl = false,
|
||||||
_autoCheckUpdate = true,
|
_autoCheckUpdate = true,
|
||||||
_systemProxy = false,
|
|
||||||
_testUrl = defaultTestUrl,
|
_testUrl = defaultTestUrl,
|
||||||
_accessControl = const AccessControl(),
|
_accessControl = const AccessControl(),
|
||||||
_isAnimateToPage = true,
|
_isAnimateToPage = true,
|
||||||
_allowBypass = true,
|
|
||||||
_isExclude = false,
|
_isExclude = false,
|
||||||
_proxyCardType = ProxyCardType.expand,
|
_proxyCardType = ProxyCardType.expand,
|
||||||
_windowProps = defaultWindowProps,
|
_windowProps = const WindowProps(),
|
||||||
_proxiesType = ProxiesType.tab,
|
_proxiesType = ProxiesType.tab,
|
||||||
_proxiesColumns = 2,
|
_prueBlack = false,
|
||||||
_onlyProxy = false;
|
_onlyProxy = false,
|
||||||
|
_proxiesLayout = ProxiesLayout.standard,
|
||||||
|
_vpnProps = const VpnProps(),
|
||||||
|
_desktopProps = const DesktopProps(),
|
||||||
|
_showLabel = false;
|
||||||
|
|
||||||
deleteProfileById(String id) {
|
deleteProfileById(String id) {
|
||||||
_profiles = profiles.where((element) => element.id != id).toList();
|
_profiles = profiles.where((element) => element.id != id).toList();
|
||||||
@@ -309,6 +344,16 @@ class Config extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonKey(defaultValue: ProxiesLayout.standard)
|
||||||
|
ProxiesLayout get proxiesLayout => _proxiesLayout;
|
||||||
|
|
||||||
|
set proxiesLayout(ProxiesLayout value) {
|
||||||
|
if (_proxiesLayout != value) {
|
||||||
|
_proxiesLayout = value;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@JsonKey(defaultValue: true)
|
@JsonKey(defaultValue: true)
|
||||||
bool get isMinimizeOnExit => _isMinimizeOnExit;
|
bool get isMinimizeOnExit => _isMinimizeOnExit;
|
||||||
|
|
||||||
@@ -387,30 +432,6 @@ class Config extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonKey(defaultValue: true)
|
|
||||||
bool get allowBypass {
|
|
||||||
return _allowBypass;
|
|
||||||
}
|
|
||||||
|
|
||||||
set allowBypass(bool value) {
|
|
||||||
if (_allowBypass != value) {
|
|
||||||
_allowBypass = value;
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@JsonKey(defaultValue: false)
|
|
||||||
bool get systemProxy {
|
|
||||||
return _systemProxy;
|
|
||||||
}
|
|
||||||
|
|
||||||
set systemProxy(bool value) {
|
|
||||||
if (_systemProxy != value) {
|
|
||||||
_systemProxy = value;
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@JsonKey(defaultValue: false)
|
@JsonKey(defaultValue: false)
|
||||||
bool get onlyProxy {
|
bool get onlyProxy {
|
||||||
return _onlyProxy;
|
return _onlyProxy;
|
||||||
@@ -423,6 +444,17 @@ class Config extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonKey(defaultValue: false)
|
||||||
|
bool get prueBlack {
|
||||||
|
return _prueBlack;
|
||||||
|
}
|
||||||
|
|
||||||
|
set prueBlack(bool value) {
|
||||||
|
if (_prueBlack != value) {
|
||||||
|
_prueBlack = value;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@JsonKey(defaultValue: false)
|
@JsonKey(defaultValue: false)
|
||||||
bool get isCloseConnections {
|
bool get isCloseConnections {
|
||||||
@@ -459,16 +491,6 @@ class Config extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonKey(defaultValue: 2)
|
|
||||||
int get proxiesColumns => _proxiesColumns;
|
|
||||||
|
|
||||||
set proxiesColumns(int value) {
|
|
||||||
if (_proxiesColumns != value) {
|
|
||||||
_proxiesColumns = value;
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@JsonKey(name: "test-url", defaultValue: defaultTestUrl)
|
@JsonKey(name: "test-url", defaultValue: defaultTestUrl)
|
||||||
String get testUrl => _testUrl;
|
String get testUrl => _testUrl;
|
||||||
|
|
||||||
@@ -498,6 +520,34 @@ class Config extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VpnProps get vpnProps => _vpnProps;
|
||||||
|
|
||||||
|
set vpnProps(VpnProps value) {
|
||||||
|
if (_vpnProps != value) {
|
||||||
|
_vpnProps = value;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DesktopProps get desktopProps => _desktopProps;
|
||||||
|
|
||||||
|
set desktopProps(DesktopProps value) {
|
||||||
|
if (_desktopProps != value) {
|
||||||
|
_desktopProps = value;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonKey(defaultValue: false)
|
||||||
|
bool get showLabel => _showLabel;
|
||||||
|
|
||||||
|
set showLabel(bool value) {
|
||||||
|
if (_showLabel != value) {
|
||||||
|
_showLabel = value;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
update([
|
update([
|
||||||
Config? config,
|
Config? config,
|
||||||
RecoveryOption recoveryOptions = RecoveryOption.all,
|
RecoveryOption recoveryOptions = RecoveryOption.all,
|
||||||
@@ -522,7 +572,6 @@ class Config extends ChangeNotifier {
|
|||||||
_openLog = config._openLog;
|
_openLog = config._openLog;
|
||||||
_themeMode = config._themeMode;
|
_themeMode = config._themeMode;
|
||||||
_locale = config._locale;
|
_locale = config._locale;
|
||||||
_allowBypass = config._allowBypass;
|
|
||||||
_primaryColor = config._primaryColor;
|
_primaryColor = config._primaryColor;
|
||||||
_proxiesSortType = config._proxiesSortType;
|
_proxiesSortType = config._proxiesSortType;
|
||||||
_isMinimizeOnExit = config._isMinimizeOnExit;
|
_isMinimizeOnExit = config._isMinimizeOnExit;
|
||||||
@@ -530,9 +579,12 @@ class Config extends ChangeNotifier {
|
|||||||
_accessControl = config._accessControl;
|
_accessControl = config._accessControl;
|
||||||
_isAnimateToPage = config._isAnimateToPage;
|
_isAnimateToPage = config._isAnimateToPage;
|
||||||
_autoCheckUpdate = config._autoCheckUpdate;
|
_autoCheckUpdate = config._autoCheckUpdate;
|
||||||
|
_prueBlack = config._prueBlack;
|
||||||
_testUrl = config._testUrl;
|
_testUrl = config._testUrl;
|
||||||
_isExclude = config._isExclude;
|
_isExclude = config._isExclude;
|
||||||
_windowProps = config._windowProps;
|
_windowProps = config._windowProps;
|
||||||
|
_vpnProps = config._vpnProps;
|
||||||
|
_desktopProps = config._desktopProps;
|
||||||
}
|
}
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class ConfigExtendedParams with _$ConfigExtendedParams {
|
|||||||
@freezed
|
@freezed
|
||||||
class UpdateConfigParams with _$UpdateConfigParams {
|
class UpdateConfigParams with _$UpdateConfigParams {
|
||||||
const factory UpdateConfigParams({
|
const factory UpdateConfigParams({
|
||||||
@JsonKey(name: "profile-path") String? profilePath,
|
@JsonKey(name: "profile-id") required String profileId,
|
||||||
required ClashConfig config,
|
required ClashConfig config,
|
||||||
required ConfigExtendedParams params,
|
required ConfigExtendedParams params,
|
||||||
}) = _UpdateConfigParams;
|
}) = _UpdateConfigParams;
|
||||||
@@ -123,6 +123,9 @@ class ExternalProvider with _$ExternalProvider {
|
|||||||
const factory ExternalProvider({
|
const factory ExternalProvider({
|
||||||
required String name,
|
required String name,
|
||||||
required String type,
|
required String type,
|
||||||
|
required String path,
|
||||||
|
required int count,
|
||||||
|
@Default(false) bool isUpdating,
|
||||||
@JsonKey(name: "vehicle-type") required String vehicleType,
|
@JsonKey(name: "vehicle-type") required String vehicleType,
|
||||||
@JsonKey(name: "update-at") required DateTime updateAt,
|
@JsonKey(name: "update-at") required DateTime updateAt,
|
||||||
}) = _ExternalProvider;
|
}) = _ExternalProvider;
|
||||||
@@ -140,7 +143,7 @@ abstract mixin class AppMessageListener {
|
|||||||
|
|
||||||
void onStarted(String runTime) {}
|
void onStarted(String runTime) {}
|
||||||
|
|
||||||
void onLoaded(String groupName) {}
|
void onLoaded(String providerName) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract mixin class ServiceMessageListener {
|
abstract mixin class ServiceMessageListener {
|
||||||
@@ -150,7 +153,5 @@ abstract mixin class ServiceMessageListener {
|
|||||||
|
|
||||||
onStarted(String runTime) {}
|
onStarted(String runTime) {}
|
||||||
|
|
||||||
onLoaded(String groupName) {}
|
onLoaded(String providerName) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ ClashConfig _$ClashConfigFromJson(Map<String, dynamic> json) => ClashConfig()
|
|||||||
..logLevel =
|
..logLevel =
|
||||||
$enumDecodeNullable(_$LogLevelEnumMap, json['log-level']) ?? LogLevel.info
|
$enumDecodeNullable(_$LogLevelEnumMap, json['log-level']) ?? LogLevel.info
|
||||||
..externalController = json['external-controller'] as String? ?? ''
|
..externalController = json['external-controller'] as String? ?? ''
|
||||||
|
..keepAliveInterval = (json['keep-alive-interval'] as num?)?.toInt() ?? 30
|
||||||
..ipv6 = json['ipv6'] as bool? ?? false
|
..ipv6 = json['ipv6'] as bool? ?? false
|
||||||
..geodataLoader = json['geodata-loader'] as String? ?? 'memconservative'
|
..geodataLoader = json['geodata-loader'] as String? ?? 'memconservative'
|
||||||
..unifiedDelay = json['unified-delay'] as bool? ?? false
|
..unifiedDelay = json['unified-delay'] as bool? ?? false
|
||||||
@@ -75,6 +76,7 @@ Map<String, dynamic> _$ClashConfigToJson(ClashConfig instance) =>
|
|||||||
'allow-lan': instance.allowLan,
|
'allow-lan': instance.allowLan,
|
||||||
'log-level': _$LogLevelEnumMap[instance.logLevel]!,
|
'log-level': _$LogLevelEnumMap[instance.logLevel]!,
|
||||||
'external-controller': instance.externalController,
|
'external-controller': instance.externalController,
|
||||||
|
'keep-alive-interval': instance.keepAliveInterval,
|
||||||
'ipv6': instance.ipv6,
|
'ipv6': instance.ipv6,
|
||||||
'geodata-loader': instance.geodataLoader,
|
'geodata-loader': instance.geodataLoader,
|
||||||
'unified-delay': instance.unifiedDelay,
|
'unified-delay': instance.unifiedDelay,
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ mixin _$AccessControl {
|
|||||||
AccessControlMode get mode => throw _privateConstructorUsedError;
|
AccessControlMode get mode => throw _privateConstructorUsedError;
|
||||||
List<String> get acceptList => throw _privateConstructorUsedError;
|
List<String> get acceptList => throw _privateConstructorUsedError;
|
||||||
List<String> get rejectList => throw _privateConstructorUsedError;
|
List<String> get rejectList => throw _privateConstructorUsedError;
|
||||||
|
AccessSortType get sort => throw _privateConstructorUsedError;
|
||||||
bool get isFilterSystemApp => throw _privateConstructorUsedError;
|
bool get isFilterSystemApp => throw _privateConstructorUsedError;
|
||||||
|
|
||||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||||
@@ -41,6 +42,7 @@ abstract class $AccessControlCopyWith<$Res> {
|
|||||||
{AccessControlMode mode,
|
{AccessControlMode mode,
|
||||||
List<String> acceptList,
|
List<String> acceptList,
|
||||||
List<String> rejectList,
|
List<String> rejectList,
|
||||||
|
AccessSortType sort,
|
||||||
bool isFilterSystemApp});
|
bool isFilterSystemApp});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,6 +62,7 @@ class _$AccessControlCopyWithImpl<$Res, $Val extends AccessControl>
|
|||||||
Object? mode = null,
|
Object? mode = null,
|
||||||
Object? acceptList = null,
|
Object? acceptList = null,
|
||||||
Object? rejectList = null,
|
Object? rejectList = null,
|
||||||
|
Object? sort = null,
|
||||||
Object? isFilterSystemApp = null,
|
Object? isFilterSystemApp = null,
|
||||||
}) {
|
}) {
|
||||||
return _then(_value.copyWith(
|
return _then(_value.copyWith(
|
||||||
@@ -75,6 +78,10 @@ class _$AccessControlCopyWithImpl<$Res, $Val extends AccessControl>
|
|||||||
? _value.rejectList
|
? _value.rejectList
|
||||||
: rejectList // ignore: cast_nullable_to_non_nullable
|
: rejectList // ignore: cast_nullable_to_non_nullable
|
||||||
as List<String>,
|
as List<String>,
|
||||||
|
sort: null == sort
|
||||||
|
? _value.sort
|
||||||
|
: sort // ignore: cast_nullable_to_non_nullable
|
||||||
|
as AccessSortType,
|
||||||
isFilterSystemApp: null == isFilterSystemApp
|
isFilterSystemApp: null == isFilterSystemApp
|
||||||
? _value.isFilterSystemApp
|
? _value.isFilterSystemApp
|
||||||
: isFilterSystemApp // ignore: cast_nullable_to_non_nullable
|
: isFilterSystemApp // ignore: cast_nullable_to_non_nullable
|
||||||
@@ -95,6 +102,7 @@ abstract class _$$AccessControlImplCopyWith<$Res>
|
|||||||
{AccessControlMode mode,
|
{AccessControlMode mode,
|
||||||
List<String> acceptList,
|
List<String> acceptList,
|
||||||
List<String> rejectList,
|
List<String> rejectList,
|
||||||
|
AccessSortType sort,
|
||||||
bool isFilterSystemApp});
|
bool isFilterSystemApp});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,6 +120,7 @@ class __$$AccessControlImplCopyWithImpl<$Res>
|
|||||||
Object? mode = null,
|
Object? mode = null,
|
||||||
Object? acceptList = null,
|
Object? acceptList = null,
|
||||||
Object? rejectList = null,
|
Object? rejectList = null,
|
||||||
|
Object? sort = null,
|
||||||
Object? isFilterSystemApp = null,
|
Object? isFilterSystemApp = null,
|
||||||
}) {
|
}) {
|
||||||
return _then(_$AccessControlImpl(
|
return _then(_$AccessControlImpl(
|
||||||
@@ -127,6 +136,10 @@ class __$$AccessControlImplCopyWithImpl<$Res>
|
|||||||
? _value._rejectList
|
? _value._rejectList
|
||||||
: rejectList // ignore: cast_nullable_to_non_nullable
|
: rejectList // ignore: cast_nullable_to_non_nullable
|
||||||
as List<String>,
|
as List<String>,
|
||||||
|
sort: null == sort
|
||||||
|
? _value.sort
|
||||||
|
: sort // ignore: cast_nullable_to_non_nullable
|
||||||
|
as AccessSortType,
|
||||||
isFilterSystemApp: null == isFilterSystemApp
|
isFilterSystemApp: null == isFilterSystemApp
|
||||||
? _value.isFilterSystemApp
|
? _value.isFilterSystemApp
|
||||||
: isFilterSystemApp // ignore: cast_nullable_to_non_nullable
|
: isFilterSystemApp // ignore: cast_nullable_to_non_nullable
|
||||||
@@ -142,6 +155,7 @@ class _$AccessControlImpl implements _AccessControl {
|
|||||||
{this.mode = AccessControlMode.rejectSelected,
|
{this.mode = AccessControlMode.rejectSelected,
|
||||||
final List<String> acceptList = const [],
|
final List<String> acceptList = const [],
|
||||||
final List<String> rejectList = const [],
|
final List<String> rejectList = const [],
|
||||||
|
this.sort = AccessSortType.none,
|
||||||
this.isFilterSystemApp = true})
|
this.isFilterSystemApp = true})
|
||||||
: _acceptList = acceptList,
|
: _acceptList = acceptList,
|
||||||
_rejectList = rejectList;
|
_rejectList = rejectList;
|
||||||
@@ -170,13 +184,16 @@ class _$AccessControlImpl implements _AccessControl {
|
|||||||
return EqualUnmodifiableListView(_rejectList);
|
return EqualUnmodifiableListView(_rejectList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@JsonKey()
|
||||||
|
final AccessSortType sort;
|
||||||
@override
|
@override
|
||||||
@JsonKey()
|
@JsonKey()
|
||||||
final bool isFilterSystemApp;
|
final bool isFilterSystemApp;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'AccessControl(mode: $mode, acceptList: $acceptList, rejectList: $rejectList, isFilterSystemApp: $isFilterSystemApp)';
|
return 'AccessControl(mode: $mode, acceptList: $acceptList, rejectList: $rejectList, sort: $sort, isFilterSystemApp: $isFilterSystemApp)';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -189,6 +206,7 @@ class _$AccessControlImpl implements _AccessControl {
|
|||||||
.equals(other._acceptList, _acceptList) &&
|
.equals(other._acceptList, _acceptList) &&
|
||||||
const DeepCollectionEquality()
|
const DeepCollectionEquality()
|
||||||
.equals(other._rejectList, _rejectList) &&
|
.equals(other._rejectList, _rejectList) &&
|
||||||
|
(identical(other.sort, sort) || other.sort == sort) &&
|
||||||
(identical(other.isFilterSystemApp, isFilterSystemApp) ||
|
(identical(other.isFilterSystemApp, isFilterSystemApp) ||
|
||||||
other.isFilterSystemApp == isFilterSystemApp));
|
other.isFilterSystemApp == isFilterSystemApp));
|
||||||
}
|
}
|
||||||
@@ -200,6 +218,7 @@ class _$AccessControlImpl implements _AccessControl {
|
|||||||
mode,
|
mode,
|
||||||
const DeepCollectionEquality().hash(_acceptList),
|
const DeepCollectionEquality().hash(_acceptList),
|
||||||
const DeepCollectionEquality().hash(_rejectList),
|
const DeepCollectionEquality().hash(_rejectList),
|
||||||
|
sort,
|
||||||
isFilterSystemApp);
|
isFilterSystemApp);
|
||||||
|
|
||||||
@JsonKey(ignore: true)
|
@JsonKey(ignore: true)
|
||||||
@@ -221,6 +240,7 @@ abstract class _AccessControl implements AccessControl {
|
|||||||
{final AccessControlMode mode,
|
{final AccessControlMode mode,
|
||||||
final List<String> acceptList,
|
final List<String> acceptList,
|
||||||
final List<String> rejectList,
|
final List<String> rejectList,
|
||||||
|
final AccessSortType sort,
|
||||||
final bool isFilterSystemApp}) = _$AccessControlImpl;
|
final bool isFilterSystemApp}) = _$AccessControlImpl;
|
||||||
|
|
||||||
factory _AccessControl.fromJson(Map<String, dynamic> json) =
|
factory _AccessControl.fromJson(Map<String, dynamic> json) =
|
||||||
@@ -233,6 +253,8 @@ abstract class _AccessControl implements AccessControl {
|
|||||||
@override
|
@override
|
||||||
List<String> get rejectList;
|
List<String> get rejectList;
|
||||||
@override
|
@override
|
||||||
|
AccessSortType get sort;
|
||||||
|
@override
|
||||||
bool get isFilterSystemApp;
|
bool get isFilterSystemApp;
|
||||||
@override
|
@override
|
||||||
@JsonKey(ignore: true)
|
@JsonKey(ignore: true)
|
||||||
@@ -247,6 +269,8 @@ CoreState _$CoreStateFromJson(Map<String, dynamic> json) {
|
|||||||
/// @nodoc
|
/// @nodoc
|
||||||
mixin _$CoreState {
|
mixin _$CoreState {
|
||||||
AccessControl? get accessControl => throw _privateConstructorUsedError;
|
AccessControl? get accessControl => throw _privateConstructorUsedError;
|
||||||
|
String get currentProfileName => throw _privateConstructorUsedError;
|
||||||
|
bool get enable => throw _privateConstructorUsedError;
|
||||||
bool get allowBypass => throw _privateConstructorUsedError;
|
bool get allowBypass => throw _privateConstructorUsedError;
|
||||||
bool get systemProxy => throw _privateConstructorUsedError;
|
bool get systemProxy => throw _privateConstructorUsedError;
|
||||||
int get mixedPort => throw _privateConstructorUsedError;
|
int get mixedPort => throw _privateConstructorUsedError;
|
||||||
@@ -265,6 +289,8 @@ abstract class $CoreStateCopyWith<$Res> {
|
|||||||
@useResult
|
@useResult
|
||||||
$Res call(
|
$Res call(
|
||||||
{AccessControl? accessControl,
|
{AccessControl? accessControl,
|
||||||
|
String currentProfileName,
|
||||||
|
bool enable,
|
||||||
bool allowBypass,
|
bool allowBypass,
|
||||||
bool systemProxy,
|
bool systemProxy,
|
||||||
int mixedPort,
|
int mixedPort,
|
||||||
@@ -287,6 +313,8 @@ class _$CoreStateCopyWithImpl<$Res, $Val extends CoreState>
|
|||||||
@override
|
@override
|
||||||
$Res call({
|
$Res call({
|
||||||
Object? accessControl = freezed,
|
Object? accessControl = freezed,
|
||||||
|
Object? currentProfileName = null,
|
||||||
|
Object? enable = null,
|
||||||
Object? allowBypass = null,
|
Object? allowBypass = null,
|
||||||
Object? systemProxy = null,
|
Object? systemProxy = null,
|
||||||
Object? mixedPort = null,
|
Object? mixedPort = null,
|
||||||
@@ -297,6 +325,14 @@ class _$CoreStateCopyWithImpl<$Res, $Val extends CoreState>
|
|||||||
? _value.accessControl
|
? _value.accessControl
|
||||||
: accessControl // ignore: cast_nullable_to_non_nullable
|
: accessControl // ignore: cast_nullable_to_non_nullable
|
||||||
as AccessControl?,
|
as AccessControl?,
|
||||||
|
currentProfileName: null == currentProfileName
|
||||||
|
? _value.currentProfileName
|
||||||
|
: currentProfileName // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
|
enable: null == enable
|
||||||
|
? _value.enable
|
||||||
|
: enable // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
allowBypass: null == allowBypass
|
allowBypass: null == allowBypass
|
||||||
? _value.allowBypass
|
? _value.allowBypass
|
||||||
: allowBypass // ignore: cast_nullable_to_non_nullable
|
: allowBypass // ignore: cast_nullable_to_non_nullable
|
||||||
@@ -339,6 +375,8 @@ abstract class _$$CoreStateImplCopyWith<$Res>
|
|||||||
@useResult
|
@useResult
|
||||||
$Res call(
|
$Res call(
|
||||||
{AccessControl? accessControl,
|
{AccessControl? accessControl,
|
||||||
|
String currentProfileName,
|
||||||
|
bool enable,
|
||||||
bool allowBypass,
|
bool allowBypass,
|
||||||
bool systemProxy,
|
bool systemProxy,
|
||||||
int mixedPort,
|
int mixedPort,
|
||||||
@@ -360,6 +398,8 @@ class __$$CoreStateImplCopyWithImpl<$Res>
|
|||||||
@override
|
@override
|
||||||
$Res call({
|
$Res call({
|
||||||
Object? accessControl = freezed,
|
Object? accessControl = freezed,
|
||||||
|
Object? currentProfileName = null,
|
||||||
|
Object? enable = null,
|
||||||
Object? allowBypass = null,
|
Object? allowBypass = null,
|
||||||
Object? systemProxy = null,
|
Object? systemProxy = null,
|
||||||
Object? mixedPort = null,
|
Object? mixedPort = null,
|
||||||
@@ -370,6 +410,14 @@ class __$$CoreStateImplCopyWithImpl<$Res>
|
|||||||
? _value.accessControl
|
? _value.accessControl
|
||||||
: accessControl // ignore: cast_nullable_to_non_nullable
|
: accessControl // ignore: cast_nullable_to_non_nullable
|
||||||
as AccessControl?,
|
as AccessControl?,
|
||||||
|
currentProfileName: null == currentProfileName
|
||||||
|
? _value.currentProfileName
|
||||||
|
: currentProfileName // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
|
enable: null == enable
|
||||||
|
? _value.enable
|
||||||
|
: enable // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
allowBypass: null == allowBypass
|
allowBypass: null == allowBypass
|
||||||
? _value.allowBypass
|
? _value.allowBypass
|
||||||
: allowBypass // ignore: cast_nullable_to_non_nullable
|
: allowBypass // ignore: cast_nullable_to_non_nullable
|
||||||
@@ -395,6 +443,8 @@ class __$$CoreStateImplCopyWithImpl<$Res>
|
|||||||
class _$CoreStateImpl implements _CoreState {
|
class _$CoreStateImpl implements _CoreState {
|
||||||
const _$CoreStateImpl(
|
const _$CoreStateImpl(
|
||||||
{this.accessControl,
|
{this.accessControl,
|
||||||
|
required this.currentProfileName,
|
||||||
|
required this.enable,
|
||||||
required this.allowBypass,
|
required this.allowBypass,
|
||||||
required this.systemProxy,
|
required this.systemProxy,
|
||||||
required this.mixedPort,
|
required this.mixedPort,
|
||||||
@@ -406,6 +456,10 @@ class _$CoreStateImpl implements _CoreState {
|
|||||||
@override
|
@override
|
||||||
final AccessControl? accessControl;
|
final AccessControl? accessControl;
|
||||||
@override
|
@override
|
||||||
|
final String currentProfileName;
|
||||||
|
@override
|
||||||
|
final bool enable;
|
||||||
|
@override
|
||||||
final bool allowBypass;
|
final bool allowBypass;
|
||||||
@override
|
@override
|
||||||
final bool systemProxy;
|
final bool systemProxy;
|
||||||
@@ -416,7 +470,7 @@ class _$CoreStateImpl implements _CoreState {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'CoreState(accessControl: $accessControl, allowBypass: $allowBypass, systemProxy: $systemProxy, mixedPort: $mixedPort, onlyProxy: $onlyProxy)';
|
return 'CoreState(accessControl: $accessControl, currentProfileName: $currentProfileName, enable: $enable, allowBypass: $allowBypass, systemProxy: $systemProxy, mixedPort: $mixedPort, onlyProxy: $onlyProxy)';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -426,6 +480,9 @@ class _$CoreStateImpl implements _CoreState {
|
|||||||
other is _$CoreStateImpl &&
|
other is _$CoreStateImpl &&
|
||||||
(identical(other.accessControl, accessControl) ||
|
(identical(other.accessControl, accessControl) ||
|
||||||
other.accessControl == accessControl) &&
|
other.accessControl == accessControl) &&
|
||||||
|
(identical(other.currentProfileName, currentProfileName) ||
|
||||||
|
other.currentProfileName == currentProfileName) &&
|
||||||
|
(identical(other.enable, enable) || other.enable == enable) &&
|
||||||
(identical(other.allowBypass, allowBypass) ||
|
(identical(other.allowBypass, allowBypass) ||
|
||||||
other.allowBypass == allowBypass) &&
|
other.allowBypass == allowBypass) &&
|
||||||
(identical(other.systemProxy, systemProxy) ||
|
(identical(other.systemProxy, systemProxy) ||
|
||||||
@@ -438,8 +495,15 @@ class _$CoreStateImpl implements _CoreState {
|
|||||||
|
|
||||||
@JsonKey(ignore: true)
|
@JsonKey(ignore: true)
|
||||||
@override
|
@override
|
||||||
int get hashCode => Object.hash(runtimeType, accessControl, allowBypass,
|
int get hashCode => Object.hash(
|
||||||
systemProxy, mixedPort, onlyProxy);
|
runtimeType,
|
||||||
|
accessControl,
|
||||||
|
currentProfileName,
|
||||||
|
enable,
|
||||||
|
allowBypass,
|
||||||
|
systemProxy,
|
||||||
|
mixedPort,
|
||||||
|
onlyProxy);
|
||||||
|
|
||||||
@JsonKey(ignore: true)
|
@JsonKey(ignore: true)
|
||||||
@override
|
@override
|
||||||
@@ -458,6 +522,8 @@ class _$CoreStateImpl implements _CoreState {
|
|||||||
abstract class _CoreState implements CoreState {
|
abstract class _CoreState implements CoreState {
|
||||||
const factory _CoreState(
|
const factory _CoreState(
|
||||||
{final AccessControl? accessControl,
|
{final AccessControl? accessControl,
|
||||||
|
required final String currentProfileName,
|
||||||
|
required final bool enable,
|
||||||
required final bool allowBypass,
|
required final bool allowBypass,
|
||||||
required final bool systemProxy,
|
required final bool systemProxy,
|
||||||
required final int mixedPort,
|
required final int mixedPort,
|
||||||
@@ -469,6 +535,10 @@ abstract class _CoreState implements CoreState {
|
|||||||
@override
|
@override
|
||||||
AccessControl? get accessControl;
|
AccessControl? get accessControl;
|
||||||
@override
|
@override
|
||||||
|
String get currentProfileName;
|
||||||
|
@override
|
||||||
|
bool get enable;
|
||||||
|
@override
|
||||||
bool get allowBypass;
|
bool get allowBypass;
|
||||||
@override
|
@override
|
||||||
bool get systemProxy;
|
bool get systemProxy;
|
||||||
@@ -672,3 +742,318 @@ abstract class _WindowProps implements WindowProps {
|
|||||||
_$$WindowPropsImplCopyWith<_$WindowPropsImpl> get copyWith =>
|
_$$WindowPropsImplCopyWith<_$WindowPropsImpl> get copyWith =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VpnProps _$VpnPropsFromJson(Map<String, dynamic> json) {
|
||||||
|
return _VpnProps.fromJson(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
mixin _$VpnProps {
|
||||||
|
bool get enable => throw _privateConstructorUsedError;
|
||||||
|
bool get systemProxy => throw _privateConstructorUsedError;
|
||||||
|
bool get allowBypass => throw _privateConstructorUsedError;
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
$VpnPropsCopyWith<VpnProps> get copyWith =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class $VpnPropsCopyWith<$Res> {
|
||||||
|
factory $VpnPropsCopyWith(VpnProps value, $Res Function(VpnProps) then) =
|
||||||
|
_$VpnPropsCopyWithImpl<$Res, VpnProps>;
|
||||||
|
@useResult
|
||||||
|
$Res call({bool enable, bool systemProxy, bool allowBypass});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class _$VpnPropsCopyWithImpl<$Res, $Val extends VpnProps>
|
||||||
|
implements $VpnPropsCopyWith<$Res> {
|
||||||
|
_$VpnPropsCopyWithImpl(this._value, this._then);
|
||||||
|
|
||||||
|
// ignore: unused_field
|
||||||
|
final $Val _value;
|
||||||
|
// ignore: unused_field
|
||||||
|
final $Res Function($Val) _then;
|
||||||
|
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
@override
|
||||||
|
$Res call({
|
||||||
|
Object? enable = null,
|
||||||
|
Object? systemProxy = null,
|
||||||
|
Object? allowBypass = null,
|
||||||
|
}) {
|
||||||
|
return _then(_value.copyWith(
|
||||||
|
enable: null == enable
|
||||||
|
? _value.enable
|
||||||
|
: enable // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
systemProxy: null == systemProxy
|
||||||
|
? _value.systemProxy
|
||||||
|
: systemProxy // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
allowBypass: null == allowBypass
|
||||||
|
? _value.allowBypass
|
||||||
|
: allowBypass // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
) as $Val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class _$$VpnPropsImplCopyWith<$Res>
|
||||||
|
implements $VpnPropsCopyWith<$Res> {
|
||||||
|
factory _$$VpnPropsImplCopyWith(
|
||||||
|
_$VpnPropsImpl value, $Res Function(_$VpnPropsImpl) then) =
|
||||||
|
__$$VpnPropsImplCopyWithImpl<$Res>;
|
||||||
|
@override
|
||||||
|
@useResult
|
||||||
|
$Res call({bool enable, bool systemProxy, bool allowBypass});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class __$$VpnPropsImplCopyWithImpl<$Res>
|
||||||
|
extends _$VpnPropsCopyWithImpl<$Res, _$VpnPropsImpl>
|
||||||
|
implements _$$VpnPropsImplCopyWith<$Res> {
|
||||||
|
__$$VpnPropsImplCopyWithImpl(
|
||||||
|
_$VpnPropsImpl _value, $Res Function(_$VpnPropsImpl) _then)
|
||||||
|
: super(_value, _then);
|
||||||
|
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
@override
|
||||||
|
$Res call({
|
||||||
|
Object? enable = null,
|
||||||
|
Object? systemProxy = null,
|
||||||
|
Object? allowBypass = null,
|
||||||
|
}) {
|
||||||
|
return _then(_$VpnPropsImpl(
|
||||||
|
enable: null == enable
|
||||||
|
? _value.enable
|
||||||
|
: enable // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
systemProxy: null == systemProxy
|
||||||
|
? _value.systemProxy
|
||||||
|
: systemProxy // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
allowBypass: null == allowBypass
|
||||||
|
? _value.allowBypass
|
||||||
|
: allowBypass // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
@JsonSerializable()
|
||||||
|
class _$VpnPropsImpl implements _VpnProps {
|
||||||
|
const _$VpnPropsImpl(
|
||||||
|
{this.enable = true, this.systemProxy = false, this.allowBypass = true});
|
||||||
|
|
||||||
|
factory _$VpnPropsImpl.fromJson(Map<String, dynamic> json) =>
|
||||||
|
_$$VpnPropsImplFromJson(json);
|
||||||
|
|
||||||
|
@override
|
||||||
|
@JsonKey()
|
||||||
|
final bool enable;
|
||||||
|
@override
|
||||||
|
@JsonKey()
|
||||||
|
final bool systemProxy;
|
||||||
|
@override
|
||||||
|
@JsonKey()
|
||||||
|
final bool allowBypass;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'VpnProps(enable: $enable, systemProxy: $systemProxy, allowBypass: $allowBypass)';
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return identical(this, other) ||
|
||||||
|
(other.runtimeType == runtimeType &&
|
||||||
|
other is _$VpnPropsImpl &&
|
||||||
|
(identical(other.enable, enable) || other.enable == enable) &&
|
||||||
|
(identical(other.systemProxy, systemProxy) ||
|
||||||
|
other.systemProxy == systemProxy) &&
|
||||||
|
(identical(other.allowBypass, allowBypass) ||
|
||||||
|
other.allowBypass == allowBypass));
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
@override
|
||||||
|
int get hashCode =>
|
||||||
|
Object.hash(runtimeType, enable, systemProxy, allowBypass);
|
||||||
|
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
@override
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
_$$VpnPropsImplCopyWith<_$VpnPropsImpl> get copyWith =>
|
||||||
|
__$$VpnPropsImplCopyWithImpl<_$VpnPropsImpl>(this, _$identity);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
return _$$VpnPropsImplToJson(
|
||||||
|
this,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class _VpnProps implements VpnProps {
|
||||||
|
const factory _VpnProps(
|
||||||
|
{final bool enable,
|
||||||
|
final bool systemProxy,
|
||||||
|
final bool allowBypass}) = _$VpnPropsImpl;
|
||||||
|
|
||||||
|
factory _VpnProps.fromJson(Map<String, dynamic> json) =
|
||||||
|
_$VpnPropsImpl.fromJson;
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool get enable;
|
||||||
|
@override
|
||||||
|
bool get systemProxy;
|
||||||
|
@override
|
||||||
|
bool get allowBypass;
|
||||||
|
@override
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
_$$VpnPropsImplCopyWith<_$VpnPropsImpl> get copyWith =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
}
|
||||||
|
|
||||||
|
DesktopProps _$DesktopPropsFromJson(Map<String, dynamic> json) {
|
||||||
|
return _DesktopProps.fromJson(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
mixin _$DesktopProps {
|
||||||
|
bool get systemProxy => throw _privateConstructorUsedError;
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
$DesktopPropsCopyWith<DesktopProps> get copyWith =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class $DesktopPropsCopyWith<$Res> {
|
||||||
|
factory $DesktopPropsCopyWith(
|
||||||
|
DesktopProps value, $Res Function(DesktopProps) then) =
|
||||||
|
_$DesktopPropsCopyWithImpl<$Res, DesktopProps>;
|
||||||
|
@useResult
|
||||||
|
$Res call({bool systemProxy});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class _$DesktopPropsCopyWithImpl<$Res, $Val extends DesktopProps>
|
||||||
|
implements $DesktopPropsCopyWith<$Res> {
|
||||||
|
_$DesktopPropsCopyWithImpl(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? systemProxy = null,
|
||||||
|
}) {
|
||||||
|
return _then(_value.copyWith(
|
||||||
|
systemProxy: null == systemProxy
|
||||||
|
? _value.systemProxy
|
||||||
|
: systemProxy // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
) as $Val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class _$$DesktopPropsImplCopyWith<$Res>
|
||||||
|
implements $DesktopPropsCopyWith<$Res> {
|
||||||
|
factory _$$DesktopPropsImplCopyWith(
|
||||||
|
_$DesktopPropsImpl value, $Res Function(_$DesktopPropsImpl) then) =
|
||||||
|
__$$DesktopPropsImplCopyWithImpl<$Res>;
|
||||||
|
@override
|
||||||
|
@useResult
|
||||||
|
$Res call({bool systemProxy});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class __$$DesktopPropsImplCopyWithImpl<$Res>
|
||||||
|
extends _$DesktopPropsCopyWithImpl<$Res, _$DesktopPropsImpl>
|
||||||
|
implements _$$DesktopPropsImplCopyWith<$Res> {
|
||||||
|
__$$DesktopPropsImplCopyWithImpl(
|
||||||
|
_$DesktopPropsImpl _value, $Res Function(_$DesktopPropsImpl) _then)
|
||||||
|
: super(_value, _then);
|
||||||
|
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
@override
|
||||||
|
$Res call({
|
||||||
|
Object? systemProxy = null,
|
||||||
|
}) {
|
||||||
|
return _then(_$DesktopPropsImpl(
|
||||||
|
systemProxy: null == systemProxy
|
||||||
|
? _value.systemProxy
|
||||||
|
: systemProxy // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
@JsonSerializable()
|
||||||
|
class _$DesktopPropsImpl implements _DesktopProps {
|
||||||
|
const _$DesktopPropsImpl({this.systemProxy = true});
|
||||||
|
|
||||||
|
factory _$DesktopPropsImpl.fromJson(Map<String, dynamic> json) =>
|
||||||
|
_$$DesktopPropsImplFromJson(json);
|
||||||
|
|
||||||
|
@override
|
||||||
|
@JsonKey()
|
||||||
|
final bool systemProxy;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'DesktopProps(systemProxy: $systemProxy)';
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return identical(this, other) ||
|
||||||
|
(other.runtimeType == runtimeType &&
|
||||||
|
other is _$DesktopPropsImpl &&
|
||||||
|
(identical(other.systemProxy, systemProxy) ||
|
||||||
|
other.systemProxy == systemProxy));
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
@override
|
||||||
|
int get hashCode => Object.hash(runtimeType, systemProxy);
|
||||||
|
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
@override
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
_$$DesktopPropsImplCopyWith<_$DesktopPropsImpl> get copyWith =>
|
||||||
|
__$$DesktopPropsImplCopyWithImpl<_$DesktopPropsImpl>(this, _$identity);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
return _$$DesktopPropsImplToJson(
|
||||||
|
this,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class _DesktopProps implements DesktopProps {
|
||||||
|
const factory _DesktopProps({final bool systemProxy}) = _$DesktopPropsImpl;
|
||||||
|
|
||||||
|
factory _DesktopProps.fromJson(Map<String, dynamic> json) =
|
||||||
|
_$DesktopPropsImpl.fromJson;
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool get systemProxy;
|
||||||
|
@override
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
_$$DesktopPropsImplCopyWith<_$DesktopPropsImpl> get copyWith =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
}
|
||||||
|
|||||||
@@ -23,6 +23,9 @@ Config _$ConfigFromJson(Map<String, dynamic> json) => Config()
|
|||||||
..proxiesSortType =
|
..proxiesSortType =
|
||||||
$enumDecodeNullable(_$ProxiesSortTypeEnumMap, json['proxiesSortType']) ??
|
$enumDecodeNullable(_$ProxiesSortTypeEnumMap, json['proxiesSortType']) ??
|
||||||
ProxiesSortType.none
|
ProxiesSortType.none
|
||||||
|
..proxiesLayout =
|
||||||
|
$enumDecodeNullable(_$ProxiesLayoutEnumMap, json['proxiesLayout']) ??
|
||||||
|
ProxiesLayout.standard
|
||||||
..isMinimizeOnExit = json['isMinimizeOnExit'] as bool? ?? true
|
..isMinimizeOnExit = json['isMinimizeOnExit'] as bool? ?? true
|
||||||
..isAccessControl = json['isAccessControl'] as bool? ?? false
|
..isAccessControl = json['isAccessControl'] as bool? ?? false
|
||||||
..accessControl =
|
..accessControl =
|
||||||
@@ -33,9 +36,8 @@ Config _$ConfigFromJson(Map<String, dynamic> json) => Config()
|
|||||||
..isAnimateToPage = json['isAnimateToPage'] as bool? ?? true
|
..isAnimateToPage = json['isAnimateToPage'] as bool? ?? true
|
||||||
..isCompatible = json['isCompatible'] as bool? ?? true
|
..isCompatible = json['isCompatible'] as bool? ?? true
|
||||||
..autoCheckUpdate = json['autoCheckUpdate'] as bool? ?? true
|
..autoCheckUpdate = json['autoCheckUpdate'] as bool? ?? true
|
||||||
..allowBypass = json['allowBypass'] as bool? ?? true
|
|
||||||
..systemProxy = json['systemProxy'] as bool? ?? false
|
|
||||||
..onlyProxy = json['onlyProxy'] as bool? ?? false
|
..onlyProxy = json['onlyProxy'] as bool? ?? false
|
||||||
|
..prueBlack = json['prueBlack'] as bool? ?? false
|
||||||
..isCloseConnections = json['isCloseConnections'] as bool? ?? false
|
..isCloseConnections = json['isCloseConnections'] as bool? ?? false
|
||||||
..proxiesType = $enumDecodeNullable(_$ProxiesTypeEnumMap, json['proxiesType'],
|
..proxiesType = $enumDecodeNullable(_$ProxiesTypeEnumMap, json['proxiesType'],
|
||||||
unknownValue: ProxiesType.tab) ??
|
unknownValue: ProxiesType.tab) ??
|
||||||
@@ -43,12 +45,15 @@ Config _$ConfigFromJson(Map<String, dynamic> json) => Config()
|
|||||||
..proxyCardType =
|
..proxyCardType =
|
||||||
$enumDecodeNullable(_$ProxyCardTypeEnumMap, json['proxyCardType']) ??
|
$enumDecodeNullable(_$ProxyCardTypeEnumMap, json['proxyCardType']) ??
|
||||||
ProxyCardType.expand
|
ProxyCardType.expand
|
||||||
..proxiesColumns = (json['proxiesColumns'] as num?)?.toInt() ?? 2
|
|
||||||
..testUrl =
|
..testUrl =
|
||||||
json['test-url'] as String? ?? 'https://www.gstatic.com/generate_204'
|
json['test-url'] as String? ?? 'https://www.gstatic.com/generate_204'
|
||||||
..isExclude = json['isExclude'] as bool? ?? false
|
..isExclude = json['isExclude'] as bool? ?? false
|
||||||
..windowProps =
|
..windowProps =
|
||||||
WindowProps.fromJson(json['windowProps'] as Map<String, dynamic>?);
|
WindowProps.fromJson(json['windowProps'] as Map<String, dynamic>?)
|
||||||
|
..vpnProps = VpnProps.fromJson(json['vpnProps'] as Map<String, dynamic>?)
|
||||||
|
..desktopProps =
|
||||||
|
DesktopProps.fromJson(json['desktopProps'] as Map<String, dynamic>?)
|
||||||
|
..showLabel = json['showLabel'] as bool? ?? false;
|
||||||
|
|
||||||
Map<String, dynamic> _$ConfigToJson(Config instance) => <String, dynamic>{
|
Map<String, dynamic> _$ConfigToJson(Config instance) => <String, dynamic>{
|
||||||
'profiles': instance.profiles,
|
'profiles': instance.profiles,
|
||||||
@@ -61,6 +66,7 @@ Map<String, dynamic> _$ConfigToJson(Config instance) => <String, dynamic>{
|
|||||||
'locale': instance.locale,
|
'locale': instance.locale,
|
||||||
'primaryColor': instance.primaryColor,
|
'primaryColor': instance.primaryColor,
|
||||||
'proxiesSortType': _$ProxiesSortTypeEnumMap[instance.proxiesSortType]!,
|
'proxiesSortType': _$ProxiesSortTypeEnumMap[instance.proxiesSortType]!,
|
||||||
|
'proxiesLayout': _$ProxiesLayoutEnumMap[instance.proxiesLayout]!,
|
||||||
'isMinimizeOnExit': instance.isMinimizeOnExit,
|
'isMinimizeOnExit': instance.isMinimizeOnExit,
|
||||||
'isAccessControl': instance.isAccessControl,
|
'isAccessControl': instance.isAccessControl,
|
||||||
'accessControl': instance.accessControl,
|
'accessControl': instance.accessControl,
|
||||||
@@ -68,16 +74,17 @@ Map<String, dynamic> _$ConfigToJson(Config instance) => <String, dynamic>{
|
|||||||
'isAnimateToPage': instance.isAnimateToPage,
|
'isAnimateToPage': instance.isAnimateToPage,
|
||||||
'isCompatible': instance.isCompatible,
|
'isCompatible': instance.isCompatible,
|
||||||
'autoCheckUpdate': instance.autoCheckUpdate,
|
'autoCheckUpdate': instance.autoCheckUpdate,
|
||||||
'allowBypass': instance.allowBypass,
|
|
||||||
'systemProxy': instance.systemProxy,
|
|
||||||
'onlyProxy': instance.onlyProxy,
|
'onlyProxy': instance.onlyProxy,
|
||||||
|
'prueBlack': instance.prueBlack,
|
||||||
'isCloseConnections': instance.isCloseConnections,
|
'isCloseConnections': instance.isCloseConnections,
|
||||||
'proxiesType': _$ProxiesTypeEnumMap[instance.proxiesType]!,
|
'proxiesType': _$ProxiesTypeEnumMap[instance.proxiesType]!,
|
||||||
'proxyCardType': _$ProxyCardTypeEnumMap[instance.proxyCardType]!,
|
'proxyCardType': _$ProxyCardTypeEnumMap[instance.proxyCardType]!,
|
||||||
'proxiesColumns': instance.proxiesColumns,
|
|
||||||
'test-url': instance.testUrl,
|
'test-url': instance.testUrl,
|
||||||
'isExclude': instance.isExclude,
|
'isExclude': instance.isExclude,
|
||||||
'windowProps': instance.windowProps,
|
'windowProps': instance.windowProps,
|
||||||
|
'vpnProps': instance.vpnProps,
|
||||||
|
'desktopProps': instance.desktopProps,
|
||||||
|
'showLabel': instance.showLabel,
|
||||||
};
|
};
|
||||||
|
|
||||||
const _$ThemeModeEnumMap = {
|
const _$ThemeModeEnumMap = {
|
||||||
@@ -92,6 +99,12 @@ const _$ProxiesSortTypeEnumMap = {
|
|||||||
ProxiesSortType.name: 'name',
|
ProxiesSortType.name: 'name',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const _$ProxiesLayoutEnumMap = {
|
||||||
|
ProxiesLayout.loose: 'loose',
|
||||||
|
ProxiesLayout.standard: 'standard',
|
||||||
|
ProxiesLayout.tight: 'tight',
|
||||||
|
};
|
||||||
|
|
||||||
const _$ProxiesTypeEnumMap = {
|
const _$ProxiesTypeEnumMap = {
|
||||||
ProxiesType.tab: 'tab',
|
ProxiesType.tab: 'tab',
|
||||||
ProxiesType.list: 'list',
|
ProxiesType.list: 'list',
|
||||||
@@ -115,6 +128,8 @@ _$AccessControlImpl _$$AccessControlImplFromJson(Map<String, dynamic> json) =>
|
|||||||
?.map((e) => e as String)
|
?.map((e) => e as String)
|
||||||
.toList() ??
|
.toList() ??
|
||||||
const [],
|
const [],
|
||||||
|
sort: $enumDecodeNullable(_$AccessSortTypeEnumMap, json['sort']) ??
|
||||||
|
AccessSortType.none,
|
||||||
isFilterSystemApp: json['isFilterSystemApp'] as bool? ?? true,
|
isFilterSystemApp: json['isFilterSystemApp'] as bool? ?? true,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -123,6 +138,7 @@ Map<String, dynamic> _$$AccessControlImplToJson(_$AccessControlImpl instance) =>
|
|||||||
'mode': _$AccessControlModeEnumMap[instance.mode]!,
|
'mode': _$AccessControlModeEnumMap[instance.mode]!,
|
||||||
'acceptList': instance.acceptList,
|
'acceptList': instance.acceptList,
|
||||||
'rejectList': instance.rejectList,
|
'rejectList': instance.rejectList,
|
||||||
|
'sort': _$AccessSortTypeEnumMap[instance.sort]!,
|
||||||
'isFilterSystemApp': instance.isFilterSystemApp,
|
'isFilterSystemApp': instance.isFilterSystemApp,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -131,12 +147,20 @@ const _$AccessControlModeEnumMap = {
|
|||||||
AccessControlMode.rejectSelected: 'rejectSelected',
|
AccessControlMode.rejectSelected: 'rejectSelected',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const _$AccessSortTypeEnumMap = {
|
||||||
|
AccessSortType.none: 'none',
|
||||||
|
AccessSortType.name: 'name',
|
||||||
|
AccessSortType.time: 'time',
|
||||||
|
};
|
||||||
|
|
||||||
_$CoreStateImpl _$$CoreStateImplFromJson(Map<String, dynamic> json) =>
|
_$CoreStateImpl _$$CoreStateImplFromJson(Map<String, dynamic> json) =>
|
||||||
_$CoreStateImpl(
|
_$CoreStateImpl(
|
||||||
accessControl: json['accessControl'] == null
|
accessControl: json['accessControl'] == null
|
||||||
? null
|
? null
|
||||||
: AccessControl.fromJson(
|
: AccessControl.fromJson(
|
||||||
json['accessControl'] as Map<String, dynamic>),
|
json['accessControl'] as Map<String, dynamic>),
|
||||||
|
currentProfileName: json['currentProfileName'] as String,
|
||||||
|
enable: json['enable'] as bool,
|
||||||
allowBypass: json['allowBypass'] as bool,
|
allowBypass: json['allowBypass'] as bool,
|
||||||
systemProxy: json['systemProxy'] as bool,
|
systemProxy: json['systemProxy'] as bool,
|
||||||
mixedPort: (json['mixedPort'] as num).toInt(),
|
mixedPort: (json['mixedPort'] as num).toInt(),
|
||||||
@@ -146,6 +170,8 @@ _$CoreStateImpl _$$CoreStateImplFromJson(Map<String, dynamic> json) =>
|
|||||||
Map<String, dynamic> _$$CoreStateImplToJson(_$CoreStateImpl instance) =>
|
Map<String, dynamic> _$$CoreStateImplToJson(_$CoreStateImpl instance) =>
|
||||||
<String, dynamic>{
|
<String, dynamic>{
|
||||||
'accessControl': instance.accessControl,
|
'accessControl': instance.accessControl,
|
||||||
|
'currentProfileName': instance.currentProfileName,
|
||||||
|
'enable': instance.enable,
|
||||||
'allowBypass': instance.allowBypass,
|
'allowBypass': instance.allowBypass,
|
||||||
'systemProxy': instance.systemProxy,
|
'systemProxy': instance.systemProxy,
|
||||||
'mixedPort': instance.mixedPort,
|
'mixedPort': instance.mixedPort,
|
||||||
@@ -167,3 +193,27 @@ Map<String, dynamic> _$$WindowPropsImplToJson(_$WindowPropsImpl instance) =>
|
|||||||
'top': instance.top,
|
'top': instance.top,
|
||||||
'left': instance.left,
|
'left': instance.left,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
_$VpnPropsImpl _$$VpnPropsImplFromJson(Map<String, dynamic> json) =>
|
||||||
|
_$VpnPropsImpl(
|
||||||
|
enable: json['enable'] as bool? ?? true,
|
||||||
|
systemProxy: json['systemProxy'] as bool? ?? false,
|
||||||
|
allowBypass: json['allowBypass'] as bool? ?? true,
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> _$$VpnPropsImplToJson(_$VpnPropsImpl instance) =>
|
||||||
|
<String, dynamic>{
|
||||||
|
'enable': instance.enable,
|
||||||
|
'systemProxy': instance.systemProxy,
|
||||||
|
'allowBypass': instance.allowBypass,
|
||||||
|
};
|
||||||
|
|
||||||
|
_$DesktopPropsImpl _$$DesktopPropsImplFromJson(Map<String, dynamic> json) =>
|
||||||
|
_$DesktopPropsImpl(
|
||||||
|
systemProxy: json['systemProxy'] as bool? ?? true,
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> _$$DesktopPropsImplToJson(_$DesktopPropsImpl instance) =>
|
||||||
|
<String, dynamic>{
|
||||||
|
'systemProxy': instance.systemProxy,
|
||||||
|
};
|
||||||
|
|||||||
@@ -248,8 +248,8 @@ UpdateConfigParams _$UpdateConfigParamsFromJson(Map<String, dynamic> json) {
|
|||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
mixin _$UpdateConfigParams {
|
mixin _$UpdateConfigParams {
|
||||||
@JsonKey(name: "profile-path")
|
@JsonKey(name: "profile-id")
|
||||||
String? get profilePath => throw _privateConstructorUsedError;
|
String get profileId => throw _privateConstructorUsedError;
|
||||||
ClashConfig get config => throw _privateConstructorUsedError;
|
ClashConfig get config => throw _privateConstructorUsedError;
|
||||||
ConfigExtendedParams get params => throw _privateConstructorUsedError;
|
ConfigExtendedParams get params => throw _privateConstructorUsedError;
|
||||||
|
|
||||||
@@ -266,7 +266,7 @@ abstract class $UpdateConfigParamsCopyWith<$Res> {
|
|||||||
_$UpdateConfigParamsCopyWithImpl<$Res, UpdateConfigParams>;
|
_$UpdateConfigParamsCopyWithImpl<$Res, UpdateConfigParams>;
|
||||||
@useResult
|
@useResult
|
||||||
$Res call(
|
$Res call(
|
||||||
{@JsonKey(name: "profile-path") String? profilePath,
|
{@JsonKey(name: "profile-id") String profileId,
|
||||||
ClashConfig config,
|
ClashConfig config,
|
||||||
ConfigExtendedParams params});
|
ConfigExtendedParams params});
|
||||||
|
|
||||||
@@ -286,15 +286,15 @@ class _$UpdateConfigParamsCopyWithImpl<$Res, $Val extends UpdateConfigParams>
|
|||||||
@pragma('vm:prefer-inline')
|
@pragma('vm:prefer-inline')
|
||||||
@override
|
@override
|
||||||
$Res call({
|
$Res call({
|
||||||
Object? profilePath = freezed,
|
Object? profileId = null,
|
||||||
Object? config = null,
|
Object? config = null,
|
||||||
Object? params = null,
|
Object? params = null,
|
||||||
}) {
|
}) {
|
||||||
return _then(_value.copyWith(
|
return _then(_value.copyWith(
|
||||||
profilePath: freezed == profilePath
|
profileId: null == profileId
|
||||||
? _value.profilePath
|
? _value.profileId
|
||||||
: profilePath // ignore: cast_nullable_to_non_nullable
|
: profileId // ignore: cast_nullable_to_non_nullable
|
||||||
as String?,
|
as String,
|
||||||
config: null == config
|
config: null == config
|
||||||
? _value.config
|
? _value.config
|
||||||
: config // ignore: cast_nullable_to_non_nullable
|
: config // ignore: cast_nullable_to_non_nullable
|
||||||
@@ -324,7 +324,7 @@ abstract class _$$UpdateConfigParamsImplCopyWith<$Res>
|
|||||||
@override
|
@override
|
||||||
@useResult
|
@useResult
|
||||||
$Res call(
|
$Res call(
|
||||||
{@JsonKey(name: "profile-path") String? profilePath,
|
{@JsonKey(name: "profile-id") String profileId,
|
||||||
ClashConfig config,
|
ClashConfig config,
|
||||||
ConfigExtendedParams params});
|
ConfigExtendedParams params});
|
||||||
|
|
||||||
@@ -343,15 +343,15 @@ class __$$UpdateConfigParamsImplCopyWithImpl<$Res>
|
|||||||
@pragma('vm:prefer-inline')
|
@pragma('vm:prefer-inline')
|
||||||
@override
|
@override
|
||||||
$Res call({
|
$Res call({
|
||||||
Object? profilePath = freezed,
|
Object? profileId = null,
|
||||||
Object? config = null,
|
Object? config = null,
|
||||||
Object? params = null,
|
Object? params = null,
|
||||||
}) {
|
}) {
|
||||||
return _then(_$UpdateConfigParamsImpl(
|
return _then(_$UpdateConfigParamsImpl(
|
||||||
profilePath: freezed == profilePath
|
profileId: null == profileId
|
||||||
? _value.profilePath
|
? _value.profileId
|
||||||
: profilePath // ignore: cast_nullable_to_non_nullable
|
: profileId // ignore: cast_nullable_to_non_nullable
|
||||||
as String?,
|
as String,
|
||||||
config: null == config
|
config: null == config
|
||||||
? _value.config
|
? _value.config
|
||||||
: config // ignore: cast_nullable_to_non_nullable
|
: config // ignore: cast_nullable_to_non_nullable
|
||||||
@@ -368,7 +368,7 @@ class __$$UpdateConfigParamsImplCopyWithImpl<$Res>
|
|||||||
@JsonSerializable()
|
@JsonSerializable()
|
||||||
class _$UpdateConfigParamsImpl implements _UpdateConfigParams {
|
class _$UpdateConfigParamsImpl implements _UpdateConfigParams {
|
||||||
const _$UpdateConfigParamsImpl(
|
const _$UpdateConfigParamsImpl(
|
||||||
{@JsonKey(name: "profile-path") this.profilePath,
|
{@JsonKey(name: "profile-id") required this.profileId,
|
||||||
required this.config,
|
required this.config,
|
||||||
required this.params});
|
required this.params});
|
||||||
|
|
||||||
@@ -376,8 +376,8 @@ class _$UpdateConfigParamsImpl implements _UpdateConfigParams {
|
|||||||
_$$UpdateConfigParamsImplFromJson(json);
|
_$$UpdateConfigParamsImplFromJson(json);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@JsonKey(name: "profile-path")
|
@JsonKey(name: "profile-id")
|
||||||
final String? profilePath;
|
final String profileId;
|
||||||
@override
|
@override
|
||||||
final ClashConfig config;
|
final ClashConfig config;
|
||||||
@override
|
@override
|
||||||
@@ -385,7 +385,7 @@ class _$UpdateConfigParamsImpl implements _UpdateConfigParams {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'UpdateConfigParams(profilePath: $profilePath, config: $config, params: $params)';
|
return 'UpdateConfigParams(profileId: $profileId, config: $config, params: $params)';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -393,15 +393,15 @@ class _$UpdateConfigParamsImpl implements _UpdateConfigParams {
|
|||||||
return identical(this, other) ||
|
return identical(this, other) ||
|
||||||
(other.runtimeType == runtimeType &&
|
(other.runtimeType == runtimeType &&
|
||||||
other is _$UpdateConfigParamsImpl &&
|
other is _$UpdateConfigParamsImpl &&
|
||||||
(identical(other.profilePath, profilePath) ||
|
(identical(other.profileId, profileId) ||
|
||||||
other.profilePath == profilePath) &&
|
other.profileId == profileId) &&
|
||||||
(identical(other.config, config) || other.config == config) &&
|
(identical(other.config, config) || other.config == config) &&
|
||||||
(identical(other.params, params) || other.params == params));
|
(identical(other.params, params) || other.params == params));
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonKey(ignore: true)
|
@JsonKey(ignore: true)
|
||||||
@override
|
@override
|
||||||
int get hashCode => Object.hash(runtimeType, profilePath, config, params);
|
int get hashCode => Object.hash(runtimeType, profileId, config, params);
|
||||||
|
|
||||||
@JsonKey(ignore: true)
|
@JsonKey(ignore: true)
|
||||||
@override
|
@override
|
||||||
@@ -420,7 +420,7 @@ class _$UpdateConfigParamsImpl implements _UpdateConfigParams {
|
|||||||
|
|
||||||
abstract class _UpdateConfigParams implements UpdateConfigParams {
|
abstract class _UpdateConfigParams implements UpdateConfigParams {
|
||||||
const factory _UpdateConfigParams(
|
const factory _UpdateConfigParams(
|
||||||
{@JsonKey(name: "profile-path") final String? profilePath,
|
{@JsonKey(name: "profile-id") required final String profileId,
|
||||||
required final ClashConfig config,
|
required final ClashConfig config,
|
||||||
required final ConfigExtendedParams params}) = _$UpdateConfigParamsImpl;
|
required final ConfigExtendedParams params}) = _$UpdateConfigParamsImpl;
|
||||||
|
|
||||||
@@ -428,8 +428,8 @@ abstract class _UpdateConfigParams implements UpdateConfigParams {
|
|||||||
_$UpdateConfigParamsImpl.fromJson;
|
_$UpdateConfigParamsImpl.fromJson;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@JsonKey(name: "profile-path")
|
@JsonKey(name: "profile-id")
|
||||||
String? get profilePath;
|
String get profileId;
|
||||||
@override
|
@override
|
||||||
ClashConfig get config;
|
ClashConfig get config;
|
||||||
@override
|
@override
|
||||||
@@ -1687,6 +1687,9 @@ ExternalProvider _$ExternalProviderFromJson(Map<String, dynamic> json) {
|
|||||||
mixin _$ExternalProvider {
|
mixin _$ExternalProvider {
|
||||||
String get name => throw _privateConstructorUsedError;
|
String get name => throw _privateConstructorUsedError;
|
||||||
String get type => throw _privateConstructorUsedError;
|
String get type => throw _privateConstructorUsedError;
|
||||||
|
String get path => throw _privateConstructorUsedError;
|
||||||
|
int get count => throw _privateConstructorUsedError;
|
||||||
|
bool get isUpdating => throw _privateConstructorUsedError;
|
||||||
@JsonKey(name: "vehicle-type")
|
@JsonKey(name: "vehicle-type")
|
||||||
String get vehicleType => throw _privateConstructorUsedError;
|
String get vehicleType => throw _privateConstructorUsedError;
|
||||||
@JsonKey(name: "update-at")
|
@JsonKey(name: "update-at")
|
||||||
@@ -1707,6 +1710,9 @@ abstract class $ExternalProviderCopyWith<$Res> {
|
|||||||
$Res call(
|
$Res call(
|
||||||
{String name,
|
{String name,
|
||||||
String type,
|
String type,
|
||||||
|
String path,
|
||||||
|
int count,
|
||||||
|
bool isUpdating,
|
||||||
@JsonKey(name: "vehicle-type") String vehicleType,
|
@JsonKey(name: "vehicle-type") String vehicleType,
|
||||||
@JsonKey(name: "update-at") DateTime updateAt});
|
@JsonKey(name: "update-at") DateTime updateAt});
|
||||||
}
|
}
|
||||||
@@ -1726,6 +1732,9 @@ class _$ExternalProviderCopyWithImpl<$Res, $Val extends ExternalProvider>
|
|||||||
$Res call({
|
$Res call({
|
||||||
Object? name = null,
|
Object? name = null,
|
||||||
Object? type = null,
|
Object? type = null,
|
||||||
|
Object? path = null,
|
||||||
|
Object? count = null,
|
||||||
|
Object? isUpdating = null,
|
||||||
Object? vehicleType = null,
|
Object? vehicleType = null,
|
||||||
Object? updateAt = null,
|
Object? updateAt = null,
|
||||||
}) {
|
}) {
|
||||||
@@ -1738,6 +1747,18 @@ class _$ExternalProviderCopyWithImpl<$Res, $Val extends ExternalProvider>
|
|||||||
? _value.type
|
? _value.type
|
||||||
: type // ignore: cast_nullable_to_non_nullable
|
: type // ignore: cast_nullable_to_non_nullable
|
||||||
as String,
|
as String,
|
||||||
|
path: null == path
|
||||||
|
? _value.path
|
||||||
|
: path // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
|
count: null == count
|
||||||
|
? _value.count
|
||||||
|
: count // ignore: cast_nullable_to_non_nullable
|
||||||
|
as int,
|
||||||
|
isUpdating: null == isUpdating
|
||||||
|
? _value.isUpdating
|
||||||
|
: isUpdating // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
vehicleType: null == vehicleType
|
vehicleType: null == vehicleType
|
||||||
? _value.vehicleType
|
? _value.vehicleType
|
||||||
: vehicleType // ignore: cast_nullable_to_non_nullable
|
: vehicleType // ignore: cast_nullable_to_non_nullable
|
||||||
@@ -1761,6 +1782,9 @@ abstract class _$$ExternalProviderImplCopyWith<$Res>
|
|||||||
$Res call(
|
$Res call(
|
||||||
{String name,
|
{String name,
|
||||||
String type,
|
String type,
|
||||||
|
String path,
|
||||||
|
int count,
|
||||||
|
bool isUpdating,
|
||||||
@JsonKey(name: "vehicle-type") String vehicleType,
|
@JsonKey(name: "vehicle-type") String vehicleType,
|
||||||
@JsonKey(name: "update-at") DateTime updateAt});
|
@JsonKey(name: "update-at") DateTime updateAt});
|
||||||
}
|
}
|
||||||
@@ -1778,6 +1802,9 @@ class __$$ExternalProviderImplCopyWithImpl<$Res>
|
|||||||
$Res call({
|
$Res call({
|
||||||
Object? name = null,
|
Object? name = null,
|
||||||
Object? type = null,
|
Object? type = null,
|
||||||
|
Object? path = null,
|
||||||
|
Object? count = null,
|
||||||
|
Object? isUpdating = null,
|
||||||
Object? vehicleType = null,
|
Object? vehicleType = null,
|
||||||
Object? updateAt = null,
|
Object? updateAt = null,
|
||||||
}) {
|
}) {
|
||||||
@@ -1790,6 +1817,18 @@ class __$$ExternalProviderImplCopyWithImpl<$Res>
|
|||||||
? _value.type
|
? _value.type
|
||||||
: type // ignore: cast_nullable_to_non_nullable
|
: type // ignore: cast_nullable_to_non_nullable
|
||||||
as String,
|
as String,
|
||||||
|
path: null == path
|
||||||
|
? _value.path
|
||||||
|
: path // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
|
count: null == count
|
||||||
|
? _value.count
|
||||||
|
: count // ignore: cast_nullable_to_non_nullable
|
||||||
|
as int,
|
||||||
|
isUpdating: null == isUpdating
|
||||||
|
? _value.isUpdating
|
||||||
|
: isUpdating // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
vehicleType: null == vehicleType
|
vehicleType: null == vehicleType
|
||||||
? _value.vehicleType
|
? _value.vehicleType
|
||||||
: vehicleType // ignore: cast_nullable_to_non_nullable
|
: vehicleType // ignore: cast_nullable_to_non_nullable
|
||||||
@@ -1808,6 +1847,9 @@ class _$ExternalProviderImpl implements _ExternalProvider {
|
|||||||
const _$ExternalProviderImpl(
|
const _$ExternalProviderImpl(
|
||||||
{required this.name,
|
{required this.name,
|
||||||
required this.type,
|
required this.type,
|
||||||
|
required this.path,
|
||||||
|
required this.count,
|
||||||
|
this.isUpdating = false,
|
||||||
@JsonKey(name: "vehicle-type") required this.vehicleType,
|
@JsonKey(name: "vehicle-type") required this.vehicleType,
|
||||||
@JsonKey(name: "update-at") required this.updateAt});
|
@JsonKey(name: "update-at") required this.updateAt});
|
||||||
|
|
||||||
@@ -1819,6 +1861,13 @@ class _$ExternalProviderImpl implements _ExternalProvider {
|
|||||||
@override
|
@override
|
||||||
final String type;
|
final String type;
|
||||||
@override
|
@override
|
||||||
|
final String path;
|
||||||
|
@override
|
||||||
|
final int count;
|
||||||
|
@override
|
||||||
|
@JsonKey()
|
||||||
|
final bool isUpdating;
|
||||||
|
@override
|
||||||
@JsonKey(name: "vehicle-type")
|
@JsonKey(name: "vehicle-type")
|
||||||
final String vehicleType;
|
final String vehicleType;
|
||||||
@override
|
@override
|
||||||
@@ -1827,7 +1876,7 @@ class _$ExternalProviderImpl implements _ExternalProvider {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'ExternalProvider(name: $name, type: $type, vehicleType: $vehicleType, updateAt: $updateAt)';
|
return 'ExternalProvider(name: $name, type: $type, path: $path, count: $count, isUpdating: $isUpdating, vehicleType: $vehicleType, updateAt: $updateAt)';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -1837,6 +1886,10 @@ class _$ExternalProviderImpl implements _ExternalProvider {
|
|||||||
other is _$ExternalProviderImpl &&
|
other is _$ExternalProviderImpl &&
|
||||||
(identical(other.name, name) || other.name == name) &&
|
(identical(other.name, name) || other.name == name) &&
|
||||||
(identical(other.type, type) || other.type == type) &&
|
(identical(other.type, type) || other.type == type) &&
|
||||||
|
(identical(other.path, path) || other.path == path) &&
|
||||||
|
(identical(other.count, count) || other.count == count) &&
|
||||||
|
(identical(other.isUpdating, isUpdating) ||
|
||||||
|
other.isUpdating == isUpdating) &&
|
||||||
(identical(other.vehicleType, vehicleType) ||
|
(identical(other.vehicleType, vehicleType) ||
|
||||||
other.vehicleType == vehicleType) &&
|
other.vehicleType == vehicleType) &&
|
||||||
(identical(other.updateAt, updateAt) ||
|
(identical(other.updateAt, updateAt) ||
|
||||||
@@ -1845,8 +1898,8 @@ class _$ExternalProviderImpl implements _ExternalProvider {
|
|||||||
|
|
||||||
@JsonKey(ignore: true)
|
@JsonKey(ignore: true)
|
||||||
@override
|
@override
|
||||||
int get hashCode =>
|
int get hashCode => Object.hash(
|
||||||
Object.hash(runtimeType, name, type, vehicleType, updateAt);
|
runtimeType, name, type, path, count, isUpdating, vehicleType, updateAt);
|
||||||
|
|
||||||
@JsonKey(ignore: true)
|
@JsonKey(ignore: true)
|
||||||
@override
|
@override
|
||||||
@@ -1867,6 +1920,9 @@ abstract class _ExternalProvider implements ExternalProvider {
|
|||||||
const factory _ExternalProvider(
|
const factory _ExternalProvider(
|
||||||
{required final String name,
|
{required final String name,
|
||||||
required final String type,
|
required final String type,
|
||||||
|
required final String path,
|
||||||
|
required final int count,
|
||||||
|
final bool isUpdating,
|
||||||
@JsonKey(name: "vehicle-type") required final String vehicleType,
|
@JsonKey(name: "vehicle-type") required final String vehicleType,
|
||||||
@JsonKey(name: "update-at") required final DateTime updateAt}) =
|
@JsonKey(name: "update-at") required final DateTime updateAt}) =
|
||||||
_$ExternalProviderImpl;
|
_$ExternalProviderImpl;
|
||||||
@@ -1879,6 +1935,12 @@ abstract class _ExternalProvider implements ExternalProvider {
|
|||||||
@override
|
@override
|
||||||
String get type;
|
String get type;
|
||||||
@override
|
@override
|
||||||
|
String get path;
|
||||||
|
@override
|
||||||
|
int get count;
|
||||||
|
@override
|
||||||
|
bool get isUpdating;
|
||||||
|
@override
|
||||||
@JsonKey(name: "vehicle-type")
|
@JsonKey(name: "vehicle-type")
|
||||||
String get vehicleType;
|
String get vehicleType;
|
||||||
@override
|
@override
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ Map<String, dynamic> _$$ConfigExtendedParamsImplToJson(
|
|||||||
_$UpdateConfigParamsImpl _$$UpdateConfigParamsImplFromJson(
|
_$UpdateConfigParamsImpl _$$UpdateConfigParamsImplFromJson(
|
||||||
Map<String, dynamic> json) =>
|
Map<String, dynamic> json) =>
|
||||||
_$UpdateConfigParamsImpl(
|
_$UpdateConfigParamsImpl(
|
||||||
profilePath: json['profile-path'] as String?,
|
profileId: json['profile-id'] as String,
|
||||||
config: ClashConfig.fromJson(json['config'] as Map<String, dynamic>),
|
config: ClashConfig.fromJson(json['config'] as Map<String, dynamic>),
|
||||||
params:
|
params:
|
||||||
ConfigExtendedParams.fromJson(json['params'] as Map<String, dynamic>),
|
ConfigExtendedParams.fromJson(json['params'] as Map<String, dynamic>),
|
||||||
@@ -36,7 +36,7 @@ _$UpdateConfigParamsImpl _$$UpdateConfigParamsImplFromJson(
|
|||||||
Map<String, dynamic> _$$UpdateConfigParamsImplToJson(
|
Map<String, dynamic> _$$UpdateConfigParamsImplToJson(
|
||||||
_$UpdateConfigParamsImpl instance) =>
|
_$UpdateConfigParamsImpl instance) =>
|
||||||
<String, dynamic>{
|
<String, dynamic>{
|
||||||
'profile-path': instance.profilePath,
|
'profile-id': instance.profileId,
|
||||||
'config': instance.config,
|
'config': instance.config,
|
||||||
'params': instance.params,
|
'params': instance.params,
|
||||||
};
|
};
|
||||||
@@ -156,6 +156,9 @@ _$ExternalProviderImpl _$$ExternalProviderImplFromJson(
|
|||||||
_$ExternalProviderImpl(
|
_$ExternalProviderImpl(
|
||||||
name: json['name'] as String,
|
name: json['name'] as String,
|
||||||
type: json['type'] as String,
|
type: json['type'] as String,
|
||||||
|
path: json['path'] as String,
|
||||||
|
count: (json['count'] as num).toInt(),
|
||||||
|
isUpdating: json['isUpdating'] as bool? ?? false,
|
||||||
vehicleType: json['vehicle-type'] as String,
|
vehicleType: json['vehicle-type'] as String,
|
||||||
updateAt: DateTime.parse(json['update-at'] as String),
|
updateAt: DateTime.parse(json['update-at'] as String),
|
||||||
);
|
);
|
||||||
@@ -165,6 +168,9 @@ Map<String, dynamic> _$$ExternalProviderImplToJson(
|
|||||||
<String, dynamic>{
|
<String, dynamic>{
|
||||||
'name': instance.name,
|
'name': instance.name,
|
||||||
'type': instance.type,
|
'type': instance.type,
|
||||||
|
'path': instance.path,
|
||||||
|
'count': instance.count,
|
||||||
|
'isUpdating': instance.isUpdating,
|
||||||
'vehicle-type': instance.vehicleType,
|
'vehicle-type': instance.vehicleType,
|
||||||
'update-at': instance.updateAt.toIso8601String(),
|
'update-at': instance.updateAt.toIso8601String(),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ mixin _$Package {
|
|||||||
String get packageName => throw _privateConstructorUsedError;
|
String get packageName => throw _privateConstructorUsedError;
|
||||||
String get label => throw _privateConstructorUsedError;
|
String get label => throw _privateConstructorUsedError;
|
||||||
bool get isSystem => throw _privateConstructorUsedError;
|
bool get isSystem => throw _privateConstructorUsedError;
|
||||||
|
int get firstInstallTime => throw _privateConstructorUsedError;
|
||||||
|
|
||||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||||
@JsonKey(ignore: true)
|
@JsonKey(ignore: true)
|
||||||
@@ -34,7 +35,8 @@ abstract class $PackageCopyWith<$Res> {
|
|||||||
factory $PackageCopyWith(Package value, $Res Function(Package) then) =
|
factory $PackageCopyWith(Package value, $Res Function(Package) then) =
|
||||||
_$PackageCopyWithImpl<$Res, Package>;
|
_$PackageCopyWithImpl<$Res, Package>;
|
||||||
@useResult
|
@useResult
|
||||||
$Res call({String packageName, String label, bool isSystem});
|
$Res call(
|
||||||
|
{String packageName, String label, bool isSystem, int firstInstallTime});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
@@ -53,6 +55,7 @@ class _$PackageCopyWithImpl<$Res, $Val extends Package>
|
|||||||
Object? packageName = null,
|
Object? packageName = null,
|
||||||
Object? label = null,
|
Object? label = null,
|
||||||
Object? isSystem = null,
|
Object? isSystem = null,
|
||||||
|
Object? firstInstallTime = null,
|
||||||
}) {
|
}) {
|
||||||
return _then(_value.copyWith(
|
return _then(_value.copyWith(
|
||||||
packageName: null == packageName
|
packageName: null == packageName
|
||||||
@@ -67,6 +70,10 @@ class _$PackageCopyWithImpl<$Res, $Val extends Package>
|
|||||||
? _value.isSystem
|
? _value.isSystem
|
||||||
: isSystem // ignore: cast_nullable_to_non_nullable
|
: isSystem // ignore: cast_nullable_to_non_nullable
|
||||||
as bool,
|
as bool,
|
||||||
|
firstInstallTime: null == firstInstallTime
|
||||||
|
? _value.firstInstallTime
|
||||||
|
: firstInstallTime // ignore: cast_nullable_to_non_nullable
|
||||||
|
as int,
|
||||||
) as $Val);
|
) as $Val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -78,7 +85,8 @@ abstract class _$$PackageImplCopyWith<$Res> implements $PackageCopyWith<$Res> {
|
|||||||
__$$PackageImplCopyWithImpl<$Res>;
|
__$$PackageImplCopyWithImpl<$Res>;
|
||||||
@override
|
@override
|
||||||
@useResult
|
@useResult
|
||||||
$Res call({String packageName, String label, bool isSystem});
|
$Res call(
|
||||||
|
{String packageName, String label, bool isSystem, int firstInstallTime});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
@@ -95,6 +103,7 @@ class __$$PackageImplCopyWithImpl<$Res>
|
|||||||
Object? packageName = null,
|
Object? packageName = null,
|
||||||
Object? label = null,
|
Object? label = null,
|
||||||
Object? isSystem = null,
|
Object? isSystem = null,
|
||||||
|
Object? firstInstallTime = null,
|
||||||
}) {
|
}) {
|
||||||
return _then(_$PackageImpl(
|
return _then(_$PackageImpl(
|
||||||
packageName: null == packageName
|
packageName: null == packageName
|
||||||
@@ -109,6 +118,10 @@ class __$$PackageImplCopyWithImpl<$Res>
|
|||||||
? _value.isSystem
|
? _value.isSystem
|
||||||
: isSystem // ignore: cast_nullable_to_non_nullable
|
: isSystem // ignore: cast_nullable_to_non_nullable
|
||||||
as bool,
|
as bool,
|
||||||
|
firstInstallTime: null == firstInstallTime
|
||||||
|
? _value.firstInstallTime
|
||||||
|
: firstInstallTime // ignore: cast_nullable_to_non_nullable
|
||||||
|
as int,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -117,7 +130,10 @@ class __$$PackageImplCopyWithImpl<$Res>
|
|||||||
@JsonSerializable()
|
@JsonSerializable()
|
||||||
class _$PackageImpl implements _Package {
|
class _$PackageImpl implements _Package {
|
||||||
const _$PackageImpl(
|
const _$PackageImpl(
|
||||||
{required this.packageName, required this.label, required this.isSystem});
|
{required this.packageName,
|
||||||
|
required this.label,
|
||||||
|
required this.isSystem,
|
||||||
|
required this.firstInstallTime});
|
||||||
|
|
||||||
factory _$PackageImpl.fromJson(Map<String, dynamic> json) =>
|
factory _$PackageImpl.fromJson(Map<String, dynamic> json) =>
|
||||||
_$$PackageImplFromJson(json);
|
_$$PackageImplFromJson(json);
|
||||||
@@ -128,10 +144,12 @@ class _$PackageImpl implements _Package {
|
|||||||
final String label;
|
final String label;
|
||||||
@override
|
@override
|
||||||
final bool isSystem;
|
final bool isSystem;
|
||||||
|
@override
|
||||||
|
final int firstInstallTime;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'Package(packageName: $packageName, label: $label, isSystem: $isSystem)';
|
return 'Package(packageName: $packageName, label: $label, isSystem: $isSystem, firstInstallTime: $firstInstallTime)';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -143,12 +161,15 @@ class _$PackageImpl implements _Package {
|
|||||||
other.packageName == packageName) &&
|
other.packageName == packageName) &&
|
||||||
(identical(other.label, label) || other.label == label) &&
|
(identical(other.label, label) || other.label == label) &&
|
||||||
(identical(other.isSystem, isSystem) ||
|
(identical(other.isSystem, isSystem) ||
|
||||||
other.isSystem == isSystem));
|
other.isSystem == isSystem) &&
|
||||||
|
(identical(other.firstInstallTime, firstInstallTime) ||
|
||||||
|
other.firstInstallTime == firstInstallTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonKey(ignore: true)
|
@JsonKey(ignore: true)
|
||||||
@override
|
@override
|
||||||
int get hashCode => Object.hash(runtimeType, packageName, label, isSystem);
|
int get hashCode =>
|
||||||
|
Object.hash(runtimeType, packageName, label, isSystem, firstInstallTime);
|
||||||
|
|
||||||
@JsonKey(ignore: true)
|
@JsonKey(ignore: true)
|
||||||
@override
|
@override
|
||||||
@@ -168,7 +189,8 @@ abstract class _Package implements Package {
|
|||||||
const factory _Package(
|
const factory _Package(
|
||||||
{required final String packageName,
|
{required final String packageName,
|
||||||
required final String label,
|
required final String label,
|
||||||
required final bool isSystem}) = _$PackageImpl;
|
required final bool isSystem,
|
||||||
|
required final int firstInstallTime}) = _$PackageImpl;
|
||||||
|
|
||||||
factory _Package.fromJson(Map<String, dynamic> json) = _$PackageImpl.fromJson;
|
factory _Package.fromJson(Map<String, dynamic> json) = _$PackageImpl.fromJson;
|
||||||
|
|
||||||
@@ -179,6 +201,8 @@ abstract class _Package implements Package {
|
|||||||
@override
|
@override
|
||||||
bool get isSystem;
|
bool get isSystem;
|
||||||
@override
|
@override
|
||||||
|
int get firstInstallTime;
|
||||||
|
@override
|
||||||
@JsonKey(ignore: true)
|
@JsonKey(ignore: true)
|
||||||
_$$PackageImplCopyWith<_$PackageImpl> get copyWith =>
|
_$$PackageImplCopyWith<_$PackageImpl> get copyWith =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ _$PackageImpl _$$PackageImplFromJson(Map<String, dynamic> json) =>
|
|||||||
packageName: json['packageName'] as String,
|
packageName: json['packageName'] as String,
|
||||||
label: json['label'] as String,
|
label: json['label'] as String,
|
||||||
isSystem: json['isSystem'] as bool,
|
isSystem: json['isSystem'] as bool,
|
||||||
|
firstInstallTime: (json['firstInstallTime'] as num).toInt(),
|
||||||
);
|
);
|
||||||
|
|
||||||
Map<String, dynamic> _$$PackageImplToJson(_$PackageImpl instance) =>
|
Map<String, dynamic> _$$PackageImplToJson(_$PackageImpl instance) =>
|
||||||
@@ -18,4 +19,5 @@ Map<String, dynamic> _$$PackageImplToJson(_$PackageImpl instance) =>
|
|||||||
'packageName': instance.packageName,
|
'packageName': instance.packageName,
|
||||||
'label': instance.label,
|
'label': instance.label,
|
||||||
'isSystem': instance.isSystem,
|
'isSystem': instance.isSystem,
|
||||||
|
'firstInstallTime': instance.firstInstallTime,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -223,6 +223,8 @@ mixin _$Profile {
|
|||||||
bool get autoUpdate => throw _privateConstructorUsedError;
|
bool get autoUpdate => throw _privateConstructorUsedError;
|
||||||
Map<String, String> get selectedMap => throw _privateConstructorUsedError;
|
Map<String, String> get selectedMap => throw _privateConstructorUsedError;
|
||||||
Set<String> get unfoldSet => throw _privateConstructorUsedError;
|
Set<String> get unfoldSet => throw _privateConstructorUsedError;
|
||||||
|
@JsonKey(includeToJson: false, includeFromJson: false)
|
||||||
|
bool get isUpdating => throw _privateConstructorUsedError;
|
||||||
|
|
||||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||||
@JsonKey(ignore: true)
|
@JsonKey(ignore: true)
|
||||||
@@ -244,7 +246,8 @@ abstract class $ProfileCopyWith<$Res> {
|
|||||||
UserInfo? userInfo,
|
UserInfo? userInfo,
|
||||||
bool autoUpdate,
|
bool autoUpdate,
|
||||||
Map<String, String> selectedMap,
|
Map<String, String> selectedMap,
|
||||||
Set<String> unfoldSet});
|
Set<String> unfoldSet,
|
||||||
|
@JsonKey(includeToJson: false, includeFromJson: false) bool isUpdating});
|
||||||
|
|
||||||
$UserInfoCopyWith<$Res>? get userInfo;
|
$UserInfoCopyWith<$Res>? get userInfo;
|
||||||
}
|
}
|
||||||
@@ -272,6 +275,7 @@ class _$ProfileCopyWithImpl<$Res, $Val extends Profile>
|
|||||||
Object? autoUpdate = null,
|
Object? autoUpdate = null,
|
||||||
Object? selectedMap = null,
|
Object? selectedMap = null,
|
||||||
Object? unfoldSet = null,
|
Object? unfoldSet = null,
|
||||||
|
Object? isUpdating = null,
|
||||||
}) {
|
}) {
|
||||||
return _then(_value.copyWith(
|
return _then(_value.copyWith(
|
||||||
id: null == id
|
id: null == id
|
||||||
@@ -314,6 +318,10 @@ class _$ProfileCopyWithImpl<$Res, $Val extends Profile>
|
|||||||
? _value.unfoldSet
|
? _value.unfoldSet
|
||||||
: unfoldSet // ignore: cast_nullable_to_non_nullable
|
: unfoldSet // ignore: cast_nullable_to_non_nullable
|
||||||
as Set<String>,
|
as Set<String>,
|
||||||
|
isUpdating: null == isUpdating
|
||||||
|
? _value.isUpdating
|
||||||
|
: isUpdating // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
) as $Val);
|
) as $Val);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -347,7 +355,8 @@ abstract class _$$ProfileImplCopyWith<$Res> implements $ProfileCopyWith<$Res> {
|
|||||||
UserInfo? userInfo,
|
UserInfo? userInfo,
|
||||||
bool autoUpdate,
|
bool autoUpdate,
|
||||||
Map<String, String> selectedMap,
|
Map<String, String> selectedMap,
|
||||||
Set<String> unfoldSet});
|
Set<String> unfoldSet,
|
||||||
|
@JsonKey(includeToJson: false, includeFromJson: false) bool isUpdating});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
$UserInfoCopyWith<$Res>? get userInfo;
|
$UserInfoCopyWith<$Res>? get userInfo;
|
||||||
@@ -374,6 +383,7 @@ class __$$ProfileImplCopyWithImpl<$Res>
|
|||||||
Object? autoUpdate = null,
|
Object? autoUpdate = null,
|
||||||
Object? selectedMap = null,
|
Object? selectedMap = null,
|
||||||
Object? unfoldSet = null,
|
Object? unfoldSet = null,
|
||||||
|
Object? isUpdating = null,
|
||||||
}) {
|
}) {
|
||||||
return _then(_$ProfileImpl(
|
return _then(_$ProfileImpl(
|
||||||
id: null == id
|
id: null == id
|
||||||
@@ -416,6 +426,10 @@ class __$$ProfileImplCopyWithImpl<$Res>
|
|||||||
? _value._unfoldSet
|
? _value._unfoldSet
|
||||||
: unfoldSet // ignore: cast_nullable_to_non_nullable
|
: unfoldSet // ignore: cast_nullable_to_non_nullable
|
||||||
as Set<String>,
|
as Set<String>,
|
||||||
|
isUpdating: null == isUpdating
|
||||||
|
? _value.isUpdating
|
||||||
|
: isUpdating // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -433,7 +447,9 @@ class _$ProfileImpl implements _Profile {
|
|||||||
this.userInfo,
|
this.userInfo,
|
||||||
this.autoUpdate = true,
|
this.autoUpdate = true,
|
||||||
final Map<String, String> selectedMap = const {},
|
final Map<String, String> selectedMap = const {},
|
||||||
final Set<String> unfoldSet = const {}})
|
final Set<String> unfoldSet = const {},
|
||||||
|
@JsonKey(includeToJson: false, includeFromJson: false)
|
||||||
|
this.isUpdating = false})
|
||||||
: _selectedMap = selectedMap,
|
: _selectedMap = selectedMap,
|
||||||
_unfoldSet = unfoldSet;
|
_unfoldSet = unfoldSet;
|
||||||
|
|
||||||
@@ -476,9 +492,13 @@ class _$ProfileImpl implements _Profile {
|
|||||||
return EqualUnmodifiableSetView(_unfoldSet);
|
return EqualUnmodifiableSetView(_unfoldSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@JsonKey(includeToJson: false, includeFromJson: false)
|
||||||
|
final bool isUpdating;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'Profile(id: $id, label: $label, currentGroupName: $currentGroupName, url: $url, lastUpdateDate: $lastUpdateDate, autoUpdateDuration: $autoUpdateDuration, userInfo: $userInfo, autoUpdate: $autoUpdate, selectedMap: $selectedMap, unfoldSet: $unfoldSet)';
|
return 'Profile(id: $id, label: $label, currentGroupName: $currentGroupName, url: $url, lastUpdateDate: $lastUpdateDate, autoUpdateDuration: $autoUpdateDuration, userInfo: $userInfo, autoUpdate: $autoUpdate, selectedMap: $selectedMap, unfoldSet: $unfoldSet, isUpdating: $isUpdating)';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -502,7 +522,9 @@ class _$ProfileImpl implements _Profile {
|
|||||||
const DeepCollectionEquality()
|
const DeepCollectionEquality()
|
||||||
.equals(other._selectedMap, _selectedMap) &&
|
.equals(other._selectedMap, _selectedMap) &&
|
||||||
const DeepCollectionEquality()
|
const DeepCollectionEquality()
|
||||||
.equals(other._unfoldSet, _unfoldSet));
|
.equals(other._unfoldSet, _unfoldSet) &&
|
||||||
|
(identical(other.isUpdating, isUpdating) ||
|
||||||
|
other.isUpdating == isUpdating));
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonKey(ignore: true)
|
@JsonKey(ignore: true)
|
||||||
@@ -518,7 +540,8 @@ class _$ProfileImpl implements _Profile {
|
|||||||
userInfo,
|
userInfo,
|
||||||
autoUpdate,
|
autoUpdate,
|
||||||
const DeepCollectionEquality().hash(_selectedMap),
|
const DeepCollectionEquality().hash(_selectedMap),
|
||||||
const DeepCollectionEquality().hash(_unfoldSet));
|
const DeepCollectionEquality().hash(_unfoldSet),
|
||||||
|
isUpdating);
|
||||||
|
|
||||||
@JsonKey(ignore: true)
|
@JsonKey(ignore: true)
|
||||||
@override
|
@override
|
||||||
@@ -545,7 +568,9 @@ abstract class _Profile implements Profile {
|
|||||||
final UserInfo? userInfo,
|
final UserInfo? userInfo,
|
||||||
final bool autoUpdate,
|
final bool autoUpdate,
|
||||||
final Map<String, String> selectedMap,
|
final Map<String, String> selectedMap,
|
||||||
final Set<String> unfoldSet}) = _$ProfileImpl;
|
final Set<String> unfoldSet,
|
||||||
|
@JsonKey(includeToJson: false, includeFromJson: false)
|
||||||
|
final bool isUpdating}) = _$ProfileImpl;
|
||||||
|
|
||||||
factory _Profile.fromJson(Map<String, dynamic> json) = _$ProfileImpl.fromJson;
|
factory _Profile.fromJson(Map<String, dynamic> json) = _$ProfileImpl.fromJson;
|
||||||
|
|
||||||
@@ -570,6 +595,9 @@ abstract class _Profile implements Profile {
|
|||||||
@override
|
@override
|
||||||
Set<String> get unfoldSet;
|
Set<String> get unfoldSet;
|
||||||
@override
|
@override
|
||||||
|
@JsonKey(includeToJson: false, includeFromJson: false)
|
||||||
|
bool get isUpdating;
|
||||||
|
@override
|
||||||
@JsonKey(ignore: true)
|
@JsonKey(ignore: true)
|
||||||
_$$ProfileImplCopyWith<_$ProfileImpl> get copyWith =>
|
_$$ProfileImplCopyWith<_$ProfileImpl> get copyWith =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -9,6 +9,7 @@ class Package with _$Package {
|
|||||||
required String packageName,
|
required String packageName,
|
||||||
required String label,
|
required String label,
|
||||||
required bool isSystem,
|
required bool isSystem,
|
||||||
|
required int firstInstallTime,
|
||||||
}) = _Package;
|
}) = _Package;
|
||||||
|
|
||||||
factory Package.fromJson(Map<String, Object?> json) =>
|
factory Package.fromJson(Map<String, Object?> json) =>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// ignore_for_file: invalid_annotation_target
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
@@ -55,6 +56,9 @@ class Profile with _$Profile {
|
|||||||
@Default(true) bool autoUpdate,
|
@Default(true) bool autoUpdate,
|
||||||
@Default({}) SelectedMap selectedMap,
|
@Default({}) SelectedMap selectedMap,
|
||||||
@Default({}) Set<String> unfoldSet,
|
@Default({}) Set<String> unfoldSet,
|
||||||
|
@JsonKey(includeToJson: false, includeFromJson: false)
|
||||||
|
@Default(false)
|
||||||
|
bool isUpdating,
|
||||||
}) = _Profile;
|
}) = _Profile;
|
||||||
|
|
||||||
factory Profile.fromJson(Map<String, Object?> json) =>
|
factory Profile.fromJson(Map<String, Object?> json) =>
|
||||||
@@ -63,7 +67,7 @@ class Profile with _$Profile {
|
|||||||
factory Profile.normal({
|
factory Profile.normal({
|
||||||
String? label,
|
String? label,
|
||||||
String url = '',
|
String url = '',
|
||||||
}) {
|
}) {
|
||||||
return Profile(
|
return Profile(
|
||||||
label: label,
|
label: label,
|
||||||
url: url,
|
url: url,
|
||||||
@@ -77,8 +81,7 @@ extension ProfileExtension on Profile {
|
|||||||
ProfileType get type =>
|
ProfileType get type =>
|
||||||
url.isEmpty == true ? ProfileType.file : ProfileType.url;
|
url.isEmpty == true ? ProfileType.file : ProfileType.url;
|
||||||
|
|
||||||
bool get realAutoUpdate =>
|
bool get realAutoUpdate => url.isEmpty == true ? false : autoUpdate;
|
||||||
url.isEmpty == true ? false : autoUpdate;
|
|
||||||
|
|
||||||
Future<void> checkAndUpdate() async {
|
Future<void> checkAndUpdate() async {
|
||||||
final isExists = await check();
|
final isExists = await check();
|
||||||
|
|||||||
@@ -41,4 +41,4 @@ class Proxy with _$Proxy {
|
|||||||
}) = _Proxy;
|
}) = _Proxy;
|
||||||
|
|
||||||
factory Proxy.fromJson(Map<String, Object?> json) => _$ProxyFromJson(json);
|
factory Proxy.fromJson(Map<String, Object?> json) => _$ProxyFromJson(json);
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,10 @@
|
|||||||
|
import 'package:collection/collection.dart';
|
||||||
|
import 'package:fl_clash/common/common.dart';
|
||||||
import 'package:fl_clash/enum/enum.dart';
|
import 'package:fl_clash/enum/enum.dart';
|
||||||
import 'package:fl_clash/models/models.dart';
|
import 'package:fl_clash/models/models.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
|
import 'package:lpinyin/lpinyin.dart';
|
||||||
|
|
||||||
part 'generated/selector.freezed.dart';
|
part 'generated/selector.freezed.dart';
|
||||||
|
|
||||||
@@ -34,16 +37,25 @@ class ProfilesSelectorState with _$ProfilesSelectorState {
|
|||||||
const factory ProfilesSelectorState({
|
const factory ProfilesSelectorState({
|
||||||
required List<Profile> profiles,
|
required List<Profile> profiles,
|
||||||
required String? currentProfileId,
|
required String? currentProfileId,
|
||||||
required ViewMode viewMode,
|
required int columns,
|
||||||
}) = _ProfilesSelectorState;
|
}) = _ProfilesSelectorState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@freezed
|
||||||
|
class NetworkDetectionState with _$NetworkDetectionState {
|
||||||
|
const factory NetworkDetectionState({
|
||||||
|
required bool isTesting,
|
||||||
|
required IpInfo? ipInfo,
|
||||||
|
}) = _NetworkDetectionState;
|
||||||
|
}
|
||||||
|
|
||||||
@freezed
|
@freezed
|
||||||
class ApplicationSelectorState with _$ApplicationSelectorState {
|
class ApplicationSelectorState with _$ApplicationSelectorState {
|
||||||
const factory ApplicationSelectorState({
|
const factory ApplicationSelectorState({
|
||||||
String? locale,
|
required String? locale,
|
||||||
ThemeMode? themeMode,
|
required ThemeMode? themeMode,
|
||||||
int? primaryColor,
|
required int? primaryColor,
|
||||||
|
required bool prueBlack,
|
||||||
}) = _ApplicationSelectorState;
|
}) = _ApplicationSelectorState;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,7 +64,9 @@ class TrayContainerSelectorState with _$TrayContainerSelectorState {
|
|||||||
const factory TrayContainerSelectorState({
|
const factory TrayContainerSelectorState({
|
||||||
required Mode mode,
|
required Mode mode,
|
||||||
required bool autoLaunch,
|
required bool autoLaunch,
|
||||||
required bool isRun,
|
required bool systemProxy,
|
||||||
|
required bool tunEnable,
|
||||||
|
required bool isStart,
|
||||||
required String? locale,
|
required String? locale,
|
||||||
}) = _TrayContainerSelectorState;
|
}) = _TrayContainerSelectorState;
|
||||||
}
|
}
|
||||||
@@ -131,18 +145,41 @@ class MoreToolsSelectorState with _$MoreToolsSelectorState {
|
|||||||
@freezed
|
@freezed
|
||||||
class PackageListSelectorState with _$PackageListSelectorState {
|
class PackageListSelectorState with _$PackageListSelectorState {
|
||||||
const factory PackageListSelectorState({
|
const factory PackageListSelectorState({
|
||||||
|
required List<Package> packages,
|
||||||
required AccessControl accessControl,
|
required AccessControl accessControl,
|
||||||
required bool isAccessControl,
|
required bool isAccessControl,
|
||||||
}) = _PackageListSelectorState;
|
}) = _PackageListSelectorState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension PackageListSelectorStateExt on PackageListSelectorState {
|
||||||
@freezed
|
List<Package> getList(List<String> selectedList) {
|
||||||
class ColumnsSelectorState with _$ColumnsSelectorState {
|
final isFilterSystemApp = accessControl.isFilterSystemApp;
|
||||||
const factory ColumnsSelectorState({
|
final sort = accessControl.sort;
|
||||||
required int columns,
|
return packages
|
||||||
required ViewMode viewMode,
|
.where((item) => isFilterSystemApp ? item.isSystem == false : true)
|
||||||
}) = _ColumnsSelectorState;
|
.sorted(
|
||||||
|
(a, b) {
|
||||||
|
return switch (sort) {
|
||||||
|
AccessSortType.none => 0,
|
||||||
|
AccessSortType.name => other.sortByChar(
|
||||||
|
PinyinHelper.getPinyin(a.label),
|
||||||
|
PinyinHelper.getPinyin(b.label),
|
||||||
|
),
|
||||||
|
AccessSortType.time =>
|
||||||
|
a.firstInstallTime.compareTo(b.firstInstallTime),
|
||||||
|
};
|
||||||
|
},
|
||||||
|
).sorted(
|
||||||
|
(a, b) {
|
||||||
|
final isSelectA = selectedList.contains(a.packageName);
|
||||||
|
final isSelectB = selectedList.contains(b.packageName);
|
||||||
|
if (isSelectA && isSelectB) return 0;
|
||||||
|
if (isSelectA) return -1;
|
||||||
|
if (isSelectB) return 1;
|
||||||
|
return 0;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@freezed
|
@freezed
|
||||||
@@ -154,9 +191,48 @@ class ProxiesListHeaderSelectorState with _$ProxiesListHeaderSelectorState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@freezed
|
@freezed
|
||||||
class CurrentGroupProxyNameSelectorState with _$CurrentGroupProxyNameSelectorState {
|
class ProxiesActionsState with _$ProxiesActionsState {
|
||||||
const factory CurrentGroupProxyNameSelectorState({
|
const factory ProxiesActionsState({
|
||||||
required String? proxyName,
|
required bool isCurrent,
|
||||||
required String? proxyName2,
|
required bool hasProvider,
|
||||||
}) = _CurrentGroupProxyNameSelectorState;
|
}) = _ProxiesActionsState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@freezed
|
||||||
|
class AutoLaunchState with _$AutoLaunchState {
|
||||||
|
const factory AutoLaunchState({
|
||||||
|
required bool isAutoLaunch,
|
||||||
|
required bool isOpenTun,
|
||||||
|
}) = _AutoLaunchState;
|
||||||
|
}
|
||||||
|
|
||||||
|
@freezed
|
||||||
|
class ProxyState with _$ProxyState {
|
||||||
|
const factory ProxyState({
|
||||||
|
required bool isStart,
|
||||||
|
required bool systemProxy,
|
||||||
|
required int port,
|
||||||
|
}) = _ProxyState;
|
||||||
|
}
|
||||||
|
|
||||||
|
@freezed
|
||||||
|
class ClashConfigState with _$ClashConfigState {
|
||||||
|
const factory ClashConfigState({
|
||||||
|
required int mixedPort,
|
||||||
|
required bool allowLan,
|
||||||
|
required bool ipv6,
|
||||||
|
required String geodataLoader,
|
||||||
|
required LogLevel logLevel,
|
||||||
|
required String externalController,
|
||||||
|
required Mode mode,
|
||||||
|
required FindProcessMode findProcessMode,
|
||||||
|
required int keepAliveInterval,
|
||||||
|
required bool unifiedDelay,
|
||||||
|
required bool tcpConcurrent,
|
||||||
|
required Tun tun,
|
||||||
|
required Dns dns,
|
||||||
|
required GeoXMap geoXUrl,
|
||||||
|
required List<String> rules,
|
||||||
|
required String? globalRealUa,
|
||||||
|
}) = _ClashConfigState;
|
||||||
|
}
|
||||||
|
|||||||
@@ -12,15 +12,15 @@ class SystemColorSchemes {
|
|||||||
});
|
});
|
||||||
|
|
||||||
getSystemColorSchemeForBrightness(Brightness? brightness) {
|
getSystemColorSchemeForBrightness(Brightness? brightness) {
|
||||||
if (brightness != null && brightness == Brightness.dark) {
|
if (brightness == Brightness.dark) {
|
||||||
return darkColorScheme != null
|
return darkColorScheme != null
|
||||||
? ColorScheme.fromSeed(
|
? ColorScheme.fromSeed(
|
||||||
seedColor: darkColorScheme!.primary,
|
seedColor: darkColorScheme!.primary,
|
||||||
brightness: brightness,
|
brightness: Brightness.dark,
|
||||||
)
|
)
|
||||||
: ColorScheme.fromSeed(
|
: ColorScheme.fromSeed(
|
||||||
seedColor: defaultPrimaryColor,
|
seedColor: defaultPrimaryColor,
|
||||||
brightness: brightness,
|
brightness: Brightness.dark,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return lightColorScheme != null
|
return lightColorScheme != null
|
||||||
|
|||||||
@@ -13,20 +13,6 @@ typedef OnSelected = void Function(int index);
|
|||||||
class HomePage extends StatelessWidget {
|
class HomePage extends StatelessWidget {
|
||||||
const HomePage({super.key});
|
const HomePage({super.key});
|
||||||
|
|
||||||
_navigationBarContainer({
|
|
||||||
required BuildContext context,
|
|
||||||
required Widget child,
|
|
||||||
}) {
|
|
||||||
// if (!system.isDesktop) return child;
|
|
||||||
return Container(
|
|
||||||
padding: const EdgeInsets.all(16).copyWith(
|
|
||||||
right: 0,
|
|
||||||
),
|
|
||||||
color: context.colorScheme.surface,
|
|
||||||
child: child,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
_getNavigationBar({
|
_getNavigationBar({
|
||||||
required BuildContext context,
|
required BuildContext context,
|
||||||
required ViewMode viewMode,
|
required ViewMode viewMode,
|
||||||
@@ -47,62 +33,78 @@ class HomePage extends StatelessWidget {
|
|||||||
selectedIndex: currentIndex,
|
selectedIndex: currentIndex,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
final extended = viewMode == ViewMode.desktop;
|
return LayoutBuilder(
|
||||||
return _navigationBarContainer(
|
builder: (_, container) {
|
||||||
context: context,
|
return Material(
|
||||||
child: NavigationRail(
|
color: context.colorScheme.surfaceContainer,
|
||||||
groupAlignment: -0.8,
|
child: Container(
|
||||||
selectedIconTheme: IconThemeData(
|
padding: const EdgeInsets.symmetric(
|
||||||
color: context.colorScheme.onSurfaceVariant,
|
vertical: 16,
|
||||||
),
|
|
||||||
unselectedIconTheme: IconThemeData(
|
|
||||||
color: context.colorScheme.onSurfaceVariant,
|
|
||||||
),
|
|
||||||
selectedLabelTextStyle: context.textTheme.labelLarge!.copyWith(
|
|
||||||
color: context.colorScheme.onSurface,
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
),
|
|
||||||
unselectedLabelTextStyle: context.textTheme.labelLarge!.copyWith(
|
|
||||||
color: context.colorScheme.onSurface,
|
|
||||||
),
|
|
||||||
destinations: navigationItems
|
|
||||||
.map(
|
|
||||||
(e) => NavigationRailDestination(
|
|
||||||
icon: e.icon,
|
|
||||||
label: Text(
|
|
||||||
Intl.message(e.label),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.toList(),
|
|
||||||
onDestinationSelected: globalState.appController.toPage,
|
|
||||||
extended: extended,
|
|
||||||
minExtendedWidth: 200,
|
|
||||||
selectedIndex: currentIndex,
|
|
||||||
labelType: extended
|
|
||||||
? NavigationRailLabelType.none
|
|
||||||
: NavigationRailLabelType.selected,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
return NavigationRail(
|
|
||||||
groupAlignment: -0.95,
|
|
||||||
destinations: navigationItems
|
|
||||||
.map(
|
|
||||||
(e) => NavigationRailDestination(
|
|
||||||
icon: e.icon,
|
|
||||||
label: Text(
|
|
||||||
Intl.message(e.label),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
)
|
height: container.maxHeight,
|
||||||
.toList(),
|
child: Column(
|
||||||
onDestinationSelected: globalState.appController.toPage,
|
children: [
|
||||||
extended: extended,
|
Expanded(
|
||||||
minExtendedWidth: 172,
|
child: SingleChildScrollView(
|
||||||
selectedIndex: currentIndex,
|
child: IntrinsicHeight(
|
||||||
labelType: extended
|
child: Selector<Config, bool>(
|
||||||
? NavigationRailLabelType.none
|
selector: (_, config) => config.showLabel,
|
||||||
: NavigationRailLabelType.selected,
|
builder: (_, showLabel, __) {
|
||||||
|
return NavigationRail(
|
||||||
|
backgroundColor:
|
||||||
|
context.colorScheme.surfaceContainer,
|
||||||
|
selectedIconTheme: IconThemeData(
|
||||||
|
color: context.colorScheme.onSurfaceVariant,
|
||||||
|
),
|
||||||
|
unselectedIconTheme: IconThemeData(
|
||||||
|
color: context.colorScheme.onSurfaceVariant,
|
||||||
|
),
|
||||||
|
selectedLabelTextStyle:
|
||||||
|
context.textTheme.labelLarge!.copyWith(
|
||||||
|
color: context.colorScheme.onSurface,
|
||||||
|
),
|
||||||
|
unselectedLabelTextStyle:
|
||||||
|
context.textTheme.labelLarge!.copyWith(
|
||||||
|
color: context.colorScheme.onSurface,
|
||||||
|
),
|
||||||
|
destinations: navigationItems
|
||||||
|
.map(
|
||||||
|
(e) => NavigationRailDestination(
|
||||||
|
icon: e.icon,
|
||||||
|
label: Text(
|
||||||
|
Intl.message(e.label),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.toList(),
|
||||||
|
onDestinationSelected:
|
||||||
|
globalState.appController.toPage,
|
||||||
|
extended: false,
|
||||||
|
selectedIndex: currentIndex,
|
||||||
|
labelType: showLabel
|
||||||
|
? NavigationRailLabelType.all
|
||||||
|
: NavigationRailLabelType.none,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 16,
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
onPressed: () {
|
||||||
|
final config = globalState.appController.config;
|
||||||
|
config.showLabel = !config.showLabel;
|
||||||
|
},
|
||||||
|
icon: const Icon(Icons.menu),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,16 @@ class App {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<List<String>> getChinaPackageNames() async {
|
||||||
|
final packageNamesString =
|
||||||
|
await methodChannel.invokeMethod<String>("getChinaPackageNames");
|
||||||
|
return Isolate.run<List<String>>(() {
|
||||||
|
final List<dynamic> packageNamesRaw =
|
||||||
|
packageNamesString != null ? json.decode(packageNamesString) : [];
|
||||||
|
return packageNamesRaw.map((e) => e.toString()).toList();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
Future<bool> openFile(String path) async {
|
Future<bool> openFile(String path) async {
|
||||||
return await methodChannel.invokeMethod<bool>("openFile", {
|
return await methodChannel.invokeMethod<bool>("openFile", {
|
||||||
"path": path,
|
"path": path,
|
||||||
|
|||||||
29
lib/plugins/service.dart
Normal file
29
lib/plugins/service.dart
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
import 'dart:io';
|
||||||
|
import 'dart:isolate';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
|
class Service {
|
||||||
|
static Service? _instance;
|
||||||
|
late MethodChannel methodChannel;
|
||||||
|
ReceivePort? receiver;
|
||||||
|
|
||||||
|
Service._internal() {
|
||||||
|
methodChannel = const MethodChannel("service");
|
||||||
|
}
|
||||||
|
|
||||||
|
factory Service() {
|
||||||
|
_instance ??= Service._internal();
|
||||||
|
return _instance!;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<bool?> init() async {
|
||||||
|
return await methodChannel.invokeMethod<bool>("init");
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<bool?> destroy() async {
|
||||||
|
return await methodChannel.invokeMethod<bool>("destroy");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final service = Platform.isAndroid ? Service() : null;
|
||||||
@@ -4,22 +4,18 @@ import 'dart:ffi';
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'dart:isolate';
|
import 'dart:isolate';
|
||||||
import 'package:fl_clash/clash/clash.dart';
|
import 'package:fl_clash/clash/clash.dart';
|
||||||
import 'package:fl_clash/common/common.dart';
|
|
||||||
import 'package:fl_clash/enum/enum.dart';
|
import 'package:fl_clash/enum/enum.dart';
|
||||||
import 'package:fl_clash/models/models.dart';
|
import 'package:fl_clash/models/models.dart';
|
||||||
import 'package:fl_clash/state.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:proxy/proxy_platform_interface.dart';
|
|
||||||
|
|
||||||
class Proxy extends ProxyPlatform {
|
class Vpn {
|
||||||
static Proxy? _instance;
|
static Vpn? _instance;
|
||||||
late MethodChannel methodChannel;
|
late MethodChannel methodChannel;
|
||||||
ReceivePort? receiver;
|
ReceivePort? receiver;
|
||||||
ServiceMessageListener? _serviceMessageHandler;
|
ServiceMessageListener? _serviceMessageHandler;
|
||||||
|
|
||||||
Proxy._internal() {
|
Vpn._internal() {
|
||||||
methodChannel = const MethodChannel("proxy");
|
methodChannel = const MethodChannel("vpn");
|
||||||
methodChannel.setMethodCallHandler((call) async {
|
methodChannel.setMethodCallHandler((call) async {
|
||||||
switch (call.method) {
|
switch (call.method) {
|
||||||
case "started":
|
case "started":
|
||||||
@@ -32,36 +28,21 @@ class Proxy extends ProxyPlatform {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
factory Proxy() {
|
factory Vpn() {
|
||||||
_instance ??= Proxy._internal();
|
_instance ??= Vpn._internal();
|
||||||
return _instance!;
|
return _instance!;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool?> initService() async {
|
Future<bool?> startVpn(port) async {
|
||||||
return await methodChannel.invokeMethod<bool>("initService");
|
|
||||||
}
|
|
||||||
|
|
||||||
handleStop() {
|
|
||||||
globalState.stopSystemProxy();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<bool?> startProxy(port) async {
|
|
||||||
final state = clashCore.getState();
|
final state = clashCore.getState();
|
||||||
return await methodChannel.invokeMethod<bool>("startProxy", {
|
return await methodChannel.invokeMethod<bool>("start", {
|
||||||
'port': state.mixedPort,
|
'port': state.mixedPort,
|
||||||
'args': json.encode(state),
|
'args': json.encode(state),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
Future<bool?> stopVpn() async {
|
||||||
Future<bool?> stopProxy() async {
|
return await methodChannel.invokeMethod<bool>("stop");
|
||||||
clashCore.stopTun();
|
|
||||||
final isStop = await methodChannel.invokeMethod<bool>("stopProxy");
|
|
||||||
if (isStop == true) {
|
|
||||||
startTime = null;
|
|
||||||
}
|
|
||||||
return isStop;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool?> setProtect(int fd) async {
|
Future<bool?> setProtect(int fd) async {
|
||||||
@@ -78,11 +59,7 @@ class Proxy extends ProxyPlatform {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get isStart => startTime != null && startTime!.isBeforeNow;
|
|
||||||
|
|
||||||
onStarted(int? fd) {
|
onStarted(int? fd) {
|
||||||
debugPrint("onStarted ==> $fd");
|
|
||||||
if (fd == null) return;
|
|
||||||
if (receiver != null) {
|
if (receiver != null) {
|
||||||
receiver!.close();
|
receiver!.close();
|
||||||
receiver == null;
|
receiver == null;
|
||||||
@@ -91,11 +68,7 @@ class Proxy extends ProxyPlatform {
|
|||||||
receiver!.listen((message) {
|
receiver!.listen((message) {
|
||||||
_handleServiceMessage(message);
|
_handleServiceMessage(message);
|
||||||
});
|
});
|
||||||
clashCore.startTun(fd, receiver!.sendPort.nativePort);
|
clashCore.startTun(fd ?? 0, receiver!.sendPort.nativePort);
|
||||||
}
|
|
||||||
|
|
||||||
updateStartTime() {
|
|
||||||
startTime = clashCore.getRunTime();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setServiceMessageHandler(ServiceMessageListener serviceMessageListener) {
|
setServiceMessageHandler(ServiceMessageListener serviceMessageListener) {
|
||||||
@@ -104,7 +77,6 @@ class Proxy extends ProxyPlatform {
|
|||||||
|
|
||||||
_handleServiceMessage(String message) {
|
_handleServiceMessage(String message) {
|
||||||
final m = ServiceMessage.fromJson(json.decode(message));
|
final m = ServiceMessage.fromJson(json.decode(message));
|
||||||
debugPrint(m.toString());
|
|
||||||
switch (m.type) {
|
switch (m.type) {
|
||||||
case ServiceMessageType.protect:
|
case ServiceMessageType.protect:
|
||||||
_serviceMessageHandler?.onProtect(Fd.fromJson(m.data));
|
_serviceMessageHandler?.onProtect(Fd.fromJson(m.data));
|
||||||
@@ -118,4 +90,4 @@ class Proxy extends ProxyPlatform {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final proxy = Platform.isAndroid ? Proxy() : null;
|
final vpn = Platform.isAndroid ? Vpn() : null;
|
||||||
@@ -3,7 +3,8 @@ import 'dart:io';
|
|||||||
|
|
||||||
import 'package:animations/animations.dart';
|
import 'package:animations/animations.dart';
|
||||||
import 'package:fl_clash/clash/clash.dart';
|
import 'package:fl_clash/clash/clash.dart';
|
||||||
import 'package:fl_clash/plugins/proxy.dart';
|
import 'package:fl_clash/plugins/service.dart';
|
||||||
|
import 'package:fl_clash/plugins/vpn.dart';
|
||||||
import 'package:fl_clash/widgets/scaffold.dart';
|
import 'package:fl_clash/widgets/scaffold.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:package_info_plus/package_info_plus.dart';
|
import 'package:package_info_plus/package_info_plus.dart';
|
||||||
@@ -18,14 +19,18 @@ class GlobalState {
|
|||||||
Timer? timer;
|
Timer? timer;
|
||||||
Timer? groupsUpdateTimer;
|
Timer? groupsUpdateTimer;
|
||||||
var isVpnService = false;
|
var isVpnService = false;
|
||||||
|
var autoRun = false;
|
||||||
late PackageInfo packageInfo;
|
late PackageInfo packageInfo;
|
||||||
Function? updateCurrentDelayDebounce;
|
Function? updateCurrentDelayDebounce;
|
||||||
PageController? pageController;
|
PageController? pageController;
|
||||||
|
DateTime? startTime;
|
||||||
final navigatorKey = GlobalKey<NavigatorState>();
|
final navigatorKey = GlobalKey<NavigatorState>();
|
||||||
late AppController appController;
|
late AppController appController;
|
||||||
GlobalKey<CommonScaffoldState> homeScaffoldKey = GlobalKey();
|
GlobalKey<CommonScaffoldState> homeScaffoldKey = GlobalKey();
|
||||||
List<Function> updateFunctionLists = [];
|
List<Function> updateFunctionLists = [];
|
||||||
|
|
||||||
|
bool get isStart => startTime != null && startTime!.isBeforeNow;
|
||||||
|
|
||||||
startListenUpdate() {
|
startListenUpdate() {
|
||||||
if (timer != null && timer!.isActive == true) return;
|
if (timer != null && timer!.isActive == true) return;
|
||||||
timer = Timer.periodic(const Duration(seconds: 1), (Timer t) {
|
timer = Timer.periodic(const Duration(seconds: 1), (Timer t) {
|
||||||
@@ -45,11 +50,10 @@ class GlobalState {
|
|||||||
required Config config,
|
required Config config,
|
||||||
bool isPatch = true,
|
bool isPatch = true,
|
||||||
}) async {
|
}) async {
|
||||||
final profilePath = await appPath.getProfilePath(config.currentProfileId);
|
|
||||||
await config.currentProfile?.checkAndUpdate();
|
await config.currentProfile?.checkAndUpdate();
|
||||||
final res = await clashCore.updateConfig(
|
final res = await clashCore.updateConfig(
|
||||||
UpdateConfigParams(
|
UpdateConfigParams(
|
||||||
profilePath: profilePath,
|
profileId: config.currentProfileId ?? "",
|
||||||
config: clashConfig,
|
config: clashConfig,
|
||||||
params: ConfigExtendedParams(
|
params: ConfigExtendedParams(
|
||||||
isPatch: isPatch,
|
isPatch: isPatch,
|
||||||
@@ -66,23 +70,32 @@ class GlobalState {
|
|||||||
appState.versionInfo = clashCore.getVersionInfo();
|
appState.versionInfo = clashCore.getVersionInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> startSystemProxy({
|
handleStart({
|
||||||
required AppState appState,
|
|
||||||
required Config config,
|
required Config config,
|
||||||
required ClashConfig clashConfig,
|
required ClashConfig clashConfig,
|
||||||
}) async {
|
}) async {
|
||||||
if (!globalState.isVpnService && Platform.isAndroid) {
|
clashCore.start();
|
||||||
await proxy?.initService();
|
if (globalState.isVpnService) {
|
||||||
} else {
|
await vpn?.startVpn(clashConfig.mixedPort);
|
||||||
await proxyManager.startProxy(
|
startListenUpdate();
|
||||||
port: clashConfig.mixedPort,
|
return;
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
startTime ??= DateTime.now();
|
||||||
|
await service?.init();
|
||||||
startListenUpdate();
|
startListenUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> stopSystemProxy() async {
|
updateStartTime() {
|
||||||
await proxyManager.stopProxy();
|
startTime = clashCore.getRunTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
handleStop() async {
|
||||||
|
clashCore.stop();
|
||||||
|
if (Platform.isAndroid) {
|
||||||
|
clashCore.stopTun();
|
||||||
|
}
|
||||||
|
await service?.destroy();
|
||||||
|
startTime = null;
|
||||||
stopListenUpdate();
|
stopListenUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,8 +109,12 @@ class GlobalState {
|
|||||||
config: config,
|
config: config,
|
||||||
isPatch: false,
|
isPatch: false,
|
||||||
);
|
);
|
||||||
clashCore.setProfileName(config.currentProfile?.label ?? '');
|
|
||||||
await updateGroups(appState);
|
await updateGroups(appState);
|
||||||
|
await updateProviders(appState);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateProviders(AppState appState) async {
|
||||||
|
appState.providers = await clashCore.getExternalProviders();
|
||||||
}
|
}
|
||||||
|
|
||||||
init({
|
init({
|
||||||
@@ -111,6 +128,18 @@ class GlobalState {
|
|||||||
config: config,
|
config: config,
|
||||||
clashConfig: clashConfig,
|
clashConfig: clashConfig,
|
||||||
);
|
);
|
||||||
|
clashCore.setState(
|
||||||
|
CoreState(
|
||||||
|
enable: config.vpnProps.enable,
|
||||||
|
accessControl: config.isAccessControl ? config.accessControl : null,
|
||||||
|
allowBypass: config.vpnProps.allowBypass,
|
||||||
|
systemProxy: config.vpnProps.systemProxy,
|
||||||
|
mixedPort: clashConfig.mixedPort,
|
||||||
|
onlyProxy: config.onlyProxy,
|
||||||
|
currentProfileName:
|
||||||
|
config.currentProfile?.label ?? config.currentProfileId ?? "",
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
updateCoreVersionInfo(appState);
|
updateCoreVersionInfo(appState);
|
||||||
}
|
}
|
||||||
@@ -194,8 +223,8 @@ class GlobalState {
|
|||||||
}) {
|
}) {
|
||||||
final traffic = clashCore.getTraffic();
|
final traffic = clashCore.getTraffic();
|
||||||
if (Platform.isAndroid && isVpnService == true) {
|
if (Platform.isAndroid && isVpnService == true) {
|
||||||
proxy?.startForeground(
|
vpn?.startForeground(
|
||||||
title: clashCore.getProfileName(),
|
title: clashCore.getState().currentProfileName,
|
||||||
content: "$traffic",
|
content: "$traffic",
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
|
import 'package:fl_clash/models/models.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class ScrollOverBuilder extends StatefulWidget {
|
class ScrollOverBuilder extends StatefulWidget {
|
||||||
final Widget Function(bool isOver) builder;
|
final Widget Function(bool isOver) builder;
|
||||||
@@ -15,7 +17,6 @@ class ScrollOverBuilder extends StatefulWidget {
|
|||||||
class _ScrollOverBuilderState extends State<ScrollOverBuilder> {
|
class _ScrollOverBuilderState extends State<ScrollOverBuilder> {
|
||||||
final isOverNotifier = ValueNotifier<bool>(false);
|
final isOverNotifier = ValueNotifier<bool>(false);
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
super.dispose();
|
super.dispose();
|
||||||
@@ -38,3 +39,29 @@ class _ScrollOverBuilderState extends State<ScrollOverBuilder> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ProxiesActionsBuilder extends StatelessWidget {
|
||||||
|
final Widget? child;
|
||||||
|
final Widget Function(
|
||||||
|
ProxiesActionsState state,
|
||||||
|
Widget? child,
|
||||||
|
) builder;
|
||||||
|
|
||||||
|
const ProxiesActionsBuilder({
|
||||||
|
super.key,
|
||||||
|
required this.child,
|
||||||
|
required this.builder,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Selector<AppState, ProxiesActionsState>(
|
||||||
|
selector: (_, appState) => ProxiesActionsState(
|
||||||
|
isCurrent: appState.currentLabel == "proxies",
|
||||||
|
hasProvider: appState.providers.isNotEmpty,
|
||||||
|
),
|
||||||
|
builder: (_, state, child) => builder(state, child),
|
||||||
|
child: child,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import 'package:fl_clash/common/common.dart';
|
import 'package:fl_clash/common/common.dart';
|
||||||
import 'package:fl_clash/enum/enum.dart';
|
import 'package:fl_clash/enum/enum.dart';
|
||||||
|
import 'package:fl_clash/state.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'text.dart';
|
import 'text.dart';
|
||||||
@@ -29,43 +30,47 @@ class InfoHeader extends StatelessWidget {
|
|||||||
return Container(
|
return Container(
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.max,
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
Row(
|
Flexible(
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
if (info.iconData != null) ...[
|
|
||||||
Icon(
|
|
||||||
info.iconData,
|
|
||||||
color: Theme.of(context).colorScheme.primary,
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
width: 8,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
Flexible(
|
|
||||||
child: TooltipText(
|
|
||||||
text: Text(
|
|
||||||
info.label,
|
|
||||||
maxLines: 1,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: Theme.of(context).textTheme.titleMedium,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
flex: 1,
|
flex: 1,
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.max,
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
|
||||||
children: [
|
children: [
|
||||||
...actions,
|
if (info.iconData != null) ...[
|
||||||
|
Icon(
|
||||||
|
info.iconData,
|
||||||
|
color: Theme.of(context).colorScheme.primary,
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
width: 8,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
Flexible(
|
||||||
|
flex: 1,
|
||||||
|
child: TooltipText(
|
||||||
|
text: Text(
|
||||||
|
info.label,
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: Theme.of(context).textTheme.titleMedium,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
const SizedBox(
|
||||||
|
width: 8,
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
...actions,
|
||||||
|
],
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -146,18 +151,28 @@ class CommonCard extends StatelessWidget {
|
|||||||
childWidget = Column(
|
childWidget = Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
Flexible(
|
InfoHeader(
|
||||||
flex: 0,
|
info: info!,
|
||||||
child: InfoHeader(
|
|
||||||
info: info!,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
Flexible(
|
Flexible(
|
||||||
|
flex: 1,
|
||||||
child: child,
|
child: child,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
if (selectWidget != null && isSelected) {
|
||||||
|
final List<Widget> children = [];
|
||||||
|
children.add(childWidget);
|
||||||
|
children.add(
|
||||||
|
Positioned.fill(
|
||||||
|
child: selectWidget!,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
childWidget = Stack(
|
||||||
|
children: children,
|
||||||
|
);
|
||||||
|
}
|
||||||
return OutlinedButton(
|
return OutlinedButton(
|
||||||
clipBehavior: Clip.antiAlias,
|
clipBehavior: Clip.antiAlias,
|
||||||
style: ButtonStyle(
|
style: ButtonStyle(
|
||||||
@@ -175,25 +190,7 @@ class CommonCard extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
onPressed: onPressed,
|
onPressed: onPressed,
|
||||||
child: Builder(
|
child: childWidget,
|
||||||
builder: (_) {
|
|
||||||
if (selectWidget == null) {
|
|
||||||
return childWidget;
|
|
||||||
}
|
|
||||||
List<Widget> children = [];
|
|
||||||
children.add(childWidget);
|
|
||||||
if (isSelected) {
|
|
||||||
children.add(
|
|
||||||
Positioned.fill(
|
|
||||||
child: selectWidget!,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return Stack(
|
|
||||||
children: children,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
import 'package:fl_clash/clash/clash.dart';
|
import 'package:fl_clash/clash/clash.dart';
|
||||||
|
import 'package:fl_clash/enum/enum.dart';
|
||||||
import 'package:fl_clash/models/models.dart';
|
import 'package:fl_clash/models/models.dart';
|
||||||
import 'package:fl_clash/plugins/proxy.dart';
|
|
||||||
import 'package:fl_clash/state.dart';
|
import 'package:fl_clash/state.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
import '../common/function.dart';
|
||||||
|
|
||||||
class ClashContainer extends StatefulWidget {
|
class ClashContainer extends StatefulWidget {
|
||||||
final Widget child;
|
final Widget child;
|
||||||
|
|
||||||
@@ -19,14 +21,53 @@ class ClashContainer extends StatefulWidget {
|
|||||||
|
|
||||||
class _ClashContainerState extends State<ClashContainer>
|
class _ClashContainerState extends State<ClashContainer>
|
||||||
with AppMessageListener {
|
with AppMessageListener {
|
||||||
|
Function? updateClashConfigDebounce;
|
||||||
|
|
||||||
|
Widget _updateContainer(Widget child) {
|
||||||
|
return Selector<ClashConfig, ClashConfigState>(
|
||||||
|
selector: (_, clashConfig) => ClashConfigState(
|
||||||
|
mixedPort: clashConfig.mixedPort,
|
||||||
|
allowLan: clashConfig.allowLan,
|
||||||
|
ipv6: clashConfig.ipv6,
|
||||||
|
logLevel: clashConfig.logLevel,
|
||||||
|
geodataLoader: clashConfig.geodataLoader,
|
||||||
|
externalController: clashConfig.externalController,
|
||||||
|
mode: clashConfig.mode,
|
||||||
|
findProcessMode: clashConfig.findProcessMode,
|
||||||
|
keepAliveInterval: clashConfig.keepAliveInterval,
|
||||||
|
unifiedDelay: clashConfig.unifiedDelay,
|
||||||
|
tcpConcurrent: clashConfig.tcpConcurrent,
|
||||||
|
tun: clashConfig.tun,
|
||||||
|
dns: clashConfig.dns,
|
||||||
|
geoXUrl: clashConfig.geoXUrl,
|
||||||
|
rules: clashConfig.rules,
|
||||||
|
globalRealUa: clashConfig.globalRealUa,
|
||||||
|
),
|
||||||
|
builder: (__, state, child) {
|
||||||
|
if (updateClashConfigDebounce == null) {
|
||||||
|
updateClashConfigDebounce = debounce<Function()>(() async {
|
||||||
|
await globalState.appController.updateClashConfig();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
updateClashConfigDebounce!();
|
||||||
|
}
|
||||||
|
return child!;
|
||||||
|
},
|
||||||
|
child: child,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Widget _updateCoreState(Widget child) {
|
Widget _updateCoreState(Widget child) {
|
||||||
return Selector2<Config, ClashConfig, CoreState>(
|
return Selector2<Config, ClashConfig, CoreState>(
|
||||||
selector: (_, config, clashConfig) => CoreState(
|
selector: (_, config, clashConfig) => CoreState(
|
||||||
accessControl: config.isAccessControl ? config.accessControl : null,
|
accessControl: config.isAccessControl ? config.accessControl : null,
|
||||||
allowBypass: config.allowBypass,
|
enable: config.vpnProps.enable,
|
||||||
systemProxy: config.systemProxy,
|
allowBypass: config.vpnProps.allowBypass,
|
||||||
|
systemProxy: config.vpnProps.systemProxy,
|
||||||
mixedPort: clashConfig.mixedPort,
|
mixedPort: clashConfig.mixedPort,
|
||||||
onlyProxy: config.onlyProxy,
|
onlyProxy: config.onlyProxy,
|
||||||
|
currentProfileName:
|
||||||
|
config.currentProfile?.label ?? config.currentProfileId ?? "",
|
||||||
),
|
),
|
||||||
builder: (__, state, child) {
|
builder: (__, state, child) {
|
||||||
clashCore.setState(state);
|
clashCore.setState(state);
|
||||||
@@ -36,9 +77,38 @@ class _ClashContainerState extends State<ClashContainer>
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_changeProfile() async {
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||||
|
if (globalState.autoRun) {
|
||||||
|
globalState.autoRun = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final appController = globalState.appController;
|
||||||
|
appController.appState.delayMap = {};
|
||||||
|
await appController.applyProfile();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _changeProfileContainer(Widget child) {
|
||||||
|
return Selector<Config, String?>(
|
||||||
|
selector: (_, config) => config.currentProfileId,
|
||||||
|
builder: (__, state, child) {
|
||||||
|
_changeProfile();
|
||||||
|
return child!;
|
||||||
|
},
|
||||||
|
child: child,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return _updateCoreState(widget.child);
|
return _changeProfileContainer(
|
||||||
|
_updateCoreState(
|
||||||
|
_updateContainer(
|
||||||
|
widget.child,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -54,15 +124,20 @@ class _ClashContainerState extends State<ClashContainer>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onDelay(Delay delay) {
|
Future<void> onDelay(Delay delay) async {
|
||||||
final appController = globalState.appController;
|
final appController = globalState.appController;
|
||||||
appController.setDelay(delay);
|
appController.setDelay(delay);
|
||||||
super.onDelay(delay);
|
super.onDelay(delay);
|
||||||
|
await globalState.appController.updateGroupDebounce();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onLog(Log log) {
|
void onLog(Log log) {
|
||||||
globalState.appController.appState.addLog(log);
|
globalState.appController.appState.addLog(log);
|
||||||
|
if (log.logLevel == LogLevel.error) {
|
||||||
|
globalState.appController.showSnackBar(log.payload ?? '');
|
||||||
|
}
|
||||||
|
debugPrint("$log");
|
||||||
super.onLog(log);
|
super.onLog(log);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,24 +148,14 @@ class _ClashContainerState extends State<ClashContainer>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onLoaded(String groupName) {
|
void onLoaded(String providerName) {
|
||||||
final appController = globalState.appController;
|
final appController = globalState.appController;
|
||||||
final currentSelectedMap = appController.config.currentSelectedMap;
|
appController.appState.setProvider(
|
||||||
final proxyName = currentSelectedMap[groupName];
|
clashCore.getExternalProvider(
|
||||||
if (proxyName == null) return;
|
providerName,
|
||||||
appController.changeProxy(
|
),
|
||||||
groupName: groupName,
|
|
||||||
proxyName: proxyName,
|
|
||||||
);
|
);
|
||||||
super.onLoaded(proxyName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<void> onStarted(String runTime) async {
|
|
||||||
super.onStarted(runTime);
|
|
||||||
proxy?.updateStartTime();
|
|
||||||
final appController = globalState.appController;
|
|
||||||
await appController.applyProfile(isPrue: true);
|
|
||||||
appController.addCheckIpNumDebounce();
|
appController.addCheckIpNumDebounce();
|
||||||
|
super.onLoaded(providerName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
37
lib/widgets/proxy_container.dart
Normal file
37
lib/widgets/proxy_container.dart
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
import 'package:fl_clash/common/proxy.dart';
|
||||||
|
import 'package:fl_clash/models/models.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
class ProxyContainer extends StatelessWidget {
|
||||||
|
final Widget child;
|
||||||
|
|
||||||
|
const ProxyContainer({super.key, required this.child});
|
||||||
|
|
||||||
|
_updateProxy(ProxyState proxyState) {
|
||||||
|
final isStart = proxyState.isStart;
|
||||||
|
final systemProxy = proxyState.systemProxy;
|
||||||
|
final port = proxyState.port;
|
||||||
|
if (isStart && systemProxy) {
|
||||||
|
proxy?.startProxy(port);
|
||||||
|
}else{
|
||||||
|
proxy?.stopProxy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Selector3<AppState, Config, ClashConfig, ProxyState>(
|
||||||
|
selector: (_, appState, config, clashConfig) => ProxyState(
|
||||||
|
isStart: appState.isStart,
|
||||||
|
systemProxy: config.desktopProps.systemProxy,
|
||||||
|
port: clashConfig.mixedPort,
|
||||||
|
),
|
||||||
|
builder: (_, state, child) {
|
||||||
|
_updateProxy(state);
|
||||||
|
return child!;
|
||||||
|
},
|
||||||
|
child: child,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -109,7 +109,7 @@ class CommonScaffoldState extends State<CommonScaffold> {
|
|||||||
valueListenable: _actions,
|
valueListenable: _actions,
|
||||||
builder: (_, actions, __) {
|
builder: (_, actions, __) {
|
||||||
final realActions =
|
final realActions =
|
||||||
actions.isNotEmpty ? actions : widget.actions;
|
actions.isNotEmpty ? actions : widget.actions;
|
||||||
return AppBar(
|
return AppBar(
|
||||||
centerTitle: false,
|
centerTitle: false,
|
||||||
automaticallyImplyLeading: widget.automaticallyImplyLeading,
|
automaticallyImplyLeading: widget.automaticallyImplyLeading,
|
||||||
|
|||||||
74
lib/widgets/setting.dart
Normal file
74
lib/widgets/setting.dart
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
import 'package:fl_clash/common/common.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'card.dart';
|
||||||
|
|
||||||
|
class SettingInfoCard extends StatelessWidget {
|
||||||
|
final Info info;
|
||||||
|
final bool? isSelected;
|
||||||
|
final VoidCallback onPressed;
|
||||||
|
|
||||||
|
const SettingInfoCard(
|
||||||
|
this.info, {
|
||||||
|
super.key,
|
||||||
|
this.isSelected,
|
||||||
|
required this.onPressed,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return CommonCard(
|
||||||
|
isSelected: isSelected,
|
||||||
|
onPressed: onPressed,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(12),
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Flexible(
|
||||||
|
child: Icon(info.iconData),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
width: 8,
|
||||||
|
),
|
||||||
|
Flexible(
|
||||||
|
child: Text(
|
||||||
|
info.label,
|
||||||
|
style: context.textTheme.bodyMedium,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class SettingTextCard extends StatelessWidget {
|
||||||
|
final String text;
|
||||||
|
final bool? isSelected;
|
||||||
|
final VoidCallback onPressed;
|
||||||
|
|
||||||
|
const SettingTextCard(
|
||||||
|
this.text, {
|
||||||
|
super.key,
|
||||||
|
this.isSelected,
|
||||||
|
required this.onPressed,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return CommonCard(
|
||||||
|
onPressed: onPressed,
|
||||||
|
isSelected: isSelected,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(12),
|
||||||
|
child: Text(
|
||||||
|
text,
|
||||||
|
style: context.textTheme.bodyMedium,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user