Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8d4931c093 | ||
|
|
23e3baf534 | ||
|
|
d522a64604 | ||
|
|
3902ea0064 |
15
README.md
15
README.md
@@ -6,18 +6,9 @@
|
||||
|
||||
## FlClash
|
||||
|
||||
<p style="text-align: left;">
|
||||
<a href="https://github.com/chen08209/FlClash/releases/latest">
|
||||
<img alt="release" src="https://img.shields.io/github/v/release/chen08209/FlClash?logo=github"/>
|
||||
</a>
|
||||
<a href="https://t.me/FlClash">
|
||||
<img alt="channel" src="https://img.shields.io/badge/Telegram-Channel-blue?logo=telegram"/>
|
||||
</a>
|
||||
<img alt="downloads" src="https://img.shields.io/github/downloads/chen08209/FlClash/total"/>
|
||||
<a href="LICENSE">
|
||||
<img alt="license" src="https://img.shields.io/github/license/chen08209/FlClash"/>
|
||||
</a>
|
||||
</p>
|
||||
[](https://github.com/chen08209/FlClash/releases/)[](https://github.com/chen08209/FlClash/releases/)[](LICENSE)
|
||||
|
||||
[](https://t.me/FlClash)
|
||||
|
||||
A multi-platform proxy client based on ClashMeta, simple and easy to use, open-source and ad-free.
|
||||
|
||||
|
||||
@@ -6,18 +6,10 @@
|
||||
|
||||
## FlClash
|
||||
|
||||
<p style="text-align: left;">
|
||||
<a href="https://github.com/chen08209/FlClash/releases/latest">
|
||||
<img alt="release" src="https://img.shields.io/github/v/release/chen08209/FlClash?logo=github"/>
|
||||
</a>
|
||||
<a href="https://t.me/FlClash">
|
||||
<img alt="channel" src="https://img.shields.io/badge/Telegram-Channel-blue?logo=telegram"/>
|
||||
</a>
|
||||
<img alt="downloads" src="https://img.shields.io/github/downloads/chen08209/FlClash/total"/>
|
||||
<a href="LICENSE">
|
||||
<img alt="license" src="https://img.shields.io/github/license/chen08209/FlClash"/>
|
||||
</a>
|
||||
</p>
|
||||
[](https://github.com/chen08209/FlClash/releases/)[](https://github.com/chen08209/FlClash/releases/)[](LICENSE)
|
||||
|
||||
[](https://t.me/FlClash)
|
||||
|
||||
|
||||
基于ClashMeta的多平台代理客户端,简单易用,开源无广告。
|
||||
|
||||
|
||||
@@ -34,22 +34,22 @@ def isRelease = defStoreFile.exists() && defStorePassword != null && defKeyAlias
|
||||
android {
|
||||
namespace "com.follow.clash"
|
||||
compileSdkVersion 34
|
||||
ndkVersion "25.1.8937393"
|
||||
ndkVersion "27.1.12297006"
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
sourceCompatibility JavaVersion.VERSION_17
|
||||
targetCompatibility JavaVersion.VERSION_17
|
||||
}
|
||||
|
||||
kotlinOptions {
|
||||
jvmTarget = '1.8'
|
||||
jvmTarget = '17'
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main.java.srcDirs += 'src/main/kotlin'
|
||||
}
|
||||
signingConfigs {
|
||||
if (isRelease){
|
||||
if (isRelease) {
|
||||
release {
|
||||
storeFile defStoreFile
|
||||
storePassword defStorePassword
|
||||
@@ -74,10 +74,9 @@ android {
|
||||
applicationIdSuffix '.debug'
|
||||
}
|
||||
release {
|
||||
minifyEnabled true
|
||||
if(isRelease){
|
||||
if (isRelease) {
|
||||
signingConfig signingConfigs.release
|
||||
}else{
|
||||
} else {
|
||||
signingConfig signingConfigs.debug
|
||||
}
|
||||
proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
|
||||
|
||||
@@ -10,25 +10,22 @@
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE"
|
||||
tools:ignore="SystemPermissionTypo" />
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
|
||||
<uses-permission
|
||||
android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE"
|
||||
tools:ignore="SystemPermissionTypo" />
|
||||
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
|
||||
<uses-permission
|
||||
android:name="android.permission.QUERY_ALL_PACKAGES"
|
||||
tools:ignore="QueryAllPackagesPermission" />
|
||||
|
||||
<application
|
||||
android:name="${applicationName}"
|
||||
android:enableOnBackInvokedCallback="true"
|
||||
android:extractNativeLibs="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="FlClash"
|
||||
android:networkSecurityConfig="@xml/network_security_config"
|
||||
tools:targetApi="tiramisu">
|
||||
android:hardwareAccelerated="true"
|
||||
android:label="FlClash">
|
||||
<activity
|
||||
android:name="com.follow.clash.MainActivity"
|
||||
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
|
||||
@@ -72,7 +69,17 @@
|
||||
|
||||
<activity
|
||||
android:name=".TempActivity"
|
||||
android:theme="@style/TransparentTheme" />
|
||||
android:exported="true"
|
||||
android:theme="@style/TransparentTheme">
|
||||
<intent-filter>
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<action android:name="com.follow.clash.action.START" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<action android:name="com.follow.clash.action.STOP" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<service
|
||||
android:name=".services.FlClashTileService"
|
||||
@@ -119,12 +126,19 @@
|
||||
<intent-filter>
|
||||
<action android:name="android.net.VpnService" />
|
||||
</intent-filter>
|
||||
<property
|
||||
android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
|
||||
android:value="vpn" />
|
||||
</service>
|
||||
|
||||
<service
|
||||
android:name=".services.FlClashService"
|
||||
android:exported="false"
|
||||
android:foregroundServiceType="specialUse" />
|
||||
android:foregroundServiceType="specialUse">
|
||||
<property
|
||||
android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
|
||||
android:value="service" />
|
||||
</service>
|
||||
|
||||
<meta-data
|
||||
android:name="flutterEmbedding"
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.follow.clash
|
||||
|
||||
import com.follow.clash.models.Props
|
||||
import com.follow.clash.models.TunProps
|
||||
|
||||
import com.follow.clash.models.VpnOptions
|
||||
|
||||
interface BaseServiceInterface {
|
||||
fun start(port: Int, props: Props?): TunProps?
|
||||
fun start(options: VpnOptions): Int
|
||||
fun stop()
|
||||
fun startForeground(title: String, content: String)
|
||||
}
|
||||
@@ -33,7 +33,7 @@ object GlobalState {
|
||||
return currentEngine?.plugins?.get(AppPlugin::class.java) as AppPlugin?
|
||||
}
|
||||
|
||||
fun getCurrentTitlePlugin(): TilePlugin? {
|
||||
fun getCurrentTilePlugin(): TilePlugin? {
|
||||
val currentEngine = if (flutterEngine != null) flutterEngine else serviceEngine
|
||||
return currentEngine?.plugins?.get(TilePlugin::class.java) as TilePlugin?
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.follow.clash
|
||||
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import com.follow.clash.plugins.AppPlugin
|
||||
import com.follow.clash.plugins.ServicePlugin
|
||||
import com.follow.clash.plugins.VpnPlugin
|
||||
@@ -9,7 +11,6 @@ import io.flutter.embedding.android.FlutterActivity
|
||||
import io.flutter.embedding.engine.FlutterEngine
|
||||
|
||||
class MainActivity : FlutterActivity() {
|
||||
|
||||
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
|
||||
super.configureFlutterEngine(flutterEngine)
|
||||
flutterEngine.plugins.add(AppPlugin())
|
||||
|
||||
@@ -6,6 +6,15 @@ import android.os.Bundle
|
||||
class TempActivity : Activity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
when (intent.action) {
|
||||
"com.follow.clash.action.START" -> {
|
||||
GlobalState.getCurrentTilePlugin()?.handleStart()
|
||||
}
|
||||
|
||||
"com.follow.clash.action.STOP" -> {
|
||||
GlobalState.getCurrentTilePlugin()?.handleStop()
|
||||
}
|
||||
}
|
||||
finishAndRemoveTask()
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import android.system.OsConstants.IPPROTO_TCP
|
||||
import android.system.OsConstants.IPPROTO_UDP
|
||||
import android.util.Base64
|
||||
import androidx.core.graphics.drawable.toBitmap
|
||||
import com.follow.clash.models.CIDR
|
||||
import com.follow.clash.models.Metadata
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
@@ -33,10 +34,29 @@ fun Metadata.getProtocol(): Int? {
|
||||
return null
|
||||
}
|
||||
|
||||
fun String.toCIDR(): CIDR {
|
||||
val parts = split("/")
|
||||
if (parts.size != 2) {
|
||||
throw IllegalArgumentException("Invalid CIDR format")
|
||||
}
|
||||
val ipAddress = parts[0]
|
||||
val prefixLength = parts[1].toIntOrNull()
|
||||
?: throw IllegalArgumentException("Invalid prefix length")
|
||||
|
||||
fun ConnectivityManager.resolvePrimaryDns(network: Network?): String? {
|
||||
val properties = getLinkProperties(network) ?: return null
|
||||
return properties.dnsServers.firstOrNull()?.asSocketAddressText(53)
|
||||
val address = InetAddress.getByName(ipAddress)
|
||||
|
||||
val maxPrefix = if (address.address.size == 4) 32 else 128
|
||||
if (prefixLength < 0 || prefixLength > maxPrefix) {
|
||||
throw IllegalArgumentException("Invalid prefix length for IP version")
|
||||
}
|
||||
|
||||
return CIDR(address, prefixLength)
|
||||
}
|
||||
|
||||
|
||||
fun ConnectivityManager.resolveDns(network: Network?): List<String> {
|
||||
val properties = getLinkProperties(network) ?: return listOf()
|
||||
return properties.dnsServers.map { it.asSocketAddressText(53) }
|
||||
}
|
||||
|
||||
fun InetAddress.asSocketAddressText(port: Int): String {
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
package com.follow.clash.models
|
||||
|
||||
import android.net.NetworkCapabilities
|
||||
import android.os.Build
|
||||
|
||||
val TRANSPORT_PRIORITY = sequence {
|
||||
yield(NetworkCapabilities.TRANSPORT_CELLULAR)
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 27) {
|
||||
yield(NetworkCapabilities.TRANSPORT_LOWPAN)
|
||||
}
|
||||
|
||||
yield(NetworkCapabilities.TRANSPORT_BLUETOOTH)
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 26) {
|
||||
yield(NetworkCapabilities.TRANSPORT_WIFI_AWARE)
|
||||
}
|
||||
|
||||
yield(NetworkCapabilities.TRANSPORT_WIFI)
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 31) {
|
||||
yield(NetworkCapabilities.TRANSPORT_USB)
|
||||
}
|
||||
|
||||
yield(NetworkCapabilities.TRANSPORT_ETHERNET)
|
||||
}.toList()
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.follow.clash.models
|
||||
|
||||
import java.net.InetAddress
|
||||
|
||||
enum class AccessControlMode {
|
||||
acceptSelected,
|
||||
rejectSelected,
|
||||
@@ -11,19 +13,16 @@ data class AccessControl(
|
||||
val rejectList: List<String>,
|
||||
)
|
||||
|
||||
data class Props(
|
||||
val enable: Boolean?,
|
||||
val accessControl: AccessControl?,
|
||||
val allowBypass: Boolean?,
|
||||
val systemProxy: Boolean?,
|
||||
)
|
||||
data class CIDR(val address: InetAddress, val prefixLength: Int)
|
||||
|
||||
data class TunProps(
|
||||
val fd: Int,
|
||||
val gateway: String,
|
||||
val gateway6: String,
|
||||
val portal: String,
|
||||
val portal6: String,
|
||||
val dns: String,
|
||||
val dns6: String
|
||||
data class VpnOptions(
|
||||
val enable: Boolean,
|
||||
val port: Int,
|
||||
val accessControl: AccessControl?,
|
||||
val allowBypass: Boolean,
|
||||
val systemProxy: Boolean,
|
||||
val bypassDomain: List<String>,
|
||||
val ipv4Address: String,
|
||||
val ipv6Address: String,
|
||||
val dnsServerAddress: String,
|
||||
)
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.follow.clash.plugins
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.ComponentName
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
@@ -16,9 +15,7 @@ import com.follow.clash.BaseServiceInterface
|
||||
import com.follow.clash.GlobalState
|
||||
import com.follow.clash.RunState
|
||||
import com.follow.clash.extensions.getProtocol
|
||||
import com.follow.clash.extensions.resolvePrimaryDns
|
||||
import com.follow.clash.models.Props
|
||||
import com.follow.clash.models.TunProps
|
||||
import com.follow.clash.extensions.resolveDns
|
||||
import com.follow.clash.services.FlClashService
|
||||
import com.follow.clash.services.FlClashVpnService
|
||||
import com.google.gson.Gson
|
||||
@@ -32,14 +29,14 @@ import kotlinx.coroutines.withContext
|
||||
import java.net.InetSocketAddress
|
||||
import kotlin.concurrent.withLock
|
||||
import com.follow.clash.models.Process
|
||||
import com.follow.clash.models.VpnOptions
|
||||
|
||||
|
||||
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 lateinit var options: VpnOptions
|
||||
private lateinit var scope: CoroutineScope
|
||||
|
||||
private val connectivity by lazy {
|
||||
@@ -79,11 +76,9 @@ class VpnPlugin : FlutterPlugin, MethodChannel.MethodCallHandler {
|
||||
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) {
|
||||
val data = call.argument<String>("data")
|
||||
options = Gson().fromJson(data, VpnOptions::class.java)
|
||||
when (options.enable) {
|
||||
true -> handleStartVpn()
|
||||
false -> start()
|
||||
}
|
||||
@@ -163,8 +158,7 @@ class VpnPlugin : FlutterPlugin, MethodChannel.MethodCallHandler {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("ForegroundServiceType")
|
||||
fun handleStartVpn() {
|
||||
private fun handleStartVpn() {
|
||||
GlobalState.getCurrentAppPlugin()?.requestVpnPermission(context) {
|
||||
start()
|
||||
}
|
||||
@@ -177,9 +171,11 @@ class VpnPlugin : FlutterPlugin, MethodChannel.MethodCallHandler {
|
||||
val networks = mutableSetOf<Network>()
|
||||
|
||||
fun onUpdateNetwork() {
|
||||
val dns = networks.mapNotNull {
|
||||
connectivity?.resolvePrimaryDns(it)
|
||||
}.joinToString(separator = ",")
|
||||
val dns = networks.flatMap { network ->
|
||||
connectivity?.resolveDns(network) ?: emptyList()
|
||||
}
|
||||
.toSet()
|
||||
.joinToString(",")
|
||||
scope.launch {
|
||||
withContext(Dispatchers.Main) {
|
||||
flutterMethodChannel.invokeMethod("dnsChanged", dns)
|
||||
@@ -226,7 +222,6 @@ class VpnPlugin : FlutterPlugin, MethodChannel.MethodCallHandler {
|
||||
onUpdateNetwork()
|
||||
}
|
||||
|
||||
@SuppressLint("ForegroundServiceType")
|
||||
private fun startForeground(title: String, content: String) {
|
||||
GlobalState.runLock.withLock {
|
||||
if (GlobalState.runState.value != RunState.START) return
|
||||
@@ -242,10 +237,10 @@ class VpnPlugin : FlutterPlugin, MethodChannel.MethodCallHandler {
|
||||
GlobalState.runLock.withLock {
|
||||
if (GlobalState.runState.value == RunState.START) return
|
||||
GlobalState.runState.value = RunState.START
|
||||
val tunProps = flClashService?.start(port, props)
|
||||
val fd = flClashService?.start(options)
|
||||
flutterMethodChannel.invokeMethod(
|
||||
"started",
|
||||
Gson().toJson(tunProps, TunProps::class.java)
|
||||
fd
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -260,7 +255,7 @@ class VpnPlugin : FlutterPlugin, MethodChannel.MethodCallHandler {
|
||||
}
|
||||
|
||||
private fun bindService() {
|
||||
val intent = when (props?.enable == true) {
|
||||
val intent = when (options.enable) {
|
||||
true -> Intent(context, FlClashVpnService::class.java)
|
||||
false -> Intent(context, FlClashService::class.java)
|
||||
}
|
||||
|
||||
@@ -11,14 +11,12 @@ 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
|
||||
import com.follow.clash.models.VpnOptions
|
||||
|
||||
|
||||
@SuppressLint("WrongConstant")
|
||||
class FlClashService : Service(), BaseServiceInterface {
|
||||
|
||||
private val binder = LocalBinder()
|
||||
@@ -73,7 +71,7 @@ class FlClashService : Service(), BaseServiceInterface {
|
||||
}
|
||||
}
|
||||
|
||||
override fun start(port: Int, props: Props?) = null
|
||||
override fun start(options: VpnOptions) = 0
|
||||
|
||||
override fun stop() {
|
||||
stopSelf()
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.follow.clash.services
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.PendingIntent
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
@@ -37,6 +38,7 @@ class FlClashTileService : TileService() {
|
||||
GlobalState.runState.observeForever(observer)
|
||||
}
|
||||
|
||||
@SuppressLint("StartActivityAndCollapseDeprecated")
|
||||
private fun activityTransfer() {
|
||||
val intent = Intent(this, TempActivity::class.java)
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_MULTIPLE_TASK)
|
||||
@@ -67,15 +69,15 @@ class FlClashTileService : TileService() {
|
||||
activityTransfer()
|
||||
if (GlobalState.runState.value == RunState.STOP) {
|
||||
GlobalState.runState.value = RunState.PENDING
|
||||
val titlePlugin = GlobalState.getCurrentTitlePlugin()
|
||||
if (titlePlugin != null) {
|
||||
titlePlugin.handleStart()
|
||||
val tilePlugin = GlobalState.getCurrentTilePlugin()
|
||||
if (tilePlugin != null) {
|
||||
tilePlugin.handleStart()
|
||||
} else {
|
||||
GlobalState.initServiceEngine(applicationContext)
|
||||
}
|
||||
} else if (GlobalState.runState.value == RunState.START) {
|
||||
GlobalState.runState.value = RunState.PENDING
|
||||
GlobalState.getCurrentTitlePlugin()?.handleStop()
|
||||
GlobalState.getCurrentTilePlugin()?.handleStop()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,71 +15,41 @@ import android.os.Build
|
||||
import android.os.IBinder
|
||||
import android.os.Parcel
|
||||
import android.os.RemoteException
|
||||
import android.util.Log
|
||||
import androidx.core.app.NotificationCompat
|
||||
import com.follow.clash.BaseServiceInterface
|
||||
import com.follow.clash.GlobalState
|
||||
import com.follow.clash.MainActivity
|
||||
import com.follow.clash.R
|
||||
import com.follow.clash.TempActivity
|
||||
import com.follow.clash.extensions.toCIDR
|
||||
import com.follow.clash.models.AccessControlMode
|
||||
import com.follow.clash.models.Props
|
||||
import com.follow.clash.models.TunProps
|
||||
import com.follow.clash.models.VpnOptions
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
|
||||
@SuppressLint("WrongConstant")
|
||||
class FlClashVpnService : VpnService(), BaseServiceInterface {
|
||||
|
||||
companion object {
|
||||
private val passList = listOf(
|
||||
"*zhihu.com",
|
||||
"*zhimg.com",
|
||||
"*jd.com",
|
||||
"100ime-iat-api.xfyun.cn",
|
||||
"*360buyimg.com",
|
||||
"localhost",
|
||||
"*.local",
|
||||
"127.*",
|
||||
"10.*",
|
||||
"172.16.*",
|
||||
"172.17.*",
|
||||
"172.18.*",
|
||||
"172.19.*",
|
||||
"172.2*",
|
||||
"172.30.*",
|
||||
"172.31.*",
|
||||
"192.168.*"
|
||||
)
|
||||
private const val TUN_MTU = 9000
|
||||
private const val TUN_SUBNET_PREFIX = 30
|
||||
private const val TUN_GATEWAY = "172.19.0.1"
|
||||
private const val TUN_SUBNET_PREFIX6 = 126
|
||||
private const val TUN_GATEWAY6 = "fdfe:dcba:9876::1"
|
||||
private const val TUN_PORTAL = "172.19.0.2"
|
||||
private const val TUN_PORTAL6 = "fdfe:dcba:9876::2"
|
||||
private const val TUN_DNS = TUN_PORTAL
|
||||
private const val TUN_DNS6 = TUN_PORTAL6
|
||||
private const val NET_ANY = "0.0.0.0"
|
||||
private const val NET_ANY6 = "::"
|
||||
}
|
||||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
GlobalState.initServiceEngine(applicationContext)
|
||||
}
|
||||
|
||||
override fun start(port: Int, props: Props?): TunProps {
|
||||
override fun start(options: VpnOptions): Int {
|
||||
return with(Builder()) {
|
||||
addAddress(TUN_GATEWAY, TUN_SUBNET_PREFIX)
|
||||
addAddress(TUN_GATEWAY6, TUN_SUBNET_PREFIX6)
|
||||
addRoute(NET_ANY, 0)
|
||||
addRoute(NET_ANY6, 0)
|
||||
addDnsServer(TUN_DNS)
|
||||
addDnsServer(TUN_DNS6)
|
||||
setMtu(TUN_MTU)
|
||||
props?.accessControl?.let { accessControl ->
|
||||
if (options.ipv4Address.isNotEmpty()) {
|
||||
val cidr = options.ipv4Address.toCIDR()
|
||||
addAddress(cidr.address, cidr.prefixLength)
|
||||
addRoute("0.0.0.0", 0)
|
||||
}
|
||||
if (options.ipv6Address.isNotEmpty()) {
|
||||
val cidr = options.ipv6Address.toCIDR()
|
||||
addAddress(cidr.address, cidr.prefixLength)
|
||||
addRoute("::", 0)
|
||||
}
|
||||
addDnsServer(options.dnsServerAddress)
|
||||
setMtu(9000)
|
||||
options.accessControl?.let { accessControl ->
|
||||
when (accessControl.mode) {
|
||||
AccessControlMode.acceptSelected -> {
|
||||
(accessControl.acceptList + packageName).forEach {
|
||||
@@ -99,32 +69,24 @@ class FlClashVpnService : VpnService(), BaseServiceInterface {
|
||||
if (Build.VERSION.SDK_INT >= 29) {
|
||||
setMetered(false)
|
||||
}
|
||||
if (props?.allowBypass == true) {
|
||||
if (options.allowBypass) {
|
||||
allowBypass()
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && props?.systemProxy == true) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && options.systemProxy) {
|
||||
setHttpProxy(
|
||||
ProxyInfo.buildDirectProxy(
|
||||
"127.0.0.1",
|
||||
port,
|
||||
passList
|
||||
options.port,
|
||||
options.bypassDomain
|
||||
)
|
||||
)
|
||||
}
|
||||
TunProps(
|
||||
fd = establish()?.detachFd()
|
||||
?: throw NullPointerException("Establish VPN rejected by system"),
|
||||
gateway = "$TUN_GATEWAY/$TUN_SUBNET_PREFIX",
|
||||
gateway6 = "$TUN_GATEWAY6/$TUN_SUBNET_PREFIX6",
|
||||
portal = TUN_PORTAL,
|
||||
portal6 = TUN_PORTAL6,
|
||||
dns = TUN_DNS,
|
||||
dns6 = TUN_DNS6
|
||||
)
|
||||
establish()?.detachFd()
|
||||
?: throw NullPointerException("Establish VPN rejected by system")
|
||||
}
|
||||
}
|
||||
|
||||
fun updateUnderlyingNetworks( networks: Array<Network>){
|
||||
fun updateUnderlyingNetworks(networks: Array<Network>) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
|
||||
this.setUnderlyingNetworks(networks)
|
||||
}
|
||||
@@ -159,6 +121,27 @@ class FlClashVpnService : VpnService(), BaseServiceInterface {
|
||||
PendingIntent.FLAG_UPDATE_CURRENT
|
||||
)
|
||||
}
|
||||
|
||||
val stopIntent = Intent(this, TempActivity::class.java)
|
||||
stopIntent.action = "com.follow.clash.action.STOP"
|
||||
stopIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_MULTIPLE_TASK)
|
||||
|
||||
|
||||
val stopPendingIntent = if (Build.VERSION.SDK_INT >= 31) {
|
||||
PendingIntent.getActivity(
|
||||
this,
|
||||
0,
|
||||
stopIntent,
|
||||
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
|
||||
)
|
||||
} else {
|
||||
PendingIntent.getActivity(
|
||||
this,
|
||||
0,
|
||||
stopIntent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT
|
||||
)
|
||||
}
|
||||
with(NotificationCompat.Builder(this, CHANNEL)) {
|
||||
setSmallIcon(R.drawable.ic_stat_name)
|
||||
setContentTitle("FlClash")
|
||||
@@ -172,6 +155,7 @@ class FlClashVpnService : VpnService(), BaseServiceInterface {
|
||||
setShowWhen(false)
|
||||
setOnlyAlertOnce(true)
|
||||
setAutoCancel(true)
|
||||
addAction(0, "Stop", stopPendingIntent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,7 +194,7 @@ class FlClashVpnService : VpnService(), BaseServiceInterface {
|
||||
val isSuccess = super.onTransact(code, data, reply, flags)
|
||||
if (!isSuccess) {
|
||||
CoroutineScope(Dispatchers.Main).launch {
|
||||
GlobalState.getCurrentTitlePlugin()?.handleStop()
|
||||
GlobalState.getCurrentTilePlugin()?.handleStop()
|
||||
}
|
||||
}
|
||||
return isSuccess
|
||||
|
||||
Binary file not shown.
Binary file not shown.
64257
assets/data/GeoSite.dat
64257
assets/data/GeoSite.dat
File diff suppressed because one or more lines are too long
Binary file not shown.
299
core/common.go
299
core/common.go
@@ -3,14 +3,15 @@ package main
|
||||
import "C"
|
||||
import (
|
||||
"context"
|
||||
"core/state"
|
||||
"errors"
|
||||
route "github.com/metacubex/mihomo/hub/route"
|
||||
"github.com/metacubex/mihomo/constant/features"
|
||||
"github.com/metacubex/mihomo/hub/route"
|
||||
"math"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"sync"
|
||||
"syscall"
|
||||
"time"
|
||||
@@ -234,151 +235,151 @@ func decorationConfig(profileId string, cfg config.RawConfig) *config.RawConfig
|
||||
return prof
|
||||
}
|
||||
|
||||
func Reduce[T any, U any](s []T, initVal U, f func(U, T) U) U {
|
||||
for _, v := range s {
|
||||
initVal = f(initVal, v)
|
||||
}
|
||||
return initVal
|
||||
}
|
||||
//func Reduce[T any, U any](s []T, initVal U, f func(U, T) U) U {
|
||||
// for _, v := range s {
|
||||
// initVal = f(initVal, v)
|
||||
// }
|
||||
// return initVal
|
||||
//}
|
||||
//
|
||||
//func Map[T, U any](slice []T, fn func(T) U) []U {
|
||||
// result := make([]U, len(slice))
|
||||
// for i, v := range slice {
|
||||
// result[i] = fn(v)
|
||||
// }
|
||||
// return result
|
||||
//}
|
||||
//
|
||||
//func replaceFromMap(s string, m map[string]string) string {
|
||||
// for k, v := range m {
|
||||
// s = strings.ReplaceAll(s, k, v)
|
||||
// }
|
||||
// return s
|
||||
//}
|
||||
//
|
||||
//func removeDuplicateFromSlice[T any](slice []T) []T {
|
||||
// result := make([]T, 0)
|
||||
// seen := make(map[any]struct{})
|
||||
// for _, value := range slice {
|
||||
// if _, ok := seen[value]; !ok {
|
||||
// result = append(result, value)
|
||||
// seen[value] = struct{}{}
|
||||
// }
|
||||
// }
|
||||
// return result
|
||||
//}
|
||||
|
||||
func Map[T, U any](slice []T, fn func(T) U) []U {
|
||||
result := make([]U, len(slice))
|
||||
for i, v := range slice {
|
||||
result[i] = fn(v)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func replaceFromMap(s string, m map[string]string) string {
|
||||
for k, v := range m {
|
||||
s = strings.ReplaceAll(s, k, v)
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
func removeDuplicateFromSlice[T any](slice []T) []T {
|
||||
result := make([]T, 0)
|
||||
seen := make(map[any]struct{})
|
||||
for _, value := range slice {
|
||||
if _, ok := seen[value]; !ok {
|
||||
result = append(result, value)
|
||||
seen[value] = struct{}{}
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func generateProxyGroupAndRule(proxyGroup *[]map[string]any, rule *[]string) {
|
||||
var replacements = map[string]string{}
|
||||
var selectArr []map[string]any
|
||||
var urlTestArr []map[string]any
|
||||
var fallbackArr []map[string]any
|
||||
for _, group := range *proxyGroup {
|
||||
switch group["type"] {
|
||||
case "select":
|
||||
selectArr = append(selectArr, group)
|
||||
replacements[group["name"].(string)] = "Proxy"
|
||||
break
|
||||
case "url-test":
|
||||
urlTestArr = append(urlTestArr, group)
|
||||
replacements[group["name"].(string)] = "Auto"
|
||||
break
|
||||
case "fallback":
|
||||
fallbackArr = append(fallbackArr, group)
|
||||
replacements[group["name"].(string)] = "Fallback"
|
||||
break
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
ProxyProxies := Reduce(selectArr, []string{}, func(res []string, cur map[string]any) []string {
|
||||
if cur["proxies"] == nil {
|
||||
return res
|
||||
}
|
||||
for _, proxyName := range cur["proxies"].([]interface{}) {
|
||||
if str, ok := proxyName.(string); ok {
|
||||
str = replaceFromMap(str, replacements)
|
||||
if str != "Proxy" {
|
||||
res = append(res, str)
|
||||
}
|
||||
}
|
||||
}
|
||||
return res
|
||||
})
|
||||
|
||||
ProxyProxies = removeDuplicateFromSlice(ProxyProxies)
|
||||
|
||||
AutoProxies := Reduce(urlTestArr, []string{}, func(res []string, cur map[string]any) []string {
|
||||
if cur["proxies"] == nil {
|
||||
return res
|
||||
}
|
||||
for _, proxyName := range cur["proxies"].([]interface{}) {
|
||||
if str, ok := proxyName.(string); ok {
|
||||
str = replaceFromMap(str, replacements)
|
||||
if str != "Auto" {
|
||||
res = append(res, str)
|
||||
}
|
||||
}
|
||||
}
|
||||
return res
|
||||
})
|
||||
|
||||
AutoProxies = removeDuplicateFromSlice(AutoProxies)
|
||||
|
||||
FallbackProxies := Reduce(fallbackArr, []string{}, func(res []string, cur map[string]any) []string {
|
||||
if cur["proxies"] == nil {
|
||||
return res
|
||||
}
|
||||
for _, proxyName := range cur["proxies"].([]interface{}) {
|
||||
if str, ok := proxyName.(string); ok {
|
||||
str = replaceFromMap(str, replacements)
|
||||
if str != "Fallback" {
|
||||
res = append(res, str)
|
||||
}
|
||||
}
|
||||
}
|
||||
return res
|
||||
})
|
||||
|
||||
FallbackProxies = removeDuplicateFromSlice(FallbackProxies)
|
||||
|
||||
var computedProxyGroup []map[string]any
|
||||
|
||||
if len(ProxyProxies) > 0 {
|
||||
computedProxyGroup = append(computedProxyGroup,
|
||||
map[string]any{
|
||||
"name": "Proxy",
|
||||
"type": "select",
|
||||
"proxies": ProxyProxies,
|
||||
})
|
||||
}
|
||||
|
||||
if len(AutoProxies) > 0 {
|
||||
computedProxyGroup = append(computedProxyGroup,
|
||||
map[string]any{
|
||||
"name": "Auto",
|
||||
"type": "url-test",
|
||||
"proxies": AutoProxies,
|
||||
})
|
||||
}
|
||||
|
||||
if len(FallbackProxies) > 0 {
|
||||
computedProxyGroup = append(computedProxyGroup,
|
||||
map[string]any{
|
||||
"name": "Fallback",
|
||||
"type": "fallback",
|
||||
"proxies": FallbackProxies,
|
||||
})
|
||||
}
|
||||
|
||||
computedRule := Map(*rule, func(value string) string {
|
||||
return replaceFromMap(value, replacements)
|
||||
})
|
||||
|
||||
*proxyGroup = computedProxyGroup
|
||||
*rule = computedRule
|
||||
}
|
||||
//func generateProxyGroupAndRule(proxyGroup *[]map[string]any, rule *[]string) {
|
||||
// var replacements = map[string]string{}
|
||||
// var selectArr []map[string]any
|
||||
// var urlTestArr []map[string]any
|
||||
// var fallbackArr []map[string]any
|
||||
// for _, group := range *proxyGroup {
|
||||
// switch group["type"] {
|
||||
// case "select":
|
||||
// selectArr = append(selectArr, group)
|
||||
// replacements[group["name"].(string)] = "Proxy"
|
||||
// break
|
||||
// case "url-test":
|
||||
// urlTestArr = append(urlTestArr, group)
|
||||
// replacements[group["name"].(string)] = "Auto"
|
||||
// break
|
||||
// case "fallback":
|
||||
// fallbackArr = append(fallbackArr, group)
|
||||
// replacements[group["name"].(string)] = "Fallback"
|
||||
// break
|
||||
// default:
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// ProxyProxies := Reduce(selectArr, []string{}, func(res []string, cur map[string]any) []string {
|
||||
// if cur["proxies"] == nil {
|
||||
// return res
|
||||
// }
|
||||
// for _, proxyName := range cur["proxies"].([]interface{}) {
|
||||
// if str, ok := proxyName.(string); ok {
|
||||
// str = replaceFromMap(str, replacements)
|
||||
// if str != "Proxy" {
|
||||
// res = append(res, str)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return res
|
||||
// })
|
||||
//
|
||||
// ProxyProxies = removeDuplicateFromSlice(ProxyProxies)
|
||||
//
|
||||
// AutoProxies := Reduce(urlTestArr, []string{}, func(res []string, cur map[string]any) []string {
|
||||
// if cur["proxies"] == nil {
|
||||
// return res
|
||||
// }
|
||||
// for _, proxyName := range cur["proxies"].([]interface{}) {
|
||||
// if str, ok := proxyName.(string); ok {
|
||||
// str = replaceFromMap(str, replacements)
|
||||
// if str != "Auto" {
|
||||
// res = append(res, str)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return res
|
||||
// })
|
||||
//
|
||||
// AutoProxies = removeDuplicateFromSlice(AutoProxies)
|
||||
//
|
||||
// FallbackProxies := Reduce(fallbackArr, []string{}, func(res []string, cur map[string]any) []string {
|
||||
// if cur["proxies"] == nil {
|
||||
// return res
|
||||
// }
|
||||
// for _, proxyName := range cur["proxies"].([]interface{}) {
|
||||
// if str, ok := proxyName.(string); ok {
|
||||
// str = replaceFromMap(str, replacements)
|
||||
// if str != "Fallback" {
|
||||
// res = append(res, str)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return res
|
||||
// })
|
||||
//
|
||||
// FallbackProxies = removeDuplicateFromSlice(FallbackProxies)
|
||||
//
|
||||
// var computedProxyGroup []map[string]any
|
||||
//
|
||||
// if len(ProxyProxies) > 0 {
|
||||
// computedProxyGroup = append(computedProxyGroup,
|
||||
// map[string]any{
|
||||
// "name": "Proxy",
|
||||
// "type": "select",
|
||||
// "proxies": ProxyProxies,
|
||||
// })
|
||||
// }
|
||||
//
|
||||
// if len(AutoProxies) > 0 {
|
||||
// computedProxyGroup = append(computedProxyGroup,
|
||||
// map[string]any{
|
||||
// "name": "Auto",
|
||||
// "type": "url-test",
|
||||
// "proxies": AutoProxies,
|
||||
// })
|
||||
// }
|
||||
//
|
||||
// if len(FallbackProxies) > 0 {
|
||||
// computedProxyGroup = append(computedProxyGroup,
|
||||
// map[string]any{
|
||||
// "name": "Fallback",
|
||||
// "type": "fallback",
|
||||
// "proxies": FallbackProxies,
|
||||
// })
|
||||
// }
|
||||
//
|
||||
// computedRule := Map(*rule, func(value string) string {
|
||||
// return replaceFromMap(value, replacements)
|
||||
// })
|
||||
//
|
||||
// *proxyGroup = computedProxyGroup
|
||||
// *rule = computedRule
|
||||
//}
|
||||
|
||||
func genHosts(hosts, patchHosts map[string]any) {
|
||||
for k, v := range patchHosts {
|
||||
@@ -468,7 +469,9 @@ func updateListeners(general *config.General, listeners map[string]constant.Inbo
|
||||
listener.ReCreateShadowSocks(general.ShadowSocksConfig, tunnel.Tunnel)
|
||||
listener.ReCreateVmess(general.VmessConfig, tunnel.Tunnel)
|
||||
listener.ReCreateTuic(general.TuicServer, tunnel.Tunnel)
|
||||
listener.ReCreateTun(general.Tun, tunnel.Tunnel)
|
||||
if !features.Android {
|
||||
listener.ReCreateTun(general.Tun, tunnel.Tunnel)
|
||||
}
|
||||
}
|
||||
|
||||
func stopListeners() {
|
||||
@@ -522,7 +525,7 @@ func patchSelectGroup() {
|
||||
}
|
||||
|
||||
func applyConfig() error {
|
||||
cfg, err := config.ParseRawConfig(currentRawConfig)
|
||||
cfg, err := config.ParseRawConfig(state.CurrentRawConfig)
|
||||
if err != nil {
|
||||
cfg, _ = config.ParseRawConfig(config.DefaultRawConfig())
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import "C"
|
||||
import (
|
||||
"context"
|
||||
bridge "core/dart-bridge"
|
||||
"core/state"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/metacubex/mihomo/common/utils"
|
||||
@@ -30,8 +31,6 @@ import (
|
||||
"github.com/metacubex/mihomo/tunnel/statistic"
|
||||
)
|
||||
|
||||
var currentRawConfig = config.DefaultRawConfig()
|
||||
|
||||
var configParams = ConfigExtendedParams{}
|
||||
|
||||
var externalProviders = map[string]cp.Provider{}
|
||||
@@ -124,7 +123,7 @@ func updateConfig(s *C.char, port C.longlong) {
|
||||
}
|
||||
configParams = params.Params
|
||||
prof := decorationConfig(params.ProfileId, params.Config)
|
||||
currentRawConfig = prof
|
||||
state.CurrentRawConfig = prof
|
||||
err = applyConfig()
|
||||
if err != nil {
|
||||
bridge.SendToPort(i, err.Error())
|
||||
@@ -184,7 +183,7 @@ func changeProxy(s *C.char) {
|
||||
|
||||
//export getTraffic
|
||||
func getTraffic() *C.char {
|
||||
up, down := statistic.DefaultManager.Current(state.OnlyProxy)
|
||||
up, down := statistic.DefaultManager.Current(state.CurrentState.OnlyProxy)
|
||||
traffic := map[string]int64{
|
||||
"up": up,
|
||||
"down": down,
|
||||
@@ -199,7 +198,7 @@ func getTraffic() *C.char {
|
||||
|
||||
//export getTotalTraffic
|
||||
func getTotalTraffic() *C.char {
|
||||
up, down := statistic.DefaultManager.Total(state.OnlyProxy)
|
||||
up, down := statistic.DefaultManager.Total(state.CurrentState.OnlyProxy)
|
||||
traffic := map[string]int64{
|
||||
"up": up,
|
||||
"down": down,
|
||||
|
||||
@@ -2,36 +2,33 @@ package main
|
||||
|
||||
import "C"
|
||||
import (
|
||||
"core/state"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type AccessControl struct {
|
||||
Mode string `json:"mode"`
|
||||
AcceptList []string `json:"acceptList"`
|
||||
RejectList []string `json:"rejectList"`
|
||||
IsFilterSystemApp bool `json:"isFilterSystemApp"`
|
||||
//export getCurrentProfileName
|
||||
func getCurrentProfileName() *C.char {
|
||||
if state.CurrentState == nil {
|
||||
return C.CString("")
|
||||
}
|
||||
return C.CString(state.CurrentState.CurrentProfileName)
|
||||
}
|
||||
|
||||
type AndroidProps struct {
|
||||
Enable bool `json:"enable"`
|
||||
AccessControl *AccessControl `json:"accessControl"`
|
||||
AllowBypass bool `json:"allowBypass"`
|
||||
SystemProxy bool `json:"systemProxy"`
|
||||
}
|
||||
|
||||
type State struct {
|
||||
AndroidProps
|
||||
CurrentProfileName string `json:"currentProfileName"`
|
||||
MixedPort int `json:"mixedPort"`
|
||||
OnlyProxy bool `json:"onlyProxy"`
|
||||
}
|
||||
|
||||
var state State
|
||||
|
||||
//export getState
|
||||
func getState() *C.char {
|
||||
data, err := json.Marshal(state)
|
||||
//export getAndroidVpnOptions
|
||||
func getAndroidVpnOptions() *C.char {
|
||||
options := state.AndroidVpnOptions{
|
||||
Enable: state.CurrentState.Enable,
|
||||
Port: state.CurrentRawConfig.MixedPort,
|
||||
Ipv4Address: state.DefaultIpv4Address,
|
||||
Ipv6Address: state.GetIpv6Address(),
|
||||
AccessControl: state.CurrentState.AccessControl,
|
||||
SystemProxy: state.CurrentState.SystemProxy,
|
||||
AllowBypass: state.CurrentState.AllowBypass,
|
||||
BypassDomain: state.CurrentState.BypassDomain,
|
||||
DnsServerAddress: state.GetDnsServerAddress(),
|
||||
}
|
||||
data, err := json.Marshal(options)
|
||||
if err != nil {
|
||||
fmt.Println("Error:", err)
|
||||
return C.CString("")
|
||||
@@ -42,7 +39,7 @@ func getState() *C.char {
|
||||
//export setState
|
||||
func setState(s *C.char) {
|
||||
paramsString := C.GoString(s)
|
||||
err := json.Unmarshal([]byte(paramsString), &state)
|
||||
err := json.Unmarshal([]byte(paramsString), state.CurrentState)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
59
core/state/state.go
Normal file
59
core/state/state.go
Normal file
@@ -0,0 +1,59 @@
|
||||
package state
|
||||
|
||||
import "github.com/metacubex/mihomo/config"
|
||||
|
||||
var DefaultIpv4Address = "172.19.0.1/30"
|
||||
var DefaultDnsAddress = "172.19.0.2"
|
||||
var DefaultIpv6Address = "fdfe:dcba:9876::1/126"
|
||||
|
||||
var CurrentRawConfig = config.DefaultRawConfig()
|
||||
|
||||
type AndroidVpnOptions struct {
|
||||
Enable bool `json:"enable"`
|
||||
Port int `json:"port"`
|
||||
AccessControl *AccessControl `json:"accessControl"`
|
||||
AllowBypass bool `json:"allowBypass"`
|
||||
SystemProxy bool `json:"systemProxy"`
|
||||
BypassDomain []string `json:"bypassDomain"`
|
||||
Ipv4Address string `json:"ipv4Address"`
|
||||
Ipv6Address string `json:"ipv6Address"`
|
||||
DnsServerAddress string `json:"dnsServerAddress"`
|
||||
}
|
||||
|
||||
type AccessControl struct {
|
||||
Mode string `json:"mode"`
|
||||
AcceptList []string `json:"acceptList"`
|
||||
RejectList []string `json:"rejectList"`
|
||||
IsFilterSystemApp bool `json:"isFilterSystemApp"`
|
||||
}
|
||||
|
||||
type AndroidVpnRawOptions struct {
|
||||
Enable bool `json:"enable"`
|
||||
AccessControl *AccessControl `json:"accessControl"`
|
||||
AllowBypass bool `json:"allowBypass"`
|
||||
SystemProxy bool `json:"systemProxy"`
|
||||
Ipv6 bool `json:"ipv6"`
|
||||
BypassDomain []string `json:"bypassDomain"`
|
||||
}
|
||||
|
||||
type State struct {
|
||||
AndroidVpnRawOptions
|
||||
CurrentProfileName string `json:"currentProfileName"`
|
||||
OnlyProxy bool `json:"onlyProxy"`
|
||||
}
|
||||
|
||||
var CurrentState = &State{}
|
||||
|
||||
func GetIpv6Address() string {
|
||||
if CurrentState.Ipv6 {
|
||||
return DefaultIpv6Address
|
||||
} else {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
func GetDnsServerAddress() string {
|
||||
//prefix, _ := netip.ParsePrefix(DefaultIpv4Address)
|
||||
//return prefix.Addr().String()
|
||||
return DefaultDnsAddress
|
||||
}
|
||||
22
core/tun.go
22
core/tun.go
@@ -6,7 +6,6 @@ import "C"
|
||||
import (
|
||||
"core/platform"
|
||||
t "core/tun"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"github.com/metacubex/mihomo/listener/sing_tun"
|
||||
"strconv"
|
||||
@@ -42,11 +41,10 @@ var (
|
||||
)
|
||||
|
||||
//export startTUN
|
||||
func startTUN(s *C.char, port C.longlong) {
|
||||
func startTUN(fd C.int, port C.longlong) {
|
||||
i := int64(port)
|
||||
ServicePort = i
|
||||
paramsString := C.GoString(s)
|
||||
if paramsString == "" {
|
||||
if fd == 0 {
|
||||
tunLock.Lock()
|
||||
defer tunLock.Unlock()
|
||||
now := time.Now()
|
||||
@@ -61,20 +59,8 @@ func startTUN(s *C.char, port C.longlong) {
|
||||
go func() {
|
||||
tunLock.Lock()
|
||||
defer tunLock.Unlock()
|
||||
|
||||
var tunProps = &t.Props{}
|
||||
err := json.Unmarshal([]byte(paramsString), tunProps)
|
||||
if err != nil {
|
||||
log.Errorln("startTUN error: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
tunListener, err = t.Start(*tunProps)
|
||||
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
f := int(fd)
|
||||
tunListener, _ = t.Start(f)
|
||||
if tunListener != nil {
|
||||
log.Infoln("TUN address: %v", tunListener.Address())
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ package tun
|
||||
|
||||
import "C"
|
||||
import (
|
||||
"github.com/metacubex/mihomo/constant"
|
||||
"core/state"
|
||||
LC "github.com/metacubex/mihomo/listener/config"
|
||||
"github.com/metacubex/mihomo/listener/sing_tun"
|
||||
"github.com/metacubex/mihomo/log"
|
||||
@@ -23,38 +23,38 @@ type Props struct {
|
||||
Dns6 string `json:"dns6"`
|
||||
}
|
||||
|
||||
func Start(tunProps Props) (*sing_tun.Listener, error) {
|
||||
func Start(fd int) (*sing_tun.Listener, error) {
|
||||
var prefix4 []netip.Prefix
|
||||
tempPrefix4, err := netip.ParsePrefix(tunProps.Gateway)
|
||||
tempPrefix4, err := netip.ParsePrefix(state.DefaultIpv4Address)
|
||||
if err != nil {
|
||||
log.Errorln("startTUN error:", err)
|
||||
return nil, err
|
||||
}
|
||||
prefix4 = append(prefix4, tempPrefix4)
|
||||
|
||||
var prefix6 []netip.Prefix
|
||||
tempPrefix6, err := netip.ParsePrefix(tunProps.Gateway6)
|
||||
if err != nil {
|
||||
log.Errorln("startTUN error:", err)
|
||||
return nil, err
|
||||
if state.CurrentState.Ipv6 {
|
||||
tempPrefix6, err := netip.ParsePrefix(state.DefaultIpv6Address)
|
||||
if err != nil {
|
||||
log.Errorln("startTUN error:", err)
|
||||
return nil, err
|
||||
}
|
||||
prefix6 = append(prefix6, tempPrefix6)
|
||||
}
|
||||
prefix6 = append(prefix6, tempPrefix6)
|
||||
|
||||
var dnsHijack []string
|
||||
dnsHijack = append(dnsHijack, net.JoinHostPort(tunProps.Dns, "53"))
|
||||
dnsHijack = append(dnsHijack, net.JoinHostPort(tunProps.Dns6, "53"))
|
||||
dnsHijack = append(dnsHijack, net.JoinHostPort(state.GetDnsServerAddress(), "53"))
|
||||
|
||||
options := LC.Tun{
|
||||
Enable: true,
|
||||
Device: sing_tun.InterfaceName,
|
||||
Stack: constant.TunSystem,
|
||||
Device: state.CurrentRawConfig.Tun.Device,
|
||||
Stack: state.CurrentRawConfig.Tun.Stack,
|
||||
DNSHijack: dnsHijack,
|
||||
AutoRoute: false,
|
||||
AutoDetectInterface: false,
|
||||
Inet4Address: prefix4,
|
||||
Inet6Address: prefix6,
|
||||
MTU: 9000,
|
||||
FileDescriptor: tunProps.Fd,
|
||||
FileDescriptor: fd,
|
||||
}
|
||||
|
||||
listener, err := sing_tun.New(options, tunnel.Tunnel)
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:dynamic_color/dynamic_color.dart';
|
||||
import 'package:fl_clash/l10n/l10n.dart';
|
||||
import 'package:fl_clash/common/common.dart';
|
||||
@@ -29,11 +27,13 @@ runAppWithPreferences(
|
||||
ChangeNotifierProvider<Config>(
|
||||
create: (_) => config,
|
||||
),
|
||||
ChangeNotifierProvider<AppFlowingState>(
|
||||
create: (_) => AppFlowingState(),
|
||||
),
|
||||
ChangeNotifierProxyProvider2<Config, ClashConfig, AppState>(
|
||||
create: (_) => appState,
|
||||
update: (_, config, clashConfig, appState) {
|
||||
appState?.mode = clashConfig.mode;
|
||||
appState?.isCompatible = config.isCompatible;
|
||||
appState?.selectedMap = config.currentSelectedMap;
|
||||
return appState!;
|
||||
},
|
||||
@@ -85,6 +85,7 @@ class ApplicationState extends State<Application> {
|
||||
super.initState();
|
||||
_initTimer();
|
||||
globalState.appController = AppController(context);
|
||||
globalState.measure = Measure.of(context);
|
||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
|
||||
final currentContext = globalState.navigatorKey.currentContext;
|
||||
if (currentContext != null) {
|
||||
@@ -161,7 +162,7 @@ class ApplicationState extends State<Application> {
|
||||
child: ClashManager(
|
||||
child: Selector2<AppState, Config, ApplicationSelectorState>(
|
||||
selector: (_, appState, config) => ApplicationSelectorState(
|
||||
locale: config.locale,
|
||||
locale: config.appSetting.locale,
|
||||
themeMode: config.themeMode,
|
||||
primaryColor: config.primaryColor,
|
||||
prueBlack: config.prueBlack,
|
||||
@@ -179,8 +180,15 @@ class ApplicationState extends State<Application> {
|
||||
GlobalWidgetsLocalizations.delegate
|
||||
],
|
||||
builder: (_, child) {
|
||||
return MediaManager(
|
||||
child: _buildPage(child!),
|
||||
return LayoutBuilder(
|
||||
builder: (_, container) {
|
||||
final appController = globalState.appController;
|
||||
final maxWidth = container.maxWidth;
|
||||
if (appController.appState.viewWidth != maxWidth) {
|
||||
globalState.appController.updateViewWidth(maxWidth);
|
||||
}
|
||||
return _buildPage(child!);
|
||||
},
|
||||
);
|
||||
},
|
||||
scrollBehavior: BaseScrollBehavior(),
|
||||
|
||||
@@ -287,13 +287,18 @@ class ClashCore {
|
||||
malloc.free(stateChar);
|
||||
}
|
||||
|
||||
CoreState getState() {
|
||||
final stateRaw = clashFFI.getState();
|
||||
final state = json.decode(
|
||||
stateRaw.cast<Utf8>().toDartString(),
|
||||
);
|
||||
clashFFI.freeCString(stateRaw);
|
||||
return CoreState.fromJson(state);
|
||||
String getCurrentProfileName() {
|
||||
final currentProfileRaw = clashFFI.getCurrentProfileName();
|
||||
final currentProfile = currentProfileRaw.cast<Utf8>().toDartString();
|
||||
clashFFI.freeCString(currentProfileRaw);
|
||||
return currentProfile;
|
||||
}
|
||||
|
||||
AndroidVpnOptions getAndroidVpnOptions() {
|
||||
final vpnOptionsRaw = clashFFI.getAndroidVpnOptions();
|
||||
final vpnOptions = json.decode(vpnOptionsRaw.cast<Utf8>().toDartString());
|
||||
clashFFI.freeCString(vpnOptionsRaw);
|
||||
return AndroidVpnOptions.fromJson(vpnOptions);
|
||||
}
|
||||
|
||||
Traffic getTraffic() {
|
||||
@@ -322,11 +327,9 @@ class ClashCore {
|
||||
clashFFI.stopLog();
|
||||
}
|
||||
|
||||
startTun(TunProps? tunProps, int port) {
|
||||
startTun(int fd, int port) {
|
||||
if (!Platform.isAndroid) return;
|
||||
final tunPropsChar = json.encode(tunProps).toNativeUtf8().cast<Char>();
|
||||
clashFFI.startTUN(tunPropsChar, port);
|
||||
malloc.free(tunPropsChar);
|
||||
clashFFI.startTUN(fd, port);
|
||||
}
|
||||
|
||||
updateDns(String dns) {
|
||||
|
||||
@@ -5144,6 +5144,20 @@ class ClashFFI {
|
||||
late final __FCmulcr =
|
||||
__FCmulcrPtr.asFunction<_Fcomplex Function(_Fcomplex, double)>();
|
||||
|
||||
void updateDns(
|
||||
ffi.Pointer<ffi.Char> s,
|
||||
) {
|
||||
return _updateDns(
|
||||
s,
|
||||
);
|
||||
}
|
||||
|
||||
late final _updateDnsPtr =
|
||||
_lookup<ffi.NativeFunction<ffi.Void Function(ffi.Pointer<ffi.Char>)>>(
|
||||
'updateDns');
|
||||
late final _updateDns =
|
||||
_updateDnsPtr.asFunction<void Function(ffi.Pointer<ffi.Char>)>();
|
||||
|
||||
void start() {
|
||||
return _start();
|
||||
}
|
||||
@@ -5264,20 +5278,6 @@ class ClashFFI {
|
||||
late final _getProxies =
|
||||
_getProxiesPtr.asFunction<ffi.Pointer<ffi.Char> Function()>();
|
||||
|
||||
void updateDns(
|
||||
ffi.Pointer<ffi.Char> s,
|
||||
) {
|
||||
return _updateDns(
|
||||
s,
|
||||
);
|
||||
}
|
||||
|
||||
late final _updateDnsPtr =
|
||||
_lookup<ffi.NativeFunction<ffi.Void Function(ffi.Pointer<ffi.Char>)>>(
|
||||
'updateDns');
|
||||
late final _updateDns =
|
||||
_updateDnsPtr.asFunction<void Function(ffi.Pointer<ffi.Char>)>();
|
||||
|
||||
void changeProxy(
|
||||
ffi.Pointer<ffi.Char> s,
|
||||
) {
|
||||
@@ -5557,14 +5557,25 @@ class ClashFFI {
|
||||
late final _setProcessMap =
|
||||
_setProcessMapPtr.asFunction<void Function(ffi.Pointer<ffi.Char>)>();
|
||||
|
||||
ffi.Pointer<ffi.Char> getState() {
|
||||
return _getState();
|
||||
ffi.Pointer<ffi.Char> getCurrentProfileName() {
|
||||
return _getCurrentProfileName();
|
||||
}
|
||||
|
||||
late final _getStatePtr =
|
||||
_lookup<ffi.NativeFunction<ffi.Pointer<ffi.Char> Function()>>('getState');
|
||||
late final _getState =
|
||||
_getStatePtr.asFunction<ffi.Pointer<ffi.Char> Function()>();
|
||||
late final _getCurrentProfileNamePtr =
|
||||
_lookup<ffi.NativeFunction<ffi.Pointer<ffi.Char> Function()>>(
|
||||
'getCurrentProfileName');
|
||||
late final _getCurrentProfileName =
|
||||
_getCurrentProfileNamePtr.asFunction<ffi.Pointer<ffi.Char> Function()>();
|
||||
|
||||
ffi.Pointer<ffi.Char> getAndroidVpnOptions() {
|
||||
return _getAndroidVpnOptions();
|
||||
}
|
||||
|
||||
late final _getAndroidVpnOptionsPtr =
|
||||
_lookup<ffi.NativeFunction<ffi.Pointer<ffi.Char> Function()>>(
|
||||
'getAndroidVpnOptions');
|
||||
late final _getAndroidVpnOptions =
|
||||
_getAndroidVpnOptionsPtr.asFunction<ffi.Pointer<ffi.Char> Function()>();
|
||||
|
||||
void setState(
|
||||
ffi.Pointer<ffi.Char> s,
|
||||
@@ -5581,20 +5592,19 @@ class ClashFFI {
|
||||
_setStatePtr.asFunction<void Function(ffi.Pointer<ffi.Char>)>();
|
||||
|
||||
void startTUN(
|
||||
ffi.Pointer<ffi.Char> s,
|
||||
int fd,
|
||||
int port,
|
||||
) {
|
||||
return _startTUN(
|
||||
s,
|
||||
fd,
|
||||
port,
|
||||
);
|
||||
}
|
||||
|
||||
late final _startTUNPtr = _lookup<
|
||||
ffi.NativeFunction<
|
||||
ffi.Void Function(ffi.Pointer<ffi.Char>, ffi.LongLong)>>('startTUN');
|
||||
late final _startTUN =
|
||||
_startTUNPtr.asFunction<void Function(ffi.Pointer<ffi.Char>, int)>();
|
||||
late final _startTUNPtr =
|
||||
_lookup<ffi.NativeFunction<ffi.Void Function(ffi.Int, ffi.LongLong)>>(
|
||||
'startTUN');
|
||||
late final _startTUN = _startTUNPtr.asFunction<void Function(int, int)>();
|
||||
|
||||
ffi.Pointer<ffi.Char> getRunTime() {
|
||||
return _getRunTime();
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:fl_clash/plugins/app.dart';
|
||||
import 'package:fl_clash/state.dart';
|
||||
|
||||
class Android {
|
||||
init() async {
|
||||
app?.onExit = () {};
|
||||
app?.onExit = () async {
|
||||
await globalState.appController.savePreferences();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,4 +28,5 @@ export 'iterable.dart';
|
||||
export 'scroll.dart';
|
||||
export 'icons.dart';
|
||||
export 'http.dart';
|
||||
export 'keyboard.dart';
|
||||
export 'keyboard.dart';
|
||||
export 'network.dart';
|
||||
@@ -1,8 +1,9 @@
|
||||
import 'dart:io';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:fl_clash/enum/enum.dart';
|
||||
import 'package:fl_clash/models/clash_config.dart';
|
||||
import 'package:fl_clash/models/models.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'system.dart';
|
||||
|
||||
@@ -26,9 +27,9 @@ const GeoXMap defaultGeoXMap = {
|
||||
"mmdb":
|
||||
"https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geoip.metadb",
|
||||
"asn":
|
||||
"https://github.com/xishang0128/geoip/releases/download/latest/GeoLite2-ASN.mmdb",
|
||||
"https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/GeoLite2-ASN.mmdb",
|
||||
"geoip":
|
||||
"https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/GeoIP.dat",
|
||||
"https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geoip.dat",
|
||||
"geosite":
|
||||
"https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geosite.dat"
|
||||
};
|
||||
@@ -51,6 +52,21 @@ final filter = ImageFilter.blur(
|
||||
tileMode: TileMode.mirror,
|
||||
);
|
||||
|
||||
const navigationItemListEquality = ListEquality<NavigationItem>();
|
||||
const connectionListEquality = ListEquality<Connection>();
|
||||
const stringListEquality = ListEquality<String>();
|
||||
const logListEquality = ListEquality<Log>();
|
||||
const groupListEquality = ListEquality<Group>();
|
||||
const externalProviderListEquality = ListEquality<ExternalProvider>();
|
||||
const packageListEquality = ListEquality<Package>();
|
||||
const hotKeyActionListEquality = ListEquality<HotKeyAction>();
|
||||
const stringAndStringMapEquality = MapEquality<String, String>();
|
||||
const stringAndStringMapEntryIterableEquality =
|
||||
IterableEquality<MapEntry<String, String>>();
|
||||
const stringAndIntQMapEquality = MapEquality<String, int?>();
|
||||
const stringSetEquality = SetEquality<String>();
|
||||
const keyboardModifierListEquality = SetEquality<KeyboardModifier>();
|
||||
|
||||
const viewModeColumnsMap = {
|
||||
ViewMode.mobile: [2, 1],
|
||||
ViewMode.laptop: [3, 2],
|
||||
|
||||
@@ -11,7 +11,7 @@ extension BuildContextExtension on BuildContext {
|
||||
return MediaQuery.of(this).size;
|
||||
}
|
||||
|
||||
double get width {
|
||||
double get viewWidth {
|
||||
return appSize.width;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,8 +11,9 @@ class FlClashHttpOverrides extends HttpOverrides {
|
||||
client.badCertificateCallback = (_, __, ___) => true;
|
||||
client.findProxy = (url) {
|
||||
debugPrint("find $url");
|
||||
final port = globalState.appController.clashConfig.mixedPort;
|
||||
final isStart = globalState.appController.appState.isStart;
|
||||
final appController = globalState.appController;
|
||||
final port = appController.clashConfig.mixedPort;
|
||||
final isStart = appController.appFlowingState.isStart;
|
||||
if (!isStart) return "DIRECT";
|
||||
return "PROXY localhost:$port";
|
||||
};
|
||||
|
||||
@@ -62,6 +62,6 @@ extension DoubleListExt on List<double> {
|
||||
}
|
||||
}
|
||||
|
||||
return -1; // 这行理论上不会执行到,但为了完整性保留
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,22 +58,7 @@ class AutoLaunch {
|
||||
|
||||
Future<bool> windowsEnable() async {
|
||||
await disable();
|
||||
return windows?.runas(
|
||||
'schtasks',
|
||||
[
|
||||
'/Create',
|
||||
'/SC',
|
||||
'ONLOGON',
|
||||
'/TN',
|
||||
appName,
|
||||
'/TR',
|
||||
'"${Platform.resolvedExecutable}"',
|
||||
'/RL',
|
||||
'HIGHEST',
|
||||
'/F'
|
||||
].join(" "),
|
||||
) ??
|
||||
false;
|
||||
return await windows?.registerTask(appName) ?? false;
|
||||
}
|
||||
|
||||
Future<bool> disable() async {
|
||||
@@ -81,9 +66,9 @@ class AutoLaunch {
|
||||
}
|
||||
|
||||
updateStatus(AutoLaunchState state) async {
|
||||
final isOpenTun = state.isOpenTun;
|
||||
final isAdminAutoLaunch = state.isAdminAutoLaunch;
|
||||
final isAutoLaunch = state.isAutoLaunch;
|
||||
if (Platform.isWindows && isOpenTun) {
|
||||
if (Platform.isWindows && isAdminAutoLaunch) {
|
||||
if (await windowsIsEnable == isAutoLaunch) return;
|
||||
if (isAutoLaunch) {
|
||||
final isEnable = await windowsEnable();
|
||||
|
||||
@@ -15,4 +15,10 @@ extension ListExtension<T> on List<T> {
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
List<T> safeSublist(int start) {
|
||||
if(start <= 0) return this;
|
||||
if(start > length) return [];
|
||||
return sublist(start);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,9 @@ class Measure {
|
||||
final TextScaler _textScale;
|
||||
late BuildContext context;
|
||||
|
||||
Measure.of(this.context) : _textScale = MediaQuery.of(context).textScaler;
|
||||
Measure.of(this.context)
|
||||
: _textScale = TextScaler.linear(
|
||||
WidgetsBinding.instance.platformDispatcher.textScaleFactor);
|
||||
|
||||
Size computeTextSize(Text text) {
|
||||
final textPainter = TextPainter(
|
||||
@@ -19,6 +21,7 @@ class Measure {
|
||||
}
|
||||
|
||||
double? _bodyMediumHeight;
|
||||
Size? _bodyLargeSize;
|
||||
double? _bodySmallHeight;
|
||||
double? _labelSmallHeight;
|
||||
double? _labelMediumHeight;
|
||||
@@ -28,17 +31,28 @@ class Measure {
|
||||
double get bodyMediumHeight {
|
||||
_bodyMediumHeight ??= computeTextSize(
|
||||
Text(
|
||||
"",
|
||||
"X",
|
||||
style: context.textTheme.bodyMedium,
|
||||
),
|
||||
).height;
|
||||
return _bodyMediumHeight!;
|
||||
}
|
||||
|
||||
|
||||
Size get bodyLargeSize {
|
||||
_bodyLargeSize ??= computeTextSize(
|
||||
Text(
|
||||
"X",
|
||||
style: context.textTheme.bodyLarge,
|
||||
),
|
||||
);
|
||||
return _bodyLargeSize!;
|
||||
}
|
||||
|
||||
double get bodySmallHeight {
|
||||
_bodySmallHeight ??= computeTextSize(
|
||||
Text(
|
||||
"",
|
||||
"X",
|
||||
style: context.textTheme.bodySmall,
|
||||
),
|
||||
).height;
|
||||
@@ -48,7 +62,7 @@ class Measure {
|
||||
double get labelSmallHeight {
|
||||
_labelSmallHeight ??= computeTextSize(
|
||||
Text(
|
||||
"",
|
||||
"X",
|
||||
style: context.textTheme.labelSmall,
|
||||
),
|
||||
).height;
|
||||
@@ -58,7 +72,7 @@ class Measure {
|
||||
double get labelMediumHeight {
|
||||
_labelMediumHeight ??= computeTextSize(
|
||||
Text(
|
||||
"",
|
||||
"X",
|
||||
style: context.textTheme.labelMedium,
|
||||
),
|
||||
).height;
|
||||
@@ -68,7 +82,7 @@ class Measure {
|
||||
double get titleLargeHeight {
|
||||
_titleLargeHeight ??= computeTextSize(
|
||||
Text(
|
||||
"",
|
||||
"X",
|
||||
style: context.textTheme.titleLarge,
|
||||
),
|
||||
).height;
|
||||
@@ -78,7 +92,7 @@ class Measure {
|
||||
double get titleMediumHeight {
|
||||
_titleMediumHeight ??= computeTextSize(
|
||||
Text(
|
||||
"",
|
||||
"X",
|
||||
style: context.textTheme.titleMedium,
|
||||
),
|
||||
).height;
|
||||
|
||||
25
lib/common/network.dart
Normal file
25
lib/common/network.dart
Normal file
@@ -0,0 +1,25 @@
|
||||
import 'dart:io';
|
||||
|
||||
extension NetworkInterfaceExt on NetworkInterface {
|
||||
bool get isWifi {
|
||||
final nameLowCase = name.toLowerCase();
|
||||
if (nameLowCase.contains('wlan') ||
|
||||
nameLowCase.contains('wi-fi') ||
|
||||
nameLowCase == 'en0' ||
|
||||
nameLowCase == 'eth0') {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool get includesIPv4 {
|
||||
return addresses.any((addr) => addr.isIPv4);
|
||||
}
|
||||
}
|
||||
|
||||
extension InternetAddressExt on InternetAddress {
|
||||
bool get isIPv4 {
|
||||
return type == InternetAddressType.IPv4;
|
||||
}
|
||||
}
|
||||
@@ -171,14 +171,18 @@ class Other {
|
||||
if (disposition == null) return null;
|
||||
final parseValue = HeaderValue.parse(disposition);
|
||||
final parameters = parseValue.parameters;
|
||||
final key = parameters.keys
|
||||
.firstWhere((key) => key.startsWith("filename"), orElse: () => '');
|
||||
if (key.isEmpty) return null;
|
||||
if (key == "filename*") {
|
||||
return Uri.decodeComponent((parameters[key] ?? "").split("'").last);
|
||||
} else {
|
||||
return parameters[key];
|
||||
final fileNamePointKey = parameters.keys
|
||||
.firstWhere((key) => key == "filename*", orElse: () => "");
|
||||
if (fileNamePointKey.isNotEmpty) {
|
||||
final res = parameters[fileNamePointKey]?.split("''") ?? [];
|
||||
if (res.length >= 2) {
|
||||
return Uri.decodeComponent(res[1]);
|
||||
}
|
||||
}
|
||||
final fileNameKey = parameters.keys
|
||||
.firstWhere((key) => key == "filename", orElse: () => "");
|
||||
if (fileNameKey.isEmpty) return null;
|
||||
return parameters[fileNameKey];
|
||||
}
|
||||
|
||||
double getViewWidth() {
|
||||
@@ -220,6 +224,15 @@ class Other {
|
||||
String getBackupFileName() {
|
||||
return "${appName}_backup_${DateTime.now().show}.zip";
|
||||
}
|
||||
|
||||
String get logFile {
|
||||
return "${appName}_${DateTime.now().show}.log";
|
||||
}
|
||||
|
||||
Size getScreenSize() {
|
||||
final view = WidgetsBinding.instance.platformDispatcher.views.first;
|
||||
return view.physicalSize / view.devicePixelRatio;
|
||||
}
|
||||
}
|
||||
|
||||
final other = Other();
|
||||
|
||||
@@ -8,11 +8,12 @@ import 'constant.dart';
|
||||
|
||||
class AppPath {
|
||||
static AppPath? _instance;
|
||||
Completer<Directory> cacheDir = Completer();
|
||||
Completer<Directory> dataDir = Completer();
|
||||
Completer<Directory> downloadDir = Completer();
|
||||
Completer<Directory> tempDir = Completer();
|
||||
late String appDirPath;
|
||||
|
||||
// Future<Directory> _createDesktopCacheDir() async {
|
||||
// final path = join(dirname(Platform.resolvedExecutable), 'cache');
|
||||
// final dir = Directory(path);
|
||||
// if (await dir.exists()) {
|
||||
// await dir.create(recursive: true);
|
||||
@@ -21,8 +22,12 @@ class AppPath {
|
||||
// }
|
||||
|
||||
AppPath._internal() {
|
||||
appDirPath = join(dirname(Platform.resolvedExecutable));
|
||||
getApplicationSupportDirectory().then((value) {
|
||||
cacheDir.complete(value);
|
||||
dataDir.complete(value);
|
||||
});
|
||||
getTemporaryDirectory().then((value){
|
||||
tempDir.complete(value);
|
||||
});
|
||||
getDownloadsDirectory().then((value) {
|
||||
downloadDir.complete(value);
|
||||
@@ -49,12 +54,12 @@ class AppPath {
|
||||
}
|
||||
|
||||
Future<String> getHomeDirPath() async {
|
||||
final directory = await cacheDir.future;
|
||||
final directory = await dataDir.future;
|
||||
return directory.path;
|
||||
}
|
||||
|
||||
Future<String> getProfilesPath() async {
|
||||
final directory = await cacheDir.future;
|
||||
final directory = await dataDir.future;
|
||||
return join(directory.path, profilesDirectoryName);
|
||||
}
|
||||
|
||||
@@ -63,6 +68,11 @@ class AppPath {
|
||||
final directory = await getProfilesPath();
|
||||
return join(directory, "$id.yaml");
|
||||
}
|
||||
|
||||
Future<String> get tempPath async {
|
||||
final directory = await tempDir.future;
|
||||
return directory.path;
|
||||
}
|
||||
}
|
||||
|
||||
final appPath = AppPath();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import '../models/models.dart';
|
||||
@@ -28,7 +29,8 @@ class Preferences {
|
||||
try {
|
||||
return ClashConfig.fromJson(clashConfigMap);
|
||||
} catch (e) {
|
||||
throw e.toString();
|
||||
debugPrint(e.toString());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +50,8 @@ class Preferences {
|
||||
try {
|
||||
return Config.fromJson(configMap);
|
||||
} catch (e) {
|
||||
throw e.toString();
|
||||
debugPrint(e.toString());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'dart:math';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
@@ -77,7 +76,7 @@ class Request {
|
||||
};
|
||||
|
||||
Future<IpInfo?> checkIp({CancelToken? cancelToken}) async {
|
||||
for (final source in _ipInfoSources.entries.toList()..shuffle(Random())) {
|
||||
for (final source in _ipInfoSources.entries) {
|
||||
try {
|
||||
final response = await _dio
|
||||
.get<Map<String, dynamic>>(
|
||||
|
||||
@@ -25,3 +25,18 @@ class HiddenBarScrollBehavior extends BaseScrollBehavior {
|
||||
return child;
|
||||
}
|
||||
}
|
||||
|
||||
class ShowBarScrollBehavior extends BaseScrollBehavior {
|
||||
@override
|
||||
Widget buildScrollbar(
|
||||
BuildContext context,
|
||||
Widget child,
|
||||
ScrollableDetails details,
|
||||
) {
|
||||
return Scrollbar(
|
||||
interactive: true,
|
||||
controller: details.controller,
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
extension StringExtension on String {
|
||||
bool get isUrl {
|
||||
return RegExp(r'^(http|https|ftp)://').hasMatch(this);
|
||||
@@ -8,4 +13,38 @@ extension StringExtension on String {
|
||||
other.toLowerCase(),
|
||||
);
|
||||
}
|
||||
|
||||
List<int> get encodeUtf16LeWithBom {
|
||||
final byteData = ByteData(length * 2);
|
||||
final bom = [0xFF, 0xFE];
|
||||
for (int i = 0; i < length; i++) {
|
||||
int charCode = codeUnitAt(i);
|
||||
byteData.setUint16(i * 2, charCode, Endian.little);
|
||||
}
|
||||
return bom + byteData.buffer.asUint8List();
|
||||
}
|
||||
|
||||
Uint8List? get getBase64 {
|
||||
final regExp = RegExp(r'base64,(.*)');
|
||||
final match = regExp.firstMatch(this);
|
||||
final realValue = match?.group(1) ?? '';
|
||||
if (realValue.isEmpty) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return base64.decode(realValue);
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
bool get isRegex {
|
||||
try {
|
||||
RegExp(this);
|
||||
return true;
|
||||
} catch (e) {
|
||||
debugPrint(e.toString());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ import 'dart:io';
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
import 'package:fl_clash/plugins/app.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:window_manager/window_manager.dart';
|
||||
|
||||
import 'window.dart';
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import 'dart:ffi';
|
||||
import 'dart:io';
|
||||
import 'package:ffi/ffi.dart';
|
||||
import 'package:fl_clash/common/common.dart';
|
||||
import 'package:path/path.dart';
|
||||
|
||||
class Windows {
|
||||
static Windows? _instance;
|
||||
@@ -54,6 +56,62 @@ class Windows {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Future<bool> registerTask(String appName) async {
|
||||
final taskXml = '''
|
||||
<?xml version="1.0" encoding="UTF-16"?>
|
||||
<Task version="1.3" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
|
||||
<Principals>
|
||||
<Principal id="Author">
|
||||
<LogonType>InteractiveToken</LogonType>
|
||||
<RunLevel>HighestAvailable</RunLevel>
|
||||
</Principal>
|
||||
</Principals>
|
||||
<Triggers>
|
||||
<LogonTrigger/>
|
||||
</Triggers>
|
||||
<Settings>
|
||||
<MultipleInstancesPolicy>Parallel</MultipleInstancesPolicy>
|
||||
<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
|
||||
<StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>
|
||||
<AllowHardTerminate>false</AllowHardTerminate>
|
||||
<StartWhenAvailable>false</StartWhenAvailable>
|
||||
<RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
|
||||
<IdleSettings>
|
||||
<StopOnIdleEnd>false</StopOnIdleEnd>
|
||||
<RestartOnIdle>false</RestartOnIdle>
|
||||
</IdleSettings>
|
||||
<AllowStartOnDemand>true</AllowStartOnDemand>
|
||||
<Enabled>true</Enabled>
|
||||
<Hidden>false</Hidden>
|
||||
<RunOnlyIfIdle>false</RunOnlyIfIdle>
|
||||
<WakeToRun>false</WakeToRun>
|
||||
<ExecutionTimeLimit>PT72H</ExecutionTimeLimit>
|
||||
<Priority>7</Priority>
|
||||
</Settings>
|
||||
<Actions Context="Author">
|
||||
<Exec>
|
||||
<Command>"${Platform.resolvedExecutable}"</Command>
|
||||
</Exec>
|
||||
</Actions>
|
||||
</Task>''';
|
||||
final taskPath = join(await appPath.tempPath, "task.xml");
|
||||
await File(taskPath).create(recursive: true);
|
||||
await File(taskPath)
|
||||
.writeAsBytes(taskXml.encodeUtf16LeWithBom, flush: true);
|
||||
final commandLine = [
|
||||
'/Create',
|
||||
'/TN',
|
||||
appName,
|
||||
'/XML',
|
||||
"%s",
|
||||
'/F',
|
||||
].join(" ");
|
||||
return runas(
|
||||
'schtasks',
|
||||
commandLine.replaceFirst("%s", taskPath),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
final windows = Platform.isWindows ? Windows() : null;
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'dart:isolate';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:archive/archive.dart';
|
||||
import 'package:fl_clash/common/archive.dart';
|
||||
@@ -19,6 +20,7 @@ import 'common/common.dart';
|
||||
class AppController {
|
||||
final BuildContext context;
|
||||
late AppState appState;
|
||||
late AppFlowingState appFlowingState;
|
||||
late Config config;
|
||||
late ClashConfig clashConfig;
|
||||
late Function updateClashConfigDebounce;
|
||||
@@ -30,6 +32,7 @@ class AppController {
|
||||
appState = context.read<AppState>();
|
||||
config = context.read<Config>();
|
||||
clashConfig = context.read<ClashConfig>();
|
||||
appFlowingState = context.read<AppFlowingState>();
|
||||
updateClashConfigDebounce = debounce<Function()>(() async {
|
||||
await updateClashConfig();
|
||||
});
|
||||
@@ -56,13 +59,15 @@ class AppController {
|
||||
updateRunTime,
|
||||
updateTraffic,
|
||||
];
|
||||
applyProfileDebounce();
|
||||
if (!Platform.isAndroid) {
|
||||
applyProfileDebounce();
|
||||
}
|
||||
} else {
|
||||
await globalState.handleStop();
|
||||
clashCore.resetTraffic();
|
||||
appState.traffics = [];
|
||||
appState.totalTraffic = Traffic();
|
||||
appState.runTime = null;
|
||||
appFlowingState.traffics = [];
|
||||
appFlowingState.totalTraffic = Traffic();
|
||||
appFlowingState.runTime = null;
|
||||
addCheckIpNumDebounce();
|
||||
}
|
||||
}
|
||||
@@ -76,15 +81,15 @@ class AppController {
|
||||
if (startTime != null) {
|
||||
final startTimeStamp = startTime.millisecondsSinceEpoch;
|
||||
final nowTimeStamp = DateTime.now().millisecondsSinceEpoch;
|
||||
appState.runTime = nowTimeStamp - startTimeStamp;
|
||||
appFlowingState.runTime = nowTimeStamp - startTimeStamp;
|
||||
} else {
|
||||
appState.runTime = null;
|
||||
appFlowingState.runTime = null;
|
||||
}
|
||||
}
|
||||
|
||||
updateTraffic() {
|
||||
globalState.updateTraffic(
|
||||
appState: appState,
|
||||
appFlowingState: appFlowingState,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -116,11 +121,15 @@ class AppController {
|
||||
}
|
||||
|
||||
Future<void> updateClashConfig({bool isPatch = true}) async {
|
||||
await globalState.updateClashConfig(
|
||||
clashConfig: clashConfig,
|
||||
config: config,
|
||||
isPatch: isPatch,
|
||||
);
|
||||
final commonScaffoldState = globalState.homeScaffoldKey.currentState;
|
||||
if (commonScaffoldState?.mounted != true) return;
|
||||
await commonScaffoldState?.loadingRun(() async {
|
||||
await globalState.updateClashConfig(
|
||||
clashConfig: clashConfig,
|
||||
config: config,
|
||||
isPatch: isPatch,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Future applyProfile({bool isPrue = false}) async {
|
||||
@@ -163,7 +172,7 @@ class AppController {
|
||||
try {
|
||||
updateProfile(profile);
|
||||
} catch (e) {
|
||||
appState.addLog(
|
||||
appFlowingState.addLog(
|
||||
Log(
|
||||
logLevel: LogLevel.info,
|
||||
payload: e.toString(),
|
||||
@@ -218,7 +227,7 @@ class AppController {
|
||||
}
|
||||
|
||||
handleBackOrExit() async {
|
||||
if (config.isMinimizeOnExit) {
|
||||
if (config.appSetting.minimizeOnExit) {
|
||||
if (system.isDesktop) {
|
||||
await savePreferences();
|
||||
}
|
||||
@@ -237,16 +246,16 @@ class AppController {
|
||||
}
|
||||
|
||||
updateLogStatus() {
|
||||
if (config.openLogs) {
|
||||
if (config.appSetting.openLogs) {
|
||||
clashCore.startLog();
|
||||
} else {
|
||||
clashCore.stopLog();
|
||||
appState.logs = [];
|
||||
appFlowingState.logs = [];
|
||||
}
|
||||
}
|
||||
|
||||
autoCheckUpdate() async {
|
||||
if (!config.autoCheckUpdate) return;
|
||||
if (!config.appSetting.autoCheckUpdate) return;
|
||||
final res = await request.checkForUpdate();
|
||||
checkUpdateResultHandle(data: res);
|
||||
}
|
||||
@@ -297,10 +306,10 @@ class AppController {
|
||||
init() async {
|
||||
final isDisclaimerAccepted = await handlerDisclaimer();
|
||||
if (!isDisclaimerAccepted) {
|
||||
system.exit();
|
||||
handleExit();
|
||||
}
|
||||
updateLogStatus();
|
||||
if (!config.silentLaunch) {
|
||||
if (!config.appSetting.silentLaunch) {
|
||||
window?.show();
|
||||
}
|
||||
if (Platform.isAndroid) {
|
||||
@@ -309,7 +318,7 @@ class AppController {
|
||||
if (globalState.isStart) {
|
||||
await updateStatus(true);
|
||||
} else {
|
||||
await updateStatus(config.autoRun);
|
||||
await updateStatus(config.appSetting.autoRun);
|
||||
}
|
||||
autoUpdateProfiles();
|
||||
autoCheckUpdate();
|
||||
@@ -324,7 +333,7 @@ class AppController {
|
||||
return;
|
||||
}
|
||||
appState.currentLabel = appState.currentNavigationItems[index].label;
|
||||
if ((config.isAnimateToPage || hasAnimate)) {
|
||||
if ((config.appSetting.isAnimateToPage || hasAnimate)) {
|
||||
globalState.pageController?.animateToPage(
|
||||
index,
|
||||
duration: kTabScrollDuration,
|
||||
@@ -400,7 +409,9 @@ class AppController {
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
config.isDisclaimerAccepted = true;
|
||||
config.appSetting = config.appSetting.copyWith(
|
||||
disclaimerAccepted: true,
|
||||
);
|
||||
Navigator.of(context).pop<bool>(true);
|
||||
},
|
||||
child: Text(appLocalizations.agree),
|
||||
@@ -412,7 +423,7 @@ class AppController {
|
||||
}
|
||||
|
||||
Future<bool> handlerDisclaimer() async {
|
||||
if (config.isDisclaimerAccepted) {
|
||||
if (config.appSetting.disclaimerAccepted) {
|
||||
return true;
|
||||
}
|
||||
return showDisclaimer();
|
||||
@@ -504,7 +515,7 @@ class AppController {
|
||||
}
|
||||
|
||||
List<Proxy> getSortProxies(List<Proxy> proxies) {
|
||||
return switch (config.proxiesSortType) {
|
||||
return switch (config.proxiesStyle.sortType) {
|
||||
ProxiesSortType.none => proxies,
|
||||
ProxiesSortType.delay => _sortOfDelay(proxies),
|
||||
ProxiesSortType.name => _sortOfName(proxies),
|
||||
@@ -518,21 +529,6 @@ class AppController {
|
||||
'';
|
||||
}
|
||||
|
||||
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) ?? [];
|
||||
});
|
||||
}
|
||||
|
||||
updateTun() {
|
||||
clashConfig.tun = clashConfig.tun.copyWith(
|
||||
enable: !clashConfig.tun.enable,
|
||||
@@ -546,11 +542,19 @@ class AppController {
|
||||
}
|
||||
|
||||
updateStart() {
|
||||
updateStatus(!appState.isStart);
|
||||
updateStatus(!appFlowingState.isStart);
|
||||
}
|
||||
|
||||
updateAutoLaunch() {
|
||||
config.autoLaunch = !config.autoLaunch;
|
||||
config.appSetting = config.appSetting.copyWith(
|
||||
autoLaunch: !config.appSetting.autoLaunch,
|
||||
);
|
||||
}
|
||||
|
||||
updateAdminAutoLaunch() {
|
||||
config.appSetting = config.appSetting.copyWith(
|
||||
adminAutoLaunch: !config.appSetting.adminAutoLaunch,
|
||||
);
|
||||
}
|
||||
|
||||
updateVisible() async {
|
||||
@@ -571,6 +575,36 @@ class AppController {
|
||||
clashConfig.mode = Mode.values[nextIndex];
|
||||
}
|
||||
|
||||
Future<bool> exportLogs() async {
|
||||
final logsRaw = appFlowingState.logs.map(
|
||||
(item) => item.toString(),
|
||||
);
|
||||
final data = await Isolate.run<List<int>>(() async {
|
||||
final logsRawString = logsRaw.join("\n");
|
||||
return utf8.encode(logsRawString);
|
||||
});
|
||||
return await picker.saveFile(
|
||||
other.logFile,
|
||||
Uint8List.fromList(data),
|
||||
) !=
|
||||
null;
|
||||
}
|
||||
|
||||
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,
|
||||
|
||||
@@ -15,6 +15,10 @@ extension GroupTypeExtension on GroupType {
|
||||
)
|
||||
.toList();
|
||||
|
||||
bool get isURLTestOrFallback {
|
||||
return [GroupType.URLTest, GroupType.Fallback].contains(this);
|
||||
}
|
||||
|
||||
static GroupType? getGroupType(String value) {
|
||||
final index = GroupTypeExtension.valueList.indexOf(value);
|
||||
if (index == -1) return null;
|
||||
@@ -152,3 +156,9 @@ enum HotAction {
|
||||
proxy,
|
||||
tun,
|
||||
}
|
||||
|
||||
enum ProxiesIconStyle {
|
||||
standard,
|
||||
none,
|
||||
icon,
|
||||
}
|
||||
|
||||
@@ -8,6 +8,84 @@ import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class CloseConnectionsSwitch extends StatelessWidget {
|
||||
const CloseConnectionsSwitch({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Selector<Config, bool>(
|
||||
selector: (_, config) => config.appSetting.closeConnections,
|
||||
builder: (_, closeConnections, __) {
|
||||
return ListItem.switchItem(
|
||||
title: Text(appLocalizations.autoCloseConnections),
|
||||
subtitle: Text(appLocalizations.autoCloseConnectionsDesc),
|
||||
delegate: SwitchDelegate(
|
||||
value: closeConnections,
|
||||
onChanged: (value) async {
|
||||
final config = globalState.appController.config;
|
||||
config.appSetting = config.appSetting.copyWith(
|
||||
closeConnections: value,
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class UsageSwitch extends StatelessWidget {
|
||||
const UsageSwitch({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Selector<Config, bool>(
|
||||
selector: (_, config) => config.appSetting.onlyProxy,
|
||||
builder: (_, onlyProxy, __) {
|
||||
return ListItem.switchItem(
|
||||
title: Text(appLocalizations.onlyStatisticsProxy),
|
||||
subtitle: Text(appLocalizations.onlyStatisticsProxyDesc),
|
||||
delegate: SwitchDelegate(
|
||||
value: onlyProxy,
|
||||
onChanged: (bool value) async {
|
||||
final config = globalState.appController.config;
|
||||
config.appSetting = config.appSetting.copyWith(
|
||||
onlyProxy: value,
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class AdminAutoLaunchItem extends StatelessWidget {
|
||||
const AdminAutoLaunchItem({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Selector<Config, bool>(
|
||||
selector: (_, config) => config.appSetting.adminAutoLaunch,
|
||||
builder: (_, adminAutoLaunch, __) {
|
||||
return ListItem.switchItem(
|
||||
title: Text(appLocalizations.adminAutoLaunch),
|
||||
subtitle: Text(appLocalizations.adminAutoLaunchDesc),
|
||||
delegate: SwitchDelegate(
|
||||
value: adminAutoLaunch,
|
||||
onChanged: (bool value) async {
|
||||
final config = globalState.appController.config;
|
||||
config.appSetting = config.appSetting.copyWith(
|
||||
adminAutoLaunch: value,
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ApplicationSettingFragment extends StatelessWidget {
|
||||
const ApplicationSettingFragment({super.key});
|
||||
|
||||
@@ -20,17 +98,18 @@ class ApplicationSettingFragment extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
List<Widget> items = [
|
||||
Selector<Config, bool>(
|
||||
selector: (_, config) => config.isMinimizeOnExit,
|
||||
selector: (_, config) => config.appSetting.minimizeOnExit,
|
||||
builder: (_, isMinimizeOnExit, child) {
|
||||
return ListItem.switchItem(
|
||||
leading: const Icon(Icons.back_hand),
|
||||
title: Text(appLocalizations.minimizeOnExit),
|
||||
subtitle: Text(appLocalizations.minimizeOnExitDesc),
|
||||
delegate: SwitchDelegate(
|
||||
value: isMinimizeOnExit,
|
||||
onChanged: (bool value) {
|
||||
final config = context.read<Config>();
|
||||
config.isMinimizeOnExit = value;
|
||||
config.appSetting = config.appSetting.copyWith(
|
||||
minimizeOnExit: value,
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
@@ -38,52 +117,57 @@ class ApplicationSettingFragment extends StatelessWidget {
|
||||
),
|
||||
if (system.isDesktop)
|
||||
Selector<Config, bool>(
|
||||
selector: (_, config) => config.autoLaunch,
|
||||
selector: (_, config) => config.appSetting.autoLaunch,
|
||||
builder: (_, autoLaunch, child) {
|
||||
return ListItem.switchItem(
|
||||
leading: const Icon(Icons.rocket_launch),
|
||||
title: Text(appLocalizations.autoLaunch),
|
||||
subtitle: Text(appLocalizations.autoLaunchDesc),
|
||||
delegate: SwitchDelegate(
|
||||
value: autoLaunch,
|
||||
onChanged: (bool value) {
|
||||
final config = context.read<Config>();
|
||||
config.autoLaunch = value;
|
||||
final config = globalState.appController.config;
|
||||
config.appSetting = config.appSetting.copyWith(
|
||||
autoLaunch: value,
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
if(Platform.isWindows)
|
||||
const AdminAutoLaunchItem(),
|
||||
if (system.isDesktop)
|
||||
Selector<Config, bool>(
|
||||
selector: (_, config) => config.silentLaunch,
|
||||
selector: (_, config) => config.appSetting.silentLaunch,
|
||||
builder: (_, silentLaunch, child) {
|
||||
return ListItem.switchItem(
|
||||
leading: const Icon(Icons.expand_circle_down),
|
||||
title: Text(appLocalizations.silentLaunch),
|
||||
subtitle: Text(appLocalizations.silentLaunchDesc),
|
||||
delegate: SwitchDelegate(
|
||||
value: silentLaunch,
|
||||
onChanged: (bool value) {
|
||||
final config = context.read<Config>();
|
||||
config.silentLaunch = value;
|
||||
final config = globalState.appController.config;
|
||||
config.appSetting = config.appSetting.copyWith(
|
||||
silentLaunch: value,
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
Selector<Config, bool>(
|
||||
selector: (_, config) => config.autoRun,
|
||||
selector: (_, config) => config.appSetting.autoRun,
|
||||
builder: (_, autoRun, child) {
|
||||
return ListItem.switchItem(
|
||||
leading: const Icon(Icons.not_started),
|
||||
title: Text(appLocalizations.autoRun),
|
||||
subtitle: Text(appLocalizations.autoRunDesc),
|
||||
delegate: SwitchDelegate(
|
||||
value: autoRun,
|
||||
onChanged: (bool value) {
|
||||
final config = context.read<Config>();
|
||||
config.autoRun = value;
|
||||
final config = globalState.appController.config;
|
||||
config.appSetting = config.appSetting.copyWith(
|
||||
autoRun: value,
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
@@ -91,17 +175,18 @@ class ApplicationSettingFragment extends StatelessWidget {
|
||||
),
|
||||
if (Platform.isAndroid)
|
||||
Selector<Config, bool>(
|
||||
selector: (_, config) => config.isExclude,
|
||||
selector: (_, config) => config.appSetting.hidden,
|
||||
builder: (_, isExclude, child) {
|
||||
return ListItem.switchItem(
|
||||
leading: const Icon(Icons.visibility_off),
|
||||
title: Text(appLocalizations.exclude),
|
||||
subtitle: Text(appLocalizations.excludeDesc),
|
||||
delegate: SwitchDelegate(
|
||||
value: isExclude,
|
||||
onChanged: (value) {
|
||||
final config = context.read<Config>();
|
||||
config.isExclude = value;
|
||||
final config = globalState.appController.config;
|
||||
config.appSetting = config.appSetting.copyWith(
|
||||
hidden: value,
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
@@ -109,52 +194,56 @@ class ApplicationSettingFragment extends StatelessWidget {
|
||||
),
|
||||
if (Platform.isAndroid)
|
||||
Selector<Config, bool>(
|
||||
selector: (_, config) => config.isAnimateToPage,
|
||||
selector: (_, config) => config.appSetting.isAnimateToPage,
|
||||
builder: (_, isAnimateToPage, child) {
|
||||
return ListItem.switchItem(
|
||||
leading: const Icon(Icons.animation),
|
||||
title: Text(appLocalizations.tabAnimation),
|
||||
subtitle: Text(appLocalizations.tabAnimationDesc),
|
||||
delegate: SwitchDelegate(
|
||||
value: isAnimateToPage,
|
||||
onChanged: (value) {
|
||||
final config = context.read<Config>();
|
||||
config.isAnimateToPage = value;
|
||||
final config = globalState.appController.config;
|
||||
config.appSetting = config.appSetting.copyWith(
|
||||
isAnimateToPage: value,
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
Selector<Config, bool>(
|
||||
selector: (_, config) => config.openLogs,
|
||||
selector: (_, config) => config.appSetting.openLogs,
|
||||
builder: (_, openLogs, child) {
|
||||
return ListItem.switchItem(
|
||||
leading: const Icon(Icons.bug_report),
|
||||
title: Text(appLocalizations.logcat),
|
||||
subtitle: Text(appLocalizations.logcatDesc),
|
||||
delegate: SwitchDelegate(
|
||||
value: openLogs,
|
||||
onChanged: (bool value) {
|
||||
final config = context.read<Config>();
|
||||
config.openLogs = value;
|
||||
globalState.appController.updateLogStatus();
|
||||
final config = globalState.appController.config;
|
||||
config.appSetting = config.appSetting.copyWith(
|
||||
openLogs: value,
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
const CloseConnectionsSwitch(),
|
||||
const UsageSwitch(),
|
||||
Selector<Config, bool>(
|
||||
selector: (_, config) => config.autoCheckUpdate,
|
||||
selector: (_, config) => config.appSetting.autoCheckUpdate,
|
||||
builder: (_, autoCheckUpdate, child) {
|
||||
return ListItem.switchItem(
|
||||
leading: const Icon(Icons.system_update),
|
||||
title: Text(appLocalizations.autoCheckUpdate),
|
||||
subtitle: Text(appLocalizations.autoCheckUpdateDesc),
|
||||
delegate: SwitchDelegate(
|
||||
value: autoCheckUpdate,
|
||||
onChanged: (bool value) {
|
||||
final config = context.read<Config>();
|
||||
config.autoCheckUpdate = value;
|
||||
final config = globalState.appController.config;
|
||||
config.appSetting = config.appSetting.copyWith(
|
||||
autoCheckUpdate: value,
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:fl_clash/common/common.dart';
|
||||
import 'package:fl_clash/models/config.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 CloseConnectionsSwitch extends StatelessWidget {
|
||||
const CloseConnectionsSwitch({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Selector<Config, bool>(
|
||||
selector: (_, config) => config.isCloseConnections,
|
||||
builder: (_, isCloseConnections, __) {
|
||||
return ListItem.switchItem(
|
||||
leading: const Icon(Icons.auto_delete_outlined),
|
||||
title: Text(appLocalizations.autoCloseConnections),
|
||||
subtitle: Text(appLocalizations.autoCloseConnectionsDesc),
|
||||
delegate: SwitchDelegate(
|
||||
value: isCloseConnections,
|
||||
onChanged: (bool value) async {
|
||||
final appController = globalState.appController;
|
||||
appController.config.isCloseConnections = value;
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class UsageSwitch extends StatelessWidget {
|
||||
const UsageSwitch({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Selector<Config, bool>(
|
||||
selector: (_, config) => config.onlyProxy,
|
||||
builder: (_, onlyProxy, __) {
|
||||
return ListItem.switchItem(
|
||||
leading: const Icon(Icons.data_usage_outlined),
|
||||
title: Text(appLocalizations.onlyStatisticsProxy),
|
||||
subtitle: Text(appLocalizations.onlyStatisticsProxyDesc),
|
||||
delegate: SwitchDelegate(
|
||||
value: onlyProxy,
|
||||
onChanged: (bool value) async {
|
||||
final appController = globalState.appController;
|
||||
appController.config.onlyProxy = value;
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
final appItems = [
|
||||
const CloseConnectionsSwitch(),
|
||||
const UsageSwitch(),
|
||||
];
|
||||
@@ -1,10 +1,7 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:fl_clash/common/common.dart';
|
||||
import 'package:fl_clash/fragments/config/app.dart';
|
||||
import 'package:fl_clash/fragments/config/dns.dart';
|
||||
import 'package:fl_clash/fragments/config/general.dart';
|
||||
import 'package:fl_clash/fragments/config/vpn.dart';
|
||||
import 'package:fl_clash/fragments/config/network.dart';
|
||||
import 'package:fl_clash/widgets/widgets.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@@ -20,36 +17,16 @@ class _ConfigFragmentState extends State<ConfigFragment> {
|
||||
Widget build(BuildContext context) {
|
||||
List<Widget> items = [
|
||||
ListItem.open(
|
||||
title: Text(appLocalizations.app),
|
||||
subtitle: Text(appLocalizations.appDesc),
|
||||
leading: const Icon(Icons.settings_applications),
|
||||
title: Text(appLocalizations.network),
|
||||
subtitle: Text(appLocalizations.networkDesc),
|
||||
leading: const Icon(Icons.vpn_key),
|
||||
delegate: OpenDelegate(
|
||||
title: appLocalizations.app,
|
||||
title: appLocalizations.network,
|
||||
isScaffold: true,
|
||||
isBlur: false,
|
||||
widget: generateListView(
|
||||
appItems
|
||||
.separated(
|
||||
const Divider(
|
||||
height: 0,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
widget: const NetworkListView(),
|
||||
),
|
||||
),
|
||||
if (Platform.isAndroid)
|
||||
ListItem.open(
|
||||
title: const Text("VPN"),
|
||||
subtitle: Text(appLocalizations.vpnDesc),
|
||||
leading: const Icon(Icons.vpn_key),
|
||||
delegate: OpenDelegate(
|
||||
title: "VPN",
|
||||
isBlur: false,
|
||||
widget: generateListView(
|
||||
vpnItems,
|
||||
),
|
||||
),
|
||||
),
|
||||
ListItem.open(
|
||||
title: Text(appLocalizations.general),
|
||||
subtitle: Text(appLocalizations.generalDesc),
|
||||
@@ -67,11 +44,9 @@ class _ConfigFragmentState extends State<ConfigFragment> {
|
||||
title: const Text("DNS"),
|
||||
subtitle: Text(appLocalizations.dnsDesc),
|
||||
leading: const Icon(Icons.dns),
|
||||
delegate: OpenDelegate(
|
||||
delegate: const OpenDelegate(
|
||||
title: "DNS",
|
||||
widget: generateListView(
|
||||
dnsItems,
|
||||
),
|
||||
widget: DnsListView(),
|
||||
isScaffold: true,
|
||||
isBlur: false,
|
||||
extendPageWidth: 360,
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:fl_clash/common/app_localizations.dart';
|
||||
import 'package:fl_clash/common/common.dart';
|
||||
import 'package:fl_clash/enum/enum.dart';
|
||||
import 'package:fl_clash/models/models.dart';
|
||||
@@ -11,27 +10,8 @@ import 'package:provider/provider.dart';
|
||||
class OverrideItem extends StatelessWidget {
|
||||
const OverrideItem({super.key});
|
||||
|
||||
_initActions(BuildContext context) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
||||
final commonScaffoldState =
|
||||
context.findAncestorStateOfType<CommonScaffoldState>();
|
||||
commonScaffoldState?.actions = [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
globalState.appController.clashConfig.dns = const Dns();
|
||||
},
|
||||
tooltip: appLocalizations.resetDns,
|
||||
icon: const Icon(
|
||||
Icons.replay,
|
||||
),
|
||||
)
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
_initActions(context);
|
||||
return Selector<Config, bool>(
|
||||
selector: (_, config) => config.overrideDns,
|
||||
builder: (_, override, __) {
|
||||
@@ -51,35 +31,6 @@ class OverrideItem extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
class DnsDisabledContainer extends StatelessWidget {
|
||||
final Widget child;
|
||||
|
||||
const DnsDisabledContainer(
|
||||
this.child, {
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Selector<Config, bool>(
|
||||
selector: (_, config) => config.overrideDns,
|
||||
builder: (_, enable, child) {
|
||||
return AbsorbPointer(
|
||||
absorbing: !enable,
|
||||
child: DisabledMask(
|
||||
status: !enable,
|
||||
child: Container(
|
||||
color: context.colorScheme.surface,
|
||||
child: child!,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class StatusItem extends StatelessWidget {
|
||||
const StatusItem({super.key});
|
||||
|
||||
@@ -268,26 +219,17 @@ class FakeIpFilterItem extends StatelessWidget {
|
||||
title: appLocalizations.fakeipFilter,
|
||||
widget: Selector<ClashConfig, List<String>>(
|
||||
selector: (_, clashConfig) => clashConfig.dns.fakeIpFilter,
|
||||
shouldRebuild: (prev, next) =>
|
||||
!const ListEquality<String>().equals(prev, next),
|
||||
shouldRebuild: (prev, next) => !stringListEquality.equals(prev, next),
|
||||
builder: (_, fakeIpFilter, __) {
|
||||
return UpdatePage(
|
||||
return ListPage(
|
||||
title: appLocalizations.fakeipFilter,
|
||||
items: fakeIpFilter,
|
||||
titleBuilder: (item) => Text(item),
|
||||
onRemove: (value) {
|
||||
onChange: (items){
|
||||
final clashConfig = globalState.appController.clashConfig;
|
||||
final dns = clashConfig.dns;
|
||||
clashConfig.dns = dns.copyWith(
|
||||
fakeIpFilter: List.from(dns.fakeIpFilter)..remove(value),
|
||||
);
|
||||
},
|
||||
onAdd: (value) {
|
||||
final clashConfig = globalState.appController.clashConfig;
|
||||
final dns = clashConfig.dns;
|
||||
if (fakeIpFilter.contains(value)) return;
|
||||
clashConfig.dns = dns.copyWith(
|
||||
fakeIpFilter: List.from(dns.fakeIpFilter)..add(value),
|
||||
fakeIpFilter: List.from(items),
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -312,28 +254,17 @@ class DefaultNameserverItem extends StatelessWidget {
|
||||
title: appLocalizations.defaultNameserver,
|
||||
widget: Selector<ClashConfig, List<String>>(
|
||||
selector: (_, clashConfig) => clashConfig.dns.defaultNameserver,
|
||||
shouldRebuild: (prev, next) =>
|
||||
!const ListEquality<String>().equals(prev, next),
|
||||
shouldRebuild: (prev, next) => !stringListEquality.equals(prev, next),
|
||||
builder: (_, defaultNameserver, __) {
|
||||
return UpdatePage(
|
||||
return ListPage(
|
||||
title: appLocalizations.defaultNameserver,
|
||||
items: defaultNameserver,
|
||||
titleBuilder: (item) => Text(item),
|
||||
onRemove: (value) {
|
||||
onChange: (items){
|
||||
final clashConfig = globalState.appController.clashConfig;
|
||||
final dns = clashConfig.dns;
|
||||
clashConfig.dns = dns.copyWith(
|
||||
defaultNameserver: List.from(dns.defaultNameserver)
|
||||
..remove(value),
|
||||
);
|
||||
},
|
||||
onAdd: (value) {
|
||||
final clashConfig = globalState.appController.clashConfig;
|
||||
final dns = clashConfig.dns;
|
||||
if (defaultNameserver.contains(value)) return;
|
||||
clashConfig.dns = dns.copyWith(
|
||||
defaultNameserver: List.from(dns.defaultNameserver)
|
||||
..add(value),
|
||||
defaultNameserver: List.from(items),
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -358,26 +289,17 @@ class NameserverItem extends StatelessWidget {
|
||||
isBlur: false,
|
||||
widget: Selector<ClashConfig, List<String>>(
|
||||
selector: (_, clashConfig) => clashConfig.dns.nameserver,
|
||||
shouldRebuild: (prev, next) =>
|
||||
!const ListEquality<String>().equals(prev, next),
|
||||
shouldRebuild: (prev, next) => !stringListEquality.equals(prev, next),
|
||||
builder: (_, nameserver, __) {
|
||||
return UpdatePage(
|
||||
return ListPage(
|
||||
title: "域名服务器",
|
||||
items: nameserver,
|
||||
titleBuilder: (item) => Text(item),
|
||||
onRemove: (value) {
|
||||
onChange: (items){
|
||||
final clashConfig = globalState.appController.clashConfig;
|
||||
final dns = clashConfig.dns;
|
||||
clashConfig.dns = dns.copyWith(
|
||||
nameserver: List.from(dns.nameserver)..remove(value),
|
||||
);
|
||||
},
|
||||
onAdd: (value) {
|
||||
final clashConfig = globalState.appController.clashConfig;
|
||||
final dns = clashConfig.dns;
|
||||
if (nameserver.contains(value)) return;
|
||||
clashConfig.dns = dns.copyWith(
|
||||
nameserver: List.from(dns.nameserver)..add(value),
|
||||
nameserver: List.from(items),
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -457,26 +379,16 @@ class NameserverPolicyItem extends StatelessWidget {
|
||||
shouldRebuild: (prev, next) =>
|
||||
!const MapEquality<String, String>().equals(prev, next),
|
||||
builder: (_, nameserverPolicy, __) {
|
||||
return UpdatePage(
|
||||
return ListPage(
|
||||
title: appLocalizations.nameserverPolicy,
|
||||
items: nameserverPolicy.entries,
|
||||
titleBuilder: (item) => Text(item.key),
|
||||
subtitleBuilder: (item) => Text(item.value),
|
||||
isMap: true,
|
||||
onRemove: (value) {
|
||||
onChange: (items){
|
||||
final clashConfig = globalState.appController.clashConfig;
|
||||
final dns = clashConfig.dns;
|
||||
clashConfig.dns = dns.copyWith(
|
||||
nameserverPolicy: Map.from(dns.nameserverPolicy)
|
||||
..remove(value.key),
|
||||
);
|
||||
},
|
||||
onAdd: (value) {
|
||||
final clashConfig = globalState.appController.clashConfig;
|
||||
final dns = clashConfig.dns;
|
||||
clashConfig.dns = dns.copyWith(
|
||||
nameserverPolicy: Map.from(dns.nameserverPolicy)
|
||||
..addEntries([value]),
|
||||
nameserverPolicy: Map.fromEntries(items),
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -501,28 +413,17 @@ class ProxyServerNameserverItem extends StatelessWidget {
|
||||
title: appLocalizations.proxyNameserver,
|
||||
widget: Selector<ClashConfig, List<String>>(
|
||||
selector: (_, clashConfig) => clashConfig.dns.proxyServerNameserver,
|
||||
shouldRebuild: (prev, next) =>
|
||||
!const ListEquality<String>().equals(prev, next),
|
||||
shouldRebuild: (prev, next) => !stringListEquality.equals(prev, next),
|
||||
builder: (_, proxyServerNameserver, __) {
|
||||
return UpdatePage(
|
||||
return ListPage(
|
||||
title: appLocalizations.proxyNameserver,
|
||||
items: proxyServerNameserver,
|
||||
titleBuilder: (item) => Text(item),
|
||||
onRemove: (value) {
|
||||
onChange: (items){
|
||||
final clashConfig = globalState.appController.clashConfig;
|
||||
final dns = clashConfig.dns;
|
||||
clashConfig.dns = dns.copyWith(
|
||||
proxyServerNameserver: List.from(dns.proxyServerNameserver)
|
||||
..remove(value),
|
||||
);
|
||||
},
|
||||
onAdd: (value) {
|
||||
final clashConfig = globalState.appController.clashConfig;
|
||||
final dns = clashConfig.dns;
|
||||
if (proxyServerNameserver.contains(value)) return;
|
||||
clashConfig.dns = dns.copyWith(
|
||||
proxyServerNameserver: List.from(dns.proxyServerNameserver)
|
||||
..add(value),
|
||||
proxyServerNameserver: List.from(items),
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -547,26 +448,17 @@ class FallbackItem extends StatelessWidget {
|
||||
title: appLocalizations.fallback,
|
||||
widget: Selector<ClashConfig, List<String>>(
|
||||
selector: (_, clashConfig) => clashConfig.dns.fallback,
|
||||
shouldRebuild: (prev, next) =>
|
||||
!const ListEquality<String>().equals(prev, next),
|
||||
shouldRebuild: (prev, next) => !stringListEquality.equals(prev, next),
|
||||
builder: (_, fallback, __) {
|
||||
return UpdatePage(
|
||||
return ListPage(
|
||||
title: appLocalizations.fallback,
|
||||
items: fallback,
|
||||
titleBuilder: (item) => Text(item),
|
||||
onRemove: (value) {
|
||||
onChange: (items){
|
||||
final clashConfig = globalState.appController.clashConfig;
|
||||
final dns = clashConfig.dns;
|
||||
clashConfig.dns = dns.copyWith(
|
||||
fallback: List.from(dns.fallback)..remove(value),
|
||||
);
|
||||
},
|
||||
onAdd: (value) {
|
||||
final clashConfig = globalState.appController.clashConfig;
|
||||
final dns = clashConfig.dns;
|
||||
if (fallback.contains(value)) return;
|
||||
clashConfig.dns = dns.copyWith(
|
||||
fallback: List.from(dns.fallback)..add(value),
|
||||
fallback: List.from(items),
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -657,28 +549,18 @@ class GeositeItem extends StatelessWidget {
|
||||
title: "Geosite",
|
||||
widget: Selector<ClashConfig, List<String>>(
|
||||
selector: (_, clashConfig) => clashConfig.dns.fallbackFilter.geosite,
|
||||
shouldRebuild: (prev, next) =>
|
||||
!const ListEquality<String>().equals(prev, next),
|
||||
shouldRebuild: (prev, next) => !stringListEquality.equals(prev, next),
|
||||
builder: (_, geosite, __) {
|
||||
return UpdatePage(
|
||||
return ListPage(
|
||||
title: "Geosite",
|
||||
items: geosite,
|
||||
titleBuilder: (item) => Text(item),
|
||||
onRemove: (value) {
|
||||
onChange: (items){
|
||||
final clashConfig = globalState.appController.clashConfig;
|
||||
final dns = clashConfig.dns;
|
||||
clashConfig.dns = dns.copyWith(
|
||||
fallbackFilter: dns.fallbackFilter.copyWith(
|
||||
geosite: List.from(geosite)..remove(value),
|
||||
),
|
||||
);
|
||||
},
|
||||
onAdd: (value) {
|
||||
final clashConfig = globalState.appController.clashConfig;
|
||||
final dns = clashConfig.dns;
|
||||
clashConfig.dns = dns.copyWith(
|
||||
fallbackFilter: dns.fallbackFilter.copyWith(
|
||||
geosite: List.from(geosite)..add(value),
|
||||
geosite: List.from(items),
|
||||
),
|
||||
);
|
||||
},
|
||||
@@ -703,28 +585,18 @@ class IpcidrItem extends StatelessWidget {
|
||||
title: appLocalizations.ipcidr,
|
||||
widget: Selector<ClashConfig, List<String>>(
|
||||
selector: (_, clashConfig) => clashConfig.dns.fallbackFilter.ipcidr,
|
||||
shouldRebuild: (prev, next) =>
|
||||
!const ListEquality<String>().equals(prev, next),
|
||||
shouldRebuild: (prev, next) => !stringListEquality.equals(prev, next),
|
||||
builder: (_, ipcidr, __) {
|
||||
return UpdatePage(
|
||||
return ListPage(
|
||||
title: appLocalizations.ipcidr,
|
||||
items: ipcidr,
|
||||
titleBuilder: (item) => Text(item),
|
||||
onRemove: (value) {
|
||||
onChange: (items){
|
||||
final clashConfig = globalState.appController.clashConfig;
|
||||
final dns = clashConfig.dns;
|
||||
clashConfig.dns = dns.copyWith(
|
||||
fallbackFilter: dns.fallbackFilter.copyWith(
|
||||
ipcidr: List.from(ipcidr)..remove(value),
|
||||
),
|
||||
);
|
||||
},
|
||||
onAdd: (value) {
|
||||
final clashConfig = globalState.appController.clashConfig;
|
||||
final dns = clashConfig.dns;
|
||||
clashConfig.dns = dns.copyWith(
|
||||
fallbackFilter: dns.fallbackFilter.copyWith(
|
||||
ipcidr: List.from(ipcidr)..add(value),
|
||||
ipcidr: List.from(items),
|
||||
),
|
||||
);
|
||||
},
|
||||
@@ -749,28 +621,18 @@ class DomainItem extends StatelessWidget {
|
||||
title: appLocalizations.domain,
|
||||
widget: Selector<ClashConfig, List<String>>(
|
||||
selector: (_, clashConfig) => clashConfig.dns.fallbackFilter.domain,
|
||||
shouldRebuild: (prev, next) =>
|
||||
!const ListEquality<String>().equals(prev, next),
|
||||
shouldRebuild: (prev, next) => !stringListEquality.equals(prev, next),
|
||||
builder: (_, domain, __) {
|
||||
return UpdatePage(
|
||||
return ListPage(
|
||||
title: appLocalizations.domain,
|
||||
items: domain,
|
||||
titleBuilder: (item) => Text(item),
|
||||
onRemove: (value) {
|
||||
onChange: (items){
|
||||
final clashConfig = globalState.appController.clashConfig;
|
||||
final dns = clashConfig.dns;
|
||||
clashConfig.dns = dns.copyWith(
|
||||
fallbackFilter: dns.fallbackFilter.copyWith(
|
||||
domain: List.from(domain)..remove(value),
|
||||
),
|
||||
);
|
||||
},
|
||||
onAdd: (value) {
|
||||
final clashConfig = globalState.appController.clashConfig;
|
||||
final dns = clashConfig.dns;
|
||||
clashConfig.dns = dns.copyWith(
|
||||
fallbackFilter: dns.fallbackFilter.copyWith(
|
||||
domain: List.from(domain)..add(value),
|
||||
domain: List.from(items),
|
||||
),
|
||||
);
|
||||
},
|
||||
@@ -788,27 +650,25 @@ class DnsOptions extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return DnsDisabledContainer(
|
||||
Column(
|
||||
children: generateSection(
|
||||
title: appLocalizations.options,
|
||||
items: [
|
||||
const StatusItem(),
|
||||
const UseHostsItem(),
|
||||
const UseSystemHostsItem(),
|
||||
const IPv6Item(),
|
||||
const RespectRulesItem(),
|
||||
const PreferH3Item(),
|
||||
const DnsModeItem(),
|
||||
const FakeIpRangeItem(),
|
||||
const FakeIpFilterItem(),
|
||||
const DefaultNameserverItem(),
|
||||
const NameserverPolicyItem(),
|
||||
const NameserverItem(),
|
||||
const FallbackItem(),
|
||||
const ProxyServerNameserverItem(),
|
||||
],
|
||||
),
|
||||
return Column(
|
||||
children: generateSection(
|
||||
title: appLocalizations.options,
|
||||
items: [
|
||||
const StatusItem(),
|
||||
const UseHostsItem(),
|
||||
const UseSystemHostsItem(),
|
||||
const IPv6Item(),
|
||||
const RespectRulesItem(),
|
||||
const PreferH3Item(),
|
||||
const DnsModeItem(),
|
||||
const FakeIpRangeItem(),
|
||||
const FakeIpFilterItem(),
|
||||
const DefaultNameserverItem(),
|
||||
const NameserverPolicyItem(),
|
||||
const NameserverItem(),
|
||||
const FallbackItem(),
|
||||
const ProxyServerNameserverItem(),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -819,18 +679,16 @@ class FallbackFilterOptions extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return DnsDisabledContainer(
|
||||
Column(
|
||||
children: generateSection(
|
||||
title: appLocalizations.fallbackFilter,
|
||||
items: [
|
||||
const GeoipItem(),
|
||||
const GeoipCodeItem(),
|
||||
const GeositeItem(),
|
||||
const IpcidrItem(),
|
||||
const DomainItem(),
|
||||
],
|
||||
),
|
||||
return Column(
|
||||
children: generateSection(
|
||||
title: appLocalizations.fallbackFilter,
|
||||
items: [
|
||||
const GeoipItem(),
|
||||
const GeoipCodeItem(),
|
||||
const GeositeItem(),
|
||||
const IpcidrItem(),
|
||||
const DomainItem(),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -841,3 +699,41 @@ const dnsItems = <Widget>[
|
||||
DnsOptions(),
|
||||
FallbackFilterOptions(),
|
||||
];
|
||||
|
||||
class DnsListView extends StatelessWidget {
|
||||
const DnsListView({super.key});
|
||||
|
||||
_initActions(BuildContext context) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
||||
final commonScaffoldState =
|
||||
context.findAncestorStateOfType<CommonScaffoldState>();
|
||||
commonScaffoldState?.actions = [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
globalState.showMessage(
|
||||
title: appLocalizations.reset,
|
||||
message: TextSpan(
|
||||
text: appLocalizations.resetTip,
|
||||
),
|
||||
onTab: () {
|
||||
globalState.appController.clashConfig.dns = defaultDns;
|
||||
Navigator.of(context).pop();
|
||||
});
|
||||
},
|
||||
tooltip: appLocalizations.reset,
|
||||
icon: const Icon(
|
||||
Icons.replay,
|
||||
),
|
||||
)
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
_initActions(context);
|
||||
return generateListView(
|
||||
dnsItems,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ class TestUrlItem extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Selector<Config, String>(
|
||||
selector: (_, config) => config.testUrl,
|
||||
selector: (_, config) => config.appSetting.testUrl,
|
||||
builder: (_, value, __) {
|
||||
return ListItem.input(
|
||||
leading: const Icon(Icons.timeline),
|
||||
@@ -135,7 +135,10 @@ class TestUrlItem extends StatelessWidget {
|
||||
if (!value.isUrl) {
|
||||
throw "Invalid url";
|
||||
}
|
||||
globalState.appController.config.testUrl = value;
|
||||
final config = globalState.appController.config;
|
||||
config.appSetting = config.appSetting.copyWith(
|
||||
testUrl: value,
|
||||
);
|
||||
} catch (e) {
|
||||
globalState.showMessage(
|
||||
title: appLocalizations.testUrl,
|
||||
@@ -212,21 +215,15 @@ class HostsItem extends StatelessWidget {
|
||||
!const MapEquality<String, String>().equals(prev, next),
|
||||
builder: (_, hosts, ___) {
|
||||
final entries = hosts.entries;
|
||||
return UpdatePage(
|
||||
return ListPage(
|
||||
title: "Hosts",
|
||||
items: entries,
|
||||
titleBuilder: (item) => Text(item.key),
|
||||
subtitleBuilder: (item) => Text(item.value),
|
||||
onRemove: (value) {
|
||||
onChange: (items){
|
||||
final clashConfig = globalState.appController.clashConfig;
|
||||
clashConfig.hosts = Map.from(hosts)..remove(value.key);
|
||||
clashConfig.hosts = Map.fromEntries(items);
|
||||
},
|
||||
onAdd: (value) {
|
||||
final clashConfig = globalState.appController.clashConfig;
|
||||
clashConfig.hosts = Map.from(clashConfig.hosts)
|
||||
..addEntries([value]);
|
||||
},
|
||||
isMap: true,
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
270
lib/fragments/config/network.dart
Normal file
270
lib/fragments/config/network.dart
Normal file
@@ -0,0 +1,270 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:fl_clash/common/common.dart';
|
||||
import 'package:fl_clash/enum/enum.dart';
|
||||
import 'package:fl_clash/models/models.dart';
|
||||
import 'package:fl_clash/state.dart';
|
||||
import 'package:fl_clash/widgets/widgets.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class VPNSwitch extends StatelessWidget {
|
||||
const VPNSwitch({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Selector<Config, bool>(
|
||||
selector: (_, config) => config.vpnProps.enable,
|
||||
builder: (_, enable, __) {
|
||||
return ListItem.switchItem(
|
||||
title: const Text("VPN"),
|
||||
subtitle: Text(appLocalizations.vpnEnableDesc),
|
||||
delegate: SwitchDelegate(
|
||||
value: enable,
|
||||
onChanged: (value) async {
|
||||
final config = globalState.appController.config;
|
||||
config.vpnProps = config.vpnProps.copyWith(
|
||||
enable: value,
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class TUNItem extends StatelessWidget {
|
||||
const TUNItem({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Selector<Config, bool>(
|
||||
selector: (_, config) => config.vpnProps.enable,
|
||||
builder: (_, enable, __) {
|
||||
return ListItem.switchItem(
|
||||
title: Text(appLocalizations.tun),
|
||||
subtitle: Text(appLocalizations.tunDesc),
|
||||
delegate: SwitchDelegate(
|
||||
value: enable,
|
||||
onChanged: (value) async {
|
||||
final clashConfig = globalState.appController.clashConfig;
|
||||
clashConfig.tun = clashConfig.tun.copyWith(
|
||||
enable: value,
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class AllowBypassSwitch extends StatelessWidget {
|
||||
const AllowBypassSwitch({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Selector<Config, bool>(
|
||||
selector: (_, config) => config.vpnProps.allowBypass,
|
||||
builder: (_, allowBypass, __) {
|
||||
return ListItem.switchItem(
|
||||
title: Text(appLocalizations.allowBypass),
|
||||
subtitle: Text(appLocalizations.allowBypassDesc),
|
||||
delegate: SwitchDelegate(
|
||||
value: allowBypass,
|
||||
onChanged: (bool value) async {
|
||||
final config = globalState.appController.config;
|
||||
final vpnProps = config.vpnProps;
|
||||
config.vpnProps = vpnProps.copyWith(
|
||||
allowBypass: value,
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class SystemProxySwitch extends StatelessWidget {
|
||||
const SystemProxySwitch({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Selector<Config, bool>(
|
||||
selector: (_, config) => config.vpnProps.systemProxy,
|
||||
builder: (_, systemProxy, __) {
|
||||
return ListItem.switchItem(
|
||||
title: Text(appLocalizations.systemProxy),
|
||||
subtitle: Text(appLocalizations.systemProxyDesc),
|
||||
delegate: SwitchDelegate(
|
||||
value: systemProxy,
|
||||
onChanged: (bool value) async {
|
||||
final config = globalState.appController.config;
|
||||
final vpnProps = config.vpnProps;
|
||||
config.vpnProps = vpnProps.copyWith(
|
||||
systemProxy: value,
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class Ipv6Switch extends StatelessWidget {
|
||||
const Ipv6Switch({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Selector<Config, bool>(
|
||||
selector: (_, config) => config.vpnProps.ipv6,
|
||||
builder: (_, ipv6, __) {
|
||||
return ListItem.switchItem(
|
||||
title: const Text("IPv6"),
|
||||
subtitle: Text(appLocalizations.ipv6InboundDesc),
|
||||
delegate: SwitchDelegate(
|
||||
value: ipv6,
|
||||
onChanged: (bool value) async {
|
||||
final config = globalState.appController.config;
|
||||
final vpnProps = config.vpnProps;
|
||||
config.vpnProps = vpnProps.copyWith(
|
||||
ipv6: value,
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class TunStackItem extends StatelessWidget {
|
||||
const TunStackItem({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Selector<ClashConfig, TunStack>(
|
||||
selector: (_, clashConfig) => clashConfig.tun.stack,
|
||||
builder: (_, stack, __) {
|
||||
return ListItem.options(
|
||||
title: Text(appLocalizations.stackMode),
|
||||
subtitle: Text(stack.name),
|
||||
delegate: OptionsDelegate<TunStack>(
|
||||
value: stack,
|
||||
options: TunStack.values,
|
||||
textBuilder: (value) => value.name,
|
||||
onChanged: (value) {
|
||||
if (value == null) {
|
||||
return;
|
||||
}
|
||||
final clashConfig = globalState.appController.clashConfig;
|
||||
clashConfig.tun = clashConfig.tun.copyWith(
|
||||
stack: value,
|
||||
);
|
||||
},
|
||||
title: appLocalizations.stackMode,
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class BypassDomainItem extends StatelessWidget {
|
||||
const BypassDomainItem({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListItem.open(
|
||||
title: Text(appLocalizations.bypassDomain),
|
||||
subtitle: Text(appLocalizations.bypassDomainDesc),
|
||||
delegate: OpenDelegate(
|
||||
isBlur: false,
|
||||
title: appLocalizations.bypassDomain,
|
||||
widget: Selector<Config, List<String>>(
|
||||
selector: (_, config) => config.vpnProps.bypassDomain,
|
||||
shouldRebuild: (prev, next) =>
|
||||
!stringListEquality.equals(prev, next),
|
||||
builder: (_, bypassDomain, __) {
|
||||
return ListPage(
|
||||
title: appLocalizations.bypassDomain,
|
||||
items: bypassDomain,
|
||||
titleBuilder: (item) => Text(item),
|
||||
onChange: (items){
|
||||
final config = globalState.appController.config;
|
||||
config.vpnProps = config.vpnProps.copyWith(
|
||||
bypassDomain: List.from(items),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
extendPageWidth: 360,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
final networkItems = [
|
||||
Platform.isAndroid ? const VPNSwitch() : const TUNItem(),
|
||||
if (Platform.isAndroid)
|
||||
...generateSection(
|
||||
title: "VPN",
|
||||
items: [
|
||||
const SystemProxySwitch(),
|
||||
const AllowBypassSwitch(),
|
||||
const Ipv6Switch(),
|
||||
const BypassDomainItem(),
|
||||
],
|
||||
),
|
||||
...generateSection(
|
||||
title: appLocalizations.options,
|
||||
items: [
|
||||
const TunStackItem(),
|
||||
],
|
||||
),
|
||||
];
|
||||
|
||||
class NetworkListView extends StatelessWidget {
|
||||
const NetworkListView({super.key});
|
||||
|
||||
_initActions(BuildContext context) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
||||
final commonScaffoldState =
|
||||
context.findAncestorStateOfType<CommonScaffoldState>();
|
||||
commonScaffoldState?.actions = [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
globalState.showMessage(
|
||||
title: appLocalizations.reset,
|
||||
message: TextSpan(
|
||||
text: appLocalizations.resetTip,
|
||||
),
|
||||
onTab: () {
|
||||
final appController = globalState.appController;
|
||||
appController.config.vpnProps = defaultVpnProps;
|
||||
appController.clashConfig.tun = defaultTun;
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
);
|
||||
},
|
||||
tooltip: appLocalizations.reset,
|
||||
icon: const Icon(
|
||||
Icons.replay,
|
||||
),
|
||||
)
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
_initActions(context);
|
||||
return generateListView(
|
||||
networkItems,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,140 +0,0 @@
|
||||
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/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 Selector<Config, bool>(
|
||||
selector: (_, config) => config.vpnProps.enable,
|
||||
builder: (_, enable, __) {
|
||||
return ListItem.switchItem(
|
||||
leading: const Icon(Icons.stacked_line_chart),
|
||||
title: const Text("VPN"),
|
||||
subtitle: Text(appLocalizations.vpnEnableDesc),
|
||||
delegate: SwitchDelegate(
|
||||
value: enable,
|
||||
onChanged: (bool value) async {
|
||||
final config = globalState.appController.config;
|
||||
final vpnProps = config.vpnProps;
|
||||
config.vpnProps = vpnProps.copyWith(
|
||||
enable: value,
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class VPNDisabledContainer extends StatelessWidget {
|
||||
final Widget child;
|
||||
|
||||
const VPNDisabledContainer(
|
||||
this.child, {
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Selector<Config, bool>(
|
||||
selector: (_, config) => config.vpnProps.enable,
|
||||
builder: (_, enable, child) {
|
||||
return AbsorbPointer(
|
||||
absorbing: !enable,
|
||||
child: DisabledMask(
|
||||
status: !enable,
|
||||
child: child!,
|
||||
),
|
||||
);
|
||||
},
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class AllowBypassSwitch extends StatelessWidget {
|
||||
const AllowBypassSwitch({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Selector<Config, bool>(
|
||||
selector: (_, config) => config.vpnProps.allowBypass,
|
||||
builder: (_, allowBypass, __) {
|
||||
return ListItem.switchItem(
|
||||
leading: const Icon(Icons.arrow_forward_outlined),
|
||||
title: Text(appLocalizations.allowBypass),
|
||||
subtitle: Text(appLocalizations.allowBypassDesc),
|
||||
delegate: SwitchDelegate(
|
||||
value: allowBypass,
|
||||
onChanged: (bool value) async {
|
||||
final config = globalState.appController.config;
|
||||
final vpnProps = config.vpnProps;
|
||||
config.vpnProps = vpnProps.copyWith(
|
||||
allowBypass: value,
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class SystemProxySwitch extends StatelessWidget {
|
||||
const SystemProxySwitch({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Selector<Config, bool>(
|
||||
selector: (_, config) => config.vpnProps.systemProxy,
|
||||
builder: (_, systemProxy, __) {
|
||||
return ListItem.switchItem(
|
||||
leading: const Icon(Icons.settings_ethernet),
|
||||
title: Text(appLocalizations.systemProxy),
|
||||
subtitle: Text(appLocalizations.systemProxyDesc),
|
||||
delegate: SwitchDelegate(
|
||||
value: systemProxy,
|
||||
onChanged: (bool value) async {
|
||||
final config = globalState.appController.config;
|
||||
final vpnProps = config.vpnProps;
|
||||
config.vpnProps = vpnProps.copyWith(
|
||||
systemProxy: value,
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class VpnOptions extends StatelessWidget {
|
||||
const VpnOptions({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return VPNDisabledContainer(
|
||||
Column(
|
||||
children: generateSection(
|
||||
title: appLocalizations.options,
|
||||
items: [
|
||||
const SystemProxySwitch(),
|
||||
const AllowBypassSwitch(),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
final vpnItems = [
|
||||
const VPNSwitch(),
|
||||
const VpnOptions(),
|
||||
];
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'dart:io';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:fl_clash/common/common.dart';
|
||||
|
||||
@@ -13,16 +13,55 @@ class IntranetIP extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _IntranetIPState extends State<IntranetIP> {
|
||||
final ipNotifier = ValueNotifier<String>("");
|
||||
final ipNotifier = ValueNotifier<String?>("");
|
||||
|
||||
Future<String?> getLocalIpAddress() async {
|
||||
List<NetworkInterface> interfaces = await NetworkInterface.list();
|
||||
for (final interface in interfaces) {
|
||||
for (final address in interface.addresses) {
|
||||
if (!address.isLoopback) {
|
||||
return address.address;
|
||||
Future<String> getNetworkType() async {
|
||||
try {
|
||||
List<NetworkInterface> interfaces = await NetworkInterface.list(
|
||||
includeLoopback: false,
|
||||
type: InternetAddressType.any,
|
||||
);
|
||||
|
||||
for (var interface in interfaces) {
|
||||
if (interface.name.toLowerCase().contains('wlan') ||
|
||||
interface.name.toLowerCase().contains('wi-fi')) {
|
||||
return 'WiFi';
|
||||
}
|
||||
if (interface.name.toLowerCase().contains('rmnet') ||
|
||||
interface.name.toLowerCase().contains('ccmni') ||
|
||||
interface.name.toLowerCase().contains('cellular')) {
|
||||
return 'Mobile Data';
|
||||
}
|
||||
}
|
||||
|
||||
return 'Unknown';
|
||||
} catch (e) {
|
||||
return 'Error';
|
||||
}
|
||||
}
|
||||
|
||||
Future<String?> getLocalIpAddress() async {
|
||||
List<NetworkInterface> interfaces = await NetworkInterface.list(
|
||||
includeLoopback: false,
|
||||
)
|
||||
..sort((a, b) {
|
||||
if (a.isWifi && !b.isWifi) return -1;
|
||||
if (!a.isWifi && b.isWifi) return 1;
|
||||
if (a.includesIPv4 && !b.includesIPv4) return -1;
|
||||
if (!a.includesIPv4 && b.includesIPv4) return 1;
|
||||
return 0;
|
||||
});
|
||||
for (final interface in interfaces) {
|
||||
final addresses = interface.addresses;
|
||||
if (addresses.isEmpty) {
|
||||
continue;
|
||||
}
|
||||
addresses.sort((a, b) {
|
||||
if (a.isIPv4 && !b.isIPv4) return -1;
|
||||
if (!a.isIPv4 && b.isIPv4) return 1;
|
||||
return 0;
|
||||
});
|
||||
return addresses.first.address;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -48,17 +87,15 @@ class _IntranetIPState extends State<IntranetIP> {
|
||||
label: appLocalizations.intranetIP,
|
||||
iconData: Icons.devices,
|
||||
),
|
||||
onPressed: (){
|
||||
|
||||
},
|
||||
onPressed: () {},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(16).copyWith(top: 0),
|
||||
height: globalState.measure.titleLargeHeight + 24 - 2,
|
||||
height: globalState.measure.titleMediumHeight + 24 - 2,
|
||||
child: ValueListenableBuilder(
|
||||
valueListenable: ipNotifier,
|
||||
builder: (_, value, __) {
|
||||
return FadeBox(
|
||||
child: value.isNotEmpty
|
||||
child: value != null
|
||||
? Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
@@ -67,8 +104,9 @@ class _IntranetIPState extends State<IntranetIP> {
|
||||
flex: 1,
|
||||
child: TooltipText(
|
||||
text: Text(
|
||||
value,
|
||||
style: context.textTheme.titleLarge?.toSoftBold.toMinus,
|
||||
value.isNotEmpty ? value : appLocalizations.noNetwork,
|
||||
style: context
|
||||
.textTheme.titleLarge?.toSoftBold.toMinus,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:fl_clash/common/common.dart';
|
||||
import 'package:fl_clash/models/models.dart';
|
||||
@@ -22,14 +24,17 @@ class _NetworkDetectionState extends State<NetworkDetection> {
|
||||
);
|
||||
bool? _preIsStart;
|
||||
Function? _checkIpDebounce;
|
||||
Timer? _setTimeoutTimer;
|
||||
CancelToken? cancelToken;
|
||||
|
||||
_checkIp() async {
|
||||
final appState = globalState.appController.appState;
|
||||
final appFlowingState = globalState.appController.appFlowingState;
|
||||
final isInit = appState.isInit;
|
||||
if (!isInit) return;
|
||||
final isStart = appState.isStart;
|
||||
final isStart = appFlowingState.isStart;
|
||||
if (_preIsStart == false && _preIsStart == isStart) return;
|
||||
_clearSetTimeoutTimer();
|
||||
networkDetectionState.value = networkDetectionState.value.copyWith(
|
||||
isTesting: true,
|
||||
ipInfo: null,
|
||||
@@ -42,11 +47,32 @@ class _NetworkDetectionState extends State<NetworkDetection> {
|
||||
cancelToken = CancelToken();
|
||||
try {
|
||||
final ipInfo = await request.checkIp(cancelToken: cancelToken);
|
||||
if (ipInfo != null) {
|
||||
networkDetectionState.value = networkDetectionState.value.copyWith(
|
||||
isTesting: false,
|
||||
ipInfo: ipInfo,
|
||||
);
|
||||
return;
|
||||
}
|
||||
_setTimeoutTimer = Timer(const Duration(milliseconds: 2000), () {
|
||||
networkDetectionState.value = networkDetectionState.value.copyWith(
|
||||
isTesting: false,
|
||||
ipInfo: null,
|
||||
);
|
||||
});
|
||||
} catch (_) {
|
||||
networkDetectionState.value = networkDetectionState.value.copyWith(
|
||||
isTesting: false,
|
||||
ipInfo: ipInfo,
|
||||
isTesting: true,
|
||||
ipInfo: null,
|
||||
);
|
||||
} catch (_) {}
|
||||
}
|
||||
}
|
||||
|
||||
_clearSetTimeoutTimer() {
|
||||
if(_setTimeoutTimer != null){
|
||||
_setTimeoutTimer?.cancel();
|
||||
_setTimeoutTimer = null;
|
||||
}
|
||||
}
|
||||
|
||||
_checkIpContainer(Widget child) {
|
||||
|
||||
@@ -116,8 +116,8 @@ class _NetworkSpeedState extends State<NetworkSpeed> {
|
||||
label: appLocalizations.networkSpeed,
|
||||
iconData: Icons.speed_sharp,
|
||||
),
|
||||
child: Selector<AppState, List<Traffic>>(
|
||||
selector: (_, appState) => appState.traffics,
|
||||
child: Selector<AppFlowingState, List<Traffic>>(
|
||||
selector: (_, appFlowingState) => appFlowingState.traffics,
|
||||
builder: (_, traffics, __) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
|
||||
@@ -34,7 +34,7 @@ class _StartButtonState extends State<StartButton>
|
||||
|
||||
handleSwitchStart() {
|
||||
final appController = globalState.appController;
|
||||
if (isStart == appController.appState.isStart) {
|
||||
if (isStart == appController.appFlowingState.isStart) {
|
||||
isStart = !isStart;
|
||||
updateController();
|
||||
appController.updateStatus(isStart);
|
||||
@@ -50,8 +50,8 @@ class _StartButtonState extends State<StartButton>
|
||||
}
|
||||
|
||||
Widget _updateControllerContainer(Widget child) {
|
||||
return Selector<AppState, bool>(
|
||||
selector: (_, appState) => appState.isStart,
|
||||
return Selector<AppFlowingState, bool>(
|
||||
selector: (_, appFlowingState) => appFlowingState.isStart,
|
||||
builder: (_, isStart, child) {
|
||||
if (isStart != this.isStart) {
|
||||
this.isStart = isStart;
|
||||
@@ -127,8 +127,8 @@ class _StartButtonState extends State<StartButton>
|
||||
);
|
||||
},
|
||||
child: _updateControllerContainer(
|
||||
Selector<AppState, int?>(
|
||||
selector: (_, appState) => appState.runTime,
|
||||
Selector<AppFlowingState, int?>(
|
||||
selector: (_, appFlowingState) => appFlowingState.runTime,
|
||||
builder: (_, int? value, __) {
|
||||
final text = other.getTimeText(value);
|
||||
return Text(
|
||||
|
||||
@@ -56,8 +56,8 @@ class TrafficUsage extends StatelessWidget {
|
||||
label: appLocalizations.trafficUsage,
|
||||
iconData: Icons.data_saver_off,
|
||||
),
|
||||
child: Selector<AppState, Traffic>(
|
||||
selector: (_, appState) => appState.totalTraffic,
|
||||
child: Selector<AppFlowingState, Traffic>(
|
||||
selector: (_, appFlowingState) => appFlowingState.totalTraffic,
|
||||
builder: (_, totalTraffic, __) {
|
||||
final upTotalTrafficValue = totalTraffic.up;
|
||||
final downTotalTrafficValue = totalTraffic.down;
|
||||
|
||||
@@ -146,7 +146,7 @@ class _HotKeyRecorderState extends State<HotKeyRecorder> {
|
||||
final index = hotKeyActions.indexWhere(
|
||||
(item) =>
|
||||
item.key == currentHotkeyAction.key &&
|
||||
keyboardModifiersEquality.equals(
|
||||
keyboardModifierListEquality.equals(
|
||||
item.modifiers,
|
||||
currentHotkeyAction.modifiers,
|
||||
),
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:fl_clash/common/common.dart';
|
||||
import 'package:fl_clash/enum/enum.dart';
|
||||
import 'package:fl_clash/state.dart';
|
||||
@@ -21,7 +19,6 @@ class _LogsFragmentState extends State<LogsFragment> {
|
||||
final scrollController = ScrollController(
|
||||
keepScrollOffset: false,
|
||||
);
|
||||
List<GlobalObjectKey<_LogItemState>> keys = [];
|
||||
|
||||
Timer? timer;
|
||||
|
||||
@@ -29,19 +26,22 @@ class _LogsFragmentState extends State<LogsFragment> {
|
||||
void initState() {
|
||||
super.initState();
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
final appState = globalState.appController.appState;
|
||||
logsNotifier.value = logsNotifier.value.copyWith(logs: appState.logs);
|
||||
final appFlowingState = globalState.appController.appFlowingState;
|
||||
logsNotifier.value =
|
||||
logsNotifier.value.copyWith(logs: appFlowingState.logs);
|
||||
if (timer != null) {
|
||||
timer?.cancel();
|
||||
timer = null;
|
||||
}
|
||||
timer = Timer.periodic(const Duration(milliseconds: 200), (timer) {
|
||||
final logs = appState.logs;
|
||||
if (!const ListEquality<Log>().equals(
|
||||
final logs = appFlowingState.logs;
|
||||
if (!logListEquality.equals(
|
||||
logsNotifier.value.logs,
|
||||
logs,
|
||||
)) {
|
||||
logsNotifier.value = logsNotifier.value.copyWith(logs: logs);
|
||||
logsNotifier.value = logsNotifier.value.copyWith(
|
||||
logs: logs,
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -56,6 +56,21 @@ class _LogsFragmentState extends State<LogsFragment> {
|
||||
timer = null;
|
||||
}
|
||||
|
||||
_handleExport() async {
|
||||
final commonScaffoldState = context.commonScaffoldState;
|
||||
final res = await commonScaffoldState?.loadingRun<bool>(
|
||||
() async {
|
||||
return await globalState.appController.exportLogs();
|
||||
},
|
||||
title: appLocalizations.exportLogs,
|
||||
);
|
||||
if (res != true) return;
|
||||
globalState.showMessage(
|
||||
title: appLocalizations.tip,
|
||||
message: TextSpan(text: appLocalizations.exportSuccess),
|
||||
);
|
||||
}
|
||||
|
||||
_initActions() {
|
||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
||||
final commonScaffoldState =
|
||||
@@ -72,6 +87,17 @@ class _LogsFragmentState extends State<LogsFragment> {
|
||||
},
|
||||
icon: const Icon(Icons.search),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
_handleExport();
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.file_download_outlined,
|
||||
),
|
||||
),
|
||||
];
|
||||
});
|
||||
}
|
||||
@@ -112,15 +138,26 @@ class _LogsFragmentState extends State<LogsFragment> {
|
||||
child: ValueListenableBuilder<LogsAndKeywords>(
|
||||
valueListenable: logsNotifier,
|
||||
builder: (_, state, __) {
|
||||
var logs = state.filteredLogs;
|
||||
final logs = state.filteredLogs;
|
||||
if (logs.isEmpty) {
|
||||
return NullStatus(
|
||||
label: appLocalizations.nullLogsDesc,
|
||||
);
|
||||
}
|
||||
logs = logs.reversed.toList();
|
||||
keys = logs
|
||||
.map((log) => GlobalObjectKey<_LogItemState>(log.dateTime))
|
||||
final reversedLogs = logs.reversed.toList();
|
||||
final logWidgets = reversedLogs
|
||||
.map<Widget>(
|
||||
(log) => LogItem(
|
||||
key: Key(log.dateTime.toString()),
|
||||
log: log,
|
||||
onClick: _addKeyword,
|
||||
),
|
||||
)
|
||||
.separated(
|
||||
const Divider(
|
||||
height: 0,
|
||||
),
|
||||
)
|
||||
.toList();
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@@ -147,22 +184,38 @@ class _LogsFragmentState extends State<LogsFragment> {
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: ListView.separated(
|
||||
controller: scrollController,
|
||||
itemBuilder: (_, index) {
|
||||
final log = logs[index];
|
||||
return LogItem(
|
||||
key: Key(log.dateTime.toString()),
|
||||
log: log,
|
||||
onClick: _addKeyword,
|
||||
);
|
||||
child: LayoutBuilder(
|
||||
builder: (_, constraints) {
|
||||
return ScrollConfiguration(
|
||||
behavior: ShowBarScrollBehavior(),
|
||||
child: ListView.builder(
|
||||
controller: scrollController,
|
||||
itemExtentBuilder: (index, __) {
|
||||
final widget = logWidgets[index];
|
||||
if (widget.runtimeType == Divider) {
|
||||
return 0;
|
||||
}
|
||||
final measure = globalState.measure;
|
||||
final bodyLargeSize = measure.bodyLargeSize;
|
||||
final bodySmallHeight = measure.bodySmallHeight;
|
||||
final bodyMediumHeight = measure.bodyMediumHeight;
|
||||
final log = reversedLogs[(index / 2).floor()];
|
||||
final width = (log.payload?.length ?? 0) *
|
||||
bodyLargeSize.width +
|
||||
200;
|
||||
final lines = (width / constraints.maxWidth).ceil();
|
||||
return lines * bodyLargeSize.height +
|
||||
bodySmallHeight +
|
||||
8 +
|
||||
bodyMediumHeight +
|
||||
40;
|
||||
},
|
||||
itemBuilder: (_, index) {
|
||||
return logWidgets[index];
|
||||
},
|
||||
itemCount: logWidgets.length,
|
||||
));
|
||||
},
|
||||
separatorBuilder: (BuildContext context, int index) {
|
||||
return const Divider(
|
||||
height: 0,
|
||||
);
|
||||
},
|
||||
itemCount: logs.length,
|
||||
),
|
||||
)
|
||||
],
|
||||
@@ -236,7 +289,8 @@ class LogsSearchDelegate extends SearchDelegate {
|
||||
_addKeyword(String keyword) {
|
||||
final isContains = logsNotifier.value.keywords.contains(keyword);
|
||||
if (isContains) return;
|
||||
final keywords = List<String>.from(logsNotifier.value.keywords)..add(keyword);
|
||||
final keywords = List<String>.from(logsNotifier.value.keywords)
|
||||
..add(keyword);
|
||||
logsNotifier.value = logsNotifier.value.copyWith(
|
||||
keywords: keywords,
|
||||
);
|
||||
@@ -245,7 +299,8 @@ class LogsSearchDelegate extends SearchDelegate {
|
||||
_deleteKeyword(String keyword) {
|
||||
final isContains = logsNotifier.value.keywords.contains(keyword);
|
||||
if (!isContains) return;
|
||||
final keywords = List<String>.from(logsNotifier.value.keywords)..remove(keyword);
|
||||
final keywords = List<String>.from(logsNotifier.value.keywords)
|
||||
..remove(keyword);
|
||||
logsNotifier.value = logsNotifier.value.copyWith(
|
||||
keywords: keywords,
|
||||
);
|
||||
@@ -330,7 +385,9 @@ class _LogItemState extends State<LogItem> {
|
||||
horizontal: 16,
|
||||
vertical: 4,
|
||||
),
|
||||
title: SelectableText(log.payload ?? ''),
|
||||
title: SelectableText(
|
||||
log.payload ?? '',
|
||||
),
|
||||
subtitle: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
@@ -339,7 +396,9 @@ class _LogItemState extends State<LogItem> {
|
||||
style: context.textTheme.bodySmall
|
||||
?.copyWith(color: context.colorScheme.primary),
|
||||
),
|
||||
const SizedBox(height: 8,),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
Container(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: CommonChip(
|
||||
|
||||
@@ -459,10 +459,9 @@ class _ReorderableProfilesState extends State<ReorderableProfiles> {
|
||||
flex: 1,
|
||||
child: ReorderableListView.builder(
|
||||
buildDefaultDragHandles: false,
|
||||
padding: const EdgeInsets.all(12),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
proxyDecorator: proxyDecorator,
|
||||
onReorder: (int oldIndex, int newIndex) {
|
||||
if (oldIndex == newIndex) return;
|
||||
onReorder: (oldIndex, newIndex) {
|
||||
setState(() {
|
||||
if (oldIndex < newIndex) {
|
||||
newIndex -= 1;
|
||||
|
||||
@@ -166,20 +166,20 @@ class ContextMenuControllerImpl implements SelectionToolbarController {
|
||||
// _removeOverLayEntry();
|
||||
}
|
||||
|
||||
_handleCut(CodeLineEditingController controller) {
|
||||
controller.cut();
|
||||
_removeOverLayEntry();
|
||||
}
|
||||
|
||||
_handleCopy(CodeLineEditingController controller) async {
|
||||
await controller.copy();
|
||||
_removeOverLayEntry();
|
||||
}
|
||||
|
||||
_handlePaste(CodeLineEditingController controller) {
|
||||
controller.paste();
|
||||
_removeOverLayEntry();
|
||||
}
|
||||
// _handleCut(CodeLineEditingController controller) {
|
||||
// controller.cut();
|
||||
// _removeOverLayEntry();
|
||||
// }
|
||||
//
|
||||
// _handleCopy(CodeLineEditingController controller) async {
|
||||
// await controller.copy();
|
||||
// _removeOverLayEntry();
|
||||
// }
|
||||
//
|
||||
// _handlePaste(CodeLineEditingController controller) {
|
||||
// controller.paste();
|
||||
// _removeOverLayEntry();
|
||||
// }
|
||||
|
||||
@override
|
||||
void show({
|
||||
|
||||
@@ -102,12 +102,12 @@ class ProxyCard extends StatelessWidget {
|
||||
|
||||
_changeProxy(BuildContext context) async {
|
||||
final appController = globalState.appController;
|
||||
final isUrlTest = groupType == GroupType.URLTest;
|
||||
final isURLTestOrFallback = groupType.isURLTestOrFallback;
|
||||
final isSelector = groupType == GroupType.Selector;
|
||||
if (isUrlTest || isSelector) {
|
||||
if (isURLTestOrFallback || isSelector) {
|
||||
final currentProxyName =
|
||||
appController.config.currentSelectedMap[groupName];
|
||||
final nextProxyName = switch (isUrlTest) {
|
||||
final nextProxyName = switch (isURLTestOrFallback) {
|
||||
true => currentProxyName == proxy.name ? "" : proxy.name,
|
||||
false => proxy.name,
|
||||
};
|
||||
@@ -133,7 +133,7 @@ class ProxyCard extends StatelessWidget {
|
||||
final measure = globalState.measure;
|
||||
final delayText = _buildDelayText();
|
||||
final proxyNameText = _buildProxyNameText(context);
|
||||
return currentGroupProxyNameBuilder(
|
||||
return currentSelectedProxyNameBuilder(
|
||||
groupName: groupName,
|
||||
builder: (currentGroupName) {
|
||||
return Stack(
|
||||
@@ -207,30 +207,16 @@ class ProxyCard extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
if (groupType == GroupType.URLTest)
|
||||
if (groupType.isURLTestOrFallback)
|
||||
Selector<Config, String>(
|
||||
selector: (_, config) {
|
||||
final selectedProxyName =
|
||||
config.currentSelectedMap[groupName];
|
||||
return selectedProxyName ?? '';
|
||||
},
|
||||
builder: (_, value, __) {
|
||||
builder: (_, value, child) {
|
||||
if (value != proxy.name) return Container();
|
||||
return Positioned.fill(
|
||||
child: Container(
|
||||
alignment: Alignment.topRight,
|
||||
margin: const EdgeInsets.all(8),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(4),
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color:
|
||||
Theme.of(context).colorScheme.secondaryContainer,
|
||||
),
|
||||
child: const SelectIcon(),
|
||||
),
|
||||
),
|
||||
);
|
||||
return child!;
|
||||
},
|
||||
child: Positioned.fill(
|
||||
child: Container(
|
||||
|
||||
@@ -6,7 +6,7 @@ import 'package:fl_clash/state.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
Widget currentGroupProxyNameBuilder({
|
||||
Widget currentSelectedProxyNameBuilder({
|
||||
required String groupName,
|
||||
required Widget Function(String currentGroupName) builder,
|
||||
}) {
|
||||
@@ -16,8 +16,8 @@ Widget currentGroupProxyNameBuilder({
|
||||
final selectedProxyName = config.currentSelectedMap[groupName];
|
||||
return group?.getCurrentSelectedName(selectedProxyName ?? "") ?? "";
|
||||
},
|
||||
builder: (_, currentGroupName, ___) {
|
||||
return builder(currentGroupName);
|
||||
builder: (_, currentSelectedProxyName, ___) {
|
||||
return builder(currentSelectedProxyName);
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -81,9 +81,9 @@ double getScrollToSelectedOffset({
|
||||
final appController = globalState.appController;
|
||||
final columns = other.getProxiesColumns(
|
||||
appController.appState.viewWidth,
|
||||
appController.config.proxiesLayout,
|
||||
appController.config.proxiesStyle.layout,
|
||||
);
|
||||
final proxyCardType = appController.config.proxyCardType;
|
||||
final proxyCardType = appController.config.proxiesStyle.cardType;
|
||||
final selectedName = appController.getCurrentSelectedName(groupName);
|
||||
final findSelectedIndex = proxies.indexWhere(
|
||||
(proxy) => proxy.name == selectedName,
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:collection/collection.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/state.dart';
|
||||
import 'package:fl_clash/widgets/builder.dart';
|
||||
import 'package:fl_clash/widgets/card.dart';
|
||||
import 'package:fl_clash/widgets/text.dart';
|
||||
import 'package:fl_clash/widgets/widgets.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
@@ -244,18 +240,17 @@ class _ProxiesListFragmentState extends State<ProxiesListFragment> {
|
||||
return ProxiesListSelectorState(
|
||||
groupNames: groupNames,
|
||||
currentUnfoldSet: config.currentUnfoldSet,
|
||||
proxyCardType: config.proxyCardType,
|
||||
proxiesSortType: config.proxiesSortType,
|
||||
proxyCardType: config.proxiesStyle.cardType,
|
||||
proxiesSortType: config.proxiesStyle.sortType,
|
||||
columns: other.getProxiesColumns(
|
||||
appState.viewWidth,
|
||||
config.proxiesLayout,
|
||||
config.proxiesStyle.layout,
|
||||
),
|
||||
sortNum: appState.sortNum,
|
||||
);
|
||||
},
|
||||
shouldRebuild: (prev, next) {
|
||||
if (!const ListEquality<String>()
|
||||
.equals(prev.groupNames, next.groupNames)) {
|
||||
if (!stringListEquality.equals(prev.groupNames, next.groupNames)) {
|
||||
_headerStateNotifier.value = const ProxiesListHeaderSelectorState(
|
||||
offset: 0,
|
||||
currentIndex: 0,
|
||||
@@ -264,75 +259,73 @@ class _ProxiesListFragmentState extends State<ProxiesListFragment> {
|
||||
return prev != next;
|
||||
},
|
||||
builder: (_, state, __) {
|
||||
return ScaleBuilder(builder: (_) {
|
||||
final items = _buildItems(
|
||||
groupNames: state.groupNames,
|
||||
currentUnfoldSet: state.currentUnfoldSet,
|
||||
columns: state.columns,
|
||||
type: state.proxyCardType,
|
||||
);
|
||||
final itemsOffset = _getItemHeightList(items, state.proxyCardType);
|
||||
return Scrollbar(
|
||||
controller: _controller,
|
||||
thumbVisibility: true,
|
||||
trackVisibility: true,
|
||||
thickness: 8,
|
||||
radius: const Radius.circular(8),
|
||||
interactive: true,
|
||||
child: Stack(
|
||||
children: [
|
||||
Positioned.fill(
|
||||
child: ScrollConfiguration(
|
||||
behavior: HiddenBarScrollBehavior(),
|
||||
child: ListView.builder(
|
||||
padding: const EdgeInsets.all(16),
|
||||
controller: _controller,
|
||||
itemExtentBuilder: (index, __) {
|
||||
return itemsOffset[index];
|
||||
},
|
||||
itemCount: items.length,
|
||||
itemBuilder: (_, index) {
|
||||
return items[index];
|
||||
},
|
||||
),
|
||||
final items = _buildItems(
|
||||
groupNames: state.groupNames,
|
||||
currentUnfoldSet: state.currentUnfoldSet,
|
||||
columns: state.columns,
|
||||
type: state.proxyCardType,
|
||||
);
|
||||
final itemsOffset = _getItemHeightList(items, state.proxyCardType);
|
||||
return Scrollbar(
|
||||
controller: _controller,
|
||||
thumbVisibility: true,
|
||||
trackVisibility: true,
|
||||
thickness: 8,
|
||||
radius: const Radius.circular(8),
|
||||
interactive: true,
|
||||
child: Stack(
|
||||
children: [
|
||||
Positioned.fill(
|
||||
child: ScrollConfiguration(
|
||||
behavior: HiddenBarScrollBehavior(),
|
||||
child: ListView.builder(
|
||||
padding: const EdgeInsets.all(16),
|
||||
controller: _controller,
|
||||
itemExtentBuilder: (index, __) {
|
||||
return itemsOffset[index];
|
||||
},
|
||||
itemCount: items.length,
|
||||
itemBuilder: (_, index) {
|
||||
return items[index];
|
||||
},
|
||||
),
|
||||
),
|
||||
LayoutBuilder(builder: (_, container) {
|
||||
return ValueListenableBuilder(
|
||||
valueListenable: _headerStateNotifier,
|
||||
builder: (_, headerState, ___) {
|
||||
final index =
|
||||
headerState.currentIndex > state.groupNames.length - 1
|
||||
? 0
|
||||
: headerState.currentIndex;
|
||||
return Stack(
|
||||
children: [
|
||||
Positioned(
|
||||
top: -headerState.offset,
|
||||
child: Container(
|
||||
width: container.maxWidth,
|
||||
color: context.colorScheme.surface,
|
||||
padding: const EdgeInsets.only(
|
||||
top: 16,
|
||||
left: 16,
|
||||
right: 16,
|
||||
bottom: 8,
|
||||
),
|
||||
child: _buildHeader(
|
||||
groupName: state.groupNames[index],
|
||||
currentUnfoldSet: state.currentUnfoldSet,
|
||||
),
|
||||
),
|
||||
LayoutBuilder(builder: (_, container) {
|
||||
return ValueListenableBuilder(
|
||||
valueListenable: _headerStateNotifier,
|
||||
builder: (_, headerState, ___) {
|
||||
final index =
|
||||
headerState.currentIndex > state.groupNames.length - 1
|
||||
? 0
|
||||
: headerState.currentIndex;
|
||||
return Stack(
|
||||
children: [
|
||||
Positioned(
|
||||
top: -headerState.offset,
|
||||
child: Container(
|
||||
width: container.maxWidth,
|
||||
color: context.colorScheme.surface,
|
||||
padding: const EdgeInsets.only(
|
||||
top: 16,
|
||||
left: 16,
|
||||
right: 16,
|
||||
bottom: 8,
|
||||
),
|
||||
child: _buildHeader(
|
||||
groupName: state.groupNames[index],
|
||||
currentUnfoldSet: state.currentUnfoldSet,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}),
|
||||
],
|
||||
),
|
||||
);
|
||||
});
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -379,11 +372,6 @@ class _ListHeaderState extends State<ListHeader>
|
||||
}
|
||||
|
||||
_handleChange(String groupName) {
|
||||
if (isExpand) {
|
||||
_animationController.reverse();
|
||||
} else {
|
||||
_animationController.forward();
|
||||
}
|
||||
widget.onChange(groupName);
|
||||
}
|
||||
|
||||
@@ -413,13 +401,69 @@ class _ListHeaderState extends State<ListHeader>
|
||||
super.didUpdateWidget(oldWidget);
|
||||
if (oldWidget.isExpand != widget.isExpand) {
|
||||
if (isExpand) {
|
||||
_animationController.value = 1.0;
|
||||
_animationController.forward();
|
||||
} else {
|
||||
_animationController.value = 0.0;
|
||||
_animationController.reverse();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildIcon() {
|
||||
return Selector<Config, ProxiesIconStyle>(
|
||||
selector: (_, config) => config.proxiesStyle.iconStyle,
|
||||
builder: (_, iconStyle, child) {
|
||||
return Selector<Config, String>(
|
||||
selector: (_, config) {
|
||||
final iconMapEntryList =
|
||||
config.proxiesStyle.iconMap.entries.toList();
|
||||
final index = iconMapEntryList.indexWhere((item) {
|
||||
try{
|
||||
return RegExp(item.key).hasMatch(groupName);
|
||||
}catch(_){
|
||||
return false;
|
||||
}
|
||||
});
|
||||
if (index != -1) {
|
||||
return iconMapEntryList[index].value;
|
||||
}
|
||||
return icon;
|
||||
},
|
||||
builder: (_, icon, __) {
|
||||
return switch (iconStyle) {
|
||||
ProxiesIconStyle.standard => Container(
|
||||
height: 48,
|
||||
width: 48,
|
||||
margin: const EdgeInsets.only(
|
||||
right: 16,
|
||||
),
|
||||
padding: const EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
color: context.colorScheme.secondaryContainer,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: CommonIcon(
|
||||
src: icon,
|
||||
size: 32,
|
||||
),
|
||||
),
|
||||
ProxiesIconStyle.icon => Container(
|
||||
margin: const EdgeInsets.only(
|
||||
right: 16,
|
||||
),
|
||||
child: CommonIcon(
|
||||
src: icon,
|
||||
size: 42,
|
||||
),
|
||||
),
|
||||
ProxiesIconStyle.none => Container(),
|
||||
};
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CommonCard(
|
||||
@@ -427,41 +471,17 @@ class _ListHeaderState extends State<ListHeader>
|
||||
radius: 24,
|
||||
type: CommonCardType.filled,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 12,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Flexible(
|
||||
child: Row(
|
||||
children: [
|
||||
const SizedBox(
|
||||
width: 4,
|
||||
),
|
||||
Container(
|
||||
height: 48,
|
||||
width: 48,
|
||||
padding: const EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
color: context.colorScheme.secondaryContainer,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: icon.isNotEmpty
|
||||
? CachedNetworkImage(
|
||||
imageUrl: icon,
|
||||
errorWidget: (_, __, ___) => const Icon(
|
||||
IconsExt.target,
|
||||
size: 32,
|
||||
),
|
||||
)
|
||||
: const Icon(
|
||||
IconsExt.target,
|
||||
size: 32,
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 16,
|
||||
),
|
||||
_buildIcon(),
|
||||
Flexible(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
@@ -487,7 +507,7 @@ class _ListHeaderState extends State<ListHeader>
|
||||
),
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: currentGroupProxyNameBuilder(
|
||||
child: currentSelectedProxyNameBuilder(
|
||||
groupName: groupName,
|
||||
builder: (currentGroupName) {
|
||||
return Row(
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import 'package:fl_clash/common/app_localizations.dart';
|
||||
import 'package:fl_clash/common/common.dart';
|
||||
import 'package:fl_clash/enum/enum.dart';
|
||||
import 'package:fl_clash/fragments/proxies/list.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';
|
||||
|
||||
import 'providers.dart';
|
||||
import 'setting.dart';
|
||||
import 'tab.dart';
|
||||
@@ -37,7 +37,7 @@ class _ProxiesFragmentState extends State<ProxiesFragment> {
|
||||
);
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.swap_vert_circle_outlined,
|
||||
Icons.poll_outlined,
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
@@ -56,6 +56,63 @@ class _ProxiesFragmentState extends State<ProxiesFragment> {
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
)
|
||||
] else ...[
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
showExtendPage(
|
||||
context,
|
||||
extendPageWidth: 360,
|
||||
title: appLocalizations.iconConfiguration,
|
||||
body: Selector<Config, Map<String, String>>(
|
||||
selector: (_, config) => config.proxiesStyle.iconMap,
|
||||
shouldRebuild: (prev, next) {
|
||||
return !stringAndStringMapEntryIterableEquality.equals(
|
||||
prev.entries,
|
||||
next.entries,
|
||||
);
|
||||
},
|
||||
builder: (_, iconMap, __) {
|
||||
final entries = iconMap.entries.toList();
|
||||
return ListPage(
|
||||
title: appLocalizations.iconConfiguration,
|
||||
items: entries,
|
||||
keyLabel: appLocalizations.regExp,
|
||||
valueLabel: appLocalizations.icon,
|
||||
keyBuilder: (item) => Key(item.key),
|
||||
titleBuilder: (item) => Text(item.key),
|
||||
leadingBuilder: (item) => Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: CommonIcon(
|
||||
src: item.value,
|
||||
size: 42,
|
||||
),
|
||||
),
|
||||
subtitleBuilder: (item) => Text(
|
||||
item.value,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
onChange: (entries) {
|
||||
final config = globalState.appController.config;
|
||||
config.proxiesStyle = config.proxiesStyle.copyWith(
|
||||
iconMap: Map.fromEntries(entries),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.style_outlined,
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
)
|
||||
],
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
@@ -63,7 +120,7 @@ class _ProxiesFragmentState extends State<ProxiesFragment> {
|
||||
title: appLocalizations.proxiesSetting,
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return const ProxiesSettingWidget();
|
||||
return const ProxiesSetting();
|
||||
},
|
||||
);
|
||||
},
|
||||
@@ -78,7 +135,7 @@ class _ProxiesFragmentState extends State<ProxiesFragment> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Selector<Config, ProxiesType>(
|
||||
selector: (_, config) => config.proxiesType,
|
||||
selector: (_, config) => config.proxiesStyle.type,
|
||||
builder: (_, proxiesType, __) {
|
||||
return ProxiesActionsBuilder(
|
||||
builder: (state, child) {
|
||||
|
||||
@@ -7,8 +7,8 @@ import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class ProxiesSettingWidget extends StatelessWidget {
|
||||
const ProxiesSettingWidget({super.key});
|
||||
class ProxiesSetting extends StatelessWidget {
|
||||
const ProxiesSetting({super.key});
|
||||
|
||||
IconData _getIconWithProxiesType(ProxiesType type) {
|
||||
return switch (type) {
|
||||
@@ -41,6 +41,14 @@ class ProxiesSettingWidget extends StatelessWidget {
|
||||
};
|
||||
}
|
||||
|
||||
String _getTextWithProxiesIconStyle(ProxiesIconStyle style) {
|
||||
return switch (style) {
|
||||
ProxiesIconStyle.standard => appLocalizations.standard,
|
||||
ProxiesIconStyle.none => appLocalizations.noIcon,
|
||||
ProxiesIconStyle.icon => appLocalizations.onlyIcon,
|
||||
};
|
||||
}
|
||||
|
||||
List<Widget> _buildStyleSetting() {
|
||||
return generateSection(
|
||||
title: appLocalizations.style,
|
||||
@@ -49,7 +57,7 @@ class ProxiesSettingWidget extends StatelessWidget {
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Selector<Config, ProxiesType>(
|
||||
selector: (_, config) => config.proxiesType,
|
||||
selector: (_, config) => config.proxiesStyle.type,
|
||||
builder: (_, proxiesType, __) {
|
||||
final config = globalState.appController.config;
|
||||
return Wrap(
|
||||
@@ -63,7 +71,9 @@ class ProxiesSettingWidget extends StatelessWidget {
|
||||
),
|
||||
isSelected: proxiesType == item,
|
||||
onPressed: () {
|
||||
config.proxiesType = item;
|
||||
config.proxiesStyle = config.proxiesStyle.copyWith(
|
||||
type: item,
|
||||
);
|
||||
},
|
||||
)
|
||||
],
|
||||
@@ -83,7 +93,7 @@ class ProxiesSettingWidget extends StatelessWidget {
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Selector<Config, ProxiesSortType>(
|
||||
selector: (_, config) => config.proxiesSortType,
|
||||
selector: (_, config) => config.proxiesStyle.sortType,
|
||||
builder: (_, proxiesSortType, __) {
|
||||
final config = globalState.appController.config;
|
||||
return Wrap(
|
||||
@@ -97,7 +107,9 @@ class ProxiesSettingWidget extends StatelessWidget {
|
||||
),
|
||||
isSelected: proxiesSortType == item,
|
||||
onPressed: () {
|
||||
config.proxiesSortType = item;
|
||||
config.proxiesStyle = config.proxiesStyle.copyWith(
|
||||
sortType: item,
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
@@ -117,7 +129,7 @@ class ProxiesSettingWidget extends StatelessWidget {
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Selector<Config, ProxyCardType>(
|
||||
selector: (_, config) => config.proxyCardType,
|
||||
selector: (_, config) => config.proxiesStyle.cardType,
|
||||
builder: (_, proxyCardType, __) {
|
||||
final config = globalState.appController.config;
|
||||
return Wrap(
|
||||
@@ -128,7 +140,9 @@ class ProxiesSettingWidget extends StatelessWidget {
|
||||
Intl.message(item.name),
|
||||
isSelected: item == proxyCardType,
|
||||
onPressed: () {
|
||||
config.proxyCardType = item;
|
||||
config.proxiesStyle = config.proxiesStyle.copyWith(
|
||||
cardType: item,
|
||||
);
|
||||
},
|
||||
)
|
||||
],
|
||||
@@ -149,8 +163,8 @@ class ProxiesSettingWidget extends StatelessWidget {
|
||||
horizontal: 16,
|
||||
),
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Selector< Config, ProxiesLayout>(
|
||||
selector: (_, config) => config.proxiesLayout,
|
||||
child: Selector<Config, ProxiesLayout>(
|
||||
selector: (_, config) => config.proxiesStyle.layout,
|
||||
builder: (_, proxiesLayout, __) {
|
||||
final config = globalState.appController.config;
|
||||
return Wrap(
|
||||
@@ -161,7 +175,9 @@ class ProxiesSettingWidget extends StatelessWidget {
|
||||
getTextForProxiesLayout(item),
|
||||
isSelected: item == proxiesLayout,
|
||||
onPressed: () {
|
||||
config.proxiesLayout = item;
|
||||
config.proxiesStyle = config.proxiesStyle.copyWith(
|
||||
layout: item,
|
||||
);
|
||||
},
|
||||
)
|
||||
],
|
||||
@@ -173,6 +189,39 @@ class ProxiesSettingWidget extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
_buildGroupStyleSetting() {
|
||||
return generateSection(
|
||||
title: "图标样式",
|
||||
items: [
|
||||
SingleChildScrollView(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Selector<Config, ProxiesIconStyle>(
|
||||
selector: (_, config) => config.proxiesStyle.iconStyle,
|
||||
builder: (_, iconStyle, __) {
|
||||
return Wrap(
|
||||
spacing: 16,
|
||||
children: [
|
||||
for (final item in ProxiesIconStyle.values)
|
||||
SettingTextCard(
|
||||
_getTextWithProxiesIconStyle(item),
|
||||
isSelected: iconStyle == item,
|
||||
onPressed: () {
|
||||
final config = globalState.appController.config;
|
||||
config.proxiesStyle = config.proxiesStyle.copyWith(
|
||||
iconStyle: item,
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
@@ -185,6 +234,22 @@ class ProxiesSettingWidget extends StatelessWidget {
|
||||
..._buildSortSetting(),
|
||||
..._buildLayoutSetting(),
|
||||
..._buildSizeSetting(),
|
||||
Selector<Config, bool>(
|
||||
selector: (_, config) =>
|
||||
config.proxiesStyle.type == ProxiesType.list,
|
||||
builder: (_, value, child) {
|
||||
if (value) {
|
||||
return child!;
|
||||
}
|
||||
return Container();
|
||||
},
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
..._buildGroupStyleSetting(),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:fl_clash/common/common.dart';
|
||||
import 'package:fl_clash/enum/enum.dart';
|
||||
import 'package:fl_clash/models/models.dart';
|
||||
@@ -120,8 +118,7 @@ class ProxiesTabFragmentState extends State<ProxiesTabFragment>
|
||||
);
|
||||
},
|
||||
shouldRebuild: (prev, next) {
|
||||
if (!const ListEquality<String>()
|
||||
.equals(prev.groupNames, next.groupNames)) {
|
||||
if (!stringListEquality.equals(prev.groupNames, next.groupNames)) {
|
||||
_tabController?.dispose();
|
||||
_tabController = null;
|
||||
return true;
|
||||
@@ -287,11 +284,11 @@ class ProxyGroupViewState extends State<ProxyGroupView> {
|
||||
selector: (_, appState, config) {
|
||||
final group = appState.getGroupWithName(groupName)!;
|
||||
return ProxyGroupSelectorState(
|
||||
proxyCardType: config.proxyCardType,
|
||||
proxiesSortType: config.proxiesSortType,
|
||||
proxyCardType: config.proxiesStyle.cardType,
|
||||
proxiesSortType: config.proxiesStyle.sortType,
|
||||
columns: other.getProxiesColumns(
|
||||
appState.viewWidth,
|
||||
config.proxiesLayout,
|
||||
config.proxiesStyle.layout,
|
||||
),
|
||||
sortNum: appState.sortNum,
|
||||
proxies: group.all,
|
||||
@@ -314,33 +311,31 @@ class ProxyGroupViewState extends State<ProxyGroupView> {
|
||||
},
|
||||
child: Align(
|
||||
alignment: Alignment.topCenter,
|
||||
child: ScaleBuilder(
|
||||
builder: (_) => GridView.builder(
|
||||
controller: _controller,
|
||||
padding: const EdgeInsets.only(
|
||||
top: 16,
|
||||
left: 16,
|
||||
right: 16,
|
||||
bottom: 80,
|
||||
),
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: columns,
|
||||
mainAxisSpacing: 8,
|
||||
crossAxisSpacing: 8,
|
||||
mainAxisExtent: getItemHeight(proxyCardType),
|
||||
),
|
||||
itemCount: sortedProxies.length,
|
||||
itemBuilder: (_, index) {
|
||||
final proxy = sortedProxies[index];
|
||||
return ProxyCard(
|
||||
groupType: state.groupType,
|
||||
type: proxyCardType,
|
||||
key: ValueKey('$groupName.${proxy.name}'),
|
||||
proxy: proxy,
|
||||
groupName: groupName,
|
||||
);
|
||||
},
|
||||
child: GridView.builder(
|
||||
controller: _controller,
|
||||
padding: const EdgeInsets.only(
|
||||
top: 16,
|
||||
left: 16,
|
||||
right: 16,
|
||||
bottom: 96,
|
||||
),
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: columns,
|
||||
mainAxisSpacing: 8,
|
||||
crossAxisSpacing: 8,
|
||||
mainAxisExtent: getItemHeight(proxyCardType),
|
||||
),
|
||||
itemCount: sortedProxies.length,
|
||||
itemBuilder: (_, index) {
|
||||
final proxy = sortedProxies[index];
|
||||
return ProxyCard(
|
||||
groupType: state.groupType,
|
||||
type: proxyCardType,
|
||||
key: ValueKey('$groupName.${proxy.name}'),
|
||||
proxy: proxy,
|
||||
groupName: groupName,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'dart:io';
|
||||
import 'package:fl_clash/common/common.dart';
|
||||
import 'package:fl_clash/enum/enum.dart';
|
||||
import 'package:fl_clash/models/models.dart';
|
||||
@@ -37,8 +36,11 @@ class _RequestsFragmentState extends State<RequestsFragment> {
|
||||
timer = null;
|
||||
}
|
||||
timer = Timer.periodic(const Duration(milliseconds: 200), (timer) {
|
||||
final requests = appState.requests;
|
||||
if (!const ListEquality<Connection>().equals(
|
||||
final maxLength = Platform.isAndroid ? 1000 : 60;
|
||||
final requests = appState.requests.safeSublist(
|
||||
appState.requests.length - maxLength,
|
||||
);
|
||||
if (!connectionListEquality.equals(
|
||||
requestsNotifier.value.connections,
|
||||
requests,
|
||||
)) {
|
||||
|
||||
@@ -70,7 +70,7 @@ class _ToolboxFragmentState extends State<ToolsFragment> {
|
||||
final isDisclaimerAccepted =
|
||||
await globalState.appController.showDisclaimer();
|
||||
if (!isDisclaimerAccepted) {
|
||||
system.exit();
|
||||
globalState.appController.handleExit();
|
||||
}
|
||||
},
|
||||
),
|
||||
@@ -91,7 +91,7 @@ class _ToolboxFragmentState extends State<ToolsFragment> {
|
||||
title: appLocalizations.settings,
|
||||
items: [
|
||||
Selector<Config, String?>(
|
||||
selector: (_, config) => config.locale,
|
||||
selector: (_, config) => config.appSetting.locale,
|
||||
builder: (_, localeString, __) {
|
||||
final subTitle = localeString ?? appLocalizations.defaultText;
|
||||
final currentLocale = other.getLocaleForString(localeString);
|
||||
@@ -103,8 +103,10 @@ class _ToolboxFragmentState extends State<ToolsFragment> {
|
||||
title: appLocalizations.language,
|
||||
options: [null, ...AppLocalizations.delegate.supportedLocales],
|
||||
onChanged: (Locale? value) {
|
||||
final config = context.read<Config>();
|
||||
config.locale = value?.toString();
|
||||
final config = globalState.appController.config;
|
||||
config.appSetting = config.appSetting.copyWith(
|
||||
locale: value?.toString(),
|
||||
);
|
||||
},
|
||||
textBuilder: (locale) => _getLocaleString(locale),
|
||||
value: currentLocale,
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
"tunDesc": "only effective in administrator mode",
|
||||
"minimizeOnExit": "Minimize on exit",
|
||||
"minimizeOnExitDesc": "Modify the default system exit event",
|
||||
"autoLaunch": "AutoLaunch",
|
||||
"autoLaunch": "Auto launch",
|
||||
"autoLaunchDesc": "Follow the system self startup",
|
||||
"silentLaunch": "SilentLaunch",
|
||||
"silentLaunchDesc": "Start in the background",
|
||||
@@ -123,7 +123,7 @@
|
||||
"tabAnimation": "Tab animation",
|
||||
"tabAnimationDesc": "When enabled, the home tab will add a toggle animation",
|
||||
"desc": "A multi-platform proxy client based on ClashMeta, simple and easy to use, open-source and ad-free.",
|
||||
"startVpn": "Staring VPN...",
|
||||
"startVpn": "Starting VPN...",
|
||||
"stopVpn": "Stopping VPN...",
|
||||
"discovery": "Discovery a new version",
|
||||
"compatible": "Compatibility mode",
|
||||
@@ -250,8 +250,7 @@
|
||||
"dnsDesc": "Update DNS related settings",
|
||||
"key": "Key",
|
||||
"value": "Value",
|
||||
"keyNotEmpty": "The key cannot be empty",
|
||||
"valueNotEmpty": "The value cannot be empty",
|
||||
"notEmpty": "Cannot be empty",
|
||||
"hostsDesc": "Add Hosts",
|
||||
"vpnTip": "Changes take effect after restarting the VPN",
|
||||
"vpnEnableDesc": "Auto routes all system traffic through VpnService",
|
||||
@@ -287,7 +286,6 @@
|
||||
"geoipCode": "Geoip code",
|
||||
"ipcidr": "Ipcidr",
|
||||
"domain": "Domain",
|
||||
"resetDns": "Reset Dns",
|
||||
"reset": "Reset",
|
||||
"action_view": "Show/Hide",
|
||||
"action_start": "Start/Stop",
|
||||
@@ -303,5 +301,24 @@
|
||||
"inputCorrectHotkey": "Please enter the correct hotkey",
|
||||
"hotkeyConflict": "Hotkey conflict",
|
||||
"remove": "Remove",
|
||||
"noHotKey": "No HotKey"
|
||||
"noHotKey": "No HotKey",
|
||||
"noNetwork": "No network",
|
||||
"ipv6InboundDesc": "Allow IPv6 inbound",
|
||||
"exportLogs": "Export logs",
|
||||
"exportSuccess": "Export Success",
|
||||
"iconStyle": "Icon style",
|
||||
"onlyIcon": "Icon",
|
||||
"noIcon": "None",
|
||||
"stackMode": "Stack mode",
|
||||
"network": "Network",
|
||||
"networkDesc": "Modify network-related settings",
|
||||
"bypassDomain": "Bypass domain",
|
||||
"bypassDomainDesc": "Only takes effect when the system proxy is enabled",
|
||||
"resetTip": "Make sure to reset",
|
||||
"regExp": "RegExp",
|
||||
"icon": "Icon",
|
||||
"iconConfiguration": "Icon configuration",
|
||||
"noData": "No data",
|
||||
"adminAutoLaunch": "Admin auto launch",
|
||||
"adminAutoLaunchDesc": "Boot up by using admin mode"
|
||||
}
|
||||
@@ -250,8 +250,7 @@
|
||||
"dnsDesc": "更新DNS相关设置",
|
||||
"key": "键",
|
||||
"value": "值",
|
||||
"keyNotEmpty": "键不能为空",
|
||||
"valueNotEmpty": "值不能为空",
|
||||
"notEmpty": "不能为空",
|
||||
"hostsDesc": "追加Hosts",
|
||||
"vpnTip": "重启VPN后改变生效",
|
||||
"vpnEnableDesc": "通过VpnService自动路由系统所有流量",
|
||||
@@ -287,7 +286,6 @@
|
||||
"geoipCode": "Geoip代码",
|
||||
"ipcidr": "IP/掩码",
|
||||
"domain": "域名",
|
||||
"resetDns": "重置DNS",
|
||||
"reset": "重置",
|
||||
"action_view": "显示/隐藏",
|
||||
"action_start": "启动/停止",
|
||||
@@ -303,5 +301,24 @@
|
||||
"inputCorrectHotkey": "请输入正确的快捷键",
|
||||
"hotkeyConflict": "快捷键冲突",
|
||||
"remove": "移除",
|
||||
"noHotKey": "暂无快捷键"
|
||||
"noHotKey": "暂无快捷键",
|
||||
"noNetwork": "无网络",
|
||||
"ipv6InboundDesc": "允许IPv6入站",
|
||||
"exportLogs": "导出日志",
|
||||
"exportSuccess": "导出成功",
|
||||
"iconStyle": "图标样式",
|
||||
"onlyIcon": "仅图标",
|
||||
"noIcon": "无图标",
|
||||
"stackMode": "栈模式",
|
||||
"network": "网络",
|
||||
"networkDesc": "修改网络相关设置",
|
||||
"bypassDomain": "排除域名",
|
||||
"bypassDomainDesc": "仅在系统代理启用时生效",
|
||||
"resetTip": "确定要重置吗?",
|
||||
"regExp": "正则",
|
||||
"icon": "图片",
|
||||
"iconConfiguration": "图片配置",
|
||||
"noData": "暂无数据",
|
||||
"adminAutoLaunch": "管理员自启动",
|
||||
"adminAutoLaunchDesc": "使用管理员模式开机自启动"
|
||||
}
|
||||
@@ -45,6 +45,10 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
MessageLookupByLibrary.simpleMessage("WebDAV server address"),
|
||||
"addressTip": MessageLookupByLibrary.simpleMessage(
|
||||
"Please enter a valid WebDAV address"),
|
||||
"adminAutoLaunch":
|
||||
MessageLookupByLibrary.simpleMessage("Admin auto launch"),
|
||||
"adminAutoLaunchDesc":
|
||||
MessageLookupByLibrary.simpleMessage("Boot up by using admin mode"),
|
||||
"ago": MessageLookupByLibrary.simpleMessage(" Ago"),
|
||||
"agree": MessageLookupByLibrary.simpleMessage("Agree"),
|
||||
"allApps": MessageLookupByLibrary.simpleMessage("All apps"),
|
||||
@@ -72,7 +76,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
MessageLookupByLibrary.simpleMessage("Auto lose connections"),
|
||||
"autoCloseConnectionsDesc": MessageLookupByLibrary.simpleMessage(
|
||||
"Auto close connections after change node"),
|
||||
"autoLaunch": MessageLookupByLibrary.simpleMessage("AutoLaunch"),
|
||||
"autoLaunch": MessageLookupByLibrary.simpleMessage("Auto launch"),
|
||||
"autoLaunchDesc": MessageLookupByLibrary.simpleMessage(
|
||||
"Follow the system self startup"),
|
||||
"autoRun": MessageLookupByLibrary.simpleMessage("AutoRun"),
|
||||
@@ -89,6 +93,9 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"backupSuccess": MessageLookupByLibrary.simpleMessage("Backup success"),
|
||||
"bind": MessageLookupByLibrary.simpleMessage("Bind"),
|
||||
"blacklistMode": MessageLookupByLibrary.simpleMessage("Blacklist mode"),
|
||||
"bypassDomain": MessageLookupByLibrary.simpleMessage("Bypass domain"),
|
||||
"bypassDomainDesc": MessageLookupByLibrary.simpleMessage(
|
||||
"Only takes effect when the system proxy is enabled"),
|
||||
"cancelFilterSystemApp":
|
||||
MessageLookupByLibrary.simpleMessage("Cancel filter system app"),
|
||||
"cancelSelectAll":
|
||||
@@ -161,6 +168,8 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"expand": MessageLookupByLibrary.simpleMessage("Standard"),
|
||||
"expirationTime":
|
||||
MessageLookupByLibrary.simpleMessage("Expiration time"),
|
||||
"exportLogs": MessageLookupByLibrary.simpleMessage("Export logs"),
|
||||
"exportSuccess": MessageLookupByLibrary.simpleMessage("Export Success"),
|
||||
"externalController":
|
||||
MessageLookupByLibrary.simpleMessage("ExternalController"),
|
||||
"externalControllerDesc": MessageLookupByLibrary.simpleMessage(
|
||||
@@ -204,6 +213,10 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"hotkeyManagementDesc": MessageLookupByLibrary.simpleMessage(
|
||||
"Use keyboard to control applications"),
|
||||
"hours": MessageLookupByLibrary.simpleMessage("Hours"),
|
||||
"icon": MessageLookupByLibrary.simpleMessage("Icon"),
|
||||
"iconConfiguration":
|
||||
MessageLookupByLibrary.simpleMessage("Icon configuration"),
|
||||
"iconStyle": MessageLookupByLibrary.simpleMessage("Icon style"),
|
||||
"importFromURL":
|
||||
MessageLookupByLibrary.simpleMessage("Import from URL"),
|
||||
"infiniteTime":
|
||||
@@ -217,12 +230,12 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"ipcidr": MessageLookupByLibrary.simpleMessage("Ipcidr"),
|
||||
"ipv6Desc": MessageLookupByLibrary.simpleMessage(
|
||||
"When turned on it will be able to receive IPv6 traffic"),
|
||||
"ipv6InboundDesc":
|
||||
MessageLookupByLibrary.simpleMessage("Allow IPv6 inbound"),
|
||||
"just": MessageLookupByLibrary.simpleMessage("Just"),
|
||||
"keepAliveIntervalDesc":
|
||||
MessageLookupByLibrary.simpleMessage("Tcp keep alive interval"),
|
||||
"key": MessageLookupByLibrary.simpleMessage("Key"),
|
||||
"keyNotEmpty":
|
||||
MessageLookupByLibrary.simpleMessage("The key cannot be empty"),
|
||||
"language": MessageLookupByLibrary.simpleMessage("Language"),
|
||||
"layout": MessageLookupByLibrary.simpleMessage("Layout"),
|
||||
"light": MessageLookupByLibrary.simpleMessage("Light"),
|
||||
@@ -261,15 +274,22 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
MessageLookupByLibrary.simpleMessage("Nameserver policy"),
|
||||
"nameserverPolicyDesc": MessageLookupByLibrary.simpleMessage(
|
||||
"Specify the corresponding nameserver policy"),
|
||||
"network": MessageLookupByLibrary.simpleMessage("Network"),
|
||||
"networkDesc": MessageLookupByLibrary.simpleMessage(
|
||||
"Modify network-related settings"),
|
||||
"networkDetection":
|
||||
MessageLookupByLibrary.simpleMessage("Network detection"),
|
||||
"networkSpeed": MessageLookupByLibrary.simpleMessage("Network speed"),
|
||||
"noData": MessageLookupByLibrary.simpleMessage("No data"),
|
||||
"noHotKey": MessageLookupByLibrary.simpleMessage("No HotKey"),
|
||||
"noIcon": MessageLookupByLibrary.simpleMessage("None"),
|
||||
"noInfo": MessageLookupByLibrary.simpleMessage("No info"),
|
||||
"noMoreInfoDesc": MessageLookupByLibrary.simpleMessage("No more info"),
|
||||
"noNetwork": MessageLookupByLibrary.simpleMessage("No network"),
|
||||
"noProxy": MessageLookupByLibrary.simpleMessage("No proxy"),
|
||||
"noProxyDesc": MessageLookupByLibrary.simpleMessage(
|
||||
"Please create a profile or add a valid profile"),
|
||||
"notEmpty": MessageLookupByLibrary.simpleMessage("Cannot be empty"),
|
||||
"notSelectedTip": MessageLookupByLibrary.simpleMessage(
|
||||
"The current proxy group cannot be selected."),
|
||||
"nullConnectionsDesc":
|
||||
@@ -281,6 +301,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"No profile, Please add a profile"),
|
||||
"nullRequestsDesc": MessageLookupByLibrary.simpleMessage("No requests"),
|
||||
"oneColumn": MessageLookupByLibrary.simpleMessage("One column"),
|
||||
"onlyIcon": MessageLookupByLibrary.simpleMessage("Icon"),
|
||||
"onlyOtherApps":
|
||||
MessageLookupByLibrary.simpleMessage("Only third-party apps"),
|
||||
"onlyStatisticsProxy":
|
||||
@@ -358,6 +379,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
MessageLookupByLibrary.simpleMessage("Only recovery profiles"),
|
||||
"recoverySuccess":
|
||||
MessageLookupByLibrary.simpleMessage("Recovery success"),
|
||||
"regExp": MessageLookupByLibrary.simpleMessage("RegExp"),
|
||||
"remote": MessageLookupByLibrary.simpleMessage("Remote"),
|
||||
"remoteBackupDesc":
|
||||
MessageLookupByLibrary.simpleMessage("Backup local data to WebDAV"),
|
||||
@@ -368,7 +390,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"requestsDesc": MessageLookupByLibrary.simpleMessage(
|
||||
"View recently request records"),
|
||||
"reset": MessageLookupByLibrary.simpleMessage("Reset"),
|
||||
"resetDns": MessageLookupByLibrary.simpleMessage("Reset Dns"),
|
||||
"resetTip": MessageLookupByLibrary.simpleMessage("Make sure to reset"),
|
||||
"resources": MessageLookupByLibrary.simpleMessage("Resources"),
|
||||
"resourcesDesc": MessageLookupByLibrary.simpleMessage(
|
||||
"External resource related info"),
|
||||
@@ -391,9 +413,10 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"size": MessageLookupByLibrary.simpleMessage("Size"),
|
||||
"sort": MessageLookupByLibrary.simpleMessage("Sort"),
|
||||
"source": MessageLookupByLibrary.simpleMessage("Source"),
|
||||
"stackMode": MessageLookupByLibrary.simpleMessage("Stack mode"),
|
||||
"standard": MessageLookupByLibrary.simpleMessage("Standard"),
|
||||
"start": MessageLookupByLibrary.simpleMessage("Start"),
|
||||
"startVpn": MessageLookupByLibrary.simpleMessage("Staring VPN..."),
|
||||
"startVpn": MessageLookupByLibrary.simpleMessage("Starting VPN..."),
|
||||
"status": MessageLookupByLibrary.simpleMessage("Status"),
|
||||
"statusDesc": MessageLookupByLibrary.simpleMessage(
|
||||
"System DNS will be used when turned off"),
|
||||
@@ -444,8 +467,6 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"useSystemHosts":
|
||||
MessageLookupByLibrary.simpleMessage("Use system hosts"),
|
||||
"value": MessageLookupByLibrary.simpleMessage("Value"),
|
||||
"valueNotEmpty":
|
||||
MessageLookupByLibrary.simpleMessage("The value cannot be empty"),
|
||||
"view": MessageLookupByLibrary.simpleMessage("View"),
|
||||
"vpnDesc":
|
||||
MessageLookupByLibrary.simpleMessage("Modify VPN related settings"),
|
||||
|
||||
@@ -41,6 +41,9 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"address": MessageLookupByLibrary.simpleMessage("地址"),
|
||||
"addressHelp": MessageLookupByLibrary.simpleMessage("WebDAV服务器地址"),
|
||||
"addressTip": MessageLookupByLibrary.simpleMessage("请输入有效的WebDAV地址"),
|
||||
"adminAutoLaunch": MessageLookupByLibrary.simpleMessage("管理员自启动"),
|
||||
"adminAutoLaunchDesc":
|
||||
MessageLookupByLibrary.simpleMessage("使用管理员模式开机自启动"),
|
||||
"ago": MessageLookupByLibrary.simpleMessage("前"),
|
||||
"agree": MessageLookupByLibrary.simpleMessage("同意"),
|
||||
"allApps": MessageLookupByLibrary.simpleMessage("所有应用"),
|
||||
@@ -75,6 +78,8 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"backupSuccess": MessageLookupByLibrary.simpleMessage("备份成功"),
|
||||
"bind": MessageLookupByLibrary.simpleMessage("绑定"),
|
||||
"blacklistMode": MessageLookupByLibrary.simpleMessage("黑名单模式"),
|
||||
"bypassDomain": MessageLookupByLibrary.simpleMessage("排除域名"),
|
||||
"bypassDomainDesc": MessageLookupByLibrary.simpleMessage("仅在系统代理启用时生效"),
|
||||
"cancelFilterSystemApp":
|
||||
MessageLookupByLibrary.simpleMessage("取消过滤系统应用"),
|
||||
"cancelSelectAll": MessageLookupByLibrary.simpleMessage("取消全选"),
|
||||
@@ -132,6 +137,8 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"exit": MessageLookupByLibrary.simpleMessage("退出"),
|
||||
"expand": MessageLookupByLibrary.simpleMessage("标准"),
|
||||
"expirationTime": MessageLookupByLibrary.simpleMessage("到期时间"),
|
||||
"exportLogs": MessageLookupByLibrary.simpleMessage("导出日志"),
|
||||
"exportSuccess": MessageLookupByLibrary.simpleMessage("导出成功"),
|
||||
"externalController": MessageLookupByLibrary.simpleMessage("外部控制器"),
|
||||
"externalControllerDesc":
|
||||
MessageLookupByLibrary.simpleMessage("开启后将可以通过9090端口控制Clash内核"),
|
||||
@@ -165,6 +172,9 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"hotkeyManagementDesc":
|
||||
MessageLookupByLibrary.simpleMessage("使用键盘控制应用程序"),
|
||||
"hours": MessageLookupByLibrary.simpleMessage("小时"),
|
||||
"icon": MessageLookupByLibrary.simpleMessage("图片"),
|
||||
"iconConfiguration": MessageLookupByLibrary.simpleMessage("图片配置"),
|
||||
"iconStyle": MessageLookupByLibrary.simpleMessage("图标样式"),
|
||||
"importFromURL": MessageLookupByLibrary.simpleMessage("从URL导入"),
|
||||
"infiniteTime": MessageLookupByLibrary.simpleMessage("长期有效"),
|
||||
"init": MessageLookupByLibrary.simpleMessage("初始化"),
|
||||
@@ -173,11 +183,11 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"intranetIP": MessageLookupByLibrary.simpleMessage("内网 IP"),
|
||||
"ipcidr": MessageLookupByLibrary.simpleMessage("IP/掩码"),
|
||||
"ipv6Desc": MessageLookupByLibrary.simpleMessage("开启后将可以接收IPv6流量"),
|
||||
"ipv6InboundDesc": MessageLookupByLibrary.simpleMessage("允许IPv6入站"),
|
||||
"just": MessageLookupByLibrary.simpleMessage("刚刚"),
|
||||
"keepAliveIntervalDesc":
|
||||
MessageLookupByLibrary.simpleMessage("TCP保持活动间隔"),
|
||||
"key": MessageLookupByLibrary.simpleMessage("键"),
|
||||
"keyNotEmpty": MessageLookupByLibrary.simpleMessage("键不能为空"),
|
||||
"language": MessageLookupByLibrary.simpleMessage("语言"),
|
||||
"layout": MessageLookupByLibrary.simpleMessage("布局"),
|
||||
"light": MessageLookupByLibrary.simpleMessage("浅色"),
|
||||
@@ -208,14 +218,20 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"nameserverPolicy": MessageLookupByLibrary.simpleMessage("域名服务器策略"),
|
||||
"nameserverPolicyDesc":
|
||||
MessageLookupByLibrary.simpleMessage("指定对应域名服务器策略"),
|
||||
"network": MessageLookupByLibrary.simpleMessage("网络"),
|
||||
"networkDesc": MessageLookupByLibrary.simpleMessage("修改网络相关设置"),
|
||||
"networkDetection": MessageLookupByLibrary.simpleMessage("网络检测"),
|
||||
"networkSpeed": MessageLookupByLibrary.simpleMessage("网络速度"),
|
||||
"noData": MessageLookupByLibrary.simpleMessage("暂无数据"),
|
||||
"noHotKey": MessageLookupByLibrary.simpleMessage("暂无快捷键"),
|
||||
"noIcon": MessageLookupByLibrary.simpleMessage("无图标"),
|
||||
"noInfo": MessageLookupByLibrary.simpleMessage("暂无信息"),
|
||||
"noMoreInfoDesc": MessageLookupByLibrary.simpleMessage("暂无更多信息"),
|
||||
"noNetwork": MessageLookupByLibrary.simpleMessage("无网络"),
|
||||
"noProxy": MessageLookupByLibrary.simpleMessage("暂无代理"),
|
||||
"noProxyDesc":
|
||||
MessageLookupByLibrary.simpleMessage("请创建配置文件或者添加有效配置文件"),
|
||||
"notEmpty": MessageLookupByLibrary.simpleMessage("不能为空"),
|
||||
"notSelectedTip": MessageLookupByLibrary.simpleMessage("当前代理组无法选中"),
|
||||
"nullConnectionsDesc": MessageLookupByLibrary.simpleMessage("暂无连接"),
|
||||
"nullCoreInfoDesc": MessageLookupByLibrary.simpleMessage("无法获取内核信息"),
|
||||
@@ -224,6 +240,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
MessageLookupByLibrary.simpleMessage("没有配置文件,请先添加配置文件"),
|
||||
"nullRequestsDesc": MessageLookupByLibrary.simpleMessage("暂无请求"),
|
||||
"oneColumn": MessageLookupByLibrary.simpleMessage("一列"),
|
||||
"onlyIcon": MessageLookupByLibrary.simpleMessage("仅图标"),
|
||||
"onlyOtherApps": MessageLookupByLibrary.simpleMessage("仅第三方应用"),
|
||||
"onlyStatisticsProxy": MessageLookupByLibrary.simpleMessage("仅统计代理"),
|
||||
"onlyStatisticsProxyDesc":
|
||||
@@ -281,6 +298,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"recoveryAll": MessageLookupByLibrary.simpleMessage("恢复所有数据"),
|
||||
"recoveryProfiles": MessageLookupByLibrary.simpleMessage("仅恢复配置文件"),
|
||||
"recoverySuccess": MessageLookupByLibrary.simpleMessage("恢复成功"),
|
||||
"regExp": MessageLookupByLibrary.simpleMessage("正则"),
|
||||
"remote": MessageLookupByLibrary.simpleMessage("远程"),
|
||||
"remoteBackupDesc": MessageLookupByLibrary.simpleMessage("备份数据到WebDAV"),
|
||||
"remoteRecoveryDesc":
|
||||
@@ -289,7 +307,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"requests": MessageLookupByLibrary.simpleMessage("请求"),
|
||||
"requestsDesc": MessageLookupByLibrary.simpleMessage("查看最近请求记录"),
|
||||
"reset": MessageLookupByLibrary.simpleMessage("重置"),
|
||||
"resetDns": MessageLookupByLibrary.simpleMessage("重置DNS"),
|
||||
"resetTip": MessageLookupByLibrary.simpleMessage("确定要重置吗?"),
|
||||
"resources": MessageLookupByLibrary.simpleMessage("资源"),
|
||||
"resourcesDesc": MessageLookupByLibrary.simpleMessage("外部资源相关信息"),
|
||||
"respectRules": MessageLookupByLibrary.simpleMessage("遵守规则"),
|
||||
@@ -310,6 +328,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"size": MessageLookupByLibrary.simpleMessage("尺寸"),
|
||||
"sort": MessageLookupByLibrary.simpleMessage("排序"),
|
||||
"source": MessageLookupByLibrary.simpleMessage("来源"),
|
||||
"stackMode": MessageLookupByLibrary.simpleMessage("栈模式"),
|
||||
"standard": MessageLookupByLibrary.simpleMessage("标准"),
|
||||
"start": MessageLookupByLibrary.simpleMessage("启动"),
|
||||
"startVpn": MessageLookupByLibrary.simpleMessage("正在启动VPN..."),
|
||||
@@ -355,7 +374,6 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"useHosts": MessageLookupByLibrary.simpleMessage("使用Hosts"),
|
||||
"useSystemHosts": MessageLookupByLibrary.simpleMessage("使用系统Hosts"),
|
||||
"value": MessageLookupByLibrary.simpleMessage("值"),
|
||||
"valueNotEmpty": MessageLookupByLibrary.simpleMessage("值不能为空"),
|
||||
"view": MessageLookupByLibrary.simpleMessage("查看"),
|
||||
"vpnDesc": MessageLookupByLibrary.simpleMessage("修改VPN相关设置"),
|
||||
"vpnEnableDesc":
|
||||
|
||||
@@ -470,10 +470,10 @@ class AppLocalizations {
|
||||
);
|
||||
}
|
||||
|
||||
/// `AutoLaunch`
|
||||
/// `Auto launch`
|
||||
String get autoLaunch {
|
||||
return Intl.message(
|
||||
'AutoLaunch',
|
||||
'Auto launch',
|
||||
name: 'autoLaunch',
|
||||
desc: '',
|
||||
args: [],
|
||||
@@ -1290,10 +1290,10 @@ class AppLocalizations {
|
||||
);
|
||||
}
|
||||
|
||||
/// `Staring VPN...`
|
||||
/// `Starting VPN...`
|
||||
String get startVpn {
|
||||
return Intl.message(
|
||||
'Staring VPN...',
|
||||
'Starting VPN...',
|
||||
name: 'startVpn',
|
||||
desc: '',
|
||||
args: [],
|
||||
@@ -2560,21 +2560,11 @@ class AppLocalizations {
|
||||
);
|
||||
}
|
||||
|
||||
/// `The key cannot be empty`
|
||||
String get keyNotEmpty {
|
||||
/// `Cannot be empty`
|
||||
String get notEmpty {
|
||||
return Intl.message(
|
||||
'The key cannot be empty',
|
||||
name: 'keyNotEmpty',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `The value cannot be empty`
|
||||
String get valueNotEmpty {
|
||||
return Intl.message(
|
||||
'The value cannot be empty',
|
||||
name: 'valueNotEmpty',
|
||||
'Cannot be empty',
|
||||
name: 'notEmpty',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
@@ -2930,16 +2920,6 @@ class AppLocalizations {
|
||||
);
|
||||
}
|
||||
|
||||
/// `Reset Dns`
|
||||
String get resetDns {
|
||||
return Intl.message(
|
||||
'Reset Dns',
|
||||
name: 'resetDns',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Reset`
|
||||
String get reset {
|
||||
return Intl.message(
|
||||
@@ -3099,6 +3079,196 @@ class AppLocalizations {
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `No network`
|
||||
String get noNetwork {
|
||||
return Intl.message(
|
||||
'No network',
|
||||
name: 'noNetwork',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Allow IPv6 inbound`
|
||||
String get ipv6InboundDesc {
|
||||
return Intl.message(
|
||||
'Allow IPv6 inbound',
|
||||
name: 'ipv6InboundDesc',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Export logs`
|
||||
String get exportLogs {
|
||||
return Intl.message(
|
||||
'Export logs',
|
||||
name: 'exportLogs',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Export Success`
|
||||
String get exportSuccess {
|
||||
return Intl.message(
|
||||
'Export Success',
|
||||
name: 'exportSuccess',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Icon style`
|
||||
String get iconStyle {
|
||||
return Intl.message(
|
||||
'Icon style',
|
||||
name: 'iconStyle',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Icon`
|
||||
String get onlyIcon {
|
||||
return Intl.message(
|
||||
'Icon',
|
||||
name: 'onlyIcon',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `None`
|
||||
String get noIcon {
|
||||
return Intl.message(
|
||||
'None',
|
||||
name: 'noIcon',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Stack mode`
|
||||
String get stackMode {
|
||||
return Intl.message(
|
||||
'Stack mode',
|
||||
name: 'stackMode',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Network`
|
||||
String get network {
|
||||
return Intl.message(
|
||||
'Network',
|
||||
name: 'network',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Modify network-related settings`
|
||||
String get networkDesc {
|
||||
return Intl.message(
|
||||
'Modify network-related settings',
|
||||
name: 'networkDesc',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Bypass domain`
|
||||
String get bypassDomain {
|
||||
return Intl.message(
|
||||
'Bypass domain',
|
||||
name: 'bypassDomain',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Only takes effect when the system proxy is enabled`
|
||||
String get bypassDomainDesc {
|
||||
return Intl.message(
|
||||
'Only takes effect when the system proxy is enabled',
|
||||
name: 'bypassDomainDesc',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Make sure to reset`
|
||||
String get resetTip {
|
||||
return Intl.message(
|
||||
'Make sure to reset',
|
||||
name: 'resetTip',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `RegExp`
|
||||
String get regExp {
|
||||
return Intl.message(
|
||||
'RegExp',
|
||||
name: 'regExp',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Icon`
|
||||
String get icon {
|
||||
return Intl.message(
|
||||
'Icon',
|
||||
name: 'icon',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Icon configuration`
|
||||
String get iconConfiguration {
|
||||
return Intl.message(
|
||||
'Icon configuration',
|
||||
name: 'iconConfiguration',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `No data`
|
||||
String get noData {
|
||||
return Intl.message(
|
||||
'No data',
|
||||
name: 'noData',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Admin auto launch`
|
||||
String get adminAutoLaunch {
|
||||
return Intl.message(
|
||||
'Admin auto launch',
|
||||
name: 'adminAutoLaunch',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Boot up by using admin mode`
|
||||
String get adminAutoLaunchDesc {
|
||||
return Intl.message(
|
||||
'Boot up by using admin mode',
|
||||
name: 'adminAutoLaunchDesc',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class AppLocalizationDelegate extends LocalizationsDelegate<AppLocalizations> {
|
||||
|
||||
@@ -2,7 +2,6 @@ import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:fl_clash/clash/clash.dart';
|
||||
import 'package:fl_clash/common/http.dart';
|
||||
import 'package:fl_clash/plugins/app.dart';
|
||||
import 'package:fl_clash/plugins/tile.dart';
|
||||
import 'package:fl_clash/plugins/vpn.dart';
|
||||
@@ -20,18 +19,16 @@ Future<void> main() async {
|
||||
globalState.packageInfo = await PackageInfo.fromPlatform();
|
||||
final version = await system.version;
|
||||
final config = await preferences.getConfig() ?? Config();
|
||||
globalState.autoRun = config.autoRun;
|
||||
final clashConfig = await preferences.getClashConfig() ?? ClashConfig();
|
||||
await android?.init();
|
||||
await window?.init(config.windowProps, version);
|
||||
final appState = AppState(
|
||||
mode: clashConfig.mode,
|
||||
version: version,
|
||||
isCompatible: config.isCompatible,
|
||||
selectedMap: config.currentSelectedMap,
|
||||
);
|
||||
appState.navigationItems = navigation.getItems(
|
||||
openLogs: config.openLogs,
|
||||
openLogs: config.appSetting.openLogs,
|
||||
hasProxies: false,
|
||||
);
|
||||
await globalState.init(
|
||||
@@ -58,7 +55,6 @@ Future<void> vpnService() async {
|
||||
final clashConfig = await preferences.getClashConfig() ?? ClashConfig();
|
||||
final appState = AppState(
|
||||
mode: clashConfig.mode,
|
||||
isCompatible: config.isCompatible,
|
||||
selectedMap: config.currentSelectedMap,
|
||||
version: version,
|
||||
);
|
||||
@@ -103,7 +99,7 @@ Future<void> vpnService() async {
|
||||
),
|
||||
);
|
||||
final appLocalizations = await AppLocalizations.load(
|
||||
other.getLocaleForString(config.locale) ??
|
||||
other.getLocaleForString(config.appSetting.locale) ??
|
||||
WidgetsBinding.instance.platformDispatcher.locale,
|
||||
);
|
||||
await app?.tip(appLocalizations.startVpn);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'package:fl_clash/models/models.dart';
|
||||
import 'package:fl_clash/plugins/app.dart';
|
||||
import 'package:fl_clash/state.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
@@ -20,39 +19,23 @@ class AndroidManager extends StatefulWidget {
|
||||
class _AndroidContainerState extends State<AndroidManager> {
|
||||
@override
|
||||
void initState() {
|
||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
|
||||
super.initState();
|
||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
|
||||
}
|
||||
|
||||
Widget _excludeContainer(Widget child) {
|
||||
return Selector<Config, bool>(
|
||||
selector: (_, config) => config.isExclude,
|
||||
builder: (_, isExclude, child) {
|
||||
app?.updateExcludeFromRecents(isExclude);
|
||||
selector: (_, config) => config.appSetting.hidden,
|
||||
builder: (_, hidden, child) {
|
||||
app?.updateExcludeFromRecents(hidden);
|
||||
return child!;
|
||||
},
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
|
||||
Widget _systemUiOverlayContainer(Widget child) {
|
||||
return AnnotatedRegion(
|
||||
value: SystemUiOverlayStyle(
|
||||
statusBarColor: Colors.transparent,
|
||||
statusBarIconBrightness: Theme.of(context).brightness == Brightness.dark
|
||||
? Brightness.light
|
||||
: Brightness.dark,
|
||||
systemNavigationBarColor: Colors.transparent,
|
||||
systemNavigationBarDividerColor: Colors.transparent,
|
||||
),
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return _systemUiOverlayContainer(
|
||||
_excludeContainer(widget.child),
|
||||
);
|
||||
return _excludeContainer(widget.child);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,13 +18,14 @@ class AppStateManager extends StatefulWidget {
|
||||
|
||||
class _AppStateManagerState extends State<AppStateManager>
|
||||
with WidgetsBindingObserver {
|
||||
|
||||
_updateNavigationsContainer(Widget child) {
|
||||
return Selector2<AppState, Config, UpdateNavigationsSelector>(
|
||||
selector: (_, appState, config) {
|
||||
final group = appState.currentGroups;
|
||||
final hasProfile = config.profiles.isNotEmpty;
|
||||
return UpdateNavigationsSelector(
|
||||
openLogs: config.openLogs,
|
||||
openLogs: config.appSetting.openLogs,
|
||||
hasProxies: group.isNotEmpty && hasProfile,
|
||||
);
|
||||
},
|
||||
|
||||
@@ -19,9 +19,9 @@ class ClashManager extends StatefulWidget {
|
||||
State<ClashManager> createState() => _ClashContainerState();
|
||||
}
|
||||
|
||||
class _ClashContainerState extends State<ClashManager>
|
||||
with AppMessageListener {
|
||||
class _ClashContainerState extends State<ClashManager> with AppMessageListener {
|
||||
Function? updateClashConfigDebounce;
|
||||
Function? updateDelayDebounce;
|
||||
|
||||
Widget _updateContainer(Widget child) {
|
||||
return Selector2<Config, ClashConfig, ClashConfigState>(
|
||||
@@ -64,12 +64,13 @@ class _ClashContainerState extends State<ClashManager>
|
||||
Widget _updateCoreState(Widget child) {
|
||||
return Selector2<Config, ClashConfig, CoreState>(
|
||||
selector: (_, config, clashConfig) => CoreState(
|
||||
accessControl: config.isAccessControl ? config.accessControl : null,
|
||||
enable: config.vpnProps.enable,
|
||||
accessControl: config.isAccessControl ? config.accessControl : null,
|
||||
ipv6: config.vpnProps.ipv6,
|
||||
allowBypass: config.vpnProps.allowBypass,
|
||||
bypassDomain: config.vpnProps.bypassDomain,
|
||||
systemProxy: config.vpnProps.systemProxy,
|
||||
mixedPort: clashConfig.mixedPort,
|
||||
onlyProxy: config.onlyProxy,
|
||||
onlyProxy: config.appSetting.onlyProxy,
|
||||
currentProfileName:
|
||||
config.currentProfile?.label ?? config.currentProfileId ?? "",
|
||||
),
|
||||
@@ -83,10 +84,6 @@ class _ClashContainerState extends State<ClashManager>
|
||||
|
||||
_changeProfile() async {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||
if (globalState.autoRun) {
|
||||
globalState.autoRun = false;
|
||||
return;
|
||||
}
|
||||
final appController = globalState.appController;
|
||||
appController.appState.delayMap = {};
|
||||
await appController.applyProfile();
|
||||
@@ -132,19 +129,29 @@ class _ClashContainerState extends State<ClashManager>
|
||||
final appController = globalState.appController;
|
||||
appController.setDelay(delay);
|
||||
super.onDelay(delay);
|
||||
await globalState.appController.updateGroupDebounce();
|
||||
updateDelayDebounce ??= debounce(() async {
|
||||
await appController.updateGroupDebounce();
|
||||
await appController.addCheckIpNumDebounce();
|
||||
}, milliseconds: 5000);
|
||||
updateDelayDebounce!();
|
||||
}
|
||||
|
||||
@override
|
||||
void onLog(Log log) {
|
||||
globalState.appController.appState.addLog(log);
|
||||
globalState.appController.appFlowingState.addLog(log);
|
||||
if (log.logLevel == LogLevel.error) {
|
||||
globalState.appController.showSnackBar(log.payload ?? '');
|
||||
}
|
||||
debugPrint("$log");
|
||||
// debugPrint("$log");
|
||||
super.onLog(log);
|
||||
}
|
||||
|
||||
@override
|
||||
void onStarted(String runTime) {
|
||||
super.onStarted(runTime);
|
||||
globalState.appController.applyProfileDebounce();
|
||||
}
|
||||
|
||||
@override
|
||||
void onRequest(Connection connection) async {
|
||||
globalState.appController.appState.addRequest(connection);
|
||||
@@ -159,7 +166,7 @@ class _ClashContainerState extends State<ClashManager>
|
||||
providerName,
|
||||
),
|
||||
);
|
||||
appController.addCheckIpNumDebounce();
|
||||
// appController.addCheckIpNumDebounce();
|
||||
super.onLoaded(providerName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:fl_clash/common/common.dart';
|
||||
import 'package:fl_clash/enum/enum.dart';
|
||||
import 'package:fl_clash/models/common.dart';
|
||||
import 'package:fl_clash/models/config.dart';
|
||||
@@ -63,7 +64,7 @@ class HotKeyManager extends StatelessWidget {
|
||||
return Selector<Config, List<HotKeyAction>>(
|
||||
selector: (_, config) => config.hotKeyActions,
|
||||
shouldRebuild: (prev, next) {
|
||||
return !hotKeyActionsEquality.equals(prev, next);
|
||||
return !hotKeyActionListEquality.equals(prev, next);
|
||||
},
|
||||
builder: (_, hotKeyActions, __) {
|
||||
_updateHotKeys(hotKeyActions: hotKeyActions);
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import 'package:fl_clash/common/common.dart';
|
||||
import 'package:fl_clash/models/config.dart';
|
||||
import 'package:fl_clash/state.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class MediaManager extends StatelessWidget {
|
||||
final Widget child;
|
||||
@@ -14,28 +12,7 @@ class MediaManager extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Selector<Config, ScaleProps>(
|
||||
selector: (_, config) => config.scaleProps,
|
||||
builder: (_, props, child) {
|
||||
globalState.measure = Measure.of(context);
|
||||
return child!;
|
||||
// final textScaleFactor =
|
||||
// WidgetsBinding.instance.platformDispatcher.textScaleFactor;
|
||||
// return MediaQuery(
|
||||
// data: MediaQuery.of(context).copyWith(
|
||||
// textScaler: props.custom
|
||||
// ? TextScaler.linear(props.scale * textScaleFactor)
|
||||
// : null,
|
||||
// ),
|
||||
// child: Builder(
|
||||
// builder: (context) {
|
||||
// globalState.measure = Measure.of(context);
|
||||
// return child!;
|
||||
// },
|
||||
// ),
|
||||
// );
|
||||
},
|
||||
child: child,
|
||||
);
|
||||
globalState.measure = Measure.of(context);
|
||||
return child;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,9 +21,9 @@ class ProxyManager extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Selector3<AppState, Config, ClashConfig, ProxyState>(
|
||||
selector: (_, appState, config, clashConfig) => ProxyState(
|
||||
isStart: appState.isStart,
|
||||
return Selector3<AppFlowingState, Config, ClashConfig, ProxyState>(
|
||||
selector: (_, appFlowingState, config, clashConfig) => ProxyState(
|
||||
isStart: appFlowingState.isStart,
|
||||
systemProxy: config.desktopProps.systemProxy,
|
||||
port: clashConfig.mixedPort,
|
||||
),
|
||||
|
||||
@@ -42,7 +42,7 @@ class _TrayContainerState extends State<TrayManager> with TrayListener {
|
||||
WidgetsBinding.instance.platformDispatcher.platformBrightness,
|
||||
),
|
||||
);
|
||||
if(!Platform.isLinux){
|
||||
if (!Platform.isLinux) {
|
||||
await trayManager.setToolTip(
|
||||
appName,
|
||||
);
|
||||
@@ -115,7 +115,15 @@ class _TrayContainerState extends State<TrayManager> with TrayListener {
|
||||
},
|
||||
checked: trayState.autoLaunch,
|
||||
);
|
||||
final adminAutoStartMenuItem = MenuItem.checkbox(
|
||||
label: appLocalizations.adminAutoLaunch,
|
||||
onClick: (_) async {
|
||||
globalState.appController.updateAdminAutoLaunch();
|
||||
},
|
||||
checked: trayState.adminAutoLaunch,
|
||||
);
|
||||
menuItems.add(autoStartMenuItem);
|
||||
menuItems.add(adminAutoStartMenuItem);
|
||||
menuItems.add(MenuItem.separator());
|
||||
final exitMenuItem = MenuItem(
|
||||
label: appLocalizations.exit,
|
||||
@@ -138,12 +146,14 @@ class _TrayContainerState extends State<TrayManager> with TrayListener {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Selector3<AppState, Config, ClashConfig, TrayState>(
|
||||
selector: (_, appState, config, clashConfig) => TrayState(
|
||||
return Selector4<AppState, AppFlowingState, Config, ClashConfig, TrayState>(
|
||||
selector: (_, appState, appFlowingState, config, clashConfig) =>
|
||||
TrayState(
|
||||
mode: clashConfig.mode,
|
||||
autoLaunch: config.autoLaunch,
|
||||
isStart: appState.isStart,
|
||||
locale: config.locale,
|
||||
adminAutoLaunch: config.appSetting.adminAutoLaunch,
|
||||
autoLaunch: config.appSetting.autoLaunch,
|
||||
isStart: appFlowingState.isStart,
|
||||
locale: config.appSetting.locale,
|
||||
systemProxy: config.desktopProps.systemProxy,
|
||||
tunEnable: clashConfig.tun.enable,
|
||||
brightness: appState.brightness,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'package:fl_clash/common/app_localizations.dart';
|
||||
import 'package:fl_clash/models/config.dart';
|
||||
import 'package:fl_clash/models/models.dart';
|
||||
import 'package:fl_clash/state.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
@@ -24,8 +24,8 @@ class _VpnContainerState extends State<VpnManager> {
|
||||
showTip() {
|
||||
vpnTipDebounce ??= debounce<Function()>(() async {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
final appState = globalState.appController.appState;
|
||||
if (appState.isStart) {
|
||||
final appFlowingState = globalState.appController.appFlowingState;
|
||||
if (appFlowingState.isStart) {
|
||||
globalState.showSnackBar(
|
||||
context,
|
||||
message: appLocalizations.vpnTip,
|
||||
@@ -38,13 +38,14 @@ class _VpnContainerState extends State<VpnManager> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Selector<Config, VPNState>(
|
||||
selector: (_, config) => VPNState(
|
||||
return Selector2<Config, ClashConfig, VPNState>(
|
||||
selector: (_, config, clashConfig) => VPNState(
|
||||
accessControl: config.accessControl,
|
||||
vpnProps: config.vpnProps,
|
||||
stack: clashConfig.tun.stack,
|
||||
),
|
||||
shouldRebuild: (prev,next){
|
||||
if(prev != next){
|
||||
shouldRebuild: (prev, next) {
|
||||
if (prev != next) {
|
||||
showTip();
|
||||
}
|
||||
return prev != next;
|
||||
|
||||
@@ -23,9 +23,11 @@ class _WindowContainerState extends State<WindowManager> with WindowListener {
|
||||
Function? updateLaunchDebounce;
|
||||
|
||||
_autoLaunchContainer(Widget child) {
|
||||
return Selector2<Config, ClashConfig, AutoLaunchState>(
|
||||
selector: (_, config, clashConfig) => AutoLaunchState(
|
||||
isAutoLaunch: config.autoLaunch, isOpenTun: clashConfig.tun.enable),
|
||||
return Selector<Config, AutoLaunchState>(
|
||||
selector: (_, config) => AutoLaunchState(
|
||||
isAutoLaunch: config.appSetting.autoLaunch,
|
||||
isAdminAutoLaunch: config.appSetting.adminAutoLaunch,
|
||||
),
|
||||
builder: (_, state, child) {
|
||||
updateLaunchDebounce ??= debounce((AutoLaunchState state) {
|
||||
autoLaunch?.updateStatus(state);
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:fl_clash/common/common.dart';
|
||||
import 'package:fl_clash/enum/enum.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -12,19 +9,14 @@ typedef DelayMap = Map<String, int?>;
|
||||
|
||||
class AppState with ChangeNotifier {
|
||||
List<NavigationItem> _navigationItems;
|
||||
int? _runTime;
|
||||
bool _isInit;
|
||||
VersionInfo? _versionInfo;
|
||||
List<Traffic> _traffics;
|
||||
Traffic _totalTraffic;
|
||||
List<Log> _logs;
|
||||
String _currentLabel;
|
||||
SystemColorSchemes _systemColorSchemes;
|
||||
num _sortNum;
|
||||
Mode _mode;
|
||||
DelayMap _delayMap;
|
||||
SelectedMap _selectedMap;
|
||||
bool _isCompatible;
|
||||
List<Group> _groups;
|
||||
double _viewWidth;
|
||||
List<Connection> _requests;
|
||||
@@ -36,27 +28,22 @@ class AppState with ChangeNotifier {
|
||||
|
||||
AppState({
|
||||
required Mode mode,
|
||||
required bool isCompatible,
|
||||
required SelectedMap selectedMap,
|
||||
required int version,
|
||||
}) : _navigationItems = [],
|
||||
_isInit = false,
|
||||
_currentLabel = "dashboard",
|
||||
_traffics = [],
|
||||
_logs = [],
|
||||
_viewWidth = 0,
|
||||
_viewWidth = other.getScreenSize().width,
|
||||
_selectedMap = selectedMap,
|
||||
_sortNum = 0,
|
||||
_checkIpNum = 0,
|
||||
_requests = [],
|
||||
_mode = mode,
|
||||
_brightness = null,
|
||||
_totalTraffic = Traffic(),
|
||||
_delayMap = {},
|
||||
_groups = [],
|
||||
_providers = [],
|
||||
_packages = [],
|
||||
_isCompatible = isCompatible,
|
||||
_systemColorSchemes = const SystemColorSchemes(),
|
||||
_version = version;
|
||||
|
||||
@@ -72,7 +59,7 @@ class AppState with ChangeNotifier {
|
||||
List<NavigationItem> get navigationItems => _navigationItems;
|
||||
|
||||
set navigationItems(List<NavigationItem> value) {
|
||||
if (!const ListEquality<NavigationItem>().equals(_navigationItems, value)) {
|
||||
if (!navigationItemListEquality.equals(_navigationItems, value)) {
|
||||
_navigationItems = value;
|
||||
notifyListeners();
|
||||
}
|
||||
@@ -101,17 +88,6 @@ class AppState with ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
bool get isStart => _runTime != null;
|
||||
|
||||
int? get runTime => _runTime;
|
||||
|
||||
set runTime(int? value) {
|
||||
if (_runTime != value) {
|
||||
_runTime = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
String getDesc(String type, String proxyName) {
|
||||
final groupTypeNamesList = GroupType.values.map((e) => e.name).toList();
|
||||
if (!groupTypeNamesList.contains(type)) {
|
||||
@@ -158,33 +134,6 @@ class AppState with ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
List<Traffic> get traffics => _traffics;
|
||||
|
||||
set traffics(List<Traffic> value) {
|
||||
if (_traffics != value) {
|
||||
_traffics = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
addTraffic(Traffic traffic) {
|
||||
_traffics = List.from(_traffics)..add(traffic);
|
||||
const maxLength = 60;
|
||||
if (_traffics.length > maxLength) {
|
||||
_traffics = _traffics.sublist(_traffics.length - maxLength);
|
||||
}
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Traffic get totalTraffic => _totalTraffic;
|
||||
|
||||
set totalTraffic(Traffic value) {
|
||||
if (_totalTraffic != value) {
|
||||
_totalTraffic = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
List<Connection> get requests => _requests;
|
||||
|
||||
set requests(List<Connection> value) {
|
||||
@@ -196,28 +145,8 @@ class AppState with ChangeNotifier {
|
||||
|
||||
addRequest(Connection value) {
|
||||
_requests = List.from(_requests)..add(value);
|
||||
final maxLength = Platform.isAndroid ? 1000 : 60;
|
||||
if (_requests.length > maxLength) {
|
||||
_requests = _requests.sublist(_requests.length - maxLength);
|
||||
}
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
List<Log> get logs => _logs;
|
||||
|
||||
set logs(List<Log> value) {
|
||||
if (_logs != value) {
|
||||
_logs = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
addLog(Log log) {
|
||||
_logs = List.from(_logs)..add(log);
|
||||
final maxLength = Platform.isAndroid ? 1000 : 60;
|
||||
if (_logs.length > maxLength) {
|
||||
_logs = _logs.sublist(_logs.length - maxLength);
|
||||
}
|
||||
const maxLength = 1000;
|
||||
_requests = _requests.safeSublist(_requests.length - maxLength);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
@@ -233,7 +162,7 @@ class AppState with ChangeNotifier {
|
||||
List<Group> get groups => _groups;
|
||||
|
||||
set groups(List<Group> value) {
|
||||
if (!const ListEquality<Group>().equals(_groups, value)) {
|
||||
if (!groupListEquality.equals(_groups, value)) {
|
||||
_groups = value;
|
||||
notifyListeners();
|
||||
}
|
||||
@@ -266,23 +195,12 @@ class AppState with ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
bool get isCompatible {
|
||||
return _isCompatible;
|
||||
}
|
||||
|
||||
set isCompatible(bool value) {
|
||||
if (_isCompatible != value) {
|
||||
_isCompatible = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
SelectedMap get selectedMap {
|
||||
return _selectedMap;
|
||||
}
|
||||
|
||||
set selectedMap(SelectedMap value) {
|
||||
if (!const MapEquality<String, String>().equals(_selectedMap, value)) {
|
||||
if (!stringAndStringMapEquality.equals(_selectedMap, value)) {
|
||||
_selectedMap = value;
|
||||
notifyListeners();
|
||||
}
|
||||
@@ -320,7 +238,7 @@ class AppState with ChangeNotifier {
|
||||
}
|
||||
|
||||
set delayMap(DelayMap value) {
|
||||
if (!const MapEquality<String, int?>().equals(_delayMap, value)) {
|
||||
if (!stringAndIntQMapEquality.equals(_delayMap, value)) {
|
||||
_delayMap = value;
|
||||
notifyListeners();
|
||||
}
|
||||
@@ -336,7 +254,7 @@ class AppState with ChangeNotifier {
|
||||
List<Package> get packages => _packages;
|
||||
|
||||
set packages(List<Package> value) {
|
||||
if (!const ListEquality<Package>().equals(_packages, value)) {
|
||||
if (!packageListEquality.equals(_packages, value)) {
|
||||
_packages = value;
|
||||
notifyListeners();
|
||||
}
|
||||
@@ -345,7 +263,7 @@ class AppState with ChangeNotifier {
|
||||
List<ExternalProvider> get providers => _providers;
|
||||
|
||||
set providers(List<ExternalProvider> value) {
|
||||
if (!const ListEquality<ExternalProvider>().equals(_providers, value)) {
|
||||
if (!externalProviderListEquality.equals(_providers, value)) {
|
||||
_providers = value;
|
||||
notifyListeners();
|
||||
}
|
||||
@@ -383,3 +301,67 @@ class AppState with ChangeNotifier {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class AppFlowingState with ChangeNotifier {
|
||||
int? _runTime;
|
||||
List<Log> _logs;
|
||||
List<Traffic> _traffics;
|
||||
Traffic _totalTraffic;
|
||||
|
||||
AppFlowingState()
|
||||
: _logs = [],
|
||||
_traffics = [],
|
||||
_totalTraffic = Traffic();
|
||||
|
||||
bool get isStart => _runTime != null;
|
||||
|
||||
int? get runTime => _runTime;
|
||||
|
||||
set runTime(int? value) {
|
||||
if (_runTime != value) {
|
||||
_runTime = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
List<Log> get logs => _logs;
|
||||
|
||||
set logs(List<Log> value) {
|
||||
if (_logs != value) {
|
||||
_logs = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
addLog(Log log) {
|
||||
_logs = List.from(_logs)..add(log);
|
||||
const maxLength = 1000;
|
||||
_logs = _logs.safeSublist(_logs.length - maxLength);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
List<Traffic> get traffics => _traffics;
|
||||
|
||||
set traffics(List<Traffic> value) {
|
||||
if (_traffics != value) {
|
||||
_traffics = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
addTraffic(Traffic traffic) {
|
||||
_traffics = List.from(_traffics)..add(traffic);
|
||||
const maxLength = 60;
|
||||
_traffics = _traffics.safeSublist(_traffics.length - maxLength);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Traffic get totalTraffic => _totalTraffic;
|
||||
|
||||
set totalTraffic(Traffic value) {
|
||||
if (_totalTraffic != value) {
|
||||
_totalTraffic = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
// ignore_for_file: invalid_annotation_target
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:fl_clash/common/common.dart';
|
||||
import 'package:fl_clash/state.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -14,6 +11,8 @@ part 'generated/clash_config.g.dart';
|
||||
|
||||
part 'generated/clash_config.freezed.dart';
|
||||
|
||||
const defaultTun = Tun();
|
||||
|
||||
@freezed
|
||||
class Tun with _$Tun {
|
||||
const factory Tun({
|
||||
@@ -24,6 +23,17 @@ class Tun with _$Tun {
|
||||
}) = _Tun;
|
||||
|
||||
factory Tun.fromJson(Map<String, Object?> json) => _$TunFromJson(json);
|
||||
|
||||
factory Tun.realFromJson(Map<String, Object?>? json) {
|
||||
if (json == null) {
|
||||
return defaultTun;
|
||||
}
|
||||
try {
|
||||
return Tun.fromJson(json);
|
||||
} catch (_) {
|
||||
return defaultTun;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@freezed
|
||||
@@ -45,6 +55,8 @@ class FallbackFilter with _$FallbackFilter {
|
||||
_$FallbackFilterFromJson(json);
|
||||
}
|
||||
|
||||
const defaultDns = Dns();
|
||||
|
||||
@freezed
|
||||
class Dns with _$Dns {
|
||||
const factory Dns({
|
||||
@@ -52,7 +64,7 @@ class Dns with _$Dns {
|
||||
@Default(false) @JsonKey(name: "prefer-h3") bool preferH3,
|
||||
@Default(true) @JsonKey(name: "use-hosts") bool useHosts,
|
||||
@Default(true) @JsonKey(name: "use-system-hosts") bool useSystemHosts,
|
||||
@Default(true) @JsonKey(name: "respect-rules") bool respectRules,
|
||||
@Default(false) @JsonKey(name: "respect-rules") bool respectRules,
|
||||
@Default(false) bool ipv6,
|
||||
@Default(["223.5.5.5"])
|
||||
@JsonKey(name: "default-nameserver")
|
||||
@@ -147,7 +159,7 @@ class ClashConfig extends ChangeNotifier {
|
||||
_geodataLoader = geodataLoaderMemconservative,
|
||||
_externalController = '',
|
||||
_keepAliveInterval = defaultKeepAliveInterval,
|
||||
_dns = const Dns(),
|
||||
_dns = defaultDns,
|
||||
_geoXUrl = defaultGeoXMap,
|
||||
_rules = [],
|
||||
_hosts = {};
|
||||
@@ -263,9 +275,6 @@ class ClashConfig extends ChangeNotifier {
|
||||
}
|
||||
|
||||
Tun get tun {
|
||||
if (Platform.isAndroid) {
|
||||
return _tun.copyWith(enable: false);
|
||||
}
|
||||
return _tun;
|
||||
}
|
||||
|
||||
@@ -318,7 +327,7 @@ class ClashConfig extends ChangeNotifier {
|
||||
GeoXMap get geoXUrl => _geoXUrl;
|
||||
|
||||
set geoXUrl(GeoXMap value) {
|
||||
if (!const MapEquality<String, String>().equals(value, _geoXUrl)) {
|
||||
if (!stringAndStringMapEquality.equals(value, _geoXUrl)) {
|
||||
_geoXUrl = value;
|
||||
notifyListeners();
|
||||
}
|
||||
@@ -328,7 +337,7 @@ class ClashConfig extends ChangeNotifier {
|
||||
HostsMap get hosts => _hosts;
|
||||
|
||||
set hosts(HostsMap value) {
|
||||
if (!const MapEquality<String, String>().equals(value, _hosts)) {
|
||||
if (!stringAndStringMapEquality.equals(value, _hosts)) {
|
||||
_hosts = value;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:fl_clash/common/common.dart';
|
||||
import 'package:fl_clash/enum/enum.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -304,7 +302,7 @@ extension GroupExt on Group {
|
||||
String get realNow => now ?? "";
|
||||
|
||||
String getCurrentSelectedName(String proxyName) {
|
||||
if (type == GroupType.URLTest) {
|
||||
if (type.isURLTestOrFallback) {
|
||||
return realNow.isNotEmpty ? realNow : proxyName;
|
||||
}
|
||||
return proxyName.isNotEmpty ? proxyName : realNow;
|
||||
@@ -433,6 +431,14 @@ class HotKeyAction with _$HotKeyAction {
|
||||
_$HotKeyActionFromJson(json);
|
||||
}
|
||||
|
||||
const keyboardModifiersEquality = SetEquality<KeyboardModifier>();
|
||||
const hotKeyActionsEquality = ListEquality<HotKeyAction>();
|
||||
|
||||
typedef Validator = String? Function(String? value);
|
||||
|
||||
@freezed
|
||||
class Field with _$Field {
|
||||
const factory Field({
|
||||
required String label,
|
||||
required String value,
|
||||
Validator? validator,
|
||||
}) = _Field;
|
||||
}
|
||||
@@ -1,17 +1,49 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:fl_clash/common/common.dart';
|
||||
import 'package:fl_clash/enum/enum.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
import '../enum/enum.dart';
|
||||
import '../common/common.dart';
|
||||
import 'models.dart';
|
||||
|
||||
part 'generated/config.g.dart';
|
||||
|
||||
part 'generated/config.freezed.dart';
|
||||
|
||||
const defaultAppSetting = AppSetting();
|
||||
|
||||
@freezed
|
||||
class AppSetting with _$AppSetting {
|
||||
const factory AppSetting({
|
||||
String? locale,
|
||||
@Default(false) bool onlyProxy,
|
||||
@Default(false) bool autoLaunch,
|
||||
@Default(false) bool adminAutoLaunch,
|
||||
@Default(false) bool silentLaunch,
|
||||
@Default(false) bool autoRun,
|
||||
@Default(false) bool openLogs,
|
||||
@Default(true) bool closeConnections,
|
||||
@Default(defaultTestUrl) String testUrl,
|
||||
@Default(true) bool isAnimateToPage,
|
||||
@Default(true) bool autoCheckUpdate,
|
||||
@Default(false) bool showLabel,
|
||||
@Default(false) bool disclaimerAccepted,
|
||||
@Default(true) bool minimizeOnExit,
|
||||
@Default(false) bool hidden,
|
||||
}) = _AppSetting;
|
||||
|
||||
factory AppSetting.fromJson(Map<String, Object?> json) =>
|
||||
_$AppSettingFromJson(json);
|
||||
|
||||
factory AppSetting.realFromJson(Map<String, Object?>? json) {
|
||||
final appSetting =
|
||||
json == null ? defaultAppSetting : AppSetting.fromJson(json);
|
||||
return appSetting.copyWith(
|
||||
isAnimateToPage: system.isDesktop ? false : true,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@freezed
|
||||
class AccessControl with _$AccessControl {
|
||||
const factory AccessControl({
|
||||
@@ -33,33 +65,6 @@ extension AccessControlExt on AccessControl {
|
||||
};
|
||||
}
|
||||
|
||||
@freezed
|
||||
class CoreState with _$CoreState {
|
||||
const factory CoreState({
|
||||
AccessControl? accessControl,
|
||||
required String currentProfileName,
|
||||
required bool enable,
|
||||
required bool allowBypass,
|
||||
required bool systemProxy,
|
||||
required int mixedPort,
|
||||
required bool onlyProxy,
|
||||
}) = _CoreState;
|
||||
|
||||
factory CoreState.fromJson(Map<String, Object?> json) =>
|
||||
_$CoreStateFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
class VPNState with _$VPNState {
|
||||
const factory VPNState({
|
||||
required AccessControl? accessControl,
|
||||
required VpnProps vpnProps,
|
||||
}) = _VPNState;
|
||||
|
||||
factory VPNState.fromJson(Map<String, Object?> json) =>
|
||||
_$VPNStateFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
class WindowProps with _$WindowProps {
|
||||
const factory WindowProps({
|
||||
@@ -73,12 +78,36 @@ class WindowProps with _$WindowProps {
|
||||
json == null ? const WindowProps() : _$WindowPropsFromJson(json);
|
||||
}
|
||||
|
||||
const defaultBypassDomain = [
|
||||
"*zhihu.com",
|
||||
"*zhimg.com",
|
||||
"*jd.com",
|
||||
"100ime-iat-api.xfyun.cn",
|
||||
"*360buyimg.com",
|
||||
"localhost",
|
||||
"*.local",
|
||||
"127.*",
|
||||
"10.*",
|
||||
"172.16.*",
|
||||
"172.17.*",
|
||||
"172.18.*",
|
||||
"172.19.*",
|
||||
"172.2*",
|
||||
"172.30.*",
|
||||
"172.31.*",
|
||||
"192.168.*"
|
||||
];
|
||||
|
||||
const defaultVpnProps = VpnProps();
|
||||
|
||||
@freezed
|
||||
class VpnProps with _$VpnProps {
|
||||
const factory VpnProps({
|
||||
@Default(true) bool enable,
|
||||
@Default(false) bool systemProxy,
|
||||
@Default(true) bool systemProxy,
|
||||
@Default(false) bool ipv6,
|
||||
@Default(true) bool allowBypass,
|
||||
@Default(defaultBypassDomain) List<String> bypassDomain,
|
||||
}) = _VpnProps;
|
||||
|
||||
factory VpnProps.fromJson(Map<String, Object?>? json) =>
|
||||
@@ -95,88 +124,67 @@ class DesktopProps with _$DesktopProps {
|
||||
json == null ? const DesktopProps() : _$DesktopPropsFromJson(json);
|
||||
}
|
||||
|
||||
const defaultCustomFontSizeScale = 1.0;
|
||||
|
||||
const defaultScaleProps = ScaleProps();
|
||||
const defaultProxiesStyle = ProxiesStyle();
|
||||
|
||||
@freezed
|
||||
class ScaleProps with _$ScaleProps {
|
||||
const factory ScaleProps({
|
||||
@Default(false) bool custom,
|
||||
@Default(defaultCustomFontSizeScale) double scale,
|
||||
}) = _ScaleProps;
|
||||
class ProxiesStyle with _$ProxiesStyle {
|
||||
const factory ProxiesStyle({
|
||||
@Default(ProxiesType.tab) ProxiesType type,
|
||||
@Default(ProxiesSortType.none) ProxiesSortType sortType,
|
||||
@Default(ProxiesLayout.standard) ProxiesLayout layout,
|
||||
@Default(ProxiesIconStyle.standard) ProxiesIconStyle iconStyle,
|
||||
@Default(ProxyCardType.expand) ProxyCardType cardType,
|
||||
@Default({}) Map<String, String> iconMap,
|
||||
}) = _ProxiesStyle;
|
||||
|
||||
factory ScaleProps.fromJson(Map<String, Object?>? json) =>
|
||||
json == null ? defaultScaleProps : _$ScalePropsFromJson(json);
|
||||
factory ProxiesStyle.fromJson(Map<String, Object?>? json) =>
|
||||
json == null ? defaultProxiesStyle : _$ProxiesStyleFromJson(json);
|
||||
}
|
||||
|
||||
const defaultCustomFontSizeScale = 1.0;
|
||||
|
||||
@JsonSerializable()
|
||||
class Config extends ChangeNotifier {
|
||||
AppSetting _appSetting;
|
||||
List<Profile> _profiles;
|
||||
bool _isCompatible;
|
||||
String? _currentProfileId;
|
||||
bool _autoLaunch;
|
||||
bool _silentLaunch;
|
||||
bool _autoRun;
|
||||
bool _openLog;
|
||||
ThemeMode _themeMode;
|
||||
String? _locale;
|
||||
int? _primaryColor;
|
||||
ProxiesSortType _proxiesSortType;
|
||||
bool _isMinimizeOnExit;
|
||||
bool _isAccessControl;
|
||||
AccessControl _accessControl;
|
||||
bool _isAnimateToPage;
|
||||
bool _autoCheckUpdate;
|
||||
bool _isExclude;
|
||||
DAV? _dav;
|
||||
bool _isCloseConnections;
|
||||
ProxiesType _proxiesType;
|
||||
ProxyCardType _proxyCardType;
|
||||
ProxiesLayout _proxiesLayout;
|
||||
String _testUrl;
|
||||
WindowProps _windowProps;
|
||||
bool _onlyProxy;
|
||||
bool _prueBlack;
|
||||
VpnProps _vpnProps;
|
||||
ScaleProps _scaleProps;
|
||||
DesktopProps _desktopProps;
|
||||
bool _showLabel;
|
||||
bool _overrideDns;
|
||||
List<HotKeyAction> _hotKeyActions;
|
||||
bool _isDisclaimerAccepted;
|
||||
ProxiesStyle _proxiesStyle;
|
||||
|
||||
Config()
|
||||
: _profiles = [],
|
||||
_autoLaunch = false,
|
||||
_silentLaunch = false,
|
||||
_autoRun = false,
|
||||
_isCloseConnections = false,
|
||||
_themeMode = ThemeMode.system,
|
||||
_openLog = false,
|
||||
_isCompatible = true,
|
||||
_primaryColor = defaultPrimaryColor.value,
|
||||
_proxiesSortType = ProxiesSortType.none,
|
||||
_isMinimizeOnExit = true,
|
||||
_isAccessControl = false,
|
||||
_autoCheckUpdate = true,
|
||||
_testUrl = defaultTestUrl,
|
||||
_accessControl = const AccessControl(),
|
||||
_isAnimateToPage = true,
|
||||
_isExclude = false,
|
||||
_proxyCardType = ProxyCardType.expand,
|
||||
_windowProps = const WindowProps(),
|
||||
_proxiesType = ProxiesType.tab,
|
||||
_prueBlack = false,
|
||||
_onlyProxy = false,
|
||||
_proxiesLayout = ProxiesLayout.standard,
|
||||
_vpnProps = const VpnProps(),
|
||||
_vpnProps = defaultVpnProps,
|
||||
_desktopProps = const DesktopProps(),
|
||||
_showLabel = false,
|
||||
_overrideDns = false,
|
||||
_scaleProps = const ScaleProps(),
|
||||
_isDisclaimerAccepted = false,
|
||||
_hotKeyActions = [];
|
||||
_appSetting = defaultAppSetting,
|
||||
_hotKeyActions = [],
|
||||
_proxiesStyle = defaultProxiesStyle;
|
||||
|
||||
@JsonKey(fromJson: AppSetting.realFromJson)
|
||||
AppSetting get appSetting => _appSetting;
|
||||
|
||||
set appSetting(AppSetting value) {
|
||||
if (_appSetting != value) {
|
||||
_appSetting = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
deleteProfileById(String id) {
|
||||
_profiles = profiles.where((element) => element.id != id).toList();
|
||||
@@ -256,7 +264,7 @@ class Config extends ChangeNotifier {
|
||||
Set<String> get currentUnfoldSet => currentProfile?.unfoldSet ?? {};
|
||||
|
||||
updateCurrentUnfoldSet(Set<String> value) {
|
||||
if (!const SetEquality<String>().equals(currentUnfoldSet, value)) {
|
||||
if (!stringSetEquality.equals(currentUnfoldSet, value)) {
|
||||
_setProfile(
|
||||
currentProfile!.copyWith(
|
||||
unfoldSet: value,
|
||||
@@ -297,39 +305,6 @@ class Config extends ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
@JsonKey(defaultValue: false)
|
||||
bool get autoLaunch {
|
||||
if (!system.isDesktop) return false;
|
||||
return _autoLaunch;
|
||||
}
|
||||
|
||||
set autoLaunch(bool value) {
|
||||
if (_autoLaunch != value) {
|
||||
_autoLaunch = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
@JsonKey(defaultValue: false)
|
||||
bool get silentLaunch => _silentLaunch;
|
||||
|
||||
set silentLaunch(bool value) {
|
||||
if (_silentLaunch != value) {
|
||||
_silentLaunch = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
@JsonKey(defaultValue: false)
|
||||
bool get autoRun => _autoRun;
|
||||
|
||||
set autoRun(bool value) {
|
||||
if (_autoRun != value) {
|
||||
_autoRun = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
@JsonKey(defaultValue: ThemeMode.system)
|
||||
ThemeMode get themeMode => _themeMode;
|
||||
|
||||
@@ -340,25 +315,6 @@ class Config extends ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
@JsonKey(defaultValue: false)
|
||||
bool get openLogs => _openLog;
|
||||
|
||||
set openLogs(bool value) {
|
||||
if (_openLog != value) {
|
||||
_openLog = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
String? get locale => _locale;
|
||||
|
||||
set locale(String? value) {
|
||||
if (_locale != value) {
|
||||
_locale = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
int? get primaryColor => _primaryColor;
|
||||
|
||||
set primaryColor(int? value) {
|
||||
@@ -368,36 +324,6 @@ class Config extends ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
@JsonKey(defaultValue: ProxiesSortType.none)
|
||||
ProxiesSortType get proxiesSortType => _proxiesSortType;
|
||||
|
||||
set proxiesSortType(ProxiesSortType value) {
|
||||
if (_proxiesSortType != value) {
|
||||
_proxiesSortType = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
@JsonKey(defaultValue: ProxiesLayout.standard)
|
||||
ProxiesLayout get proxiesLayout => _proxiesLayout;
|
||||
|
||||
set proxiesLayout(ProxiesLayout value) {
|
||||
if (_proxiesLayout != value) {
|
||||
_proxiesLayout = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
@JsonKey(defaultValue: true)
|
||||
bool get isMinimizeOnExit => _isMinimizeOnExit;
|
||||
|
||||
set isMinimizeOnExit(bool value) {
|
||||
if (_isMinimizeOnExit != value) {
|
||||
_isMinimizeOnExit = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
@JsonKey(defaultValue: false)
|
||||
bool get isAccessControl {
|
||||
if (!Platform.isAndroid) return false;
|
||||
@@ -429,55 +355,6 @@ class Config extends ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
@JsonKey(defaultValue: true)
|
||||
bool get isAnimateToPage {
|
||||
if (!Platform.isAndroid) return false;
|
||||
return _isAnimateToPage;
|
||||
}
|
||||
|
||||
set isAnimateToPage(bool value) {
|
||||
if (_isAnimateToPage != value) {
|
||||
_isAnimateToPage = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
@JsonKey(defaultValue: true)
|
||||
bool get isCompatible {
|
||||
return _isCompatible;
|
||||
}
|
||||
|
||||
set isCompatible(bool value) {
|
||||
if (_isCompatible != value) {
|
||||
_isCompatible = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
@JsonKey(defaultValue: true)
|
||||
bool get autoCheckUpdate {
|
||||
return _autoCheckUpdate;
|
||||
}
|
||||
|
||||
set autoCheckUpdate(bool value) {
|
||||
if (_autoCheckUpdate != value) {
|
||||
_autoCheckUpdate = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
@JsonKey(defaultValue: false)
|
||||
bool get onlyProxy {
|
||||
return _onlyProxy;
|
||||
}
|
||||
|
||||
set onlyProxy(bool value) {
|
||||
if (_onlyProxy != value) {
|
||||
_onlyProxy = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
@JsonKey(defaultValue: false)
|
||||
bool get prueBlack {
|
||||
return _prueBlack;
|
||||
@@ -490,61 +367,6 @@ class Config extends ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
@JsonKey(defaultValue: false)
|
||||
bool get isCloseConnections {
|
||||
return _isCloseConnections;
|
||||
}
|
||||
|
||||
set isCloseConnections(bool value) {
|
||||
if (_isCloseConnections != value) {
|
||||
_isCloseConnections = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
@JsonKey(
|
||||
defaultValue: ProxiesType.tab,
|
||||
unknownEnumValue: ProxiesType.tab,
|
||||
)
|
||||
ProxiesType get proxiesType => _proxiesType;
|
||||
|
||||
set proxiesType(ProxiesType value) {
|
||||
if (_proxiesType != value) {
|
||||
_proxiesType = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
@JsonKey(defaultValue: ProxyCardType.expand)
|
||||
ProxyCardType get proxyCardType => _proxyCardType;
|
||||
|
||||
set proxyCardType(ProxyCardType value) {
|
||||
if (_proxyCardType != value) {
|
||||
_proxyCardType = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
@JsonKey(name: "test-url", defaultValue: defaultTestUrl)
|
||||
String get testUrl => _testUrl;
|
||||
|
||||
set testUrl(String value) {
|
||||
if (_testUrl != value) {
|
||||
_testUrl = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
@JsonKey(defaultValue: false)
|
||||
bool get isExclude => _isExclude;
|
||||
|
||||
set isExclude(bool value) {
|
||||
if (_isExclude != value) {
|
||||
_isExclude = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
WindowProps get windowProps => _windowProps;
|
||||
|
||||
set windowProps(WindowProps value) {
|
||||
@@ -572,25 +394,6 @@ class Config extends ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
ScaleProps get scaleProps => _scaleProps;
|
||||
|
||||
set scaleProps(ScaleProps value) {
|
||||
if (_scaleProps != value) {
|
||||
_scaleProps = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
@JsonKey(defaultValue: false)
|
||||
bool get showLabel => _showLabel;
|
||||
|
||||
set showLabel(bool value) {
|
||||
if (_showLabel != value) {
|
||||
_showLabel = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
@JsonKey(defaultValue: false)
|
||||
bool get overrideDns => _overrideDns;
|
||||
|
||||
@@ -601,16 +404,6 @@ class Config extends ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
@JsonKey(defaultValue: false)
|
||||
bool get isDisclaimerAccepted => _isDisclaimerAccepted;
|
||||
|
||||
set isDisclaimerAccepted(bool value) {
|
||||
if (_isDisclaimerAccepted != value) {
|
||||
_isDisclaimerAccepted = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
@JsonKey(defaultValue: [])
|
||||
List<HotKeyAction> get hotKeyActions => _hotKeyActions;
|
||||
|
||||
@@ -621,6 +414,19 @@ class Config extends ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
ProxiesStyle get proxiesStyle => _proxiesStyle;
|
||||
|
||||
set proxiesStyle(ProxiesStyle value) {
|
||||
if (_proxiesStyle != value ||
|
||||
!stringAndStringMapEntryIterableEquality.equals(
|
||||
_proxiesStyle.iconMap.entries,
|
||||
value.iconMap.entries,
|
||||
)) {
|
||||
_proxiesStyle = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
updateOrAddHotKeyAction(HotKeyAction hotKeyAction) {
|
||||
final index =
|
||||
_hotKeyActions.indexWhere((item) => item.action == hotKeyAction.action);
|
||||
@@ -646,28 +452,16 @@ class Config extends ChangeNotifier {
|
||||
_currentProfileId = _profiles.first.id;
|
||||
}
|
||||
if (onlyProfiles) return;
|
||||
_appSetting = config._appSetting;
|
||||
_currentProfileId = config._currentProfileId;
|
||||
_isCloseConnections = config._isCloseConnections;
|
||||
_isCompatible = config._isCompatible;
|
||||
_autoLaunch = config._autoLaunch;
|
||||
_dav = config._dav;
|
||||
_silentLaunch = config._silentLaunch;
|
||||
_autoRun = config._autoRun;
|
||||
_proxiesType = config._proxiesType;
|
||||
_openLog = config._openLog;
|
||||
_themeMode = config._themeMode;
|
||||
_locale = config._locale;
|
||||
_primaryColor = config._primaryColor;
|
||||
_proxiesSortType = config._proxiesSortType;
|
||||
_isMinimizeOnExit = config._isMinimizeOnExit;
|
||||
_isAccessControl = config._isAccessControl;
|
||||
_accessControl = config._accessControl;
|
||||
_isAnimateToPage = config._isAnimateToPage;
|
||||
_autoCheckUpdate = config._autoCheckUpdate;
|
||||
_prueBlack = config._prueBlack;
|
||||
_testUrl = config._testUrl;
|
||||
_isExclude = config._isExclude;
|
||||
_windowProps = config._windowProps;
|
||||
_proxiesStyle = config._proxiesStyle;
|
||||
_vpnProps = config._vpnProps;
|
||||
_overrideDns = config._overrideDns;
|
||||
_desktopProps = config._desktopProps;
|
||||
|
||||
@@ -8,6 +8,41 @@ part 'generated/ffi.g.dart';
|
||||
|
||||
part 'generated/ffi.freezed.dart';
|
||||
|
||||
@freezed
|
||||
class CoreState with _$CoreState {
|
||||
const factory CoreState({
|
||||
required bool enable,
|
||||
AccessControl? accessControl,
|
||||
required String currentProfileName,
|
||||
required bool allowBypass,
|
||||
required bool systemProxy,
|
||||
required List<String> bypassDomain,
|
||||
required bool ipv6,
|
||||
required bool onlyProxy,
|
||||
}) = _CoreState;
|
||||
|
||||
factory CoreState.fromJson(Map<String, Object?> json) =>
|
||||
_$CoreStateFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
class AndroidVpnOptions with _$AndroidVpnOptions {
|
||||
const factory AndroidVpnOptions({
|
||||
required bool enable,
|
||||
required int port,
|
||||
required AccessControl? accessControl,
|
||||
required bool allowBypass,
|
||||
required bool systemProxy,
|
||||
required List<String> bypassDomain,
|
||||
required String ipv4Address,
|
||||
required String ipv6Address,
|
||||
required String dnsServerAddress,
|
||||
}) = _AndroidVpnOptions;
|
||||
|
||||
factory AndroidVpnOptions.fromJson(Map<String, Object?> json) =>
|
||||
_$AndroidVpnOptionsFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
class ConfigExtendedParams with _$ConfigExtendedParams {
|
||||
const factory ConfigExtendedParams({
|
||||
|
||||
@@ -772,7 +772,7 @@ class _$DnsImpl implements _Dns {
|
||||
@JsonKey(name: "prefer-h3") this.preferH3 = false,
|
||||
@JsonKey(name: "use-hosts") this.useHosts = true,
|
||||
@JsonKey(name: "use-system-hosts") this.useSystemHosts = true,
|
||||
@JsonKey(name: "respect-rules") this.respectRules = true,
|
||||
@JsonKey(name: "respect-rules") this.respectRules = false,
|
||||
this.ipv6 = false,
|
||||
@JsonKey(name: "default-nameserver")
|
||||
final List<String> defaultNameserver = const ["223.5.5.5"],
|
||||
|
||||
@@ -32,9 +32,9 @@ ClashConfig _$ClashConfigFromJson(Map<String, dynamic> json) => ClashConfig()
|
||||
'mmdb':
|
||||
'https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geoip.metadb',
|
||||
'asn':
|
||||
'https://github.com/xishang0128/geoip/releases/download/latest/GeoLite2-ASN.mmdb',
|
||||
'https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/GeoLite2-ASN.mmdb',
|
||||
'geoip':
|
||||
'https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/GeoIP.dat',
|
||||
'https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geoip.dat',
|
||||
'geosite':
|
||||
'https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geosite.dat'
|
||||
}
|
||||
@@ -141,7 +141,7 @@ _$DnsImpl _$$DnsImplFromJson(Map<String, dynamic> json) => _$DnsImpl(
|
||||
preferH3: json['prefer-h3'] as bool? ?? false,
|
||||
useHosts: json['use-hosts'] as bool? ?? true,
|
||||
useSystemHosts: json['use-system-hosts'] as bool? ?? true,
|
||||
respectRules: json['respect-rules'] as bool? ?? true,
|
||||
respectRules: json['respect-rules'] as bool? ?? false,
|
||||
ipv6: json['ipv6'] as bool? ?? false,
|
||||
defaultNameserver: (json['default-nameserver'] as List<dynamic>?)
|
||||
?.map((e) => e as String)
|
||||
|
||||
@@ -2468,3 +2468,153 @@ abstract class _HotKeyAction implements HotKeyAction {
|
||||
_$$HotKeyActionImplCopyWith<_$HotKeyActionImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$Field {
|
||||
String get label => throw _privateConstructorUsedError;
|
||||
String get value => throw _privateConstructorUsedError;
|
||||
Validator? get validator => throw _privateConstructorUsedError;
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
$FieldCopyWith<Field> get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $FieldCopyWith<$Res> {
|
||||
factory $FieldCopyWith(Field value, $Res Function(Field) then) =
|
||||
_$FieldCopyWithImpl<$Res, Field>;
|
||||
@useResult
|
||||
$Res call({String label, String value, Validator? validator});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$FieldCopyWithImpl<$Res, $Val extends Field>
|
||||
implements $FieldCopyWith<$Res> {
|
||||
_$FieldCopyWithImpl(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? label = null,
|
||||
Object? value = null,
|
||||
Object? validator = freezed,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
label: null == label
|
||||
? _value.label
|
||||
: label // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
value: null == value
|
||||
? _value.value
|
||||
: value // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
validator: freezed == validator
|
||||
? _value.validator
|
||||
: validator // ignore: cast_nullable_to_non_nullable
|
||||
as Validator?,
|
||||
) as $Val);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$FieldImplCopyWith<$Res> implements $FieldCopyWith<$Res> {
|
||||
factory _$$FieldImplCopyWith(
|
||||
_$FieldImpl value, $Res Function(_$FieldImpl) then) =
|
||||
__$$FieldImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({String label, String value, Validator? validator});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$FieldImplCopyWithImpl<$Res>
|
||||
extends _$FieldCopyWithImpl<$Res, _$FieldImpl>
|
||||
implements _$$FieldImplCopyWith<$Res> {
|
||||
__$$FieldImplCopyWithImpl(
|
||||
_$FieldImpl _value, $Res Function(_$FieldImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? label = null,
|
||||
Object? value = null,
|
||||
Object? validator = freezed,
|
||||
}) {
|
||||
return _then(_$FieldImpl(
|
||||
label: null == label
|
||||
? _value.label
|
||||
: label // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
value: null == value
|
||||
? _value.value
|
||||
: value // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
validator: freezed == validator
|
||||
? _value.validator
|
||||
: validator // ignore: cast_nullable_to_non_nullable
|
||||
as Validator?,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$FieldImpl implements _Field {
|
||||
const _$FieldImpl({required this.label, required this.value, this.validator});
|
||||
|
||||
@override
|
||||
final String label;
|
||||
@override
|
||||
final String value;
|
||||
@override
|
||||
final Validator? validator;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Field(label: $label, value: $value, validator: $validator)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$FieldImpl &&
|
||||
(identical(other.label, label) || other.label == label) &&
|
||||
(identical(other.value, value) || other.value == value) &&
|
||||
(identical(other.validator, validator) ||
|
||||
other.validator == validator));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, label, value, validator);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$FieldImplCopyWith<_$FieldImpl> get copyWith =>
|
||||
__$$FieldImplCopyWithImpl<_$FieldImpl>(this, _$identity);
|
||||
}
|
||||
|
||||
abstract class _Field implements Field {
|
||||
const factory _Field(
|
||||
{required final String label,
|
||||
required final String value,
|
||||
final Validator? validator}) = _$FieldImpl;
|
||||
|
||||
@override
|
||||
String get label;
|
||||
@override
|
||||
String get value;
|
||||
@override
|
||||
Validator? get validator;
|
||||
@override
|
||||
@JsonKey(ignore: true)
|
||||
_$$FieldImplCopyWith<_$FieldImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -7,96 +7,52 @@ part of '../config.dart';
|
||||
// **************************************************************************
|
||||
|
||||
Config _$ConfigFromJson(Map<String, dynamic> json) => Config()
|
||||
..appSetting =
|
||||
AppSetting.realFromJson(json['appSetting'] as Map<String, Object?>?)
|
||||
..profiles = (json['profiles'] as List<dynamic>?)
|
||||
?.map((e) => Profile.fromJson(e as Map<String, dynamic>))
|
||||
.toList() ??
|
||||
[]
|
||||
..currentProfileId = json['currentProfileId'] as String?
|
||||
..autoLaunch = json['autoLaunch'] as bool? ?? false
|
||||
..silentLaunch = json['silentLaunch'] as bool? ?? false
|
||||
..autoRun = json['autoRun'] as bool? ?? false
|
||||
..themeMode = $enumDecodeNullable(_$ThemeModeEnumMap, json['themeMode']) ??
|
||||
ThemeMode.system
|
||||
..openLogs = json['openLogs'] as bool? ?? false
|
||||
..locale = json['locale'] as String?
|
||||
..primaryColor = (json['primaryColor'] as num?)?.toInt()
|
||||
..proxiesSortType =
|
||||
$enumDecodeNullable(_$ProxiesSortTypeEnumMap, json['proxiesSortType']) ??
|
||||
ProxiesSortType.none
|
||||
..proxiesLayout =
|
||||
$enumDecodeNullable(_$ProxiesLayoutEnumMap, json['proxiesLayout']) ??
|
||||
ProxiesLayout.standard
|
||||
..isMinimizeOnExit = json['isMinimizeOnExit'] as bool? ?? true
|
||||
..isAccessControl = json['isAccessControl'] as bool? ?? false
|
||||
..accessControl =
|
||||
AccessControl.fromJson(json['accessControl'] as Map<String, dynamic>)
|
||||
..dav = json['dav'] == null
|
||||
? null
|
||||
: DAV.fromJson(json['dav'] as Map<String, dynamic>)
|
||||
..isAnimateToPage = json['isAnimateToPage'] as bool? ?? true
|
||||
..isCompatible = json['isCompatible'] as bool? ?? true
|
||||
..autoCheckUpdate = json['autoCheckUpdate'] as bool? ?? true
|
||||
..onlyProxy = json['onlyProxy'] as bool? ?? false
|
||||
..prueBlack = json['prueBlack'] as bool? ?? false
|
||||
..isCloseConnections = json['isCloseConnections'] as bool? ?? false
|
||||
..proxiesType = $enumDecodeNullable(_$ProxiesTypeEnumMap, json['proxiesType'],
|
||||
unknownValue: ProxiesType.tab) ??
|
||||
ProxiesType.tab
|
||||
..proxyCardType =
|
||||
$enumDecodeNullable(_$ProxyCardTypeEnumMap, json['proxyCardType']) ??
|
||||
ProxyCardType.expand
|
||||
..testUrl =
|
||||
json['test-url'] as String? ?? 'https://www.gstatic.com/generate_204'
|
||||
..isExclude = json['isExclude'] as bool? ?? false
|
||||
..windowProps =
|
||||
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>?)
|
||||
..scaleProps =
|
||||
ScaleProps.fromJson(json['scaleProps'] as Map<String, dynamic>?)
|
||||
..showLabel = json['showLabel'] as bool? ?? false
|
||||
..overrideDns = json['overrideDns'] as bool? ?? false
|
||||
..isDisclaimerAccepted = json['isDisclaimerAccepted'] as bool? ?? false
|
||||
..hotKeyActions = (json['hotKeyActions'] as List<dynamic>?)
|
||||
?.map((e) => HotKeyAction.fromJson(e as Map<String, dynamic>))
|
||||
.toList() ??
|
||||
[];
|
||||
[]
|
||||
..proxiesStyle =
|
||||
ProxiesStyle.fromJson(json['proxiesStyle'] as Map<String, dynamic>?);
|
||||
|
||||
Map<String, dynamic> _$ConfigToJson(Config instance) => <String, dynamic>{
|
||||
'appSetting': instance.appSetting,
|
||||
'profiles': instance.profiles,
|
||||
'currentProfileId': instance.currentProfileId,
|
||||
'autoLaunch': instance.autoLaunch,
|
||||
'silentLaunch': instance.silentLaunch,
|
||||
'autoRun': instance.autoRun,
|
||||
'themeMode': _$ThemeModeEnumMap[instance.themeMode]!,
|
||||
'openLogs': instance.openLogs,
|
||||
'locale': instance.locale,
|
||||
'primaryColor': instance.primaryColor,
|
||||
'proxiesSortType': _$ProxiesSortTypeEnumMap[instance.proxiesSortType]!,
|
||||
'proxiesLayout': _$ProxiesLayoutEnumMap[instance.proxiesLayout]!,
|
||||
'isMinimizeOnExit': instance.isMinimizeOnExit,
|
||||
'isAccessControl': instance.isAccessControl,
|
||||
'accessControl': instance.accessControl,
|
||||
'dav': instance.dav,
|
||||
'isAnimateToPage': instance.isAnimateToPage,
|
||||
'isCompatible': instance.isCompatible,
|
||||
'autoCheckUpdate': instance.autoCheckUpdate,
|
||||
'onlyProxy': instance.onlyProxy,
|
||||
'prueBlack': instance.prueBlack,
|
||||
'isCloseConnections': instance.isCloseConnections,
|
||||
'proxiesType': _$ProxiesTypeEnumMap[instance.proxiesType]!,
|
||||
'proxyCardType': _$ProxyCardTypeEnumMap[instance.proxyCardType]!,
|
||||
'test-url': instance.testUrl,
|
||||
'isExclude': instance.isExclude,
|
||||
'windowProps': instance.windowProps,
|
||||
'vpnProps': instance.vpnProps,
|
||||
'desktopProps': instance.desktopProps,
|
||||
'scaleProps': instance.scaleProps,
|
||||
'showLabel': instance.showLabel,
|
||||
'overrideDns': instance.overrideDns,
|
||||
'isDisclaimerAccepted': instance.isDisclaimerAccepted,
|
||||
'hotKeyActions': instance.hotKeyActions,
|
||||
'proxiesStyle': instance.proxiesStyle,
|
||||
};
|
||||
|
||||
const _$ThemeModeEnumMap = {
|
||||
@@ -105,28 +61,43 @@ const _$ThemeModeEnumMap = {
|
||||
ThemeMode.dark: 'dark',
|
||||
};
|
||||
|
||||
const _$ProxiesSortTypeEnumMap = {
|
||||
ProxiesSortType.none: 'none',
|
||||
ProxiesSortType.delay: 'delay',
|
||||
ProxiesSortType.name: 'name',
|
||||
};
|
||||
_$AppSettingImpl _$$AppSettingImplFromJson(Map<String, dynamic> json) =>
|
||||
_$AppSettingImpl(
|
||||
locale: json['locale'] as String?,
|
||||
onlyProxy: json['onlyProxy'] as bool? ?? false,
|
||||
autoLaunch: json['autoLaunch'] as bool? ?? false,
|
||||
adminAutoLaunch: json['adminAutoLaunch'] as bool? ?? false,
|
||||
silentLaunch: json['silentLaunch'] as bool? ?? false,
|
||||
autoRun: json['autoRun'] as bool? ?? false,
|
||||
openLogs: json['openLogs'] as bool? ?? false,
|
||||
closeConnections: json['closeConnections'] as bool? ?? true,
|
||||
testUrl: json['testUrl'] as String? ?? defaultTestUrl,
|
||||
isAnimateToPage: json['isAnimateToPage'] as bool? ?? true,
|
||||
autoCheckUpdate: json['autoCheckUpdate'] as bool? ?? true,
|
||||
showLabel: json['showLabel'] as bool? ?? false,
|
||||
disclaimerAccepted: json['disclaimerAccepted'] as bool? ?? false,
|
||||
minimizeOnExit: json['minimizeOnExit'] as bool? ?? true,
|
||||
hidden: json['hidden'] as bool? ?? false,
|
||||
);
|
||||
|
||||
const _$ProxiesLayoutEnumMap = {
|
||||
ProxiesLayout.loose: 'loose',
|
||||
ProxiesLayout.standard: 'standard',
|
||||
ProxiesLayout.tight: 'tight',
|
||||
};
|
||||
|
||||
const _$ProxiesTypeEnumMap = {
|
||||
ProxiesType.tab: 'tab',
|
||||
ProxiesType.list: 'list',
|
||||
};
|
||||
|
||||
const _$ProxyCardTypeEnumMap = {
|
||||
ProxyCardType.expand: 'expand',
|
||||
ProxyCardType.shrink: 'shrink',
|
||||
ProxyCardType.min: 'min',
|
||||
};
|
||||
Map<String, dynamic> _$$AppSettingImplToJson(_$AppSettingImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'locale': instance.locale,
|
||||
'onlyProxy': instance.onlyProxy,
|
||||
'autoLaunch': instance.autoLaunch,
|
||||
'adminAutoLaunch': instance.adminAutoLaunch,
|
||||
'silentLaunch': instance.silentLaunch,
|
||||
'autoRun': instance.autoRun,
|
||||
'openLogs': instance.openLogs,
|
||||
'closeConnections': instance.closeConnections,
|
||||
'testUrl': instance.testUrl,
|
||||
'isAnimateToPage': instance.isAnimateToPage,
|
||||
'autoCheckUpdate': instance.autoCheckUpdate,
|
||||
'showLabel': instance.showLabel,
|
||||
'disclaimerAccepted': instance.disclaimerAccepted,
|
||||
'minimizeOnExit': instance.minimizeOnExit,
|
||||
'hidden': instance.hidden,
|
||||
};
|
||||
|
||||
_$AccessControlImpl _$$AccessControlImplFromJson(Map<String, dynamic> json) =>
|
||||
_$AccessControlImpl(
|
||||
@@ -165,46 +136,6 @@ const _$AccessSortTypeEnumMap = {
|
||||
AccessSortType.time: 'time',
|
||||
};
|
||||
|
||||
_$CoreStateImpl _$$CoreStateImplFromJson(Map<String, dynamic> json) =>
|
||||
_$CoreStateImpl(
|
||||
accessControl: json['accessControl'] == null
|
||||
? null
|
||||
: AccessControl.fromJson(
|
||||
json['accessControl'] as Map<String, dynamic>),
|
||||
currentProfileName: json['currentProfileName'] as String,
|
||||
enable: json['enable'] as bool,
|
||||
allowBypass: json['allowBypass'] as bool,
|
||||
systemProxy: json['systemProxy'] as bool,
|
||||
mixedPort: (json['mixedPort'] as num).toInt(),
|
||||
onlyProxy: json['onlyProxy'] as bool,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$CoreStateImplToJson(_$CoreStateImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'accessControl': instance.accessControl,
|
||||
'currentProfileName': instance.currentProfileName,
|
||||
'enable': instance.enable,
|
||||
'allowBypass': instance.allowBypass,
|
||||
'systemProxy': instance.systemProxy,
|
||||
'mixedPort': instance.mixedPort,
|
||||
'onlyProxy': instance.onlyProxy,
|
||||
};
|
||||
|
||||
_$VPNStateImpl _$$VPNStateImplFromJson(Map<String, dynamic> json) =>
|
||||
_$VPNStateImpl(
|
||||
accessControl: json['accessControl'] == null
|
||||
? null
|
||||
: AccessControl.fromJson(
|
||||
json['accessControl'] as Map<String, dynamic>),
|
||||
vpnProps: VpnProps.fromJson(json['vpnProps'] as Map<String, dynamic>?),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$VPNStateImplToJson(_$VPNStateImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'accessControl': instance.accessControl,
|
||||
'vpnProps': instance.vpnProps,
|
||||
};
|
||||
|
||||
_$WindowPropsImpl _$$WindowPropsImplFromJson(Map<String, dynamic> json) =>
|
||||
_$WindowPropsImpl(
|
||||
width: (json['width'] as num?)?.toDouble() ?? 1000,
|
||||
@@ -224,15 +155,22 @@ Map<String, dynamic> _$$WindowPropsImplToJson(_$WindowPropsImpl instance) =>
|
||||
_$VpnPropsImpl _$$VpnPropsImplFromJson(Map<String, dynamic> json) =>
|
||||
_$VpnPropsImpl(
|
||||
enable: json['enable'] as bool? ?? true,
|
||||
systemProxy: json['systemProxy'] as bool? ?? false,
|
||||
systemProxy: json['systemProxy'] as bool? ?? true,
|
||||
ipv6: json['ipv6'] as bool? ?? false,
|
||||
allowBypass: json['allowBypass'] as bool? ?? true,
|
||||
bypassDomain: (json['bypassDomain'] as List<dynamic>?)
|
||||
?.map((e) => e as String)
|
||||
.toList() ??
|
||||
defaultBypassDomain,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$VpnPropsImplToJson(_$VpnPropsImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'enable': instance.enable,
|
||||
'systemProxy': instance.systemProxy,
|
||||
'ipv6': instance.ipv6,
|
||||
'allowBypass': instance.allowBypass,
|
||||
'bypassDomain': instance.bypassDomain,
|
||||
};
|
||||
|
||||
_$DesktopPropsImpl _$$DesktopPropsImplFromJson(Map<String, dynamic> json) =>
|
||||
@@ -245,14 +183,61 @@ Map<String, dynamic> _$$DesktopPropsImplToJson(_$DesktopPropsImpl instance) =>
|
||||
'systemProxy': instance.systemProxy,
|
||||
};
|
||||
|
||||
_$ScalePropsImpl _$$ScalePropsImplFromJson(Map<String, dynamic> json) =>
|
||||
_$ScalePropsImpl(
|
||||
custom: json['custom'] as bool? ?? false,
|
||||
scale: (json['scale'] as num?)?.toDouble() ?? defaultCustomFontSizeScale,
|
||||
_$ProxiesStyleImpl _$$ProxiesStyleImplFromJson(Map<String, dynamic> json) =>
|
||||
_$ProxiesStyleImpl(
|
||||
type: $enumDecodeNullable(_$ProxiesTypeEnumMap, json['type']) ??
|
||||
ProxiesType.tab,
|
||||
sortType:
|
||||
$enumDecodeNullable(_$ProxiesSortTypeEnumMap, json['sortType']) ??
|
||||
ProxiesSortType.none,
|
||||
layout: $enumDecodeNullable(_$ProxiesLayoutEnumMap, json['layout']) ??
|
||||
ProxiesLayout.standard,
|
||||
iconStyle:
|
||||
$enumDecodeNullable(_$ProxiesIconStyleEnumMap, json['iconStyle']) ??
|
||||
ProxiesIconStyle.standard,
|
||||
cardType: $enumDecodeNullable(_$ProxyCardTypeEnumMap, json['cardType']) ??
|
||||
ProxyCardType.expand,
|
||||
iconMap: (json['iconMap'] as Map<String, dynamic>?)?.map(
|
||||
(k, e) => MapEntry(k, e as String),
|
||||
) ??
|
||||
const {},
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$ScalePropsImplToJson(_$ScalePropsImpl instance) =>
|
||||
Map<String, dynamic> _$$ProxiesStyleImplToJson(_$ProxiesStyleImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'custom': instance.custom,
|
||||
'scale': instance.scale,
|
||||
'type': _$ProxiesTypeEnumMap[instance.type]!,
|
||||
'sortType': _$ProxiesSortTypeEnumMap[instance.sortType]!,
|
||||
'layout': _$ProxiesLayoutEnumMap[instance.layout]!,
|
||||
'iconStyle': _$ProxiesIconStyleEnumMap[instance.iconStyle]!,
|
||||
'cardType': _$ProxyCardTypeEnumMap[instance.cardType]!,
|
||||
'iconMap': instance.iconMap,
|
||||
};
|
||||
|
||||
const _$ProxiesTypeEnumMap = {
|
||||
ProxiesType.tab: 'tab',
|
||||
ProxiesType.list: 'list',
|
||||
};
|
||||
|
||||
const _$ProxiesSortTypeEnumMap = {
|
||||
ProxiesSortType.none: 'none',
|
||||
ProxiesSortType.delay: 'delay',
|
||||
ProxiesSortType.name: 'name',
|
||||
};
|
||||
|
||||
const _$ProxiesLayoutEnumMap = {
|
||||
ProxiesLayout.loose: 'loose',
|
||||
ProxiesLayout.standard: 'standard',
|
||||
ProxiesLayout.tight: 'tight',
|
||||
};
|
||||
|
||||
const _$ProxiesIconStyleEnumMap = {
|
||||
ProxiesIconStyle.standard: 'standard',
|
||||
ProxiesIconStyle.none: 'none',
|
||||
ProxiesIconStyle.icon: 'icon',
|
||||
};
|
||||
|
||||
const _$ProxyCardTypeEnumMap = {
|
||||
ProxyCardType.expand: 'expand',
|
||||
ProxyCardType.shrink: 'shrink',
|
||||
ProxyCardType.min: 'min',
|
||||
};
|
||||
|
||||
@@ -14,6 +14,666 @@ T _$identity<T>(T value) => value;
|
||||
final _privateConstructorUsedError = UnsupportedError(
|
||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
|
||||
|
||||
CoreState _$CoreStateFromJson(Map<String, dynamic> json) {
|
||||
return _CoreState.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$CoreState {
|
||||
bool get enable => throw _privateConstructorUsedError;
|
||||
AccessControl? get accessControl => throw _privateConstructorUsedError;
|
||||
String get currentProfileName => throw _privateConstructorUsedError;
|
||||
bool get allowBypass => throw _privateConstructorUsedError;
|
||||
bool get systemProxy => throw _privateConstructorUsedError;
|
||||
List<String> get bypassDomain => throw _privateConstructorUsedError;
|
||||
bool get ipv6 => throw _privateConstructorUsedError;
|
||||
bool get onlyProxy => throw _privateConstructorUsedError;
|
||||
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
@JsonKey(ignore: true)
|
||||
$CoreStateCopyWith<CoreState> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $CoreStateCopyWith<$Res> {
|
||||
factory $CoreStateCopyWith(CoreState value, $Res Function(CoreState) then) =
|
||||
_$CoreStateCopyWithImpl<$Res, CoreState>;
|
||||
@useResult
|
||||
$Res call(
|
||||
{bool enable,
|
||||
AccessControl? accessControl,
|
||||
String currentProfileName,
|
||||
bool allowBypass,
|
||||
bool systemProxy,
|
||||
List<String> bypassDomain,
|
||||
bool ipv6,
|
||||
bool onlyProxy});
|
||||
|
||||
$AccessControlCopyWith<$Res>? get accessControl;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$CoreStateCopyWithImpl<$Res, $Val extends CoreState>
|
||||
implements $CoreStateCopyWith<$Res> {
|
||||
_$CoreStateCopyWithImpl(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? accessControl = freezed,
|
||||
Object? currentProfileName = null,
|
||||
Object? allowBypass = null,
|
||||
Object? systemProxy = null,
|
||||
Object? bypassDomain = null,
|
||||
Object? ipv6 = null,
|
||||
Object? onlyProxy = null,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
enable: null == enable
|
||||
? _value.enable
|
||||
: enable // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
accessControl: freezed == accessControl
|
||||
? _value.accessControl
|
||||
: accessControl // ignore: cast_nullable_to_non_nullable
|
||||
as AccessControl?,
|
||||
currentProfileName: null == currentProfileName
|
||||
? _value.currentProfileName
|
||||
: currentProfileName // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
allowBypass: null == allowBypass
|
||||
? _value.allowBypass
|
||||
: allowBypass // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
systemProxy: null == systemProxy
|
||||
? _value.systemProxy
|
||||
: systemProxy // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
bypassDomain: null == bypassDomain
|
||||
? _value.bypassDomain
|
||||
: bypassDomain // ignore: cast_nullable_to_non_nullable
|
||||
as List<String>,
|
||||
ipv6: null == ipv6
|
||||
? _value.ipv6
|
||||
: ipv6 // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
onlyProxy: null == onlyProxy
|
||||
? _value.onlyProxy
|
||||
: onlyProxy // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
) as $Val);
|
||||
}
|
||||
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$AccessControlCopyWith<$Res>? get accessControl {
|
||||
if (_value.accessControl == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $AccessControlCopyWith<$Res>(_value.accessControl!, (value) {
|
||||
return _then(_value.copyWith(accessControl: value) as $Val);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$CoreStateImplCopyWith<$Res>
|
||||
implements $CoreStateCopyWith<$Res> {
|
||||
factory _$$CoreStateImplCopyWith(
|
||||
_$CoreStateImpl value, $Res Function(_$CoreStateImpl) then) =
|
||||
__$$CoreStateImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call(
|
||||
{bool enable,
|
||||
AccessControl? accessControl,
|
||||
String currentProfileName,
|
||||
bool allowBypass,
|
||||
bool systemProxy,
|
||||
List<String> bypassDomain,
|
||||
bool ipv6,
|
||||
bool onlyProxy});
|
||||
|
||||
@override
|
||||
$AccessControlCopyWith<$Res>? get accessControl;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$CoreStateImplCopyWithImpl<$Res>
|
||||
extends _$CoreStateCopyWithImpl<$Res, _$CoreStateImpl>
|
||||
implements _$$CoreStateImplCopyWith<$Res> {
|
||||
__$$CoreStateImplCopyWithImpl(
|
||||
_$CoreStateImpl _value, $Res Function(_$CoreStateImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? enable = null,
|
||||
Object? accessControl = freezed,
|
||||
Object? currentProfileName = null,
|
||||
Object? allowBypass = null,
|
||||
Object? systemProxy = null,
|
||||
Object? bypassDomain = null,
|
||||
Object? ipv6 = null,
|
||||
Object? onlyProxy = null,
|
||||
}) {
|
||||
return _then(_$CoreStateImpl(
|
||||
enable: null == enable
|
||||
? _value.enable
|
||||
: enable // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
accessControl: freezed == accessControl
|
||||
? _value.accessControl
|
||||
: accessControl // ignore: cast_nullable_to_non_nullable
|
||||
as AccessControl?,
|
||||
currentProfileName: null == currentProfileName
|
||||
? _value.currentProfileName
|
||||
: currentProfileName // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
allowBypass: null == allowBypass
|
||||
? _value.allowBypass
|
||||
: allowBypass // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
systemProxy: null == systemProxy
|
||||
? _value.systemProxy
|
||||
: systemProxy // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
bypassDomain: null == bypassDomain
|
||||
? _value._bypassDomain
|
||||
: bypassDomain // ignore: cast_nullable_to_non_nullable
|
||||
as List<String>,
|
||||
ipv6: null == ipv6
|
||||
? _value.ipv6
|
||||
: ipv6 // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
onlyProxy: null == onlyProxy
|
||||
? _value.onlyProxy
|
||||
: onlyProxy // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$CoreStateImpl implements _CoreState {
|
||||
const _$CoreStateImpl(
|
||||
{required this.enable,
|
||||
this.accessControl,
|
||||
required this.currentProfileName,
|
||||
required this.allowBypass,
|
||||
required this.systemProxy,
|
||||
required final List<String> bypassDomain,
|
||||
required this.ipv6,
|
||||
required this.onlyProxy})
|
||||
: _bypassDomain = bypassDomain;
|
||||
|
||||
factory _$CoreStateImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$CoreStateImplFromJson(json);
|
||||
|
||||
@override
|
||||
final bool enable;
|
||||
@override
|
||||
final AccessControl? accessControl;
|
||||
@override
|
||||
final String currentProfileName;
|
||||
@override
|
||||
final bool allowBypass;
|
||||
@override
|
||||
final bool systemProxy;
|
||||
final List<String> _bypassDomain;
|
||||
@override
|
||||
List<String> get bypassDomain {
|
||||
if (_bypassDomain is EqualUnmodifiableListView) return _bypassDomain;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_bypassDomain);
|
||||
}
|
||||
|
||||
@override
|
||||
final bool ipv6;
|
||||
@override
|
||||
final bool onlyProxy;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'CoreState(enable: $enable, accessControl: $accessControl, currentProfileName: $currentProfileName, allowBypass: $allowBypass, systemProxy: $systemProxy, bypassDomain: $bypassDomain, ipv6: $ipv6, onlyProxy: $onlyProxy)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$CoreStateImpl &&
|
||||
(identical(other.enable, enable) || other.enable == enable) &&
|
||||
(identical(other.accessControl, accessControl) ||
|
||||
other.accessControl == accessControl) &&
|
||||
(identical(other.currentProfileName, currentProfileName) ||
|
||||
other.currentProfileName == currentProfileName) &&
|
||||
(identical(other.allowBypass, allowBypass) ||
|
||||
other.allowBypass == allowBypass) &&
|
||||
(identical(other.systemProxy, systemProxy) ||
|
||||
other.systemProxy == systemProxy) &&
|
||||
const DeepCollectionEquality()
|
||||
.equals(other._bypassDomain, _bypassDomain) &&
|
||||
(identical(other.ipv6, ipv6) || other.ipv6 == ipv6) &&
|
||||
(identical(other.onlyProxy, onlyProxy) ||
|
||||
other.onlyProxy == onlyProxy));
|
||||
}
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
int get hashCode => Object.hash(
|
||||
runtimeType,
|
||||
enable,
|
||||
accessControl,
|
||||
currentProfileName,
|
||||
allowBypass,
|
||||
systemProxy,
|
||||
const DeepCollectionEquality().hash(_bypassDomain),
|
||||
ipv6,
|
||||
onlyProxy);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$CoreStateImplCopyWith<_$CoreStateImpl> get copyWith =>
|
||||
__$$CoreStateImplCopyWithImpl<_$CoreStateImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$CoreStateImplToJson(
|
||||
this,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _CoreState implements CoreState {
|
||||
const factory _CoreState(
|
||||
{required final bool enable,
|
||||
final AccessControl? accessControl,
|
||||
required final String currentProfileName,
|
||||
required final bool allowBypass,
|
||||
required final bool systemProxy,
|
||||
required final List<String> bypassDomain,
|
||||
required final bool ipv6,
|
||||
required final bool onlyProxy}) = _$CoreStateImpl;
|
||||
|
||||
factory _CoreState.fromJson(Map<String, dynamic> json) =
|
||||
_$CoreStateImpl.fromJson;
|
||||
|
||||
@override
|
||||
bool get enable;
|
||||
@override
|
||||
AccessControl? get accessControl;
|
||||
@override
|
||||
String get currentProfileName;
|
||||
@override
|
||||
bool get allowBypass;
|
||||
@override
|
||||
bool get systemProxy;
|
||||
@override
|
||||
List<String> get bypassDomain;
|
||||
@override
|
||||
bool get ipv6;
|
||||
@override
|
||||
bool get onlyProxy;
|
||||
@override
|
||||
@JsonKey(ignore: true)
|
||||
_$$CoreStateImplCopyWith<_$CoreStateImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
AndroidVpnOptions _$AndroidVpnOptionsFromJson(Map<String, dynamic> json) {
|
||||
return _AndroidVpnOptions.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$AndroidVpnOptions {
|
||||
bool get enable => throw _privateConstructorUsedError;
|
||||
int get port => throw _privateConstructorUsedError;
|
||||
AccessControl? get accessControl => throw _privateConstructorUsedError;
|
||||
bool get allowBypass => throw _privateConstructorUsedError;
|
||||
bool get systemProxy => throw _privateConstructorUsedError;
|
||||
List<String> get bypassDomain => throw _privateConstructorUsedError;
|
||||
String get ipv4Address => throw _privateConstructorUsedError;
|
||||
String get ipv6Address => throw _privateConstructorUsedError;
|
||||
String get dnsServerAddress => throw _privateConstructorUsedError;
|
||||
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
@JsonKey(ignore: true)
|
||||
$AndroidVpnOptionsCopyWith<AndroidVpnOptions> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $AndroidVpnOptionsCopyWith<$Res> {
|
||||
factory $AndroidVpnOptionsCopyWith(
|
||||
AndroidVpnOptions value, $Res Function(AndroidVpnOptions) then) =
|
||||
_$AndroidVpnOptionsCopyWithImpl<$Res, AndroidVpnOptions>;
|
||||
@useResult
|
||||
$Res call(
|
||||
{bool enable,
|
||||
int port,
|
||||
AccessControl? accessControl,
|
||||
bool allowBypass,
|
||||
bool systemProxy,
|
||||
List<String> bypassDomain,
|
||||
String ipv4Address,
|
||||
String ipv6Address,
|
||||
String dnsServerAddress});
|
||||
|
||||
$AccessControlCopyWith<$Res>? get accessControl;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$AndroidVpnOptionsCopyWithImpl<$Res, $Val extends AndroidVpnOptions>
|
||||
implements $AndroidVpnOptionsCopyWith<$Res> {
|
||||
_$AndroidVpnOptionsCopyWithImpl(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? port = null,
|
||||
Object? accessControl = freezed,
|
||||
Object? allowBypass = null,
|
||||
Object? systemProxy = null,
|
||||
Object? bypassDomain = null,
|
||||
Object? ipv4Address = null,
|
||||
Object? ipv6Address = null,
|
||||
Object? dnsServerAddress = null,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
enable: null == enable
|
||||
? _value.enable
|
||||
: enable // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
port: null == port
|
||||
? _value.port
|
||||
: port // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
accessControl: freezed == accessControl
|
||||
? _value.accessControl
|
||||
: accessControl // ignore: cast_nullable_to_non_nullable
|
||||
as AccessControl?,
|
||||
allowBypass: null == allowBypass
|
||||
? _value.allowBypass
|
||||
: allowBypass // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
systemProxy: null == systemProxy
|
||||
? _value.systemProxy
|
||||
: systemProxy // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
bypassDomain: null == bypassDomain
|
||||
? _value.bypassDomain
|
||||
: bypassDomain // ignore: cast_nullable_to_non_nullable
|
||||
as List<String>,
|
||||
ipv4Address: null == ipv4Address
|
||||
? _value.ipv4Address
|
||||
: ipv4Address // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
ipv6Address: null == ipv6Address
|
||||
? _value.ipv6Address
|
||||
: ipv6Address // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
dnsServerAddress: null == dnsServerAddress
|
||||
? _value.dnsServerAddress
|
||||
: dnsServerAddress // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
) as $Val);
|
||||
}
|
||||
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$AccessControlCopyWith<$Res>? get accessControl {
|
||||
if (_value.accessControl == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $AccessControlCopyWith<$Res>(_value.accessControl!, (value) {
|
||||
return _then(_value.copyWith(accessControl: value) as $Val);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$AndroidVpnOptionsImplCopyWith<$Res>
|
||||
implements $AndroidVpnOptionsCopyWith<$Res> {
|
||||
factory _$$AndroidVpnOptionsImplCopyWith(_$AndroidVpnOptionsImpl value,
|
||||
$Res Function(_$AndroidVpnOptionsImpl) then) =
|
||||
__$$AndroidVpnOptionsImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call(
|
||||
{bool enable,
|
||||
int port,
|
||||
AccessControl? accessControl,
|
||||
bool allowBypass,
|
||||
bool systemProxy,
|
||||
List<String> bypassDomain,
|
||||
String ipv4Address,
|
||||
String ipv6Address,
|
||||
String dnsServerAddress});
|
||||
|
||||
@override
|
||||
$AccessControlCopyWith<$Res>? get accessControl;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$AndroidVpnOptionsImplCopyWithImpl<$Res>
|
||||
extends _$AndroidVpnOptionsCopyWithImpl<$Res, _$AndroidVpnOptionsImpl>
|
||||
implements _$$AndroidVpnOptionsImplCopyWith<$Res> {
|
||||
__$$AndroidVpnOptionsImplCopyWithImpl(_$AndroidVpnOptionsImpl _value,
|
||||
$Res Function(_$AndroidVpnOptionsImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? enable = null,
|
||||
Object? port = null,
|
||||
Object? accessControl = freezed,
|
||||
Object? allowBypass = null,
|
||||
Object? systemProxy = null,
|
||||
Object? bypassDomain = null,
|
||||
Object? ipv4Address = null,
|
||||
Object? ipv6Address = null,
|
||||
Object? dnsServerAddress = null,
|
||||
}) {
|
||||
return _then(_$AndroidVpnOptionsImpl(
|
||||
enable: null == enable
|
||||
? _value.enable
|
||||
: enable // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
port: null == port
|
||||
? _value.port
|
||||
: port // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
accessControl: freezed == accessControl
|
||||
? _value.accessControl
|
||||
: accessControl // ignore: cast_nullable_to_non_nullable
|
||||
as AccessControl?,
|
||||
allowBypass: null == allowBypass
|
||||
? _value.allowBypass
|
||||
: allowBypass // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
systemProxy: null == systemProxy
|
||||
? _value.systemProxy
|
||||
: systemProxy // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
bypassDomain: null == bypassDomain
|
||||
? _value._bypassDomain
|
||||
: bypassDomain // ignore: cast_nullable_to_non_nullable
|
||||
as List<String>,
|
||||
ipv4Address: null == ipv4Address
|
||||
? _value.ipv4Address
|
||||
: ipv4Address // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
ipv6Address: null == ipv6Address
|
||||
? _value.ipv6Address
|
||||
: ipv6Address // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
dnsServerAddress: null == dnsServerAddress
|
||||
? _value.dnsServerAddress
|
||||
: dnsServerAddress // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$AndroidVpnOptionsImpl implements _AndroidVpnOptions {
|
||||
const _$AndroidVpnOptionsImpl(
|
||||
{required this.enable,
|
||||
required this.port,
|
||||
required this.accessControl,
|
||||
required this.allowBypass,
|
||||
required this.systemProxy,
|
||||
required final List<String> bypassDomain,
|
||||
required this.ipv4Address,
|
||||
required this.ipv6Address,
|
||||
required this.dnsServerAddress})
|
||||
: _bypassDomain = bypassDomain;
|
||||
|
||||
factory _$AndroidVpnOptionsImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$AndroidVpnOptionsImplFromJson(json);
|
||||
|
||||
@override
|
||||
final bool enable;
|
||||
@override
|
||||
final int port;
|
||||
@override
|
||||
final AccessControl? accessControl;
|
||||
@override
|
||||
final bool allowBypass;
|
||||
@override
|
||||
final bool systemProxy;
|
||||
final List<String> _bypassDomain;
|
||||
@override
|
||||
List<String> get bypassDomain {
|
||||
if (_bypassDomain is EqualUnmodifiableListView) return _bypassDomain;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_bypassDomain);
|
||||
}
|
||||
|
||||
@override
|
||||
final String ipv4Address;
|
||||
@override
|
||||
final String ipv6Address;
|
||||
@override
|
||||
final String dnsServerAddress;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'AndroidVpnOptions(enable: $enable, port: $port, accessControl: $accessControl, allowBypass: $allowBypass, systemProxy: $systemProxy, bypassDomain: $bypassDomain, ipv4Address: $ipv4Address, ipv6Address: $ipv6Address, dnsServerAddress: $dnsServerAddress)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$AndroidVpnOptionsImpl &&
|
||||
(identical(other.enable, enable) || other.enable == enable) &&
|
||||
(identical(other.port, port) || other.port == port) &&
|
||||
(identical(other.accessControl, accessControl) ||
|
||||
other.accessControl == accessControl) &&
|
||||
(identical(other.allowBypass, allowBypass) ||
|
||||
other.allowBypass == allowBypass) &&
|
||||
(identical(other.systemProxy, systemProxy) ||
|
||||
other.systemProxy == systemProxy) &&
|
||||
const DeepCollectionEquality()
|
||||
.equals(other._bypassDomain, _bypassDomain) &&
|
||||
(identical(other.ipv4Address, ipv4Address) ||
|
||||
other.ipv4Address == ipv4Address) &&
|
||||
(identical(other.ipv6Address, ipv6Address) ||
|
||||
other.ipv6Address == ipv6Address) &&
|
||||
(identical(other.dnsServerAddress, dnsServerAddress) ||
|
||||
other.dnsServerAddress == dnsServerAddress));
|
||||
}
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
int get hashCode => Object.hash(
|
||||
runtimeType,
|
||||
enable,
|
||||
port,
|
||||
accessControl,
|
||||
allowBypass,
|
||||
systemProxy,
|
||||
const DeepCollectionEquality().hash(_bypassDomain),
|
||||
ipv4Address,
|
||||
ipv6Address,
|
||||
dnsServerAddress);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$AndroidVpnOptionsImplCopyWith<_$AndroidVpnOptionsImpl> get copyWith =>
|
||||
__$$AndroidVpnOptionsImplCopyWithImpl<_$AndroidVpnOptionsImpl>(
|
||||
this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$AndroidVpnOptionsImplToJson(
|
||||
this,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _AndroidVpnOptions implements AndroidVpnOptions {
|
||||
const factory _AndroidVpnOptions(
|
||||
{required final bool enable,
|
||||
required final int port,
|
||||
required final AccessControl? accessControl,
|
||||
required final bool allowBypass,
|
||||
required final bool systemProxy,
|
||||
required final List<String> bypassDomain,
|
||||
required final String ipv4Address,
|
||||
required final String ipv6Address,
|
||||
required final String dnsServerAddress}) = _$AndroidVpnOptionsImpl;
|
||||
|
||||
factory _AndroidVpnOptions.fromJson(Map<String, dynamic> json) =
|
||||
_$AndroidVpnOptionsImpl.fromJson;
|
||||
|
||||
@override
|
||||
bool get enable;
|
||||
@override
|
||||
int get port;
|
||||
@override
|
||||
AccessControl? get accessControl;
|
||||
@override
|
||||
bool get allowBypass;
|
||||
@override
|
||||
bool get systemProxy;
|
||||
@override
|
||||
List<String> get bypassDomain;
|
||||
@override
|
||||
String get ipv4Address;
|
||||
@override
|
||||
String get ipv6Address;
|
||||
@override
|
||||
String get dnsServerAddress;
|
||||
@override
|
||||
@JsonKey(ignore: true)
|
||||
_$$AndroidVpnOptionsImplCopyWith<_$AndroidVpnOptionsImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
ConfigExtendedParams _$ConfigExtendedParamsFromJson(Map<String, dynamic> json) {
|
||||
return _ConfigExtendedParams.fromJson(json);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,68 @@ part of '../ffi.dart';
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_$CoreStateImpl _$$CoreStateImplFromJson(Map<String, dynamic> json) =>
|
||||
_$CoreStateImpl(
|
||||
enable: json['enable'] as bool,
|
||||
accessControl: json['accessControl'] == null
|
||||
? null
|
||||
: AccessControl.fromJson(
|
||||
json['accessControl'] as Map<String, dynamic>),
|
||||
currentProfileName: json['currentProfileName'] as String,
|
||||
allowBypass: json['allowBypass'] as bool,
|
||||
systemProxy: json['systemProxy'] as bool,
|
||||
bypassDomain: (json['bypassDomain'] as List<dynamic>)
|
||||
.map((e) => e as String)
|
||||
.toList(),
|
||||
ipv6: json['ipv6'] as bool,
|
||||
onlyProxy: json['onlyProxy'] as bool,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$CoreStateImplToJson(_$CoreStateImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'enable': instance.enable,
|
||||
'accessControl': instance.accessControl,
|
||||
'currentProfileName': instance.currentProfileName,
|
||||
'allowBypass': instance.allowBypass,
|
||||
'systemProxy': instance.systemProxy,
|
||||
'bypassDomain': instance.bypassDomain,
|
||||
'ipv6': instance.ipv6,
|
||||
'onlyProxy': instance.onlyProxy,
|
||||
};
|
||||
|
||||
_$AndroidVpnOptionsImpl _$$AndroidVpnOptionsImplFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
_$AndroidVpnOptionsImpl(
|
||||
enable: json['enable'] as bool,
|
||||
port: (json['port'] as num).toInt(),
|
||||
accessControl: json['accessControl'] == null
|
||||
? null
|
||||
: AccessControl.fromJson(
|
||||
json['accessControl'] as Map<String, dynamic>),
|
||||
allowBypass: json['allowBypass'] as bool,
|
||||
systemProxy: json['systemProxy'] as bool,
|
||||
bypassDomain: (json['bypassDomain'] as List<dynamic>)
|
||||
.map((e) => e as String)
|
||||
.toList(),
|
||||
ipv4Address: json['ipv4Address'] as String,
|
||||
ipv6Address: json['ipv6Address'] as String,
|
||||
dnsServerAddress: json['dnsServerAddress'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$AndroidVpnOptionsImplToJson(
|
||||
_$AndroidVpnOptionsImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'enable': instance.enable,
|
||||
'port': instance.port,
|
||||
'accessControl': instance.accessControl,
|
||||
'allowBypass': instance.allowBypass,
|
||||
'systemProxy': instance.systemProxy,
|
||||
'bypassDomain': instance.bypassDomain,
|
||||
'ipv4Address': instance.ipv4Address,
|
||||
'ipv6Address': instance.ipv6Address,
|
||||
'dnsServerAddress': instance.dnsServerAddress,
|
||||
};
|
||||
|
||||
_$ConfigExtendedParamsImpl _$$ConfigExtendedParamsImplFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
_$ConfigExtendedParamsImpl(
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user