Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8cdaf30de0 | ||
|
|
f39b9cf933 | ||
|
|
9df1ff46c2 | ||
|
|
fcbbbdc698 | ||
|
|
3ba8355772 | ||
|
|
f6b97f82ae | ||
|
|
13ac20f273 | ||
|
|
6de89d7de4 | ||
|
|
c36df8cb4a | ||
|
|
530817b268 | ||
|
|
721dd20251 |
16
.github/workflows/build.yml
vendored
@@ -140,4 +140,18 @@ jobs:
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
files: ./dist/*
|
||||
body_path: './release.md'
|
||||
body_path: './release.md'
|
||||
|
||||
- name: Push to fdroid repo
|
||||
uses: cpina/github-action-push-to-another-repository@v1.7.2
|
||||
env:
|
||||
SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }}
|
||||
with:
|
||||
source-directory: ./dist/
|
||||
destination-github-username: chen08209
|
||||
destination-repository-name: FlClash-fdroid-repo
|
||||
user-name: 'github-actions[bot]'
|
||||
user-email: 'github-actions[bot]@users.noreply.github.com'
|
||||
target-branch: action-pr
|
||||
commit-message: Update from ${{ github.ref_name }}
|
||||
target-directory: /tmp/
|
||||
|
||||
@@ -38,6 +38,10 @@ on Mobile:
|
||||
|
||||
✨ Support subscription link, Dark mode
|
||||
|
||||
## Download
|
||||
|
||||
<a href="https://chen08209.github.io/FlClash-fdroid-repo/repo?fingerprint=789D6D32668712EF7672F9E58DEEB15FBD6DCEEC5AE7A4371EA72F2AAE8A12FD"><img alt="Get it on F-Droid" src="snapshots/get-it-on-fdroid.svg" width="200px"/></a> <a href="https://github.com/chen08209/FlClash/releases"><img alt="Get it on GitHub" src="snapshots/get-it-on-github.svg" width="200px"/></a>
|
||||
|
||||
## Contact
|
||||
|
||||
[Telegram](https://t.me/+G-veVtwBOl4wODc1)
|
||||
|
||||
@@ -38,6 +38,11 @@ on Mobile:
|
||||
|
||||
✨ 支持一键导入订阅, 深色模式
|
||||
|
||||
## Download
|
||||
|
||||
<a href="https://chen08209.github.io/FlClash-fdroid-repo/repo?fingerprint=789D6D32668712EF7672F9E58DEEB15FBD6DCEEC5AE7A4371EA72F2AAE8A12FD"><img alt="Get it on F-Droid" src="snapshots/get-it-on-fdroid.svg" width="200px"/></a> <a href="https://github.com/chen08209/FlClash/releases"><img alt="Get it on GitHub" src="snapshots/get-it-on-github.svg" width="200px"/></a>
|
||||
|
||||
|
||||
## Contact
|
||||
|
||||
[Telegram](https://t.me/+G-veVtwBOl4wODc1)
|
||||
|
||||
@@ -78,7 +78,8 @@
|
||||
android:icon="@drawable/ic_stat_name"
|
||||
android:foregroundServiceType="specialUse"
|
||||
android:label="FlClash"
|
||||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
|
||||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
|
||||
>
|
||||
<intent-filter>
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE" />
|
||||
</intent-filter>
|
||||
@@ -86,11 +87,35 @@
|
||||
android:name="android.service.quicksettings.TOGGLEABLE_TILE"
|
||||
android:value="true" />
|
||||
</service>
|
||||
|
||||
<provider
|
||||
android:name=".FilesProvider"
|
||||
android:authorities="${applicationId}.files"
|
||||
android:exported="true"
|
||||
android:grantUriPermissions="true"
|
||||
android:permission="android.permission.MANAGE_DOCUMENTS"
|
||||
android:process=":background">
|
||||
<intent-filter>
|
||||
<action android:name="android.content.action.DOCUMENTS_PROVIDER" />
|
||||
</intent-filter>
|
||||
</provider>
|
||||
|
||||
<provider
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
android:authorities="${applicationId}.fileProvider"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true">
|
||||
<meta-data
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/file_paths" />
|
||||
</provider>
|
||||
|
||||
<service
|
||||
android:name=".services.FlClashVpnService"
|
||||
android:exported="false"
|
||||
android:foregroundServiceType="specialUse"
|
||||
android:permission="android.permission.BIND_VPN_SERVICE">
|
||||
android:permission="android.permission.BIND_VPN_SERVICE"
|
||||
>
|
||||
<intent-filter>
|
||||
<action android:name="android.net.VpnService" />
|
||||
</intent-filter>
|
||||
|
||||
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 12 KiB |
112
android/app/src/main/kotlin/com/follow/clash/FilesProvider.kt
Normal file
@@ -0,0 +1,112 @@
|
||||
package com.follow.clash
|
||||
|
||||
import android.database.Cursor
|
||||
import android.database.MatrixCursor
|
||||
import android.os.CancellationSignal
|
||||
import android.os.ParcelFileDescriptor
|
||||
import android.provider.DocumentsContract.Document
|
||||
import android.provider.DocumentsContract.Root
|
||||
import android.provider.DocumentsProvider
|
||||
import java.io.File
|
||||
import java.io.FileNotFoundException
|
||||
|
||||
|
||||
class FilesProvider : DocumentsProvider() {
|
||||
|
||||
companion object {
|
||||
private const val DEFAULT_ROOT_ID = "0"
|
||||
|
||||
private val DEFAULT_DOCUMENT_COLUMNS = arrayOf(
|
||||
Document.COLUMN_DOCUMENT_ID,
|
||||
Document.COLUMN_DISPLAY_NAME,
|
||||
Document.COLUMN_MIME_TYPE,
|
||||
Document.COLUMN_FLAGS,
|
||||
Document.COLUMN_SIZE,
|
||||
)
|
||||
private val DEFAULT_ROOT_COLUMNS = arrayOf(
|
||||
Root.COLUMN_ROOT_ID,
|
||||
Root.COLUMN_FLAGS,
|
||||
Root.COLUMN_ICON,
|
||||
Root.COLUMN_TITLE,
|
||||
Root.COLUMN_SUMMARY,
|
||||
Root.COLUMN_DOCUMENT_ID
|
||||
)
|
||||
}
|
||||
|
||||
override fun onCreate(): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun queryRoots(projection: Array<String>?): Cursor {
|
||||
return MatrixCursor(projection ?: DEFAULT_ROOT_COLUMNS).apply {
|
||||
newRow().apply {
|
||||
add(Root.COLUMN_ROOT_ID, DEFAULT_ROOT_ID)
|
||||
add(Root.COLUMN_FLAGS, Root.FLAG_LOCAL_ONLY)
|
||||
add(Root.COLUMN_ICON, R.mipmap.ic_launcher)
|
||||
add(Root.COLUMN_TITLE, context!!.getString(R.string.fl_clash))
|
||||
add(Root.COLUMN_SUMMARY, "Data")
|
||||
add(Root.COLUMN_DOCUMENT_ID, "/")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun queryChildDocuments(
|
||||
parentDocumentId: String,
|
||||
projection: Array<String>?,
|
||||
sortOrder: String?
|
||||
): Cursor {
|
||||
val result = MatrixCursor(resolveDocumentProjection(projection))
|
||||
val parentFile = if (parentDocumentId == "/") {
|
||||
context?.filesDir
|
||||
} else {
|
||||
File(parentDocumentId)
|
||||
} ?: throw FileNotFoundException("Parent directory not found")
|
||||
parentFile.listFiles()?.forEach { file ->
|
||||
includeFile(result, file)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
override fun queryDocument(documentId: String, projection: Array<String>?): Cursor {
|
||||
val result = MatrixCursor(resolveDocumentProjection(projection))
|
||||
val file = File(documentId)
|
||||
includeFile(result, file)
|
||||
return result
|
||||
}
|
||||
|
||||
override fun openDocument(
|
||||
documentId: String,
|
||||
mode: String,
|
||||
signal: CancellationSignal?
|
||||
): ParcelFileDescriptor {
|
||||
val file = File(documentId)
|
||||
val accessMode = ParcelFileDescriptor.parseMode(mode)
|
||||
return ParcelFileDescriptor.open(file, accessMode)
|
||||
}
|
||||
|
||||
private fun includeFile(result: MatrixCursor, file: File) {
|
||||
result.newRow().apply {
|
||||
add(Document.COLUMN_DOCUMENT_ID, file.absolutePath)
|
||||
add(Document.COLUMN_DISPLAY_NAME, file.name)
|
||||
add(Document.COLUMN_SIZE, file.length())
|
||||
add(
|
||||
Document.COLUMN_FLAGS,
|
||||
Document.FLAG_SUPPORTS_WRITE or Document.FLAG_SUPPORTS_DELETE
|
||||
)
|
||||
add(Document.COLUMN_MIME_TYPE, getDocumentType(file))
|
||||
}
|
||||
}
|
||||
|
||||
private fun getDocumentType(file: File): String {
|
||||
return if (file.isDirectory) {
|
||||
Document.MIME_TYPE_DIR
|
||||
} else {
|
||||
"application/octet-stream"
|
||||
}
|
||||
}
|
||||
|
||||
private fun resolveDocumentProjection(projection: Array<String>?): Array<String> {
|
||||
return projection ?: DEFAULT_DOCUMENT_COLUMNS
|
||||
}
|
||||
}
|
||||
@@ -57,8 +57,6 @@ object GlobalState {
|
||||
serviceEngine?.dartExecutor?.executeDartEntrypoint(
|
||||
vpnService,
|
||||
)
|
||||
|
||||
Log.e("FlClashVpnService", "initServiceEngine ===>")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,12 +4,14 @@ import android.Manifest
|
||||
import android.app.Activity
|
||||
import android.app.ActivityManager
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.pm.ApplicationInfo
|
||||
import android.content.pm.PackageManager
|
||||
import android.net.ConnectivityManager
|
||||
import android.os.Build
|
||||
import android.widget.Toast
|
||||
import androidx.core.content.ContextCompat.getSystemService
|
||||
import androidx.core.content.FileProvider
|
||||
import androidx.core.content.getSystemService
|
||||
import com.follow.clash.GlobalState
|
||||
import com.follow.clash.extensions.getBase64
|
||||
@@ -28,6 +30,7 @@ import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.cancel
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.io.File
|
||||
import java.net.InetSocketAddress
|
||||
|
||||
|
||||
@@ -61,7 +64,7 @@ class AppPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware
|
||||
}
|
||||
|
||||
private fun tip(message: String?) {
|
||||
if(GlobalState.flutterEngine == null){
|
||||
if (GlobalState.flutterEngine == null) {
|
||||
if (toast != null) {
|
||||
toast!!.cancel()
|
||||
}
|
||||
@@ -164,12 +167,56 @@ class AppPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware
|
||||
result.success(true)
|
||||
}
|
||||
|
||||
"openFile" -> {
|
||||
val path = call.argument<String>("path")!!
|
||||
openFile(path)
|
||||
result.success(true)
|
||||
}
|
||||
|
||||
else -> {
|
||||
result.notImplemented();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun openFile(path: String) {
|
||||
context?.let {
|
||||
val file = File(path)
|
||||
val uri = FileProvider.getUriForFile(
|
||||
it,
|
||||
"${it.packageName}.fileProvider",
|
||||
file
|
||||
)
|
||||
|
||||
val intent = Intent(Intent.ACTION_VIEW).setDataAndType(
|
||||
uri,
|
||||
"text/plain"
|
||||
)
|
||||
|
||||
val flags =
|
||||
Intent.FLAG_GRANT_WRITE_URI_PERMISSION or Intent.FLAG_GRANT_READ_URI_PERMISSION
|
||||
|
||||
val resInfoList = it.packageManager.queryIntentActivities(
|
||||
intent, PackageManager.MATCH_DEFAULT_ONLY
|
||||
)
|
||||
|
||||
for (resolveInfo in resInfoList) {
|
||||
val packageName = resolveInfo.activityInfo.packageName
|
||||
it.grantUriPermission(
|
||||
packageName,
|
||||
uri,
|
||||
flags
|
||||
)
|
||||
}
|
||||
|
||||
try {
|
||||
activity?.startActivity(intent)
|
||||
} catch (e: Exception) {
|
||||
println(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateExcludeFromRecents(value: Boolean?) {
|
||||
if (context == null) return
|
||||
val am = getSystemService(context!!, ActivityManager::class.java)
|
||||
@@ -241,4 +288,4 @@ class AppPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware
|
||||
channel.invokeMethod("exit", null)
|
||||
activity = null
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="240"
|
||||
android:viewportHeight="240"
|
||||
android:tint="#FFFFFF">
|
||||
<group android:scaleX="2.0264318"
|
||||
android:scaleY="2.0264318"
|
||||
android:translateX="-123.17181"
|
||||
android:translateY="-123.17181">
|
||||
<group android:scaleX="0.61"
|
||||
android:scaleY="0.61"
|
||||
android:translateX="46.8"
|
||||
android:translateY="46.8">
|
||||
<path
|
||||
android:pathData="M67.67,115.76L144.04,39.39A18,18 0,0 1,169.5 39.39L169.5,39.39A18,18 0,0 1,169.5 64.85L93.13,141.21A18,18 0,0 1,67.67 141.21L67.67,141.21A18,18 0,0 1,67.67 115.76z"
|
||||
android:fillColor="#6666FF"/>
|
||||
<path
|
||||
android:pathData="M98.79,146.87L136.97,108.69A18,18 72.93,0 1,162.43 108.69L162.43,108.69A18,18 72.93,0 1,162.43 134.14L124.24,172.33A18,18 76.87,0 1,98.79 172.33L98.79,172.33A18,18 76.87,0 1,98.79 146.87z"
|
||||
android:fillColor="#326CBF"/>
|
||||
<path
|
||||
android:pathData="M129.9,177.98L129.9,177.98A18,18 107.07,0 1,155.36 177.98L155.36,177.98A18,18 107.07,0 1,155.36 203.44L155.36,203.44A18,18 107.07,0 1,129.9 203.44L129.9,203.44A18,18 107.07,0 1,129.9 177.98z"
|
||||
android:fillColor="#56afee"/>
|
||||
</group>
|
||||
</group>
|
||||
</vector>
|
||||
|
Before Width: | Height: | Size: 532 B After Width: | Height: | Size: 618 B |
|
Before Width: | Height: | Size: 311 B After Width: | Height: | Size: 423 B |
|
Before Width: | Height: | Size: 671 B After Width: | Height: | Size: 803 B |
|
Before Width: | Height: | Size: 932 B After Width: | Height: | Size: 1.2 KiB |
BIN
android/app/src/main/res/drawable-xxxhdpi/ic_stat_name.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
@@ -3,23 +3,23 @@
|
||||
android:height="108dp"
|
||||
android:viewportWidth="240"
|
||||
android:viewportHeight="240">
|
||||
<group android:scaleX="0.90244895"
|
||||
android:scaleY="0.90244895"
|
||||
android:translateX="12.708843"
|
||||
android:translateY="10.703402">
|
||||
<group android:scaleX="0.61"
|
||||
android:scaleY="0.61"
|
||||
android:translateX="46.8"
|
||||
android:translateY="46.8">
|
||||
<group android:scaleX="0.924"
|
||||
android:scaleY="0.924"
|
||||
android:translateX="9.12"
|
||||
android:translateY="9.12">
|
||||
<group android:scaleX="0.63461536"
|
||||
android:scaleY="0.63461536"
|
||||
android:translateX="45.96154"
|
||||
android:translateY="43.846153">
|
||||
<path
|
||||
android:pathData="M67.67,115.76L144.04,39.39A18,18 0,0 1,169.5 39.39L169.5,39.39A18,18 0,0 1,169.5 64.85L93.13,141.21A18,18 0,0 1,67.67 141.21L67.67,141.21A18,18 0,0 1,67.67 115.76z"
|
||||
android:fillColor="#6666FF"/>
|
||||
android:pathData="M60.65,89.6L154.18,35.6A18,18 107.59,0 1,178.77 42.19L178.77,42.19A18,18 107.59,0 1,172.18 66.78L78.65,120.78A18,18 106.67,0 1,54.06 114.19L54.06,114.19A18,18 106.67,0 1,60.65 89.6z"
|
||||
android:fillColor="#6666FB"/>
|
||||
<path
|
||||
android:pathData="M98.79,146.87L136.97,108.69A18,18 72.93,0 1,162.43 108.69L162.43,108.69A18,18 72.93,0 1,162.43 134.14L124.24,172.33A18,18 76.87,0 1,98.79 172.33L98.79,172.33A18,18 76.87,0 1,98.79 146.87z"
|
||||
android:fillColor="#326CBF"/>
|
||||
android:pathData="M84.65,131.17L131.42,104.17A18,18 107.83,0 1,156 110.76L156,110.76A18,18 107.83,0 1,149.42 135.35L102.65,162.35A18,18 106.67,0 1,78.06 155.76L78.06,155.76A18,18 106.67,0 1,84.65 131.17z"
|
||||
android:fillColor="#336AB6"/>
|
||||
<path
|
||||
android:pathData="M129.9,177.98L129.9,177.98A18,18 107.07,0 1,155.36 177.98L155.36,177.98A18,18 107.07,0 1,155.36 203.44L155.36,203.44A18,18 107.07,0 1,129.9 203.44L129.9,203.44A18,18 107.07,0 1,129.9 177.98z"
|
||||
android:fillColor="#56afee"/>
|
||||
android:pathData="M108.65,172.74L108.65,172.74A18,18 116.03,0 1,133.24 179.33L133.24,179.33A18,18 116.03,0 1,126.65 203.92L126.65,203.92A18,18 116.03,0 1,102.06 197.33L102.06,197.33A18,18 116.03,0 1,108.65 172.74z"
|
||||
android:fillColor="#5CA8E9"/>
|
||||
</group>
|
||||
</group>
|
||||
</vector>
|
||||
|
||||
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 812 B After Width: | Height: | Size: 886 B |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 5.2 KiB |
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 7.1 KiB After Width: | Height: | Size: 7.1 KiB |
6
android/app/src/main/res/xml/file_paths.xml
Normal file
@@ -0,0 +1,6 @@
|
||||
<paths>
|
||||
<files-path
|
||||
name="files"
|
||||
path="."/>
|
||||
</paths>
|
||||
|
||||
|
Before Width: | Height: | Size: 9.4 KiB |
BIN
assets/images/avatars/arue.jpg
Normal file
|
After Width: | Height: | Size: 26 KiB |
BIN
assets/images/avatars/june2.jpg
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
assets/images/icon.ico
Normal file
|
After Width: | Height: | Size: 9.5 KiB |
BIN
assets/images/icon.png
Normal file
|
After Width: | Height: | Size: 20 KiB |
BIN
assets/images/icon_monochrome.png
Normal file
|
After Width: | Height: | Size: 7.0 KiB |
|
Before Width: | Height: | Size: 118 KiB |
@@ -410,7 +410,7 @@ func patchSelectGroup() {
|
||||
|
||||
var applyLock sync.Mutex
|
||||
|
||||
func applyConfig() {
|
||||
func applyConfig() error {
|
||||
applyLock.Lock()
|
||||
defer applyLock.Unlock()
|
||||
cfg, err := config.ParseRawConfig(currentConfig)
|
||||
@@ -423,8 +423,10 @@ func applyConfig() {
|
||||
if configParams.IsPatch {
|
||||
patchConfig(cfg.General)
|
||||
} else {
|
||||
closeConnections()
|
||||
runtime.GC()
|
||||
hub.UltraApplyConfig(cfg, true)
|
||||
patchSelectGroup()
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
18
core/go.mod
@@ -16,7 +16,6 @@ require (
|
||||
github.com/3andne/restls-client-go v0.1.6 // indirect
|
||||
github.com/RyuaNerin/go-krypto v1.2.4 // indirect
|
||||
github.com/Yawning/aez v0.0.0-20211027044916-e49e68abd344 // indirect
|
||||
github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da // indirect
|
||||
github.com/ajg/form v1.5.1 // indirect
|
||||
github.com/andybalholm/brotli v1.0.6 // indirect
|
||||
github.com/bahlo/generic-list-go v0.2.0 // indirect
|
||||
@@ -46,22 +45,23 @@ require (
|
||||
github.com/hashicorp/yamux v0.1.1 // indirect
|
||||
github.com/insomniacslk/dhcp v0.0.0-20240529192340-51bc6136a0a6 // indirect
|
||||
github.com/josharian/native v1.1.0 // indirect
|
||||
github.com/klauspost/compress v1.17.4 // indirect
|
||||
github.com/klauspost/compress v1.17.9 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.2.8 // indirect
|
||||
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
|
||||
github.com/lunixbochs/struc v0.0.0-20200707160740-784aaebc1d40 // indirect
|
||||
github.com/mailru/easyjson v0.7.7 // indirect
|
||||
github.com/mdlayher/netlink v1.7.2 // indirect
|
||||
github.com/mdlayher/socket v0.4.1 // indirect
|
||||
github.com/metacubex/chacha v0.1.0 // indirect
|
||||
github.com/metacubex/gopacket v1.1.20-0.20230608035415-7e2f98a3e759 // indirect
|
||||
github.com/metacubex/gvisor v0.0.0-20240320004321-933faba989ec // indirect
|
||||
github.com/metacubex/quic-go v0.45.1-0.20240610004319-163fee60637e // indirect
|
||||
github.com/metacubex/randv2 v0.2.0 // indirect
|
||||
github.com/metacubex/sing-quic v0.0.0-20240518034124-7696d3f7da72 // indirect
|
||||
github.com/metacubex/sing-shadowsocks v0.2.6 // indirect
|
||||
github.com/metacubex/sing-shadowsocks2 v0.2.0 // indirect
|
||||
github.com/metacubex/sing-tun v0.2.7-0.20240627012306-9d1f5fc0b45e // indirect
|
||||
github.com/metacubex/sing-vmess v0.1.9-0.20231207122118-72303677451f // indirect
|
||||
github.com/metacubex/sing-shadowsocks v0.2.7 // indirect
|
||||
github.com/metacubex/sing-shadowsocks2 v0.2.1 // indirect
|
||||
github.com/metacubex/sing-tun v0.2.7-0.20240719141246-19c49ac9589d // indirect
|
||||
github.com/metacubex/sing-vmess v0.1.9-0.20240719134745-1df6fb20bbf9 // indirect
|
||||
github.com/metacubex/sing-wireguard v0.0.0-20240618022557-a6efaa37127a // indirect
|
||||
github.com/metacubex/tfo-go v0.0.0-20240228025757-be1269474a66 // indirect
|
||||
github.com/metacubex/utls v1.6.6 // indirect
|
||||
@@ -76,9 +76,10 @@ require (
|
||||
github.com/quic-go/qpack v0.4.0 // indirect
|
||||
github.com/quic-go/qtls-go1-20 v0.4.1 // indirect
|
||||
github.com/sagernet/bbolt v0.0.0-20231014093535-ea5cb2fe9f0a // indirect
|
||||
github.com/sagernet/fswatch v0.1.1 // indirect
|
||||
github.com/sagernet/netlink v0.0.0-20240612041022-b9a21c07ac6a // indirect
|
||||
github.com/sagernet/nftables v0.3.0-beta.4 // indirect
|
||||
github.com/sagernet/sing v0.5.0-alpha.10 // indirect
|
||||
github.com/sagernet/sing v0.5.0-alpha.13 // indirect
|
||||
github.com/sagernet/sing-mux v0.2.1-0.20240124034317-9bfb33698bb6 // indirect
|
||||
github.com/sagernet/sing-shadowtls v0.1.4 // indirect
|
||||
github.com/sagernet/smux v0.0.0-20231208180855-7041f6ea79e7 // indirect
|
||||
@@ -96,13 +97,14 @@ require (
|
||||
github.com/vishvananda/netns v0.0.4 // indirect
|
||||
github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect
|
||||
github.com/yusufpapurcu/wmi v1.2.4 // indirect
|
||||
gitlab.com/go-extension/aes-ccm v0.0.0-20230221065045-e58665ef23c7 // indirect
|
||||
gitlab.com/yawning/bsaes.git v0.0.0-20190805113838-0a714cd429ec // indirect
|
||||
go.uber.org/mock v0.4.0 // indirect
|
||||
go4.org/netipx v0.0.0-20231129151722-fdeea329fbba // indirect
|
||||
golang.org/x/crypto v0.24.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect
|
||||
golang.org/x/mod v0.18.0 // indirect
|
||||
golang.org/x/sys v0.21.0 // indirect
|
||||
golang.org/x/sys v0.22.0 // indirect
|
||||
golang.org/x/text v0.16.0 // indirect
|
||||
golang.org/x/time v0.5.0 // indirect
|
||||
golang.org/x/tools v0.22.0 // indirect
|
||||
|
||||
36
core/go.sum
@@ -7,8 +7,6 @@ github.com/RyuaNerin/go-krypto v1.2.4 h1:mXuNdK6M317aPV0llW6Xpjbo4moOlPF7Yxz4tb4
|
||||
github.com/RyuaNerin/go-krypto v1.2.4/go.mod h1:QqCYkoutU3yInyD9INt2PGolVRsc3W4oraQadVGXJ/8=
|
||||
github.com/Yawning/aez v0.0.0-20211027044916-e49e68abd344 h1:cDVUiFo+npB0ZASqnw4q90ylaVAbnYyx0JYqK4YcGok=
|
||||
github.com/Yawning/aez v0.0.0-20211027044916-e49e68abd344/go.mod h1:9pIqrY6SXNL8vjRQE5Hd/OL5GyK/9MrGUWs87z/eFfk=
|
||||
github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da h1:KjTM2ks9d14ZYCvmHS9iAKVt9AyzRSqNU1qabPih5BY=
|
||||
github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da/go.mod h1:eHEWzANqSiWQsof+nXEI9bUVUyV6F53Fp89EuCh2EAA=
|
||||
github.com/ajg/form v1.5.1 h1:t9c7v8JUKu/XxOGBU0yjNpaMloxGEJhUkqFRq0ibGeU=
|
||||
github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY=
|
||||
github.com/andybalholm/brotli v1.0.6 h1:Yf9fFpf49Zrxb9NlQaluyE92/+X7UVHlhMNJN2sxfOI=
|
||||
@@ -90,8 +88,8 @@ github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFF
|
||||
github.com/josharian/native v1.0.1-0.20221213033349-c1e37c09b531/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w=
|
||||
github.com/josharian/native v1.1.0 h1:uuaP0hAbW7Y4l0ZRQ6C9zfb7Mg1mbFKry/xzDAfmtLA=
|
||||
github.com/josharian/native v1.1.0/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w=
|
||||
github.com/klauspost/compress v1.17.4 h1:Ej5ixsIri7BrIjBkRZLTo6ghwrEtHFk7ijlczPW4fZ4=
|
||||
github.com/klauspost/compress v1.17.4/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM=
|
||||
github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA=
|
||||
github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
|
||||
github.com/klauspost/cpuid/v2 v2.2.8 h1:+StwCXwm9PdpiEkPyzBXIy+M9KUb4ODm0Zarf1kS5BM=
|
||||
github.com/klauspost/cpuid/v2 v2.2.8/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
|
||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||
@@ -108,6 +106,8 @@ github.com/mdlayher/netlink v1.7.2 h1:/UtM3ofJap7Vl4QWCPDGXY8d3GIY2UGSDbK+QWmY8/
|
||||
github.com/mdlayher/netlink v1.7.2/go.mod h1:xraEF7uJbxLhc5fpHL4cPe221LI2bdttWlU+ZGLfQSw=
|
||||
github.com/mdlayher/socket v0.4.1 h1:eM9y2/jlbs1M615oshPQOHZzj6R6wMT7bX5NPiQvn2U=
|
||||
github.com/mdlayher/socket v0.4.1/go.mod h1:cAqeGjoufqdxWkD7DkpyS+wcefOtmu5OQ8KuoJGIReA=
|
||||
github.com/metacubex/chacha v0.1.0 h1:tg9RSJ18NvL38cCWNyYH1eiG6qDCyyXIaTLQthon0sc=
|
||||
github.com/metacubex/chacha v0.1.0/go.mod h1:Djn9bPZxLTXbJFSeyo0/qzEzQI+gUSSzttuzZM75GH8=
|
||||
github.com/metacubex/gopacket v1.1.20-0.20230608035415-7e2f98a3e759 h1:cjd4biTvOzK9ubNCCkQ+ldc4YSH/rILn53l/xGBFHHI=
|
||||
github.com/metacubex/gopacket v1.1.20-0.20230608035415-7e2f98a3e759/go.mod h1:UHOv2xu+RIgLwpXca7TLrXleEd4oR3sPatW6IF8wU88=
|
||||
github.com/metacubex/gvisor v0.0.0-20240320004321-933faba989ec h1:HxreOiFTUrJXJautEo8rnE1uKTVGY8wtZepY1Tii/Nc=
|
||||
@@ -118,14 +118,14 @@ github.com/metacubex/randv2 v0.2.0 h1:uP38uBvV2SxYfLj53kuvAjbND4RUDfFJjwr4UigMiL
|
||||
github.com/metacubex/randv2 v0.2.0/go.mod h1:kFi2SzrQ5WuneuoLLCMkABtiBu6VRrMrWFqSPyj2cxY=
|
||||
github.com/metacubex/sing-quic v0.0.0-20240518034124-7696d3f7da72 h1:Wr4g1HCb5Z/QIFwFiVNjO2qL+dRu25+Mdn9xtAZZ+ew=
|
||||
github.com/metacubex/sing-quic v0.0.0-20240518034124-7696d3f7da72/go.mod h1:g7Mxj7b7zm7YVqD975mk/hSmrb0A0G4bVvIMr2MMzn8=
|
||||
github.com/metacubex/sing-shadowsocks v0.2.6 h1:6oEB3QcsFYnNiFeoevcXrCwJ3sAablwVSgtE9R3QeFQ=
|
||||
github.com/metacubex/sing-shadowsocks v0.2.6/go.mod h1:zIkMeSnb8Mbf4hdqhw0pjzkn1d99YJ3JQm/VBg5WMTg=
|
||||
github.com/metacubex/sing-shadowsocks2 v0.2.0 h1:hqwT/AfI5d5UdPefIzR6onGHJfDXs5zgOM5QSgaM/9A=
|
||||
github.com/metacubex/sing-shadowsocks2 v0.2.0/go.mod h1:LCKF6j1P94zN8ZS+LXRK1gmYTVGB3squivBSXAFnOg8=
|
||||
github.com/metacubex/sing-tun v0.2.7-0.20240627012306-9d1f5fc0b45e h1:o+zohxPRo45P35fS9u1zfdBgr+L/7S0ObGU6YjbVBIc=
|
||||
github.com/metacubex/sing-tun v0.2.7-0.20240627012306-9d1f5fc0b45e/go.mod h1:WwJGbCx7bQcBzuQXiDOJvZH27R0kIjKNNlISIWsL6kM=
|
||||
github.com/metacubex/sing-vmess v0.1.9-0.20231207122118-72303677451f h1:QjXrHKbTMBip/C+R79bvbfr42xH1gZl3uFb0RELdZiQ=
|
||||
github.com/metacubex/sing-vmess v0.1.9-0.20231207122118-72303677451f/go.mod h1:olVkD4FChQ5gKMHG4ZzuD7+fMkJY1G8vwOKpRehjrmY=
|
||||
github.com/metacubex/sing-shadowsocks v0.2.7 h1:9f3Dt2+71TNp0e202llA2ug5h/rkWs2EZxQ5IMpf+9g=
|
||||
github.com/metacubex/sing-shadowsocks v0.2.7/go.mod h1:X3x88XtJpBxG0W0/ECOJL6Ib0SJ3xdniAkU/6/RMWU0=
|
||||
github.com/metacubex/sing-shadowsocks2 v0.2.1 h1:XIZBXlazp8EEoPp1S0DViAhLkJakjQ2f+AOwwdKKNYg=
|
||||
github.com/metacubex/sing-shadowsocks2 v0.2.1/go.mod h1:BhOug03a/RbI7y6hp6q+6ITM1dXjnLTmeWBHSTwvv2Q=
|
||||
github.com/metacubex/sing-tun v0.2.7-0.20240719141246-19c49ac9589d h1:iYlepjRCYlPXtELupDL+pQjGqkCnQz4KQOfKImP9sog=
|
||||
github.com/metacubex/sing-tun v0.2.7-0.20240719141246-19c49ac9589d/go.mod h1:olbEx9yVcaw5tHTNlRamRoxmMKcvDvcVS1YLnQGzvWE=
|
||||
github.com/metacubex/sing-vmess v0.1.9-0.20240719134745-1df6fb20bbf9 h1:OAXiCosqY8xKDp3pqTW3qbrCprZ1l6WkrXSFSCwyY4I=
|
||||
github.com/metacubex/sing-vmess v0.1.9-0.20240719134745-1df6fb20bbf9/go.mod h1:olVkD4FChQ5gKMHG4ZzuD7+fMkJY1G8vwOKpRehjrmY=
|
||||
github.com/metacubex/sing-wireguard v0.0.0-20240618022557-a6efaa37127a h1:NpSGclHJUYndUwBmyIpFBSoBVg8PoVX7QQKhYg0DjM0=
|
||||
github.com/metacubex/sing-wireguard v0.0.0-20240618022557-a6efaa37127a/go.mod h1:uY+BYb0UEknLrqvbGcwi9i++KgrKxsurysgI6G1Pveo=
|
||||
github.com/metacubex/tfo-go v0.0.0-20240228025757-be1269474a66 h1:as/aO/fM8nv4W4pOr9EETP6kV/Oaujk3fUNyQSJK61c=
|
||||
@@ -166,13 +166,15 @@ github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZV
|
||||
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
|
||||
github.com/sagernet/bbolt v0.0.0-20231014093535-ea5cb2fe9f0a h1:+NkI2670SQpQWvkkD2QgdTuzQG263YZ+2emfpeyGqW0=
|
||||
github.com/sagernet/bbolt v0.0.0-20231014093535-ea5cb2fe9f0a/go.mod h1:63s7jpZqcDAIpj8oI/1v4Izok+npJOHACFCU6+huCkM=
|
||||
github.com/sagernet/fswatch v0.1.1 h1:YqID+93B7VRfqIH3PArW/XpJv5H4OLEVWDfProGoRQs=
|
||||
github.com/sagernet/fswatch v0.1.1/go.mod h1:nz85laH0mkQqJfaOrqPpkwtU1znMFNVTpT/5oRsVz/o=
|
||||
github.com/sagernet/netlink v0.0.0-20240612041022-b9a21c07ac6a h1:ObwtHN2VpqE0ZNjr6sGeT00J8uU7JF4cNUdb44/Duis=
|
||||
github.com/sagernet/netlink v0.0.0-20240612041022-b9a21c07ac6a/go.mod h1:xLnfdiJbSp8rNqYEdIW/6eDO4mVoogml14Bh2hSiFpM=
|
||||
github.com/sagernet/nftables v0.3.0-beta.4 h1:kbULlAwAC3jvdGAC1P5Fa3GSxVwQJibNenDW2zaXr8I=
|
||||
github.com/sagernet/nftables v0.3.0-beta.4/go.mod h1:OQXAjvjNGGFxaTgVCSTRIhYB5/llyVDeapVoENYBDS8=
|
||||
github.com/sagernet/sing v0.2.18/go.mod h1:OL6k2F0vHmEzXz2KW19qQzu172FDgSbUSODylighuVo=
|
||||
github.com/sagernet/sing v0.5.0-alpha.10 h1:kuHl10gpjbKQAdQfyogQU3u0CVnpqC3wrAHe/+BFaXc=
|
||||
github.com/sagernet/sing v0.5.0-alpha.10/go.mod h1:ARkL0gM13/Iv5VCZmci/NuoOlePoIsW0m7BWfln/Hak=
|
||||
github.com/sagernet/sing v0.5.0-alpha.13 h1:fpR4TFZfu/9V3LbHSAnnnwcaXGMF8ijmAAPoY2WHSKw=
|
||||
github.com/sagernet/sing v0.5.0-alpha.13/go.mod h1:ARkL0gM13/Iv5VCZmci/NuoOlePoIsW0m7BWfln/Hak=
|
||||
github.com/sagernet/sing-mux v0.2.1-0.20240124034317-9bfb33698bb6 h1:5bCAkvDDzSMITiHFjolBwpdqYsvycdTu71FsMEFXQ14=
|
||||
github.com/sagernet/sing-mux v0.2.1-0.20240124034317-9bfb33698bb6/go.mod h1:khzr9AOPocLa+g53dBplwNDz4gdsyx/YM3swtAhlkHQ=
|
||||
github.com/sagernet/sing-shadowtls v0.1.4 h1:aTgBSJEgnumzFenPvc+kbD9/W0PywzWevnVpEx6Tw3k=
|
||||
@@ -218,6 +220,8 @@ github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/
|
||||
github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw=
|
||||
github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0=
|
||||
github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
|
||||
gitlab.com/go-extension/aes-ccm v0.0.0-20230221065045-e58665ef23c7 h1:UNrDfkQqiEYzdMlNsVvBYOAJWZjdktqFE9tQh5BT2+4=
|
||||
gitlab.com/go-extension/aes-ccm v0.0.0-20230221065045-e58665ef23c7/go.mod h1:E+rxHvJG9H6PUdzq9NRG6csuLN3XUx98BfGOVWNYnXs=
|
||||
gitlab.com/yawning/bsaes.git v0.0.0-20190805113838-0a714cd429ec h1:FpfFs4EhNehiVfzQttTuxanPIT43FtkkCFypIod8LHo=
|
||||
gitlab.com/yawning/bsaes.git v0.0.0-20190805113838-0a714cd429ec/go.mod h1:BZ1RAoRPbCxum9Grlv5aeksu2H8BiKehBYooU2LFiOQ=
|
||||
go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU=
|
||||
@@ -257,8 +261,8 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
|
||||
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
|
||||
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.21.0 h1:WVXCp+/EBEHOj53Rvu+7KiT/iElMrO8ACK16SMZ3jaA=
|
||||
golang.org/x/term v0.21.0/go.mod h1:ooXLefLobQVslOqselCNF4SxFAaoS6KujMbsGzSDmX0=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
|
||||
78
core/hub.go
@@ -13,8 +13,7 @@ import (
|
||||
"github.com/metacubex/mihomo/adapter/provider"
|
||||
"github.com/metacubex/mihomo/common/structure"
|
||||
"github.com/metacubex/mihomo/common/utils"
|
||||
"github.com/metacubex/mihomo/component/geodata"
|
||||
"github.com/metacubex/mihomo/component/mmdb"
|
||||
"github.com/metacubex/mihomo/component/updater"
|
||||
"github.com/metacubex/mihomo/config"
|
||||
"github.com/metacubex/mihomo/constant"
|
||||
cp "github.com/metacubex/mihomo/constant/provider"
|
||||
@@ -114,7 +113,11 @@ func updateConfig(s *C.char, port C.longlong) {
|
||||
configParams = params.Params
|
||||
prof := decorationConfig(params.ProfilePath, params.Config)
|
||||
currentConfig = prof
|
||||
applyConfig()
|
||||
err = applyConfig()
|
||||
if err != nil {
|
||||
bridge.SendToPort(i, err.Error())
|
||||
return
|
||||
}
|
||||
bridge.SendToPort(i, "")
|
||||
}()
|
||||
}
|
||||
@@ -164,35 +167,33 @@ func getProxies() *C.char {
|
||||
//export changeProxy
|
||||
func changeProxy(s *C.char) {
|
||||
paramsString := C.GoString(s)
|
||||
go func() {
|
||||
var params = &ChangeProxyParams{}
|
||||
err := json.Unmarshal([]byte(paramsString), params)
|
||||
if err != nil {
|
||||
log.Infoln("Unmarshal ChangeProxyParams %v", err)
|
||||
}
|
||||
groupName := *params.GroupName
|
||||
proxyName := *params.ProxyName
|
||||
proxies := tunnel.ProxiesWithProviders()
|
||||
group, ok := proxies[groupName]
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
adapterProxy := group.(*adapter.Proxy)
|
||||
selector, ok := adapterProxy.ProxyAdapter.(*outboundgroup.Selector)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
var params = &ChangeProxyParams{}
|
||||
err := json.Unmarshal([]byte(paramsString), params)
|
||||
if err != nil {
|
||||
log.Infoln("Unmarshal ChangeProxyParams %v", err)
|
||||
}
|
||||
groupName := *params.GroupName
|
||||
proxyName := *params.ProxyName
|
||||
proxies := tunnel.ProxiesWithProviders()
|
||||
group, ok := proxies[groupName]
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
adapterProxy := group.(*adapter.Proxy)
|
||||
selector, ok := adapterProxy.ProxyAdapter.(outboundgroup.SelectAble)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
err = selector.Set(proxyName)
|
||||
if err == nil {
|
||||
log.Infoln("[Selector] %s selected %s", groupName, proxyName)
|
||||
}
|
||||
}()
|
||||
err = selector.Set(proxyName)
|
||||
if err == nil {
|
||||
log.Infoln("[Selector] %s selected %s", groupName, proxyName)
|
||||
}
|
||||
}
|
||||
|
||||
//export getTraffic
|
||||
func getTraffic() *C.char {
|
||||
up, down := statistic.DefaultManager.Now()
|
||||
up, down := statistic.DefaultManager.Current(state.OnlyProxy)
|
||||
traffic := map[string]int64{
|
||||
"up": up,
|
||||
"down": down,
|
||||
@@ -207,7 +208,7 @@ func getTraffic() *C.char {
|
||||
|
||||
//export getTotalTraffic
|
||||
func getTotalTraffic() *C.char {
|
||||
up, down := statistic.DefaultManager.Total()
|
||||
up, down := statistic.DefaultManager.Total(state.OnlyProxy)
|
||||
traffic := map[string]int64{
|
||||
"up": up,
|
||||
"down": down,
|
||||
@@ -299,7 +300,7 @@ func getConnections() *C.char {
|
||||
}
|
||||
|
||||
//export closeConnections
|
||||
func closeConnections() bool {
|
||||
func closeConnections() {
|
||||
statistic.DefaultManager.Range(func(c statistic.Tracker) bool {
|
||||
err := c.Close()
|
||||
if err != nil {
|
||||
@@ -307,17 +308,16 @@ func closeConnections() bool {
|
||||
}
|
||||
return true
|
||||
})
|
||||
return true
|
||||
}
|
||||
|
||||
//export closeConnection
|
||||
func closeConnection(id *C.char) bool {
|
||||
func closeConnection(id *C.char) {
|
||||
connectionId := C.GoString(id)
|
||||
err := statistic.DefaultManager.Get(connectionId).Close()
|
||||
if err != nil {
|
||||
return false
|
||||
c := statistic.DefaultManager.Get(connectionId)
|
||||
if c == nil {
|
||||
return
|
||||
}
|
||||
return true
|
||||
_ = c.Close()
|
||||
}
|
||||
|
||||
//export getProviders
|
||||
@@ -398,25 +398,25 @@ func updateExternalProvider(providerName *C.char, providerType *C.char, port C.l
|
||||
return
|
||||
}
|
||||
case "MMDB":
|
||||
err := mmdb.DownloadMMDB(constant.Path.Resolve(providerNameString))
|
||||
err := updater.UpdateMMDB(constant.Path.Resolve(providerNameString))
|
||||
if err != nil {
|
||||
bridge.SendToPort(i, err.Error())
|
||||
return
|
||||
}
|
||||
case "ASN":
|
||||
err := mmdb.DownloadASN(constant.Path.Resolve(providerNameString))
|
||||
err := updater.UpdateASN(constant.Path.Resolve(providerNameString))
|
||||
if err != nil {
|
||||
bridge.SendToPort(i, err.Error())
|
||||
return
|
||||
}
|
||||
case "GeoIp":
|
||||
err := geodata.DownloadGeoIP(constant.Path.Resolve(providerNameString))
|
||||
err := updater.UpdateGeoIp(constant.Path.Resolve(providerNameString))
|
||||
if err != nil {
|
||||
bridge.SendToPort(i, err.Error())
|
||||
return
|
||||
}
|
||||
case "GeoSite":
|
||||
err := geodata.DownloadGeoSite(constant.Path.Resolve(providerNameString))
|
||||
err := updater.UpdateGeoSite(constant.Path.Resolve(providerNameString))
|
||||
if err != nil {
|
||||
bridge.SendToPort(i, err.Error())
|
||||
return
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
//go:build android
|
||||
|
||||
package main
|
||||
|
||||
import "C"
|
||||
@@ -21,11 +19,17 @@ type AndroidProps struct {
|
||||
SystemProxy bool `json:"systemProxy"`
|
||||
}
|
||||
|
||||
var androidProps AndroidProps
|
||||
type State struct {
|
||||
AndroidProps
|
||||
MixedPort int `json:"mixedPort"`
|
||||
OnlyProxy bool `json:"onlyProxy"`
|
||||
}
|
||||
|
||||
//export getAndroidProps
|
||||
func getAndroidProps() *C.char {
|
||||
data, err := json.Marshal(androidProps)
|
||||
var state State
|
||||
|
||||
//export getState
|
||||
func getState() *C.char {
|
||||
data, err := json.Marshal(state)
|
||||
if err != nil {
|
||||
fmt.Println("Error:", err)
|
||||
return C.CString("")
|
||||
@@ -33,10 +37,10 @@ func getAndroidProps() *C.char {
|
||||
return C.CString(string(data))
|
||||
}
|
||||
|
||||
//export setAndroidProps
|
||||
func setAndroidProps(s *C.char) {
|
||||
//export setState
|
||||
func setState(s *C.char) {
|
||||
paramsString := C.GoString(s)
|
||||
err := json.Unmarshal([]byte(paramsString), &androidProps)
|
||||
err := json.Unmarshal([]byte(paramsString), &state)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -128,7 +128,7 @@ class ApplicationState extends State<Application> {
|
||||
globalState.groupsUpdateTimer ??= Timer.periodic(
|
||||
httpTimeoutDuration,
|
||||
(timer) async {
|
||||
await globalState.appController.updateGroups();
|
||||
await globalState.appController.updateGroupDebounce();
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -136,7 +136,7 @@ class ApplicationState extends State<Application> {
|
||||
@override
|
||||
Widget build(context) {
|
||||
return AppStateContainer(
|
||||
child: ClashMessageContainer(
|
||||
child: ClashContainer(
|
||||
child: Selector2<AppState, Config, ApplicationSelectorState>(
|
||||
selector: (_, appState, config) => ApplicationSelectorState(
|
||||
locale: config.locale,
|
||||
@@ -157,9 +157,7 @@ class ApplicationState extends State<Application> {
|
||||
GlobalWidgetsLocalizations.delegate
|
||||
],
|
||||
builder: (_, child) {
|
||||
return PopContainer(
|
||||
child: _buildApp(child!),
|
||||
);
|
||||
return _buildApp(child!);
|
||||
},
|
||||
scrollBehavior: BaseScrollBehavior(),
|
||||
title: appName,
|
||||
|
||||
@@ -128,8 +128,7 @@ class ClashCore {
|
||||
UsedProxy.GLOBAL.name,
|
||||
...(proxies[UsedProxy.GLOBAL.name]["all"] as List).where((e) {
|
||||
final proxy = proxies[e] ?? {};
|
||||
return GroupTypeExtension.valueList.contains(proxy['type']) &&
|
||||
proxy['hidden'] != true;
|
||||
return GroupTypeExtension.valueList.contains(proxy['type']);
|
||||
})
|
||||
];
|
||||
final groupsRaw = groupNames.map((groupName) {
|
||||
@@ -142,7 +141,11 @@ class ClashCore {
|
||||
.toList();
|
||||
return group;
|
||||
}).toList();
|
||||
return groupsRaw.map((e) => Group.fromJson(e)).toList();
|
||||
return groupsRaw
|
||||
.map(
|
||||
(e) => Group.fromJson(e),
|
||||
)
|
||||
.toList();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -237,19 +240,19 @@ class ClashCore {
|
||||
return VersionInfo.fromJson(versionInfo);
|
||||
}
|
||||
|
||||
setProps(Props props) {
|
||||
final propsChar = json.encode(props).toNativeUtf8().cast<Char>();
|
||||
clashFFI.setAndroidProps(propsChar);
|
||||
malloc.free(propsChar);
|
||||
setState(CoreState state) {
|
||||
final stateChar = json.encode(state).toNativeUtf8().cast<Char>();
|
||||
clashFFI.setState(stateChar);
|
||||
malloc.free(stateChar);
|
||||
}
|
||||
|
||||
Props getProps() {
|
||||
final androidPropsRaw = clashFFI.getAndroidProps();
|
||||
final androidProps = json.decode(
|
||||
androidPropsRaw.cast<Utf8>().toDartString(),
|
||||
CoreState getState() {
|
||||
final stateRaw = clashFFI.getState();
|
||||
final state = json.decode(
|
||||
stateRaw.cast<Utf8>().toDartString(),
|
||||
);
|
||||
clashFFI.freeCString(androidPropsRaw);
|
||||
return Props.fromJson(androidProps);
|
||||
clashFFI.freeCString(stateRaw);
|
||||
return CoreState.fromJson(state);
|
||||
}
|
||||
|
||||
Traffic getTraffic() {
|
||||
@@ -319,11 +322,15 @@ class ClashCore {
|
||||
return connectionsRaw.map((e) => Connection.fromJson(e)).toList();
|
||||
}
|
||||
|
||||
closeConnections(String id) {
|
||||
closeConnection(String id) {
|
||||
final idChar = id.toNativeUtf8().cast<Char>();
|
||||
clashFFI.closeConnection(idChar);
|
||||
malloc.free(idChar);
|
||||
}
|
||||
|
||||
closeConnections() {
|
||||
clashFFI.closeConnections();
|
||||
}
|
||||
}
|
||||
|
||||
final clashCore = ClashCore();
|
||||
|
||||
@@ -5351,16 +5351,16 @@ class ClashFFI {
|
||||
late final _getConnections =
|
||||
_getConnectionsPtr.asFunction<ffi.Pointer<ffi.Char> Function()>();
|
||||
|
||||
int closeConnections() {
|
||||
void closeConnections() {
|
||||
return _closeConnections();
|
||||
}
|
||||
|
||||
late final _closeConnectionsPtr =
|
||||
_lookup<ffi.NativeFunction<GoUint8 Function()>>('closeConnections');
|
||||
_lookup<ffi.NativeFunction<ffi.Void Function()>>('closeConnections');
|
||||
late final _closeConnections =
|
||||
_closeConnectionsPtr.asFunction<int Function()>();
|
||||
_closeConnectionsPtr.asFunction<void Function()>();
|
||||
|
||||
int closeConnection(
|
||||
void closeConnection(
|
||||
ffi.Pointer<ffi.Char> id,
|
||||
) {
|
||||
return _closeConnection(
|
||||
@@ -5369,10 +5369,10 @@ class ClashFFI {
|
||||
}
|
||||
|
||||
late final _closeConnectionPtr =
|
||||
_lookup<ffi.NativeFunction<GoUint8 Function(ffi.Pointer<ffi.Char>)>>(
|
||||
_lookup<ffi.NativeFunction<ffi.Void Function(ffi.Pointer<ffi.Char>)>>(
|
||||
'closeConnection');
|
||||
late final _closeConnection =
|
||||
_closeConnectionPtr.asFunction<int Function(ffi.Pointer<ffi.Char>)>();
|
||||
_closeConnectionPtr.asFunction<void Function(ffi.Pointer<ffi.Char>)>();
|
||||
|
||||
ffi.Pointer<ffi.Char> getProviders() {
|
||||
return _getProviders();
|
||||
@@ -5499,29 +5499,28 @@ class ClashFFI {
|
||||
late final _setProcessMap =
|
||||
_setProcessMapPtr.asFunction<void Function(ffi.Pointer<ffi.Char>)>();
|
||||
|
||||
ffi.Pointer<ffi.Char> getAndroidProps() {
|
||||
return _getAndroidProps();
|
||||
ffi.Pointer<ffi.Char> getState() {
|
||||
return _getState();
|
||||
}
|
||||
|
||||
late final _getAndroidPropsPtr =
|
||||
_lookup<ffi.NativeFunction<ffi.Pointer<ffi.Char> Function()>>(
|
||||
'getAndroidProps');
|
||||
late final _getAndroidProps =
|
||||
_getAndroidPropsPtr.asFunction<ffi.Pointer<ffi.Char> Function()>();
|
||||
late final _getStatePtr =
|
||||
_lookup<ffi.NativeFunction<ffi.Pointer<ffi.Char> Function()>>('getState');
|
||||
late final _getState =
|
||||
_getStatePtr.asFunction<ffi.Pointer<ffi.Char> Function()>();
|
||||
|
||||
void setAndroidProps(
|
||||
void setState(
|
||||
ffi.Pointer<ffi.Char> s,
|
||||
) {
|
||||
return _setAndroidProps(
|
||||
return _setState(
|
||||
s,
|
||||
);
|
||||
}
|
||||
|
||||
late final _setAndroidPropsPtr =
|
||||
late final _setStatePtr =
|
||||
_lookup<ffi.NativeFunction<ffi.Void Function(ffi.Pointer<ffi.Char>)>>(
|
||||
'setAndroidProps');
|
||||
late final _setAndroidProps =
|
||||
_setAndroidPropsPtr.asFunction<void Function(ffi.Pointer<ffi.Char>)>();
|
||||
'setState');
|
||||
late final _setState =
|
||||
_setStatePtr.asFunction<void Function(ffi.Pointer<ffi.Char>)>();
|
||||
|
||||
void startTUN(
|
||||
int fd,
|
||||
|
||||
@@ -8,7 +8,7 @@ import 'system.dart';
|
||||
|
||||
const appName = "FlClash";
|
||||
const coreName = "clash.meta";
|
||||
const packageName = "FlClash";
|
||||
const packageName = "com.follow.clash";
|
||||
const httpTimeoutDuration = Duration(milliseconds: 5000);
|
||||
const moreDuration = Duration(milliseconds: 100);
|
||||
const animateDuration = Duration(milliseconds: 100);
|
||||
|
||||
@@ -10,4 +10,58 @@ extension IterableExt<T> on Iterable<T> {
|
||||
yield iterator.current;
|
||||
}
|
||||
}
|
||||
|
||||
Iterable<List<T>> chunks(int size) sync* {
|
||||
if (length == 0) return;
|
||||
var iterator = this.iterator;
|
||||
while (iterator.moveNext()) {
|
||||
var chunk = [iterator.current];
|
||||
for (var i = 1; i < size && iterator.moveNext(); i++) {
|
||||
chunk.add(iterator.current);
|
||||
}
|
||||
yield chunk;
|
||||
}
|
||||
}
|
||||
|
||||
Iterable<T> fill(
|
||||
int length, {
|
||||
required T Function(int count) filler,
|
||||
}) sync* {
|
||||
int count = 0;
|
||||
for (var item in this) {
|
||||
yield item;
|
||||
count++;
|
||||
if (count >= length) return;
|
||||
}
|
||||
while (count < length) {
|
||||
yield filler(count);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension DoubleListExt on List<double> {
|
||||
int findInterval(num target) {
|
||||
if (isEmpty) return -1;
|
||||
if (target < first) return -1;
|
||||
if (target >= last) return length - 1;
|
||||
|
||||
int left = 0;
|
||||
int right = length - 1;
|
||||
|
||||
while (left <= right) {
|
||||
int mid = left + (right - left) ~/ 2;
|
||||
|
||||
if (mid == length - 1 ||
|
||||
(this[mid] <= target && target < this[mid + 1])) {
|
||||
return mid;
|
||||
} else if (target < this[mid]) {
|
||||
right = mid - 1;
|
||||
} else {
|
||||
left = mid + 1;
|
||||
}
|
||||
}
|
||||
|
||||
return -1; // 这行理论上不会执行到,但为了完整性保留
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,9 +101,9 @@ class Other {
|
||||
|
||||
String getTrayIconPath() {
|
||||
if (Platform.isWindows) {
|
||||
return "assets/images/app_icon.ico";
|
||||
return "assets/images/icon.ico";
|
||||
} else {
|
||||
return "assets/images/launch_icon.png";
|
||||
return "assets/images/icon_monochrome.png";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ class Request {
|
||||
"https://ipinfo.io/json/": IpInfo.fromIpInfoIoJson,
|
||||
};
|
||||
|
||||
Future<IpInfo?> checkIp(CancelToken? cancelToken) async {
|
||||
Future<IpInfo?> checkIp({CancelToken? cancelToken}) async {
|
||||
for (final source in _ipInfoSources.entries) {
|
||||
try {
|
||||
final response = await _dio
|
||||
|
||||
@@ -14,3 +14,14 @@ class BaseScrollBehavior extends MaterialScrollBehavior {
|
||||
PointerDeviceKind.unknown,
|
||||
};
|
||||
}
|
||||
|
||||
class HiddenBarScrollBehavior extends BaseScrollBehavior {
|
||||
@override
|
||||
Widget buildScrollbar(
|
||||
BuildContext context,
|
||||
Widget child,
|
||||
ScrollableDetails details,
|
||||
) {
|
||||
return child;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ class Window {
|
||||
await windowManager.ensureInitialized();
|
||||
WindowOptions windowOptions = WindowOptions(
|
||||
size: Size(props.width, props.height),
|
||||
minimumSize: const Size(380, 600),
|
||||
minimumSize: const Size(380, 500),
|
||||
titleBarStyle: TitleBarStyle.hidden,
|
||||
);
|
||||
if (props.left != null || props.top != null) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:fl_clash/enum/enum.dart';
|
||||
import 'package:fl_clash/state.dart';
|
||||
@@ -17,6 +18,7 @@ class AppController {
|
||||
late ClashConfig clashConfig;
|
||||
late Measure measure;
|
||||
late Function updateClashConfigDebounce;
|
||||
late Function updateGroupDebounce;
|
||||
late Function addCheckIpNumDebounce;
|
||||
|
||||
AppController(this.context) {
|
||||
@@ -29,6 +31,9 @@ class AppController {
|
||||
addCheckIpNumDebounce = debounce(() {
|
||||
appState.checkIpNum++;
|
||||
});
|
||||
updateGroupDebounce = debounce(() async {
|
||||
await updateGroups();
|
||||
});
|
||||
measure = Measure.of(context);
|
||||
}
|
||||
|
||||
@@ -45,12 +50,15 @@ class AppController {
|
||||
updateRunTime,
|
||||
updateTraffic,
|
||||
];
|
||||
if (Platform.isAndroid) return;
|
||||
await applyProfile(isPrue: true);
|
||||
} else {
|
||||
await globalState.stopSystemProxy();
|
||||
clashCore.resetTraffic();
|
||||
appState.traffics = [];
|
||||
appState.totalTraffic = Traffic();
|
||||
appState.runTime = null;
|
||||
addCheckIpNumDebounce();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,7 +98,7 @@ class AppController {
|
||||
final updateId = config.profiles.first.id;
|
||||
changeProfile(updateId);
|
||||
} else {
|
||||
changeProfile(null);
|
||||
updateSystemProxy(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -108,24 +116,25 @@ class AppController {
|
||||
);
|
||||
}
|
||||
|
||||
Future applyProfile() async {
|
||||
final commonScaffoldState = globalState.homeScaffoldKey.currentState;
|
||||
if (commonScaffoldState?.mounted != true) return;
|
||||
commonScaffoldState?.loadingRun(() async {
|
||||
Future applyProfile({bool isPrue = false}) async {
|
||||
if (isPrue) {
|
||||
await globalState.applyProfile(
|
||||
appState: appState,
|
||||
config: config,
|
||||
clashConfig: clashConfig,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Future rawApplyProfile() async {
|
||||
await globalState.applyProfile(
|
||||
appState: appState,
|
||||
config: config,
|
||||
clashConfig: clashConfig,
|
||||
);
|
||||
} else {
|
||||
final commonScaffoldState = globalState.homeScaffoldKey.currentState;
|
||||
if (commonScaffoldState?.mounted != true) return;
|
||||
await commonScaffoldState?.loadingRun(() async {
|
||||
await globalState.applyProfile(
|
||||
appState: appState,
|
||||
config: config,
|
||||
clashConfig: clashConfig,
|
||||
);
|
||||
});
|
||||
}
|
||||
addCheckIpNumDebounce();
|
||||
}
|
||||
|
||||
changeProfile(String? value) async {
|
||||
@@ -192,6 +201,18 @@ class AppController {
|
||||
await preferences.saveClashConfig(clashConfig);
|
||||
}
|
||||
|
||||
changeProxy({
|
||||
required String groupName,
|
||||
required String proxyName,
|
||||
}) {
|
||||
globalState.changeProxy(
|
||||
config: config,
|
||||
groupName: groupName,
|
||||
proxyName: proxyName,
|
||||
);
|
||||
addCheckIpNumDebounce();
|
||||
}
|
||||
|
||||
handleBackOrExit() async {
|
||||
if (config.isMinimizeOnExit) {
|
||||
if (system.isDesktop) {
|
||||
@@ -383,6 +404,10 @@ class AppController {
|
||||
|
||||
addProfileFormFile() async {
|
||||
final platformFile = await globalState.safeRun(picker.pickerConfigFile);
|
||||
final bytes = platformFile?.bytes;
|
||||
if (bytes == null) {
|
||||
return null;
|
||||
}
|
||||
if (!context.mounted) return;
|
||||
globalState.navigatorKey.currentState?.popUntil((route) => route.isFirst);
|
||||
toProfiles();
|
||||
@@ -391,10 +416,6 @@ class AppController {
|
||||
final profile = await commonScaffoldState?.loadingRun<Profile?>(
|
||||
() async {
|
||||
await Future.delayed(const Duration(milliseconds: 300));
|
||||
final bytes = platformFile?.bytes;
|
||||
if (bytes == null) {
|
||||
return null;
|
||||
}
|
||||
return await Profile.normal(label: platformFile?.name).saveFile(bytes);
|
||||
},
|
||||
title: "${appLocalizations.add}${appLocalizations.profile}",
|
||||
@@ -410,8 +431,7 @@ class AppController {
|
||||
addProfileFormURL(url);
|
||||
}
|
||||
|
||||
int get columns =>
|
||||
other.getColumns(appState.viewMode, config.proxiesColumns);
|
||||
int get columns => other.getColumns(appState.viewMode, config.proxiesColumns);
|
||||
|
||||
updateViewWidth(double width) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
@@ -453,4 +473,11 @@ class AppController {
|
||||
ProxiesSortType.name => _sortOfName(proxies),
|
||||
};
|
||||
}
|
||||
|
||||
String getCurrentSelectedName(String groupName) {
|
||||
final group = appState.getGroupWithName(groupName);
|
||||
return group?.getCurrentSelectedName(
|
||||
config.currentSelectedMap[groupName] ?? '') ??
|
||||
'';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,20 @@
|
||||
import 'package:fl_clash/common/common.dart';
|
||||
import 'package:fl_clash/state.dart';
|
||||
import 'package:fl_clash/widgets/list.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
@immutable
|
||||
class Contributor {
|
||||
final String avatar;
|
||||
final String name;
|
||||
final String link;
|
||||
|
||||
const Contributor({
|
||||
required this.avatar,
|
||||
required this.name,
|
||||
required this.link,
|
||||
});
|
||||
}
|
||||
|
||||
class AboutFragment extends StatelessWidget {
|
||||
const AboutFragment({super.key});
|
||||
@@ -9,8 +22,7 @@ class AboutFragment extends StatelessWidget {
|
||||
_checkUpdate(BuildContext context) async {
|
||||
final commonScaffoldState = context.commonScaffoldState;
|
||||
if (commonScaffoldState?.mounted != true) return;
|
||||
final data =
|
||||
await commonScaffoldState?.loadingRun<Map<String, dynamic>?>(
|
||||
final data = await commonScaffoldState?.loadingRun<Map<String, dynamic>?>(
|
||||
request.checkForUpdate,
|
||||
title: appLocalizations.checkUpdate,
|
||||
);
|
||||
@@ -20,84 +32,40 @@ class AboutFragment extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListView(
|
||||
padding: kMaterialListPadding.copyWith(
|
||||
top: 16,
|
||||
bottom: 16,
|
||||
),
|
||||
children: [
|
||||
ListTile(
|
||||
title: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Wrap(
|
||||
spacing: 16,
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
children: [
|
||||
Image.asset(
|
||||
'assets/images/launch_icon.png',
|
||||
width: 100,
|
||||
height: 100,
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
appName,
|
||||
style: Theme.of(context).textTheme.headlineSmall,
|
||||
),
|
||||
Text(
|
||||
globalState.packageInfo.version,
|
||||
style: Theme.of(context).textTheme.labelLarge,
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 24,
|
||||
),
|
||||
Text(
|
||||
appLocalizations.desc,
|
||||
style: Theme.of(context).textTheme.bodySmall,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
ListTile(
|
||||
List<Widget> _buildMoreSection(BuildContext context) {
|
||||
return generateSection(
|
||||
separated: false,
|
||||
title: appLocalizations.more,
|
||||
items: [
|
||||
ListItem(
|
||||
title: Text(appLocalizations.checkUpdate),
|
||||
onTap: () {
|
||||
_checkUpdate(context);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
ListItem(
|
||||
title: const Text("Telegram"),
|
||||
onTap: () {
|
||||
launchUrl(
|
||||
Uri.parse("https://t.me/+G-veVtwBOl4wODc1"),
|
||||
globalState.openUrl(
|
||||
"https://t.me/+G-veVtwBOl4wODc1",
|
||||
);
|
||||
},
|
||||
trailing: const Icon(Icons.launch),
|
||||
),
|
||||
ListTile(
|
||||
ListItem(
|
||||
title: Text(appLocalizations.project),
|
||||
onTap: () {
|
||||
launchUrl(
|
||||
Uri.parse("https://github.com/$repository"),
|
||||
globalState.openUrl(
|
||||
"https://github.com/$repository",
|
||||
);
|
||||
},
|
||||
trailing: const Icon(Icons.launch),
|
||||
),
|
||||
ListTile(
|
||||
ListItem(
|
||||
title: Text(appLocalizations.core),
|
||||
onTap: () {
|
||||
launchUrl(
|
||||
Uri.parse("https://github.com/chen08209/Clash.Meta/tree/FlClash"),
|
||||
globalState.openUrl(
|
||||
"https://github.com/chen08209/Clash.Meta/tree/FlClash",
|
||||
);
|
||||
},
|
||||
trailing: const Icon(Icons.launch),
|
||||
@@ -105,4 +73,139 @@ class AboutFragment extends StatelessWidget {
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
List<Widget> _buildContributorsSection() {
|
||||
const contributors = [
|
||||
Contributor(
|
||||
avatar: "assets/images/avatars/june2.jpg",
|
||||
name: "June2",
|
||||
link: "https://t.me/Jibadong",
|
||||
),
|
||||
Contributor(
|
||||
avatar: "assets/images/avatars/arue.jpg",
|
||||
name: "Arue",
|
||||
link: "https://t.me/xrcm6868",
|
||||
),
|
||||
];
|
||||
return generateSection(
|
||||
separated: false,
|
||||
title: appLocalizations.otherContributors,
|
||||
items: [
|
||||
ListItem(
|
||||
title: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Wrap(
|
||||
spacing: 24,
|
||||
children: [
|
||||
for (final contributor in contributors)
|
||||
Avatar(
|
||||
contributor: contributor,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final items = [
|
||||
ListTile(
|
||||
title: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Wrap(
|
||||
spacing: 16,
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: Image.asset(
|
||||
'assets/images/icon.png',
|
||||
width: 64,
|
||||
height: 64,
|
||||
),
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
appName,
|
||||
style: Theme.of(context).textTheme.headlineSmall,
|
||||
),
|
||||
Text(
|
||||
globalState.packageInfo.version,
|
||||
style: Theme.of(context).textTheme.labelLarge,
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 24,
|
||||
),
|
||||
Text(
|
||||
appLocalizations.desc,
|
||||
style: Theme.of(context).textTheme.bodySmall,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
..._buildContributorsSection(),
|
||||
..._buildMoreSection(context),
|
||||
];
|
||||
return Padding(
|
||||
padding: kMaterialListPadding.copyWith(
|
||||
top: 16,
|
||||
bottom: 16,
|
||||
),
|
||||
child: generateListView(items),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class Avatar extends StatelessWidget {
|
||||
final Contributor contributor;
|
||||
|
||||
const Avatar({
|
||||
super.key,
|
||||
required this.contributor,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
splashColor: Colors.transparent,
|
||||
highlightColor: Colors.transparent,
|
||||
hoverColor: Colors.transparent,
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 36,
|
||||
height: 36,
|
||||
child: CircleAvatar(
|
||||
foregroundImage: AssetImage(
|
||||
contributor.avatar,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 4,
|
||||
),
|
||||
Text(
|
||||
contributor.name,
|
||||
style: context.textTheme.bodySmall,
|
||||
)
|
||||
],
|
||||
),
|
||||
onTap: () {
|
||||
globalState.openUrl(contributor.link);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,49 +111,49 @@ class _AccessFragmentState extends State<AccessFragment> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSelectedAllButton({
|
||||
required bool isAccessControl,
|
||||
required bool isSelectedAll,
|
||||
required List<String> allValueList,
|
||||
}) {
|
||||
final tooltip = isSelectedAll
|
||||
? appLocalizations.cancelSelectAll
|
||||
: appLocalizations.selectAll;
|
||||
return AbsorbPointer(
|
||||
absorbing: !isAccessControl,
|
||||
child: FloatingActionButton(
|
||||
tooltip: tooltip,
|
||||
onPressed: () {
|
||||
final config = globalState.appController.config;
|
||||
final isAccept =
|
||||
config.accessControl.mode == AccessControlMode.acceptSelected;
|
||||
|
||||
if (isSelectedAll) {
|
||||
config.accessControl = switch (isAccept) {
|
||||
true => config.accessControl.copyWith(
|
||||
acceptList: [],
|
||||
),
|
||||
false => config.accessControl.copyWith(
|
||||
rejectList: [],
|
||||
),
|
||||
};
|
||||
} else {
|
||||
config.accessControl = switch (isAccept) {
|
||||
true => config.accessControl.copyWith(
|
||||
acceptList: allValueList,
|
||||
),
|
||||
false => config.accessControl.copyWith(
|
||||
rejectList: allValueList,
|
||||
),
|
||||
};
|
||||
}
|
||||
},
|
||||
child: isSelectedAll
|
||||
? const Icon(Icons.deselect)
|
||||
: const Icon(Icons.select_all),
|
||||
),
|
||||
);
|
||||
}
|
||||
// Widget _buildSelectedAllButton({
|
||||
// required bool isAccessControl,
|
||||
// required bool isSelectedAll,
|
||||
// required List<String> allValueList,
|
||||
// }) {
|
||||
// final tooltip = isSelectedAll
|
||||
// ? appLocalizations.cancelSelectAll
|
||||
// : appLocalizations.selectAll;
|
||||
// return AbsorbPointer(
|
||||
// absorbing: !isAccessControl,
|
||||
// child: FloatingActionButton(
|
||||
// tooltip: tooltip,
|
||||
// onPressed: () {
|
||||
// final config = globalState.appController.config;
|
||||
// final isAccept =
|
||||
// config.accessControl.mode == AccessControlMode.acceptSelected;
|
||||
//
|
||||
// if (isSelectedAll) {
|
||||
// config.accessControl = switch (isAccept) {
|
||||
// true => config.accessControl.copyWith(
|
||||
// acceptList: [],
|
||||
// ),
|
||||
// false => config.accessControl.copyWith(
|
||||
// rejectList: [],
|
||||
// ),
|
||||
// };
|
||||
// } else {
|
||||
// config.accessControl = switch (isAccept) {
|
||||
// true => config.accessControl.copyWith(
|
||||
// acceptList: allValueList,
|
||||
// ),
|
||||
// false => config.accessControl.copyWith(
|
||||
// rejectList: allValueList,
|
||||
// ),
|
||||
// };
|
||||
// }
|
||||
// },
|
||||
// child: isSelectedAll
|
||||
// ? const Icon(Icons.deselect)
|
||||
// : const Icon(Icons.select_all),
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
|
||||
Widget _buildPackageList() {
|
||||
return ValueListenableBuilder(
|
||||
@@ -207,139 +207,130 @@ class _AccessFragmentState extends State<AccessFragment> {
|
||||
: appLocalizations.accessControlNotAllowDesc;
|
||||
return DisabledMask(
|
||||
status: !isAccessControl,
|
||||
child: FloatLayout(
|
||||
floatingWidget: FloatWrapper(
|
||||
child: _buildSelectedAllButton(
|
||||
isAccessControl: isAccessControl,
|
||||
isSelectedAll: valueList.length == packageNameList.length,
|
||||
allValueList: packageNameList,
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
AbsorbPointer(
|
||||
absorbing: !isAccessControl,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 4,
|
||||
bottom: 4,
|
||||
left: 16,
|
||||
right: 8,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Expanded(
|
||||
child: IntrinsicHeight(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Row(
|
||||
children: [
|
||||
Flexible(
|
||||
child: Text(
|
||||
appLocalizations.selected,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.labelLarge
|
||||
?.copyWith(
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.primary,
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
AbsorbPointer(
|
||||
absorbing: !isAccessControl,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 4,
|
||||
bottom: 4,
|
||||
left: 16,
|
||||
right: 8,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Expanded(
|
||||
child: IntrinsicHeight(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Row(
|
||||
children: [
|
||||
Flexible(
|
||||
child: Text(
|
||||
appLocalizations.selected,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.labelLarge
|
||||
?.copyWith(
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.primary,
|
||||
),
|
||||
),
|
||||
const Flexible(
|
||||
child: SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
const Flexible(
|
||||
child: SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
child: Text(
|
||||
"${valueList.length}",
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.labelLarge
|
||||
?.copyWith(
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.primary,
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
child: Text(
|
||||
"${valueList.length}",
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.labelLarge
|
||||
?.copyWith(
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.primary,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Flexible(
|
||||
child: Text(describe),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
child: Text(describe),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Flexible(
|
||||
child: _buildSearchButton(currentPackages)),
|
||||
Flexible(child: _buildFilterSystemAppButton()),
|
||||
Flexible(child: _buildAppProxyModePopup()),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Flexible(
|
||||
child: _buildSearchButton(currentPackages)),
|
||||
Flexible(child: _buildFilterSystemAppButton()),
|
||||
Flexible(child: _buildAppProxyModePopup()),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: FadeBox(
|
||||
key: const Key("fade_box"),
|
||||
child: currentPackages.isEmpty
|
||||
? const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
)
|
||||
: ListView.builder(
|
||||
itemCount: currentPackages.length,
|
||||
itemBuilder: (_, index) {
|
||||
final package = currentPackages[index];
|
||||
return PackageListItem(
|
||||
key: Key(package.packageName),
|
||||
package: package,
|
||||
value:
|
||||
valueList.contains(package.packageName),
|
||||
isActive: isAccessControl,
|
||||
onChanged: (value) {
|
||||
if (value == true) {
|
||||
valueList.add(package.packageName);
|
||||
} else {
|
||||
valueList.remove(package.packageName);
|
||||
}
|
||||
final config =
|
||||
globalState.appController.config;
|
||||
if (accessControlMode ==
|
||||
AccessControlMode.acceptSelected) {
|
||||
config.accessControl =
|
||||
config.accessControl.copyWith(
|
||||
acceptList: valueList,
|
||||
);
|
||||
} else {
|
||||
config.accessControl =
|
||||
config.accessControl.copyWith(
|
||||
rejectList: valueList,
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: FadeBox(
|
||||
key: const Key("fade_box"),
|
||||
child: currentPackages.isEmpty
|
||||
? const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
)
|
||||
: ListView.builder(
|
||||
itemCount: currentPackages.length,
|
||||
itemBuilder: (_, index) {
|
||||
final package = currentPackages[index];
|
||||
return PackageListItem(
|
||||
key: Key(package.packageName),
|
||||
package: package,
|
||||
value:
|
||||
valueList.contains(package.packageName),
|
||||
isActive: isAccessControl,
|
||||
onChanged: (value) {
|
||||
if (value == true) {
|
||||
valueList.add(package.packageName);
|
||||
} else {
|
||||
valueList.remove(package.packageName);
|
||||
}
|
||||
final config =
|
||||
globalState.appController.config;
|
||||
if (accessControlMode ==
|
||||
AccessControlMode.acceptSelected) {
|
||||
config.accessControl =
|
||||
config.accessControl.copyWith(
|
||||
acceptList: valueList,
|
||||
);
|
||||
} else {
|
||||
config.accessControl =
|
||||
config.accessControl.copyWith(
|
||||
rejectList: valueList,
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
|
||||
@@ -113,8 +113,7 @@ class _BackupAndRecoveryState extends State<BackupAndRecovery> {
|
||||
return Center(
|
||||
child: FadeBox(
|
||||
key: const Key("fade_box_1"),
|
||||
child: snapshot.connectionState ==
|
||||
ConnectionState.waiting
|
||||
child: snapshot.connectionState == ConnectionState.waiting
|
||||
? const SizedBox(
|
||||
width: 12,
|
||||
height: 12,
|
||||
@@ -159,12 +158,12 @@ class _BackupAndRecoveryState extends State<BackupAndRecovery> {
|
||||
ListHeader(
|
||||
title: appLocalizations.backupAndRecovery),
|
||||
ListItem(
|
||||
onTab: _backup,
|
||||
onTap: _backup,
|
||||
title: Text(appLocalizations.backup),
|
||||
subtitle: Text(appLocalizations.backupDesc),
|
||||
),
|
||||
ListItem(
|
||||
onTab: _handleRecovery,
|
||||
onTap: _handleRecovery,
|
||||
title: Text(appLocalizations.recovery),
|
||||
subtitle: Text(appLocalizations.recoveryDesc),
|
||||
),
|
||||
@@ -341,13 +340,13 @@ class _RecoveryOptionsDialogState extends State<RecoveryOptionsDialog> {
|
||||
child: Wrap(
|
||||
children: [
|
||||
ListItem(
|
||||
onTab: () {
|
||||
onTap: () {
|
||||
_handleOnTab(RecoveryOption.onlyProfiles);
|
||||
},
|
||||
title: Text(appLocalizations.recoveryProfiles),
|
||||
),
|
||||
ListItem(
|
||||
onTab: () {
|
||||
onTap: () {
|
||||
_handleOnTab(RecoveryOption.all);
|
||||
},
|
||||
title: Text(appLocalizations.recoveryAll),
|
||||
|
||||
@@ -141,7 +141,7 @@ class _ConfigFragmentState extends State<ConfigFragment> {
|
||||
return generateSection(
|
||||
title: appLocalizations.app,
|
||||
items: [
|
||||
if (Platform.isAndroid)
|
||||
if (Platform.isAndroid)...[
|
||||
Selector<Config, bool>(
|
||||
selector: (_, config) => config.allowBypass,
|
||||
builder: (_, allowBypass, __) {
|
||||
@@ -159,7 +159,6 @@ class _ConfigFragmentState extends State<ConfigFragment> {
|
||||
);
|
||||
},
|
||||
),
|
||||
if (Platform.isAndroid)
|
||||
Selector<Config, bool>(
|
||||
selector: (_, config) => config.systemProxy,
|
||||
builder: (_, systemProxy, __) {
|
||||
@@ -177,24 +176,59 @@ class _ConfigFragmentState extends State<ConfigFragment> {
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
Selector<Config, bool>(
|
||||
selector: (_, config) => config.isCompatible,
|
||||
builder: (_, isCompatible, __) {
|
||||
selector: (_, config) => config.isCloseConnections,
|
||||
builder: (_, isCloseConnections, __) {
|
||||
return ListItem.switchItem(
|
||||
leading: const Icon(Icons.expand_outlined),
|
||||
title: Text(appLocalizations.compatible),
|
||||
subtitle: Text(appLocalizations.compatibleDesc),
|
||||
leading: const Icon(Icons.auto_delete_outlined),
|
||||
title: Text(appLocalizations.autoCloseConnections),
|
||||
subtitle: Text(appLocalizations.autoCloseConnectionsDesc),
|
||||
delegate: SwitchDelegate(
|
||||
value: isCompatible,
|
||||
value: isCloseConnections,
|
||||
onChanged: (bool value) async {
|
||||
final appController = globalState.appController;
|
||||
appController.config.isCompatible = value;
|
||||
await appController.applyProfile();
|
||||
appController.config.isCloseConnections = value;
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
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;
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
// Selector<Config, bool>(
|
||||
// selector: (_, config) => config.isCompatible,
|
||||
// builder: (_, isCompatible, __) {
|
||||
// return ListItem.switchItem(
|
||||
// leading: const Icon(Icons.expand_outlined),
|
||||
// title: Text(appLocalizations.compatible),
|
||||
// subtitle: Text(appLocalizations.compatibleDesc),
|
||||
// delegate: SwitchDelegate(
|
||||
// value: isCompatible,
|
||||
// onChanged: (bool value) async {
|
||||
// final appController = globalState.appController;
|
||||
// appController.config.isCompatible = value;
|
||||
// await appController.applyProfile();
|
||||
// },
|
||||
// ),
|
||||
// );
|
||||
// },
|
||||
// ),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -210,7 +244,7 @@ class _ConfigFragmentState extends State<ConfigFragment> {
|
||||
leading: const Icon(Icons.info_outline),
|
||||
title: Text(appLocalizations.logLevel),
|
||||
subtitle: Text(value.name),
|
||||
onTab: () {
|
||||
onTap: () {
|
||||
_showLogLevelDialog(value);
|
||||
},
|
||||
);
|
||||
@@ -223,7 +257,7 @@ class _ConfigFragmentState extends State<ConfigFragment> {
|
||||
leading: const Icon(Icons.computer_outlined),
|
||||
title: const Text("UA"),
|
||||
subtitle: Text(value ?? appLocalizations.defaultText),
|
||||
onTab: () {
|
||||
onTap: () {
|
||||
_showUaDialog(value);
|
||||
},
|
||||
);
|
||||
@@ -236,7 +270,7 @@ class _ConfigFragmentState extends State<ConfigFragment> {
|
||||
leading: const Icon(Icons.timeline),
|
||||
title: Text(appLocalizations.testUrl),
|
||||
subtitle: Text(value),
|
||||
onTab: () {
|
||||
onTap: () {
|
||||
_modifyTestUrl(value);
|
||||
},
|
||||
);
|
||||
@@ -246,7 +280,7 @@ class _ConfigFragmentState extends State<ConfigFragment> {
|
||||
selector: (_, clashConfig) => clashConfig.mixedPort,
|
||||
builder: (_, mixedPort, __) {
|
||||
return ListItem(
|
||||
onTab: () {
|
||||
onTap: () {
|
||||
_modifyMixedPort(mixedPort);
|
||||
},
|
||||
leading: const Icon(Icons.adjust_outlined),
|
||||
|
||||
@@ -37,8 +37,9 @@ class _ConnectionsFragmentState extends State<ConnectionsFragment> {
|
||||
timer = Timer.periodic(
|
||||
const Duration(seconds: 1),
|
||||
(timer) {
|
||||
connectionsNotifier.value = connectionsNotifier.value
|
||||
.copyWith(connections: clashCore.getConnections());
|
||||
connectionsNotifier.value = connectionsNotifier.value.copyWith(
|
||||
connections: clashCore.getConnections(),
|
||||
);
|
||||
},
|
||||
);
|
||||
});
|
||||
@@ -61,6 +62,18 @@ class _ConnectionsFragmentState extends State<ConnectionsFragment> {
|
||||
},
|
||||
icon: const Icon(Icons.search),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
clashCore.closeConnections();
|
||||
connectionsNotifier.value = connectionsNotifier.value.copyWith(
|
||||
connections: clashCore.getConnections(),
|
||||
);
|
||||
},
|
||||
icon: const Icon(Icons.delete_sweep_outlined),
|
||||
),
|
||||
];
|
||||
},
|
||||
);
|
||||
@@ -87,7 +100,7 @@ class _ConnectionsFragmentState extends State<ConnectionsFragment> {
|
||||
}
|
||||
|
||||
_handleBlockConnection(String id) {
|
||||
clashCore.closeConnections(id);
|
||||
clashCore.closeConnection(id);
|
||||
connectionsNotifier.value = connectionsNotifier.value
|
||||
.copyWith(connections: clashCore.getConnections());
|
||||
}
|
||||
@@ -227,7 +240,7 @@ class ConnectionsSearchDelegate extends SearchDelegate {
|
||||
}
|
||||
|
||||
_handleBlockConnection(String id) {
|
||||
clashCore.closeConnections(id);
|
||||
clashCore.closeConnection(id);
|
||||
connectionsNotifier.value = connectionsNotifier.value.copyWith(
|
||||
connections: clashCore.getConnections(),
|
||||
);
|
||||
|
||||
@@ -35,7 +35,7 @@ class _DashboardFragmentState extends State<DashboardFragment> {
|
||||
// final viewMode = other.getViewMode(viewWidth);
|
||||
// final isDesktop = viewMode == ViewMode.desktop;
|
||||
return Grid(
|
||||
crossAxisCount: max(4 * ((viewWidth / 320).ceil()), 8),
|
||||
crossAxisCount: max(4 * ((viewWidth / 350).ceil()), 8),
|
||||
crossAxisSpacing: 16,
|
||||
mainAxisSpacing: 16,
|
||||
children: const [
|
||||
|
||||
@@ -18,48 +18,37 @@ class _NetworkDetectionState extends State<NetworkDetection> {
|
||||
final ipInfoNotifier = ValueNotifier<IpInfo?>(null);
|
||||
final timeoutNotifier = ValueNotifier<bool>(false);
|
||||
bool? _preIsStart;
|
||||
CancelToken? cancelToken;
|
||||
Function? _checkIpDebounce;
|
||||
|
||||
_checkIp(
|
||||
bool isInit,
|
||||
bool isStart,
|
||||
) async {
|
||||
_checkIp() async {
|
||||
final appState = globalState.appController.appState;
|
||||
final isInit = appState.isInit;
|
||||
final isStart = appState.isStart;
|
||||
if (!isInit) return;
|
||||
timeoutNotifier.value = false;
|
||||
if (_preIsStart == false && _preIsStart == isStart) return;
|
||||
if (cancelToken != null) {
|
||||
cancelToken!.cancel();
|
||||
cancelToken = null;
|
||||
}
|
||||
_preIsStart = isStart;
|
||||
ipInfoNotifier.value = null;
|
||||
final ipInfo = await request.checkIp(cancelToken);
|
||||
final ipInfo = await request.checkIp();
|
||||
if (ipInfo == null) {
|
||||
timeoutNotifier.value = true;
|
||||
return;
|
||||
} else {
|
||||
timeoutNotifier.value = false;
|
||||
}
|
||||
_preIsStart = isStart;
|
||||
ipInfoNotifier.value = ipInfo;
|
||||
}
|
||||
|
||||
_checkIpContainer(Widget child) {
|
||||
_checkIpDebounce = debounce(_checkIp);
|
||||
return Selector2<AppState, Config, CheckIpSelectorState>(
|
||||
selector: (_, appState, config) {
|
||||
return CheckIpSelectorState(
|
||||
isInit: appState.isInit,
|
||||
selectedMap: appState.selectedMap,
|
||||
isStart: appState.isStart,
|
||||
checkIpNum: appState.checkIpNum,
|
||||
);
|
||||
return Selector<AppState, num>(
|
||||
selector: (_, appState) {
|
||||
return appState.checkIpNum;
|
||||
},
|
||||
builder: (_, state, __) {
|
||||
builder: (_, checkIpNum, child) {
|
||||
if (_checkIpDebounce != null) {
|
||||
_checkIpDebounce!([state.isInit, state.isStart]);
|
||||
_checkIpDebounce!();
|
||||
}
|
||||
return child;
|
||||
return child!;
|
||||
},
|
||||
child: child,
|
||||
);
|
||||
@@ -74,6 +63,7 @@ class _NetworkDetectionState extends State<NetworkDetection> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
_checkIpDebounce = debounce(_checkIp);
|
||||
return _checkIpContainer(
|
||||
ValueListenableBuilder<IpInfo?>(
|
||||
valueListenable: ipInfoNotifier,
|
||||
|
||||
@@ -48,19 +48,19 @@ class AddProfile extends StatelessWidget {
|
||||
leading: const Icon(Icons.qr_code),
|
||||
title: Text(appLocalizations.qrcode),
|
||||
subtitle: Text(appLocalizations.qrcodeDesc),
|
||||
onTab: _toScan,
|
||||
onTap: _toScan,
|
||||
),
|
||||
ListItem(
|
||||
leading: const Icon(Icons.upload_file),
|
||||
title: Text(appLocalizations.file),
|
||||
subtitle: Text(appLocalizations.fileDesc),
|
||||
onTab: _handleAddProfileFormFile,
|
||||
onTap: _handleAddProfileFormFile,
|
||||
),
|
||||
ListItem(
|
||||
leading: const Icon(Icons.cloud_download),
|
||||
title: Text(appLocalizations.url),
|
||||
subtitle: Text(appLocalizations.urlDesc),
|
||||
onTab: _toAdd,
|
||||
onTap: _toAdd,
|
||||
)
|
||||
],
|
||||
);
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
|
||||
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/plugins/app.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 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
class EditProfile extends StatefulWidget {
|
||||
final Profile profile;
|
||||
@@ -26,6 +31,8 @@ class _EditProfileState extends State<EditProfile> {
|
||||
late TextEditingController autoUpdateDurationController;
|
||||
late bool autoUpdate;
|
||||
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
||||
final fileInfoNotifier = ValueNotifier<FileInfo?>(null);
|
||||
Uint8List? fileData;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -36,12 +43,16 @@ class _EditProfileState extends State<EditProfile> {
|
||||
autoUpdateDurationController = TextEditingController(
|
||||
text: widget.profile.autoUpdateDuration.inMinutes.toString(),
|
||||
);
|
||||
appPath.getProfilePath(widget.profile.id).then((path) async {
|
||||
if (path == null) return;
|
||||
fileInfoNotifier.value = await _getFileInfo(path);
|
||||
});
|
||||
}
|
||||
|
||||
_handleConfirm() {
|
||||
_handleConfirm() async {
|
||||
if (!_formKey.currentState!.validate()) return;
|
||||
final config = widget.context.read<Config>();
|
||||
final profile = widget.profile.copyWith(
|
||||
var profile = widget.profile.copyWith(
|
||||
url: urlController.text,
|
||||
label: labelController.text,
|
||||
autoUpdate: autoUpdate,
|
||||
@@ -52,7 +63,11 @@ class _EditProfileState extends State<EditProfile> {
|
||||
),
|
||||
);
|
||||
final hasUpdate = widget.profile.url != profile.url;
|
||||
config.setProfile(profile);
|
||||
if (fileData != null) {
|
||||
config.setProfile(await profile.saveFile(fileData!));
|
||||
} else {
|
||||
config.setProfile(profile);
|
||||
}
|
||||
if (hasUpdate) {
|
||||
globalState.homeScaffoldKey.currentState?.loadingRun(
|
||||
() async {
|
||||
@@ -62,7 +77,9 @@ class _EditProfileState extends State<EditProfile> {
|
||||
},
|
||||
);
|
||||
}
|
||||
Navigator.of(context).pop();
|
||||
if (mounted) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
}
|
||||
|
||||
_setAutoUpdate(bool value) {
|
||||
@@ -72,6 +89,97 @@ class _EditProfileState extends State<EditProfile> {
|
||||
});
|
||||
}
|
||||
|
||||
Future<FileInfo> _getFileInfo(path) async {
|
||||
final file = File(path);
|
||||
final lastModified = await file.lastModified();
|
||||
final size = await file.length();
|
||||
return FileInfo(
|
||||
size: size,
|
||||
lastModified: lastModified,
|
||||
);
|
||||
}
|
||||
|
||||
_editProfileFile() async {
|
||||
final profilePath = await appPath.getProfilePath(widget.profile.id);
|
||||
if (profilePath == null) return;
|
||||
globalState.safeRun(() async {
|
||||
if (Platform.isAndroid) {
|
||||
await app?.openFile(
|
||||
profilePath,
|
||||
);
|
||||
return;
|
||||
}
|
||||
await launchUrl(
|
||||
Uri.file(
|
||||
profilePath,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
_uploadProfileFile() async {
|
||||
final platformFile = await globalState.safeRun(picker.pickerConfigFile);
|
||||
if (platformFile?.bytes == null) return;
|
||||
fileData = platformFile?.bytes;
|
||||
fileInfoNotifier.value = fileInfoNotifier.value?.copyWith(
|
||||
size: fileData?.length ?? 0,
|
||||
lastModified: DateTime.now(),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSubtitle() {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(
|
||||
height: 4,
|
||||
),
|
||||
ValueListenableBuilder<FileInfo?>(
|
||||
valueListenable: fileInfoNotifier,
|
||||
builder: (_, fileInfo, __) {
|
||||
final height =
|
||||
globalState.appController.measure.bodyMediumHeight + 4;
|
||||
return SizedBox(
|
||||
height: height,
|
||||
child: FadeBox(
|
||||
child: fileInfo == null
|
||||
? SizedBox(
|
||||
width: height,
|
||||
height: height,
|
||||
child: const CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
),
|
||||
)
|
||||
: Text(
|
||||
fileInfo.desc,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
Wrap(
|
||||
runSpacing: 6,
|
||||
spacing: 12,
|
||||
children: [
|
||||
CommonChip(
|
||||
avatar: const Icon(Icons.edit),
|
||||
label: appLocalizations.edit,
|
||||
onPressed: _editProfileFile,
|
||||
),
|
||||
CommonChip(
|
||||
avatar: const Icon(Icons.upload),
|
||||
label: appLocalizations.upload,
|
||||
onPressed: _uploadProfileFile,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final items = [
|
||||
@@ -141,7 +249,11 @@ class _EditProfileState extends State<EditProfile> {
|
||||
},
|
||||
),
|
||||
),
|
||||
]
|
||||
],
|
||||
ListItem(
|
||||
title: Text(appLocalizations.profile),
|
||||
subtitle: _buildSubtitle(),
|
||||
),
|
||||
];
|
||||
return FloatLayout(
|
||||
floatingWidget: FloatWrapper(
|
||||
@@ -158,17 +270,23 @@ class _EditProfileState extends State<EditProfile> {
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 16,
|
||||
),
|
||||
child: ListView.separated(
|
||||
primary: true,
|
||||
itemBuilder: (_, index) {
|
||||
return items[index];
|
||||
},
|
||||
separatorBuilder: (_, __) {
|
||||
return const SizedBox(
|
||||
height: 24,
|
||||
child: ScrollOverBuilder(
|
||||
builder: (isOver) {
|
||||
return ListView.separated(
|
||||
padding: kMaterialListPadding.copyWith(
|
||||
bottom: isOver ? 72 : 36,
|
||||
),
|
||||
itemBuilder: (_, index) {
|
||||
return items[index];
|
||||
},
|
||||
separatorBuilder: (_, __) {
|
||||
return const SizedBox(
|
||||
height: 24,
|
||||
);
|
||||
},
|
||||
itemCount: items.length,
|
||||
);
|
||||
},
|
||||
itemCount: items.length,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'package:fl_clash/enum/enum.dart';
|
||||
import 'package:fl_clash/fragments/profiles/edit_profile.dart';
|
||||
import 'package:fl_clash/fragments/profiles/view_profile.dart';
|
||||
import 'package:fl_clash/models/models.dart';
|
||||
import 'package:fl_clash/common/common.dart';
|
||||
import 'package:fl_clash/state.dart';
|
||||
@@ -16,7 +15,6 @@ enum ProfileActions {
|
||||
edit,
|
||||
update,
|
||||
delete,
|
||||
view,
|
||||
}
|
||||
|
||||
class ProfilesFragment extends StatefulWidget {
|
||||
@@ -27,7 +25,6 @@ class ProfilesFragment extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _ProfilesFragmentState extends State<ProfilesFragment> {
|
||||
final hasPadding = ValueNotifier<bool>(false);
|
||||
Function? applyConfigDebounce;
|
||||
|
||||
List<GlobalObjectKey<_ProfileItemState>> profileItemKeys = [];
|
||||
@@ -77,17 +74,6 @@ class _ProfilesFragmentState extends State<ProfilesFragment> {
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
hasPadding.dispose();
|
||||
}
|
||||
|
||||
_changeProfile(String? id) async {
|
||||
final appController = globalState.appController;
|
||||
final config = appController.config;
|
||||
@@ -140,41 +126,33 @@ class _ProfilesFragmentState extends State<ProfilesFragment> {
|
||||
final columns = _getColumns(state.viewMode);
|
||||
return Align(
|
||||
alignment: Alignment.topCenter,
|
||||
child: NotificationListener<ScrollNotification>(
|
||||
onNotification: (scrollNotification) {
|
||||
hasPadding.value =
|
||||
scrollNotification.metrics.maxScrollExtent > 0;
|
||||
return true;
|
||||
},
|
||||
child: ValueListenableBuilder(
|
||||
valueListenable: hasPadding,
|
||||
builder: (_, hasPadding, __) {
|
||||
return SingleChildScrollView(
|
||||
padding: EdgeInsets.only(
|
||||
left: 16,
|
||||
right: 16,
|
||||
top: 16,
|
||||
bottom: 16 + (hasPadding ? 72 : 0),
|
||||
),
|
||||
child: Grid(
|
||||
mainAxisSpacing: 16,
|
||||
crossAxisSpacing: 16,
|
||||
crossAxisCount: columns,
|
||||
children: [
|
||||
for (int i = 0; i < state.profiles.length; i++)
|
||||
GridItem(
|
||||
child: ProfileItem(
|
||||
key: profileItemKeys[i],
|
||||
profile: state.profiles[i],
|
||||
groupValue: state.currentProfileId,
|
||||
onChanged: _changeProfile,
|
||||
),
|
||||
child: ScrollOverBuilder(
|
||||
builder: (isOver) {
|
||||
return SingleChildScrollView(
|
||||
padding: EdgeInsets.only(
|
||||
left: 16,
|
||||
right: 16,
|
||||
top: 16,
|
||||
bottom: 16 + (isOver ? 72 : 0),
|
||||
),
|
||||
child: Grid(
|
||||
mainAxisSpacing: 16,
|
||||
crossAxisSpacing: 16,
|
||||
crossAxisCount: columns,
|
||||
children: [
|
||||
for (int i = 0; i < state.profiles.length; i++)
|
||||
GridItem(
|
||||
child: ProfileItem(
|
||||
key: profileItemKeys[i],
|
||||
profile: state.profiles[i],
|
||||
groupValue: state.currentProfileId,
|
||||
onChanged: _changeProfile,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
@@ -204,7 +182,18 @@ class _ProfileItemState extends State<ProfileItem> {
|
||||
final isUpdating = ValueNotifier<bool>(false);
|
||||
|
||||
_handleDeleteProfile() async {
|
||||
globalState.appController.deleteProfile(widget.profile.id);
|
||||
globalState.showMessage(
|
||||
title: appLocalizations.tip,
|
||||
message: TextSpan(
|
||||
text: appLocalizations.deleteProfileTip,
|
||||
),
|
||||
onTab: () async {
|
||||
await globalState.appController.deleteProfile(widget.profile.id);
|
||||
if(mounted){
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
_handleUpdateProfile() async {
|
||||
@@ -216,9 +205,8 @@ class _ProfileItemState extends State<ProfileItem> {
|
||||
try {
|
||||
final appController = globalState.appController;
|
||||
await appController.updateProfile(widget.profile);
|
||||
if (widget.profile.id == appController.config.currentProfile?.id &&
|
||||
!appController.appState.isStart) {
|
||||
globalState.appController.rawApplyProfile();
|
||||
if (widget.profile.id == appController.config.currentProfile?.id) {
|
||||
globalState.appController.applyProfile(isPrue: true);
|
||||
}
|
||||
} catch (e) {
|
||||
isUpdating.value = false;
|
||||
@@ -243,16 +231,6 @@ class _ProfileItemState extends State<ProfileItem> {
|
||||
);
|
||||
}
|
||||
|
||||
_handleViewProfile() {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ViewProfile(
|
||||
profile: widget.profile,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
_buildTitle(Profile profile) {
|
||||
final textTheme = context.textTheme;
|
||||
return Container(
|
||||
@@ -313,91 +291,14 @@ class _ProfileItemState extends State<ProfileItem> {
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
appLocalizations.expirationTime,
|
||||
style: textTheme.labelMedium?.toLighter,
|
||||
),
|
||||
const SizedBox(
|
||||
width: 4,
|
||||
),
|
||||
Text(
|
||||
expireShow,
|
||||
style: textTheme.labelMedium?.toLighter,
|
||||
style: textTheme.labelMedium?.toLight,
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
);
|
||||
// final child = switch (userInfo != null) {
|
||||
// true => () {
|
||||
// final use = userInfo!.upload + userInfo.download;
|
||||
// final total = userInfo.total;
|
||||
// final useShow = TrafficValue(value: use).show;
|
||||
// final totalShow = TrafficValue(value: total).show;
|
||||
// final progress = total == 0 ? 0.0 : use / total;
|
||||
// final expireShow = userInfo.expire == 0
|
||||
// ? appLocalizations.infiniteTime
|
||||
// : DateTime.fromMillisecondsSinceEpoch(
|
||||
// userInfo.expire * 1000)
|
||||
// .show;
|
||||
// return Column(
|
||||
// mainAxisSize: MainAxisSize.min,
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// mainAxisAlignment: MainAxisAlignment.center,
|
||||
// children: [
|
||||
// Container(
|
||||
// margin: const EdgeInsets.symmetric(
|
||||
// vertical: 8,
|
||||
// ),
|
||||
// child: LinearProgressIndicator(
|
||||
// minHeight: 6,
|
||||
// value: progress,
|
||||
// ),
|
||||
// ),
|
||||
// Text(
|
||||
// "$useShow / $totalShow",
|
||||
// style: textTheme.labelMedium?.toLight(),
|
||||
// ),
|
||||
// const SizedBox(
|
||||
// height: 2,
|
||||
// ),
|
||||
// Row(
|
||||
// children: [
|
||||
// Text(
|
||||
// appLocalizations.expirationTime,
|
||||
// style: textTheme.labelMedium?.toLighter(),
|
||||
// ),
|
||||
// const SizedBox(
|
||||
// width: 4,
|
||||
// ),
|
||||
// Text(
|
||||
// expireShow,
|
||||
// style: textTheme.labelMedium?.toLighter(),
|
||||
// ),
|
||||
// ],
|
||||
// )
|
||||
// ],
|
||||
// );
|
||||
// }(),
|
||||
// false => Column(
|
||||
// children: [
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.only(top: 8),
|
||||
// child: CommonChip(
|
||||
// onPressed: _handleViewProfile,
|
||||
// avatar: const Icon(Icons.remove_red_eye),
|
||||
// label: appLocalizations.view,
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// };
|
||||
// final measure = globalState.appController.measure;
|
||||
// final height = 6 + 8 * 2 + 2 + measure.labelMediumHeight * 2;
|
||||
// return SizedBox(
|
||||
// height: height,
|
||||
// child: child,
|
||||
// );
|
||||
}),
|
||||
],
|
||||
),
|
||||
@@ -416,70 +317,62 @@ class _ProfileItemState extends State<ProfileItem> {
|
||||
final groupValue = widget.groupValue;
|
||||
final onChanged = widget.onChanged;
|
||||
return CommonCard(
|
||||
child: ListItem.radio(
|
||||
isSelected: profile.id == groupValue,
|
||||
onPressed: () {
|
||||
onChanged(profile.id);
|
||||
},
|
||||
child: ListItem(
|
||||
key: Key(profile.id),
|
||||
horizontalTitleGap: 16,
|
||||
delegate: RadioDelegate<String?>(
|
||||
value: profile.id,
|
||||
groupValue: groupValue,
|
||||
onChanged: onChanged,
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
trailing: SizedBox(
|
||||
height: 48,
|
||||
width: 48,
|
||||
height: 40,
|
||||
width: 40,
|
||||
child: ValueListenableBuilder(
|
||||
valueListenable: isUpdating,
|
||||
builder: (_, isUpdating, ___) {
|
||||
return FadeBox(
|
||||
child: isUpdating
|
||||
? const Padding(
|
||||
padding: EdgeInsets.all(8),
|
||||
child: CircularProgressIndicator(),
|
||||
)
|
||||
: CommonPopupMenu<ProfileActions>(
|
||||
items: [
|
||||
child: isUpdating
|
||||
? const Padding(
|
||||
padding: EdgeInsets.all(8),
|
||||
child: CircularProgressIndicator(),
|
||||
)
|
||||
: CommonPopupMenu<ProfileActions>(
|
||||
items: [
|
||||
CommonPopupMenuItem(
|
||||
action: ProfileActions.edit,
|
||||
label: appLocalizations.edit,
|
||||
iconData: Icons.edit,
|
||||
),
|
||||
if (profile.type == ProfileType.url)
|
||||
CommonPopupMenuItem(
|
||||
action: ProfileActions.edit,
|
||||
label: appLocalizations.edit,
|
||||
iconData: Icons.edit,
|
||||
action: ProfileActions.update,
|
||||
label: appLocalizations.update,
|
||||
iconData: Icons.sync,
|
||||
),
|
||||
if (profile.type == ProfileType.url)
|
||||
CommonPopupMenuItem(
|
||||
action: ProfileActions.update,
|
||||
label: appLocalizations.update,
|
||||
iconData: Icons.sync,
|
||||
),
|
||||
CommonPopupMenuItem(
|
||||
action: ProfileActions.view,
|
||||
label: appLocalizations.view,
|
||||
iconData: Icons.visibility,
|
||||
),
|
||||
CommonPopupMenuItem(
|
||||
action: ProfileActions.delete,
|
||||
label: appLocalizations.delete,
|
||||
iconData: Icons.delete,
|
||||
),
|
||||
],
|
||||
onSelected: (ProfileActions? action) async {
|
||||
switch (action) {
|
||||
case ProfileActions.edit:
|
||||
_handleShowEditExtendPage();
|
||||
break;
|
||||
case ProfileActions.delete:
|
||||
_handleDeleteProfile();
|
||||
break;
|
||||
case ProfileActions.update:
|
||||
_handleUpdateProfile();
|
||||
break;
|
||||
case ProfileActions.view:
|
||||
_handleViewProfile();
|
||||
break;
|
||||
case null:
|
||||
break;
|
||||
}
|
||||
},
|
||||
));
|
||||
CommonPopupMenuItem(
|
||||
action: ProfileActions.delete,
|
||||
label: appLocalizations.delete,
|
||||
iconData: Icons.delete,
|
||||
),
|
||||
],
|
||||
onSelected: (ProfileActions? action) async {
|
||||
switch (action) {
|
||||
case ProfileActions.edit:
|
||||
_handleShowEditExtendPage();
|
||||
break;
|
||||
case ProfileActions.delete:
|
||||
_handleDeleteProfile();
|
||||
break;
|
||||
case ProfileActions.update:
|
||||
_handleUpdateProfile();
|
||||
break;
|
||||
case null:
|
||||
break;
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
@@ -1,207 +0,0 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:fl_clash/common/common.dart';
|
||||
import 'package:fl_clash/models/models.dart';
|
||||
import 'package:fl_clash/state.dart';
|
||||
import 'package:fl_clash/widgets/scaffold.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:re_editor/re_editor.dart';
|
||||
import 'package:re_highlight/languages/yaml.dart';
|
||||
import 'package:re_highlight/styles/intellij-light.dart';
|
||||
|
||||
class ViewProfile extends StatefulWidget {
|
||||
final Profile profile;
|
||||
|
||||
const ViewProfile({
|
||||
super.key,
|
||||
required this.profile,
|
||||
});
|
||||
|
||||
@override
|
||||
State<ViewProfile> createState() => _ViewProfileState();
|
||||
}
|
||||
|
||||
class _ViewProfileState extends State<ViewProfile> {
|
||||
bool readOnly = true;
|
||||
CodeLineEditingController? controller;
|
||||
final contentNotifier = ValueNotifier<String>("");
|
||||
final key = GlobalKey<CommonScaffoldState>();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||
final profilePath = await appPath.getProfilePath(widget.profile.id);
|
||||
if (profilePath == null) {
|
||||
return;
|
||||
}
|
||||
final file = File(profilePath);
|
||||
final text = await file.readAsString();
|
||||
contentNotifier.value = text;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
contentNotifier.dispose();
|
||||
controller?.dispose();
|
||||
}
|
||||
|
||||
Profile get profile => widget.profile;
|
||||
|
||||
_handleChangeReadOnly() async {
|
||||
if (readOnly == true) {
|
||||
setState(() {
|
||||
readOnly = false;
|
||||
});
|
||||
} else {
|
||||
final text = controller?.text;
|
||||
if (text == null || text == contentNotifier.value) {
|
||||
setState(() {
|
||||
readOnly = true;
|
||||
});
|
||||
return;
|
||||
}
|
||||
contentNotifier.value = text;
|
||||
final newProfile = await key.currentState?.loadingRun<Profile>(() async {
|
||||
return await profile.saveFileWithString(text);
|
||||
});
|
||||
if (newProfile == null) return;
|
||||
globalState.appController.config.setProfile(newProfile);
|
||||
setState(() {
|
||||
readOnly = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CommonScaffold(
|
||||
key: key,
|
||||
actions: [
|
||||
IconButton(
|
||||
onPressed: controller?.undo,
|
||||
icon: const Icon(Icons.undo),
|
||||
),
|
||||
IconButton(
|
||||
onPressed: controller?.redo,
|
||||
icon: const Icon(Icons.redo),
|
||||
),
|
||||
if (!widget.profile.realAutoUpdate)
|
||||
IconButton(
|
||||
onPressed: _handleChangeReadOnly,
|
||||
icon: readOnly ? const Icon(Icons.edit) : const Icon(Icons.save),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
)
|
||||
],
|
||||
body: ValueListenableBuilder(
|
||||
valueListenable: contentNotifier,
|
||||
builder: (_, value, __) {
|
||||
if (value.isEmpty) return Container();
|
||||
controller = CodeLineEditingController.fromText(value);
|
||||
return CodeEditor(
|
||||
autofocus: false,
|
||||
readOnly: readOnly,
|
||||
scrollbarBuilder: (context, child, details) {
|
||||
return Scrollbar(
|
||||
controller: details.controller,
|
||||
thickness: 8,
|
||||
radius: const Radius.circular(2),
|
||||
interactive: true,
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
showCursorWhenReadOnly: false,
|
||||
controller: controller,
|
||||
toolbarController:
|
||||
!readOnly ? const ContextMenuControllerImpl() : null,
|
||||
shortcutsActivatorsBuilder:
|
||||
const DefaultCodeShortcutsActivatorsBuilder(),
|
||||
indicatorBuilder:
|
||||
(context, editingController, chunkController, notifier) {
|
||||
return Row(
|
||||
children: [
|
||||
DefaultCodeLineNumber(
|
||||
controller: editingController,
|
||||
notifier: notifier,
|
||||
),
|
||||
DefaultCodeChunkIndicator(
|
||||
width: 20,
|
||||
controller: chunkController,
|
||||
notifier: notifier,
|
||||
)
|
||||
],
|
||||
);
|
||||
},
|
||||
style: CodeEditorStyle(
|
||||
fontSize: 14,
|
||||
codeTheme: CodeHighlightTheme(
|
||||
languages: {
|
||||
'yaml': CodeHighlightThemeMode(
|
||||
mode: langYaml,
|
||||
)
|
||||
},
|
||||
theme: intellijLightTheme,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
title: widget.profile.label ?? widget.profile.id,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ContextMenuItemWidget extends PopupMenuItem<void> {
|
||||
ContextMenuItemWidget({
|
||||
super.key,
|
||||
required String text,
|
||||
required VoidCallback super.onTap,
|
||||
}) : super(child: Text(text));
|
||||
}
|
||||
|
||||
class ContextMenuControllerImpl implements SelectionToolbarController {
|
||||
const ContextMenuControllerImpl();
|
||||
|
||||
@override
|
||||
void hide(BuildContext context) {}
|
||||
|
||||
@override
|
||||
void show({
|
||||
required BuildContext context,
|
||||
required CodeLineEditingController controller,
|
||||
required TextSelectionToolbarAnchors anchors,
|
||||
Rect? renderRect,
|
||||
required LayerLink layerLink,
|
||||
required ValueNotifier<bool> visibility,
|
||||
}) {
|
||||
if (controller.selectedText.isEmpty) {
|
||||
return;
|
||||
}
|
||||
showMenu(
|
||||
context: context,
|
||||
position: RelativeRect.fromSize(
|
||||
(anchors.secondaryAnchor ?? anchors.primaryAnchor) &
|
||||
const Size(150, double.infinity),
|
||||
MediaQuery.of(context).size,
|
||||
),
|
||||
items: [
|
||||
ContextMenuItemWidget(
|
||||
text: appLocalizations.cut,
|
||||
onTap: controller.cut,
|
||||
),
|
||||
ContextMenuItemWidget(
|
||||
text: appLocalizations.copy,
|
||||
onTap: controller.copy,
|
||||
),
|
||||
ContextMenuItemWidget(
|
||||
text: appLocalizations.paste,
|
||||
onTap: controller.paste,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'package:fl_clash/clash/clash.dart';
|
||||
import 'package:fl_clash/common/common.dart';
|
||||
import 'package:fl_clash/enum/enum.dart';
|
||||
import 'package:fl_clash/fragments/proxies/common.dart';
|
||||
import 'package:fl_clash/models/models.dart';
|
||||
import 'package:fl_clash/state.dart';
|
||||
import 'package:fl_clash/widgets/widgets.dart';
|
||||
@@ -10,7 +10,7 @@ import 'package:provider/provider.dart';
|
||||
class ProxyCard extends StatelessWidget {
|
||||
final String groupName;
|
||||
final Proxy proxy;
|
||||
final bool isSelected;
|
||||
final GroupType groupType;
|
||||
final CommonCardType style;
|
||||
final ProxyCardType type;
|
||||
|
||||
@@ -18,7 +18,7 @@ class ProxyCard extends StatelessWidget {
|
||||
super.key,
|
||||
required this.groupName,
|
||||
required this.proxy,
|
||||
required this.isSelected,
|
||||
required this.groupType,
|
||||
this.style = CommonCardType.plain,
|
||||
required this.type,
|
||||
});
|
||||
@@ -91,25 +91,31 @@ class ProxyCard extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
_changeProxy(BuildContext context) {
|
||||
_changeProxy(BuildContext context) async {
|
||||
final appController = globalState.appController;
|
||||
final group = appController.appState.getGroupWithName(groupName)!;
|
||||
if (group.type != GroupType.Selector) {
|
||||
globalState.showSnackBar(
|
||||
context,
|
||||
message: appLocalizations.notSelectedTip,
|
||||
final isUrlTest = groupType == GroupType.URLTest;
|
||||
final isSelector = groupType == GroupType.Selector;
|
||||
if (isUrlTest || isSelector) {
|
||||
final currentProxyName =
|
||||
appController.config.currentSelectedMap[groupName];
|
||||
final nextProxyName = switch (isUrlTest) {
|
||||
true => currentProxyName == proxy.name ? "" : proxy.name,
|
||||
false => proxy.name,
|
||||
};
|
||||
appController.config.updateCurrentSelectedMap(
|
||||
groupName,
|
||||
nextProxyName,
|
||||
);
|
||||
appController.changeProxy(
|
||||
groupName: groupName,
|
||||
proxyName: nextProxyName,
|
||||
);
|
||||
await appController.updateGroupDebounce();
|
||||
return;
|
||||
}
|
||||
globalState.appController.config.updateCurrentSelectedMap(
|
||||
groupName,
|
||||
proxy.name,
|
||||
);
|
||||
clashCore.changeProxy(
|
||||
ChangeProxyParams(
|
||||
groupName: groupName,
|
||||
proxyName: proxy.name,
|
||||
),
|
||||
globalState.showSnackBar(
|
||||
context,
|
||||
message: appLocalizations.notSelectedTip,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -118,75 +124,125 @@ class ProxyCard extends StatelessWidget {
|
||||
final measure = globalState.appController.measure;
|
||||
final delayText = _buildDelayText();
|
||||
final proxyNameText = _buildProxyNameText(context);
|
||||
return CommonCard(
|
||||
type: style,
|
||||
key: key,
|
||||
onPressed: () {
|
||||
_changeProxy(context);
|
||||
},
|
||||
isSelected: isSelected,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
return currentGroupProxyNameBuilder(
|
||||
groupName: groupName,
|
||||
builder: (currentGroupName) {
|
||||
return Stack(
|
||||
children: [
|
||||
proxyNameText,
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
if (type == ProxyCardType.expand) ...[
|
||||
SizedBox(
|
||||
height: measure.bodySmallHeight,
|
||||
child: Selector<AppState, String>(
|
||||
selector: (context, appState) => appState.getDesc(
|
||||
proxy.type,
|
||||
proxy.name,
|
||||
),
|
||||
builder: (_, desc, __) {
|
||||
return TooltipText(
|
||||
text: Text(
|
||||
desc,
|
||||
style: context.textTheme.bodySmall?.copyWith(
|
||||
overflow: TextOverflow.ellipsis,
|
||||
color: context.textTheme.bodySmall?.color?.toLight(),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
delayText,
|
||||
] else
|
||||
SizedBox(
|
||||
height: measure.bodySmallHeight,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
CommonCard(
|
||||
type: style,
|
||||
key: key,
|
||||
onPressed: () {
|
||||
_changeProxy(context);
|
||||
},
|
||||
isSelected: currentGroupName == proxy.name,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: TooltipText(
|
||||
text: Text(
|
||||
proxy.type,
|
||||
style: context.textTheme.bodySmall?.copyWith(
|
||||
overflow: TextOverflow.ellipsis,
|
||||
color:
|
||||
context.textTheme.bodySmall?.color?.toLight(),
|
||||
proxyNameText,
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
if (type == ProxyCardType.expand) ...[
|
||||
SizedBox(
|
||||
height: measure.bodySmallHeight,
|
||||
child: Selector<AppState, String>(
|
||||
selector: (context, appState) => appState.getDesc(
|
||||
proxy.type,
|
||||
proxy.name,
|
||||
),
|
||||
builder: (_, desc, __) {
|
||||
return TooltipText(
|
||||
text: Text(
|
||||
desc,
|
||||
style: context.textTheme.bodySmall?.copyWith(
|
||||
overflow: TextOverflow.ellipsis,
|
||||
color: context.textTheme.bodySmall?.color
|
||||
?.toLight(),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
delayText,
|
||||
] else
|
||||
SizedBox(
|
||||
height: measure.bodySmallHeight,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: TooltipText(
|
||||
text: Text(
|
||||
proxy.type,
|
||||
style: context.textTheme.bodySmall?.copyWith(
|
||||
overflow: TextOverflow.ellipsis,
|
||||
color: context.textTheme.bodySmall?.color
|
||||
?.toLight(),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
delayText,
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
delayText,
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
if (groupType == GroupType.URLTest)
|
||||
Selector<Config, String>(
|
||||
selector: (_, config) {
|
||||
final selectedProxyName =
|
||||
config.currentSelectedMap[groupName];
|
||||
return selectedProxyName ?? '';
|
||||
},
|
||||
builder: (_, value, __) {
|
||||
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(),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
child: 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(),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
75
lib/fragments/proxies/common.dart
Normal file
@@ -0,0 +1,75 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:fl_clash/clash/clash.dart';
|
||||
import 'package:fl_clash/common/constant.dart';
|
||||
import 'package:fl_clash/enum/enum.dart';
|
||||
import 'package:fl_clash/models/models.dart';
|
||||
import 'package:fl_clash/state.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
Widget currentGroupProxyNameBuilder({
|
||||
required String groupName,
|
||||
required Widget Function(String currentGroupName) builder,
|
||||
}) {
|
||||
return Selector2<AppState, Config, String>(
|
||||
selector: (_, appState, config) {
|
||||
final group = appState.getGroupWithName(groupName);
|
||||
final selectedProxyName = config.currentSelectedMap[groupName];
|
||||
return group?.getCurrentSelectedName(selectedProxyName ?? "") ?? "";
|
||||
},
|
||||
builder: (_, currentGroupName, ___) {
|
||||
return builder(currentGroupName);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
double get listHeaderHeight {
|
||||
final measure = globalState.appController.measure;
|
||||
return 24 + measure.titleMediumHeight + 4 + measure.bodyMediumHeight;
|
||||
}
|
||||
|
||||
double getItemHeight(ProxyCardType proxyCardType) {
|
||||
final measure = globalState.appController.measure;
|
||||
final baseHeight =
|
||||
12 * 2 + measure.bodyMediumHeight * 2 + measure.bodySmallHeight + 8;
|
||||
return switch (proxyCardType) {
|
||||
ProxyCardType.expand => baseHeight + measure.labelSmallHeight + 8,
|
||||
ProxyCardType.shrink => baseHeight,
|
||||
ProxyCardType.min => baseHeight - measure.bodyMediumHeight,
|
||||
};
|
||||
}
|
||||
|
||||
delayTest(List<Proxy> proxies) async {
|
||||
final appController = globalState.appController;
|
||||
for (final proxy in proxies) {
|
||||
final proxyName = appController.appState.getRealProxyName(proxy.name);
|
||||
globalState.appController.setDelay(
|
||||
Delay(
|
||||
name: proxyName,
|
||||
value: 0,
|
||||
),
|
||||
);
|
||||
clashCore.getDelay(proxyName).then((delay) {
|
||||
globalState.appController.setDelay(delay);
|
||||
});
|
||||
}
|
||||
await Future.delayed(httpTimeoutDuration + moreDuration);
|
||||
appController.appState.sortNum++;
|
||||
}
|
||||
|
||||
double getScrollToSelectedOffset({
|
||||
required String groupName,
|
||||
required List<Proxy> proxies,
|
||||
}) {
|
||||
final appController = globalState.appController;
|
||||
final columns = appController.columns;
|
||||
final proxyCardType = appController.config.proxyCardType;
|
||||
final selectedName = appController.getCurrentSelectedName(groupName);
|
||||
final findSelectedIndex = proxies.indexWhere(
|
||||
(proxy) => proxy.name == selectedName,
|
||||
);
|
||||
final selectedIndex = findSelectedIndex != -1 ? findSelectedIndex : 0;
|
||||
final rows = (selectedIndex / columns).floor();
|
||||
return max(rows * (getItemHeight(proxyCardType) + 8) - 8, 0);
|
||||
}
|
||||
@@ -1,404 +0,0 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:fl_clash/clash/clash.dart';
|
||||
import 'package:fl_clash/common/common.dart';
|
||||
import 'package:fl_clash/enum/enum.dart';
|
||||
import 'package:fl_clash/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 'card.dart';
|
||||
|
||||
class ProxyGroupView extends StatefulWidget {
|
||||
final String groupName;
|
||||
final ProxiesType type;
|
||||
|
||||
const ProxyGroupView({
|
||||
super.key,
|
||||
required this.groupName,
|
||||
required this.type,
|
||||
});
|
||||
|
||||
@override
|
||||
State<ProxyGroupView> createState() => _ProxyGroupViewState();
|
||||
}
|
||||
|
||||
class _ProxyGroupViewState extends State<ProxyGroupView> {
|
||||
var isLock = false;
|
||||
final scrollController = ScrollController();
|
||||
var isEnd = false;
|
||||
|
||||
String get groupName => widget.groupName;
|
||||
|
||||
ProxiesType get type => widget.type;
|
||||
|
||||
double _getItemHeight(ProxyCardType proxyCardType) {
|
||||
final measure = globalState.appController.measure;
|
||||
final baseHeight =
|
||||
12 * 2 + measure.bodyMediumHeight * 2 + measure.bodySmallHeight + 8;
|
||||
return switch(proxyCardType){
|
||||
ProxyCardType.expand => baseHeight + measure.labelSmallHeight + 8,
|
||||
ProxyCardType.shrink => baseHeight,
|
||||
ProxyCardType.min => baseHeight - measure.bodyMediumHeight,
|
||||
};
|
||||
}
|
||||
|
||||
_delayTest(List<Proxy> proxies) async {
|
||||
if (isLock) return;
|
||||
isLock = true;
|
||||
final appController = globalState.appController;
|
||||
for (final proxy in proxies) {
|
||||
final proxyName =
|
||||
appController.appState.getRealProxyName(proxy.name) ?? proxy.name;
|
||||
globalState.appController.setDelay(
|
||||
Delay(
|
||||
name: proxyName,
|
||||
value: 0,
|
||||
),
|
||||
);
|
||||
clashCore.getDelay(proxyName).then((delay) {
|
||||
globalState.appController.setDelay(delay);
|
||||
});
|
||||
}
|
||||
await Future.delayed(httpTimeoutDuration + moreDuration);
|
||||
appController.appState.sortNum++;
|
||||
isLock = false;
|
||||
}
|
||||
|
||||
Widget _currentProxyNameBuilder({
|
||||
required Widget Function(String) builder,
|
||||
}) {
|
||||
return Selector2<AppState, Config, String>(
|
||||
selector: (_, appState, config) {
|
||||
final group = appState.getGroupWithName(groupName)!;
|
||||
return config.currentSelectedMap[groupName] ?? group.now ?? '';
|
||||
},
|
||||
builder: (_, value, ___) {
|
||||
return builder(value);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTabGroupView({
|
||||
required List<Proxy> proxies,
|
||||
required int columns,
|
||||
required ProxyCardType proxyCardType,
|
||||
}) {
|
||||
final sortedProxies = globalState.appController.getSortProxies(
|
||||
proxies,
|
||||
);
|
||||
return DelayTestButtonContainer(
|
||||
onClick: () async {
|
||||
await _delayTest(
|
||||
proxies,
|
||||
);
|
||||
},
|
||||
child: Align(
|
||||
alignment: Alignment.topCenter,
|
||||
child: GridView.builder(
|
||||
padding: const EdgeInsets.all(16),
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: columns,
|
||||
mainAxisSpacing: 8,
|
||||
crossAxisSpacing: 8,
|
||||
mainAxisExtent: _getItemHeight(proxyCardType),
|
||||
),
|
||||
itemCount: sortedProxies.length,
|
||||
itemBuilder: (_, index) {
|
||||
final proxy = sortedProxies[index];
|
||||
return _currentProxyNameBuilder(builder: (value) {
|
||||
return ProxyCard(
|
||||
type: proxyCardType,
|
||||
key: ValueKey('$groupName.${proxy.name}'),
|
||||
isSelected: value == proxy.name,
|
||||
proxy: proxy,
|
||||
groupName: groupName,
|
||||
);
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildExpansionGroupView({
|
||||
required List<Proxy> proxies,
|
||||
required int columns,
|
||||
required ProxyCardType proxyCardType,
|
||||
}) {
|
||||
final sortedProxies = globalState.appController.getSortProxies(
|
||||
proxies,
|
||||
);
|
||||
final group =
|
||||
globalState.appController.appState.getGroupWithName(groupName)!;
|
||||
final itemHeight = _getItemHeight(proxyCardType);
|
||||
final innerHeight = context.appSize.height - 200;
|
||||
final lines = (sortedProxies.length / columns).ceil();
|
||||
final minLines =
|
||||
innerHeight >= 200 ? (innerHeight / itemHeight).floor() : 3;
|
||||
final height = (itemHeight + 8) * min(lines, minLines) - 8;
|
||||
return Selector<Config, Set<String>>(
|
||||
selector: (_, config) => config.currentUnfoldSet,
|
||||
builder: (_, currentUnfoldSet, __) {
|
||||
return CommonCard(
|
||||
child: ExpansionTile(
|
||||
childrenPadding: const EdgeInsets.all(8),
|
||||
initiallyExpanded: currentUnfoldSet.contains(groupName),
|
||||
iconColor: context.colorScheme.onSurfaceVariant,
|
||||
onExpansionChanged: (value) {
|
||||
final tempUnfoldSet = Set<String>.from(currentUnfoldSet);
|
||||
if (value) {
|
||||
tempUnfoldSet.add(groupName);
|
||||
} else {
|
||||
tempUnfoldSet.remove(groupName);
|
||||
}
|
||||
globalState.appController.config.updateCurrentUnfoldSet(
|
||||
tempUnfoldSet,
|
||||
);
|
||||
},
|
||||
controlAffinity: ListTileControlAffinity.trailing,
|
||||
title: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(groupName),
|
||||
const SizedBox(
|
||||
height: 4,
|
||||
),
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
group.type.name,
|
||||
style: context.textTheme.labelMedium?.toLight,
|
||||
),
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: _currentProxyNameBuilder(
|
||||
builder: (value) {
|
||||
return Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.center,
|
||||
children: [
|
||||
if (value.isNotEmpty) ...[
|
||||
Icon(
|
||||
Icons.arrow_right,
|
||||
color: context
|
||||
.colorScheme.onSurfaceVariant,
|
||||
),
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: Text(
|
||||
overflow: TextOverflow.ellipsis,
|
||||
value,
|
||||
style: context
|
||||
.textTheme.labelMedium?.toLight,
|
||||
),
|
||||
),
|
||||
]
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 4,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(
|
||||
Icons.network_ping,
|
||||
size: 20,
|
||||
color: context.colorScheme.onSurfaceVariant,
|
||||
),
|
||||
onPressed: () {
|
||||
_delayTest(sortedProxies);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
shape: const RoundedRectangleBorder(
|
||||
side: BorderSide.none,
|
||||
),
|
||||
collapsedShape: const RoundedRectangleBorder(
|
||||
side: BorderSide.none,
|
||||
),
|
||||
children: [
|
||||
SizedBox(
|
||||
height: height,
|
||||
child: GridView.builder(
|
||||
key: widget.key,
|
||||
controller: scrollController,
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: columns,
|
||||
mainAxisSpacing: 8,
|
||||
crossAxisSpacing: 8,
|
||||
mainAxisExtent: _getItemHeight(proxyCardType),
|
||||
),
|
||||
itemCount: sortedProxies.length,
|
||||
itemBuilder: (_, index) {
|
||||
final proxy = sortedProxies[index];
|
||||
return _currentProxyNameBuilder(
|
||||
builder: (value) {
|
||||
return ProxyCard(
|
||||
style: CommonCardType.filled,
|
||||
type: proxyCardType,
|
||||
isSelected: value == proxy.name,
|
||||
key: ValueKey('$groupName.${proxy.name}'),
|
||||
proxy: proxy,
|
||||
groupName: groupName,
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
scrollController.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Selector2<AppState, Config, ProxyGroupSelectorState>(
|
||||
selector: (_, appState, config) {
|
||||
final group = appState.getGroupWithName(groupName)!;
|
||||
return ProxyGroupSelectorState(
|
||||
proxyCardType: config.proxyCardType,
|
||||
proxiesSortType: config.proxiesSortType,
|
||||
columns: globalState.appController.columns,
|
||||
sortNum: appState.sortNum,
|
||||
proxies: group.all,
|
||||
);
|
||||
},
|
||||
builder: (_, state, __) {
|
||||
final proxies = state.proxies;
|
||||
final columns = state.columns;
|
||||
final proxyCardType = state.proxyCardType;
|
||||
return switch (type) {
|
||||
ProxiesType.tab => _buildTabGroupView(
|
||||
proxies: proxies,
|
||||
columns: columns,
|
||||
proxyCardType: proxyCardType,
|
||||
),
|
||||
ProxiesType.list => _buildExpansionGroupView(
|
||||
proxies: proxies,
|
||||
columns: columns,
|
||||
proxyCardType: proxyCardType,
|
||||
),
|
||||
};
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class DelayTestButtonContainer extends StatefulWidget {
|
||||
final Widget child;
|
||||
final Future Function() onClick;
|
||||
|
||||
const DelayTestButtonContainer({
|
||||
super.key,
|
||||
required this.child,
|
||||
required this.onClick,
|
||||
});
|
||||
|
||||
@override
|
||||
State<DelayTestButtonContainer> createState() =>
|
||||
_DelayTestButtonContainerState();
|
||||
}
|
||||
|
||||
class _DelayTestButtonContainerState extends State<DelayTestButtonContainer>
|
||||
with SingleTickerProviderStateMixin {
|
||||
late AnimationController _controller;
|
||||
late Animation<double> _scale;
|
||||
|
||||
_healthcheck() async {
|
||||
_controller.forward();
|
||||
await widget.onClick();
|
||||
_controller.reverse();
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_controller = AnimationController(
|
||||
vsync: this,
|
||||
duration: const Duration(
|
||||
milliseconds: 200,
|
||||
),
|
||||
);
|
||||
_scale = Tween<double>(
|
||||
begin: 1.0,
|
||||
end: 0.0,
|
||||
).animate(
|
||||
CurvedAnimation(
|
||||
parent: _controller,
|
||||
curve: const Interval(
|
||||
0,
|
||||
1,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
_controller.reverse();
|
||||
return FloatLayout(
|
||||
floatingWidget: FloatWrapper(
|
||||
child: AnimatedBuilder(
|
||||
animation: _controller.view,
|
||||
builder: (_, child) {
|
||||
return SizedBox(
|
||||
width: 56,
|
||||
height: 56,
|
||||
child: Transform.scale(
|
||||
scale: _scale.value,
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
},
|
||||
child: FloatingActionButton(
|
||||
heroTag: null,
|
||||
onPressed: _healthcheck,
|
||||
child: const Icon(Icons.network_ping),
|
||||
),
|
||||
),
|
||||
),
|
||||
child: widget.child,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,50 +1,521 @@
|
||||
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/card.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'group.dart';
|
||||
import 'card.dart';
|
||||
import 'common.dart';
|
||||
|
||||
typedef GroupNameProxiesMap = Map<String, List<Proxy>>;
|
||||
|
||||
class ProxiesListFragment extends StatefulWidget {
|
||||
const ProxiesListFragment({super.key});
|
||||
|
||||
@override
|
||||
State<ProxiesListFragment> createState() =>
|
||||
_ProxiesListFragmentState();
|
||||
State<ProxiesListFragment> createState() => _ProxiesListFragmentState();
|
||||
}
|
||||
|
||||
class _ProxiesListFragmentState
|
||||
extends State<ProxiesListFragment> {
|
||||
class _ProxiesListFragmentState extends State<ProxiesListFragment> {
|
||||
final _controller = ScrollController();
|
||||
final _headerStateNotifier = ValueNotifier<ProxiesListHeaderSelectorState>(
|
||||
const ProxiesListHeaderSelectorState(
|
||||
offset: 0,
|
||||
currentIndex: 0,
|
||||
),
|
||||
);
|
||||
List<double> _headerOffset = [];
|
||||
GroupNameProxiesMap _lastGroupNameProxiesMap = {};
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_controller.addListener(_adjustHeader);
|
||||
}
|
||||
|
||||
_adjustHeader() {
|
||||
final offset = _controller.offset;
|
||||
final index = _headerOffset.findInterval(offset);
|
||||
final currentIndex = index;
|
||||
double headerOffset = 0.0;
|
||||
if (index + 1 <= _headerOffset.length - 1) {
|
||||
final endOffset = _headerOffset[index + 1];
|
||||
final startOffset = endOffset - listHeaderHeight - 8;
|
||||
if (offset > startOffset && offset < endOffset) {
|
||||
headerOffset = offset - startOffset;
|
||||
}
|
||||
}
|
||||
_headerStateNotifier.value = _headerStateNotifier.value.copyWith(
|
||||
currentIndex: currentIndex,
|
||||
offset: headerOffset,
|
||||
);
|
||||
}
|
||||
|
||||
double _getListItemHeight(Type type, ProxyCardType proxyCardType) {
|
||||
return switch (type) {
|
||||
const (SizedBox) => 8,
|
||||
const (ListHeader) => listHeaderHeight,
|
||||
Type() => getItemHeight(proxyCardType),
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
_headerStateNotifier.dispose();
|
||||
_controller.removeListener(_adjustHeader);
|
||||
_controller.dispose();
|
||||
}
|
||||
|
||||
_handleChange(Set<String> currentUnfoldSet, String groupName) {
|
||||
final tempUnfoldSet = Set<String>.from(currentUnfoldSet);
|
||||
if (tempUnfoldSet.contains(groupName)) {
|
||||
tempUnfoldSet.remove(groupName);
|
||||
} else {
|
||||
tempUnfoldSet.add(groupName);
|
||||
}
|
||||
globalState.appController.config.updateCurrentUnfoldSet(
|
||||
tempUnfoldSet,
|
||||
);
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_adjustHeader();
|
||||
});
|
||||
}
|
||||
|
||||
List<double> _getItemHeightList(
|
||||
List<Widget> items,
|
||||
ProxyCardType proxyCardType,
|
||||
) {
|
||||
final itemHeightList = <double>[];
|
||||
List<double> headerOffset = [];
|
||||
double currentHeight = 0;
|
||||
for (final item in items) {
|
||||
if (item.runtimeType == ListHeader) {
|
||||
headerOffset.add(currentHeight);
|
||||
}
|
||||
final itemHeight = _getListItemHeight(item.runtimeType, proxyCardType);
|
||||
itemHeightList.add(itemHeight);
|
||||
currentHeight = currentHeight + itemHeight;
|
||||
}
|
||||
_headerOffset = headerOffset;
|
||||
return itemHeightList;
|
||||
}
|
||||
|
||||
List<Widget> _buildItems({
|
||||
required List<String> groupNames,
|
||||
required int columns,
|
||||
required Set<String> currentUnfoldSet,
|
||||
required ProxyCardType type,
|
||||
}) {
|
||||
final items = <Widget>[];
|
||||
final GroupNameProxiesMap groupNameProxiesMap = {};
|
||||
for (final groupName in groupNames) {
|
||||
final group =
|
||||
globalState.appController.appState.getGroupWithName(groupName)!;
|
||||
final isExpand = currentUnfoldSet.contains(groupName);
|
||||
items.addAll([
|
||||
ListHeader(
|
||||
onScrollToSelected: _scrollToGroupSelected,
|
||||
key: Key(groupName),
|
||||
isExpand: isExpand,
|
||||
group: group,
|
||||
onChange: (String groupName) {
|
||||
_handleChange(currentUnfoldSet, groupName);
|
||||
},
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
]);
|
||||
if (isExpand) {
|
||||
final sortedProxies = globalState.appController.getSortProxies(
|
||||
group.all,
|
||||
);
|
||||
groupNameProxiesMap[groupName] = sortedProxies;
|
||||
final chunks = sortedProxies.chunks(columns);
|
||||
final rows = chunks.map<Widget>((proxies) {
|
||||
final children = proxies
|
||||
.map<Widget>(
|
||||
(proxy) => Flexible(
|
||||
child: ProxyCard(
|
||||
type: type,
|
||||
groupType: group.type,
|
||||
key: ValueKey('$groupName.${proxy.name}'),
|
||||
proxy: proxy,
|
||||
groupName: groupName,
|
||||
),
|
||||
),
|
||||
)
|
||||
.fill(
|
||||
columns,
|
||||
filler: (_) => const Flexible(
|
||||
child: SizedBox(),
|
||||
),
|
||||
)
|
||||
.separated(
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
);
|
||||
|
||||
return Row(
|
||||
children: children.toList(),
|
||||
);
|
||||
}).separated(
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
);
|
||||
items.addAll(
|
||||
[
|
||||
...rows,
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
_lastGroupNameProxiesMap = groupNameProxiesMap;
|
||||
return items;
|
||||
}
|
||||
|
||||
_buildHeader({
|
||||
required String groupName,
|
||||
required Set<String> currentUnfoldSet,
|
||||
}) {
|
||||
final group =
|
||||
globalState.appController.appState.getGroupWithName(groupName)!;
|
||||
final isExpand = currentUnfoldSet.contains(groupName);
|
||||
return SizedBox(
|
||||
height: listHeaderHeight,
|
||||
child: ListHeader(
|
||||
onScrollToSelected: _scrollToGroupSelected,
|
||||
key: Key(groupName),
|
||||
isExpand: isExpand,
|
||||
group: group,
|
||||
onChange: (String groupName) {
|
||||
_handleChange(currentUnfoldSet, groupName);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
_scrollToGroupSelected(String groupName) {
|
||||
if (_controller.position.maxScrollExtent == 0) {
|
||||
return;
|
||||
}
|
||||
final appController = globalState.appController;
|
||||
final currentGroups = appController.appState.currentGroups;
|
||||
final groupNames = currentGroups.map((e) => e.name).toList();
|
||||
final findIndex = groupNames.indexWhere((item) => item == groupName);
|
||||
final index = findIndex != -1 ? findIndex : 0;
|
||||
final currentInitOffset = _headerOffset[index];
|
||||
final proxies = _lastGroupNameProxiesMap[groupName];
|
||||
_controller.animateTo(
|
||||
currentInitOffset +
|
||||
getScrollToSelectedOffset(
|
||||
groupName: groupName,
|
||||
proxies: proxies ?? [],
|
||||
),
|
||||
duration: const Duration(milliseconds: 300),
|
||||
curve: Curves.easeIn,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Selector2<AppState, Config, ProxiesSelectorState>(
|
||||
return Selector2<AppState, Config, ProxiesListSelectorState>(
|
||||
selector: (_, appState, config) {
|
||||
final currentGroups = appState.currentGroups;
|
||||
final groupNames = currentGroups.map((e) => e.name).toList();
|
||||
return ProxiesSelectorState(
|
||||
return ProxiesListSelectorState(
|
||||
groupNames: groupNames,
|
||||
currentGroupName: config.currentGroupName,
|
||||
currentUnfoldSet: config.currentUnfoldSet,
|
||||
proxyCardType: config.proxyCardType,
|
||||
proxiesSortType: config.proxiesSortType,
|
||||
columns: globalState.appController.columns,
|
||||
sortNum: appState.sortNum,
|
||||
);
|
||||
},
|
||||
shouldRebuild: (prev, next) {
|
||||
if (!const ListEquality<String>()
|
||||
.equals(prev.groupNames, next.groupNames)) {
|
||||
_headerStateNotifier.value = const ProxiesListHeaderSelectorState(
|
||||
offset: 0,
|
||||
currentIndex: 0,
|
||||
);
|
||||
}
|
||||
return prev != next;
|
||||
},
|
||||
builder: (_, state, __) {
|
||||
return ListView.separated(
|
||||
padding: const EdgeInsets.all(16),
|
||||
itemCount: state.groupNames.length,
|
||||
itemBuilder: (_, index) {
|
||||
final groupName = state.groupNames[index];
|
||||
return ProxyGroupView(
|
||||
key: PageStorageKey(groupName),
|
||||
groupName: groupName,
|
||||
type: ProxiesType.list,
|
||||
);
|
||||
},
|
||||
separatorBuilder: (BuildContext context, int index) {
|
||||
return const SizedBox(
|
||||
height: 16,
|
||||
);
|
||||
},
|
||||
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,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ListHeader extends StatefulWidget {
|
||||
final Group group;
|
||||
|
||||
final Function(String groupName) onChange;
|
||||
final Function(String groupName) onScrollToSelected;
|
||||
final bool isExpand;
|
||||
|
||||
const ListHeader({
|
||||
super.key,
|
||||
required this.group,
|
||||
required this.onChange,
|
||||
required this.onScrollToSelected,
|
||||
required this.isExpand,
|
||||
});
|
||||
|
||||
@override
|
||||
State<ListHeader> createState() => _ListHeaderState();
|
||||
}
|
||||
|
||||
class _ListHeaderState extends State<ListHeader>
|
||||
with SingleTickerProviderStateMixin {
|
||||
late AnimationController _animationController;
|
||||
late Animation<double> _iconTurns;
|
||||
var isLock = false;
|
||||
|
||||
String get groupName => widget.group.name;
|
||||
|
||||
String get groupType => widget.group.type.name;
|
||||
|
||||
bool get isExpand => widget.isExpand;
|
||||
|
||||
_delayTest(List<Proxy> proxies) async {
|
||||
if (isLock) return;
|
||||
isLock = true;
|
||||
await delayTest(proxies);
|
||||
isLock = false;
|
||||
}
|
||||
|
||||
_handleChange(String groupName) {
|
||||
if (isExpand) {
|
||||
_animationController.reverse();
|
||||
} else {
|
||||
_animationController.forward();
|
||||
}
|
||||
widget.onChange(groupName);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_animationController = AnimationController(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
vsync: this,
|
||||
);
|
||||
_iconTurns = _animationController.drive(
|
||||
Tween<double>(begin: 0.0, end: 0.5),
|
||||
);
|
||||
if (isExpand) {
|
||||
_animationController.value = 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_animationController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(ListHeader oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
if (oldWidget.isExpand != widget.isExpand) {
|
||||
if (isExpand) {
|
||||
_animationController.value = 1.0;
|
||||
} else {
|
||||
_animationController.value = 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CommonCard(
|
||||
key: widget.key,
|
||||
type: CommonCardType.filled,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Flexible(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
groupName,
|
||||
style: context.textTheme.titleMedium,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 4,
|
||||
),
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
groupType,
|
||||
style: context.textTheme.labelMedium?.toLight,
|
||||
),
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: currentGroupProxyNameBuilder(
|
||||
groupName: groupName,
|
||||
builder: (currentGroupName) {
|
||||
return Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
if (currentGroupName.isNotEmpty) ...[
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: Text(
|
||||
overflow: TextOverflow.ellipsis,
|
||||
" · $currentGroupName",
|
||||
style: context
|
||||
.textTheme.labelMedium?.toLight,
|
||||
),
|
||||
),
|
||||
]
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
if (isExpand) ...[
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
widget.onScrollToSelected(groupName);
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.adjust,
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
_delayTest(widget.group.all);
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.network_ping,
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 4,
|
||||
),
|
||||
],
|
||||
AnimatedBuilder(
|
||||
animation: _animationController.view,
|
||||
builder: (_, __) {
|
||||
return IconButton.filledTonal(
|
||||
onPressed: () {
|
||||
_handleChange(groupName);
|
||||
},
|
||||
icon: RotationTransition(
|
||||
turns: _iconTurns,
|
||||
child: const Icon(
|
||||
Icons.expand_more,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
_handleChange(groupName);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,12 +17,26 @@ class ProxiesFragment extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _ProxiesFragmentState extends State<ProxiesFragment> {
|
||||
final GlobalKey<ProxiesTabFragmentState> _proxiesTabKey = GlobalKey();
|
||||
|
||||
_initActions() {
|
||||
_initActions(ProxiesType proxiesType) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
||||
final commonScaffoldState =
|
||||
context.findAncestorStateOfType<CommonScaffoldState>();
|
||||
commonScaffoldState?.actions = [
|
||||
if (proxiesType == ProxiesType.tab) ...[
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
_proxiesTabKey.currentState?.scrollToGroupSelected();
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.gps_fixed,
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
)
|
||||
],
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
showSheet(
|
||||
@@ -43,23 +57,24 @@ class _ProxiesFragmentState extends State<ProxiesFragment> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Selector<AppState, bool>(
|
||||
selector: (_, appState) => appState.currentLabel == 'proxies',
|
||||
builder: (_, isCurrent, child) {
|
||||
if (isCurrent) {
|
||||
_initActions();
|
||||
}
|
||||
return child!;
|
||||
return Selector<Config, ProxiesType>(
|
||||
selector: (_, config) => config.proxiesType,
|
||||
builder: (_, proxiesType, __) {
|
||||
return Selector<AppState, bool>(
|
||||
selector: (_, appState) => appState.currentLabel == 'proxies',
|
||||
builder: (_, isCurrent, child) {
|
||||
if (isCurrent) {
|
||||
_initActions(proxiesType);
|
||||
}
|
||||
return switch (proxiesType) {
|
||||
ProxiesType.tab => ProxiesTabFragment(
|
||||
key: _proxiesTabKey,
|
||||
),
|
||||
ProxiesType.list => const ProxiesListFragment(),
|
||||
};
|
||||
},
|
||||
);
|
||||
},
|
||||
child: Selector<Config, ProxiesType>(
|
||||
selector: (_, config) => config.proxiesType,
|
||||
builder: (_, proxiesType, __) {
|
||||
return switch (proxiesType) {
|
||||
ProxiesType.tab => const ProxiesTabFragment(),
|
||||
ProxiesType.list => const ProxiesListFragment(),
|
||||
};
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,19 +8,23 @@ import 'package:fl_clash/widgets/widgets.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'group.dart';
|
||||
import 'card.dart';
|
||||
import 'common.dart';
|
||||
|
||||
typedef GroupNameKeyMap = Map<String, GlobalObjectKey<ProxyGroupViewState>>;
|
||||
|
||||
class ProxiesTabFragment extends StatefulWidget {
|
||||
const ProxiesTabFragment({super.key});
|
||||
|
||||
@override
|
||||
State<ProxiesTabFragment> createState() => _ProxiesTabFragmentState();
|
||||
State<ProxiesTabFragment> createState() => ProxiesTabFragmentState();
|
||||
}
|
||||
|
||||
class _ProxiesTabFragmentState extends State<ProxiesTabFragment>
|
||||
class ProxiesTabFragmentState extends State<ProxiesTabFragment>
|
||||
with TickerProviderStateMixin {
|
||||
TabController? _tabController;
|
||||
final hasMoreButtonNotifier = ValueNotifier<bool>(false);
|
||||
final _hasMoreButtonNotifier = ValueNotifier<bool>(false);
|
||||
GroupNameKeyMap _keyMap = {};
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
@@ -28,6 +32,11 @@ class _ProxiesTabFragmentState extends State<ProxiesTabFragment>
|
||||
_tabController?.dispose();
|
||||
}
|
||||
|
||||
scrollToGroupSelected() {
|
||||
final currentGroupName = globalState.appController.config.currentGroupName;
|
||||
_keyMap[currentGroupName]?.currentState?.scrollToSelected();
|
||||
}
|
||||
|
||||
_buildMoreButton() {
|
||||
return Selector<AppState, bool>(
|
||||
selector: (_, appState) => appState.viewMode == ViewMode.mobile,
|
||||
@@ -83,6 +92,7 @@ class _ProxiesTabFragmentState extends State<ProxiesTabFragment>
|
||||
.updateCurrentGroupName(
|
||||
groupName,
|
||||
);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
isSelected: groupName == state.currentGroupName,
|
||||
)
|
||||
@@ -126,18 +136,29 @@ class _ProxiesTabFragmentState extends State<ProxiesTabFragment>
|
||||
initialIndex: index == -1 ? 0 : index,
|
||||
vsync: this,
|
||||
);
|
||||
GroupNameKeyMap keyMap = {};
|
||||
final children = state.groupNames.map((groupName) {
|
||||
keyMap[groupName] = GlobalObjectKey(groupName);
|
||||
return KeepContainer(
|
||||
child: ProxyGroupView(
|
||||
key: keyMap[groupName],
|
||||
groupName: groupName,
|
||||
),
|
||||
);
|
||||
}).toList();
|
||||
_keyMap = keyMap;
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
NotificationListener<ScrollMetricsNotification>(
|
||||
onNotification: (scrollNotification) {
|
||||
hasMoreButtonNotifier.value =
|
||||
_hasMoreButtonNotifier.value =
|
||||
scrollNotification.metrics.maxScrollExtent > 0;
|
||||
return true;
|
||||
},
|
||||
child: ValueListenableBuilder(
|
||||
valueListenable: hasMoreButtonNotifier,
|
||||
valueListenable: _hasMoreButtonNotifier,
|
||||
builder: (_, value, child) {
|
||||
return Stack(
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
@@ -199,16 +220,7 @@ class _ProxiesTabFragmentState extends State<ProxiesTabFragment>
|
||||
Expanded(
|
||||
child: TabBarView(
|
||||
controller: _tabController,
|
||||
children: [
|
||||
for (final groupName in state.groupNames)
|
||||
KeepContainer(
|
||||
key: ObjectKey(groupName),
|
||||
child: ProxyGroupView(
|
||||
groupName: groupName,
|
||||
type: ProxiesType.tab,
|
||||
),
|
||||
),
|
||||
],
|
||||
children: children,
|
||||
),
|
||||
)
|
||||
],
|
||||
@@ -217,3 +229,192 @@ class _ProxiesTabFragmentState extends State<ProxiesTabFragment>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ProxyGroupView extends StatefulWidget {
|
||||
final String groupName;
|
||||
|
||||
const ProxyGroupView({
|
||||
super.key,
|
||||
required this.groupName,
|
||||
});
|
||||
|
||||
@override
|
||||
State<ProxyGroupView> createState() => ProxyGroupViewState();
|
||||
}
|
||||
|
||||
class ProxyGroupViewState extends State<ProxyGroupView> {
|
||||
var isLock = false;
|
||||
final _controller = ScrollController();
|
||||
List<Proxy> _lastProxies = [];
|
||||
|
||||
String get groupName => widget.groupName;
|
||||
|
||||
_delayTest(List<Proxy> proxies) async {
|
||||
if (isLock) return;
|
||||
isLock = true;
|
||||
await delayTest(proxies);
|
||||
isLock = false;
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
_controller.dispose();
|
||||
}
|
||||
|
||||
scrollToSelected() {
|
||||
if (_controller.position.maxScrollExtent == 0) {
|
||||
return;
|
||||
}
|
||||
_controller.animateTo(
|
||||
16 +
|
||||
getScrollToSelectedOffset(
|
||||
groupName: groupName,
|
||||
proxies: _lastProxies,
|
||||
),
|
||||
duration: const Duration(milliseconds: 300),
|
||||
curve: Curves.easeIn,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Selector2<AppState, Config, ProxyGroupSelectorState>(
|
||||
selector: (_, appState, config) {
|
||||
final group = appState.getGroupWithName(groupName)!;
|
||||
return ProxyGroupSelectorState(
|
||||
proxyCardType: config.proxyCardType,
|
||||
proxiesSortType: config.proxiesSortType,
|
||||
columns: globalState.appController.columns,
|
||||
sortNum: appState.sortNum,
|
||||
proxies: group.all,
|
||||
groupType: group.type,
|
||||
);
|
||||
},
|
||||
builder: (_, state, __) {
|
||||
final proxies = state.proxies;
|
||||
final columns = state.columns;
|
||||
final proxyCardType = state.proxyCardType;
|
||||
final sortedProxies = globalState.appController.getSortProxies(
|
||||
proxies,
|
||||
);
|
||||
_lastProxies = sortedProxies;
|
||||
return DelayTestButtonContainer(
|
||||
onClick: () async {
|
||||
await _delayTest(
|
||||
proxies,
|
||||
);
|
||||
},
|
||||
child: Align(
|
||||
alignment: Alignment.topCenter,
|
||||
child: GridView.builder(
|
||||
controller: _controller,
|
||||
padding: const EdgeInsets.all(16),
|
||||
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,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class DelayTestButtonContainer extends StatefulWidget {
|
||||
final Widget child;
|
||||
final Future Function() onClick;
|
||||
|
||||
const DelayTestButtonContainer({
|
||||
super.key,
|
||||
required this.child,
|
||||
required this.onClick,
|
||||
});
|
||||
|
||||
@override
|
||||
State<DelayTestButtonContainer> createState() =>
|
||||
_DelayTestButtonContainerState();
|
||||
}
|
||||
|
||||
class _DelayTestButtonContainerState extends State<DelayTestButtonContainer>
|
||||
with SingleTickerProviderStateMixin {
|
||||
late AnimationController _controller;
|
||||
late Animation<double> _scale;
|
||||
|
||||
_healthcheck() async {
|
||||
_controller.forward();
|
||||
await widget.onClick();
|
||||
_controller.reverse();
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_controller = AnimationController(
|
||||
vsync: this,
|
||||
duration: const Duration(
|
||||
milliseconds: 200,
|
||||
),
|
||||
);
|
||||
_scale = Tween<double>(
|
||||
begin: 1.0,
|
||||
end: 0.0,
|
||||
).animate(
|
||||
CurvedAnimation(
|
||||
parent: _controller,
|
||||
curve: const Interval(
|
||||
0,
|
||||
1,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
_controller.reverse();
|
||||
return FloatLayout(
|
||||
floatingWidget: FloatWrapper(
|
||||
child: AnimatedBuilder(
|
||||
animation: _controller.view,
|
||||
builder: (_, child) {
|
||||
return SizedBox(
|
||||
width: 56,
|
||||
height: 56,
|
||||
child: Transform.scale(
|
||||
scale: _scale.value,
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
},
|
||||
child: FloatingActionButton(
|
||||
heroTag: null,
|
||||
onPressed: _healthcheck,
|
||||
child: const Icon(Icons.network_ping),
|
||||
),
|
||||
),
|
||||
),
|
||||
child: widget.child,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,17 +22,6 @@ class GeoItem {
|
||||
});
|
||||
}
|
||||
|
||||
@immutable
|
||||
class FileInfo {
|
||||
final String size;
|
||||
final DateTime lastModified;
|
||||
|
||||
const FileInfo({
|
||||
required this.size,
|
||||
required this.lastModified,
|
||||
});
|
||||
}
|
||||
|
||||
class Resources extends StatefulWidget {
|
||||
const Resources({super.key});
|
||||
|
||||
@@ -196,27 +185,11 @@ class _GeoDataListItemState extends State<GeoDataListItem> {
|
||||
final lastModified = await file.lastModified();
|
||||
final size = await file.length();
|
||||
return FileInfo(
|
||||
size: TrafficValue(value: size).show,
|
||||
size: size,
|
||||
lastModified: lastModified,
|
||||
);
|
||||
}
|
||||
|
||||
// _uploadGeoFile(String fileName) async {
|
||||
// final res = await picker.pickerGeoDataFile();
|
||||
// if (res == null || res.bytes == null) return;
|
||||
// final homePath = await appPath.getHomeDirPath();
|
||||
// final file = File(join(homePath, fileName));
|
||||
// await file.writeAsBytes(
|
||||
// res.bytes!,
|
||||
// flush: true,
|
||||
// );
|
||||
// setState(() {});
|
||||
// }
|
||||
|
||||
String _buildFileInfoDesc(FileInfo fileInfo) {
|
||||
return "${fileInfo.size} · ${fileInfo.lastModified.lastUpdateTimeDesc}";
|
||||
}
|
||||
|
||||
Widget _buildSubtitle(String url) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@@ -240,7 +213,7 @@ class _GeoDataListItemState extends State<GeoDataListItem> {
|
||||
),
|
||||
)
|
||||
: Text(
|
||||
_buildFileInfoDesc(snapshot.data!),
|
||||
snapshot.data!.desc,
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -510,4 +483,4 @@ class _UpdateGeoUrlFormDialogState extends State<UpdateGeoUrlFormDialog> {
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:fl_clash/common/common.dart';
|
||||
import 'package:fl_clash/models/models.dart';
|
||||
import 'package:fl_clash/state.dart';
|
||||
@@ -23,27 +21,6 @@ class ThemeModeItem {
|
||||
class ThemeFragment extends StatelessWidget {
|
||||
const ThemeFragment({super.key});
|
||||
|
||||
Widget _itemCard({
|
||||
required BuildContext context,
|
||||
required Info info,
|
||||
required Widget child,
|
||||
}) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 16,
|
||||
),
|
||||
child: Wrap(
|
||||
runSpacing: 16,
|
||||
children: [
|
||||
InfoHeader(
|
||||
info: info,
|
||||
),
|
||||
child,
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final previewCard = Padding(
|
||||
|
||||
@@ -211,5 +211,13 @@
|
||||
"sort": "Sort",
|
||||
"columns": "Columns",
|
||||
"proxiesSetting": "Proxies setting",
|
||||
"proxyGroup": "Proxy group"
|
||||
"proxyGroup": "Proxy group",
|
||||
"go": "Go",
|
||||
"externalLink": "External link",
|
||||
"otherContributors": "Other contributors",
|
||||
"autoCloseConnections": "Auto lose connections",
|
||||
"autoCloseConnectionsDesc": "Auto close connections after change node",
|
||||
"onlyStatisticsProxy": "Only statistics proxy",
|
||||
"onlyStatisticsProxyDesc": "When turned on, only statistics proxy traffic",
|
||||
"deleteProfileTip": "Sure you want to delete the current profile?"
|
||||
}
|
||||
@@ -211,5 +211,13 @@
|
||||
"sort": "排序",
|
||||
"columns": "列数",
|
||||
"proxiesSetting": "代理设置",
|
||||
"proxyGroup": "代理组"
|
||||
"proxyGroup": "代理组",
|
||||
"go": "前往",
|
||||
"externalLink": "外部链接",
|
||||
"otherContributors": "其他贡献者",
|
||||
"autoCloseConnections": "自动关闭连接",
|
||||
"autoCloseConnectionsDesc": "切换节点后自动关闭连接",
|
||||
"onlyStatisticsProxy": "仅统计代理",
|
||||
"onlyStatisticsProxyDesc": "开启后,将只统计代理流量",
|
||||
"deleteProfileTip": "确定要删除当前配置吗?"
|
||||
}
|
||||
@@ -58,6 +58,10 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
MessageLookupByLibrary.simpleMessage("Auto check updates"),
|
||||
"autoCheckUpdateDesc": MessageLookupByLibrary.simpleMessage(
|
||||
"Auto check for updates when the app starts"),
|
||||
"autoCloseConnections":
|
||||
MessageLookupByLibrary.simpleMessage("Auto lose connections"),
|
||||
"autoCloseConnectionsDesc": MessageLookupByLibrary.simpleMessage(
|
||||
"Auto close connections after change node"),
|
||||
"autoLaunch": MessageLookupByLibrary.simpleMessage("AutoLaunch"),
|
||||
"autoLaunchDesc": MessageLookupByLibrary.simpleMessage(
|
||||
"Follow the system self startup"),
|
||||
@@ -111,6 +115,8 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"delay": MessageLookupByLibrary.simpleMessage("Delay"),
|
||||
"delaySort": MessageLookupByLibrary.simpleMessage("Sort by delay"),
|
||||
"delete": MessageLookupByLibrary.simpleMessage("Delete"),
|
||||
"deleteProfileTip": MessageLookupByLibrary.simpleMessage(
|
||||
"Sure you want to delete the current profile?"),
|
||||
"desc": MessageLookupByLibrary.simpleMessage(
|
||||
"A multi-platform proxy client based on ClashMeta, simple and easy to use, open-source and ad-free."),
|
||||
"direct": MessageLookupByLibrary.simpleMessage("Direct"),
|
||||
@@ -135,6 +141,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
MessageLookupByLibrary.simpleMessage("ExternalController"),
|
||||
"externalControllerDesc": MessageLookupByLibrary.simpleMessage(
|
||||
"Once enabled, the Clash kernel can be controlled on port 9090"),
|
||||
"externalLink": MessageLookupByLibrary.simpleMessage("External link"),
|
||||
"externalResources":
|
||||
MessageLookupByLibrary.simpleMessage("External resources"),
|
||||
"file": MessageLookupByLibrary.simpleMessage("File"),
|
||||
@@ -153,6 +160,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"geodataLoaderDesc": MessageLookupByLibrary.simpleMessage(
|
||||
"Enabling will use the Geo low memory loader"),
|
||||
"global": MessageLookupByLibrary.simpleMessage("Global"),
|
||||
"go": MessageLookupByLibrary.simpleMessage("Go"),
|
||||
"goDownload": MessageLookupByLibrary.simpleMessage("Go to download"),
|
||||
"hours": MessageLookupByLibrary.simpleMessage("Hours"),
|
||||
"importFromURL":
|
||||
@@ -202,7 +210,13 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"No profile, Please add a profile"),
|
||||
"nullRequestsDesc": MessageLookupByLibrary.simpleMessage("No requests"),
|
||||
"oneColumn": MessageLookupByLibrary.simpleMessage("One column"),
|
||||
"onlyStatisticsProxy":
|
||||
MessageLookupByLibrary.simpleMessage("Only statistics proxy"),
|
||||
"onlyStatisticsProxyDesc": MessageLookupByLibrary.simpleMessage(
|
||||
"When turned on, only statistics proxy traffic"),
|
||||
"other": MessageLookupByLibrary.simpleMessage("Other"),
|
||||
"otherContributors":
|
||||
MessageLookupByLibrary.simpleMessage("Other contributors"),
|
||||
"outboundMode": MessageLookupByLibrary.simpleMessage("Outbound mode"),
|
||||
"override": MessageLookupByLibrary.simpleMessage("Override"),
|
||||
"overrideDesc": MessageLookupByLibrary.simpleMessage(
|
||||
|
||||
@@ -49,6 +49,9 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"autoCheckUpdate": MessageLookupByLibrary.simpleMessage("自动检查更新"),
|
||||
"autoCheckUpdateDesc":
|
||||
MessageLookupByLibrary.simpleMessage("应用启动时自动检查更新"),
|
||||
"autoCloseConnections": MessageLookupByLibrary.simpleMessage("自动关闭连接"),
|
||||
"autoCloseConnectionsDesc":
|
||||
MessageLookupByLibrary.simpleMessage("切换节点后自动关闭连接"),
|
||||
"autoLaunch": MessageLookupByLibrary.simpleMessage("自启动"),
|
||||
"autoLaunchDesc": MessageLookupByLibrary.simpleMessage("跟随系统自启动"),
|
||||
"autoRun": MessageLookupByLibrary.simpleMessage("自动运行"),
|
||||
@@ -93,6 +96,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"delay": MessageLookupByLibrary.simpleMessage("延迟"),
|
||||
"delaySort": MessageLookupByLibrary.simpleMessage("按延迟排序"),
|
||||
"delete": MessageLookupByLibrary.simpleMessage("删除"),
|
||||
"deleteProfileTip": MessageLookupByLibrary.simpleMessage("确定要删除当前配置吗?"),
|
||||
"desc": MessageLookupByLibrary.simpleMessage(
|
||||
"基于ClashMeta的多平台代理客户端,简单易用,开源无广告。"),
|
||||
"direct": MessageLookupByLibrary.simpleMessage("直连"),
|
||||
@@ -111,6 +115,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"externalController": MessageLookupByLibrary.simpleMessage("外部控制器"),
|
||||
"externalControllerDesc":
|
||||
MessageLookupByLibrary.simpleMessage("开启后将可以通过9090端口控制Clash内核"),
|
||||
"externalLink": MessageLookupByLibrary.simpleMessage("外部链接"),
|
||||
"externalResources": MessageLookupByLibrary.simpleMessage("外部资源"),
|
||||
"file": MessageLookupByLibrary.simpleMessage("文件"),
|
||||
"fileDesc": MessageLookupByLibrary.simpleMessage("直接上传配置文件"),
|
||||
@@ -125,6 +130,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"geodataLoaderDesc":
|
||||
MessageLookupByLibrary.simpleMessage("开启将使用Geo低内存加载器"),
|
||||
"global": MessageLookupByLibrary.simpleMessage("全局"),
|
||||
"go": MessageLookupByLibrary.simpleMessage("前往"),
|
||||
"goDownload": MessageLookupByLibrary.simpleMessage("前往下载"),
|
||||
"hours": MessageLookupByLibrary.simpleMessage("小时"),
|
||||
"importFromURL": MessageLookupByLibrary.simpleMessage("从URL导入"),
|
||||
@@ -165,7 +171,11 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
MessageLookupByLibrary.simpleMessage("没有配置文件,请先添加配置文件"),
|
||||
"nullRequestsDesc": MessageLookupByLibrary.simpleMessage("暂无请求"),
|
||||
"oneColumn": MessageLookupByLibrary.simpleMessage("一列"),
|
||||
"onlyStatisticsProxy": MessageLookupByLibrary.simpleMessage("仅统计代理"),
|
||||
"onlyStatisticsProxyDesc":
|
||||
MessageLookupByLibrary.simpleMessage("开启后,将只统计代理流量"),
|
||||
"other": MessageLookupByLibrary.simpleMessage("其他"),
|
||||
"otherContributors": MessageLookupByLibrary.simpleMessage("其他贡献者"),
|
||||
"outboundMode": MessageLookupByLibrary.simpleMessage("出站模式"),
|
||||
"override": MessageLookupByLibrary.simpleMessage("覆写"),
|
||||
"overrideDesc": MessageLookupByLibrary.simpleMessage("覆写代理相关配置"),
|
||||
|
||||
@@ -2179,6 +2179,86 @@ class AppLocalizations {
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Go`
|
||||
String get go {
|
||||
return Intl.message(
|
||||
'Go',
|
||||
name: 'go',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `External link`
|
||||
String get externalLink {
|
||||
return Intl.message(
|
||||
'External link',
|
||||
name: 'externalLink',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Other contributors`
|
||||
String get otherContributors {
|
||||
return Intl.message(
|
||||
'Other contributors',
|
||||
name: 'otherContributors',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Auto lose connections`
|
||||
String get autoCloseConnections {
|
||||
return Intl.message(
|
||||
'Auto lose connections',
|
||||
name: 'autoCloseConnections',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Auto close connections after change node`
|
||||
String get autoCloseConnectionsDesc {
|
||||
return Intl.message(
|
||||
'Auto close connections after change node',
|
||||
name: 'autoCloseConnectionsDesc',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Only statistics proxy`
|
||||
String get onlyStatisticsProxy {
|
||||
return Intl.message(
|
||||
'Only statistics proxy',
|
||||
name: 'onlyStatisticsProxy',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `When turned on, only statistics proxy traffic`
|
||||
String get onlyStatisticsProxyDesc {
|
||||
return Intl.message(
|
||||
'When turned on, only statistics proxy traffic',
|
||||
name: 'onlyStatisticsProxyDesc',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Sure you want to delete the current profile?`
|
||||
String get deleteProfileTip {
|
||||
return Intl.message(
|
||||
'Sure you want to delete the current profile?',
|
||||
name: 'deleteProfileTip',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class AppLocalizationDelegate extends LocalizationsDelegate<AppLocalizations> {
|
||||
|
||||
@@ -47,6 +47,7 @@ Future<void> main() async {
|
||||
Future<void> vpnService() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
globalState.isVpnService = true;
|
||||
globalState.packageInfo = await PackageInfo.fromPlatform();
|
||||
final config = await preferences.getConfig() ?? Config();
|
||||
final clashConfig = await preferences.getClashConfig() ?? ClashConfig();
|
||||
final appState = AppState(
|
||||
@@ -86,11 +87,10 @@ Future<void> vpnService() async {
|
||||
final currentSelectedMap = config.currentSelectedMap;
|
||||
final proxyName = currentSelectedMap[groupName];
|
||||
if (proxyName == null) return;
|
||||
clashCore.changeProxy(
|
||||
ChangeProxyParams(
|
||||
groupName: groupName,
|
||||
proxyName: proxyName,
|
||||
),
|
||||
globalState.changeProxy(
|
||||
config: config,
|
||||
groupName: groupName,
|
||||
proxyName: proxyName,
|
||||
);
|
||||
},
|
||||
),
|
||||
@@ -119,7 +119,7 @@ Future<void> vpnService() async {
|
||||
|
||||
globalState.updateTraffic();
|
||||
globalState.updateFunctionLists = [
|
||||
() {
|
||||
() {
|
||||
globalState.updateTraffic();
|
||||
}
|
||||
];
|
||||
@@ -137,8 +137,7 @@ class ServiceMessageHandler with ServiceMessageListener {
|
||||
required Function(Process process) onProcess,
|
||||
required Function(String runTime) onStarted,
|
||||
required Function(String groupName) onLoaded,
|
||||
})
|
||||
: _onProtect = onProtect,
|
||||
}) : _onProtect = onProtect,
|
||||
_onProcess = onProcess,
|
||||
_onStarted = onStarted,
|
||||
_onLoaded = onLoaded;
|
||||
|
||||
@@ -55,7 +55,7 @@ class AppState with ChangeNotifier {
|
||||
_delayMap = {},
|
||||
_groups = [],
|
||||
_isCompatible = isCompatible,
|
||||
_systemColorSchemes = SystemColorSchemes();
|
||||
_systemColorSchemes = const SystemColorSchemes();
|
||||
|
||||
String get currentLabel => _currentLabel;
|
||||
|
||||
@@ -109,7 +109,7 @@ class AppState with ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
String getDesc(String type, String? proxyName) {
|
||||
String getDesc(String type, String proxyName) {
|
||||
final groupTypeNamesList = GroupType.values.map((e) => e.name).toList();
|
||||
if (!groupTypeNamesList.contains(type)) {
|
||||
return type;
|
||||
@@ -120,15 +120,17 @@ class AppState with ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
String? getRealProxyName(String? proxyName) {
|
||||
if (proxyName == null) return null;
|
||||
String getRealProxyName(String proxyName) {
|
||||
if (proxyName.isEmpty) return proxyName;
|
||||
final index = groups.indexWhere((element) => element.name == proxyName);
|
||||
if (index == -1) return proxyName;
|
||||
final group = groups[index];
|
||||
return getRealProxyName((selectedMap.containsKey(proxyName)
|
||||
? selectedMap[proxyName]
|
||||
: group.now)) ??
|
||||
proxyName;
|
||||
final currentSelectedName =
|
||||
group.getCurrentSelectedName(selectedMap[proxyName] ?? '');
|
||||
if (currentSelectedName.isEmpty) return proxyName;
|
||||
return getRealProxyName(
|
||||
currentSelectedName,
|
||||
);
|
||||
}
|
||||
|
||||
String? get showProxyName {
|
||||
@@ -140,7 +142,7 @@ class AppState with ChangeNotifier {
|
||||
return selectedMap[firstGroupName] ?? firstGroup.now;
|
||||
}
|
||||
|
||||
int? getDelay(String? proxyName) {
|
||||
int? getDelay(String proxyName) {
|
||||
return _delayMap[getRealProxyName(proxyName)];
|
||||
}
|
||||
|
||||
@@ -293,6 +295,7 @@ class AppState with ChangeNotifier {
|
||||
.toList();
|
||||
case Mode.rule:
|
||||
return groups
|
||||
.where((item) => item.hidden == false)
|
||||
.where((element) => element.name != GroupName.GLOBAL.name)
|
||||
.toList();
|
||||
}
|
||||
|
||||
@@ -275,7 +275,7 @@ class ClashConfig extends ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
@JsonKey(name: "global-ua", defaultValue: null)
|
||||
@JsonKey(name: "global-ua", includeFromJson: false, includeToJson: true)
|
||||
String get globalUa {
|
||||
if (_globalRealUa == null) {
|
||||
return globalState.packageInfo.ua;
|
||||
@@ -320,7 +320,6 @@ class ClashConfig extends ChangeNotifier {
|
||||
_geodataLoader = clashConfig._geodataLoader;
|
||||
_dns = clashConfig._dns;
|
||||
_rules = clashConfig._rules;
|
||||
_globalRealUa = clashConfig.globalRealUa;
|
||||
}
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
@@ -26,14 +26,16 @@ class AccessControl with _$AccessControl {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class Props with _$Props {
|
||||
const factory Props({
|
||||
class CoreState with _$CoreState {
|
||||
const factory CoreState({
|
||||
AccessControl? accessControl,
|
||||
required bool allowBypass,
|
||||
required bool systemProxy,
|
||||
}) = _Props;
|
||||
required int mixedPort,
|
||||
required bool onlyProxy,
|
||||
}) = _CoreState;
|
||||
|
||||
factory Props.fromJson(Map<String, Object?> json) => _$PropsFromJson(json);
|
||||
factory CoreState.fromJson(Map<String, Object?> json) => _$CoreStateFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
@@ -73,17 +75,20 @@ class Config extends ChangeNotifier {
|
||||
bool _systemProxy;
|
||||
bool _isExclude;
|
||||
DAV? _dav;
|
||||
bool _isCloseConnections;
|
||||
ProxiesType _proxiesType;
|
||||
ProxyCardType _proxyCardType;
|
||||
int _proxiesColumns;
|
||||
String _testUrl;
|
||||
WindowProps _windowProps;
|
||||
bool _onlyProxy;
|
||||
|
||||
Config()
|
||||
: _profiles = [],
|
||||
_autoLaunch = false,
|
||||
_silentLaunch = false,
|
||||
_autoRun = false,
|
||||
_isCloseConnections = false,
|
||||
_themeMode = ThemeMode.system,
|
||||
_openLog = false,
|
||||
_isCompatible = true,
|
||||
@@ -101,7 +106,8 @@ class Config extends ChangeNotifier {
|
||||
_proxyCardType = ProxyCardType.expand,
|
||||
_windowProps = defaultWindowProps,
|
||||
_proxiesType = ProxiesType.tab,
|
||||
_proxiesColumns = 2;
|
||||
_proxiesColumns = 2,
|
||||
_onlyProxy = false;
|
||||
|
||||
deleteProfileById(String id) {
|
||||
_profiles = profiles.where((element) => element.id != id).toList();
|
||||
@@ -405,6 +411,31 @@ class Config extends ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
@JsonKey(defaultValue: false)
|
||||
bool get onlyProxy {
|
||||
return _onlyProxy;
|
||||
}
|
||||
|
||||
set onlyProxy(bool value) {
|
||||
if (_onlyProxy != value) {
|
||||
_onlyProxy = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@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,
|
||||
@@ -482,6 +513,7 @@ class Config extends ChangeNotifier {
|
||||
}
|
||||
if (onlyProfiles) return;
|
||||
_currentProfileId = config._currentProfileId;
|
||||
_isCloseConnections = config._isCloseConnections;
|
||||
_isCompatible = config._isCompatible;
|
||||
_autoLaunch = config._autoLaunch;
|
||||
_silentLaunch = config._silentLaunch;
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// ignore_for_file: invalid_annotation_target
|
||||
|
||||
import 'package:fl_clash/enum/enum.dart';
|
||||
import 'package:fl_clash/models/clash_config.dart';
|
||||
import 'package:fl_clash/models/connection.dart';
|
||||
import 'package:fl_clash/models/models.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
|
||||
21
lib/models/file.dart
Normal file
@@ -0,0 +1,21 @@
|
||||
import 'package:fl_clash/common/datetime.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
import 'traffic.dart';
|
||||
|
||||
part 'generated/file.freezed.dart';
|
||||
|
||||
@freezed
|
||||
class FileInfo with _$FileInfo {
|
||||
const factory FileInfo({
|
||||
required int size,
|
||||
required DateTime lastModified,
|
||||
}) = _FileInfo;
|
||||
}
|
||||
|
||||
|
||||
extension FileInfoExt on FileInfo{
|
||||
String get desc => "${TrafficValue(value: size).show} · ${lastModified.lastUpdateTimeDesc}";
|
||||
}
|
||||
|
||||
|
||||
@@ -82,6 +82,7 @@ Map<String, dynamic> _$ClashConfigToJson(ClashConfig instance) =>
|
||||
'tun': instance.tun,
|
||||
'dns': instance.dns,
|
||||
'rules': instance.rules,
|
||||
'global-ua': instance.globalUa,
|
||||
'global-real-ua': instance.globalRealUa,
|
||||
'geox-url': instance.geoXUrl,
|
||||
};
|
||||
|
||||
@@ -240,35 +240,43 @@ abstract class _AccessControl implements AccessControl {
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
Props _$PropsFromJson(Map<String, dynamic> json) {
|
||||
return _Props.fromJson(json);
|
||||
CoreState _$CoreStateFromJson(Map<String, dynamic> json) {
|
||||
return _CoreState.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$Props {
|
||||
mixin _$CoreState {
|
||||
AccessControl? get accessControl => throw _privateConstructorUsedError;
|
||||
bool get allowBypass => throw _privateConstructorUsedError;
|
||||
bool get systemProxy => throw _privateConstructorUsedError;
|
||||
int get mixedPort => throw _privateConstructorUsedError;
|
||||
bool get onlyProxy => throw _privateConstructorUsedError;
|
||||
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
@JsonKey(ignore: true)
|
||||
$PropsCopyWith<Props> get copyWith => throw _privateConstructorUsedError;
|
||||
$CoreStateCopyWith<CoreState> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $PropsCopyWith<$Res> {
|
||||
factory $PropsCopyWith(Props value, $Res Function(Props) then) =
|
||||
_$PropsCopyWithImpl<$Res, Props>;
|
||||
abstract class $CoreStateCopyWith<$Res> {
|
||||
factory $CoreStateCopyWith(CoreState value, $Res Function(CoreState) then) =
|
||||
_$CoreStateCopyWithImpl<$Res, CoreState>;
|
||||
@useResult
|
||||
$Res call({AccessControl? accessControl, bool allowBypass, bool systemProxy});
|
||||
$Res call(
|
||||
{AccessControl? accessControl,
|
||||
bool allowBypass,
|
||||
bool systemProxy,
|
||||
int mixedPort,
|
||||
bool onlyProxy});
|
||||
|
||||
$AccessControlCopyWith<$Res>? get accessControl;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$PropsCopyWithImpl<$Res, $Val extends Props>
|
||||
implements $PropsCopyWith<$Res> {
|
||||
_$PropsCopyWithImpl(this._value, this._then);
|
||||
class _$CoreStateCopyWithImpl<$Res, $Val extends CoreState>
|
||||
implements $CoreStateCopyWith<$Res> {
|
||||
_$CoreStateCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
@@ -281,6 +289,8 @@ class _$PropsCopyWithImpl<$Res, $Val extends Props>
|
||||
Object? accessControl = freezed,
|
||||
Object? allowBypass = null,
|
||||
Object? systemProxy = null,
|
||||
Object? mixedPort = null,
|
||||
Object? onlyProxy = null,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
accessControl: freezed == accessControl
|
||||
@@ -295,6 +305,14 @@ class _$PropsCopyWithImpl<$Res, $Val extends Props>
|
||||
? _value.systemProxy
|
||||
: systemProxy // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
mixedPort: null == mixedPort
|
||||
? _value.mixedPort
|
||||
: mixedPort // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
onlyProxy: null == onlyProxy
|
||||
? _value.onlyProxy
|
||||
: onlyProxy // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
) as $Val);
|
||||
}
|
||||
|
||||
@@ -312,24 +330,30 @@ class _$PropsCopyWithImpl<$Res, $Val extends Props>
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$PropsImplCopyWith<$Res> implements $PropsCopyWith<$Res> {
|
||||
factory _$$PropsImplCopyWith(
|
||||
_$PropsImpl value, $Res Function(_$PropsImpl) then) =
|
||||
__$$PropsImplCopyWithImpl<$Res>;
|
||||
abstract class _$$CoreStateImplCopyWith<$Res>
|
||||
implements $CoreStateCopyWith<$Res> {
|
||||
factory _$$CoreStateImplCopyWith(
|
||||
_$CoreStateImpl value, $Res Function(_$CoreStateImpl) then) =
|
||||
__$$CoreStateImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({AccessControl? accessControl, bool allowBypass, bool systemProxy});
|
||||
$Res call(
|
||||
{AccessControl? accessControl,
|
||||
bool allowBypass,
|
||||
bool systemProxy,
|
||||
int mixedPort,
|
||||
bool onlyProxy});
|
||||
|
||||
@override
|
||||
$AccessControlCopyWith<$Res>? get accessControl;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$PropsImplCopyWithImpl<$Res>
|
||||
extends _$PropsCopyWithImpl<$Res, _$PropsImpl>
|
||||
implements _$$PropsImplCopyWith<$Res> {
|
||||
__$$PropsImplCopyWithImpl(
|
||||
_$PropsImpl _value, $Res Function(_$PropsImpl) _then)
|
||||
class __$$CoreStateImplCopyWithImpl<$Res>
|
||||
extends _$CoreStateCopyWithImpl<$Res, _$CoreStateImpl>
|
||||
implements _$$CoreStateImplCopyWith<$Res> {
|
||||
__$$CoreStateImplCopyWithImpl(
|
||||
_$CoreStateImpl _value, $Res Function(_$CoreStateImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@@ -338,8 +362,10 @@ class __$$PropsImplCopyWithImpl<$Res>
|
||||
Object? accessControl = freezed,
|
||||
Object? allowBypass = null,
|
||||
Object? systemProxy = null,
|
||||
Object? mixedPort = null,
|
||||
Object? onlyProxy = null,
|
||||
}) {
|
||||
return _then(_$PropsImpl(
|
||||
return _then(_$CoreStateImpl(
|
||||
accessControl: freezed == accessControl
|
||||
? _value.accessControl
|
||||
: accessControl // ignore: cast_nullable_to_non_nullable
|
||||
@@ -352,20 +378,30 @@ class __$$PropsImplCopyWithImpl<$Res>
|
||||
? _value.systemProxy
|
||||
: systemProxy // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
mixedPort: null == mixedPort
|
||||
? _value.mixedPort
|
||||
: mixedPort // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
onlyProxy: null == onlyProxy
|
||||
? _value.onlyProxy
|
||||
: onlyProxy // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$PropsImpl implements _Props {
|
||||
const _$PropsImpl(
|
||||
class _$CoreStateImpl implements _CoreState {
|
||||
const _$CoreStateImpl(
|
||||
{this.accessControl,
|
||||
required this.allowBypass,
|
||||
required this.systemProxy});
|
||||
required this.systemProxy,
|
||||
required this.mixedPort,
|
||||
required this.onlyProxy});
|
||||
|
||||
factory _$PropsImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$PropsImplFromJson(json);
|
||||
factory _$CoreStateImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$CoreStateImplFromJson(json);
|
||||
|
||||
@override
|
||||
final AccessControl? accessControl;
|
||||
@@ -373,51 +409,62 @@ class _$PropsImpl implements _Props {
|
||||
final bool allowBypass;
|
||||
@override
|
||||
final bool systemProxy;
|
||||
@override
|
||||
final int mixedPort;
|
||||
@override
|
||||
final bool onlyProxy;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Props(accessControl: $accessControl, allowBypass: $allowBypass, systemProxy: $systemProxy)';
|
||||
return 'CoreState(accessControl: $accessControl, allowBypass: $allowBypass, systemProxy: $systemProxy, mixedPort: $mixedPort, onlyProxy: $onlyProxy)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$PropsImpl &&
|
||||
other is _$CoreStateImpl &&
|
||||
(identical(other.accessControl, accessControl) ||
|
||||
other.accessControl == accessControl) &&
|
||||
(identical(other.allowBypass, allowBypass) ||
|
||||
other.allowBypass == allowBypass) &&
|
||||
(identical(other.systemProxy, systemProxy) ||
|
||||
other.systemProxy == systemProxy));
|
||||
other.systemProxy == systemProxy) &&
|
||||
(identical(other.mixedPort, mixedPort) ||
|
||||
other.mixedPort == mixedPort) &&
|
||||
(identical(other.onlyProxy, onlyProxy) ||
|
||||
other.onlyProxy == onlyProxy));
|
||||
}
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
int get hashCode =>
|
||||
Object.hash(runtimeType, accessControl, allowBypass, systemProxy);
|
||||
int get hashCode => Object.hash(runtimeType, accessControl, allowBypass,
|
||||
systemProxy, mixedPort, onlyProxy);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$PropsImplCopyWith<_$PropsImpl> get copyWith =>
|
||||
__$$PropsImplCopyWithImpl<_$PropsImpl>(this, _$identity);
|
||||
_$$CoreStateImplCopyWith<_$CoreStateImpl> get copyWith =>
|
||||
__$$CoreStateImplCopyWithImpl<_$CoreStateImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$PropsImplToJson(
|
||||
return _$$CoreStateImplToJson(
|
||||
this,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _Props implements Props {
|
||||
const factory _Props(
|
||||
abstract class _CoreState implements CoreState {
|
||||
const factory _CoreState(
|
||||
{final AccessControl? accessControl,
|
||||
required final bool allowBypass,
|
||||
required final bool systemProxy}) = _$PropsImpl;
|
||||
required final bool systemProxy,
|
||||
required final int mixedPort,
|
||||
required final bool onlyProxy}) = _$CoreStateImpl;
|
||||
|
||||
factory _Props.fromJson(Map<String, dynamic> json) = _$PropsImpl.fromJson;
|
||||
factory _CoreState.fromJson(Map<String, dynamic> json) =
|
||||
_$CoreStateImpl.fromJson;
|
||||
|
||||
@override
|
||||
AccessControl? get accessControl;
|
||||
@@ -426,8 +473,12 @@ abstract class _Props implements Props {
|
||||
@override
|
||||
bool get systemProxy;
|
||||
@override
|
||||
int get mixedPort;
|
||||
@override
|
||||
bool get onlyProxy;
|
||||
@override
|
||||
@JsonKey(ignore: true)
|
||||
_$$PropsImplCopyWith<_$PropsImpl> get copyWith =>
|
||||
_$$CoreStateImplCopyWith<_$CoreStateImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,9 @@ Config _$ConfigFromJson(Map<String, dynamic> json) => Config()
|
||||
..isCompatible = json['isCompatible'] as bool? ?? true
|
||||
..autoCheckUpdate = json['autoCheckUpdate'] as bool? ?? true
|
||||
..allowBypass = json['allowBypass'] as bool? ?? true
|
||||
..systemProxy = json['systemProxy'] as bool? ?? true
|
||||
..systemProxy = json['systemProxy'] as bool? ?? false
|
||||
..onlyProxy = json['onlyProxy'] as bool? ?? false
|
||||
..isCloseConnections = json['isCloseConnections'] as bool? ?? false
|
||||
..proxiesType = $enumDecodeNullable(_$ProxiesTypeEnumMap, json['proxiesType'],
|
||||
unknownValue: ProxiesType.tab) ??
|
||||
ProxiesType.tab
|
||||
@@ -68,6 +70,8 @@ Map<String, dynamic> _$ConfigToJson(Config instance) => <String, dynamic>{
|
||||
'autoCheckUpdate': instance.autoCheckUpdate,
|
||||
'allowBypass': instance.allowBypass,
|
||||
'systemProxy': instance.systemProxy,
|
||||
'onlyProxy': instance.onlyProxy,
|
||||
'isCloseConnections': instance.isCloseConnections,
|
||||
'proxiesType': _$ProxiesTypeEnumMap[instance.proxiesType]!,
|
||||
'proxyCardType': _$ProxyCardTypeEnumMap[instance.proxyCardType]!,
|
||||
'proxiesColumns': instance.proxiesColumns,
|
||||
@@ -127,20 +131,25 @@ const _$AccessControlModeEnumMap = {
|
||||
AccessControlMode.rejectSelected: 'rejectSelected',
|
||||
};
|
||||
|
||||
_$PropsImpl _$$PropsImplFromJson(Map<String, dynamic> json) => _$PropsImpl(
|
||||
_$CoreStateImpl _$$CoreStateImplFromJson(Map<String, dynamic> json) =>
|
||||
_$CoreStateImpl(
|
||||
accessControl: json['accessControl'] == null
|
||||
? null
|
||||
: AccessControl.fromJson(
|
||||
json['accessControl'] as Map<String, dynamic>),
|
||||
allowBypass: json['allowBypass'] as bool,
|
||||
systemProxy: json['systemProxy'] as bool,
|
||||
mixedPort: (json['mixedPort'] as num).toInt(),
|
||||
onlyProxy: json['onlyProxy'] as bool,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$PropsImplToJson(_$PropsImpl instance) =>
|
||||
Map<String, dynamic> _$$CoreStateImplToJson(_$CoreStateImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'accessControl': instance.accessControl,
|
||||
'allowBypass': instance.allowBypass,
|
||||
'systemProxy': instance.systemProxy,
|
||||
'mixedPort': instance.mixedPort,
|
||||
'onlyProxy': instance.onlyProxy,
|
||||
};
|
||||
|
||||
_$WindowPropsImpl _$$WindowPropsImplFromJson(Map<String, dynamic> json) =>
|
||||
|
||||
150
lib/models/generated/file.freezed.dart
Normal file
@@ -0,0 +1,150 @@
|
||||
// coverage:ignore-file
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
part of '../file.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
final _privateConstructorUsedError = UnsupportedError(
|
||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
|
||||
|
||||
/// @nodoc
|
||||
mixin _$FileInfo {
|
||||
int get size => throw _privateConstructorUsedError;
|
||||
DateTime get lastModified => throw _privateConstructorUsedError;
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
$FileInfoCopyWith<FileInfo> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $FileInfoCopyWith<$Res> {
|
||||
factory $FileInfoCopyWith(FileInfo value, $Res Function(FileInfo) then) =
|
||||
_$FileInfoCopyWithImpl<$Res, FileInfo>;
|
||||
@useResult
|
||||
$Res call({int size, DateTime lastModified});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$FileInfoCopyWithImpl<$Res, $Val extends FileInfo>
|
||||
implements $FileInfoCopyWith<$Res> {
|
||||
_$FileInfoCopyWithImpl(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? size = null,
|
||||
Object? lastModified = null,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
size: null == size
|
||||
? _value.size
|
||||
: size // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
lastModified: null == lastModified
|
||||
? _value.lastModified
|
||||
: lastModified // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
) as $Val);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$FileInfoImplCopyWith<$Res>
|
||||
implements $FileInfoCopyWith<$Res> {
|
||||
factory _$$FileInfoImplCopyWith(
|
||||
_$FileInfoImpl value, $Res Function(_$FileInfoImpl) then) =
|
||||
__$$FileInfoImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({int size, DateTime lastModified});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$FileInfoImplCopyWithImpl<$Res>
|
||||
extends _$FileInfoCopyWithImpl<$Res, _$FileInfoImpl>
|
||||
implements _$$FileInfoImplCopyWith<$Res> {
|
||||
__$$FileInfoImplCopyWithImpl(
|
||||
_$FileInfoImpl _value, $Res Function(_$FileInfoImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? size = null,
|
||||
Object? lastModified = null,
|
||||
}) {
|
||||
return _then(_$FileInfoImpl(
|
||||
size: null == size
|
||||
? _value.size
|
||||
: size // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
lastModified: null == lastModified
|
||||
? _value.lastModified
|
||||
: lastModified // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$FileInfoImpl implements _FileInfo {
|
||||
const _$FileInfoImpl({required this.size, required this.lastModified});
|
||||
|
||||
@override
|
||||
final int size;
|
||||
@override
|
||||
final DateTime lastModified;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'FileInfo(size: $size, lastModified: $lastModified)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$FileInfoImpl &&
|
||||
(identical(other.size, size) || other.size == size) &&
|
||||
(identical(other.lastModified, lastModified) ||
|
||||
other.lastModified == lastModified));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, size, lastModified);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$FileInfoImplCopyWith<_$FileInfoImpl> get copyWith =>
|
||||
__$$FileInfoImplCopyWithImpl<_$FileInfoImpl>(this, _$identity);
|
||||
}
|
||||
|
||||
abstract class _FileInfo implements FileInfo {
|
||||
const factory _FileInfo(
|
||||
{required final int size,
|
||||
required final DateTime lastModified}) = _$FileInfoImpl;
|
||||
|
||||
@override
|
||||
int get size;
|
||||
@override
|
||||
DateTime get lastModified;
|
||||
@override
|
||||
@JsonKey(ignore: true)
|
||||
_$$FileInfoImplCopyWith<_$FileInfoImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
@@ -23,6 +23,7 @@ mixin _$Group {
|
||||
GroupType get type => throw _privateConstructorUsedError;
|
||||
List<Proxy> get all => throw _privateConstructorUsedError;
|
||||
String? get now => throw _privateConstructorUsedError;
|
||||
bool? get hidden => throw _privateConstructorUsedError;
|
||||
String get name => throw _privateConstructorUsedError;
|
||||
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
@@ -35,7 +36,12 @@ abstract class $GroupCopyWith<$Res> {
|
||||
factory $GroupCopyWith(Group value, $Res Function(Group) then) =
|
||||
_$GroupCopyWithImpl<$Res, Group>;
|
||||
@useResult
|
||||
$Res call({GroupType type, List<Proxy> all, String? now, String name});
|
||||
$Res call(
|
||||
{GroupType type,
|
||||
List<Proxy> all,
|
||||
String? now,
|
||||
bool? hidden,
|
||||
String name});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@@ -54,6 +60,7 @@ class _$GroupCopyWithImpl<$Res, $Val extends Group>
|
||||
Object? type = null,
|
||||
Object? all = null,
|
||||
Object? now = freezed,
|
||||
Object? hidden = freezed,
|
||||
Object? name = null,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
@@ -69,6 +76,10 @@ class _$GroupCopyWithImpl<$Res, $Val extends Group>
|
||||
? _value.now
|
||||
: now // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
hidden: freezed == hidden
|
||||
? _value.hidden
|
||||
: hidden // ignore: cast_nullable_to_non_nullable
|
||||
as bool?,
|
||||
name: null == name
|
||||
? _value.name
|
||||
: name // ignore: cast_nullable_to_non_nullable
|
||||
@@ -84,7 +95,12 @@ abstract class _$$GroupImplCopyWith<$Res> implements $GroupCopyWith<$Res> {
|
||||
__$$GroupImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({GroupType type, List<Proxy> all, String? now, String name});
|
||||
$Res call(
|
||||
{GroupType type,
|
||||
List<Proxy> all,
|
||||
String? now,
|
||||
bool? hidden,
|
||||
String name});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@@ -101,6 +117,7 @@ class __$$GroupImplCopyWithImpl<$Res>
|
||||
Object? type = null,
|
||||
Object? all = null,
|
||||
Object? now = freezed,
|
||||
Object? hidden = freezed,
|
||||
Object? name = null,
|
||||
}) {
|
||||
return _then(_$GroupImpl(
|
||||
@@ -116,6 +133,10 @@ class __$$GroupImplCopyWithImpl<$Res>
|
||||
? _value.now
|
||||
: now // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
hidden: freezed == hidden
|
||||
? _value.hidden
|
||||
: hidden // ignore: cast_nullable_to_non_nullable
|
||||
as bool?,
|
||||
name: null == name
|
||||
? _value.name
|
||||
: name // ignore: cast_nullable_to_non_nullable
|
||||
@@ -131,6 +152,7 @@ class _$GroupImpl implements _Group {
|
||||
{required this.type,
|
||||
final List<Proxy> all = const [],
|
||||
this.now,
|
||||
this.hidden,
|
||||
required this.name})
|
||||
: _all = all;
|
||||
|
||||
@@ -151,11 +173,13 @@ class _$GroupImpl implements _Group {
|
||||
@override
|
||||
final String? now;
|
||||
@override
|
||||
final bool? hidden;
|
||||
@override
|
||||
final String name;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Group(type: $type, all: $all, now: $now, name: $name)';
|
||||
return 'Group(type: $type, all: $all, now: $now, hidden: $hidden, name: $name)';
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -166,13 +190,14 @@ class _$GroupImpl implements _Group {
|
||||
(identical(other.type, type) || other.type == type) &&
|
||||
const DeepCollectionEquality().equals(other._all, _all) &&
|
||||
(identical(other.now, now) || other.now == now) &&
|
||||
(identical(other.hidden, hidden) || other.hidden == hidden) &&
|
||||
(identical(other.name, name) || other.name == name));
|
||||
}
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
int get hashCode => Object.hash(
|
||||
runtimeType, type, const DeepCollectionEquality().hash(_all), now, name);
|
||||
int get hashCode => Object.hash(runtimeType, type,
|
||||
const DeepCollectionEquality().hash(_all), now, hidden, name);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@@ -193,6 +218,7 @@ abstract class _Group implements Group {
|
||||
{required final GroupType type,
|
||||
final List<Proxy> all,
|
||||
final String? now,
|
||||
final bool? hidden,
|
||||
required final String name}) = _$GroupImpl;
|
||||
|
||||
factory _Group.fromJson(Map<String, dynamic> json) = _$GroupImpl.fromJson;
|
||||
@@ -204,6 +230,8 @@ abstract class _Group implements Group {
|
||||
@override
|
||||
String? get now;
|
||||
@override
|
||||
bool? get hidden;
|
||||
@override
|
||||
String get name;
|
||||
@override
|
||||
@JsonKey(ignore: true)
|
||||
|
||||
@@ -13,6 +13,7 @@ _$GroupImpl _$$GroupImplFromJson(Map<String, dynamic> json) => _$GroupImpl(
|
||||
.toList() ??
|
||||
const [],
|
||||
now: json['now'] as String?,
|
||||
hidden: json['hidden'] as bool?,
|
||||
name: json['name'] as String,
|
||||
);
|
||||
|
||||
@@ -21,6 +22,7 @@ Map<String, dynamic> _$$GroupImplToJson(_$GroupImpl instance) =>
|
||||
'type': _$GroupTypeEnumMap[instance.type]!,
|
||||
'all': instance.all,
|
||||
'now': instance.now,
|
||||
'hidden': instance.hidden,
|
||||
'name': instance.name,
|
||||
};
|
||||
|
||||
|
||||
@@ -158,10 +158,8 @@ abstract class _StartButtonSelectorState implements StartButtonSelectorState {
|
||||
|
||||
/// @nodoc
|
||||
mixin _$CheckIpSelectorState {
|
||||
bool get isInit => throw _privateConstructorUsedError;
|
||||
bool get isStart => throw _privateConstructorUsedError;
|
||||
String? get currentProfileId => throw _privateConstructorUsedError;
|
||||
Map<String, String> get selectedMap => throw _privateConstructorUsedError;
|
||||
num get checkIpNum => throw _privateConstructorUsedError;
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
$CheckIpSelectorStateCopyWith<CheckIpSelectorState> get copyWith =>
|
||||
@@ -174,11 +172,7 @@ abstract class $CheckIpSelectorStateCopyWith<$Res> {
|
||||
$Res Function(CheckIpSelectorState) then) =
|
||||
_$CheckIpSelectorStateCopyWithImpl<$Res, CheckIpSelectorState>;
|
||||
@useResult
|
||||
$Res call(
|
||||
{bool isInit,
|
||||
bool isStart,
|
||||
Map<String, String> selectedMap,
|
||||
num checkIpNum});
|
||||
$Res call({String? currentProfileId, Map<String, String> selectedMap});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@@ -195,28 +189,18 @@ class _$CheckIpSelectorStateCopyWithImpl<$Res,
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? isInit = null,
|
||||
Object? isStart = null,
|
||||
Object? currentProfileId = freezed,
|
||||
Object? selectedMap = null,
|
||||
Object? checkIpNum = null,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
isInit: null == isInit
|
||||
? _value.isInit
|
||||
: isInit // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
isStart: null == isStart
|
||||
? _value.isStart
|
||||
: isStart // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
currentProfileId: freezed == currentProfileId
|
||||
? _value.currentProfileId
|
||||
: currentProfileId // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
selectedMap: null == selectedMap
|
||||
? _value.selectedMap
|
||||
: selectedMap // ignore: cast_nullable_to_non_nullable
|
||||
as Map<String, String>,
|
||||
checkIpNum: null == checkIpNum
|
||||
? _value.checkIpNum
|
||||
: checkIpNum // ignore: cast_nullable_to_non_nullable
|
||||
as num,
|
||||
) as $Val);
|
||||
}
|
||||
}
|
||||
@@ -229,11 +213,7 @@ abstract class _$$CheckIpSelectorStateImplCopyWith<$Res>
|
||||
__$$CheckIpSelectorStateImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call(
|
||||
{bool isInit,
|
||||
bool isStart,
|
||||
Map<String, String> selectedMap,
|
||||
num checkIpNum});
|
||||
$Res call({String? currentProfileId, Map<String, String> selectedMap});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@@ -247,28 +227,18 @@ class __$$CheckIpSelectorStateImplCopyWithImpl<$Res>
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? isInit = null,
|
||||
Object? isStart = null,
|
||||
Object? currentProfileId = freezed,
|
||||
Object? selectedMap = null,
|
||||
Object? checkIpNum = null,
|
||||
}) {
|
||||
return _then(_$CheckIpSelectorStateImpl(
|
||||
isInit: null == isInit
|
||||
? _value.isInit
|
||||
: isInit // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
isStart: null == isStart
|
||||
? _value.isStart
|
||||
: isStart // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
currentProfileId: freezed == currentProfileId
|
||||
? _value.currentProfileId
|
||||
: currentProfileId // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
selectedMap: null == selectedMap
|
||||
? _value._selectedMap
|
||||
: selectedMap // ignore: cast_nullable_to_non_nullable
|
||||
as Map<String, String>,
|
||||
checkIpNum: null == checkIpNum
|
||||
? _value.checkIpNum
|
||||
: checkIpNum // ignore: cast_nullable_to_non_nullable
|
||||
as num,
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -277,16 +247,12 @@ class __$$CheckIpSelectorStateImplCopyWithImpl<$Res>
|
||||
|
||||
class _$CheckIpSelectorStateImpl implements _CheckIpSelectorState {
|
||||
const _$CheckIpSelectorStateImpl(
|
||||
{required this.isInit,
|
||||
required this.isStart,
|
||||
required final Map<String, String> selectedMap,
|
||||
required this.checkIpNum})
|
||||
{required this.currentProfileId,
|
||||
required final Map<String, String> selectedMap})
|
||||
: _selectedMap = selectedMap;
|
||||
|
||||
@override
|
||||
final bool isInit;
|
||||
@override
|
||||
final bool isStart;
|
||||
final String? currentProfileId;
|
||||
final Map<String, String> _selectedMap;
|
||||
@override
|
||||
Map<String, String> get selectedMap {
|
||||
@@ -295,12 +261,9 @@ class _$CheckIpSelectorStateImpl implements _CheckIpSelectorState {
|
||||
return EqualUnmodifiableMapView(_selectedMap);
|
||||
}
|
||||
|
||||
@override
|
||||
final num checkIpNum;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'CheckIpSelectorState(isInit: $isInit, isStart: $isStart, selectedMap: $selectedMap, checkIpNum: $checkIpNum)';
|
||||
return 'CheckIpSelectorState(currentProfileId: $currentProfileId, selectedMap: $selectedMap)';
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -308,17 +271,15 @@ class _$CheckIpSelectorStateImpl implements _CheckIpSelectorState {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$CheckIpSelectorStateImpl &&
|
||||
(identical(other.isInit, isInit) || other.isInit == isInit) &&
|
||||
(identical(other.isStart, isStart) || other.isStart == isStart) &&
|
||||
(identical(other.currentProfileId, currentProfileId) ||
|
||||
other.currentProfileId == currentProfileId) &&
|
||||
const DeepCollectionEquality()
|
||||
.equals(other._selectedMap, _selectedMap) &&
|
||||
(identical(other.checkIpNum, checkIpNum) ||
|
||||
other.checkIpNum == checkIpNum));
|
||||
.equals(other._selectedMap, _selectedMap));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, isInit, isStart,
|
||||
const DeepCollectionEquality().hash(_selectedMap), checkIpNum);
|
||||
int get hashCode => Object.hash(runtimeType, currentProfileId,
|
||||
const DeepCollectionEquality().hash(_selectedMap));
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@@ -331,20 +292,15 @@ class _$CheckIpSelectorStateImpl implements _CheckIpSelectorState {
|
||||
|
||||
abstract class _CheckIpSelectorState implements CheckIpSelectorState {
|
||||
const factory _CheckIpSelectorState(
|
||||
{required final bool isInit,
|
||||
required final bool isStart,
|
||||
required final Map<String, String> selectedMap,
|
||||
required final num checkIpNum}) = _$CheckIpSelectorStateImpl;
|
||||
{required final String? currentProfileId,
|
||||
required final Map<String, String> selectedMap}) =
|
||||
_$CheckIpSelectorStateImpl;
|
||||
|
||||
@override
|
||||
bool get isInit;
|
||||
@override
|
||||
bool get isStart;
|
||||
String? get currentProfileId;
|
||||
@override
|
||||
Map<String, String> get selectedMap;
|
||||
@override
|
||||
num get checkIpNum;
|
||||
@override
|
||||
@JsonKey(ignore: true)
|
||||
_$$CheckIpSelectorStateImplCopyWith<_$CheckIpSelectorStateImpl>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
@@ -1756,11 +1712,263 @@ abstract class _ProxiesSelectorState implements ProxiesSelectorState {
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$ProxiesListSelectorState {
|
||||
List<String> get groupNames => throw _privateConstructorUsedError;
|
||||
Set<String> get currentUnfoldSet => throw _privateConstructorUsedError;
|
||||
ProxiesSortType get proxiesSortType => throw _privateConstructorUsedError;
|
||||
ProxyCardType get proxyCardType => throw _privateConstructorUsedError;
|
||||
num get sortNum => throw _privateConstructorUsedError;
|
||||
int get columns => throw _privateConstructorUsedError;
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
$ProxiesListSelectorStateCopyWith<ProxiesListSelectorState> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $ProxiesListSelectorStateCopyWith<$Res> {
|
||||
factory $ProxiesListSelectorStateCopyWith(ProxiesListSelectorState value,
|
||||
$Res Function(ProxiesListSelectorState) then) =
|
||||
_$ProxiesListSelectorStateCopyWithImpl<$Res, ProxiesListSelectorState>;
|
||||
@useResult
|
||||
$Res call(
|
||||
{List<String> groupNames,
|
||||
Set<String> currentUnfoldSet,
|
||||
ProxiesSortType proxiesSortType,
|
||||
ProxyCardType proxyCardType,
|
||||
num sortNum,
|
||||
int columns});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$ProxiesListSelectorStateCopyWithImpl<$Res,
|
||||
$Val extends ProxiesListSelectorState>
|
||||
implements $ProxiesListSelectorStateCopyWith<$Res> {
|
||||
_$ProxiesListSelectorStateCopyWithImpl(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? groupNames = null,
|
||||
Object? currentUnfoldSet = null,
|
||||
Object? proxiesSortType = null,
|
||||
Object? proxyCardType = null,
|
||||
Object? sortNum = null,
|
||||
Object? columns = null,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
groupNames: null == groupNames
|
||||
? _value.groupNames
|
||||
: groupNames // ignore: cast_nullable_to_non_nullable
|
||||
as List<String>,
|
||||
currentUnfoldSet: null == currentUnfoldSet
|
||||
? _value.currentUnfoldSet
|
||||
: currentUnfoldSet // ignore: cast_nullable_to_non_nullable
|
||||
as Set<String>,
|
||||
proxiesSortType: null == proxiesSortType
|
||||
? _value.proxiesSortType
|
||||
: proxiesSortType // ignore: cast_nullable_to_non_nullable
|
||||
as ProxiesSortType,
|
||||
proxyCardType: null == proxyCardType
|
||||
? _value.proxyCardType
|
||||
: proxyCardType // ignore: cast_nullable_to_non_nullable
|
||||
as ProxyCardType,
|
||||
sortNum: null == sortNum
|
||||
? _value.sortNum
|
||||
: sortNum // ignore: cast_nullable_to_non_nullable
|
||||
as num,
|
||||
columns: null == columns
|
||||
? _value.columns
|
||||
: columns // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
) as $Val);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$ProxiesListSelectorStateImplCopyWith<$Res>
|
||||
implements $ProxiesListSelectorStateCopyWith<$Res> {
|
||||
factory _$$ProxiesListSelectorStateImplCopyWith(
|
||||
_$ProxiesListSelectorStateImpl value,
|
||||
$Res Function(_$ProxiesListSelectorStateImpl) then) =
|
||||
__$$ProxiesListSelectorStateImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call(
|
||||
{List<String> groupNames,
|
||||
Set<String> currentUnfoldSet,
|
||||
ProxiesSortType proxiesSortType,
|
||||
ProxyCardType proxyCardType,
|
||||
num sortNum,
|
||||
int columns});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$ProxiesListSelectorStateImplCopyWithImpl<$Res>
|
||||
extends _$ProxiesListSelectorStateCopyWithImpl<$Res,
|
||||
_$ProxiesListSelectorStateImpl>
|
||||
implements _$$ProxiesListSelectorStateImplCopyWith<$Res> {
|
||||
__$$ProxiesListSelectorStateImplCopyWithImpl(
|
||||
_$ProxiesListSelectorStateImpl _value,
|
||||
$Res Function(_$ProxiesListSelectorStateImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? groupNames = null,
|
||||
Object? currentUnfoldSet = null,
|
||||
Object? proxiesSortType = null,
|
||||
Object? proxyCardType = null,
|
||||
Object? sortNum = null,
|
||||
Object? columns = null,
|
||||
}) {
|
||||
return _then(_$ProxiesListSelectorStateImpl(
|
||||
groupNames: null == groupNames
|
||||
? _value._groupNames
|
||||
: groupNames // ignore: cast_nullable_to_non_nullable
|
||||
as List<String>,
|
||||
currentUnfoldSet: null == currentUnfoldSet
|
||||
? _value._currentUnfoldSet
|
||||
: currentUnfoldSet // ignore: cast_nullable_to_non_nullable
|
||||
as Set<String>,
|
||||
proxiesSortType: null == proxiesSortType
|
||||
? _value.proxiesSortType
|
||||
: proxiesSortType // ignore: cast_nullable_to_non_nullable
|
||||
as ProxiesSortType,
|
||||
proxyCardType: null == proxyCardType
|
||||
? _value.proxyCardType
|
||||
: proxyCardType // ignore: cast_nullable_to_non_nullable
|
||||
as ProxyCardType,
|
||||
sortNum: null == sortNum
|
||||
? _value.sortNum
|
||||
: sortNum // ignore: cast_nullable_to_non_nullable
|
||||
as num,
|
||||
columns: null == columns
|
||||
? _value.columns
|
||||
: columns // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$ProxiesListSelectorStateImpl implements _ProxiesListSelectorState {
|
||||
const _$ProxiesListSelectorStateImpl(
|
||||
{required final List<String> groupNames,
|
||||
required final Set<String> currentUnfoldSet,
|
||||
required this.proxiesSortType,
|
||||
required this.proxyCardType,
|
||||
required this.sortNum,
|
||||
required this.columns})
|
||||
: _groupNames = groupNames,
|
||||
_currentUnfoldSet = currentUnfoldSet;
|
||||
|
||||
final List<String> _groupNames;
|
||||
@override
|
||||
List<String> get groupNames {
|
||||
if (_groupNames is EqualUnmodifiableListView) return _groupNames;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_groupNames);
|
||||
}
|
||||
|
||||
final Set<String> _currentUnfoldSet;
|
||||
@override
|
||||
Set<String> get currentUnfoldSet {
|
||||
if (_currentUnfoldSet is EqualUnmodifiableSetView) return _currentUnfoldSet;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableSetView(_currentUnfoldSet);
|
||||
}
|
||||
|
||||
@override
|
||||
final ProxiesSortType proxiesSortType;
|
||||
@override
|
||||
final ProxyCardType proxyCardType;
|
||||
@override
|
||||
final num sortNum;
|
||||
@override
|
||||
final int columns;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ProxiesListSelectorState(groupNames: $groupNames, currentUnfoldSet: $currentUnfoldSet, proxiesSortType: $proxiesSortType, proxyCardType: $proxyCardType, sortNum: $sortNum, columns: $columns)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$ProxiesListSelectorStateImpl &&
|
||||
const DeepCollectionEquality()
|
||||
.equals(other._groupNames, _groupNames) &&
|
||||
const DeepCollectionEquality()
|
||||
.equals(other._currentUnfoldSet, _currentUnfoldSet) &&
|
||||
(identical(other.proxiesSortType, proxiesSortType) ||
|
||||
other.proxiesSortType == proxiesSortType) &&
|
||||
(identical(other.proxyCardType, proxyCardType) ||
|
||||
other.proxyCardType == proxyCardType) &&
|
||||
(identical(other.sortNum, sortNum) || other.sortNum == sortNum) &&
|
||||
(identical(other.columns, columns) || other.columns == columns));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(
|
||||
runtimeType,
|
||||
const DeepCollectionEquality().hash(_groupNames),
|
||||
const DeepCollectionEquality().hash(_currentUnfoldSet),
|
||||
proxiesSortType,
|
||||
proxyCardType,
|
||||
sortNum,
|
||||
columns);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$ProxiesListSelectorStateImplCopyWith<_$ProxiesListSelectorStateImpl>
|
||||
get copyWith => __$$ProxiesListSelectorStateImplCopyWithImpl<
|
||||
_$ProxiesListSelectorStateImpl>(this, _$identity);
|
||||
}
|
||||
|
||||
abstract class _ProxiesListSelectorState implements ProxiesListSelectorState {
|
||||
const factory _ProxiesListSelectorState(
|
||||
{required final List<String> groupNames,
|
||||
required final Set<String> currentUnfoldSet,
|
||||
required final ProxiesSortType proxiesSortType,
|
||||
required final ProxyCardType proxyCardType,
|
||||
required final num sortNum,
|
||||
required final int columns}) = _$ProxiesListSelectorStateImpl;
|
||||
|
||||
@override
|
||||
List<String> get groupNames;
|
||||
@override
|
||||
Set<String> get currentUnfoldSet;
|
||||
@override
|
||||
ProxiesSortType get proxiesSortType;
|
||||
@override
|
||||
ProxyCardType get proxyCardType;
|
||||
@override
|
||||
num get sortNum;
|
||||
@override
|
||||
int get columns;
|
||||
@override
|
||||
@JsonKey(ignore: true)
|
||||
_$$ProxiesListSelectorStateImplCopyWith<_$ProxiesListSelectorStateImpl>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$ProxyGroupSelectorState {
|
||||
ProxiesSortType get proxiesSortType => throw _privateConstructorUsedError;
|
||||
ProxyCardType get proxyCardType => throw _privateConstructorUsedError;
|
||||
num get sortNum => throw _privateConstructorUsedError;
|
||||
GroupType get groupType => throw _privateConstructorUsedError;
|
||||
List<Proxy> get proxies => throw _privateConstructorUsedError;
|
||||
int get columns => throw _privateConstructorUsedError;
|
||||
|
||||
@@ -1779,6 +1987,7 @@ abstract class $ProxyGroupSelectorStateCopyWith<$Res> {
|
||||
{ProxiesSortType proxiesSortType,
|
||||
ProxyCardType proxyCardType,
|
||||
num sortNum,
|
||||
GroupType groupType,
|
||||
List<Proxy> proxies,
|
||||
int columns});
|
||||
}
|
||||
@@ -1800,6 +2009,7 @@ class _$ProxyGroupSelectorStateCopyWithImpl<$Res,
|
||||
Object? proxiesSortType = null,
|
||||
Object? proxyCardType = null,
|
||||
Object? sortNum = null,
|
||||
Object? groupType = null,
|
||||
Object? proxies = null,
|
||||
Object? columns = null,
|
||||
}) {
|
||||
@@ -1816,6 +2026,10 @@ class _$ProxyGroupSelectorStateCopyWithImpl<$Res,
|
||||
? _value.sortNum
|
||||
: sortNum // ignore: cast_nullable_to_non_nullable
|
||||
as num,
|
||||
groupType: null == groupType
|
||||
? _value.groupType
|
||||
: groupType // ignore: cast_nullable_to_non_nullable
|
||||
as GroupType,
|
||||
proxies: null == proxies
|
||||
? _value.proxies
|
||||
: proxies // ignore: cast_nullable_to_non_nullable
|
||||
@@ -1841,6 +2055,7 @@ abstract class _$$ProxyGroupSelectorStateImplCopyWith<$Res>
|
||||
{ProxiesSortType proxiesSortType,
|
||||
ProxyCardType proxyCardType,
|
||||
num sortNum,
|
||||
GroupType groupType,
|
||||
List<Proxy> proxies,
|
||||
int columns});
|
||||
}
|
||||
@@ -1861,6 +2076,7 @@ class __$$ProxyGroupSelectorStateImplCopyWithImpl<$Res>
|
||||
Object? proxiesSortType = null,
|
||||
Object? proxyCardType = null,
|
||||
Object? sortNum = null,
|
||||
Object? groupType = null,
|
||||
Object? proxies = null,
|
||||
Object? columns = null,
|
||||
}) {
|
||||
@@ -1877,6 +2093,10 @@ class __$$ProxyGroupSelectorStateImplCopyWithImpl<$Res>
|
||||
? _value.sortNum
|
||||
: sortNum // ignore: cast_nullable_to_non_nullable
|
||||
as num,
|
||||
groupType: null == groupType
|
||||
? _value.groupType
|
||||
: groupType // ignore: cast_nullable_to_non_nullable
|
||||
as GroupType,
|
||||
proxies: null == proxies
|
||||
? _value._proxies
|
||||
: proxies // ignore: cast_nullable_to_non_nullable
|
||||
@@ -1896,6 +2116,7 @@ class _$ProxyGroupSelectorStateImpl implements _ProxyGroupSelectorState {
|
||||
{required this.proxiesSortType,
|
||||
required this.proxyCardType,
|
||||
required this.sortNum,
|
||||
required this.groupType,
|
||||
required final List<Proxy> proxies,
|
||||
required this.columns})
|
||||
: _proxies = proxies;
|
||||
@@ -1906,6 +2127,8 @@ class _$ProxyGroupSelectorStateImpl implements _ProxyGroupSelectorState {
|
||||
final ProxyCardType proxyCardType;
|
||||
@override
|
||||
final num sortNum;
|
||||
@override
|
||||
final GroupType groupType;
|
||||
final List<Proxy> _proxies;
|
||||
@override
|
||||
List<Proxy> get proxies {
|
||||
@@ -1919,7 +2142,7 @@ class _$ProxyGroupSelectorStateImpl implements _ProxyGroupSelectorState {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ProxyGroupSelectorState(proxiesSortType: $proxiesSortType, proxyCardType: $proxyCardType, sortNum: $sortNum, proxies: $proxies, columns: $columns)';
|
||||
return 'ProxyGroupSelectorState(proxiesSortType: $proxiesSortType, proxyCardType: $proxyCardType, sortNum: $sortNum, groupType: $groupType, proxies: $proxies, columns: $columns)';
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -1932,13 +2155,21 @@ class _$ProxyGroupSelectorStateImpl implements _ProxyGroupSelectorState {
|
||||
(identical(other.proxyCardType, proxyCardType) ||
|
||||
other.proxyCardType == proxyCardType) &&
|
||||
(identical(other.sortNum, sortNum) || other.sortNum == sortNum) &&
|
||||
(identical(other.groupType, groupType) ||
|
||||
other.groupType == groupType) &&
|
||||
const DeepCollectionEquality().equals(other._proxies, _proxies) &&
|
||||
(identical(other.columns, columns) || other.columns == columns));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, proxiesSortType, proxyCardType,
|
||||
sortNum, const DeepCollectionEquality().hash(_proxies), columns);
|
||||
int get hashCode => Object.hash(
|
||||
runtimeType,
|
||||
proxiesSortType,
|
||||
proxyCardType,
|
||||
sortNum,
|
||||
groupType,
|
||||
const DeepCollectionEquality().hash(_proxies),
|
||||
columns);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@@ -1953,6 +2184,7 @@ abstract class _ProxyGroupSelectorState implements ProxyGroupSelectorState {
|
||||
{required final ProxiesSortType proxiesSortType,
|
||||
required final ProxyCardType proxyCardType,
|
||||
required final num sortNum,
|
||||
required final GroupType groupType,
|
||||
required final List<Proxy> proxies,
|
||||
required final int columns}) = _$ProxyGroupSelectorStateImpl;
|
||||
|
||||
@@ -1963,6 +2195,8 @@ abstract class _ProxyGroupSelectorState implements ProxyGroupSelectorState {
|
||||
@override
|
||||
num get sortNum;
|
||||
@override
|
||||
GroupType get groupType;
|
||||
@override
|
||||
List<Proxy> get proxies;
|
||||
@override
|
||||
int get columns;
|
||||
@@ -2401,3 +2635,302 @@ abstract class _ColumnsSelectorState implements ColumnsSelectorState {
|
||||
_$$ColumnsSelectorStateImplCopyWith<_$ColumnsSelectorStateImpl>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$ProxiesListHeaderSelectorState {
|
||||
double get offset => throw _privateConstructorUsedError;
|
||||
int get currentIndex => throw _privateConstructorUsedError;
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
$ProxiesListHeaderSelectorStateCopyWith<ProxiesListHeaderSelectorState>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $ProxiesListHeaderSelectorStateCopyWith<$Res> {
|
||||
factory $ProxiesListHeaderSelectorStateCopyWith(
|
||||
ProxiesListHeaderSelectorState value,
|
||||
$Res Function(ProxiesListHeaderSelectorState) then) =
|
||||
_$ProxiesListHeaderSelectorStateCopyWithImpl<$Res,
|
||||
ProxiesListHeaderSelectorState>;
|
||||
@useResult
|
||||
$Res call({double offset, int currentIndex});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$ProxiesListHeaderSelectorStateCopyWithImpl<$Res,
|
||||
$Val extends ProxiesListHeaderSelectorState>
|
||||
implements $ProxiesListHeaderSelectorStateCopyWith<$Res> {
|
||||
_$ProxiesListHeaderSelectorStateCopyWithImpl(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? offset = null,
|
||||
Object? currentIndex = null,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
offset: null == offset
|
||||
? _value.offset
|
||||
: offset // ignore: cast_nullable_to_non_nullable
|
||||
as double,
|
||||
currentIndex: null == currentIndex
|
||||
? _value.currentIndex
|
||||
: currentIndex // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
) as $Val);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$ProxiesListHeaderSelectorStateImplCopyWith<$Res>
|
||||
implements $ProxiesListHeaderSelectorStateCopyWith<$Res> {
|
||||
factory _$$ProxiesListHeaderSelectorStateImplCopyWith(
|
||||
_$ProxiesListHeaderSelectorStateImpl value,
|
||||
$Res Function(_$ProxiesListHeaderSelectorStateImpl) then) =
|
||||
__$$ProxiesListHeaderSelectorStateImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({double offset, int currentIndex});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$ProxiesListHeaderSelectorStateImplCopyWithImpl<$Res>
|
||||
extends _$ProxiesListHeaderSelectorStateCopyWithImpl<$Res,
|
||||
_$ProxiesListHeaderSelectorStateImpl>
|
||||
implements _$$ProxiesListHeaderSelectorStateImplCopyWith<$Res> {
|
||||
__$$ProxiesListHeaderSelectorStateImplCopyWithImpl(
|
||||
_$ProxiesListHeaderSelectorStateImpl _value,
|
||||
$Res Function(_$ProxiesListHeaderSelectorStateImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? offset = null,
|
||||
Object? currentIndex = null,
|
||||
}) {
|
||||
return _then(_$ProxiesListHeaderSelectorStateImpl(
|
||||
offset: null == offset
|
||||
? _value.offset
|
||||
: offset // ignore: cast_nullable_to_non_nullable
|
||||
as double,
|
||||
currentIndex: null == currentIndex
|
||||
? _value.currentIndex
|
||||
: currentIndex // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$ProxiesListHeaderSelectorStateImpl
|
||||
implements _ProxiesListHeaderSelectorState {
|
||||
const _$ProxiesListHeaderSelectorStateImpl(
|
||||
{required this.offset, required this.currentIndex});
|
||||
|
||||
@override
|
||||
final double offset;
|
||||
@override
|
||||
final int currentIndex;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ProxiesListHeaderSelectorState(offset: $offset, currentIndex: $currentIndex)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$ProxiesListHeaderSelectorStateImpl &&
|
||||
(identical(other.offset, offset) || other.offset == offset) &&
|
||||
(identical(other.currentIndex, currentIndex) ||
|
||||
other.currentIndex == currentIndex));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, offset, currentIndex);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$ProxiesListHeaderSelectorStateImplCopyWith<
|
||||
_$ProxiesListHeaderSelectorStateImpl>
|
||||
get copyWith => __$$ProxiesListHeaderSelectorStateImplCopyWithImpl<
|
||||
_$ProxiesListHeaderSelectorStateImpl>(this, _$identity);
|
||||
}
|
||||
|
||||
abstract class _ProxiesListHeaderSelectorState
|
||||
implements ProxiesListHeaderSelectorState {
|
||||
const factory _ProxiesListHeaderSelectorState(
|
||||
{required final double offset,
|
||||
required final int currentIndex}) = _$ProxiesListHeaderSelectorStateImpl;
|
||||
|
||||
@override
|
||||
double get offset;
|
||||
@override
|
||||
int get currentIndex;
|
||||
@override
|
||||
@JsonKey(ignore: true)
|
||||
_$$ProxiesListHeaderSelectorStateImplCopyWith<
|
||||
_$ProxiesListHeaderSelectorStateImpl>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$CurrentGroupProxyNameSelectorState {
|
||||
String? get proxyName => throw _privateConstructorUsedError;
|
||||
String? get proxyName2 => throw _privateConstructorUsedError;
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
$CurrentGroupProxyNameSelectorStateCopyWith<
|
||||
CurrentGroupProxyNameSelectorState>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $CurrentGroupProxyNameSelectorStateCopyWith<$Res> {
|
||||
factory $CurrentGroupProxyNameSelectorStateCopyWith(
|
||||
CurrentGroupProxyNameSelectorState value,
|
||||
$Res Function(CurrentGroupProxyNameSelectorState) then) =
|
||||
_$CurrentGroupProxyNameSelectorStateCopyWithImpl<$Res,
|
||||
CurrentGroupProxyNameSelectorState>;
|
||||
@useResult
|
||||
$Res call({String? proxyName, String? proxyName2});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$CurrentGroupProxyNameSelectorStateCopyWithImpl<$Res,
|
||||
$Val extends CurrentGroupProxyNameSelectorState>
|
||||
implements $CurrentGroupProxyNameSelectorStateCopyWith<$Res> {
|
||||
_$CurrentGroupProxyNameSelectorStateCopyWithImpl(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? proxyName = freezed,
|
||||
Object? proxyName2 = freezed,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
proxyName: freezed == proxyName
|
||||
? _value.proxyName
|
||||
: proxyName // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
proxyName2: freezed == proxyName2
|
||||
? _value.proxyName2
|
||||
: proxyName2 // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
) as $Val);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$CurrentGroupProxyNameSelectorStateImplCopyWith<$Res>
|
||||
implements $CurrentGroupProxyNameSelectorStateCopyWith<$Res> {
|
||||
factory _$$CurrentGroupProxyNameSelectorStateImplCopyWith(
|
||||
_$CurrentGroupProxyNameSelectorStateImpl value,
|
||||
$Res Function(_$CurrentGroupProxyNameSelectorStateImpl) then) =
|
||||
__$$CurrentGroupProxyNameSelectorStateImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({String? proxyName, String? proxyName2});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$CurrentGroupProxyNameSelectorStateImplCopyWithImpl<$Res>
|
||||
extends _$CurrentGroupProxyNameSelectorStateCopyWithImpl<$Res,
|
||||
_$CurrentGroupProxyNameSelectorStateImpl>
|
||||
implements _$$CurrentGroupProxyNameSelectorStateImplCopyWith<$Res> {
|
||||
__$$CurrentGroupProxyNameSelectorStateImplCopyWithImpl(
|
||||
_$CurrentGroupProxyNameSelectorStateImpl _value,
|
||||
$Res Function(_$CurrentGroupProxyNameSelectorStateImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? proxyName = freezed,
|
||||
Object? proxyName2 = freezed,
|
||||
}) {
|
||||
return _then(_$CurrentGroupProxyNameSelectorStateImpl(
|
||||
proxyName: freezed == proxyName
|
||||
? _value.proxyName
|
||||
: proxyName // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
proxyName2: freezed == proxyName2
|
||||
? _value.proxyName2
|
||||
: proxyName2 // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$CurrentGroupProxyNameSelectorStateImpl
|
||||
implements _CurrentGroupProxyNameSelectorState {
|
||||
const _$CurrentGroupProxyNameSelectorStateImpl(
|
||||
{required this.proxyName, required this.proxyName2});
|
||||
|
||||
@override
|
||||
final String? proxyName;
|
||||
@override
|
||||
final String? proxyName2;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'CurrentGroupProxyNameSelectorState(proxyName: $proxyName, proxyName2: $proxyName2)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$CurrentGroupProxyNameSelectorStateImpl &&
|
||||
(identical(other.proxyName, proxyName) ||
|
||||
other.proxyName == proxyName) &&
|
||||
(identical(other.proxyName2, proxyName2) ||
|
||||
other.proxyName2 == proxyName2));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, proxyName, proxyName2);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$CurrentGroupProxyNameSelectorStateImplCopyWith<
|
||||
_$CurrentGroupProxyNameSelectorStateImpl>
|
||||
get copyWith => __$$CurrentGroupProxyNameSelectorStateImplCopyWithImpl<
|
||||
_$CurrentGroupProxyNameSelectorStateImpl>(this, _$identity);
|
||||
}
|
||||
|
||||
abstract class _CurrentGroupProxyNameSelectorState
|
||||
implements CurrentGroupProxyNameSelectorState {
|
||||
const factory _CurrentGroupProxyNameSelectorState(
|
||||
{required final String? proxyName,
|
||||
required final String? proxyName2}) =
|
||||
_$CurrentGroupProxyNameSelectorStateImpl;
|
||||
|
||||
@override
|
||||
String? get proxyName;
|
||||
@override
|
||||
String? get proxyName2;
|
||||
@override
|
||||
@JsonKey(ignore: true)
|
||||
_$$CurrentGroupProxyNameSelectorStateImplCopyWith<
|
||||
_$CurrentGroupProxyNameSelectorStateImpl>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
@@ -13,4 +13,5 @@ export 'ffi.dart';
|
||||
export 'selector.dart';
|
||||
export 'navigation.dart';
|
||||
export 'dav.dart';
|
||||
export 'ip.dart';
|
||||
export 'ip.dart';
|
||||
export 'file.dart';
|
||||
@@ -14,12 +14,24 @@ class Group with _$Group {
|
||||
required GroupType type,
|
||||
@Default([]) List<Proxy> all,
|
||||
String? now,
|
||||
bool? hidden,
|
||||
required String name,
|
||||
}) = _Group;
|
||||
|
||||
factory Group.fromJson(Map<String, Object?> json) => _$GroupFromJson(json);
|
||||
}
|
||||
|
||||
extension GroupExt on Group {
|
||||
String get realNow => now ?? "";
|
||||
|
||||
String getCurrentSelectedName(String proxyName) {
|
||||
if (type == GroupType.URLTest) {
|
||||
return realNow.isNotEmpty ? realNow : proxyName;
|
||||
}
|
||||
return proxyName.isNotEmpty ? proxyName : realNow;
|
||||
}
|
||||
}
|
||||
|
||||
@freezed
|
||||
class Proxy with _$Proxy {
|
||||
const factory Proxy({
|
||||
|
||||
@@ -16,10 +16,8 @@ class StartButtonSelectorState with _$StartButtonSelectorState {
|
||||
@freezed
|
||||
class CheckIpSelectorState with _$CheckIpSelectorState {
|
||||
const factory CheckIpSelectorState({
|
||||
required bool isInit,
|
||||
required bool isStart,
|
||||
required String? currentProfileId,
|
||||
required SelectedMap selectedMap,
|
||||
required num checkIpNum
|
||||
}) = _CheckIpSelectorState;
|
||||
}
|
||||
|
||||
@@ -99,12 +97,25 @@ class ProxiesSelectorState with _$ProxiesSelectorState {
|
||||
}) = _ProxiesSelectorState;
|
||||
}
|
||||
|
||||
@freezed
|
||||
class ProxiesListSelectorState with _$ProxiesListSelectorState {
|
||||
const factory ProxiesListSelectorState({
|
||||
required List<String> groupNames,
|
||||
required Set<String> currentUnfoldSet,
|
||||
required ProxiesSortType proxiesSortType,
|
||||
required ProxyCardType proxyCardType,
|
||||
required num sortNum,
|
||||
required int columns,
|
||||
}) = _ProxiesListSelectorState;
|
||||
}
|
||||
|
||||
@freezed
|
||||
class ProxyGroupSelectorState with _$ProxyGroupSelectorState {
|
||||
const factory ProxyGroupSelectorState({
|
||||
required ProxiesSortType proxiesSortType,
|
||||
required ProxyCardType proxyCardType,
|
||||
required num sortNum,
|
||||
required GroupType groupType,
|
||||
required List<Proxy> proxies,
|
||||
required int columns,
|
||||
}) = _ProxyGroupSelectorState;
|
||||
@@ -133,3 +144,19 @@ class ColumnsSelectorState with _$ColumnsSelectorState {
|
||||
required ViewMode viewMode,
|
||||
}) = _ColumnsSelectorState;
|
||||
}
|
||||
|
||||
@freezed
|
||||
class ProxiesListHeaderSelectorState with _$ProxiesListHeaderSelectorState {
|
||||
const factory ProxiesListHeaderSelectorState({
|
||||
required double offset,
|
||||
required int currentIndex,
|
||||
}) = _ProxiesListHeaderSelectorState;
|
||||
}
|
||||
|
||||
@freezed
|
||||
class CurrentGroupProxyNameSelectorState with _$CurrentGroupProxyNameSelectorState {
|
||||
const factory CurrentGroupProxyNameSelectorState({
|
||||
required String? proxyName,
|
||||
required String? proxyName2,
|
||||
}) = _CurrentGroupProxyNameSelectorState;
|
||||
}
|
||||
@@ -13,6 +13,20 @@ typedef OnSelected = void Function(int index);
|
||||
class HomePage extends StatelessWidget {
|
||||
const HomePage({super.key});
|
||||
|
||||
_navigationBarContainer({
|
||||
required BuildContext context,
|
||||
required Widget child,
|
||||
}) {
|
||||
// if (!system.isDesktop) return child;
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16).copyWith(
|
||||
right: 0,
|
||||
),
|
||||
color: context.colorScheme.surface,
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
|
||||
_getNavigationBar({
|
||||
required BuildContext context,
|
||||
required ViewMode viewMode,
|
||||
@@ -34,110 +48,117 @@ class HomePage extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
final extended = viewMode == ViewMode.desktop;
|
||||
// return NavigationRail(
|
||||
// backgroundColor: context.colorScheme.surfaceContainer,
|
||||
// groupAlignment: -0.8,
|
||||
// destinations: navigationItems
|
||||
// .map(
|
||||
// (e) => NavigationRailDestination(
|
||||
// icon: e.icon,
|
||||
// label: Text(
|
||||
// Intl.message(e.label),
|
||||
// ),
|
||||
// ),
|
||||
// )
|
||||
// .toList(),
|
||||
// onDestinationSelected: globalState.appController.toPage,
|
||||
// extended: extended,
|
||||
// minExtendedWidth: 172,
|
||||
// selectedIndex: currentIndex,
|
||||
// labelType: extended
|
||||
// ? NavigationRailLabelType.none
|
||||
// : NavigationRailLabelType.selected,
|
||||
// );
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16).copyWith(
|
||||
right: 0,
|
||||
),
|
||||
color: context.colorScheme.surface,
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
child: NavigationRail(
|
||||
backgroundColor: context.colorScheme.surfaceContainer,
|
||||
groupAlignment: -0.8,
|
||||
destinations: navigationItems
|
||||
.map(
|
||||
(e) => NavigationRailDestination(
|
||||
icon: e.icon,
|
||||
label: Text(
|
||||
Intl.message(e.label),
|
||||
),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
onDestinationSelected: globalState.appController.toPage,
|
||||
extended: extended,
|
||||
minExtendedWidth: 172,
|
||||
selectedIndex: currentIndex,
|
||||
labelType: extended
|
||||
? NavigationRailLabelType.none
|
||||
: NavigationRailLabelType.selected,
|
||||
return _navigationBarContainer(
|
||||
context: context,
|
||||
child: NavigationRail(
|
||||
groupAlignment: -0.8,
|
||||
selectedIconTheme: IconThemeData(
|
||||
color: context.colorScheme.onSurfaceVariant,
|
||||
),
|
||||
unselectedIconTheme: IconThemeData(
|
||||
color: context.colorScheme.onSurfaceVariant,
|
||||
),
|
||||
selectedLabelTextStyle: context.textTheme.labelLarge!.copyWith(
|
||||
color: context.colorScheme.onSurface,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
unselectedLabelTextStyle: context.textTheme.labelLarge!.copyWith(
|
||||
color: context.colorScheme.onSurface,
|
||||
),
|
||||
destinations: navigationItems
|
||||
.map(
|
||||
(e) => NavigationRailDestination(
|
||||
icon: e.icon,
|
||||
label: Text(
|
||||
Intl.message(e.label),
|
||||
),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
onDestinationSelected: globalState.appController.toPage,
|
||||
extended: extended,
|
||||
minExtendedWidth: 200,
|
||||
selectedIndex: currentIndex,
|
||||
labelType: extended
|
||||
? NavigationRailLabelType.none
|
||||
: NavigationRailLabelType.selected,
|
||||
),
|
||||
);
|
||||
return NavigationRail(
|
||||
groupAlignment: -0.95,
|
||||
destinations: navigationItems
|
||||
.map(
|
||||
(e) => NavigationRailDestination(
|
||||
icon: e.icon,
|
||||
label: Text(
|
||||
Intl.message(e.label),
|
||||
),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
onDestinationSelected: globalState.appController.toPage,
|
||||
extended: extended,
|
||||
minExtendedWidth: 172,
|
||||
selectedIndex: currentIndex,
|
||||
labelType: extended
|
||||
? NavigationRailLabelType.none
|
||||
: NavigationRailLabelType.selected,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return LayoutBuilder(
|
||||
builder: (_, container) {
|
||||
final appController = globalState.appController;
|
||||
final maxWidth = container.maxWidth;
|
||||
if (appController.appState.viewWidth != maxWidth) {
|
||||
globalState.appController.updateViewWidth(maxWidth);
|
||||
}
|
||||
return Selector2<AppState, Config, HomeSelectorState>(
|
||||
selector: (_, appState, config) {
|
||||
return HomeSelectorState(
|
||||
currentLabel: appState.currentLabel,
|
||||
navigationItems: appState.currentNavigationItems,
|
||||
viewMode: other.getViewMode(maxWidth),
|
||||
locale: config.locale,
|
||||
);
|
||||
},
|
||||
builder: (_, state, child) {
|
||||
final viewMode = state.viewMode;
|
||||
final navigationItems = state.navigationItems;
|
||||
final currentLabel = state.currentLabel;
|
||||
final index = navigationItems.lastIndexWhere(
|
||||
(element) => element.label == currentLabel,
|
||||
);
|
||||
final currentIndex = index == -1 ? 0 : index;
|
||||
final navigationBar = _getNavigationBar(
|
||||
context: context,
|
||||
viewMode: viewMode,
|
||||
navigationItems: navigationItems,
|
||||
currentIndex: currentIndex,
|
||||
);
|
||||
final bottomNavigationBar =
|
||||
viewMode == ViewMode.mobile ? navigationBar : null;
|
||||
final sideNavigationBar =
|
||||
viewMode != ViewMode.mobile ? navigationBar : null;
|
||||
return CommonScaffold(
|
||||
key: globalState.homeScaffoldKey,
|
||||
title: Intl.message(
|
||||
currentLabel,
|
||||
),
|
||||
sideNavigationBar: sideNavigationBar,
|
||||
body: child!,
|
||||
bottomNavigationBar: bottomNavigationBar,
|
||||
);
|
||||
},
|
||||
child: const HomeBody(
|
||||
key: Key("home_boy"),
|
||||
),
|
||||
);
|
||||
},
|
||||
return PopContainer(
|
||||
child: LayoutBuilder(
|
||||
builder: (_, container) {
|
||||
final appController = globalState.appController;
|
||||
final maxWidth = container.maxWidth;
|
||||
if (appController.appState.viewWidth != maxWidth) {
|
||||
globalState.appController.updateViewWidth(maxWidth);
|
||||
}
|
||||
return Selector2<AppState, Config, HomeSelectorState>(
|
||||
selector: (_, appState, config) {
|
||||
return HomeSelectorState(
|
||||
currentLabel: appState.currentLabel,
|
||||
navigationItems: appState.currentNavigationItems,
|
||||
viewMode: other.getViewMode(maxWidth),
|
||||
locale: config.locale,
|
||||
);
|
||||
},
|
||||
builder: (_, state, child) {
|
||||
final viewMode = state.viewMode;
|
||||
final navigationItems = state.navigationItems;
|
||||
final currentLabel = state.currentLabel;
|
||||
final index = navigationItems.lastIndexWhere(
|
||||
(element) => element.label == currentLabel,
|
||||
);
|
||||
final currentIndex = index == -1 ? 0 : index;
|
||||
final navigationBar = _getNavigationBar(
|
||||
context: context,
|
||||
viewMode: viewMode,
|
||||
navigationItems: navigationItems,
|
||||
currentIndex: currentIndex,
|
||||
);
|
||||
final bottomNavigationBar =
|
||||
viewMode == ViewMode.mobile ? navigationBar : null;
|
||||
final sideNavigationBar =
|
||||
viewMode != ViewMode.mobile ? navigationBar : null;
|
||||
return CommonScaffold(
|
||||
key: globalState.homeScaffoldKey,
|
||||
title: Intl.message(
|
||||
currentLabel,
|
||||
),
|
||||
sideNavigationBar: sideNavigationBar,
|
||||
body: child!,
|
||||
bottomNavigationBar: bottomNavigationBar,
|
||||
);
|
||||
},
|
||||
child: const HomeBody(
|
||||
key: Key("home_boy"),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,10 +5,8 @@ import 'dart:isolate';
|
||||
|
||||
import 'package:fl_clash/clash/clash.dart';
|
||||
import 'package:fl_clash/models/models.dart';
|
||||
import 'package:fl_clash/state.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
class App {
|
||||
static App? _instance;
|
||||
@@ -50,6 +48,13 @@ class App {
|
||||
});
|
||||
}
|
||||
|
||||
Future<bool> openFile(String path) async {
|
||||
return await methodChannel.invokeMethod<bool>("openFile", {
|
||||
"path": path,
|
||||
}) ??
|
||||
false;
|
||||
}
|
||||
|
||||
Future<ImageProvider?> getPackageIcon(String packageName) async {
|
||||
final base64 = await methodChannel.invokeMethod<String>("getPackageIcon", {
|
||||
"packageName": packageName,
|
||||
|
||||
@@ -47,9 +47,10 @@ class Proxy extends ProxyPlatform {
|
||||
|
||||
@override
|
||||
Future<bool?> startProxy(port) async {
|
||||
final state = clashCore.getState();
|
||||
return await methodChannel.invokeMethod<bool>("startProxy", {
|
||||
'port': port,
|
||||
'args': json.encode(clashCore.getProps()),
|
||||
'port': state.mixedPort,
|
||||
'args': json.encode(state),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -103,6 +104,7 @@ class Proxy extends ProxyPlatform {
|
||||
|
||||
_handleServiceMessage(String message) {
|
||||
final m = ServiceMessage.fromJson(json.decode(message));
|
||||
debugPrint(m.toString());
|
||||
switch (m.type) {
|
||||
case ServiceMessageType.protect:
|
||||
_serviceMessageHandler?.onProtect(Fd.fromJson(m.data));
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'package:fl_clash/plugins/proxy.dart';
|
||||
import 'package:fl_clash/widgets/scaffold.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import 'controller.dart';
|
||||
|
||||
@@ -52,7 +53,7 @@ class GlobalState {
|
||||
config: clashConfig,
|
||||
params: ConfigExtendedParams(
|
||||
isPatch: isPatch,
|
||||
isCompatible: config.isCompatible,
|
||||
isCompatible: true,
|
||||
selectedMap: config.currentSelectedMap,
|
||||
testUrl: config.testUrl,
|
||||
),
|
||||
@@ -71,13 +72,6 @@ class GlobalState {
|
||||
required ClashConfig clashConfig,
|
||||
}) async {
|
||||
if (!globalState.isVpnService && Platform.isAndroid) {
|
||||
clashCore.setProps(
|
||||
Props(
|
||||
accessControl: config.isAccessControl ? config.accessControl : null,
|
||||
allowBypass: config.allowBypass,
|
||||
systemProxy: config.systemProxy,
|
||||
),
|
||||
);
|
||||
await proxy?.initService();
|
||||
} else {
|
||||
await proxyManager.startProxy(
|
||||
@@ -85,16 +79,6 @@ class GlobalState {
|
||||
);
|
||||
}
|
||||
startListenUpdate();
|
||||
if (Platform.isAndroid) {
|
||||
return;
|
||||
}
|
||||
applyProfile(
|
||||
appState: appState,
|
||||
config: config,
|
||||
clashConfig: clashConfig,
|
||||
).then((_) {
|
||||
globalState.appController.addCheckIpNumDebounce();
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> stopSystemProxy() async {
|
||||
@@ -123,15 +107,6 @@ class GlobalState {
|
||||
}) async {
|
||||
appState.isInit = clashCore.isInit;
|
||||
if (!appState.isInit) {
|
||||
if(Platform.isAndroid){
|
||||
clashCore.setProps(
|
||||
Props(
|
||||
accessControl: config.isAccessControl ? config.accessControl : null,
|
||||
allowBypass: config.allowBypass,
|
||||
systemProxy: config.systemProxy,
|
||||
),
|
||||
);
|
||||
}
|
||||
appState.isInit = await clashService.init(
|
||||
config: config,
|
||||
clashConfig: clashConfig,
|
||||
@@ -159,12 +134,14 @@ class GlobalState {
|
||||
width: 300,
|
||||
constraints: const BoxConstraints(maxHeight: 200),
|
||||
child: SingleChildScrollView(
|
||||
child: RichText(
|
||||
overflow: TextOverflow.visible,
|
||||
text: TextSpan(
|
||||
child: SelectableText.rich(
|
||||
TextSpan(
|
||||
style: Theme.of(context).textTheme.labelLarge,
|
||||
children: [message],
|
||||
),
|
||||
style: const TextStyle(
|
||||
overflow: TextOverflow.visible,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -183,6 +160,22 @@ class GlobalState {
|
||||
);
|
||||
}
|
||||
|
||||
changeProxy({
|
||||
required Config config,
|
||||
required String groupName,
|
||||
required String proxyName,
|
||||
}) {
|
||||
clashCore.changeProxy(
|
||||
ChangeProxyParams(
|
||||
groupName: groupName,
|
||||
proxyName: proxyName,
|
||||
),
|
||||
);
|
||||
if (config.isCloseConnections) {
|
||||
clashCore.closeConnections();
|
||||
}
|
||||
}
|
||||
|
||||
Future<T?> showCommonDialog<T>({
|
||||
required Widget child,
|
||||
}) async {
|
||||
@@ -261,6 +254,17 @@ class GlobalState {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
openUrl(String url) {
|
||||
showMessage(
|
||||
message: TextSpan(text: url),
|
||||
title: appLocalizations.externalLink,
|
||||
confirmText: appLocalizations.go,
|
||||
onTab: () {
|
||||
launchUrl(Uri.parse(url));
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
final globalState = GlobalState();
|
||||
|
||||
40
lib/widgets/builder.dart
Normal file
@@ -0,0 +1,40 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ScrollOverBuilder extends StatefulWidget {
|
||||
final Widget Function(bool isOver) builder;
|
||||
|
||||
const ScrollOverBuilder({
|
||||
super.key,
|
||||
required this.builder,
|
||||
});
|
||||
|
||||
@override
|
||||
State<ScrollOverBuilder> createState() => _ScrollOverBuilderState();
|
||||
}
|
||||
|
||||
class _ScrollOverBuilderState extends State<ScrollOverBuilder> {
|
||||
final isOverNotifier = ValueNotifier<bool>(false);
|
||||
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
isOverNotifier.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return NotificationListener<ScrollMetricsNotification>(
|
||||
onNotification: (scrollNotification) {
|
||||
isOverNotifier.value = scrollNotification.metrics.maxScrollExtent > 0;
|
||||
return true;
|
||||
},
|
||||
child: ValueListenableBuilder<bool>(
|
||||
valueListenable: isOverNotifier,
|
||||
builder: (_, isOver, __) {
|
||||
return widget.builder(isOver);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -38,10 +38,7 @@ class InfoHeader extends StatelessWidget {
|
||||
if (info.iconData != null) ...[
|
||||
Icon(
|
||||
info.iconData,
|
||||
color: Theme
|
||||
.of(context)
|
||||
.colorScheme
|
||||
.primary,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
@@ -53,10 +50,7 @@ class InfoHeader extends StatelessWidget {
|
||||
info.label,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: Theme
|
||||
.of(context)
|
||||
.textTheme
|
||||
.titleMedium,
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -86,6 +80,7 @@ class CommonCard extends StatelessWidget {
|
||||
this.onPressed,
|
||||
this.info,
|
||||
this.selectWidget,
|
||||
this.radius = 12,
|
||||
required this.child,
|
||||
}) : isSelected = isSelected ?? false;
|
||||
|
||||
@@ -95,14 +90,13 @@ class CommonCard extends StatelessWidget {
|
||||
final Widget child;
|
||||
final Info? info;
|
||||
final CommonCardType type;
|
||||
final double radius;
|
||||
|
||||
BorderSide getBorderSide(BuildContext context, Set<WidgetState> states) {
|
||||
if (type == CommonCardType.filled) {
|
||||
return BorderSide.none;
|
||||
}
|
||||
final colorScheme = Theme
|
||||
.of(context)
|
||||
.colorScheme;
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
final hoverColor = isSelected
|
||||
? colorScheme.primary.toLight()
|
||||
: colorScheme.primary.toLighter();
|
||||
@@ -119,9 +113,7 @@ class CommonCard extends StatelessWidget {
|
||||
}
|
||||
|
||||
Color? getBackgroundColor(BuildContext context, Set<WidgetState> states) {
|
||||
final colorScheme = Theme
|
||||
.of(context)
|
||||
.colorScheme;
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
switch (type) {
|
||||
case CommonCardType.plain:
|
||||
if (isSelected) {
|
||||
@@ -130,8 +122,7 @@ class CommonCard extends StatelessWidget {
|
||||
if (states.isEmpty) {
|
||||
return colorScheme.secondaryContainer.toLittle();
|
||||
}
|
||||
return Theme
|
||||
.of(context)
|
||||
return Theme.of(context)
|
||||
.outlinedButtonTheme
|
||||
.style
|
||||
?.backgroundColor
|
||||
@@ -167,29 +158,31 @@ class CommonCard extends StatelessWidget {
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
return OutlinedButton(
|
||||
clipBehavior: Clip.antiAlias,
|
||||
style: ButtonStyle(
|
||||
padding: const WidgetStatePropertyAll(EdgeInsets.zero),
|
||||
shape: WidgetStatePropertyAll(
|
||||
RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderRadius: BorderRadius.circular(radius),
|
||||
),
|
||||
),
|
||||
backgroundColor: WidgetStateProperty.resolveWith(
|
||||
(states) => getBackgroundColor(context, states),
|
||||
(states) => getBackgroundColor(context, states),
|
||||
),
|
||||
side: WidgetStateProperty.resolveWith(
|
||||
(states) => getBorderSide(context, states),
|
||||
(states) => getBorderSide(context, states),
|
||||
),
|
||||
),
|
||||
onPressed: onPressed,
|
||||
child: Builder(
|
||||
builder: (_) {
|
||||
if (selectWidget == null) {
|
||||
return childWidget;
|
||||
}
|
||||
List<Widget> children = [];
|
||||
children.add(childWidget);
|
||||
if (selectWidget != null && isSelected) {
|
||||
if (isSelected) {
|
||||
children.add(
|
||||
Positioned.fill(
|
||||
child: selectWidget!,
|
||||
@@ -211,10 +204,7 @@ class SelectIcon extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Material(
|
||||
color: Theme
|
||||
.of(context)
|
||||
.colorScheme
|
||||
.inversePrimary,
|
||||
color: Theme.of(context).colorScheme.inversePrimary,
|
||||
shape: const CircleBorder(),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(4),
|
||||
|
||||
@@ -3,24 +3,42 @@ import 'package:fl_clash/models/models.dart';
|
||||
import 'package:fl_clash/plugins/proxy.dart';
|
||||
import 'package:fl_clash/state.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class ClashMessageContainer extends StatefulWidget {
|
||||
class ClashContainer extends StatefulWidget {
|
||||
final Widget child;
|
||||
|
||||
const ClashMessageContainer({
|
||||
const ClashContainer({
|
||||
super.key,
|
||||
required this.child,
|
||||
});
|
||||
|
||||
@override
|
||||
State<ClashMessageContainer> createState() => _ClashMessageContainerState();
|
||||
State<ClashContainer> createState() => _ClashContainerState();
|
||||
}
|
||||
|
||||
class _ClashMessageContainerState extends State<ClashMessageContainer>
|
||||
class _ClashContainerState extends State<ClashContainer>
|
||||
with AppMessageListener {
|
||||
Widget _updateCoreState(Widget child) {
|
||||
return Selector2<Config, ClashConfig, CoreState>(
|
||||
selector: (_, config, clashConfig) => CoreState(
|
||||
accessControl: config.isAccessControl ? config.accessControl : null,
|
||||
allowBypass: config.allowBypass,
|
||||
systemProxy: config.systemProxy,
|
||||
mixedPort: clashConfig.mixedPort,
|
||||
onlyProxy: config.onlyProxy,
|
||||
),
|
||||
builder: (__, state, child) {
|
||||
clashCore.setState(state);
|
||||
return child!;
|
||||
},
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return widget.child;
|
||||
return _updateCoreState(widget.child);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -60,23 +78,19 @@ class _ClashMessageContainerState extends State<ClashMessageContainer>
|
||||
final currentSelectedMap = appController.config.currentSelectedMap;
|
||||
final proxyName = currentSelectedMap[groupName];
|
||||
if (proxyName == null) return;
|
||||
clashCore.changeProxy(
|
||||
ChangeProxyParams(
|
||||
groupName: groupName,
|
||||
proxyName: proxyName,
|
||||
),
|
||||
appController.changeProxy(
|
||||
groupName: groupName,
|
||||
proxyName: proxyName,
|
||||
);
|
||||
appController.addCheckIpNumDebounce();
|
||||
super.onLoaded(proxyName);
|
||||
}
|
||||
|
||||
@override
|
||||
void onStarted(String runTime) {
|
||||
Future<void> onStarted(String runTime) async {
|
||||
super.onStarted(runTime);
|
||||
proxy?.updateStartTime();
|
||||
final appController = globalState.appController;
|
||||
appController.rawApplyProfile().then((_) {
|
||||
appController.addCheckIpNumDebounce();
|
||||
});
|
||||
await appController.applyProfile(isPrue: true);
|
||||
appController.addCheckIpNumDebounce();
|
||||
}
|
||||
}
|
||||
@@ -78,7 +78,7 @@ class ListItem<T> extends StatelessWidget {
|
||||
final Widget? trailing;
|
||||
final Delegate delegate;
|
||||
final double? horizontalTitleGap;
|
||||
final void Function()? onTab;
|
||||
final void Function()? onTap;
|
||||
|
||||
const ListItem({
|
||||
super.key,
|
||||
@@ -89,7 +89,7 @@ class ListItem<T> extends StatelessWidget {
|
||||
this.trailing,
|
||||
this.horizontalTitleGap,
|
||||
this.prue,
|
||||
this.onTab,
|
||||
this.onTap,
|
||||
this.tileTitleAlignment = ListTileTitleAlignment.center,
|
||||
}) : delegate = const Delegate();
|
||||
|
||||
@@ -104,7 +104,7 @@ class ListItem<T> extends StatelessWidget {
|
||||
this.horizontalTitleGap,
|
||||
this.prue,
|
||||
this.tileTitleAlignment = ListTileTitleAlignment.center,
|
||||
}) : onTab = null;
|
||||
}) : onTap = null;
|
||||
|
||||
const ListItem.next({
|
||||
super.key,
|
||||
@@ -117,7 +117,7 @@ class ListItem<T> extends StatelessWidget {
|
||||
this.horizontalTitleGap,
|
||||
this.prue,
|
||||
this.tileTitleAlignment = ListTileTitleAlignment.center,
|
||||
}) : onTab = null;
|
||||
}) : onTap = null;
|
||||
|
||||
const ListItem.checkbox({
|
||||
super.key,
|
||||
@@ -130,7 +130,7 @@ class ListItem<T> extends StatelessWidget {
|
||||
this.prue,
|
||||
this.tileTitleAlignment = ListTileTitleAlignment.center,
|
||||
}) : trailing = null,
|
||||
onTab = null;
|
||||
onTap = null;
|
||||
|
||||
const ListItem.switchItem({
|
||||
super.key,
|
||||
@@ -143,7 +143,7 @@ class ListItem<T> extends StatelessWidget {
|
||||
this.prue,
|
||||
this.tileTitleAlignment = ListTileTitleAlignment.center,
|
||||
}) : trailing = null,
|
||||
onTab = null;
|
||||
onTap = null;
|
||||
|
||||
const ListItem.radio({
|
||||
super.key,
|
||||
@@ -156,10 +156,10 @@ class ListItem<T> extends StatelessWidget {
|
||||
this.prue,
|
||||
this.tileTitleAlignment = ListTileTitleAlignment.center,
|
||||
}) : leading = null,
|
||||
onTab = null;
|
||||
onTap = null;
|
||||
|
||||
_buildListTile({
|
||||
void Function()? onTab,
|
||||
void Function()? onTap,
|
||||
Widget? trailing,
|
||||
Widget? leading,
|
||||
}) {
|
||||
@@ -188,7 +188,7 @@ class ListItem<T> extends StatelessWidget {
|
||||
}
|
||||
return InkWell(
|
||||
splashFactory: NoSplash.splashFactory,
|
||||
onTap: onTab,
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
padding: padding,
|
||||
child: Row(
|
||||
@@ -203,7 +203,7 @@ class ListItem<T> extends StatelessWidget {
|
||||
title: title,
|
||||
subtitle: subtitle,
|
||||
titleAlignment: tileTitleAlignment,
|
||||
onTap: onTab,
|
||||
onTap: onTap,
|
||||
trailing: trailing ?? this.trailing,
|
||||
contentPadding: padding,
|
||||
);
|
||||
@@ -213,6 +213,9 @@ class ListItem<T> extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
if (delegate is OpenDelegate) {
|
||||
final openDelegate = delegate as OpenDelegate;
|
||||
final child = SafeArea(
|
||||
child: openDelegate.widget,
|
||||
);
|
||||
return OpenContainer(
|
||||
closedBuilder: (_, action) {
|
||||
openAction() {
|
||||
@@ -221,7 +224,7 @@ class ListItem<T> extends StatelessWidget {
|
||||
if (!isMobile) {
|
||||
showExtendPage(
|
||||
context,
|
||||
body: openDelegate.widget,
|
||||
body: child,
|
||||
title: openDelegate.title,
|
||||
extendPageWidth: openDelegate.extendPageWidth,
|
||||
);
|
||||
@@ -230,14 +233,16 @@ class ListItem<T> extends StatelessWidget {
|
||||
action();
|
||||
}
|
||||
|
||||
return _buildListTile(onTab: openAction);
|
||||
return _buildListTile(
|
||||
onTap: openAction,
|
||||
);
|
||||
},
|
||||
openBuilder: (_, action) {
|
||||
return CommonScaffold.open(
|
||||
key: Key(openDelegate.title),
|
||||
onBack: action,
|
||||
title: openDelegate.title,
|
||||
body: openDelegate.widget,
|
||||
body: child,
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -245,7 +250,7 @@ class ListItem<T> extends StatelessWidget {
|
||||
if (delegate is NextDelegate) {
|
||||
final nextDelegate = delegate as NextDelegate;
|
||||
return _buildListTile(
|
||||
onTab: () {
|
||||
onTap: () {
|
||||
final isMobile =
|
||||
globalState.appController.appState.viewMode == ViewMode.mobile;
|
||||
if (!isMobile) {
|
||||
@@ -272,7 +277,7 @@ class ListItem<T> extends StatelessWidget {
|
||||
if (delegate is CheckboxDelegate) {
|
||||
final checkboxDelegate = delegate as CheckboxDelegate;
|
||||
return _buildListTile(
|
||||
onTab: () {
|
||||
onTap: () {
|
||||
if (checkboxDelegate.onChanged != null) {
|
||||
checkboxDelegate.onChanged!(!checkboxDelegate.value);
|
||||
}
|
||||
@@ -286,7 +291,7 @@ class ListItem<T> extends StatelessWidget {
|
||||
if (delegate is SwitchDelegate) {
|
||||
final switchDelegate = delegate as SwitchDelegate;
|
||||
return _buildListTile(
|
||||
onTab: () {
|
||||
onTap: () {
|
||||
if (switchDelegate.onChanged != null) {
|
||||
switchDelegate.onChanged!(!switchDelegate.value);
|
||||
}
|
||||
@@ -300,7 +305,7 @@ class ListItem<T> extends StatelessWidget {
|
||||
if (delegate is RadioDelegate) {
|
||||
final radioDelegate = delegate as RadioDelegate<T>;
|
||||
return _buildListTile(
|
||||
onTab: () {
|
||||
onTap: () {
|
||||
if (radioDelegate.onChanged != null) {
|
||||
radioDelegate.onChanged!(radioDelegate.value);
|
||||
}
|
||||
@@ -319,7 +324,7 @@ class ListItem<T> extends StatelessWidget {
|
||||
}
|
||||
|
||||
return _buildListTile(
|
||||
onTab: onTab,
|
||||
onTap: onTap,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -399,10 +404,10 @@ List<Widget> generateInfoSection({
|
||||
}) {
|
||||
final genItems = separated
|
||||
? items.separated(
|
||||
const Divider(
|
||||
height: 0,
|
||||
),
|
||||
)
|
||||
const Divider(
|
||||
height: 0,
|
||||
),
|
||||
)
|
||||
: items;
|
||||
return [
|
||||
if (items.isNotEmpty)
|
||||
@@ -414,7 +419,6 @@ List<Widget> generateInfoSection({
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Widget generateListView(List<Widget> items) {
|
||||
return ListView.builder(
|
||||
itemCount: items.length,
|
||||
|
||||
@@ -19,7 +19,7 @@ class _PopContainerState extends State<PopContainer> {
|
||||
if (Platform.isAndroid) {
|
||||
return PopScope(
|
||||
canPop: false,
|
||||
onPopInvoked: (didPop) async {
|
||||
onPopInvoked: (_) async {
|
||||
final canPop = Navigator.canPop(context);
|
||||
if (canPop) {
|
||||
Navigator.pop(context);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import 'package:fl_clash/common/common.dart';
|
||||
import 'package:fl_clash/state.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
class CommonScaffold extends StatefulWidget {
|
||||
final Widget body;
|
||||
@@ -86,7 +85,7 @@ class CommonScaffoldState extends State<CommonScaffold> {
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(covariant CommonScaffold oldWidget) {
|
||||
void didUpdateWidget(CommonScaffold oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
if (oldWidget.title != widget.title) {
|
||||
_actions.value = [];
|
||||
@@ -95,6 +94,8 @@ class CommonScaffoldState extends State<CommonScaffold> {
|
||||
|
||||
Widget? get _sideNavigationBar => widget.sideNavigationBar;
|
||||
|
||||
Widget get body => SafeArea(child: widget.body);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final scaffold = Scaffold(
|
||||
@@ -108,7 +109,7 @@ class CommonScaffoldState extends State<CommonScaffold> {
|
||||
valueListenable: _actions,
|
||||
builder: (_, actions, __) {
|
||||
final realActions =
|
||||
actions.isNotEmpty ? actions : widget.actions;
|
||||
actions.isNotEmpty ? actions : widget.actions;
|
||||
return AppBar(
|
||||
centerTitle: false,
|
||||
automaticallyImplyLeading: widget.automaticallyImplyLeading,
|
||||
@@ -134,7 +135,7 @@ class CommonScaffoldState extends State<CommonScaffold> {
|
||||
],
|
||||
),
|
||||
),
|
||||
body: widget.body,
|
||||
body: body,
|
||||
bottomNavigationBar: widget.bottomNavigationBar,
|
||||
);
|
||||
return _sideNavigationBar != null
|
||||
|
||||