Compare commits

..

1 Commits

Author SHA1 Message Date
chen08209
aec325a19a Optimize android vpn performance
Optimize more details
2025-04-15 15:54:36 +08:00
108 changed files with 955 additions and 3975 deletions

View File

@@ -1,57 +0,0 @@
name: 问题反馈 / Bug report
title: "[BUG] "
description: 反馈你遇到的问题 / Report the issue you are experiencing
body:
- type: markdown
attributes:
value: |
## 在提交问题之前,请确认以下事项:
1. 请务必给issue填写一个简洁明了的标题以便他人快速检索
2. 请确保[已有的问题](https://github.com/chen08209/FlClash/issues?q=is%3Aissue) 中没有人提交过相似issue否则请在已有的issue下进行讨论
3. 请务必按照模板规范详细描述问题否则issue将会被直接关闭
## Before submitting the issue, please make sure of the following checklist:
1. Please be sure to fill in a concise and clear title for the issue so that others can quickly search
2. Please make sure there is no similar issue in the [existing issues](https://github.com/chen08209/FlClash/issues?q=is%3Aissue), otherwise please discuss under the existing issue
3. Please describe the problem in detail according to the template specification, otherwise issue will be closed directly.
- type: textarea
id: description
attributes:
label: 问题描述 / Describe the bug
description: 详细清晰地描述你遇到的问题,并配合截图 / Describe the problem you encountered in detail and clearly, and provide screenshots
validations:
required: true
- type: textarea
attributes:
label: 软件版本 / Version
description: 请提供FlClash的具体版本 / Please provide the specific version of FlClash.
validations:
required: true
- type: textarea
attributes:
label: 复现步骤 / To Reproduce
description: 请提供复现问题的步骤 / Steps to reproduce the behavior
validations:
required: true
- type: dropdown
attributes:
label: 操作系统 / OS
options:
- Android
- Windows
- MacOS
- Linux
validations:
required: true
- type: input
attributes:
label: 操作系统版本 / OS Version
description: 请提供你的操作系统版本Linux请额外提供桌面环境及窗口系统 / Please provide your OS version, for Linux, please also provide the desktop environment and window system
validations:
required: true
- type: textarea
attributes:
label: 日志(勿上传日志文件,请粘贴日志内容) / Log (Do not upload the log file, paste the log content directly)
description: 请提供完整或相关部分的Debug日志请在“软件左侧菜单”->“设置”->“日志等级”调整到debug / Please provide a complete or relevant Debug log (please adjust it to debug in the left menu of software-> Settings-> Log Level)
validations:
required: true

View File

@@ -1,4 +0,0 @@
contact_links:
- name: 讨论交流 / Communication
url: https://t.me/+G-veVtwBOl4wODc1
about: 在 Telegram 群组中与其他用户讨论交流 / Communicate with other users in the Telegram group

View File

@@ -1,42 +0,0 @@
name: 功能请求 / Feature request
title: "[Feature] "
description: 提出你的功能请求 / Propose your feature request
body:
- type: markdown
attributes:
value: |
## 在提交问题之前,请确认以下事项:
1. 请务必给issue填写一个简洁明了的标题以便他人快速检索
2. 请确保[已有的问题](https://github.com/chen08209/FlClash/issues?q=is%3Aissue) 中没有人提交过相似issue否则请在已有的issue下进行讨论
3. 请务必按照模板规范详细描述问题否则issue将会被直接关闭
## Before submitting the issue, please make sure of the following checklist:
1. Please be sure to fill in a concise and clear title for the issue so that others can quickly search
2. Please make sure there is no similar issue in the [existing issues](https://github.com/chen08209/FlClash/issues?q=is%3Aissue), otherwise please discuss under the existing issue
3. Please describe the problem in detail according to the template specification, otherwise issue will be closed directly.
- type: textarea
id: description
attributes:
label: 功能描述 / Feature description
description: 详细清晰地描述你的功能请求 / A clear and concise description of what the feature is
validations:
required: true
- type: textarea
attributes:
label: 使用场景 / Use case
description: 请描述你的功能请求的使用场景 / Please describe the use case of your feature request
validations:
required: true
- type: checkboxes
id: os-labels
attributes:
label: 适用系统 / Target OS
description: 请选择该功能适用的操作系统(至少选择一个) / Please select the operating system(s) for this feature request (select at least one)
options:
- label: Android
- label: Windows
- label: MacOS
- label: Linux
validations:
required: true

View File

@@ -27,27 +27,29 @@ jobs:
- platform: macos
os: macos-latest
arch: arm64
- platform: windows
os: windows-11-arm
arch: arm64
- platform: linux
os: ubuntu-24.04-arm
arch: arm64
steps:
- name: Setup rust
if: startsWith(matrix.os, 'windows-11-arm')
run: |
Invoke-WebRequest -Uri "https://win.rustup.rs/aarch64" -OutFile rustup-init.exe
.\rustup-init.exe -y --default-toolchain stable
$cargoPath = "$env:USERPROFILE\.cargo\bin"
Add-Content $env:GITHUB_PATH $cargoPath
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup JAVA
if: startsWith(matrix.platform,'android')
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
- name: Setup NDK
if: startsWith(matrix.platform,'android')
uses: nttld/setup-ndk@v1
id: setup-ndk
with:
ndk-version: r26b
add-to-path: true
link-to-sdk: true
- name: Setup Android Signing
if: startsWith(matrix.platform,'android')
run: |
@@ -56,17 +58,18 @@ jobs:
echo "storePassword=${{ secrets.STORE_PASSWORD }}" >> android/local.properties
echo "keyPassword=${{ secrets.KEY_PASSWORD }}" >> android/local.properties
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.24.0'
go-version: 'stable'
cache-dependency-path: |
core/go.sum
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: ${{ (startsWith(matrix.os, 'windows-11-arm') || startsWith(matrix.os, 'ubuntu-24.04-arm')) && 'master' || 'stable' }}
channel: stable
cache: true
- name: Get Flutter Dependency
@@ -211,14 +214,6 @@ jobs:
version=$(echo "${{ github.ref_name }}" | sed 's/^v//')
sed "s|VERSION|$version|g" ./.github/release_template.md >> release.md
- name: Generate sha256
if: env.IS_STABLE == 'true'
run: |
cd ./dist
for file in $(find . -type f -not -name "*.sha256"); do
sha256sum "$file" > "${file}.sha256"
done
- name: Release
if: ${{ env.IS_STABLE == 'true' }}
uses: softprops/action-gh-release@v2

4
.gitmodules vendored
View File

@@ -6,5 +6,9 @@
path = plugins/flutter_distributor
url = git@github.com:chen08209/flutter_distributor.git
branch = FlClash
[submodule "plugins/tray_manager"]
path = plugins/tray_manager
url = git@github.com:chen08209/tray_manager.git
branch = main

View File

@@ -1,17 +1,3 @@
## v0.8.82
- Optimize android vpn performance
- Add custom primary color and color scheme
- Add linux nad windows arm release
- Optimize requests and logs page
- Fix map input page delete issues
- Update changelog
## v0.8.81
- Add rule override

View File

@@ -2,8 +2,6 @@ android_arm64:
dart ./setup.dart android --arch arm64
macos_arm64:
dart ./setup.dart macos --arch arm64
android_app:
dart ./setup.dart android
android_arm64_core:
dart ./setup.dart android --arch arm64 --out core
macos_arm64_core:

View File

@@ -31,8 +31,7 @@ def isRelease = defStoreFile.exists() && defStorePassword != null && defKeyAlias
android {
namespace "com.follow.clash"
compileSdk 35
ndkVersion = "28.0.13004108"
compileSdkVersion 35
compileOptions {
sourceCompatibility JavaVersion.VERSION_17

View File

@@ -44,7 +44,6 @@
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE_PREFERENCES" />

View File

@@ -20,10 +20,6 @@ enum class RunState {
object GlobalState {
val runLock = ReentrantLock()
const val NOTIFICATION_CHANNEL = "FlClash"
const val NOTIFICATION_ID = 1
val runState: MutableLiveData<RunState> = MutableLiveData<RunState>(RunState.STOP)
var flutterEngine: FlutterEngine? = null
private var serviceEngine: FlutterEngine? = null

View File

@@ -1,5 +1,6 @@
package com.follow.clash
import com.follow.clash.core.Core
import com.follow.clash.plugins.AppPlugin
import com.follow.clash.plugins.ServicePlugin
import com.follow.clash.plugins.TilePlugin

View File

@@ -27,6 +27,7 @@ import java.util.concurrent.locks.ReentrantLock
import kotlin.coroutines.resume
import kotlin.coroutines.suspendCoroutine
suspend fun Drawable.getBase64(): String {
val drawable = this
return withContext(Dispatchers.IO) {

View File

@@ -168,10 +168,8 @@ data object VpnPlugin : FlutterPlugin, MethodChannel.MethodCallHandler {
try {
if (GlobalState.runState.value != RunState.START) return
val data = flutterMethodChannel.awaitResult<String>("getStartForegroundParams")
val startForegroundParams = if (data != null) Gson().fromJson(
val startForegroundParams = Gson().fromJson(
data, StartForegroundParams::class.java
) else StartForegroundParams(
title = "", content = ""
)
if (lastStartForegroundParams != startForegroundParams) {
lastStartForegroundParams = startForegroundParams

View File

@@ -1,26 +1,6 @@
package com.follow.clash.services
import android.annotation.SuppressLint
import android.app.Notification
import android.app.Notification.FOREGROUND_SERVICE_IMMEDIATE
import android.app.NotificationChannel
import android.app.NotificationManager
import android.app.PendingIntent
import android.app.Service
import android.content.Intent
import android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC
import android.os.Build
import androidx.core.app.NotificationCompat
import com.follow.clash.GlobalState
import com.follow.clash.MainActivity
import com.follow.clash.R
import com.follow.clash.extensions.getActionPendingIntent
import com.follow.clash.models.VpnOptions
import io.flutter.Log
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Deferred
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
interface BaseServiceInterface {
@@ -29,71 +9,4 @@ interface BaseServiceInterface {
fun stop()
suspend fun startForeground(title: String, content: String)
}
fun Service.createFlClashNotificationBuilder(): Deferred<NotificationCompat.Builder> =
CoroutineScope(Dispatchers.Main).async {
val stopText = GlobalState.getText("stop")
val intent = Intent(this@createFlClashNotificationBuilder, MainActivity::class.java)
val pendingIntent = if (Build.VERSION.SDK_INT >= 31) {
PendingIntent.getActivity(
this@createFlClashNotificationBuilder,
0,
intent,
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
)
} else {
PendingIntent.getActivity(
this@createFlClashNotificationBuilder, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT
)
}
with(
NotificationCompat.Builder(
this@createFlClashNotificationBuilder, GlobalState.NOTIFICATION_CHANNEL
)
) {
setSmallIcon(R.drawable.ic_stat_name)
setContentTitle("FlClash")
setContentIntent(pendingIntent)
setCategory(NotificationCompat.CATEGORY_SERVICE)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
foregroundServiceBehavior = FOREGROUND_SERVICE_IMMEDIATE
}
setOngoing(true)
addAction(
0, stopText, getActionPendingIntent("STOP")
)
setShowWhen(false)
setOnlyAlertOnce(true)
}
}
@SuppressLint("ForegroundServiceType")
fun Service.startForeground(notification: Notification) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val manager = getSystemService(NotificationManager::class.java)
var channel = manager?.getNotificationChannel(GlobalState.NOTIFICATION_CHANNEL)
if (channel == null) {
Log.d("[FlClash]","createNotificationChannel===>")
channel = NotificationChannel(
GlobalState.NOTIFICATION_CHANNEL, "FlClash", NotificationManager.IMPORTANCE_LOW
)
manager?.createNotificationChannel(channel)
}
}
Log.d("[FlClash]","startForeground===>")
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
try {
startForeground(
GlobalState.NOTIFICATION_ID, notification, FOREGROUND_SERVICE_TYPE_DATA_SYNC
)
} catch (_: Exception) {
startForeground(GlobalState.NOTIFICATION_ID, notification)
}
} else {
startForeground(GlobalState.NOTIFICATION_ID, notification)
}
}

View File

@@ -1,51 +1,29 @@
package com.follow.clash.services
import android.annotation.SuppressLint
import android.app.Notification.FOREGROUND_SERVICE_IMMEDIATE
import android.app.NotificationChannel
import android.app.NotificationManager
import android.app.PendingIntent
import android.app.Service
import android.content.Intent
import android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC
import android.os.Binder
import android.os.Build
import android.os.IBinder
import androidx.core.app.NotificationCompat
import com.follow.clash.GlobalState
import com.follow.clash.MainActivity
import com.follow.clash.extensions.getActionPendingIntent
import com.follow.clash.models.VpnOptions
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Deferred
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
class FlClashService : Service(), BaseServiceInterface {
override fun start(options: VpnOptions) = 0
override fun stop() {
stopSelf()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
stopForeground(STOP_FOREGROUND_REMOVE)
}
}
private var cachedBuilder: NotificationCompat.Builder? = null
private suspend fun notificationBuilder(): NotificationCompat.Builder {
if (cachedBuilder == null) {
cachedBuilder = createFlClashNotificationBuilder().await()
}
return cachedBuilder!!
}
@SuppressLint("ForegroundServiceType")
override suspend fun startForeground(title: String, content: String) {
startForeground(
notificationBuilder()
.setContentTitle(title)
.setContentText(content).build()
)
}
override fun onTrimMemory(level: Int) {
super.onTrimMemory(level)
GlobalState.getCurrentVPNPlugin()?.requestGc()
}
private val binder = LocalBinder()
inner class LocalBinder : Binder() {
@@ -60,8 +38,93 @@ class FlClashService : Service(), BaseServiceInterface {
return super.onUnbind(intent)
}
override fun onDestroy() {
stop()
super.onDestroy()
private val CHANNEL = "FlClash"
private val notificationId: Int = 1
private val notificationBuilderDeferred: Deferred<NotificationCompat.Builder> by lazy {
CoroutineScope(Dispatchers.Main).async {
val stopText = GlobalState.getText("stop")
val intent = Intent(
this@FlClashService, MainActivity::class.java
)
val pendingIntent = if (Build.VERSION.SDK_INT >= 31) {
PendingIntent.getActivity(
this@FlClashService,
0,
intent,
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
)
} else {
PendingIntent.getActivity(
this@FlClashService,
0,
intent,
PendingIntent.FLAG_UPDATE_CURRENT
)
}
with(NotificationCompat.Builder(this@FlClashService, CHANNEL)) {
setSmallIcon(com.follow.clash.R.drawable.ic_stat_name)
setContentTitle("FlClash")
setContentIntent(pendingIntent)
setCategory(NotificationCompat.CATEGORY_SERVICE)
priority = NotificationCompat.PRIORITY_MIN
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
foregroundServiceBehavior = FOREGROUND_SERVICE_IMMEDIATE
}
addAction(
0,
stopText, // 使用 suspend 函数获取的文本
getActionPendingIntent("STOP")
)
setOngoing(true)
setShowWhen(false)
setOnlyAlertOnce(true)
setAutoCancel(true)
}
}
}
private suspend fun getNotificationBuilder(): NotificationCompat.Builder {
return notificationBuilderDeferred.await()
}
override fun start(options: VpnOptions) = 0
override fun stop() {
stopSelf()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
stopForeground(STOP_FOREGROUND_REMOVE)
}
}
@SuppressLint("ForegroundServiceType")
override suspend fun startForeground(title: String, content: String) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val manager = getSystemService(NotificationManager::class.java)
var channel = manager?.getNotificationChannel(CHANNEL)
if (channel == null) {
channel =
NotificationChannel(CHANNEL, "FlClash", NotificationManager.IMPORTANCE_LOW)
manager?.createNotificationChannel(channel)
}
}
val notification =
getNotificationBuilder()
.setContentTitle(title)
.setContentText(content).build()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
try {
startForeground(notificationId, notification, FOREGROUND_SERVICE_TYPE_DATA_SYNC)
} catch (_: Exception) {
startForeground(notificationId, notification)
}
} else {
startForeground(notificationId, notification)
}
}
}

View File

@@ -1,8 +1,12 @@
package com.follow.clash.services
import android.annotation.SuppressLint
import android.app.Notification.FOREGROUND_SERVICE_IMMEDIATE
import android.app.NotificationChannel
import android.app.NotificationManager
import android.app.PendingIntent
import android.content.Intent
import android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC
import android.net.ProxyInfo
import android.net.VpnService
import android.os.Binder
@@ -13,13 +17,18 @@ import android.os.RemoteException
import android.util.Log
import androidx.core.app.NotificationCompat
import com.follow.clash.GlobalState
import com.follow.clash.MainActivity
import com.follow.clash.R
import com.follow.clash.extensions.getActionPendingIntent
import com.follow.clash.extensions.getIpv4RouteAddress
import com.follow.clash.extensions.getIpv6RouteAddress
import com.follow.clash.extensions.toCIDR
import com.follow.clash.models.AccessControlMode
import com.follow.clash.models.VpnOptions
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Deferred
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
import kotlinx.coroutines.launch
@@ -119,22 +128,82 @@ class FlClashVpnService : VpnService(), BaseServiceInterface {
}
}
private var cachedBuilder: NotificationCompat.Builder? = null
private val CHANNEL = "FlClash"
private suspend fun notificationBuilder(): NotificationCompat.Builder {
if (cachedBuilder == null) {
cachedBuilder = createFlClashNotificationBuilder().await()
private val notificationId: Int = 1
private val notificationBuilderDeferred: Deferred<NotificationCompat.Builder> by lazy {
CoroutineScope(Dispatchers.Main).async {
val stopText = GlobalState.getText("stop")
val intent = Intent(this@FlClashVpnService, MainActivity::class.java)
val pendingIntent = if (Build.VERSION.SDK_INT >= 31) {
PendingIntent.getActivity(
this@FlClashVpnService,
0,
intent,
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
)
} else {
PendingIntent.getActivity(
this@FlClashVpnService,
0,
intent,
PendingIntent.FLAG_UPDATE_CURRENT
)
}
with(NotificationCompat.Builder(this@FlClashVpnService, CHANNEL)) {
setSmallIcon(R.drawable.ic_stat_name)
setContentTitle("FlClash")
setContentIntent(pendingIntent)
setCategory(NotificationCompat.CATEGORY_SERVICE)
priority = NotificationCompat.PRIORITY_MIN
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
foregroundServiceBehavior = FOREGROUND_SERVICE_IMMEDIATE
}
setOngoing(true)
addAction(
0,
stopText,
getActionPendingIntent("STOP")
)
setShowWhen(false)
setOnlyAlertOnce(true)
setAutoCancel(true)
}
}
return cachedBuilder!!
}
private suspend fun getNotificationBuilder(): NotificationCompat.Builder {
return notificationBuilderDeferred.await()
}
@SuppressLint("ForegroundServiceType")
override suspend fun startForeground(title: String, content: String) {
startForeground(
notificationBuilder()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val manager = getSystemService(NotificationManager::class.java)
var channel = manager?.getNotificationChannel(CHANNEL)
if (channel == null) {
channel =
NotificationChannel(CHANNEL, "FlClash", NotificationManager.IMPORTANCE_LOW)
manager?.createNotificationChannel(channel)
}
}
val notification =
getNotificationBuilder()
.setContentTitle(title)
.setContentText(content).build()
)
.setContentText(content)
.build()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
try {
startForeground(notificationId, notification, FOREGROUND_SERVICE_TYPE_DATA_SYNC)
} catch (_: Exception) {
startForeground(notificationId, notification)
}
} else {
startForeground(notificationId, notification)
}
}
override fun onTrimMemory(level: Int) {

View File

@@ -8,7 +8,7 @@ plugins {
android {
namespace = "com.follow.clash.core"
compileSdk = 35
ndkVersion = "28.0.13004108"
ndkVersion = "27.1.12297006"
defaultConfig {
minSdk = 21
@@ -46,7 +46,7 @@ android {
}
}
val copyNativeLibs by tasks.register<Copy>("copyNativeLibs") {
tasks.register<Copy>("copyNativeLibs") {
doFirst {
delete("src/main/jniLibs")
}
@@ -54,9 +54,16 @@ val copyNativeLibs by tasks.register<Copy>("copyNativeLibs") {
into("src/main/jniLibs")
}
tasks.withType<MergeSourceSetFolders>().configureEach {
dependsOn("copyNativeLibs")
}
afterEvaluate {
tasks.named("preBuild") {
dependsOn(copyNativeLibs)
tasks.named("assembleDebug").configure {
dependsOn("copyNativeLibs")
}
tasks.named("assembleRelease").configure {
dependsOn("copyNativeLibs")
}
}

View File

@@ -1,8 +1,8 @@
cmake_minimum_required(VERSION 3.22.1)
project("core")
message("CMAKE_SOURCE_DIR ${CMAKE_SOURCE_DIR}")
if (NOT "${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
add_compile_options(-O3)
@@ -22,13 +22,10 @@ if (NOT "${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
-Wl,--exclude-libs=ALL
)
endif ()
set(LIB_CLASH_PATH "${CMAKE_SOURCE_DIR}/../jniLibs/${ANDROID_ABI}/libclash.so")
message("LIB_CLASH_PATH ${LIB_CLASH_PATH}")
if (EXISTS ${LIB_CLASH_PATH})
message("Found libclash.so for ABI ${ANDROID_ABI}")
add_compile_definitions(LIBCLASH)
message(STATUS "Found libclash.so for ABI ${ANDROID_ABI}")
add_definitions(-D_LIBCLASH)
include_directories(${CMAKE_SOURCE_DIR}/../jniLibs/${ANDROID_ABI})
link_directories(${CMAKE_SOURCE_DIR}/../jniLibs/${ANDROID_ABI})
add_library(${CMAKE_PROJECT_NAME} SHARED
@@ -37,7 +34,6 @@ if (EXISTS ${LIB_CLASH_PATH})
target_link_libraries(${CMAKE_PROJECT_NAME}
clash)
else ()
message("Not found libclash.so for ABI ${ANDROID_ABI}")
add_library(${CMAKE_PROJECT_NAME} SHARED
jni_helper.cpp
core.cpp)

View File

@@ -1,6 +1,6 @@
#include <jni.h>
#ifdef LIBCLASH
#ifdef _LIBCLASH
#include <jni.h>
#include <string>
#include "jni_helper.h"
@@ -72,4 +72,17 @@ JNI_OnLoad(JavaVM *vm, void *reserved) {
&release_jni_object_impl);
return JNI_VERSION_1_6;
}
#else
extern "C"
JNIEXPORT void JNICALL
Java_com_follow_clash_core_Core_stopTun(JNIEnv *env, jobject thiz) {
}
extern "C"
JNIEXPORT void JNICALL
Java_com_follow_clash_core_Core_startTun(JNIEnv *env, jobject thiz, jint fd, jobject cb) {
}
#endif

View File

@@ -166,9 +166,6 @@ func handleAction(action *Action, result func(data interface{})) {
data := action.Data.(string)
handleSetState(data)
result(true)
case crashMethod:
result(true)
handleCrash()
default:
handle := nextHandle(action, result)
if handle {

View File

@@ -78,6 +78,7 @@ func getRawConfigWithId(id string) *config.RawConfig {
path := getProfilePath(id)
bytes, err := readFile(path)
if err != nil {
log.Errorln("profile is not exist")
return config.DefaultRawConfig()
}
prof, err := config.UnmarshalRawConfig(bytes)

View File

@@ -82,7 +82,6 @@ const (
getRunTimeMethod Method = "getRunTime"
getCurrentProfileNameMethod Method = "getCurrentProfileName"
getProfileMethod Method = "getProfile"
crashMethod Method = "crash"
)
type Method string

View File

@@ -7,7 +7,6 @@ replace github.com/metacubex/mihomo => ./Clash.Meta
require (
github.com/metacubex/mihomo v0.0.0-00010101000000-000000000000
github.com/samber/lo v1.49.1
golang.org/x/sync v0.11.0
)
require (
@@ -53,20 +52,20 @@ require (
github.com/metacubex/amneziawg-go v0.0.0-20240922133038-fdf3a4d5a4ab // indirect
github.com/metacubex/bart v0.19.0 // indirect
github.com/metacubex/bbolt v0.0.0-20240822011022-aed6d4850399 // indirect
github.com/metacubex/chacha v0.1.2 // indirect
github.com/metacubex/chacha v0.1.1 // indirect
github.com/metacubex/gopacket v1.1.20-0.20230608035415-7e2f98a3e759 // indirect
github.com/metacubex/gvisor v0.0.0-20250324165734-5857f47bd43b // indirect
github.com/metacubex/quic-go v0.49.1-0.20250212162123-c135a4412996 // indirect
github.com/metacubex/randv2 v0.2.0 // indirect
github.com/metacubex/sing-quic v0.0.0-20250404030904-b2cc8aab562c // indirect
github.com/metacubex/reality v0.0.0-20250219003814-74e8d7850629 // indirect
github.com/metacubex/sing-quic v0.0.0-20250119013740-2a19cce83925 // indirect
github.com/metacubex/sing-shadowsocks v0.2.8 // indirect
github.com/metacubex/sing-shadowsocks2 v0.2.2 // indirect
github.com/metacubex/sing-shadowtls v0.0.0-20250412122235-0e9005731a63 // indirect
github.com/metacubex/sing-tun v0.4.6-0.20250412144348-c426cb167db5 // indirect
github.com/metacubex/sing-tun v0.4.6-0.20250312042506-6d3b4dc05c04 // indirect
github.com/metacubex/sing-vmess v0.1.14-0.20250228002636-abc39e113b82 // indirect
github.com/metacubex/sing-wireguard v0.0.0-20241126021510-0827d417b589 // indirect
github.com/metacubex/tfo-go v0.0.0-20241231083714-66613d49c422 // indirect
github.com/metacubex/utls v1.7.0-alpha.1 // indirect
github.com/metacubex/utls v1.6.8-alpha.4 // indirect
github.com/metacubex/wireguard-go v0.0.0-20240922131502-c182e7471181 // indirect
github.com/miekg/dns v1.1.63 // indirect
github.com/mroth/weightedrand/v2 v2.1.0 // indirect
@@ -85,6 +84,7 @@ require (
github.com/sagernet/nftables v0.3.0-beta.4 // indirect
github.com/sagernet/sing v0.5.2 // indirect
github.com/sagernet/sing-mux v0.2.1 // indirect
github.com/sagernet/sing-shadowtls v0.1.5 // indirect
github.com/sagernet/smux v0.0.0-20231208180855-7041f6ea79e7 // indirect
github.com/shirou/gopsutil/v4 v4.25.1 // indirect
github.com/sina-ghaderi/poly1305 v0.0.0-20220724002748-c5926b03988b // indirect
@@ -107,6 +107,7 @@ require (
golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e // indirect
golang.org/x/mod v0.20.0 // indirect
golang.org/x/net v0.35.0 // indirect
golang.org/x/sync v0.11.0 // indirect
golang.org/x/sys v0.30.0 // indirect
golang.org/x/text v0.22.0 // indirect
golang.org/x/time v0.7.0 // indirect

View File

@@ -101,8 +101,8 @@ github.com/metacubex/bart v0.19.0 h1:XQ9AJeI+WO+phRPkUOoflAFwlqDJnm5BPQpixciJQBY
github.com/metacubex/bart v0.19.0/go.mod h1:DCcyfP4MC+Zy7sLK7XeGuMw+P5K9mIRsYOBgiE8icsI=
github.com/metacubex/bbolt v0.0.0-20240822011022-aed6d4850399 h1:oBowHVKZycNtAFbZ6avaCSZJYeme2Nrj+4RpV2cNJig=
github.com/metacubex/bbolt v0.0.0-20240822011022-aed6d4850399/go.mod h1:4xcieuIK+M4bGQmQYZVqEaIYqjS1ahO4kXG7EmDgEro=
github.com/metacubex/chacha v0.1.2 h1:QulCq3eVm3TO6+4nVIWJtmSe7BT2GMrgVHuAoqRQnlc=
github.com/metacubex/chacha v0.1.2/go.mod h1:Djn9bPZxLTXbJFSeyo0/qzEzQI+gUSSzttuzZM75GH8=
github.com/metacubex/chacha v0.1.1 h1:OHIv11Nd9CISAIzegpjfupIoZp9DYm6uQw41RxvmU/c=
github.com/metacubex/chacha v0.1.1/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-20250324165734-5857f47bd43b h1:RUh4OdVPz/jDrM9MQ2ySuqu2aeBqcA8rtfWUYLZ8RtI=
@@ -111,24 +111,24 @@ github.com/metacubex/quic-go v0.49.1-0.20250212162123-c135a4412996 h1:B+AP/Pj2/j
github.com/metacubex/quic-go v0.49.1-0.20250212162123-c135a4412996/go.mod h1:ExVjGyEwTUjCFqx+5uxgV7MOoA3fZI+th4D40H35xmY=
github.com/metacubex/randv2 v0.2.0 h1:uP38uBvV2SxYfLj53kuvAjbND4RUDfFJjwr4UigMiLs=
github.com/metacubex/randv2 v0.2.0/go.mod h1:kFi2SzrQ5WuneuoLLCMkABtiBu6VRrMrWFqSPyj2cxY=
github.com/metacubex/sing-quic v0.0.0-20250404030904-b2cc8aab562c h1:OB3WmMA8YPJjE36RjD9X8xlrWGJ4orxbf2R/KAE28b0=
github.com/metacubex/sing-quic v0.0.0-20250404030904-b2cc8aab562c/go.mod h1:g7Mxj7b7zm7YVqD975mk/hSmrb0A0G4bVvIMr2MMzn8=
github.com/metacubex/reality v0.0.0-20250219003814-74e8d7850629 h1:aHsYiTvubfgMa3JMTDY//hDXVvFWrHg6ARckR52ttZs=
github.com/metacubex/reality v0.0.0-20250219003814-74e8d7850629/go.mod h1:TTeIOZLdGmzc07Oedn++vWUUfkZoXLF4sEMxWuhBFr8=
github.com/metacubex/sing-quic v0.0.0-20250119013740-2a19cce83925 h1:UkPoRAnoBQMn7IK5qpoIV3OejU15q+rqel3NrbSCFKA=
github.com/metacubex/sing-quic v0.0.0-20250119013740-2a19cce83925/go.mod h1:g7Mxj7b7zm7YVqD975mk/hSmrb0A0G4bVvIMr2MMzn8=
github.com/metacubex/sing-shadowsocks v0.2.8 h1:wIhlaigswzjPw4hej75sEvWte3QR0+AJRafgwBHO5B4=
github.com/metacubex/sing-shadowsocks v0.2.8/go.mod h1:X3x88XtJpBxG0W0/ECOJL6Ib0SJ3xdniAkU/6/RMWU0=
github.com/metacubex/sing-shadowsocks2 v0.2.2 h1:eaf42uVx4Lr21S6MDYs0ZdTvGA0GEhDpb9no4+gdXPo=
github.com/metacubex/sing-shadowsocks2 v0.2.2/go.mod h1:BhOug03a/RbI7y6hp6q+6ITM1dXjnLTmeWBHSTwvv2Q=
github.com/metacubex/sing-shadowtls v0.0.0-20250412122235-0e9005731a63 h1:vy/8ZYYtWUXYnOnw/NF8ThG1W/RqM/h5rkun+OXZMH0=
github.com/metacubex/sing-shadowtls v0.0.0-20250412122235-0e9005731a63/go.mod h1:eDZ2JpkSkewGmUlCoLSn2MRFn1D0jKPIys/6aogFx7U=
github.com/metacubex/sing-tun v0.4.6-0.20250412144348-c426cb167db5 h1:hcsz5e5lqhBxn3iQQDIF60FLZ8PQT542GTQZ+1wcIGo=
github.com/metacubex/sing-tun v0.4.6-0.20250412144348-c426cb167db5/go.mod h1:V0N4rr0dWPBEE20ESkTXdbtx2riQYcb6YtwC5w/9wl0=
github.com/metacubex/sing-tun v0.4.6-0.20250312042506-6d3b4dc05c04 h1:B211C+i/I8CWf4I/BaAV0mmkEHrDBJ0XR9EWxjPbFEg=
github.com/metacubex/sing-tun v0.4.6-0.20250312042506-6d3b4dc05c04/go.mod h1:V0N4rr0dWPBEE20ESkTXdbtx2riQYcb6YtwC5w/9wl0=
github.com/metacubex/sing-vmess v0.1.14-0.20250228002636-abc39e113b82 h1:zZp5uct9+/0Hb1jKGyqDjCU4/72t43rs7qOq3Rc9oU8=
github.com/metacubex/sing-vmess v0.1.14-0.20250228002636-abc39e113b82/go.mod h1:nE7Mdzj/QUDwgRi/8BASPtsxtIFZTHA4Yst5GgwbGCQ=
github.com/metacubex/sing-wireguard v0.0.0-20241126021510-0827d417b589 h1:Z6bNy0HLTjx6BKIkV48sV/yia/GP8Bnyb5JQuGgSGzg=
github.com/metacubex/sing-wireguard v0.0.0-20241126021510-0827d417b589/go.mod h1:4NclTLIZuk+QkHVCGrP87rHi/y8YjgPytxTgApJNMhc=
github.com/metacubex/tfo-go v0.0.0-20241231083714-66613d49c422 h1:zGeQt3UyNydIVrMRB97AA5WsYEau/TyCnRtTf1yUmJY=
github.com/metacubex/tfo-go v0.0.0-20241231083714-66613d49c422/go.mod h1:l9oLnLoEXyGZ5RVLsh7QCC5XsouTUyKk4F2nLm2DHLw=
github.com/metacubex/utls v1.7.0-alpha.1 h1:oMFsPh2oTlALJ7vKXPJuqgy0YeiZ+q/LLw+ZdxZ80l4=
github.com/metacubex/utls v1.7.0-alpha.1/go.mod h1:oknYT0qTOwE4hjPmZOEpzVdefnW7bAdGLvZcqmk4TLU=
github.com/metacubex/utls v1.6.8-alpha.4 h1:5EvsCHxDNneaOtAyc8CztoNSpmonLvkvuGs01lIeeEI=
github.com/metacubex/utls v1.6.8-alpha.4/go.mod h1:MEZ5WO/VLKYs/s/dOzEK/mlXOQxc04ESeLzRgjmLYtk=
github.com/metacubex/wireguard-go v0.0.0-20240922131502-c182e7471181 h1:hJLQviGySBuaynlCwf/oYgIxbVbGRUIKZCxdya9YrbQ=
github.com/metacubex/wireguard-go v0.0.0-20240922131502-c182e7471181/go.mod h1:phewKljNYiTVT31Gcif8RiCKnTUOgVWFJjccqYM8s+Y=
github.com/miekg/dns v1.1.63 h1:8M5aAw6OMZfFXTT7K5V0Eu5YiiL8l7nUAkyN6C9YwaY=
@@ -174,6 +174,8 @@ github.com/sagernet/sing v0.5.2 h1:2OZQJNKGtji/66QLxbf/T/dqtK/3+fF/zuHH9tsGK7M=
github.com/sagernet/sing v0.5.2/go.mod h1:ARkL0gM13/Iv5VCZmci/NuoOlePoIsW0m7BWfln/Hak=
github.com/sagernet/sing-mux v0.2.1 h1:N/3MHymfnFZRd29tE3TaXwPUVVgKvxhtOkiCMLp9HVo=
github.com/sagernet/sing-mux v0.2.1/go.mod h1:dm3BWL6NvES9pbib7llpylrq7Gq+LjlzG+0RacdxcyE=
github.com/sagernet/sing-shadowtls v0.1.5 h1:uXxmq/HXh8DIiBGLzpMjCbWnzIAFs+lIxiTOjdgG5qo=
github.com/sagernet/sing-shadowtls v0.1.5/go.mod h1:tvrDPTGLrSM46Wnf7mSr+L8NHvgvF8M4YnJF790rZX4=
github.com/sagernet/smux v0.0.0-20231208180855-7041f6ea79e7 h1:DImB4lELfQhplLTxeq2z31Fpv8CQqqrUwTbrIRumZqQ=
github.com/sagernet/smux v0.0.0-20231208180855-7041f6ea79e7/go.mod h1:FP9X2xjT/Az1EsG/orYYoC+5MojWnuI7hrffz8fGwwo=
github.com/samber/lo v1.49.1 h1:4BIFyVfuQSEpluc7Fua+j1NolZHiEHEpaSEKdsH0tew=

View File

@@ -442,10 +442,6 @@ func handleSetState(params string) {
_ = json.Unmarshal([]byte(params), state.CurrentState)
}
func handleCrash() {
panic("handle invoke crash")
}
func init() {
adapter.UrlTestHook = func(url string, name string, delay uint16) {
delayData := &Delay{

View File

@@ -1,18 +1,20 @@
import 'dart:async';
import 'package:dynamic_color/dynamic_color.dart';
import 'package:fl_clash/clash/clash.dart';
import 'package:fl_clash/common/common.dart';
import 'package:fl_clash/l10n/l10n.dart';
import 'package:fl_clash/manager/hotkey_manager.dart';
import 'package:fl_clash/manager/manager.dart';
import 'package:fl_clash/plugins/app.dart';
import 'package:fl_clash/providers/providers.dart';
import 'package:fl_clash/providers/config.dart';
import 'package:fl_clash/state.dart';
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'controller.dart';
import 'models/models.dart';
import 'pages/pages.dart';
class Application extends ConsumerStatefulWidget {
@@ -25,6 +27,7 @@ class Application extends ConsumerStatefulWidget {
}
class ApplicationState extends ConsumerState<Application> {
late ColorSchemes systemColorSchemes;
Timer? _autoUpdateGroupTaskTimer;
Timer? _autoUpdateProfilesTaskTimer;
@@ -40,8 +43,16 @@ class ApplicationState extends ConsumerState<Application> {
ColorScheme _getAppColorScheme({
required Brightness brightness,
int? primaryColor,
required ColorSchemes systemColorSchemes,
}) {
return ref.read(genColorSchemeProvider(brightness));
if (primaryColor != null) {
return ColorScheme.fromSeed(
seedColor: Color(primaryColor),
brightness: brightness,
);
} else {
return systemColorSchemes.getColorSchemeForBrightness(brightness);
}
}
@override
@@ -129,6 +140,19 @@ class ApplicationState extends ConsumerState<Application> {
);
}
_updateSystemColorSchemes(
ColorScheme? lightDynamic,
ColorScheme? darkDynamic,
) {
systemColorSchemes = ColorSchemes(
lightColorScheme: lightDynamic,
darkColorScheme: darkDynamic,
);
WidgetsBinding.instance.addPostFrameCallback((_) {
globalState.appController.updateSystemColorSchemes(systemColorSchemes);
});
}
@override
Widget build(context) {
return _buildPlatformState(
@@ -138,44 +162,51 @@ class ApplicationState extends ConsumerState<Application> {
final locale =
ref.watch(appSettingProvider.select((state) => state.locale));
final themeProps = ref.watch(themeSettingProvider);
return MaterialApp(
debugShowCheckedModeBanner: false,
navigatorKey: globalState.navigatorKey,
localizationsDelegates: const [
AppLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
GlobalWidgetsLocalizations.delegate
],
builder: (_, child) {
return AppEnvManager(
child: _buildPlatformApp(
_buildApp(child!),
return DynamicColorBuilder(
builder: (lightDynamic, darkDynamic) {
_updateSystemColorSchemes(lightDynamic, darkDynamic);
return MaterialApp(
debugShowCheckedModeBanner: false,
navigatorKey: globalState.navigatorKey,
localizationsDelegates: const [
AppLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
GlobalWidgetsLocalizations.delegate
],
builder: (_, child) {
return AppEnvManager(
child: _buildPlatformApp(
_buildApp(child!),
),
);
},
scrollBehavior: BaseScrollBehavior(),
title: appName,
locale: other.getLocaleForString(locale),
supportedLocales: AppLocalizations.delegate.supportedLocales,
themeMode: themeProps.themeMode,
theme: ThemeData(
useMaterial3: true,
pageTransitionsTheme: _pageTransitionsTheme,
colorScheme: _getAppColorScheme(
brightness: Brightness.light,
systemColorSchemes: systemColorSchemes,
primaryColor: themeProps.primaryColor,
),
),
darkTheme: ThemeData(
useMaterial3: true,
pageTransitionsTheme: _pageTransitionsTheme,
colorScheme: _getAppColorScheme(
brightness: Brightness.dark,
systemColorSchemes: systemColorSchemes,
primaryColor: themeProps.primaryColor,
).toPureBlack(themeProps.pureBlack),
),
home: child,
);
},
scrollBehavior: BaseScrollBehavior(),
title: appName,
locale: utils.getLocaleForString(locale),
supportedLocales: AppLocalizations.delegate.supportedLocales,
themeMode: themeProps.themeMode,
theme: ThemeData(
useMaterial3: true,
pageTransitionsTheme: _pageTransitionsTheme,
colorScheme: _getAppColorScheme(
brightness: Brightness.light,
primaryColor: themeProps.primaryColor,
),
),
darkTheme: ThemeData(
useMaterial3: true,
pageTransitionsTheme: _pageTransitionsTheme,
colorScheme: _getAppColorScheme(
brightness: Brightness.dark,
primaryColor: themeProps.primaryColor,
).toPureBlack(themeProps.pureBlack),
),
home: child,
);
},
child: const HomePage(),

View File

@@ -58,8 +58,6 @@ mixin ClashInterface {
stopLog();
Future<bool> crash();
FutureOr<String> getConnections();
FutureOr<bool> closeConnection(String id);
@@ -106,7 +104,6 @@ abstract class ClashHandlerInterface with ClashInterface {
case ActionMethod.closeConnection:
case ActionMethod.stopListener:
case ActionMethod.setState:
case ActionMethod.crash:
completer?.complete(result.data as bool);
return;
case ActionMethod.changeProxy:
@@ -154,7 +151,7 @@ abstract class ClashHandlerInterface with ClashInterface {
Duration? timeout,
FutureOr<T> Function()? onTimeout,
}) async {
final id = "${method.name}#${utils.id}";
final id = "${method.name}#${other.id}";
callbackCompleterMap[id] = Completer<T>();
@@ -245,14 +242,6 @@ abstract class ClashHandlerInterface with ClashInterface {
);
}
@override
Future<bool> crash() {
return invoke<bool>(
method: ActionMethod.crash,
);
}
@override
Future<String> getProxies() {
return invoke<String>(

View File

@@ -1,5 +1,3 @@
import 'dart:math';
import 'package:flutter/material.dart';
extension ColorExtension on Color {
@@ -39,54 +37,11 @@ extension ColorExtension on Color {
return withAlpha(0);
}
int get value32bit {
return _floatToInt8(a) << 24 |
_floatToInt8(r) << 16 |
_floatToInt8(g) << 8 |
_floatToInt8(b) << 0;
}
int get alpha8bit => (0xff000000 & value32bit) >> 24;
int get red8bit => (0x00ff0000 & value32bit) >> 16;
int get green8bit => (0x0000ff00 & value32bit) >> 8;
int get blue8bit => (0x000000ff & value32bit) >> 0;
int _floatToInt8(double x) {
return (x * 255.0).round() & 0xff;
}
Color lighten([double amount = 10]) {
if (amount <= 0) return this;
if (amount > 100) return Colors.white;
final HSLColor hsl = this == const Color(0xFF000000)
? HSLColor.fromColor(this).withSaturation(0)
: HSLColor.fromColor(this);
return hsl
.withLightness(min(1, max(0, hsl.lightness + amount / 100)))
.toColor();
}
String get hex {
final value = toARGB32();
final red = (value >> 16) & 0xFF;
final green = (value >> 8) & 0xFF;
final blue = value & 0xFF;
return '#${red.toRadixString(16).padLeft(2, '0')}'
'${green.toRadixString(16).padLeft(2, '0')}'
'${blue.toRadixString(16).padLeft(2, '0')}'
.toUpperCase();
}
Color darken([final int amount = 10]) {
if (amount <= 0) return this;
if (amount > 100) return Colors.black;
final HSLColor hsl = HSLColor.fromColor(this);
return hsl
.withLightness(min(1, max(0, hsl.lightness - amount / 100)))
.toColor();
Color darken([double amount = .1]) {
assert(amount >= 0 && amount <= 1);
final hsl = HSLColor.fromColor(this);
final hslDark = hsl.withLightness((hsl.lightness - amount).clamp(0.0, 1.0));
return hslDark.toColor();
}
Color blendDarken(
@@ -119,7 +74,7 @@ extension ColorSchemeExtension on ColorScheme {
? copyWith(
surface: Colors.black,
surfaceContainer: surfaceContainer.darken(
5,
0.05,
),
)
: this;

View File

@@ -19,7 +19,7 @@ export 'navigation.dart';
export 'navigator.dart';
export 'network.dart';
export 'num.dart';
export 'utils.dart';
export 'other.dart';
export 'package.dart';
export 'path.dart';
export 'picker.dart';

View File

@@ -78,7 +78,7 @@ const viewModeColumnsMap = {
ViewMode.desktop: [4, 3],
};
const defaultPrimaryColor = 0xFF795548;
const defaultPrimaryColor = Colors.brown;
double getWidgetHeight(num lines) {
return max(lines * 84 * textScaleFactor + (lines - 1) * 16, 0);
@@ -87,13 +87,3 @@ double getWidgetHeight(num lines) {
final mainIsolate = "FlClashMainIsolate";
final serviceIsolate = "FlClashServiceIsolate";
const defaultPrimaryColors = [
defaultPrimaryColor,
0xFF03A9F4,
0xFFFFFF00,
0XFFBBC9CC,
0XFFABD397,
0XFFD8C0C3,
0XFF665390,
];

View File

@@ -1,4 +1,4 @@
import 'package:fl_clash/manager/message_manager.dart';
import 'package:fl_clash/manager/manager.dart';
import 'package:fl_clash/widgets/scaffold.dart';
import 'package:flutter/material.dart';
@@ -11,36 +11,6 @@ extension BuildContextExtension on BuildContext {
return findAncestorStateOfType<MessageManagerState>()?.message(text);
}
showSnackBar(
String message, {
SnackBarAction? action,
}) {
final width = viewWidth;
EdgeInsets margin;
if (width < 600) {
margin = const EdgeInsets.only(
bottom: 16,
right: 16,
left: 16,
);
} else {
margin = EdgeInsets.only(
bottom: 16,
left: 16,
right: width - 316,
);
}
ScaffoldMessenger.of(this).showSnackBar(
SnackBar(
action: action,
content: Text(message),
behavior: SnackBarBehavior.floating,
duration: const Duration(milliseconds: 1500),
margin: margin,
),
);
}
Size get appSize {
return MediaQuery.of(this).size;
}
@@ -57,10 +27,10 @@ extension BuildContextExtension on BuildContext {
T? state;
visitor(Element element) {
if (!element.mounted) {
if(!element.mounted){
return;
}
if (element is StatefulElement) {
if(element is StatefulElement){
if (element.state is T) {
state = element.state as T;
}

View File

@@ -1,7 +1,6 @@
import 'dart:async';
import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:launch_at_startup/launch_at_startup.dart';
import 'constant.dart';
@@ -35,9 +34,6 @@ class AutoLaunch {
}
updateStatus(bool isAutoLaunch) async {
if(kDebugMode){
return;
}
if (await isEnable == isAutoLaunch) return;
if (isAutoLaunch == true) {
enable();

View File

@@ -7,7 +7,7 @@ import 'package:fl_clash/enum/enum.dart';
import 'package:flutter/material.dart';
import 'package:lpinyin/lpinyin.dart';
class Utils {
class Other {
Color? getDelayColor(int? delay) {
if (delay == null) return null;
if (delay < 0) return Colors.red;
@@ -233,63 +233,6 @@ class Utils {
return max((viewWidth / 350).floor(), 1);
}
final _indexPrimary = [
50,
100,
200,
300,
400,
500,
600,
700,
800,
850,
900,
];
_createPrimarySwatch(Color color) {
final Map<int, Color> swatch = <int, Color>{};
final int a = color.alpha8bit;
final int r = color.red8bit;
final int g = color.green8bit;
final int b = color.blue8bit;
for (final int strength in _indexPrimary) {
final double ds = 0.5 - strength / 1000;
swatch[strength] = Color.fromARGB(
a,
r + ((ds < 0 ? r : (255 - r)) * ds).round(),
g + ((ds < 0 ? g : (255 - g)) * ds).round(),
b + ((ds < 0 ? b : (255 - b)) * ds).round(),
);
}
swatch[50] = swatch[50]!.lighten(18);
swatch[100] = swatch[100]!.lighten(16);
swatch[200] = swatch[200]!.lighten(14);
swatch[300] = swatch[300]!.lighten(10);
swatch[400] = swatch[400]!.lighten(6);
swatch[700] = swatch[700]!.darken(2);
swatch[800] = swatch[800]!.darken(3);
swatch[900] = swatch[900]!.darken(4);
return MaterialColor(color.value32bit, swatch);
}
List<Color> getMaterialColorShades(Color color) {
final swatch = _createPrimarySwatch(color);
return <Color>[
if (swatch[50] != null) swatch[50]!,
if (swatch[100] != null) swatch[100]!,
if (swatch[200] != null) swatch[200]!,
if (swatch[300] != null) swatch[300]!,
if (swatch[400] != null) swatch[400]!,
if (swatch[500] != null) swatch[500]!,
if (swatch[600] != null) swatch[600]!,
if (swatch[700] != null) swatch[700]!,
if (swatch[800] != null) swatch[800]!,
if (swatch[850] != null) swatch[850]!,
if (swatch[900] != null) swatch[900]!,
];
}
String getBackupFileName() {
return "${appName}_backup_${DateTime.now().show}.zip";
}
@@ -325,4 +268,4 @@ class Utils {
}
}
final utils = Utils();
final other = Other();

View File

@@ -21,7 +21,7 @@ class CommonPrint {
}
globalState.appController.addLog(
Log(
logLevel: LogLevel.app,
logLevel: LogLevel.info,
payload: payload,
),
);

View File

@@ -54,4 +54,4 @@ class Render {
}
}
final Render? render = system.isDesktop ? Render() : null;
final render = system.isDesktop ? Render() : null;

View File

@@ -68,7 +68,7 @@ class Request {
final remoteVersion = data['tag_name'];
final version = globalState.packageInfo.version;
final hasUpdate =
utils.compareVersions(remoteVersion.replaceAll('v', ''), version) > 0;
other.compareVersions(remoteVersion.replaceAll('v', ''), version) > 0;
if (!hasUpdate) return null;
return data;
}

View File

@@ -1,6 +1,5 @@
import 'dart:io';
import 'package:fl_clash/common/utils.dart';
import 'package:fl_clash/enum/enum.dart';
import 'package:fl_clash/models/models.dart';
import 'package:fl_clash/state.dart';
@@ -11,6 +10,7 @@ import 'package:tray_manager/tray_manager.dart';
import 'app_localizations.dart';
import 'constant.dart';
import 'other.dart';
import 'window.dart';
class Tray {
@@ -25,7 +25,7 @@ class Tray {
await trayManager.destroy();
}
await trayManager.setIcon(
utils.getTrayIconPath(
other.getTrayIconPath(
brightness: brightness ??
WidgetsBinding.instance.platformDispatcher.platformBrightness,
),
@@ -80,7 +80,7 @@ class Tray {
);
}
menuItems.add(MenuItem.separator());
if (Platform.isMacOS) {
if (!Platform.isWindows) {
for (final group in trayState.groups) {
List<MenuItem> subMenuItems = [];
for (final proxy in group.all) {

View File

@@ -153,7 +153,7 @@ class AppController {
updateLocalIp() async {
_ref.read(localIpProvider.notifier).value = null;
await Future.delayed(commonDuration);
_ref.read(localIpProvider.notifier).value = await utils.getLocalIpAddress();
_ref.read(localIpProvider.notifier).value = await other.getLocalIpAddress();
}
Future<void> updateProfile(Profile profile) async {
@@ -345,16 +345,12 @@ class AppController {
}
Future<void> updateGroups() async {
try {
_ref.read(groupsProvider.notifier).value = await retry(
task: () async {
return await clashCore.getProxiesGroups();
},
retryIf: (res) => res.isEmpty,
);
} catch (_) {
_ref.read(groupsProvider.notifier).value = [];
}
_ref.read(groupsProvider.notifier).value = await retry(
task: () async {
return await clashCore.getProxiesGroups();
},
retryIf: (res) => res.isEmpty,
);
}
updateProfiles() async {
@@ -366,6 +362,10 @@ class AppController {
}
}
updateSystemColorSchemes(ColorSchemes colorSchemes) {
_ref.read(appSchemesProvider.notifier).value = colorSchemes;
}
savePreferences() async {
commonPrint.log("save preferences");
await preferences.saveConfig(globalState.config);
@@ -410,14 +410,6 @@ class AppController {
}
}
Future handleClear() async {
await preferences.clearPreferences();
commonPrint.log("clear preferences");
globalState.config = Config(
themeProps: defaultThemeProps,
);
}
autoCheckUpdate() async {
if (!_ref.read(appSettingProvider).autoCheckUpdate) return;
final res = await request.checkForUpdate();
@@ -434,7 +426,7 @@ class AppController {
if (data != null) {
final tagName = data['tag_name'];
final body = data['body'];
final submits = utils.parseReleaseBody(body);
final submits = other.parseReleaseBody(body);
final textTheme = context.textTheme;
final res = await globalState.showMessage(
title: appLocalizations.discoverNewVersion,
@@ -679,9 +671,9 @@ class AppController {
List<Proxy> _sortOfName(List<Proxy> proxies) {
return List.of(proxies)
..sort(
(a, b) => utils.sortByChar(
utils.getPinyin(a.name),
utils.getPinyin(b.name),
(a, b) => other.sortByChar(
other.getPinyin(a.name),
other.getPinyin(b.name),
),
);
}
@@ -871,7 +863,7 @@ class AppController {
return utf8.encode(logsRawString);
});
return await picker.saveFile(
utils.logFile,
other.logFile,
Uint8List.fromList(data),
) !=
null;

View File

@@ -91,14 +91,7 @@ enum Mode { rule, global, direct }
enum ViewMode { mobile, laptop, desktop }
enum LogLevel {
debug,
info,
warning,
error,
silent,
app,
}
enum LogLevel { debug, info, warning, error, silent }
enum TransportProtocol { udp, tcp }
@@ -269,7 +262,6 @@ enum ActionMethod {
getCountryCode,
getMemory,
getProfile,
crash,
///Android,
setFdMap,
@@ -316,12 +308,6 @@ enum DashboardWidget {
child: NetworkSpeed(),
),
),
outboundModeV2(
GridItem(
crossAxisCellCount: 8,
child: OutboundModeV2(),
),
),
outboundMode(
GridItem(
crossAxisCellCount: 4,

View File

@@ -1,11 +1,7 @@
import 'dart:async';
import 'package:fl_clash/common/common.dart';
import 'package:fl_clash/providers/config.dart';
import 'package:fl_clash/state.dart';
import 'package:fl_clash/widgets/list.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
@immutable
class Contributor {
@@ -120,43 +116,33 @@ class AboutFragment extends StatelessWidget {
title: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Consumer(builder: (_, ref, ___) {
return _DeveloperModeDetector(
child: Wrap(
spacing: 16,
crossAxisAlignment: WrapCrossAlignment.center,
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: [
Padding(
padding: const EdgeInsets.all(12),
child: Image.asset(
'assets/images/icon.png',
width: 64,
height: 64,
),
Text(
appName,
style: Theme.of(context).textTheme.headlineSmall,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
appName,
style: Theme.of(context).textTheme.headlineSmall,
),
Text(
globalState.packageInfo.version,
style: Theme.of(context).textTheme.labelLarge,
)
],
Text(
globalState.packageInfo.version,
style: Theme.of(context).textTheme.labelLarge,
)
],
),
onEnterDeveloperMode: () {
ref.read(appSettingProvider.notifier).updateState(
(state) => state.copyWith(developerMode: true),
);
context.showNotifier(appLocalizations.developerModeEnableTip);
},
);
}),
)
],
),
const SizedBox(
height: 24,
),
@@ -223,52 +209,3 @@ class Avatar extends StatelessWidget {
);
}
}
class _DeveloperModeDetector extends StatefulWidget {
final Widget child;
final VoidCallback onEnterDeveloperMode;
const _DeveloperModeDetector({
required this.child,
required this.onEnterDeveloperMode,
});
@override
State<_DeveloperModeDetector> createState() => _DeveloperModeDetectorState();
}
class _DeveloperModeDetectorState extends State<_DeveloperModeDetector> {
int _counter = 0;
Timer? _timer;
void _handleTap() {
_counter++;
if (_counter >= 5) {
widget.onEnterDeveloperMode();
_resetCounter();
} else {
_timer?.cancel();
_timer = Timer(Duration(seconds: 1), _resetCounter);
}
}
void _resetCounter() {
_counter = 0;
_timer?.cancel();
_timer = null;
}
@override
void dispose() {
_timer?.cancel();
super.dispose();
}
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: _handleTap,
child: widget.child,
);
}
}

View File

@@ -75,7 +75,7 @@ class BackupAndRecovery extends ConsumerWidget {
() async {
final backupData = await globalState.appController.backupData();
final value = await picker.saveFile(
utils.getBackupFileName(),
other.getBackupFileName(),
Uint8List.fromList(backupData),
);
if (value == null) return false;

View File

@@ -61,6 +61,7 @@ class _ConfigFragmentState extends State<ConfigFragment> {
if (res != true) {
return;
}
ref.read(patchClashConfigProvider.notifier).updateState(
(state) => state.copyWith(
dns: defaultDns,

View File

@@ -11,6 +11,8 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'item.dart';
double _preOffset = 0;
class RequestsFragment extends ConsumerStatefulWidget {
const RequestsFragment({super.key});
@@ -24,8 +26,10 @@ class _RequestsFragmentState extends ConsumerState<RequestsFragment>
final _requestsStateNotifier =
ValueNotifier<ConnectionsState>(const ConnectionsState());
List<Connection> _requests = [];
final _cacheKey = ValueKey("requests_list");
late ScrollController _scrollController;
final ScrollController _scrollController = ScrollController(
initialScrollOffset: _preOffset != 0 ? _preOffset : double.maxFinite,
);
double _currentMaxWidth = 0;
@@ -45,13 +49,10 @@ class _RequestsFragmentState extends ConsumerState<RequestsFragment>
@override
void initState() {
super.initState();
final preOffset = globalState.cacheScrollPosition[_cacheKey] ?? -1;
_scrollController = ScrollController(
initialScrollOffset: preOffset > 0 ? preOffset : double.maxFinite,
);
_requestsStateNotifier.value = _requestsStateNotifier.value.copyWith(
connections: globalState.appState.requests.list,
);
ref.listenManual(
isCurrentPageProvider(
PageLabel.requests,
@@ -176,10 +177,11 @@ class _RequestsFragmentState extends ConsumerState<RequestsFragment>
.toList();
return Align(
alignment: Alignment.topCenter,
child: ScrollToEndBox(
controller: _scrollController,
cacheKey: _cacheKey,
dataSource: connections,
child: NotificationListener<ScrollEndNotification>(
onNotification: (details) {
_preOffset = details.metrics.pixels;
return false;
},
child: CommonScrollBar(
controller: _scrollController,
child: CacheItemExtentListView(

View File

@@ -93,7 +93,7 @@ class _DashboardFragmentState extends ConsumerState<DashboardFragment>
@override
Widget build(BuildContext context) {
final dashboardState = ref.watch(dashboardStateProvider);
final columns = max(4 * ((dashboardState.viewWidth / 320).ceil()), 8);
final columns = max(4 * ((dashboardState.viewWidth / 350).ceil()), 8);
return Align(
alignment: Alignment.topCenter,
child: SingleChildScrollView(

View File

@@ -72,63 +72,3 @@ class OutboundMode extends StatelessWidget {
);
}
}
class OutboundModeV2 extends StatelessWidget {
const OutboundModeV2({super.key});
@override
Widget build(BuildContext context) {
final height = getWidgetHeight(0.72);
return SizedBox(
height: height,
child: CommonCard(
child: Consumer(
builder: (_, ref, __) {
final mode = ref.watch(
patchClashConfigProvider.select(
(state) => state.mode,
),
);
final thumbColor = switch (mode) {
Mode.rule => context.colorScheme.secondaryContainer,
Mode.global => globalState.theme.darken3PrimaryContainer,
Mode.direct => context.colorScheme.tertiaryContainer,
};
return Container(
constraints: BoxConstraints.expand(),
child: CommonTabBar<Mode>(
children: Map.fromEntries(
Mode.values.map(
(item) => MapEntry(
item,
Container(
alignment: Alignment.center,
height: height - 16,
child: Text(
Intl.message(item.name),
style: Theme.of(context)
.textTheme
.titleSmall
?.adjustSize(1),
),
),
),
),
),
padding: EdgeInsets.symmetric(horizontal: 8),
groupValue: mode,
onValueChanged: (value) {
if (value == null) {
return;
}
globalState.appController.changeMode(value);
},
thumbColor: thumbColor,
),
);
},
),
),
);
}
}

View File

@@ -71,10 +71,10 @@ class _StartButtonState extends State<StartButton>
final textWidth = globalState.measure
.computeTextSize(
Text(
utils.getTimeDifference(
other.getTimeDifference(
DateTime.now(),
),
style: context.textTheme.titleMedium?.toSoftBold,
style: Theme.of(context).textTheme.titleMedium?.toSoftBold,
),
)
.width +
@@ -123,12 +123,10 @@ class _StartButtonState extends State<StartButton>
child: Consumer(
builder: (_, ref, __) {
final runTime = ref.watch(runTimeProvider);
final text = utils.getTimeText(runTime);
final text = other.getTimeText(runTime);
return Text(
text,
style: Theme.of(context).textTheme.titleMedium?.toSoftBold.copyWith(
color: context.colorScheme.onPrimaryContainer
),
style: Theme.of(context).textTheme.titleMedium?.toSoftBold,
);
},
),

View File

@@ -1,86 +0,0 @@
import 'package:fl_clash/clash/core.dart';
import 'package:fl_clash/common/common.dart';
import 'package:fl_clash/enum/enum.dart';
import 'package:fl_clash/providers/config.dart';
import 'package:fl_clash/state.dart';
import 'package:fl_clash/widgets/widgets.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
class DeveloperView extends ConsumerWidget {
const DeveloperView({super.key});
Widget _getDeveloperList(BuildContext context) {
return generateSectionV2(
title: appLocalizations.options,
items: [
ListItem(
leading: Icon(Icons.ac_unit),
title: Text(appLocalizations.messageTest),
onTap: () {
context.showNotifier(
appLocalizations.messageTestTip,
);
},
),
ListItem(
leading: Icon(Icons.heart_broken),
title: Text(appLocalizations.crashTest),
onTap: () {
clashCore.clashInterface.crash();
},
),
ListItem(
leading: Icon(Icons.delete_forever),
title: Text(appLocalizations.clearData),
onTap: () async {
await globalState.appController.handleClear();
},
)
],
);
}
@override
Widget build(BuildContext context, ref) {
final enable = ref.watch(
appSettingProvider.select(
(state) => state.developerMode,
),
);
return SingleChildScrollView(
padding: baseInfoEdgeInsets,
child: Column(
children: [
CommonCard(
type: CommonCardType.filled,
radius: 18,
child: ListItem.switchItem(
padding: const EdgeInsets.only(
left: 16,
right: 16,
top: 4,
bottom: 4,
),
title: Text(appLocalizations.developerMode),
delegate: SwitchDelegate(
value: enable,
onChanged: (value) {
ref.read(appSettingProvider.notifier).updateState(
(state) => state.copyWith(
developerMode: value,
),
);
},
),
),
),
SizedBox(
height: 16,
),
_getDeveloperList(context)
],
),
);
}
}

View File

@@ -11,4 +11,3 @@ export 'backup_and_recovery.dart';
export 'resources.dart';
export 'connection/requests.dart';
export 'connection/connections.dart';
export 'developer.dart';

View File

@@ -8,6 +8,8 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../models/models.dart';
import '../widgets/widgets.dart';
double _preOffset = 0;
class LogsFragment extends ConsumerStatefulWidget {
const LogsFragment({super.key});
@@ -17,8 +19,9 @@ class LogsFragment extends ConsumerStatefulWidget {
class _LogsFragmentState extends ConsumerState<LogsFragment> with PageMixin {
final _logsStateNotifier = ValueNotifier<LogsState>(LogsState());
final _cacheKey = ValueKey("logs_list");
late ScrollController _scrollController;
final _scrollController = ScrollController(
initialScrollOffset: _preOffset != 0 ? _preOffset : double.maxFinite,
);
double _currentMaxWidth = 0;
final GlobalKey<CacheItemExtentListViewState> _key = GlobalKey();
@@ -27,10 +30,6 @@ class _LogsFragmentState extends ConsumerState<LogsFragment> with PageMixin {
@override
void initState() {
super.initState();
final preOffset = globalState.cacheScrollPosition[_cacheKey] ?? -1;
_scrollController = ScrollController(
initialScrollOffset: preOffset > 0 ? preOffset : double.maxFinite,
);
_logsStateNotifier.value = _logsStateNotifier.value.copyWith(
logs: globalState.appState.logs.list,
);
@@ -181,10 +180,11 @@ class _LogsFragmentState extends ConsumerState<LogsFragment> with PageMixin {
),
)
.toList();
return ScrollToEndBox<Log>(
controller: _scrollController,
cacheKey: _cacheKey,
dataSource: logs,
return NotificationListener<ScrollEndNotification>(
onNotification: (details) {
_preOffset = details.metrics.pixels;
return false;
},
child: CommonScrollBar(
controller: _scrollController,
child: CacheItemExtentListView(

View File

@@ -104,13 +104,8 @@ class _URLFormDialogState extends State<URLFormDialog> {
runSpacing: 16,
children: [
TextField(
keyboardType: TextInputType.url,
minLines: 1,
maxLines: 5,
onSubmitted: (_) {
_handleAddProfileFormURL();
},
onEditingComplete: _handleAddProfileFormURL,
minLines: 1,
controller: urlController,
decoration: InputDecoration(
border: const OutlineInputBorder(),

View File

@@ -214,7 +214,6 @@ class _EditProfileState extends State<EditProfile> {
final items = [
ListItem(
title: TextFormField(
textInputAction: TextInputAction.next,
controller: labelController,
decoration: InputDecoration(
border: const OutlineInputBorder(),
@@ -231,8 +230,6 @@ class _EditProfileState extends State<EditProfile> {
if (widget.profile.type == ProfileType.url) ...[
ListItem(
title: TextFormField(
textInputAction: TextInputAction.next,
keyboardType: TextInputType.url,
controller: urlController,
maxLines: 5,
minLines: 1,
@@ -261,7 +258,6 @@ class _EditProfileState extends State<EditProfile> {
if (autoUpdate)
ListItem(
title: TextFormField(
textInputAction: TextInputAction.next,
controller: autoUpdateDurationController,
decoration: InputDecoration(
border: const OutlineInputBorder(),

View File

@@ -873,8 +873,6 @@ class _AddRuleDialogState extends State<AddRuleDialog> {
builder: (filed) {
return DropdownMenu(
width: 200,
enableFilter: false,
enableSearch: false,
controller: _subRuleController,
label: Text(appLocalizations.subRule),
menuHeight: 250,
@@ -892,11 +890,11 @@ class _AddRuleDialogState extends State<AddRuleDialog> {
builder: (filed) {
return DropdownMenu(
controller: _ruleTargetController,
initialSelection: filed.value,
label: Text(appLocalizations.ruleTarget),
width: 200,
menuHeight: 250,
enableFilter: false,
enableSearch: false,
enableFilter: true,
dropdownMenuEntries: _targetItems,
errorText: filed.errorText,
);

View File

@@ -63,7 +63,7 @@ class ProxyCard extends StatelessWidget {
delay > 0 ? '$delay ms' : "Timeout",
style: context.textTheme.labelSmall?.copyWith(
overflow: TextOverflow.ellipsis,
color: utils.getDelayColor(
color: other.getDelayColor(
delay,
),
),

View File

@@ -1,16 +1,9 @@
import 'dart:math';
import 'dart:ui' as ui;
import 'package:fl_clash/common/common.dart';
import 'package:fl_clash/enum/enum.dart';
import 'package:fl_clash/models/selector.dart';
import 'package:fl_clash/providers/config.dart';
import 'package:fl_clash/state.dart';
import 'package:fl_clash/widgets/widgets.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:intl/intl.dart';
class ThemeModeItem {
final ThemeMode themeMode;
@@ -39,20 +32,39 @@ class ThemeFragment extends StatelessWidget {
@override
Widget build(BuildContext context) {
return SingleChildScrollView(child: ThemeColorsBox());
final previewCard = Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: CommonCard(
onPressed: () {},
info: Info(
label: appLocalizations.preview,
iconData: Icons.looks,
),
child: Container(
height: 200,
),
),
);
return SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
previewCard,
const ThemeColorsBox(),
],
),
);
}
}
class ItemCard extends StatelessWidget {
final Widget child;
final Info info;
final List<Widget> actions;
const ItemCard({
super.key,
required this.info,
required this.child,
this.actions = const [],
});
@override
@@ -66,7 +78,6 @@ class ItemCard extends StatelessWidget {
children: [
InfoHeader(
info: info,
actions: actions,
),
child,
],
@@ -87,6 +98,7 @@ class _ThemeColorsBoxState extends ConsumerState<ThemeColorsBox> {
Widget build(BuildContext context) {
return Column(
children: [
// _FontFamilyItem(),
_ThemeModeItem(),
_PrimaryColorItem(),
_PrueBlackItem(),
@@ -98,6 +110,75 @@ class _ThemeColorsBoxState extends ConsumerState<ThemeColorsBox> {
}
}
// class _FontFamilyItem extends ConsumerWidget {
// const _FontFamilyItem();
//
// @override
// Widget build(BuildContext context, WidgetRef ref) {
// final fontFamily =
// ref.watch(themeSettingProvider.select((state) => state.fontFamily));
// List<FontFamilyItem> fontFamilyItems = [
// FontFamilyItem(
// label: appLocalizations.systemFont,
// fontFamily: FontFamily.system,
// ),
// const FontFamilyItem(
// label: "roboto",
// fontFamily: FontFamily.roboto,
// ),
// ];
// return ItemCard(
// info: Info(
// label: appLocalizations.fontFamily,
// iconData: Icons.text_fields,
// ),
// child: Container(
// margin: const EdgeInsets.only(
// left: 16,
// right: 16,
// ),
// height: 48,
// child: ListView.separated(
// scrollDirection: Axis.horizontal,
// itemBuilder: (_, index) {
// final fontFamilyItem = fontFamilyItems[index];
// return CommonCard(
// isSelected: fontFamilyItem.fontFamily == fontFamily,
// onPressed: () {
// ref.read(themeSettingProvider.notifier).updateState(
// (state) => state.copyWith(
// fontFamily: fontFamilyItem.fontFamily,
// ),
// );
// },
// child: Padding(
// padding: const EdgeInsets.symmetric(horizontal: 16),
// child: Row(
// mainAxisSize: MainAxisSize.min,
// mainAxisAlignment: MainAxisAlignment.start,
// children: [
// Flexible(
// child: Text(
// fontFamilyItem.label,
// ),
// ),
// ],
// ),
// ),
// );
// },
// separatorBuilder: (_, __) {
// return const SizedBox(
// width: 16,
// );
// },
// itemCount: fontFamilyItems.length,
// ),
// ),
// );
// }
// }
class _ThemeModeItem extends ConsumerWidget {
const _ThemeModeItem();
@@ -129,7 +210,7 @@ class _ThemeModeItem extends ConsumerWidget {
),
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 16),
height: 56,
height: 64,
child: ListView.separated(
scrollDirection: Axis.horizontal,
itemCount: themeModeItems.length,
@@ -177,270 +258,56 @@ class _ThemeModeItem extends ConsumerWidget {
}
}
class _PrimaryColorItem extends ConsumerStatefulWidget {
class _PrimaryColorItem extends ConsumerWidget {
const _PrimaryColorItem();
@override
ConsumerState<_PrimaryColorItem> createState() => _PrimaryColorItemState();
}
class _PrimaryColorItemState extends ConsumerState<_PrimaryColorItem> {
int? _removablePrimaryColor;
int _calcColumns(double maxWidth) {
return max((maxWidth / 96).ceil(), 3);
}
_handleReset() async {
final res = await globalState.showMessage(
message: TextSpan(
text: appLocalizations.resetTip,
Widget build(BuildContext context, WidgetRef ref) {
final primaryColor =
ref.watch(themeSettingProvider.select((state) => state.primaryColor));
List<Color?> primaryColors = [
null,
defaultPrimaryColor,
Colors.pinkAccent,
Colors.lightBlue,
Colors.greenAccent,
Colors.yellowAccent,
Colors.purple,
];
return ItemCard(
info: Info(
label: appLocalizations.themeColor,
iconData: Icons.palette,
),
);
if (res != true) {
return;
}
ref.read(themeSettingProvider.notifier).updateState(
(state) {
return state.copyWith(
primaryColors: defaultPrimaryColors,
primaryColor: defaultPrimaryColor,
schemeVariant: DynamicSchemeVariant.tonalSpot,
);
},
);
}
_handleDel() async {
if (_removablePrimaryColor == null) {
return;
}
final res = await globalState.showMessage(
message: TextSpan(text: appLocalizations.deleteColorTip));
if (res != true) {
return;
}
ref.read(themeSettingProvider.notifier).updateState(
(state) {
final newPrimaryColors = List<int>.from(state.primaryColors)
..remove(_removablePrimaryColor);
int? newPrimaryColor = state.primaryColor;
if (state.primaryColor == _removablePrimaryColor) {
if (newPrimaryColors.contains(defaultPrimaryColor)) {
newPrimaryColor = defaultPrimaryColor;
} else {
newPrimaryColor = null;
}
}
return state.copyWith(
primaryColors: newPrimaryColors,
primaryColor: newPrimaryColor,
);
},
);
setState(() {
_removablePrimaryColor = null;
});
}
_handleAdd() async {
final res = await globalState.showCommonDialog<int>(
child: _PaletteDialog(),
);
if (res == null) {
return;
}
final isExists = ref.read(
themeSettingProvider.select((state) => state.primaryColors.contains(res)),
);
if (isExists && mounted) {
context.showNotifier(appLocalizations.colorExists);
return;
}
ref.read(themeSettingProvider.notifier).updateState(
(state) {
return state.copyWith(
primaryColors: List.from(
state.primaryColors,
)..add(res),
);
},
);
}
_handleChangeSchemeVariant() async {
final schemeVariant = ref.read(
themeSettingProvider.select(
(state) => state.schemeVariant,
),
);
final value = await globalState.showCommonDialog<DynamicSchemeVariant>(
child: OptionsDialog<DynamicSchemeVariant>(
title: appLocalizations.colorSchemes,
options: DynamicSchemeVariant.values,
textBuilder: (item) => Intl.message("${item.name}Scheme"),
value: schemeVariant,
),
);
if (value == null) {
return;
}
ref.read(themeSettingProvider.notifier).updateState(
(state) {
return state.copyWith(
schemeVariant: value,
);
},
);
}
@override
Widget build(BuildContext context) {
final vm3 = ref.watch(
themeSettingProvider.select(
(state) => VM3(
a: state.primaryColor,
b: state.primaryColors,
c: state.schemeVariant,
child: Container(
margin: const EdgeInsets.only(
left: 16,
right: 16,
bottom: 16,
),
),
);
final primaryColor = vm3.a;
final primaryColors = [null, ...vm3.b];
final schemeVariant = vm3.c;
return CommonPopScope(
onPop: () {
if (_removablePrimaryColor != null) {
setState(() {
_removablePrimaryColor = null;
});
return false;
}
return true;
},
child: ItemCard(
info: Info(
label: appLocalizations.themeColor,
iconData: Icons.palette,
),
actions: genActions(
[
if (_removablePrimaryColor == null)
FilledButton(
style: ButtonStyle(
visualDensity: VisualDensity.compact,
),
onPressed: _handleChangeSchemeVariant,
child: Text(Intl.message("${schemeVariant.name}Scheme")),
),
_removablePrimaryColor != null
? FilledButton(
style: ButtonStyle(
visualDensity: VisualDensity.compact,
),
onPressed: () {
setState(() {
_removablePrimaryColor = null;
});
},
child: Text(appLocalizations.cancel),
)
: IconButton.filledTonal(
iconSize: 20,
padding: EdgeInsets.all(4),
visualDensity: VisualDensity.compact,
onPressed: _handleReset,
icon: Icon(Icons.replay),
)
],
space: 8,
),
child: Container(
margin: const EdgeInsets.only(
left: 16,
right: 16,
bottom: 16,
),
child: LayoutBuilder(
builder: (_, constraints) {
final columns = _calcColumns(constraints.maxWidth);
final itemWidth =
(constraints.maxWidth - (columns - 1) * 16) / columns;
return Wrap(
spacing: 16,
runSpacing: 16,
children: [
for (final color in primaryColors)
Container(
clipBehavior: Clip.none,
width: itemWidth,
height: itemWidth,
child: Stack(
alignment: Alignment.center,
clipBehavior: Clip.none,
children: [
EffectGestureDetector(
child: ColorSchemeBox(
isSelected: color == primaryColor,
primaryColor: color != null ? Color(color) : null,
onPressed: () {
setState(() {
_removablePrimaryColor = null;
});
ref
.read(themeSettingProvider.notifier)
.updateState(
(state) => state.copyWith(
primaryColor: color,
),
);
},
),
onLongPress: () {
setState(() {
_removablePrimaryColor = color;
});
},
),
if (_removablePrimaryColor != null &&
_removablePrimaryColor == color)
Container(
color: Colors.white.opacity0,
padding: EdgeInsets.all(8),
child: IconButton.filledTonal(
onPressed: _handleDel,
padding: EdgeInsets.all(12),
iconSize: 30,
icon: Icon(
color: context.colorScheme.primary,
Icons.delete,
),
),
),
],
height: 88,
child: ListView.separated(
scrollDirection: Axis.horizontal,
itemBuilder: (_, index) {
final color = primaryColors[index];
return ColorSchemeBox(
isSelected: color?.toARGB32() == primaryColor,
primaryColor: color,
onPressed: () {
ref.read(themeSettingProvider.notifier).updateState(
(state) => state.copyWith(
primaryColor: color?.toARGB32(),
),
),
if (_removablePrimaryColor == null)
Container(
width: itemWidth,
height: itemWidth,
padding: EdgeInsets.all(
4,
),
child: IconButton.filledTonal(
onPressed: _handleAdd,
iconSize: 32,
icon: Icon(
color: context.colorScheme.primary,
Icons.add,
),
),
)
],
);
},
),
);
},
);
},
separatorBuilder: (_, __) {
return const SizedBox(
width: 16,
);
},
itemCount: primaryColors.length,
),
),
);
@@ -459,14 +326,9 @@ class _PrueBlackItem extends ConsumerWidget {
child: ListItem.switchItem(
leading: Icon(
Icons.contrast,
color: context.colorScheme.primary,
),
horizontalTitleGap: 12,
title: Text(
appLocalizations.pureBlackMode,
style: Theme.of(context).textTheme.titleSmall?.copyWith(
color: context.colorScheme.onSurfaceVariant,
),
),
title: Text(appLocalizations.pureBlackMode),
delegate: SwitchDelegate(
value: prueBlack,
onChanged: (value) {
@@ -481,66 +343,3 @@ class _PrueBlackItem extends ConsumerWidget {
);
}
}
class _PaletteDialog extends StatefulWidget {
const _PaletteDialog();
@override
State<_PaletteDialog> createState() => _PaletteDialogState();
}
class _PaletteDialogState extends State<_PaletteDialog> {
final _controller = ValueNotifier<ui.Color>(Colors.transparent);
@override
Widget build(BuildContext context) {
return CommonDialog(
title: appLocalizations.palette,
actions: [
TextButton(
onPressed: () {
Navigator.of(context).pop();
},
child: Text(appLocalizations.cancel),
),
TextButton(
onPressed: () {
Navigator.of(context).pop(_controller.value.toARGB32());
},
child: Text(appLocalizations.confirm),
),
],
child: Column(
children: [
SizedBox(
height: 8,
),
SizedBox(
width: 250,
height: 250,
child: Palette(
controller: _controller,
),
),
SizedBox(
height: 24,
),
ValueListenableBuilder(
valueListenable: _controller,
builder: (_, color, __) {
return PrimaryColorBox(
primaryColor: color,
child: FilledButton(
onPressed: () {},
child: Text(
_controller.value.hex,
),
),
);
},
),
],
),
);
}
}

View File

@@ -14,7 +14,6 @@ import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:intl/intl.dart';
import 'backup_and_recovery.dart';
import 'developer.dart';
import 'theme.dart';
import 'package:path/path.dart' show dirname, join;
@@ -55,12 +54,11 @@ class _ToolboxFragmentState extends ConsumerState<ToolsFragment> {
);
}
List<Widget> _getOtherList(bool enableDeveloperMode) {
List<Widget> _getOtherList() {
return generateSection(
title: appLocalizations.other,
items: [
_DisclaimerItem(),
if (enableDeveloperMode) _DeveloperItem(),
_InfoItem(),
],
);
@@ -84,11 +82,7 @@ class _ToolboxFragmentState extends ConsumerState<ToolsFragment> {
@override
Widget build(BuildContext context) {
final vm2 = ref.watch(
appSettingProvider.select(
(state) => VM2(a: state.locale, b: state.developerMode),
),
);
ref.watch(appSettingProvider.select((state) => state.locale));
final items = [
Consumer(
builder: (_, ref, __) {
@@ -105,7 +99,7 @@ class _ToolboxFragmentState extends ConsumerState<ToolsFragment> {
},
),
..._getSettingList(),
..._getOtherList(vm2.b),
..._getOtherList(),
];
return ListView.builder(
itemCount: items.length,
@@ -128,7 +122,7 @@ class _LocaleItem extends ConsumerWidget {
final locale =
ref.watch(appSettingProvider.select((state) => state.locale));
final subTitle = locale ?? appLocalizations.defaultText;
final currentLocale = utils.getLocaleForString(locale);
final currentLocale = other.getLocaleForString(locale);
return ListItem<Locale?>.options(
leading: const Icon(Icons.language_outlined),
title: Text(appLocalizations.language),
@@ -303,19 +297,3 @@ class _InfoItem extends StatelessWidget {
);
}
}
class _DeveloperItem extends StatelessWidget {
const _DeveloperItem();
@override
Widget build(BuildContext context) {
return ListItem.open(
leading: const Icon(Icons.developer_mode),
title: Text(appLocalizations.developerMode),
delegate: OpenDelegate(
title: appLocalizations.developerMode,
widget: const DeveloperView(),
),
);
}
}

View File

@@ -372,24 +372,5 @@
"generalDesc": "Modify general settings",
"findProcessModeDesc": "There is a certain performance loss after opening",
"tabAnimationDesc": "Effective only in mobile view",
"saveTip": "Are you sure you want to save?",
"deleteColorTip": "Are you sure you want to delete the current color?",
"colorExists": "Current color already exists",
"colorSchemes": "Color schemes",
"palette": "Palette",
"tonalSpotScheme": "TonalSpot",
"fidelityScheme": "Fidelity",
"monochromeScheme": "Monochrome",
"neutralScheme": "Neutral",
"vibrantScheme": "Vibrant",
"expressiveScheme": "Expressive",
"contentScheme": "Content",
"rainbowScheme": "Rainbow",
"fruitSaladScheme": "FruitSalad",
"developerMode": "Developer mode",
"developerModeEnableTip": "Developer mode is enabled.",
"messageTest": "Message test",
"messageTestTip": "This is a message.",
"crashTest": "Crash test",
"clearData": "Clear Data"
"saveTip": "Are you sure you want to save?"
}

View File

@@ -372,24 +372,5 @@
"generalDesc": "一般設定を変更",
"findProcessModeDesc": "有効化するとパフォーマンスが若干低下します",
"tabAnimationDesc": "モバイル表示でのみ有効",
"saveTip": "保存してもよろしいですか?",
"deleteColorTip": "現在の色を削除しますか?",
"colorExists": "この色は既に存在します",
"colorSchemes": "カラースキーム",
"palette": "パレット",
"tonalSpotScheme": "トーンスポット",
"fidelityScheme": "ハイファイデリティー",
"monochromeScheme": "モノクローム",
"neutralScheme": "ニュートラル",
"vibrantScheme": "ビブラント",
"expressiveScheme": "エクスプレッシブ",
"contentScheme": "コンテンツテーマ",
"rainbowScheme": "レインボー",
"fruitSaladScheme": "フルーツサラダ",
"developerMode": "デベロッパーモード",
"developerModeEnableTip": "デベロッパーモードが有効になりました。",
"messageTest": "メッセージテスト",
"messageTestTip": "これはメッセージです。",
"crashTest": "クラッシュテスト",
"clearData": "データを消去"
"saveTip": "保存してもよろしいですか?"
}

View File

@@ -372,24 +372,5 @@
"generalDesc": "Изменение общих настроек",
"findProcessModeDesc": "При включении возможны небольшие потери производительности",
"tabAnimationDesc": "Действительно только в мобильном виде",
"saveTip": "Вы уверены, что хотите сохранить?",
"deleteColorTip": "Удалить текущий цвет?",
"colorExists": "Этот цвет уже существует",
"colorSchemes": "Цветовые схемы",
"palette": "Палитра",
"tonalSpotScheme": "Тональный акцент",
"fidelityScheme": "Точная передача",
"monochromeScheme": "Монохром",
"neutralScheme": "Нейтральные",
"vibrantScheme": "Яркие",
"expressiveScheme": "Экспрессивные",
"contentScheme": "Контентная тема",
"rainbowScheme": "Радужные",
"fruitSaladScheme": "Фруктовый микс",
"developerMode": "Режим разработчика",
"developerModeEnableTip": "Режим разработчика активирован.",
"messageTest": "Тестирование сообщения",
"messageTestTip": "Это сообщение.",
"crashTest": "Тест на сбои",
"clearData": "Очистить данные"
"saveTip": "Вы уверены, что хотите сохранить?"
}

View File

@@ -372,24 +372,5 @@
"generalDesc": "修改通用设置",
"findProcessModeDesc": "开启后会有一定性能损耗",
"tabAnimationDesc": "仅在移动视图中有效",
"saveTip": "确定要保存吗?",
"deleteColorTip": "确定删除当前颜色吗?",
"colorExists": "该颜色已存在",
"colorSchemes": "配色方案",
"palette": "调色板",
"tonalSpotScheme": "调性点缀",
"fidelityScheme": "高保真",
"monochromeScheme": "单色",
"neutralScheme": "中性",
"vibrantScheme": "活力",
"expressiveScheme": "表现力",
"contentScheme": "内容主题",
"rainbowScheme": "彩虹",
"fruitSaladScheme": "果缤纷",
"developerMode": "开发者模式",
"developerModeEnableTip": "开发者模式已启用。",
"messageTest": "消息测试",
"messageTestTip": "这是一条消息。",
"crashTest": "崩溃测试",
"clearData": "清除数据"
"saveTip": "确定要保存吗?"
}

View File

@@ -146,13 +146,8 @@ class MessageLookup extends MessageLookupByLibrary {
"The current application is already the latest version",
),
"checking": MessageLookupByLibrary.simpleMessage("Checking..."),
"clearData": MessageLookupByLibrary.simpleMessage("Clear Data"),
"clipboardExport": MessageLookupByLibrary.simpleMessage("Export clipboard"),
"clipboardImport": MessageLookupByLibrary.simpleMessage("Clipboard import"),
"colorExists": MessageLookupByLibrary.simpleMessage(
"Current color already exists",
),
"colorSchemes": MessageLookupByLibrary.simpleMessage("Color schemes"),
"columns": MessageLookupByLibrary.simpleMessage("Columns"),
"compatible": MessageLookupByLibrary.simpleMessage("Compatibility mode"),
"compatibleDesc": MessageLookupByLibrary.simpleMessage(
@@ -168,7 +163,6 @@ class MessageLookup extends MessageLookupByLibrary {
"contentEmptyTip": MessageLookupByLibrary.simpleMessage(
"Content cannot be empty",
),
"contentScheme": MessageLookupByLibrary.simpleMessage("Content"),
"copy": MessageLookupByLibrary.simpleMessage("Copy"),
"copyEnvVar": MessageLookupByLibrary.simpleMessage(
"Copying environment variables",
@@ -178,7 +172,6 @@ class MessageLookup extends MessageLookupByLibrary {
"core": MessageLookupByLibrary.simpleMessage("Core"),
"coreInfo": MessageLookupByLibrary.simpleMessage("Core info"),
"country": MessageLookupByLibrary.simpleMessage("Country"),
"crashTest": MessageLookupByLibrary.simpleMessage("Crash test"),
"create": MessageLookupByLibrary.simpleMessage("Create"),
"cut": MessageLookupByLibrary.simpleMessage("Cut"),
"dark": MessageLookupByLibrary.simpleMessage("Dark"),
@@ -195,9 +188,6 @@ class MessageLookup extends MessageLookupByLibrary {
"delay": MessageLookupByLibrary.simpleMessage("Delay"),
"delaySort": MessageLookupByLibrary.simpleMessage("Sort by delay"),
"delete": MessageLookupByLibrary.simpleMessage("Delete"),
"deleteColorTip": MessageLookupByLibrary.simpleMessage(
"Are you sure you want to delete the current color?",
),
"deleteProfileTip": MessageLookupByLibrary.simpleMessage(
"Sure you want to delete the current profile?",
),
@@ -210,10 +200,6 @@ class MessageLookup extends MessageLookupByLibrary {
"detectionTip": MessageLookupByLibrary.simpleMessage(
"Relying on third-party api is for reference only",
),
"developerMode": MessageLookupByLibrary.simpleMessage("Developer mode"),
"developerModeEnableTip": MessageLookupByLibrary.simpleMessage(
"Developer mode is enabled.",
),
"direct": MessageLookupByLibrary.simpleMessage("Direct"),
"disclaimer": MessageLookupByLibrary.simpleMessage("Disclaimer"),
"disclaimerDesc": MessageLookupByLibrary.simpleMessage(
@@ -248,7 +234,6 @@ class MessageLookup extends MessageLookupByLibrary {
"exportFile": MessageLookupByLibrary.simpleMessage("Export file"),
"exportLogs": MessageLookupByLibrary.simpleMessage("Export logs"),
"exportSuccess": MessageLookupByLibrary.simpleMessage("Export Success"),
"expressiveScheme": MessageLookupByLibrary.simpleMessage("Expressive"),
"externalController": MessageLookupByLibrary.simpleMessage(
"ExternalController",
),
@@ -266,7 +251,6 @@ class MessageLookup extends MessageLookupByLibrary {
"Generally use offshore DNS",
),
"fallbackFilter": MessageLookupByLibrary.simpleMessage("Fallback filter"),
"fidelityScheme": MessageLookupByLibrary.simpleMessage("Fidelity"),
"file": MessageLookupByLibrary.simpleMessage("File"),
"fileDesc": MessageLookupByLibrary.simpleMessage("Directly upload profile"),
"fileIsUpdate": MessageLookupByLibrary.simpleMessage(
@@ -281,7 +265,6 @@ class MessageLookup extends MessageLookupByLibrary {
),
"fontFamily": MessageLookupByLibrary.simpleMessage("FontFamily"),
"fourColumns": MessageLookupByLibrary.simpleMessage("Four columns"),
"fruitSaladScheme": MessageLookupByLibrary.simpleMessage("FruitSalad"),
"general": MessageLookupByLibrary.simpleMessage("General"),
"generalDesc": MessageLookupByLibrary.simpleMessage(
"Modify general settings",
@@ -368,10 +351,6 @@ class MessageLookup extends MessageLookupByLibrary {
),
"loose": MessageLookupByLibrary.simpleMessage("Loose"),
"memoryInfo": MessageLookupByLibrary.simpleMessage("Memory info"),
"messageTest": MessageLookupByLibrary.simpleMessage("Message test"),
"messageTestTip": MessageLookupByLibrary.simpleMessage(
"This is a message.",
),
"min": MessageLookupByLibrary.simpleMessage("Min"),
"minimizeOnExit": MessageLookupByLibrary.simpleMessage("Minimize on exit"),
"minimizeOnExitDesc": MessageLookupByLibrary.simpleMessage(
@@ -379,7 +358,6 @@ class MessageLookup extends MessageLookupByLibrary {
),
"minutes": MessageLookupByLibrary.simpleMessage("Minutes"),
"mode": MessageLookupByLibrary.simpleMessage("Mode"),
"monochromeScheme": MessageLookupByLibrary.simpleMessage("Monochrome"),
"months": MessageLookupByLibrary.simpleMessage("Months"),
"more": MessageLookupByLibrary.simpleMessage("More"),
"name": MessageLookupByLibrary.simpleMessage("Name"),
@@ -402,7 +380,6 @@ class MessageLookup extends MessageLookupByLibrary {
"Network detection",
),
"networkSpeed": MessageLookupByLibrary.simpleMessage("Network speed"),
"neutralScheme": MessageLookupByLibrary.simpleMessage("Neutral"),
"noData": MessageLookupByLibrary.simpleMessage("No data"),
"noHotKey": MessageLookupByLibrary.simpleMessage("No HotKey"),
"noIcon": MessageLookupByLibrary.simpleMessage("None"),
@@ -459,7 +436,6 @@ class MessageLookup extends MessageLookupByLibrary {
"overrideOriginRules": MessageLookupByLibrary.simpleMessage(
"Override the original rule",
),
"palette": MessageLookupByLibrary.simpleMessage("Palette"),
"password": MessageLookupByLibrary.simpleMessage("Password"),
"passwordTip": MessageLookupByLibrary.simpleMessage(
"Password cannot be empty",
@@ -530,7 +506,6 @@ class MessageLookup extends MessageLookupByLibrary {
"qrcodeDesc": MessageLookupByLibrary.simpleMessage(
"Scan QR code to obtain profile",
),
"rainbowScheme": MessageLookupByLibrary.simpleMessage("Rainbow"),
"recovery": MessageLookupByLibrary.simpleMessage("Recovery"),
"recoveryAll": MessageLookupByLibrary.simpleMessage("Recovery all data"),
"recoveryProfiles": MessageLookupByLibrary.simpleMessage(
@@ -648,7 +623,6 @@ class MessageLookup extends MessageLookupByLibrary {
"time": MessageLookupByLibrary.simpleMessage("Time"),
"tip": MessageLookupByLibrary.simpleMessage("tip"),
"toggle": MessageLookupByLibrary.simpleMessage("Toggle"),
"tonalSpotScheme": MessageLookupByLibrary.simpleMessage("TonalSpot"),
"tools": MessageLookupByLibrary.simpleMessage("Tools"),
"trafficUsage": MessageLookupByLibrary.simpleMessage("Traffic usage"),
"tun": MessageLookupByLibrary.simpleMessage("TUN"),
@@ -677,7 +651,6 @@ class MessageLookup extends MessageLookupByLibrary {
"valueExists": MessageLookupByLibrary.simpleMessage(
"The current value already exists",
),
"vibrantScheme": MessageLookupByLibrary.simpleMessage("Vibrant"),
"view": MessageLookupByLibrary.simpleMessage("View"),
"vpnDesc": MessageLookupByLibrary.simpleMessage(
"Modify VPN related settings",

View File

@@ -104,11 +104,8 @@ class MessageLookup extends MessageLookupByLibrary {
"checkUpdate": MessageLookupByLibrary.simpleMessage("更新を確認"),
"checkUpdateError": MessageLookupByLibrary.simpleMessage("アプリは最新版です"),
"checking": MessageLookupByLibrary.simpleMessage("確認中..."),
"clearData": MessageLookupByLibrary.simpleMessage("データを消去"),
"clipboardExport": MessageLookupByLibrary.simpleMessage("クリップボードにエクスポート"),
"clipboardImport": MessageLookupByLibrary.simpleMessage("クリップボードからインポート"),
"colorExists": MessageLookupByLibrary.simpleMessage("この色は既に存在します"),
"colorSchemes": MessageLookupByLibrary.simpleMessage("カラースキーム"),
"columns": MessageLookupByLibrary.simpleMessage(""),
"compatible": MessageLookupByLibrary.simpleMessage("互換モード"),
"compatibleDesc": MessageLookupByLibrary.simpleMessage(
@@ -120,7 +117,6 @@ class MessageLookup extends MessageLookupByLibrary {
"connectivity": MessageLookupByLibrary.simpleMessage("接続性:"),
"content": MessageLookupByLibrary.simpleMessage("内容"),
"contentEmptyTip": MessageLookupByLibrary.simpleMessage("内容は必須です"),
"contentScheme": MessageLookupByLibrary.simpleMessage("コンテンツテーマ"),
"copy": MessageLookupByLibrary.simpleMessage("コピー"),
"copyEnvVar": MessageLookupByLibrary.simpleMessage("環境変数をコピー"),
"copyLink": MessageLookupByLibrary.simpleMessage("リンクをコピー"),
@@ -128,7 +124,6 @@ class MessageLookup extends MessageLookupByLibrary {
"core": MessageLookupByLibrary.simpleMessage("コア"),
"coreInfo": MessageLookupByLibrary.simpleMessage("コア情報"),
"country": MessageLookupByLibrary.simpleMessage(""),
"crashTest": MessageLookupByLibrary.simpleMessage("クラッシュテスト"),
"create": MessageLookupByLibrary.simpleMessage("作成"),
"cut": MessageLookupByLibrary.simpleMessage("切り取り"),
"dark": MessageLookupByLibrary.simpleMessage("ダーク"),
@@ -143,7 +138,6 @@ class MessageLookup extends MessageLookupByLibrary {
"delay": MessageLookupByLibrary.simpleMessage("遅延"),
"delaySort": MessageLookupByLibrary.simpleMessage("遅延順"),
"delete": MessageLookupByLibrary.simpleMessage("削除"),
"deleteColorTip": MessageLookupByLibrary.simpleMessage("現在の色を削除しますか?"),
"deleteProfileTip": MessageLookupByLibrary.simpleMessage(
"現在のプロファイルを削除しますか?",
),
@@ -152,10 +146,6 @@ class MessageLookup extends MessageLookupByLibrary {
"ClashMetaベースのマルチプラットフォームプロキシクライアント。シンプルで使いやすく、オープンソースで広告なし。",
),
"detectionTip": MessageLookupByLibrary.simpleMessage("サードパーティAPIに依存参考値"),
"developerMode": MessageLookupByLibrary.simpleMessage("デベロッパーモード"),
"developerModeEnableTip": MessageLookupByLibrary.simpleMessage(
"デベロッパーモードが有効になりました。",
),
"direct": MessageLookupByLibrary.simpleMessage("ダイレクト"),
"disclaimer": MessageLookupByLibrary.simpleMessage("免責事項"),
"disclaimerDesc": MessageLookupByLibrary.simpleMessage(
@@ -182,7 +172,6 @@ class MessageLookup extends MessageLookupByLibrary {
"exportFile": MessageLookupByLibrary.simpleMessage("ファイルをエクスポート"),
"exportLogs": MessageLookupByLibrary.simpleMessage("ログをエクスポート"),
"exportSuccess": MessageLookupByLibrary.simpleMessage("エクスポート成功"),
"expressiveScheme": MessageLookupByLibrary.simpleMessage("エクスプレッシブ"),
"externalController": MessageLookupByLibrary.simpleMessage("外部コントローラー"),
"externalControllerDesc": MessageLookupByLibrary.simpleMessage(
"有効化するとClashコアをポート9090で制御可能",
@@ -194,7 +183,6 @@ class MessageLookup extends MessageLookupByLibrary {
"fallback": MessageLookupByLibrary.simpleMessage("フォールバック"),
"fallbackDesc": MessageLookupByLibrary.simpleMessage("通常はオフショアDNSを使用"),
"fallbackFilter": MessageLookupByLibrary.simpleMessage("フォールバックフィルター"),
"fidelityScheme": MessageLookupByLibrary.simpleMessage("ハイファイデリティー"),
"file": MessageLookupByLibrary.simpleMessage("ファイル"),
"fileDesc": MessageLookupByLibrary.simpleMessage("プロファイルを直接アップロード"),
"fileIsUpdate": MessageLookupByLibrary.simpleMessage(
@@ -207,7 +195,6 @@ class MessageLookup extends MessageLookupByLibrary {
),
"fontFamily": MessageLookupByLibrary.simpleMessage("フォントファミリー"),
"fourColumns": MessageLookupByLibrary.simpleMessage("4列"),
"fruitSaladScheme": MessageLookupByLibrary.simpleMessage("フルーツサラダ"),
"general": MessageLookupByLibrary.simpleMessage("一般"),
"generalDesc": MessageLookupByLibrary.simpleMessage("一般設定を変更"),
"geoData": MessageLookupByLibrary.simpleMessage("地域データ"),
@@ -264,8 +251,6 @@ class MessageLookup extends MessageLookupByLibrary {
"loopbackDesc": MessageLookupByLibrary.simpleMessage("UWPループバック解除用"),
"loose": MessageLookupByLibrary.simpleMessage(""),
"memoryInfo": MessageLookupByLibrary.simpleMessage("メモリ情報"),
"messageTest": MessageLookupByLibrary.simpleMessage("メッセージテスト"),
"messageTestTip": MessageLookupByLibrary.simpleMessage("これはメッセージです。"),
"min": MessageLookupByLibrary.simpleMessage("最小化"),
"minimizeOnExit": MessageLookupByLibrary.simpleMessage("終了時に最小化"),
"minimizeOnExitDesc": MessageLookupByLibrary.simpleMessage(
@@ -273,7 +258,6 @@ class MessageLookup extends MessageLookupByLibrary {
),
"minutes": MessageLookupByLibrary.simpleMessage(""),
"mode": MessageLookupByLibrary.simpleMessage("モード"),
"monochromeScheme": MessageLookupByLibrary.simpleMessage("モノクローム"),
"months": MessageLookupByLibrary.simpleMessage(""),
"more": MessageLookupByLibrary.simpleMessage("詳細"),
"name": MessageLookupByLibrary.simpleMessage("名前"),
@@ -288,7 +272,6 @@ class MessageLookup extends MessageLookupByLibrary {
"networkDesc": MessageLookupByLibrary.simpleMessage("ネットワーク関連設定の変更"),
"networkDetection": MessageLookupByLibrary.simpleMessage("ネットワーク検出"),
"networkSpeed": MessageLookupByLibrary.simpleMessage("ネットワーク速度"),
"neutralScheme": MessageLookupByLibrary.simpleMessage("ニュートラル"),
"noData": MessageLookupByLibrary.simpleMessage("データなし"),
"noHotKey": MessageLookupByLibrary.simpleMessage("ホットキーなし"),
"noIcon": MessageLookupByLibrary.simpleMessage("なし"),
@@ -331,7 +314,6 @@ class MessageLookup extends MessageLookupByLibrary {
"有効化するとプロファイルのDNS設定を上書き",
),
"overrideOriginRules": MessageLookupByLibrary.simpleMessage("元のルールを上書き"),
"palette": MessageLookupByLibrary.simpleMessage("パレット"),
"password": MessageLookupByLibrary.simpleMessage("パスワード"),
"passwordTip": MessageLookupByLibrary.simpleMessage("パスワードは必須です"),
"paste": MessageLookupByLibrary.simpleMessage("貼り付け"),
@@ -388,7 +370,6 @@ class MessageLookup extends MessageLookupByLibrary {
"pureBlackMode": MessageLookupByLibrary.simpleMessage("純黒モード"),
"qrcode": MessageLookupByLibrary.simpleMessage("QRコード"),
"qrcodeDesc": MessageLookupByLibrary.simpleMessage("QRコードをスキャンしてプロファイルを取得"),
"rainbowScheme": MessageLookupByLibrary.simpleMessage("レインボー"),
"recovery": MessageLookupByLibrary.simpleMessage("復元"),
"recoveryAll": MessageLookupByLibrary.simpleMessage("全データ復元"),
"recoveryProfiles": MessageLookupByLibrary.simpleMessage("プロファイルのみ復元"),
@@ -480,7 +461,6 @@ class MessageLookup extends MessageLookupByLibrary {
"time": MessageLookupByLibrary.simpleMessage("時間"),
"tip": MessageLookupByLibrary.simpleMessage("ヒント"),
"toggle": MessageLookupByLibrary.simpleMessage("トグル"),
"tonalSpotScheme": MessageLookupByLibrary.simpleMessage("トーンスポット"),
"tools": MessageLookupByLibrary.simpleMessage("ツール"),
"trafficUsage": MessageLookupByLibrary.simpleMessage("トラフィック使用量"),
"tun": MessageLookupByLibrary.simpleMessage("TUN"),
@@ -503,7 +483,6 @@ class MessageLookup extends MessageLookupByLibrary {
"useSystemHosts": MessageLookupByLibrary.simpleMessage("システムホストを使用"),
"value": MessageLookupByLibrary.simpleMessage(""),
"valueExists": MessageLookupByLibrary.simpleMessage("現在の値は既に存在します"),
"vibrantScheme": MessageLookupByLibrary.simpleMessage("ビブラント"),
"view": MessageLookupByLibrary.simpleMessage("表示"),
"vpnDesc": MessageLookupByLibrary.simpleMessage("VPN関連設定の変更"),
"vpnEnableDesc": MessageLookupByLibrary.simpleMessage(

View File

@@ -148,17 +148,12 @@ class MessageLookup extends MessageLookupByLibrary {
"Текущее приложение уже является последней версией",
),
"checking": MessageLookupByLibrary.simpleMessage("Проверка..."),
"clearData": MessageLookupByLibrary.simpleMessage("Очистить данные"),
"clipboardExport": MessageLookupByLibrary.simpleMessage(
"Экспорт в буфер обмена",
),
"clipboardImport": MessageLookupByLibrary.simpleMessage(
"Импорт из буфера обмена",
),
"colorExists": MessageLookupByLibrary.simpleMessage(
"Этот цвет уже существует",
),
"colorSchemes": MessageLookupByLibrary.simpleMessage("Цветовые схемы"),
"columns": MessageLookupByLibrary.simpleMessage("Столбцы"),
"compatible": MessageLookupByLibrary.simpleMessage("Режим совместимости"),
"compatibleDesc": MessageLookupByLibrary.simpleMessage(
@@ -174,7 +169,6 @@ class MessageLookup extends MessageLookupByLibrary {
"contentEmptyTip": MessageLookupByLibrary.simpleMessage(
"Содержание не может быть пустым",
),
"contentScheme": MessageLookupByLibrary.simpleMessage("Контентная тема"),
"copy": MessageLookupByLibrary.simpleMessage("Копировать"),
"copyEnvVar": MessageLookupByLibrary.simpleMessage(
"Копирование переменных окружения",
@@ -184,7 +178,6 @@ class MessageLookup extends MessageLookupByLibrary {
"core": MessageLookupByLibrary.simpleMessage("Ядро"),
"coreInfo": MessageLookupByLibrary.simpleMessage("Информация о ядре"),
"country": MessageLookupByLibrary.simpleMessage("Страна"),
"crashTest": MessageLookupByLibrary.simpleMessage("Тест на сбои"),
"create": MessageLookupByLibrary.simpleMessage("Создать"),
"cut": MessageLookupByLibrary.simpleMessage("Вырезать"),
"dark": MessageLookupByLibrary.simpleMessage("Темный"),
@@ -203,9 +196,6 @@ class MessageLookup extends MessageLookupByLibrary {
"delay": MessageLookupByLibrary.simpleMessage("Задержка"),
"delaySort": MessageLookupByLibrary.simpleMessage("Сортировка по задержке"),
"delete": MessageLookupByLibrary.simpleMessage("Удалить"),
"deleteColorTip": MessageLookupByLibrary.simpleMessage(
"Удалить текущий цвет?",
),
"deleteProfileTip": MessageLookupByLibrary.simpleMessage(
"Вы уверены, что хотите удалить текущий профиль?",
),
@@ -218,10 +208,6 @@ class MessageLookup extends MessageLookupByLibrary {
"detectionTip": MessageLookupByLibrary.simpleMessage(
"Опирается на сторонний API, только для справки",
),
"developerMode": MessageLookupByLibrary.simpleMessage("Режим разработчика"),
"developerModeEnableTip": MessageLookupByLibrary.simpleMessage(
"Режим разработчика активирован.",
),
"direct": MessageLookupByLibrary.simpleMessage("Прямой"),
"disclaimer": MessageLookupByLibrary.simpleMessage(
"Отказ от ответственности",
@@ -262,7 +248,6 @@ class MessageLookup extends MessageLookupByLibrary {
"exportFile": MessageLookupByLibrary.simpleMessage("Экспорт файла"),
"exportLogs": MessageLookupByLibrary.simpleMessage("Экспорт логов"),
"exportSuccess": MessageLookupByLibrary.simpleMessage("Экспорт успешен"),
"expressiveScheme": MessageLookupByLibrary.simpleMessage("Экспрессивные"),
"externalController": MessageLookupByLibrary.simpleMessage(
"Внешний контроллер",
),
@@ -282,7 +267,6 @@ class MessageLookup extends MessageLookupByLibrary {
"fallbackFilter": MessageLookupByLibrary.simpleMessage(
"Фильтр резервного DNS",
),
"fidelityScheme": MessageLookupByLibrary.simpleMessage("Точная передача"),
"file": MessageLookupByLibrary.simpleMessage("Файл"),
"fileDesc": MessageLookupByLibrary.simpleMessage("Прямая загрузка профиля"),
"fileIsUpdate": MessageLookupByLibrary.simpleMessage(
@@ -299,7 +283,6 @@ class MessageLookup extends MessageLookupByLibrary {
),
"fontFamily": MessageLookupByLibrary.simpleMessage("Семейство шрифтов"),
"fourColumns": MessageLookupByLibrary.simpleMessage("Четыре столбца"),
"fruitSaladScheme": MessageLookupByLibrary.simpleMessage("Фруктовый микс"),
"general": MessageLookupByLibrary.simpleMessage("Общие"),
"generalDesc": MessageLookupByLibrary.simpleMessage(
"Изменение общих настроек",
@@ -392,10 +375,6 @@ class MessageLookup extends MessageLookupByLibrary {
),
"loose": MessageLookupByLibrary.simpleMessage("Свободный"),
"memoryInfo": MessageLookupByLibrary.simpleMessage("Информация о памяти"),
"messageTest": MessageLookupByLibrary.simpleMessage(
"Тестирование сообщения",
),
"messageTestTip": MessageLookupByLibrary.simpleMessage("Это сообщение."),
"min": MessageLookupByLibrary.simpleMessage("Мин"),
"minimizeOnExit": MessageLookupByLibrary.simpleMessage(
"Свернуть при выходе",
@@ -405,7 +384,6 @@ class MessageLookup extends MessageLookupByLibrary {
),
"minutes": MessageLookupByLibrary.simpleMessage("Минут"),
"mode": MessageLookupByLibrary.simpleMessage("Режим"),
"monochromeScheme": MessageLookupByLibrary.simpleMessage("Монохром"),
"months": MessageLookupByLibrary.simpleMessage("Месяцев"),
"more": MessageLookupByLibrary.simpleMessage("Еще"),
"name": MessageLookupByLibrary.simpleMessage("Имя"),
@@ -428,7 +406,6 @@ class MessageLookup extends MessageLookupByLibrary {
"Обнаружение сети",
),
"networkSpeed": MessageLookupByLibrary.simpleMessage("Скорость сети"),
"neutralScheme": MessageLookupByLibrary.simpleMessage("Нейтральные"),
"noData": MessageLookupByLibrary.simpleMessage("Нет данных"),
"noHotKey": MessageLookupByLibrary.simpleMessage("Нет горячей клавиши"),
"noIcon": MessageLookupByLibrary.simpleMessage("Нет иконки"),
@@ -489,7 +466,6 @@ class MessageLookup extends MessageLookupByLibrary {
"overrideOriginRules": MessageLookupByLibrary.simpleMessage(
"Переопределить оригинальное правило",
),
"palette": MessageLookupByLibrary.simpleMessage("Палитра"),
"password": MessageLookupByLibrary.simpleMessage("Пароль"),
"passwordTip": MessageLookupByLibrary.simpleMessage(
"Пароль не может быть пустым",
@@ -562,7 +538,6 @@ class MessageLookup extends MessageLookupByLibrary {
"qrcodeDesc": MessageLookupByLibrary.simpleMessage(
"Сканируйте QR-код для получения профиля",
),
"rainbowScheme": MessageLookupByLibrary.simpleMessage("Радужные"),
"recovery": MessageLookupByLibrary.simpleMessage("Восстановление"),
"recoveryAll": MessageLookupByLibrary.simpleMessage(
"Восстановить все данные",
@@ -686,7 +661,6 @@ class MessageLookup extends MessageLookupByLibrary {
"time": MessageLookupByLibrary.simpleMessage("Время"),
"tip": MessageLookupByLibrary.simpleMessage("подсказка"),
"toggle": MessageLookupByLibrary.simpleMessage("Переключить"),
"tonalSpotScheme": MessageLookupByLibrary.simpleMessage("Тональный акцент"),
"tools": MessageLookupByLibrary.simpleMessage("Инструменты"),
"trafficUsage": MessageLookupByLibrary.simpleMessage(
"Использование трафика",
@@ -721,7 +695,6 @@ class MessageLookup extends MessageLookupByLibrary {
"valueExists": MessageLookupByLibrary.simpleMessage(
"Текущее значение уже существует",
),
"vibrantScheme": MessageLookupByLibrary.simpleMessage("Яркие"),
"view": MessageLookupByLibrary.simpleMessage("Просмотр"),
"vpnDesc": MessageLookupByLibrary.simpleMessage(
"Изменение настроек, связанных с VPN",

View File

@@ -94,11 +94,8 @@ class MessageLookup extends MessageLookupByLibrary {
"checkUpdate": MessageLookupByLibrary.simpleMessage("检查更新"),
"checkUpdateError": MessageLookupByLibrary.simpleMessage("当前应用已经是最新版了"),
"checking": MessageLookupByLibrary.simpleMessage("检测中..."),
"clearData": MessageLookupByLibrary.simpleMessage("清除数据"),
"clipboardExport": MessageLookupByLibrary.simpleMessage("导出剪贴板"),
"clipboardImport": MessageLookupByLibrary.simpleMessage("剪贴板导入"),
"colorExists": MessageLookupByLibrary.simpleMessage("该颜色已存在"),
"colorSchemes": MessageLookupByLibrary.simpleMessage("配色方案"),
"columns": MessageLookupByLibrary.simpleMessage("列数"),
"compatible": MessageLookupByLibrary.simpleMessage("兼容模式"),
"compatibleDesc": MessageLookupByLibrary.simpleMessage(
@@ -110,7 +107,6 @@ class MessageLookup extends MessageLookupByLibrary {
"connectivity": MessageLookupByLibrary.simpleMessage("连通性:"),
"content": MessageLookupByLibrary.simpleMessage("内容"),
"contentEmptyTip": MessageLookupByLibrary.simpleMessage("内容不能为空"),
"contentScheme": MessageLookupByLibrary.simpleMessage("内容主题"),
"copy": MessageLookupByLibrary.simpleMessage("复制"),
"copyEnvVar": MessageLookupByLibrary.simpleMessage("复制环境变量"),
"copyLink": MessageLookupByLibrary.simpleMessage("复制链接"),
@@ -118,7 +114,6 @@ class MessageLookup extends MessageLookupByLibrary {
"core": MessageLookupByLibrary.simpleMessage("内核"),
"coreInfo": MessageLookupByLibrary.simpleMessage("内核信息"),
"country": MessageLookupByLibrary.simpleMessage("区域"),
"crashTest": MessageLookupByLibrary.simpleMessage("崩溃测试"),
"create": MessageLookupByLibrary.simpleMessage("创建"),
"cut": MessageLookupByLibrary.simpleMessage("剪切"),
"dark": MessageLookupByLibrary.simpleMessage("深色"),
@@ -131,15 +126,12 @@ class MessageLookup extends MessageLookupByLibrary {
"delay": MessageLookupByLibrary.simpleMessage("延迟"),
"delaySort": MessageLookupByLibrary.simpleMessage("按延迟排序"),
"delete": MessageLookupByLibrary.simpleMessage("删除"),
"deleteColorTip": MessageLookupByLibrary.simpleMessage("确定删除当前颜色吗?"),
"deleteProfileTip": MessageLookupByLibrary.simpleMessage("确定要删除当前配置吗?"),
"deleteRuleTip": MessageLookupByLibrary.simpleMessage("确定要删除选中的规则吗?"),
"desc": MessageLookupByLibrary.simpleMessage(
"基于ClashMeta的多平台代理客户端简单易用开源无广告。",
),
"detectionTip": MessageLookupByLibrary.simpleMessage("依赖第三方api仅供参考"),
"developerMode": MessageLookupByLibrary.simpleMessage("开发者模式"),
"developerModeEnableTip": MessageLookupByLibrary.simpleMessage("开发者模式已启用。"),
"direct": MessageLookupByLibrary.simpleMessage("直连"),
"disclaimer": MessageLookupByLibrary.simpleMessage("免责声明"),
"disclaimerDesc": MessageLookupByLibrary.simpleMessage(
@@ -164,7 +156,6 @@ class MessageLookup extends MessageLookupByLibrary {
"exportFile": MessageLookupByLibrary.simpleMessage("导出文件"),
"exportLogs": MessageLookupByLibrary.simpleMessage("导出日志"),
"exportSuccess": MessageLookupByLibrary.simpleMessage("导出成功"),
"expressiveScheme": MessageLookupByLibrary.simpleMessage("表现力"),
"externalController": MessageLookupByLibrary.simpleMessage("外部控制器"),
"externalControllerDesc": MessageLookupByLibrary.simpleMessage(
"开启后将可以通过9090端口控制Clash内核",
@@ -176,7 +167,6 @@ class MessageLookup extends MessageLookupByLibrary {
"fallback": MessageLookupByLibrary.simpleMessage("Fallback"),
"fallbackDesc": MessageLookupByLibrary.simpleMessage("一般情况下使用境外DNS"),
"fallbackFilter": MessageLookupByLibrary.simpleMessage("Fallback过滤"),
"fidelityScheme": MessageLookupByLibrary.simpleMessage("高保真"),
"file": MessageLookupByLibrary.simpleMessage("文件"),
"fileDesc": MessageLookupByLibrary.simpleMessage("直接上传配置文件"),
"fileIsUpdate": MessageLookupByLibrary.simpleMessage("文件有修改,是否保存修改"),
@@ -185,7 +175,6 @@ class MessageLookup extends MessageLookupByLibrary {
"findProcessModeDesc": MessageLookupByLibrary.simpleMessage("开启后会有一定性能损耗"),
"fontFamily": MessageLookupByLibrary.simpleMessage("字体"),
"fourColumns": MessageLookupByLibrary.simpleMessage("四列"),
"fruitSaladScheme": MessageLookupByLibrary.simpleMessage("果缤纷"),
"general": MessageLookupByLibrary.simpleMessage("常规"),
"generalDesc": MessageLookupByLibrary.simpleMessage("修改通用设置"),
"geoData": MessageLookupByLibrary.simpleMessage("地理数据"),
@@ -236,14 +225,11 @@ class MessageLookup extends MessageLookupByLibrary {
"loopbackDesc": MessageLookupByLibrary.simpleMessage("用于UWP回环解锁"),
"loose": MessageLookupByLibrary.simpleMessage("宽松"),
"memoryInfo": MessageLookupByLibrary.simpleMessage("内存信息"),
"messageTest": MessageLookupByLibrary.simpleMessage("消息测试"),
"messageTestTip": MessageLookupByLibrary.simpleMessage("这是一条消息。"),
"min": MessageLookupByLibrary.simpleMessage("最小"),
"minimizeOnExit": MessageLookupByLibrary.simpleMessage("退出时最小化"),
"minimizeOnExitDesc": MessageLookupByLibrary.simpleMessage("修改系统默认退出事件"),
"minutes": MessageLookupByLibrary.simpleMessage("分钟"),
"mode": MessageLookupByLibrary.simpleMessage("模式"),
"monochromeScheme": MessageLookupByLibrary.simpleMessage("单色"),
"months": MessageLookupByLibrary.simpleMessage(""),
"more": MessageLookupByLibrary.simpleMessage("更多"),
"name": MessageLookupByLibrary.simpleMessage("名称"),
@@ -256,7 +242,6 @@ class MessageLookup extends MessageLookupByLibrary {
"networkDesc": MessageLookupByLibrary.simpleMessage("修改网络相关设置"),
"networkDetection": MessageLookupByLibrary.simpleMessage("网络检测"),
"networkSpeed": MessageLookupByLibrary.simpleMessage("网络速度"),
"neutralScheme": MessageLookupByLibrary.simpleMessage("中性"),
"noData": MessageLookupByLibrary.simpleMessage("暂无数据"),
"noHotKey": MessageLookupByLibrary.simpleMessage("暂无快捷键"),
"noIcon": MessageLookupByLibrary.simpleMessage("无图标"),
@@ -291,7 +276,6 @@ class MessageLookup extends MessageLookupByLibrary {
"overrideDns": MessageLookupByLibrary.simpleMessage("覆写DNS"),
"overrideDnsDesc": MessageLookupByLibrary.simpleMessage("开启后将覆盖配置中的DNS选项"),
"overrideOriginRules": MessageLookupByLibrary.simpleMessage("覆盖原始规则"),
"palette": MessageLookupByLibrary.simpleMessage("调色板"),
"password": MessageLookupByLibrary.simpleMessage("密码"),
"passwordTip": MessageLookupByLibrary.simpleMessage("密码不能为空"),
"paste": MessageLookupByLibrary.simpleMessage("粘贴"),
@@ -340,7 +324,6 @@ class MessageLookup extends MessageLookupByLibrary {
"pureBlackMode": MessageLookupByLibrary.simpleMessage("纯黑模式"),
"qrcode": MessageLookupByLibrary.simpleMessage("二维码"),
"qrcodeDesc": MessageLookupByLibrary.simpleMessage("扫描二维码获取配置文件"),
"rainbowScheme": MessageLookupByLibrary.simpleMessage("彩虹"),
"recovery": MessageLookupByLibrary.simpleMessage("恢复"),
"recoveryAll": MessageLookupByLibrary.simpleMessage("恢复所有数据"),
"recoveryProfiles": MessageLookupByLibrary.simpleMessage("仅恢复配置文件"),
@@ -422,7 +405,6 @@ class MessageLookup extends MessageLookupByLibrary {
"time": MessageLookupByLibrary.simpleMessage("时间"),
"tip": MessageLookupByLibrary.simpleMessage("提示"),
"toggle": MessageLookupByLibrary.simpleMessage("切换"),
"tonalSpotScheme": MessageLookupByLibrary.simpleMessage("调性点缀"),
"tools": MessageLookupByLibrary.simpleMessage("工具"),
"trafficUsage": MessageLookupByLibrary.simpleMessage("流量统计"),
"tun": MessageLookupByLibrary.simpleMessage("虚拟网卡"),
@@ -443,7 +425,6 @@ class MessageLookup extends MessageLookupByLibrary {
"useSystemHosts": MessageLookupByLibrary.simpleMessage("使用系统Hosts"),
"value": MessageLookupByLibrary.simpleMessage(""),
"valueExists": MessageLookupByLibrary.simpleMessage("当前值已存在"),
"vibrantScheme": MessageLookupByLibrary.simpleMessage("活力"),
"view": MessageLookupByLibrary.simpleMessage("查看"),
"vpnDesc": MessageLookupByLibrary.simpleMessage("修改VPN相关设置"),
"vpnEnableDesc": MessageLookupByLibrary.simpleMessage(

View File

@@ -2904,156 +2904,6 @@ class AppLocalizations {
args: [],
);
}
/// `Are you sure you want to delete the current color?`
String get deleteColorTip {
return Intl.message(
'Are you sure you want to delete the current color?',
name: 'deleteColorTip',
desc: '',
args: [],
);
}
/// `Current color already exists`
String get colorExists {
return Intl.message(
'Current color already exists',
name: 'colorExists',
desc: '',
args: [],
);
}
/// `Color schemes`
String get colorSchemes {
return Intl.message(
'Color schemes',
name: 'colorSchemes',
desc: '',
args: [],
);
}
/// `Palette`
String get palette {
return Intl.message('Palette', name: 'palette', desc: '', args: []);
}
/// `TonalSpot`
String get tonalSpotScheme {
return Intl.message(
'TonalSpot',
name: 'tonalSpotScheme',
desc: '',
args: [],
);
}
/// `Fidelity`
String get fidelityScheme {
return Intl.message('Fidelity', name: 'fidelityScheme', desc: '', args: []);
}
/// `Monochrome`
String get monochromeScheme {
return Intl.message(
'Monochrome',
name: 'monochromeScheme',
desc: '',
args: [],
);
}
/// `Neutral`
String get neutralScheme {
return Intl.message('Neutral', name: 'neutralScheme', desc: '', args: []);
}
/// `Vibrant`
String get vibrantScheme {
return Intl.message('Vibrant', name: 'vibrantScheme', desc: '', args: []);
}
/// `Expressive`
String get expressiveScheme {
return Intl.message(
'Expressive',
name: 'expressiveScheme',
desc: '',
args: [],
);
}
/// `Content`
String get contentScheme {
return Intl.message('Content', name: 'contentScheme', desc: '', args: []);
}
/// `Rainbow`
String get rainbowScheme {
return Intl.message('Rainbow', name: 'rainbowScheme', desc: '', args: []);
}
/// `FruitSalad`
String get fruitSaladScheme {
return Intl.message(
'FruitSalad',
name: 'fruitSaladScheme',
desc: '',
args: [],
);
}
/// `Developer mode`
String get developerMode {
return Intl.message(
'Developer mode',
name: 'developerMode',
desc: '',
args: [],
);
}
/// `Developer mode is enabled.`
String get developerModeEnableTip {
return Intl.message(
'Developer mode is enabled.',
name: 'developerModeEnableTip',
desc: '',
args: [],
);
}
/// `Message test`
String get messageTest {
return Intl.message(
'Message test',
name: 'messageTest',
desc: '',
args: [],
);
}
/// `This is a message.`
String get messageTestTip {
return Intl.message(
'This is a message.',
name: 'messageTestTip',
desc: '',
args: [],
);
}
/// `Crash test`
String get crashTest {
return Intl.message('Crash test', name: 'crashTest', desc: '', args: []);
}
/// `Clear Data`
String get clearData {
return Intl.message('Clear Data', name: 'clearData', desc: '', args: []);
}
}
class AppLocalizationDelegate extends LocalizationsDelegate<AppLocalizations> {

View File

@@ -2,7 +2,6 @@ import 'dart:async';
import 'package:fl_clash/common/common.dart';
import 'package:fl_clash/state.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
class AppStateManager extends StatefulWidget {
@@ -22,6 +21,7 @@ class _AppStateManagerState extends State<AppStateManager>
@override
void initState() {
super.initState();
WidgetsBinding.instance.addObserver(this);
}
@@ -33,10 +33,10 @@ class _AppStateManagerState extends State<AppStateManager>
@override
Future<void> didChangeAppLifecycleState(AppLifecycleState state) async {
commonPrint.log("$state");
if (state == AppLifecycleState.paused ||
state == AppLifecycleState.inactive) {
globalState.appController.savePreferences();
render?.pause();
} else {
render?.resume();
}
@@ -70,15 +70,6 @@ class AppEnvManager extends StatelessWidget {
@override
Widget build(BuildContext context) {
if (kDebugMode) {
if (globalState.isPre) {
return Banner(
message: 'DEBUG',
location: BannerLocation.topEnd,
child: child,
);
}
}
if (globalState.isPre) {
return Banner(
message: 'PRE',

View File

@@ -21,7 +21,7 @@ class MessageManager extends StatefulWidget {
class MessageManagerState extends State<MessageManager> {
final _messagesNotifier = ValueNotifier<List<CommonMessage>>([]);
final List<CommonMessage> _bufferMessages = [];
bool _pushing = false;
Completer<bool>? _messageIngCompleter;
@override
void initState() {
@@ -36,31 +36,30 @@ class MessageManagerState extends State<MessageManager> {
Future<void> message(String text) async {
final commonMessage = CommonMessage(
id: utils.uuidV4,
id: other.uuidV4,
text: text,
);
_bufferMessages.add(commonMessage);
await _showMessage();
_showMessage();
}
_showMessage() async {
if (_pushing == true) {
if (_messageIngCompleter?.isCompleted == false) {
return;
}
_pushing = true;
while (_bufferMessages.isNotEmpty) {
final commonMessage = _bufferMessages.removeAt(0);
_messagesNotifier.value = List.from(_messagesNotifier.value)
..add(
commonMessage,
);
_messageIngCompleter = Completer();
await Future.delayed(Duration(seconds: 1));
Future.delayed(commonMessage.duration, () {
_handleRemove(commonMessage);
});
if (_bufferMessages.isEmpty) {
_pushing = false;
}
_messageIngCompleter?.complete(true);
}
}
@@ -78,41 +77,41 @@ class MessageManagerState extends State<MessageManager> {
valueListenable: _messagesNotifier,
builder: (_, messages, __) {
return FadeThroughBox(
margin: EdgeInsets.only(
top: kToolbarHeight + 8,
left: 12,
right: 12,
),
alignment: Alignment.topRight,
child: messages.isEmpty
? SizedBox()
: LayoutBuilder(
key: Key(messages.last.id),
builder: (_, constraints) {
return Card(
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(12.0),
),
key: Key(messages.last.id),
builder: (_, constraints) {
return Card(
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(12.0),
),
),
elevation: 10,
margin: EdgeInsets.only(
top: kToolbarHeight,
left: 12,
right: 12,
),
color: context.colorScheme.surfaceContainerHigh,
child: Container(
width: min(
constraints.maxWidth,
400,
),
padding: EdgeInsets.symmetric(
horizontal: 12,
vertical: 16,
),
child: Text(
messages.last.text,
),
),
);
},
),
elevation: 10,
color: context.colorScheme.surfaceContainerHigh,
child: Container(
width: min(
constraints.maxWidth,
500,
),
padding: EdgeInsets.symmetric(
horizontal: 12,
vertical: 16,
),
child: Text(
messages.last.text,
),
),
);
},
),
);
},
),

View File

@@ -16,16 +16,11 @@ class ThemeManager extends StatelessWidget {
Widget build(BuildContext context) {
globalState.measure = Measure.of(context);
globalState.theme = CommonTheme.of(context);
final padding = MediaQuery.of(context).padding;
final height = MediaQuery.of(context).size.height;
return MediaQuery(
data: MediaQuery.of(context).copyWith(
textScaler: TextScaler.linear(
textScaleFactor,
),
padding: padding.copyWith(
top: padding.top > height * 0.3 ? 0.0 : padding.top,
),
),
child: LayoutBuilder(
builder: (_, container) {

View File

@@ -60,10 +60,15 @@ class _WindowContainerState extends ConsumerState<WindowManager>
@override
void onWindowFocus() {
super.onWindowFocus();
commonPrint.log("focus");
render?.resume();
}
@override
void onWindowBlur() {
super.onWindowBlur();
render?.pause();
}
@override
Future<void> onShouldTerminate() async {
await globalState.appController.handleExit();
@@ -97,8 +102,6 @@ class _WindowContainerState extends ConsumerState<WindowManager>
@override
void onWindowMinimize() async {
globalState.appController.savePreferencesDebounce();
commonPrint.log("minimize");
render?.pause();
super.onWindowMinimize();
}

View File

@@ -16,6 +16,7 @@ class AppState with _$AppState {
@Default(false) bool isInit,
@Default(PageLabel.dashboard) PageLabel pageLabel,
@Default([]) List<Package> packages,
@Default(ColorSchemes()) ColorSchemes colorSchemes,
@Default(0) int sortNum,
required Size viewSize,
@Default({}) DelayMap delayMap,
@@ -35,7 +36,7 @@ class AppState with _$AppState {
}
extension AppStateExt on AppState {
ViewMode get viewMode => utils.getViewMode(viewSize.width);
ViewMode get viewMode => other.getViewMode(viewSize.width);
bool get isStart => runTime != null;
}

View File

@@ -361,7 +361,7 @@ class Rule with _$Rule {
factory Rule.value(String value) {
return Rule(
value: value,
id: utils.uuidV4,
id: other.uuidV4,
);
}
@@ -426,12 +426,12 @@ class ClashConfig with _$ClashConfig {
@Default(defaultMixedPort) @JsonKey(name: "mixed-port") int mixedPort,
@Default(Mode.rule) Mode mode,
@Default(false) @JsonKey(name: "allow-lan") bool allowLan,
@Default(LogLevel.error) @JsonKey(name: "log-level") LogLevel logLevel,
@Default(LogLevel.info) @JsonKey(name: "log-level") LogLevel logLevel,
@Default(false) bool ipv6,
@Default(FindProcessMode.off)
@JsonKey(
name: "find-process-mode",
unknownEnumValue: FindProcessMode.always,
unknownEnumValue: FindProcessMode.off,
)
FindProcessMode findProcessMode,
@Default(defaultKeepAliveInterval)

View File

@@ -369,32 +369,21 @@ class ColorSchemes with _$ColorSchemes {
}
extension ColorSchemesExt on ColorSchemes {
ColorScheme getColorSchemeForBrightness(
Brightness brightness,
DynamicSchemeVariant schemeVariant,
) {
ColorScheme getColorSchemeForBrightness(Brightness? brightness) {
if (brightness == Brightness.dark) {
return darkColorScheme != null
? ColorScheme.fromSeed(
seedColor: darkColorScheme!.primary,
brightness: Brightness.dark,
dynamicSchemeVariant: schemeVariant,
)
: ColorScheme.fromSeed(
seedColor: Color(defaultPrimaryColor),
seedColor: defaultPrimaryColor,
brightness: Brightness.dark,
dynamicSchemeVariant: schemeVariant,
);
}
return lightColorScheme != null
? ColorScheme.fromSeed(
seedColor: lightColorScheme!.primary,
dynamicSchemeVariant: schemeVariant,
)
: ColorScheme.fromSeed(
seedColor: Color(defaultPrimaryColor),
dynamicSchemeVariant: schemeVariant,
);
? ColorScheme.fromSeed(seedColor: lightColorScheme!.primary,dynamicSchemeVariant: DynamicSchemeVariant.vibrant)
: ColorScheme.fromSeed(seedColor: defaultPrimaryColor);
}
}
@@ -511,4 +500,4 @@ class PopupMenuItemData {
final VoidCallback? onPressed;
final IconData? icon;
final PopupMenuItemType? type;
}
}

View File

@@ -8,7 +8,6 @@ import 'package:freezed_annotation/freezed_annotation.dart';
import 'models.dart';
part 'generated/config.freezed.dart';
part 'generated/config.g.dart';
const defaultBypassDomain = [
@@ -37,8 +36,9 @@ const defaultNetworkProps = NetworkProps();
const defaultProxiesStyle = ProxiesStyle();
const defaultWindowProps = WindowProps();
const defaultAccessControl = AccessControl();
final defaultThemeProps = ThemeProps(
primaryColor: defaultPrimaryColor,
final defaultThemeProps = ThemeProps().copyWith(
primaryColor: defaultPrimaryColor.toARGB32(),
themeMode: ThemeMode.dark,
);
const List<DashboardWidget> defaultDashboardWidgets = [
@@ -75,7 +75,7 @@ class AppSettingProps with _$AppSettingProps {
@Default(false) bool autoLaunch,
@Default(false) bool silentLaunch,
@Default(false) bool autoRun,
@Default(true) bool openLogs,
@Default(false) bool openLogs,
@Default(true) bool closeConnections,
@Default(defaultTestUrl) String testUrl,
@Default(true) bool isAnimateToPage,
@@ -84,7 +84,6 @@ class AppSettingProps with _$AppSettingProps {
@Default(false) bool disclaimerAccepted,
@Default(true) bool minimizeOnExit,
@Default(false) bool hidden,
@Default(false) bool developerMode,
}) = _AppSettingProps;
factory AppSettingProps.fromJson(Map<String, Object?> json) =>
@@ -143,7 +142,7 @@ class VpnProps with _$VpnProps {
}) = _VpnProps;
factory VpnProps.fromJson(Map<String, Object?>? json) =>
json == null ? defaultVpnProps : _$VpnPropsFromJson(json);
json == null ? const VpnProps() : _$VpnPropsFromJson(json);
}
@freezed
@@ -177,9 +176,7 @@ class ProxiesStyle with _$ProxiesStyle {
class ThemeProps with _$ThemeProps {
const factory ThemeProps({
int? primaryColor,
@Default(defaultPrimaryColors) List<int> primaryColors,
@Default(ThemeMode.dark) ThemeMode themeMode,
@Default(DynamicSchemeVariant.tonalSpot) DynamicSchemeVariant schemeVariant,
@Default(ThemeMode.system) ThemeMode themeMode,
@Default(false) bool pureBlack,
}) = _ThemeProps;

View File

@@ -19,6 +19,7 @@ mixin _$AppState {
bool get isInit => throw _privateConstructorUsedError;
PageLabel get pageLabel => throw _privateConstructorUsedError;
List<Package> get packages => throw _privateConstructorUsedError;
ColorSchemes get colorSchemes => throw _privateConstructorUsedError;
int get sortNum => throw _privateConstructorUsedError;
Size get viewSize => throw _privateConstructorUsedError;
Map<String, Map<String, int?>> get delayMap =>
@@ -52,6 +53,7 @@ abstract class $AppStateCopyWith<$Res> {
{bool isInit,
PageLabel pageLabel,
List<Package> packages,
ColorSchemes colorSchemes,
int sortNum,
Size viewSize,
Map<String, Map<String, int?>> delayMap,
@@ -67,6 +69,8 @@ abstract class $AppStateCopyWith<$Res> {
FixedList<Traffic> traffics,
Traffic totalTraffic,
bool needApply});
$ColorSchemesCopyWith<$Res> get colorSchemes;
}
/// @nodoc
@@ -87,6 +91,7 @@ class _$AppStateCopyWithImpl<$Res, $Val extends AppState>
Object? isInit = null,
Object? pageLabel = null,
Object? packages = null,
Object? colorSchemes = null,
Object? sortNum = null,
Object? viewSize = null,
Object? delayMap = null,
@@ -116,6 +121,10 @@ class _$AppStateCopyWithImpl<$Res, $Val extends AppState>
? _value.packages
: packages // ignore: cast_nullable_to_non_nullable
as List<Package>,
colorSchemes: null == colorSchemes
? _value.colorSchemes
: colorSchemes // ignore: cast_nullable_to_non_nullable
as ColorSchemes,
sortNum: null == sortNum
? _value.sortNum
: sortNum // ignore: cast_nullable_to_non_nullable
@@ -178,6 +187,16 @@ class _$AppStateCopyWithImpl<$Res, $Val extends AppState>
as bool,
) as $Val);
}
/// Create a copy of AppState
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$ColorSchemesCopyWith<$Res> get colorSchemes {
return $ColorSchemesCopyWith<$Res>(_value.colorSchemes, (value) {
return _then(_value.copyWith(colorSchemes: value) as $Val);
});
}
}
/// @nodoc
@@ -192,6 +211,7 @@ abstract class _$$AppStateImplCopyWith<$Res>
{bool isInit,
PageLabel pageLabel,
List<Package> packages,
ColorSchemes colorSchemes,
int sortNum,
Size viewSize,
Map<String, Map<String, int?>> delayMap,
@@ -207,6 +227,9 @@ abstract class _$$AppStateImplCopyWith<$Res>
FixedList<Traffic> traffics,
Traffic totalTraffic,
bool needApply});
@override
$ColorSchemesCopyWith<$Res> get colorSchemes;
}
/// @nodoc
@@ -225,6 +248,7 @@ class __$$AppStateImplCopyWithImpl<$Res>
Object? isInit = null,
Object? pageLabel = null,
Object? packages = null,
Object? colorSchemes = null,
Object? sortNum = null,
Object? viewSize = null,
Object? delayMap = null,
@@ -254,6 +278,10 @@ class __$$AppStateImplCopyWithImpl<$Res>
? _value._packages
: packages // ignore: cast_nullable_to_non_nullable
as List<Package>,
colorSchemes: null == colorSchemes
? _value.colorSchemes
: colorSchemes // ignore: cast_nullable_to_non_nullable
as ColorSchemes,
sortNum: null == sortNum
? _value.sortNum
: sortNum // ignore: cast_nullable_to_non_nullable
@@ -325,6 +353,7 @@ class _$AppStateImpl implements _AppState {
{this.isInit = false,
this.pageLabel = PageLabel.dashboard,
final List<Package> packages = const [],
this.colorSchemes = const ColorSchemes(),
this.sortNum = 0,
required this.viewSize,
final Map<String, Map<String, int?>> delayMap = const {},
@@ -360,6 +389,9 @@ class _$AppStateImpl implements _AppState {
return EqualUnmodifiableListView(_packages);
}
@override
@JsonKey()
final ColorSchemes colorSchemes;
@override
@JsonKey()
final int sortNum;
@@ -417,7 +449,7 @@ class _$AppStateImpl implements _AppState {
@override
String toString() {
return 'AppState(isInit: $isInit, pageLabel: $pageLabel, packages: $packages, sortNum: $sortNum, viewSize: $viewSize, delayMap: $delayMap, groups: $groups, checkIpNum: $checkIpNum, brightness: $brightness, runTime: $runTime, providers: $providers, localIp: $localIp, requests: $requests, version: $version, logs: $logs, traffics: $traffics, totalTraffic: $totalTraffic, needApply: $needApply)';
return 'AppState(isInit: $isInit, pageLabel: $pageLabel, packages: $packages, colorSchemes: $colorSchemes, sortNum: $sortNum, viewSize: $viewSize, delayMap: $delayMap, groups: $groups, checkIpNum: $checkIpNum, brightness: $brightness, runTime: $runTime, providers: $providers, localIp: $localIp, requests: $requests, version: $version, logs: $logs, traffics: $traffics, totalTraffic: $totalTraffic, needApply: $needApply)';
}
@override
@@ -429,6 +461,8 @@ class _$AppStateImpl implements _AppState {
(identical(other.pageLabel, pageLabel) ||
other.pageLabel == pageLabel) &&
const DeepCollectionEquality().equals(other._packages, _packages) &&
(identical(other.colorSchemes, colorSchemes) ||
other.colorSchemes == colorSchemes) &&
(identical(other.sortNum, sortNum) || other.sortNum == sortNum) &&
(identical(other.viewSize, viewSize) ||
other.viewSize == viewSize) &&
@@ -455,26 +489,28 @@ class _$AppStateImpl implements _AppState {
}
@override
int get hashCode => Object.hash(
runtimeType,
isInit,
pageLabel,
const DeepCollectionEquality().hash(_packages),
sortNum,
viewSize,
const DeepCollectionEquality().hash(_delayMap),
const DeepCollectionEquality().hash(_groups),
checkIpNum,
brightness,
runTime,
const DeepCollectionEquality().hash(_providers),
localIp,
requests,
version,
logs,
traffics,
totalTraffic,
needApply);
int get hashCode => Object.hashAll([
runtimeType,
isInit,
pageLabel,
const DeepCollectionEquality().hash(_packages),
colorSchemes,
sortNum,
viewSize,
const DeepCollectionEquality().hash(_delayMap),
const DeepCollectionEquality().hash(_groups),
checkIpNum,
brightness,
runTime,
const DeepCollectionEquality().hash(_providers),
localIp,
requests,
version,
logs,
traffics,
totalTraffic,
needApply
]);
/// Create a copy of AppState
/// with the given fields replaced by the non-null parameter values.
@@ -490,6 +526,7 @@ abstract class _AppState implements AppState {
{final bool isInit,
final PageLabel pageLabel,
final List<Package> packages,
final ColorSchemes colorSchemes,
final int sortNum,
required final Size viewSize,
final Map<String, Map<String, int?>> delayMap,
@@ -513,6 +550,8 @@ abstract class _AppState implements AppState {
@override
List<Package> get packages;
@override
ColorSchemes get colorSchemes;
@override
int get sortNum;
@override
Size get viewSize;

View File

@@ -2832,7 +2832,7 @@ mixin _$ClashConfig {
@JsonKey(name: "log-level")
LogLevel get logLevel => throw _privateConstructorUsedError;
bool get ipv6 => throw _privateConstructorUsedError;
@JsonKey(name: "find-process-mode", unknownEnumValue: FindProcessMode.always)
@JsonKey(name: "find-process-mode", unknownEnumValue: FindProcessMode.off)
FindProcessMode get findProcessMode => throw _privateConstructorUsedError;
@JsonKey(name: "keep-alive-interval")
int get keepAliveInterval => throw _privateConstructorUsedError;
@@ -2880,8 +2880,7 @@ abstract class $ClashConfigCopyWith<$Res> {
@JsonKey(name: "allow-lan") bool allowLan,
@JsonKey(name: "log-level") LogLevel logLevel,
bool ipv6,
@JsonKey(
name: "find-process-mode", unknownEnumValue: FindProcessMode.always)
@JsonKey(name: "find-process-mode", unknownEnumValue: FindProcessMode.off)
FindProcessMode findProcessMode,
@JsonKey(name: "keep-alive-interval") int keepAliveInterval,
@JsonKey(name: "unified-delay") bool unifiedDelay,
@@ -3058,8 +3057,7 @@ abstract class _$$ClashConfigImplCopyWith<$Res>
@JsonKey(name: "allow-lan") bool allowLan,
@JsonKey(name: "log-level") LogLevel logLevel,
bool ipv6,
@JsonKey(
name: "find-process-mode", unknownEnumValue: FindProcessMode.always)
@JsonKey(name: "find-process-mode", unknownEnumValue: FindProcessMode.off)
FindProcessMode findProcessMode,
@JsonKey(name: "keep-alive-interval") int keepAliveInterval,
@JsonKey(name: "unified-delay") bool unifiedDelay,
@@ -3200,10 +3198,9 @@ class _$ClashConfigImpl implements _ClashConfig {
{@JsonKey(name: "mixed-port") this.mixedPort = defaultMixedPort,
this.mode = Mode.rule,
@JsonKey(name: "allow-lan") this.allowLan = false,
@JsonKey(name: "log-level") this.logLevel = LogLevel.error,
@JsonKey(name: "log-level") this.logLevel = LogLevel.info,
this.ipv6 = false,
@JsonKey(
name: "find-process-mode", unknownEnumValue: FindProcessMode.always)
@JsonKey(name: "find-process-mode", unknownEnumValue: FindProcessMode.off)
this.findProcessMode = FindProcessMode.off,
@JsonKey(name: "keep-alive-interval")
this.keepAliveInterval = defaultKeepAliveInterval,
@@ -3245,7 +3242,7 @@ class _$ClashConfigImpl implements _ClashConfig {
@JsonKey()
final bool ipv6;
@override
@JsonKey(name: "find-process-mode", unknownEnumValue: FindProcessMode.always)
@JsonKey(name: "find-process-mode", unknownEnumValue: FindProcessMode.off)
final FindProcessMode findProcessMode;
@override
@JsonKey(name: "keep-alive-interval")
@@ -3388,8 +3385,7 @@ abstract class _ClashConfig implements ClashConfig {
@JsonKey(name: "allow-lan") final bool allowLan,
@JsonKey(name: "log-level") final LogLevel logLevel,
final bool ipv6,
@JsonKey(
name: "find-process-mode", unknownEnumValue: FindProcessMode.always)
@JsonKey(name: "find-process-mode", unknownEnumValue: FindProcessMode.off)
final FindProcessMode findProcessMode,
@JsonKey(name: "keep-alive-interval") final int keepAliveInterval,
@JsonKey(name: "unified-delay") final bool unifiedDelay,
@@ -3423,7 +3419,7 @@ abstract class _ClashConfig implements ClashConfig {
@override
bool get ipv6;
@override
@JsonKey(name: "find-process-mode", unknownEnumValue: FindProcessMode.always)
@JsonKey(name: "find-process-mode", unknownEnumValue: FindProcessMode.off)
FindProcessMode get findProcessMode;
@override
@JsonKey(name: "keep-alive-interval")

View File

@@ -268,11 +268,11 @@ _$ClashConfigImpl _$$ClashConfigImplFromJson(Map<String, dynamic> json) =>
mode: $enumDecodeNullable(_$ModeEnumMap, json['mode']) ?? Mode.rule,
allowLan: json['allow-lan'] as bool? ?? false,
logLevel: $enumDecodeNullable(_$LogLevelEnumMap, json['log-level']) ??
LogLevel.error,
LogLevel.info,
ipv6: json['ipv6'] as bool? ?? false,
findProcessMode: $enumDecodeNullable(
_$FindProcessModeEnumMap, json['find-process-mode'],
unknownValue: FindProcessMode.always) ??
unknownValue: FindProcessMode.off) ??
FindProcessMode.off,
keepAliveInterval: (json['keep-alive-interval'] as num?)?.toInt() ??
defaultKeepAliveInterval,
@@ -342,7 +342,6 @@ const _$LogLevelEnumMap = {
LogLevel.warning: 'warning',
LogLevel.error: 'error',
LogLevel.silent: 'silent',
LogLevel.app: 'app',
};
const _$FindProcessModeEnumMap = {

View File

@@ -22,7 +22,6 @@ const _$LogLevelEnumMap = {
LogLevel.warning: 'warning',
LogLevel.error: 'error',
LogLevel.silent: 'silent',
LogLevel.app: 'app',
};
_$PackageImpl _$$PackageImplFromJson(Map<String, dynamic> json) =>

View File

@@ -37,7 +37,6 @@ mixin _$AppSettingProps {
bool get disclaimerAccepted => throw _privateConstructorUsedError;
bool get minimizeOnExit => throw _privateConstructorUsedError;
bool get hidden => throw _privateConstructorUsedError;
bool get developerMode => throw _privateConstructorUsedError;
/// Serializes this AppSettingProps to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@@ -71,8 +70,7 @@ abstract class $AppSettingPropsCopyWith<$Res> {
bool showLabel,
bool disclaimerAccepted,
bool minimizeOnExit,
bool hidden,
bool developerMode});
bool hidden});
}
/// @nodoc
@@ -105,7 +103,6 @@ class _$AppSettingPropsCopyWithImpl<$Res, $Val extends AppSettingProps>
Object? disclaimerAccepted = null,
Object? minimizeOnExit = null,
Object? hidden = null,
Object? developerMode = null,
}) {
return _then(_value.copyWith(
locale: freezed == locale
@@ -168,10 +165,6 @@ class _$AppSettingPropsCopyWithImpl<$Res, $Val extends AppSettingProps>
? _value.hidden
: hidden // ignore: cast_nullable_to_non_nullable
as bool,
developerMode: null == developerMode
? _value.developerMode
: developerMode // ignore: cast_nullable_to_non_nullable
as bool,
) as $Val);
}
}
@@ -200,8 +193,7 @@ abstract class _$$AppSettingPropsImplCopyWith<$Res>
bool showLabel,
bool disclaimerAccepted,
bool minimizeOnExit,
bool hidden,
bool developerMode});
bool hidden});
}
/// @nodoc
@@ -232,7 +224,6 @@ class __$$AppSettingPropsImplCopyWithImpl<$Res>
Object? disclaimerAccepted = null,
Object? minimizeOnExit = null,
Object? hidden = null,
Object? developerMode = null,
}) {
return _then(_$AppSettingPropsImpl(
locale: freezed == locale
@@ -295,10 +286,6 @@ class __$$AppSettingPropsImplCopyWithImpl<$Res>
? _value.hidden
: hidden // ignore: cast_nullable_to_non_nullable
as bool,
developerMode: null == developerMode
? _value.developerMode
: developerMode // ignore: cast_nullable_to_non_nullable
as bool,
));
}
}
@@ -314,7 +301,7 @@ class _$AppSettingPropsImpl implements _AppSettingProps {
this.autoLaunch = false,
this.silentLaunch = false,
this.autoRun = false,
this.openLogs = true,
this.openLogs = false,
this.closeConnections = true,
this.testUrl = defaultTestUrl,
this.isAnimateToPage = true,
@@ -322,8 +309,7 @@ class _$AppSettingPropsImpl implements _AppSettingProps {
this.showLabel = false,
this.disclaimerAccepted = false,
this.minimizeOnExit = true,
this.hidden = false,
this.developerMode = false})
this.hidden = false})
: _dashboardWidgets = dashboardWidgets;
factory _$AppSettingPropsImpl.fromJson(Map<String, dynamic> json) =>
@@ -380,13 +366,10 @@ class _$AppSettingPropsImpl implements _AppSettingProps {
@override
@JsonKey()
final bool hidden;
@override
@JsonKey()
final bool developerMode;
@override
String toString() {
return 'AppSettingProps(locale: $locale, dashboardWidgets: $dashboardWidgets, onlyStatisticsProxy: $onlyStatisticsProxy, autoLaunch: $autoLaunch, silentLaunch: $silentLaunch, autoRun: $autoRun, openLogs: $openLogs, closeConnections: $closeConnections, testUrl: $testUrl, isAnimateToPage: $isAnimateToPage, autoCheckUpdate: $autoCheckUpdate, showLabel: $showLabel, disclaimerAccepted: $disclaimerAccepted, minimizeOnExit: $minimizeOnExit, hidden: $hidden, developerMode: $developerMode)';
return 'AppSettingProps(locale: $locale, dashboardWidgets: $dashboardWidgets, onlyStatisticsProxy: $onlyStatisticsProxy, autoLaunch: $autoLaunch, silentLaunch: $silentLaunch, autoRun: $autoRun, openLogs: $openLogs, closeConnections: $closeConnections, testUrl: $testUrl, isAnimateToPage: $isAnimateToPage, autoCheckUpdate: $autoCheckUpdate, showLabel: $showLabel, disclaimerAccepted: $disclaimerAccepted, minimizeOnExit: $minimizeOnExit, hidden: $hidden)';
}
@override
@@ -419,9 +402,7 @@ class _$AppSettingPropsImpl implements _AppSettingProps {
other.disclaimerAccepted == disclaimerAccepted) &&
(identical(other.minimizeOnExit, minimizeOnExit) ||
other.minimizeOnExit == minimizeOnExit) &&
(identical(other.hidden, hidden) || other.hidden == hidden) &&
(identical(other.developerMode, developerMode) ||
other.developerMode == developerMode));
(identical(other.hidden, hidden) || other.hidden == hidden));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@@ -442,8 +423,7 @@ class _$AppSettingPropsImpl implements _AppSettingProps {
showLabel,
disclaimerAccepted,
minimizeOnExit,
hidden,
developerMode);
hidden);
/// Create a copy of AppSettingProps
/// with the given fields replaced by the non-null parameter values.
@@ -479,8 +459,7 @@ abstract class _AppSettingProps implements AppSettingProps {
final bool showLabel,
final bool disclaimerAccepted,
final bool minimizeOnExit,
final bool hidden,
final bool developerMode}) = _$AppSettingPropsImpl;
final bool hidden}) = _$AppSettingPropsImpl;
factory _AppSettingProps.fromJson(Map<String, dynamic> json) =
_$AppSettingPropsImpl.fromJson;
@@ -516,8 +495,6 @@ abstract class _AppSettingProps implements AppSettingProps {
bool get minimizeOnExit;
@override
bool get hidden;
@override
bool get developerMode;
/// Create a copy of AppSettingProps
/// with the given fields replaced by the non-null parameter values.
@@ -1747,9 +1724,7 @@ ThemeProps _$ThemePropsFromJson(Map<String, dynamic> json) {
/// @nodoc
mixin _$ThemeProps {
int? get primaryColor => throw _privateConstructorUsedError;
List<int> get primaryColors => throw _privateConstructorUsedError;
ThemeMode get themeMode => throw _privateConstructorUsedError;
DynamicSchemeVariant get schemeVariant => throw _privateConstructorUsedError;
bool get pureBlack => throw _privateConstructorUsedError;
/// Serializes this ThemeProps to a JSON map.
@@ -1768,12 +1743,7 @@ abstract class $ThemePropsCopyWith<$Res> {
ThemeProps value, $Res Function(ThemeProps) then) =
_$ThemePropsCopyWithImpl<$Res, ThemeProps>;
@useResult
$Res call(
{int? primaryColor,
List<int> primaryColors,
ThemeMode themeMode,
DynamicSchemeVariant schemeVariant,
bool pureBlack});
$Res call({int? primaryColor, ThemeMode themeMode, bool pureBlack});
}
/// @nodoc
@@ -1792,9 +1762,7 @@ class _$ThemePropsCopyWithImpl<$Res, $Val extends ThemeProps>
@override
$Res call({
Object? primaryColor = freezed,
Object? primaryColors = null,
Object? themeMode = null,
Object? schemeVariant = null,
Object? pureBlack = null,
}) {
return _then(_value.copyWith(
@@ -1802,18 +1770,10 @@ class _$ThemePropsCopyWithImpl<$Res, $Val extends ThemeProps>
? _value.primaryColor
: primaryColor // ignore: cast_nullable_to_non_nullable
as int?,
primaryColors: null == primaryColors
? _value.primaryColors
: primaryColors // ignore: cast_nullable_to_non_nullable
as List<int>,
themeMode: null == themeMode
? _value.themeMode
: themeMode // ignore: cast_nullable_to_non_nullable
as ThemeMode,
schemeVariant: null == schemeVariant
? _value.schemeVariant
: schemeVariant // ignore: cast_nullable_to_non_nullable
as DynamicSchemeVariant,
pureBlack: null == pureBlack
? _value.pureBlack
: pureBlack // ignore: cast_nullable_to_non_nullable
@@ -1830,12 +1790,7 @@ abstract class _$$ThemePropsImplCopyWith<$Res>
__$$ThemePropsImplCopyWithImpl<$Res>;
@override
@useResult
$Res call(
{int? primaryColor,
List<int> primaryColors,
ThemeMode themeMode,
DynamicSchemeVariant schemeVariant,
bool pureBlack});
$Res call({int? primaryColor, ThemeMode themeMode, bool pureBlack});
}
/// @nodoc
@@ -1852,9 +1807,7 @@ class __$$ThemePropsImplCopyWithImpl<$Res>
@override
$Res call({
Object? primaryColor = freezed,
Object? primaryColors = null,
Object? themeMode = null,
Object? schemeVariant = null,
Object? pureBlack = null,
}) {
return _then(_$ThemePropsImpl(
@@ -1862,18 +1815,10 @@ class __$$ThemePropsImplCopyWithImpl<$Res>
? _value.primaryColor
: primaryColor // ignore: cast_nullable_to_non_nullable
as int?,
primaryColors: null == primaryColors
? _value._primaryColors
: primaryColors // ignore: cast_nullable_to_non_nullable
as List<int>,
themeMode: null == themeMode
? _value.themeMode
: themeMode // ignore: cast_nullable_to_non_nullable
as ThemeMode,
schemeVariant: null == schemeVariant
? _value.schemeVariant
: schemeVariant // ignore: cast_nullable_to_non_nullable
as DynamicSchemeVariant,
pureBlack: null == pureBlack
? _value.pureBlack
: pureBlack // ignore: cast_nullable_to_non_nullable
@@ -1887,39 +1832,24 @@ class __$$ThemePropsImplCopyWithImpl<$Res>
class _$ThemePropsImpl implements _ThemeProps {
const _$ThemePropsImpl(
{this.primaryColor,
final List<int> primaryColors = defaultPrimaryColors,
this.themeMode = ThemeMode.dark,
this.schemeVariant = DynamicSchemeVariant.tonalSpot,
this.pureBlack = false})
: _primaryColors = primaryColors;
this.themeMode = ThemeMode.system,
this.pureBlack = false});
factory _$ThemePropsImpl.fromJson(Map<String, dynamic> json) =>
_$$ThemePropsImplFromJson(json);
@override
final int? primaryColor;
final List<int> _primaryColors;
@override
@JsonKey()
List<int> get primaryColors {
if (_primaryColors is EqualUnmodifiableListView) return _primaryColors;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_primaryColors);
}
@override
@JsonKey()
final ThemeMode themeMode;
@override
@JsonKey()
final DynamicSchemeVariant schemeVariant;
@override
@JsonKey()
final bool pureBlack;
@override
String toString() {
return 'ThemeProps(primaryColor: $primaryColor, primaryColors: $primaryColors, themeMode: $themeMode, schemeVariant: $schemeVariant, pureBlack: $pureBlack)';
return 'ThemeProps(primaryColor: $primaryColor, themeMode: $themeMode, pureBlack: $pureBlack)';
}
@override
@@ -1929,25 +1859,16 @@ class _$ThemePropsImpl implements _ThemeProps {
other is _$ThemePropsImpl &&
(identical(other.primaryColor, primaryColor) ||
other.primaryColor == primaryColor) &&
const DeepCollectionEquality()
.equals(other._primaryColors, _primaryColors) &&
(identical(other.themeMode, themeMode) ||
other.themeMode == themeMode) &&
(identical(other.schemeVariant, schemeVariant) ||
other.schemeVariant == schemeVariant) &&
(identical(other.pureBlack, pureBlack) ||
other.pureBlack == pureBlack));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(
runtimeType,
primaryColor,
const DeepCollectionEquality().hash(_primaryColors),
themeMode,
schemeVariant,
pureBlack);
int get hashCode =>
Object.hash(runtimeType, primaryColor, themeMode, pureBlack);
/// Create a copy of ThemeProps
/// with the given fields replaced by the non-null parameter values.
@@ -1968,9 +1889,7 @@ class _$ThemePropsImpl implements _ThemeProps {
abstract class _ThemeProps implements ThemeProps {
const factory _ThemeProps(
{final int? primaryColor,
final List<int> primaryColors,
final ThemeMode themeMode,
final DynamicSchemeVariant schemeVariant,
final bool pureBlack}) = _$ThemePropsImpl;
factory _ThemeProps.fromJson(Map<String, dynamic> json) =
@@ -1979,12 +1898,8 @@ abstract class _ThemeProps implements ThemeProps {
@override
int? get primaryColor;
@override
List<int> get primaryColors;
@override
ThemeMode get themeMode;
@override
DynamicSchemeVariant get schemeVariant;
@override
bool get pureBlack;
/// Create a copy of ThemeProps

View File

@@ -17,7 +17,7 @@ _$AppSettingPropsImpl _$$AppSettingPropsImplFromJson(
autoLaunch: json['autoLaunch'] as bool? ?? false,
silentLaunch: json['silentLaunch'] as bool? ?? false,
autoRun: json['autoRun'] as bool? ?? false,
openLogs: json['openLogs'] as bool? ?? true,
openLogs: json['openLogs'] as bool? ?? false,
closeConnections: json['closeConnections'] as bool? ?? true,
testUrl: json['testUrl'] as String? ?? defaultTestUrl,
isAnimateToPage: json['isAnimateToPage'] as bool? ?? true,
@@ -26,7 +26,6 @@ _$AppSettingPropsImpl _$$AppSettingPropsImplFromJson(
disclaimerAccepted: json['disclaimerAccepted'] as bool? ?? false,
minimizeOnExit: json['minimizeOnExit'] as bool? ?? true,
hidden: json['hidden'] as bool? ?? false,
developerMode: json['developerMode'] as bool? ?? false,
);
Map<String, dynamic> _$$AppSettingPropsImplToJson(
@@ -49,12 +48,10 @@ Map<String, dynamic> _$$AppSettingPropsImplToJson(
'disclaimerAccepted': instance.disclaimerAccepted,
'minimizeOnExit': instance.minimizeOnExit,
'hidden': instance.hidden,
'developerMode': instance.developerMode,
};
const _$DashboardWidgetEnumMap = {
DashboardWidget.networkSpeed: 'networkSpeed',
DashboardWidget.outboundModeV2: 'outboundModeV2',
DashboardWidget.outboundMode: 'outboundMode',
DashboardWidget.trafficUsage: 'trafficUsage',
DashboardWidget.networkDetection: 'networkDetection',
@@ -225,24 +222,15 @@ const _$ProxyCardTypeEnumMap = {
_$ThemePropsImpl _$$ThemePropsImplFromJson(Map<String, dynamic> json) =>
_$ThemePropsImpl(
primaryColor: (json['primaryColor'] as num?)?.toInt(),
primaryColors: (json['primaryColors'] as List<dynamic>?)
?.map((e) => (e as num).toInt())
.toList() ??
defaultPrimaryColors,
themeMode: $enumDecodeNullable(_$ThemeModeEnumMap, json['themeMode']) ??
ThemeMode.dark,
schemeVariant: $enumDecodeNullable(
_$DynamicSchemeVariantEnumMap, json['schemeVariant']) ??
DynamicSchemeVariant.tonalSpot,
ThemeMode.system,
pureBlack: json['pureBlack'] as bool? ?? false,
);
Map<String, dynamic> _$$ThemePropsImplToJson(_$ThemePropsImpl instance) =>
<String, dynamic>{
'primaryColor': instance.primaryColor,
'primaryColors': instance.primaryColors,
'themeMode': _$ThemeModeEnumMap[instance.themeMode]!,
'schemeVariant': _$DynamicSchemeVariantEnumMap[instance.schemeVariant]!,
'pureBlack': instance.pureBlack,
};
@@ -252,18 +240,6 @@ const _$ThemeModeEnumMap = {
ThemeMode.dark: 'dark',
};
const _$DynamicSchemeVariantEnumMap = {
DynamicSchemeVariant.tonalSpot: 'tonalSpot',
DynamicSchemeVariant.fidelity: 'fidelity',
DynamicSchemeVariant.monochrome: 'monochrome',
DynamicSchemeVariant.neutral: 'neutral',
DynamicSchemeVariant.vibrant: 'vibrant',
DynamicSchemeVariant.expressive: 'expressive',
DynamicSchemeVariant.content: 'content',
DynamicSchemeVariant.rainbow: 'rainbow',
DynamicSchemeVariant.fruitSalad: 'fruitSalad',
};
_$ConfigImpl _$$ConfigImplFromJson(Map<String, dynamic> json) => _$ConfigImpl(
appSetting: json['appSetting'] == null
? defaultAppSettingProps

View File

@@ -345,7 +345,6 @@ const _$ActionMethodEnumMap = {
ActionMethod.getCountryCode: 'getCountryCode',
ActionMethod.getMemory: 'getMemory',
ActionMethod.getProfile: 'getProfile',
ActionMethod.crash: 'crash',
ActionMethod.setFdMap: 'setFdMap',
ActionMethod.setProcessMap: 'setProcessMap',
ActionMethod.setState: 'setState',

View File

@@ -173,7 +173,7 @@ extension ProfileExtension on Profile {
final disposition = response.headers.value("content-disposition");
final userinfo = response.headers.value('subscription-userinfo');
return await copyWith(
label: label ?? utils.getFileNameForDisposition(disposition) ?? id,
label: label ?? other.getFileNameForDisposition(disposition) ?? id,
subscriptionInfo: SubscriptionInfo.formHString(userinfo),
).saveFile(response.data);
}

View File

@@ -155,9 +155,9 @@ extension PackageListSelectorStateExt on PackageListSelectorState {
(a, b) {
return switch (sort) {
AccessSortType.none => 0,
AccessSortType.name => utils.sortByChar(
utils.getPinyin(a.label),
utils.getPinyin(b.label),
AccessSortType.name => other.sortByChar(
other.getPinyin(a.label),
other.getPinyin(b.label),
),
AccessSortType.time => b.lastUpdateTime.compareTo(a.lastUpdateTime),
};
@@ -243,4 +243,4 @@ class ProfileOverrideStateModel with _$ProfileOverrideStateModel {
required Set<String> selectedRules,
OverrideData? overrideData,
}) = _ProfileOverrideStateModel;
}
}

View File

@@ -129,16 +129,6 @@ class _HomePageViewState extends ConsumerState<_HomePageView> {
controller: _pageController,
physics: const NeverScrollableScrollPhysics(),
itemCount: navigationItems.length,
// onPageChanged: (index) {
// debouncer.call(DebounceTag.pageChange, () {
// WidgetsBinding.instance.addPostFrameCallback((_) {
// if (_pageIndex != index) {
// final pageLabel = navigationItems[index].label;
// _toPage(pageLabel, true);
// }
// });
// });
// },
itemBuilder: (_, index) {
final navigationItem = navigationItems[index];
return KeepScope(

View File

@@ -196,7 +196,7 @@ class ViewSize extends _$ViewSize with AutoDisposeNotifierMixin {
);
}
ViewMode get viewMode => utils.getViewMode(state.width);
ViewMode get viewMode => other.getViewMode(state.width);
bool get isMobileView => viewMode == ViewMode.mobile;
}
@@ -208,7 +208,7 @@ double viewWidth(Ref ref) {
@riverpod
ViewMode viewMode(Ref ref) {
return utils.getViewMode(ref.watch(viewWidthProvider));
return other.getViewMode(ref.watch(viewWidthProvider));
}
@riverpod
@@ -252,6 +252,21 @@ class CurrentPageLabel extends _$CurrentPageLabel
}
}
@riverpod
class AppSchemes extends _$AppSchemes with AutoDisposeNotifierMixin {
@override
ColorSchemes build() {
return globalState.appState.colorSchemes;
}
@override
onUpdate(value) {
globalState.appState = globalState.appState.copyWith(
colorSchemes: value,
);
}
}
@riverpod
class SortNum extends _$SortNum with AutoDisposeNotifierMixin {
@override

View File

@@ -120,7 +120,7 @@ class Profiles extends _$Profiles with AutoDisposeNotifierMixin {
(element) => element.label == realLabel && element.id != id) !=
-1;
if (hasDup) {
return _getLabel(utils.getOverwriteLabel(realLabel), id);
return _getLabel(other.getOverwriteLabel(realLabel), id);
} else {
return label;
}

View File

@@ -22,7 +22,7 @@ final viewWidthProvider = AutoDisposeProvider<double>.internal(
@Deprecated('Will be removed in 3.0. Use Ref instead')
// ignore: unused_element
typedef ViewWidthRef = AutoDisposeProviderRef<double>;
String _$viewModeHash() => r'736e2acc7e7d98ee30132de1990bf85f9506b47a';
String _$viewModeHash() => r'fbda5aee64803b09b1431b00650ac6e16d044743';
/// See also [viewMode].
@ProviderFor(viewMode)
@@ -203,7 +203,7 @@ final runTimeProvider = AutoDisposeNotifierProvider<RunTime, int?>.internal(
);
typedef _$RunTime = AutoDisposeNotifier<int?>;
String _$viewSizeHash() => r'07f9cce28a69d1496ba4643ef72a739312f6fc28';
String _$viewSizeHash() => r'44a8ff7a1fb1a9ad278b999560bef3ce2c9fea2a';
/// See also [ViewSize].
@ProviderFor(ViewSize)
@@ -247,6 +247,21 @@ final currentPageLabelProvider =
);
typedef _$CurrentPageLabel = AutoDisposeNotifier<PageLabel>;
String _$appSchemesHash() => r'748f48f23539a879a92f318a21e1266b1df56aae';
/// See also [AppSchemes].
@ProviderFor(AppSchemes)
final appSchemesProvider =
AutoDisposeNotifierProvider<AppSchemes, ColorSchemes>.internal(
AppSchemes.new,
name: r'appSchemesProvider',
debugGetCreateSourceHash:
const bool.fromEnvironment('dart.vm.product') ? null : _$appSchemesHash,
dependencies: null,
allTransitiveDependencies: null,
);
typedef _$AppSchemes = AutoDisposeNotifier<ColorSchemes>;
String _$sortNumHash() => r'0f85ebbc77124020eaccf988c6ac9d86a7f34d7e';
/// See also [SortNum].

View File

@@ -83,7 +83,7 @@ final themeSettingProvider =
);
typedef _$ThemeSetting = AutoDisposeNotifier<ThemeProps>;
String _$profilesHash() => r'a6514c89064e4f42fc31fe7d525088fd26c51016';
String _$profilesHash() => r'2023af6ceaf273df480897561565cb3be8054ded';
/// See also [Profiles].
@ProviderFor(Profiles)

View File

@@ -216,7 +216,7 @@ final startButtonSelectorStateProvider =
typedef StartButtonSelectorStateRef
= AutoDisposeProviderRef<StartButtonSelectorState>;
String _$profilesSelectorStateHash() =>
r'aac2deee6e747eceaf62cb5f279ec99ce9227a5a';
r'9fa4447dace0322e888efb38cbee1dabd33e0e71';
/// See also [profilesSelectorState].
@ProviderFor(profilesSelectorState)
@@ -1091,7 +1091,7 @@ final currentProfileProvider = AutoDisposeProvider<Profile?>.internal(
@Deprecated('Will be removed in 3.0. Use Ref instead')
// ignore: unused_element
typedef CurrentProfileRef = AutoDisposeProviderRef<Profile?>;
String _$getProxiesColumnsHash() => r'725066b5fc21f590a4c2656a1fd5e14ab7079079';
String _$getProxiesColumnsHash() => r'895705381fe361fa40f16da2f9cb26e8da3293e8';
/// See also [getProxiesColumns].
@ProviderFor(getProxiesColumns)
@@ -1765,169 +1765,6 @@ class _GetProfileOverrideDataProviderElement
String get profileId => (origin as GetProfileOverrideDataProvider).profileId;
}
String _$genColorSchemeHash() => r'b18f15c938a8132ee4ed02cdfc02f3b9f01724e2';
/// See also [genColorScheme].
@ProviderFor(genColorScheme)
const genColorSchemeProvider = GenColorSchemeFamily();
/// See also [genColorScheme].
class GenColorSchemeFamily extends Family<ColorScheme> {
/// See also [genColorScheme].
const GenColorSchemeFamily();
/// See also [genColorScheme].
GenColorSchemeProvider call(
Brightness brightness, {
Color? color,
bool ignoreConfig = false,
}) {
return GenColorSchemeProvider(
brightness,
color: color,
ignoreConfig: ignoreConfig,
);
}
@override
GenColorSchemeProvider getProviderOverride(
covariant GenColorSchemeProvider provider,
) {
return call(
provider.brightness,
color: provider.color,
ignoreConfig: provider.ignoreConfig,
);
}
static const Iterable<ProviderOrFamily>? _dependencies = null;
@override
Iterable<ProviderOrFamily>? get dependencies => _dependencies;
static const Iterable<ProviderOrFamily>? _allTransitiveDependencies = null;
@override
Iterable<ProviderOrFamily>? get allTransitiveDependencies =>
_allTransitiveDependencies;
@override
String? get name => r'genColorSchemeProvider';
}
/// See also [genColorScheme].
class GenColorSchemeProvider extends AutoDisposeProvider<ColorScheme> {
/// See also [genColorScheme].
GenColorSchemeProvider(
Brightness brightness, {
Color? color,
bool ignoreConfig = false,
}) : this._internal(
(ref) => genColorScheme(
ref as GenColorSchemeRef,
brightness,
color: color,
ignoreConfig: ignoreConfig,
),
from: genColorSchemeProvider,
name: r'genColorSchemeProvider',
debugGetCreateSourceHash:
const bool.fromEnvironment('dart.vm.product')
? null
: _$genColorSchemeHash,
dependencies: GenColorSchemeFamily._dependencies,
allTransitiveDependencies:
GenColorSchemeFamily._allTransitiveDependencies,
brightness: brightness,
color: color,
ignoreConfig: ignoreConfig,
);
GenColorSchemeProvider._internal(
super._createNotifier, {
required super.name,
required super.dependencies,
required super.allTransitiveDependencies,
required super.debugGetCreateSourceHash,
required super.from,
required this.brightness,
required this.color,
required this.ignoreConfig,
}) : super.internal();
final Brightness brightness;
final Color? color;
final bool ignoreConfig;
@override
Override overrideWith(
ColorScheme Function(GenColorSchemeRef provider) create,
) {
return ProviderOverride(
origin: this,
override: GenColorSchemeProvider._internal(
(ref) => create(ref as GenColorSchemeRef),
from: from,
name: null,
dependencies: null,
allTransitiveDependencies: null,
debugGetCreateSourceHash: null,
brightness: brightness,
color: color,
ignoreConfig: ignoreConfig,
),
);
}
@override
AutoDisposeProviderElement<ColorScheme> createElement() {
return _GenColorSchemeProviderElement(this);
}
@override
bool operator ==(Object other) {
return other is GenColorSchemeProvider &&
other.brightness == brightness &&
other.color == color &&
other.ignoreConfig == ignoreConfig;
}
@override
int get hashCode {
var hash = _SystemHash.combine(0, runtimeType.hashCode);
hash = _SystemHash.combine(hash, brightness.hashCode);
hash = _SystemHash.combine(hash, color.hashCode);
hash = _SystemHash.combine(hash, ignoreConfig.hashCode);
return _SystemHash.finish(hash);
}
}
@Deprecated('Will be removed in 3.0. Use Ref instead')
// ignore: unused_element
mixin GenColorSchemeRef on AutoDisposeProviderRef<ColorScheme> {
/// The parameter `brightness` of this provider.
Brightness get brightness;
/// The parameter `color` of this provider.
Color? get color;
/// The parameter `ignoreConfig` of this provider.
bool get ignoreConfig;
}
class _GenColorSchemeProviderElement
extends AutoDisposeProviderElement<ColorScheme> with GenColorSchemeRef {
_GenColorSchemeProviderElement(super.provider);
@override
Brightness get brightness => (origin as GenColorSchemeProvider).brightness;
@override
Color? get color => (origin as GenColorSchemeProvider).color;
@override
bool get ignoreConfig => (origin as GenColorSchemeProvider).ignoreConfig;
}
String _$profileOverrideStateHash() =>
r'16d7c75849ed077d60553e5d2bba4ed54b307971';

View File

@@ -1,9 +1,6 @@
import 'package:dynamic_color/dynamic_color.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:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
@@ -208,7 +205,7 @@ ProfilesSelectorState profilesSelectorState(Ref ref) {
final currentProfileId = ref.watch(currentProfileIdProvider);
final profiles = ref.watch(profilesProvider);
final columns = ref.watch(
viewWidthProvider.select((state) => utils.getProfilesColumns(state)));
viewWidthProvider.select((state) => other.getProfilesColumns(state)));
return ProfilesSelectorState(
profiles: profiles,
currentProfileId: currentProfileId,
@@ -409,7 +406,7 @@ int getProxiesColumns(Ref ref) {
final viewWidth = ref.watch(viewWidthProvider);
final proxiesLayout =
ref.watch(proxiesStyleSettingProvider.select((state) => state.layout));
return utils.getProxiesColumns(viewWidth, proxiesLayout);
return other.getProxiesColumns(viewWidth, proxiesLayout);
}
ProxyCardState _getProxyCardState(
@@ -507,38 +504,3 @@ OverrideData? getProfileOverrideData(Ref ref, String profileId) {
),
);
}
@riverpod
ColorScheme genColorScheme(
Ref ref,
Brightness brightness, {
Color? color,
bool ignoreConfig = false,
}) {
final vm2 = ref.watch(
themeSettingProvider.select(
(state) => VM2(
a: state.primaryColor,
b: state.schemeVariant,
),
),
);
if (color == null && (ignoreConfig == true || vm2.a == null)) {
// if (globalState.corePalette != null) {
// return globalState.corePalette!.toColorScheme(brightness: brightness);
// }
return ColorScheme.fromSeed(
seedColor: globalState.corePalette
?.toColorScheme(brightness: brightness)
.primary ??
globalState.accentColor,
brightness: brightness,
dynamicSchemeVariant: vm2.b,
);
}
return ColorScheme.fromSeed(
seedColor: color ?? Color(vm2.a!),
brightness: brightness,
dynamicSchemeVariant: vm2.b,
);
}

View File

@@ -1,7 +1,6 @@
import 'dart:async';
import 'package:animations/animations.dart';
import 'package:dynamic_color/dynamic_color.dart';
import 'package:fl_clash/clash/clash.dart';
import 'package:fl_clash/common/theme.dart';
import 'package:fl_clash/enum/enum.dart';
@@ -10,7 +9,6 @@ import 'package:fl_clash/plugins/service.dart';
import 'package:fl_clash/widgets/dialog.dart';
import 'package:fl_clash/widgets/scaffold.dart';
import 'package:flutter/material.dart';
import 'package:material_color_utilities/palettes/core_palette.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:url_launcher/url_launcher.dart';
@@ -22,7 +20,6 @@ typedef UpdateTasks = List<FutureOr Function()>;
class GlobalState {
static GlobalState? _instance;
Map<Key, double> cacheScrollPosition = {};
bool isService = false;
Timer? timer;
Timer? groupsUpdateTimer;
@@ -33,8 +30,6 @@ class GlobalState {
Function? updateCurrentDelayDebounce;
late Measure measure;
late CommonTheme theme;
late Color accentColor;
CorePalette? corePalette;
DateTime? startTime;
UpdateTasks tasks = [];
final navigatorKey = GlobalKey<NavigatorState>();
@@ -59,17 +54,9 @@ class GlobalState {
traffics: FixedList(30),
totalTraffic: Traffic(),
);
await _initDynamicColor();
await init();
}
_initDynamicColor() async {
try {
corePalette = await DynamicColorPlugin.getCorePalette();
accentColor = await DynamicColorPlugin.getAccentColor() ?? Color(defaultPrimaryColor);
} catch (_) {}
}
init() async {
packageInfo = await PackageInfo.fromPlatform();
config = await preferences.getConfig() ??
@@ -78,7 +65,7 @@ class GlobalState {
);
await globalState.migrateOldData(config);
await AppLocalizations.load(
utils.getLocaleForString(config.appSetting.locale) ??
other.getLocaleForString(config.appSetting.locale) ??
WidgetsBinding.instance.platformDispatcher.locale,
);
}

View File

@@ -32,7 +32,7 @@ class InfoHeader extends StatelessWidget {
return Padding(
padding: padding ?? baseInfoEdgeInsets,
child: Row(
mainAxisSize: MainAxisSize.min,
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Flexible(

View File

@@ -1,6 +1,6 @@
import 'package:fl_clash/providers/providers.dart';
import 'package:fl_clash/models/models.dart';
import 'package:fl_clash/state.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'card.dart';
import 'grid.dart';
@@ -11,17 +11,33 @@ class ColorSchemeBox extends StatelessWidget {
const ColorSchemeBox({
super.key,
required this.primaryColor,
this.primaryColor,
this.onPressed,
this.isSelected,
});
ThemeData _getTheme(BuildContext context) {
if (primaryColor != null) {
return Theme.of(context).copyWith(
colorScheme: ColorScheme.fromSeed(
seedColor: primaryColor!,
brightness: Theme.of(context).brightness,
),
);
} else {
return Theme.of(context).copyWith(
colorScheme: globalState.appState.colorSchemes
.getColorSchemeForBrightness(Theme.of(context).brightness),
);
}
}
@override
Widget build(BuildContext context) {
return AspectRatio(
aspectRatio: 1,
child: PrimaryColorBox(
primaryColor: primaryColor,
child: Theme(
data: _getTheme(context),
child: Builder(
builder: (context) {
final colorScheme = Theme.of(context).colorScheme;
@@ -85,32 +101,3 @@ class ColorSchemeBox extends StatelessWidget {
);
}
}
class PrimaryColorBox extends ConsumerWidget {
final Color? primaryColor;
final Widget child;
const PrimaryColorBox({
super.key,
required this.primaryColor,
required this.child,
});
@override
Widget build(BuildContext context, ref) {
final themeData = Theme.of(context);
final colorScheme = ref.watch(
genColorSchemeProvider(
themeData.brightness,
color: primaryColor,
ignoreConfig: true,
),
);
return Theme(
data: themeData.copyWith(
colorScheme: colorScheme,
),
child: child,
);
}
}

View File

@@ -1,73 +0,0 @@
import 'dart:math' as math;
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
class CommonSafeArea extends StatelessWidget {
const CommonSafeArea({
super.key,
this.left = true,
this.top = true,
this.right = true,
this.bottom = true,
this.minimum = EdgeInsets.zero,
this.maintainBottomViewPadding = false,
required this.child,
});
final bool left;
final bool top;
final bool right;
final bool bottom;
final EdgeInsets minimum;
final bool maintainBottomViewPadding;
final Widget child;
@override
Widget build(BuildContext context) {
assert(debugCheckHasMediaQuery(context));
EdgeInsets padding = MediaQuery.paddingOf(context);
final height = MediaQuery.of(context).size.height;
if (maintainBottomViewPadding) {
padding = padding.copyWith(
bottom: MediaQuery.viewPaddingOf(context).bottom,
);
}
final double realPaddingTop = padding.top > height * 0.5 ? 0 : padding.top;
return Padding(
padding: EdgeInsets.only(
left: math.max(left ? padding.left : 0.0, minimum.left),
top: math.max(top ? realPaddingTop : 0.0, minimum.top),
right: math.max(right ? padding.right : 0.0, minimum.right),
bottom: math.max(bottom ? padding.bottom : 0.0, minimum.bottom),
),
child: MediaQuery.removePadding(
context: context,
removeLeft: left,
removeTop: top,
removeRight: right,
removeBottom: bottom,
child: child,
),
);
}
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties
.add(FlagProperty('left', value: left, ifTrue: 'avoid left padding'));
properties
.add(FlagProperty('top', value: top, ifTrue: 'avoid top padding'));
properties.add(
FlagProperty('right', value: right, ifTrue: 'avoid right padding'));
properties.add(
FlagProperty('bottom', value: bottom, ifTrue: 'avoid bottom padding'));
}
}

View File

@@ -36,13 +36,11 @@ class FadeBox extends StatelessWidget {
class FadeThroughBox extends StatelessWidget {
final Widget child;
final Alignment? alignment;
final EdgeInsets? margin;
const FadeThroughBox({
super.key,
required this.child,
this.alignment,
this.margin
});
@override
@@ -54,7 +52,6 @@ class FadeThroughBox extends StatelessWidget {
secondaryAnimation,
) {
return Container(
margin: margin,
alignment: alignment ?? Alignment.centerLeft,
child: FadeThroughTransition(
animation: animation,

View File

@@ -278,9 +278,6 @@ class ListItem<T> extends StatelessWidget {
onBack: action,
title: openDelegate.title,
body: child,
actions: [
if (openDelegate.action != null) openDelegate.action!,
],
);
},
);
@@ -466,32 +463,6 @@ List<Widget> generateSection({
];
}
Widget generateSectionV2({
String? title,
required Iterable<Widget> items,
List<Widget>? actions,
bool separated = true,
}) {
return Column(
children: [
if (items.isNotEmpty && title != null)
ListHeader(
title: title,
actions: actions,
),
CommonCard(
radius: 18,
type: CommonCardType.filled,
child: Column(
children: [
...items,
],
),
)
],
);
}
List<Widget> generateInfoSection({
required Info info,
required Iterable<Widget> items,
@@ -524,3 +495,132 @@ Widget generateListView(List<Widget> items) {
),
);
}
class CacheItemExtentListView extends StatefulWidget {
final NullableIndexedWidgetBuilder itemBuilder;
final int itemCount;
final String Function(int index) keyBuilder;
final double Function(int index) itemExtentBuilder;
final ScrollPhysics? physics;
final bool shrinkWrap;
final bool reverse;
final ScrollController controller;
const CacheItemExtentListView({
super.key,
this.physics,
this.reverse = false,
this.shrinkWrap = false,
required this.itemBuilder,
required this.controller,
required this.keyBuilder,
required this.itemCount,
required this.itemExtentBuilder,
});
@override
State<CacheItemExtentListView> createState() =>
CacheItemExtentListViewState();
}
class CacheItemExtentListViewState extends State<CacheItemExtentListView> {
late final FixedMap<String, double> _cacheHeightMap;
@override
void initState() {
super.initState();
_cacheHeightMap = FixedMap(widget.itemCount);
}
clearCache() {
_cacheHeightMap.clear();
}
@override
Widget build(BuildContext context) {
_cacheHeightMap.updateMaxSize(widget.itemCount);
return ListView.builder(
itemBuilder: widget.itemBuilder,
itemCount: widget.itemCount,
physics: widget.physics,
reverse: widget.reverse,
shrinkWrap: widget.shrinkWrap,
controller: widget.controller,
itemExtentBuilder: (index, __) {
final key = widget.keyBuilder(index);
if (_cacheHeightMap.containsKey(key)) {
return _cacheHeightMap.get(key);
}
return _cacheHeightMap.put(key, widget.itemExtentBuilder(index));
},
);
}
@override
void dispose() {
_cacheHeightMap.clear();
super.dispose();
}
}
class CacheItemExtentSliverReorderableList extends StatefulWidget {
final IndexedWidgetBuilder itemBuilder;
final int itemCount;
final String Function(int index) keyBuilder;
final double Function(int index) itemExtentBuilder;
final ReorderCallback onReorder;
final ReorderItemProxyDecorator? proxyDecorator;
const CacheItemExtentSliverReorderableList({
super.key,
required this.itemBuilder,
required this.keyBuilder,
required this.itemCount,
required this.itemExtentBuilder,
required this.onReorder,
this.proxyDecorator,
});
@override
State<CacheItemExtentSliverReorderableList> createState() =>
CacheItemExtentSliverReorderableListState();
}
class CacheItemExtentSliverReorderableListState
extends State<CacheItemExtentSliverReorderableList> {
late final FixedMap<String, double> _cacheHeightMap;
@override
void initState() {
super.initState();
_cacheHeightMap = FixedMap(widget.itemCount);
}
clearCache() {
_cacheHeightMap.clear();
}
@override
Widget build(BuildContext context) {
_cacheHeightMap.updateMaxSize(widget.itemCount);
return SliverReorderableList(
itemBuilder: widget.itemBuilder,
itemCount: widget.itemCount,
itemExtentBuilder: (index, __) {
final key = widget.keyBuilder(index);
if (_cacheHeightMap.containsKey(key)) {
return _cacheHeightMap.get(key);
}
return _cacheHeightMap.put(key, widget.itemExtentBuilder(index));
},
onReorder: widget.onReorder,
proxyDecorator: widget.proxyDecorator,
);
}
@override
void dispose() {
_cacheHeightMap.clear();
super.dispose();
}
}

View File

@@ -1,442 +0,0 @@
import 'dart:math' as math;
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
@immutable
class Palette extends StatefulWidget {
const Palette({
super.key,
required this.controller,
});
final ValueNotifier<Color> controller;
@override
State<Palette> createState() => _PaletteState();
}
class _PaletteState extends State<Palette> {
final double _thickness = 20;
final double _radius = 4;
final double _padding = 8;
final GlobalKey renderBoxKey = GlobalKey();
bool isSquare = false;
bool isTrack = false;
late double colorHue;
late double colorSaturation;
late double colorValue;
late FocusNode _focusNode;
Color get value => widget.controller.value;
HSVColor get color => HSVColor.fromColor(value);
@override
void initState() {
super.initState();
colorHue = color.hue;
colorSaturation = color.saturation;
colorValue = color.value;
_focusNode = FocusNode();
}
_handleChange() {
widget.controller.value = HSVColor.fromAHSV(
color.alpha,
colorHue,
colorSaturation,
colorValue,
).toColor();
}
@override
void dispose() {
_focusNode.dispose();
super.dispose();
}
double trackRadius(Size size) =>
math.min(size.width, size.height) / 2 - _thickness;
static double squareRadius(double radius, double trackSquarePadding) =>
(radius - trackSquarePadding) / math.sqrt(2);
void onStart(Offset offset) {
final RenderBox renderBox =
renderBoxKey.currentContext!.findRenderObject()! as RenderBox;
final size = renderBox.size;
final radius = trackRadius(size);
final radiusOuter = radius + _thickness;
final effectiveSquareRadius = squareRadius(radius, _padding);
final startPosition = renderBox.localToGlobal(Offset.zero);
final center = Offset(size.width / 2, size.height / 2);
final vector = offset - startPosition - center;
final vectorLength = _Computer.vectorLength(vector);
isSquare = vector.dx.abs() < effectiveSquareRadius &&
vector.dy.abs() < effectiveSquareRadius;
isTrack = vectorLength >= radius && vectorLength <= radiusOuter;
if (isSquare) {
colorSaturation =
_Computer.vectorToSaturation(vector.dx, effectiveSquareRadius)
.clamp(0.0, 1.0);
colorValue = _Computer.vectorToValue(vector.dy, effectiveSquareRadius)
.clamp(0.0, 1.0);
_handleChange();
} else if (isTrack) {
colorHue = _Computer.vectorToHue(vector);
_handleChange();
} else {
isTrack = false;
isSquare = false;
}
}
void onUpdate(Offset offset) {
final RenderBox renderBox =
renderBoxKey.currentContext!.findRenderObject()! as RenderBox;
final size = renderBox.size;
final radius = trackRadius(size);
final effectiveSquareRadius = squareRadius(radius, _padding);
final startPosition = renderBox.localToGlobal(Offset.zero);
final center = Offset(size.width / 2, size.height / 2);
final vector = offset - startPosition - center;
if (isSquare) {
isTrack = false;
colorSaturation =
_Computer.vectorToSaturation(vector.dx, effectiveSquareRadius)
.clamp(0.0, 1.0);
colorValue = _Computer.vectorToValue(vector.dy, effectiveSquareRadius)
.clamp(0.0, 1.0);
_handleChange();
} else if (isTrack) {
isSquare = false;
colorHue = _Computer.vectorToHue(vector);
_handleChange();
} else {
isTrack = false;
isSquare = false;
}
}
void onEnd() {
isTrack = false;
isSquare = false;
}
@override
Widget build(BuildContext context) {
return ValueListenableBuilder(
valueListenable: widget.controller,
builder: (_, __, ___) {
return GestureDetector(
dragStartBehavior: DragStartBehavior.down,
onVerticalDragDown: (DragDownDetails details) =>
onStart(details.globalPosition),
onVerticalDragUpdate: (DragUpdateDetails details) =>
onUpdate(details.globalPosition),
onHorizontalDragUpdate: (DragUpdateDetails details) =>
onUpdate(details.globalPosition),
onVerticalDragEnd: (DragEndDetails details) => onEnd(),
onHorizontalDragEnd: (DragEndDetails details) => onEnd(),
onTapUp: (TapUpDetails details) => onEnd(),
child: SizedBox(
key: renderBoxKey,
child: Focus(
focusNode: _focusNode,
child: MouseRegion(
cursor: WidgetStateMouseCursor.clickable,
child: Stack(
fit: StackFit.expand,
children: <Widget>[
RepaintBoundary(
child: CustomPaint(
painter: _ShadePainter(
colorHue: colorHue,
colorSaturation: colorSaturation,
colorValue: colorValue,
thickness: _thickness,
padding: _padding,
trackBorderRadius: _radius,
),
),
),
CustomPaint(
painter: _ShadeThumbPainter(
colorSaturation: colorSaturation,
colorValue: colorValue,
thickness: _thickness,
padding: _padding,
),
),
RepaintBoundary(
child: CustomPaint(
painter: _TrackPainter(
thickness: _thickness,
ticks: 360,
),
),
),
CustomPaint(
painter: _TrackThumbPainter(
colorHue: colorHue,
thickness: _thickness,
),
),
],
),
),
),
),
);
},
);
}
}
class _ShadePainter extends CustomPainter {
const _ShadePainter({
required this.colorHue,
required this.colorSaturation,
required this.colorValue,
required this.thickness,
required this.padding,
required this.trackBorderRadius,
}) : super();
final double colorHue;
final double colorSaturation;
final double colorValue;
final double thickness;
final double padding;
final double trackBorderRadius;
static double trackRadius(Size size, double trackWidth) =>
math.min(size.width, size.height) / 2 - trackWidth / 2;
static double squareRadius(
double radius, double trackWidth, double padding) =>
(radius - trackWidth / 2 - padding) / math.sqrt(2);
@override
void paint(Canvas canvas, Size size) {
final Offset center = Offset(size.width / 2, size.height / 2);
final double radius = trackRadius(size, thickness);
final double effectiveSquareRadius = squareRadius(
radius,
thickness,
padding,
);
final Rect rectBox = Rect.fromLTWH(
center.dx - effectiveSquareRadius,
center.dy - effectiveSquareRadius,
effectiveSquareRadius * 2,
effectiveSquareRadius * 2);
final RRect rRect = RRect.fromRectAndRadius(
rectBox,
Radius.circular(trackBorderRadius),
);
final Shader horizontal = LinearGradient(
colors: <Color>[
Colors.white,
HSVColor.fromAHSV(1, colorHue, 1, 1).toColor()
],
).createShader(rectBox);
canvas.drawRRect(
rRect,
Paint()
..style = PaintingStyle.fill
..shader = horizontal);
final Shader vertical = const LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: <Color>[Colors.transparent, Colors.black],
).createShader(rectBox);
canvas.drawRRect(
rRect,
Paint()
..style = PaintingStyle.fill
..shader = vertical);
}
@override
bool shouldRepaint(_ShadePainter oldDelegate) {
return oldDelegate.thickness != thickness ||
oldDelegate.padding != padding ||
oldDelegate.trackBorderRadius != trackBorderRadius ||
oldDelegate.colorHue != colorHue ||
oldDelegate.colorSaturation != colorSaturation ||
oldDelegate.colorValue != colorValue;
}
}
class _TrackPainter extends CustomPainter {
const _TrackPainter({
this.ticks = 360,
required this.thickness,
}) : super();
final int ticks;
final double thickness;
@override
void paint(Canvas canvas, Size size) {
final Offset center = Offset(size.width / 2, size.height / 2);
const double rads = (2 * math.pi) / 360;
const double step = 1;
const double aliasing = 0.5;
final double shortestRectSide = math.min(size.width, size.height);
final Rect rectCircle = Rect.fromCenter(
center: center,
width: shortestRectSide - thickness,
height: shortestRectSide - thickness,
);
for (int i = 0; i < ticks; i++) {
final double sRad = (i - aliasing) * rads;
final double eRad = (i + step) * rads;
final Paint segmentPaint = Paint()
..color = HSVColor.fromAHSV(1, i.toDouble(), 1, 1).toColor()
..style = PaintingStyle.stroke
..strokeWidth = thickness;
canvas.drawArc(
rectCircle,
sRad,
sRad - eRad,
false,
segmentPaint,
);
}
}
@override
bool shouldRepaint(_TrackPainter oldDelegate) {
return oldDelegate.thickness != thickness || oldDelegate.ticks != ticks;
}
}
class _ShadeThumbPainter extends CustomPainter {
const _ShadeThumbPainter({
required this.colorSaturation,
required this.colorValue,
required this.thickness,
required this.padding,
}) : super();
final double colorSaturation;
final double colorValue;
final double thickness;
final double padding;
static double trackRadius(Size size, double thickness) =>
math.min(size.width, size.height) / 2 - thickness / 2;
static double squareRadius(
double radius, double thickness, double trackSquarePadding) =>
(radius - thickness / 2 - trackSquarePadding) / math.sqrt(2);
@override
void paint(Canvas canvas, Size size) {
final Offset center = Offset(size.width / 2, size.height / 2);
final double radius = trackRadius(size, thickness);
final double effectiveSquareRadius =
squareRadius(radius, thickness, padding);
final Paint paintBlack = Paint()
..color = Colors.black
..strokeWidth = 5
..style = PaintingStyle.stroke;
final Paint paintWhite = Paint()
..color = Colors.white
..strokeWidth = 3
..style = PaintingStyle.stroke;
final double paletteX = _Computer.saturationToVector(
colorSaturation, effectiveSquareRadius, center.dx);
final double paletteY =
_Computer.valueToVector(colorValue, effectiveSquareRadius, center.dy);
final Offset paletteVector = Offset(paletteX, paletteY);
canvas.drawCircle(paletteVector, 12, paintBlack);
canvas.drawCircle(paletteVector, 12, paintWhite);
}
@override
bool shouldRepaint(_ShadeThumbPainter oldDelegate) {
return oldDelegate.thickness != thickness ||
oldDelegate.colorSaturation != colorSaturation ||
oldDelegate.colorValue != colorValue ||
oldDelegate.padding != padding;
}
}
class _TrackThumbPainter extends CustomPainter {
const _TrackThumbPainter({
required this.colorHue,
required this.thickness,
}) : super();
final double colorHue;
final double thickness;
static double trackRadius(Size size, double thickness) =>
math.min(size.width, size.height) / 2 - thickness / 2;
@override
void paint(Canvas canvas, Size size) {
final Offset center = Offset(size.width / 2, size.height / 2);
final double radius = trackRadius(size, thickness);
final Paint paintBlack = Paint()
..color = Colors.black
..strokeWidth = 5
..style = PaintingStyle.stroke;
final Paint paintWhite = Paint()
..color = Colors.white
..strokeWidth = 3
..style = PaintingStyle.stroke;
final Offset track = _Computer.hueToVector(
(colorHue + 360.0) * math.pi / 180.0,
radius,
center,
);
canvas.drawCircle(track, thickness / 2 + 4, paintBlack);
canvas.drawCircle(track, thickness / 2 + 4, paintWhite);
}
@override
bool shouldRepaint(_TrackThumbPainter oldDelegate) {
return oldDelegate.thickness != thickness ||
oldDelegate.colorHue != colorHue;
}
}
class _Computer {
static double vectorLength(Offset vector) =>
math.sqrt(vector.dx * vector.dx + vector.dy * vector.dy);
static double vectorToHue(Offset vector) =>
(((math.atan2(vector.dy, vector.dx)) * 180.0 / math.pi) + 360.0) % 360.0;
static double vectorToSaturation(double vectorX, double squareRadius) =>
vectorX * 0.5 / squareRadius + 0.5;
static double vectorToValue(double vectorY, double squareRadius) =>
0.5 - vectorY * 0.5 / squareRadius;
static Offset hueToVector(double h, double radius, Offset center) => Offset(
math.cos(h) * radius + center.dx, math.sin(h) * radius + center.dy);
static double saturationToVector(
double s, double squareRadius, double centerX) =>
(s - 0.5) * squareRadius / 0.5 + centerX;
static double valueToVector(double l, double squareRadius, double centerY) =>
(0.5 - l) * squareRadius / 0.5 + centerY;
}

View File

@@ -126,7 +126,7 @@ class _CommonPopupBoxState extends State<CommonPopupBox> {
Navigator.of(context)
.push(
CommonPopupRoute(
barrierLabel: utils.id,
barrierLabel: other.id,
builder: (BuildContext context) {
return widget.popup;
},

View File

@@ -42,13 +42,11 @@ class CommonScaffold extends StatefulWidget {
required Widget body,
required String title,
required Function onBack,
required List<Widget> actions,
}) : this(
key: key,
body: body,
title: title,
automaticallyImplyLeading: false,
actions: actions,
leading: IconButton(
icon: const BackButtonIcon(),
onPressed: () {
@@ -439,12 +437,8 @@ class CommonScaffoldState extends State<CommonScaffold> {
floatingActionButton: ValueListenableBuilder<Widget?>(
valueListenable: _floatingActionButton,
builder: (_, value, __) {
return IntrinsicWidth(
child: IntrinsicHeight(
child: FadeScaleBox(
child: value ?? SizedBox(),
),
),
return FadeScaleBox(
child: value ?? SizedBox(),
);
},
),

View File

@@ -1,7 +1,3 @@
import 'package:collection/collection.dart';
import 'package:fl_clash/common/common.dart';
import 'package:fl_clash/common/list.dart';
import 'package:fl_clash/state.dart';
import 'package:flutter/material.dart';
class CommonScrollBar extends StatelessWidget {
@@ -49,197 +45,3 @@ class CommonAutoHiddenScrollBar extends StatelessWidget {
);
}
}
class ScrollToEndBox<T> extends StatefulWidget {
final ScrollController controller;
final List<T> dataSource;
final Widget child;
final Key cacheKey;
const ScrollToEndBox({
super.key,
required this.child,
required this.controller,
required this.cacheKey,
required this.dataSource,
});
@override
State<ScrollToEndBox<T>> createState() => _ScrollToEndBoxState<T>();
}
class _ScrollToEndBoxState<T> extends State<ScrollToEndBox<T>> {
final equals = ListEquality<T>();
_handleTryToEnd() {
WidgetsBinding.instance.addPostFrameCallback((_) {
final double offset =
globalState.cacheScrollPosition[widget.cacheKey] ?? -1;
if (offset < 0) {
widget.controller.animateTo(
duration: kThemeAnimationDuration,
widget.controller.position.maxScrollExtent,
curve: Curves.easeOut,
);
}
});
}
@override
void initState() {
super.initState();
globalState.cacheScrollPosition[widget.cacheKey] = -1;
}
@override
void didUpdateWidget(ScrollToEndBox<T> oldWidget) {
super.didUpdateWidget(oldWidget);
if (!equals.equals(oldWidget.dataSource, widget.dataSource)) {
_handleTryToEnd();
}
}
@override
Widget build(BuildContext context) {
return NotificationListener<ScrollNotification>(
onNotification: (details) {
double offset =
details.metrics.pixels == details.metrics.maxScrollExtent
? -1
: details.metrics.pixels;
globalState.cacheScrollPosition[widget.cacheKey] = offset;
return false;
},
child: widget.child,
);
}
}
class CacheItemExtentListView extends StatefulWidget {
final NullableIndexedWidgetBuilder itemBuilder;
final int itemCount;
final String Function(int index) keyBuilder;
final double Function(int index) itemExtentBuilder;
final ScrollPhysics? physics;
final bool shrinkWrap;
final bool reverse;
final ScrollController controller;
const CacheItemExtentListView({
super.key,
this.physics,
this.reverse = false,
this.shrinkWrap = false,
required this.itemBuilder,
required this.controller,
required this.keyBuilder,
required this.itemCount,
required this.itemExtentBuilder,
});
@override
State<CacheItemExtentListView> createState() =>
CacheItemExtentListViewState();
}
class CacheItemExtentListViewState extends State<CacheItemExtentListView> {
late final FixedMap<String, double> _cacheHeightMap;
@override
void initState() {
super.initState();
_cacheHeightMap = FixedMap(widget.itemCount);
}
clearCache() {
_cacheHeightMap.clear();
}
@override
Widget build(BuildContext context) {
_cacheHeightMap.updateMaxSize(widget.itemCount);
return ListView.builder(
itemBuilder: widget.itemBuilder,
itemCount: widget.itemCount,
physics: widget.physics,
reverse: widget.reverse,
shrinkWrap: widget.shrinkWrap,
controller: widget.controller,
itemExtentBuilder: (index, __) {
final key = widget.keyBuilder(index);
if (_cacheHeightMap.containsKey(key)) {
return _cacheHeightMap.get(key);
}
return _cacheHeightMap.put(key, widget.itemExtentBuilder(index));
},
);
}
@override
void dispose() {
_cacheHeightMap.clear();
super.dispose();
}
}
class CacheItemExtentSliverReorderableList extends StatefulWidget {
final IndexedWidgetBuilder itemBuilder;
final int itemCount;
final String Function(int index) keyBuilder;
final double Function(int index) itemExtentBuilder;
final ReorderCallback onReorder;
final ReorderItemProxyDecorator? proxyDecorator;
const CacheItemExtentSliverReorderableList({
super.key,
required this.itemBuilder,
required this.keyBuilder,
required this.itemCount,
required this.itemExtentBuilder,
required this.onReorder,
this.proxyDecorator,
});
@override
State<CacheItemExtentSliverReorderableList> createState() =>
CacheItemExtentSliverReorderableListState();
}
class CacheItemExtentSliverReorderableListState
extends State<CacheItemExtentSliverReorderableList> {
late final FixedMap<String, double> _cacheHeightMap;
@override
void initState() {
super.initState();
_cacheHeightMap = FixedMap(widget.itemCount);
}
clearCache() {
_cacheHeightMap.clear();
}
@override
Widget build(BuildContext context) {
_cacheHeightMap.updateMaxSize(widget.itemCount);
return SliverReorderableList(
itemBuilder: widget.itemBuilder,
itemCount: widget.itemCount,
itemExtentBuilder: (index, __) {
final key = widget.keyBuilder(index);
if (_cacheHeightMap.containsKey(key)) {
return _cacheHeightMap.get(key);
}
return _cacheHeightMap.put(key, widget.itemExtentBuilder(index));
},
onReorder: widget.onReorder,
proxyDecorator: widget.proxyDecorator,
);
}
@override
void dispose() {
_cacheHeightMap.clear();
super.dispose();
}
}

View File

@@ -369,7 +369,6 @@ class SuperGridState extends State<SuperGrid> with TickerProviderStateMixin {
}
_handleDelete(int index) async {
await _transformCompleter?.future;
_preTransformState();
final indexWhere = _tempIndexList.indexWhere((i) => i == index);
_tempIndexList.removeAt(indexWhere);
@@ -485,24 +484,9 @@ class SuperGridState extends State<SuperGrid> with TickerProviderStateMixin {
Widget _draggableWrap({
required Widget childWhenDragging,
required Widget feedback,
required Widget item,
required Widget target,
required int index,
}) {
final target = DragTarget<int>(
builder: (_, __, ___) {
return AbsorbPointer(
child: item,
);
},
onWillAcceptWithDetails: (_) {
debouncer.call(
DebounceTag.handleWill,
_handleWill,
args: [index],
);
return false;
},
);
final shakeTarget = ValueListenableBuilder(
valueListenable: _dragIndexNotifier,
builder: (_, dragIndex, child) {
@@ -555,7 +539,7 @@ class SuperGridState extends State<SuperGrid> with TickerProviderStateMixin {
valueListenable: isEditNotifier,
builder: (_, isEdit, child) {
if (!isEdit) {
return item;
return target;
}
return child!;
},
@@ -574,10 +558,12 @@ class SuperGridState extends State<SuperGrid> with TickerProviderStateMixin {
_itemContexts[index] = context;
final childWhenDragging = ActivateBox(
child: Opacity(
opacity: 0.6,
opacity: 0.3,
child: _sizeBoxWrap(
CommonCard(
child: child,
child: Container(
color: context.colorScheme.secondaryContainer,
),
),
index,
),
@@ -594,11 +580,25 @@ class SuperGridState extends State<SuperGrid> with TickerProviderStateMixin {
index,
),
);
final target = DragTarget<int>(
builder: (_, __, ___) {
return child;
},
onWillAcceptWithDetails: (_) {
debouncer.call(
DebounceTag.handleWill,
_handleWill,
args: [index],
);
return false;
},
);
return _wrapTransform(
_draggableWrap(
childWhenDragging: childWhenDragging,
feedback: feedback,
item: child,
target: target,
index: index,
),
index,
@@ -666,7 +666,8 @@ class SuperGridState extends State<SuperGrid> with TickerProviderStateMixin {
crossAxisSpacing: widget.crossAxisSpacing,
mainAxisSpacing: widget.mainAxisSpacing,
children: [
for (int i = 0; i < children.length; i++) _builderItem(i),
for (int i = 0; i < children.length; i++)
_builderItem(i),
],
);
},

Some files were not shown because too many files have changed in this diff Show More