Compare commits

..

3 Commits

Author SHA1 Message Date
chen08209
c2f3b13deb Update ndk version 2025-04-15 16:52:52 +08:00
chen08209
edc4714488 cache 2025-04-15 16:39:20 +08:00
chen08209
aec325a19a Optimize android vpn performance
Optimize more details
2025-04-15 15:54:36 +08:00
67 changed files with 507 additions and 1818 deletions

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: r28
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

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

@@ -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

@@ -7,7 +7,7 @@ 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';
@@ -43,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
@@ -175,7 +183,7 @@ class ApplicationState extends ConsumerState<Application> {
},
scrollBehavior: BaseScrollBehavior(),
title: appName,
locale: utils.getLocaleForString(locale),
locale: other.getLocaleForString(locale),
supportedLocales: AppLocalizations.delegate.supportedLocales,
themeMode: themeProps.themeMode,
theme: ThemeData(
@@ -183,6 +191,7 @@ class ApplicationState extends ConsumerState<Application> {
pageTransitionsTheme: _pageTransitionsTheme,
colorScheme: _getAppColorScheme(
brightness: Brightness.light,
systemColorSchemes: systemColorSchemes,
primaryColor: themeProps.primaryColor,
),
),
@@ -191,6 +200,7 @@ class ApplicationState extends ConsumerState<Application> {
pageTransitionsTheme: _pageTransitionsTheme,
colorScheme: _getAppColorScheme(
brightness: Brightness.dark,
systemColorSchemes: systemColorSchemes,
primaryColor: themeProps.primaryColor,
).toPureBlack(themeProps.pureBlack),
),

View File

@@ -151,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>();

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,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

@@ -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,
),

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 {
@@ -426,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,
@@ -671,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),
),
);
}
@@ -863,7 +863,7 @@ class AppController {
return utf8.encode(logsRawString);
});
return await picker.saveFile(
utils.logFile,
other.logFile,
Uint8List.fromList(data),
) !=
null;

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

@@ -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

@@ -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

@@ -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,256 +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,
),
);
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,
),
),
);
final primaryColor = vm3.a;
final primaryColors = [null, ...vm3.b];
final schemeVariant = vm3.c;
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,
),
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: () {
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,
),
),
),
],
),
),
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,
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(),
),
),
)
],
);
},
);
},
separatorBuilder: (_, __) {
return const SizedBox(
width: 16,
);
},
itemCount: primaryColors.length,
),
),
);
@@ -445,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) {
@@ -467,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

@@ -122,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),

View File

@@ -372,18 +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"
"saveTip": "Are you sure you want to save?"
}

View File

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

View File

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

View File

@@ -372,18 +372,5 @@
"generalDesc": "修改通用设置",
"findProcessModeDesc": "开启后会有一定性能损耗",
"tabAnimationDesc": "仅在移动视图中有效",
"saveTip": "确定要保存吗?",
"deleteColorTip": "确定删除当前颜色吗?",
"colorExists": "该颜色已存在",
"colorSchemes": "配色方案",
"palette": "调色板",
"tonalSpotScheme": "调性点缀",
"fidelityScheme": "高保真",
"monochromeScheme": "单色",
"neutralScheme": "中性",
"vibrantScheme": "活力",
"expressiveScheme": "表现力",
"contentScheme": "内容主题",
"rainbowScheme": "彩虹",
"fruitSaladScheme": "果缤纷"
"saveTip": "确定要保存吗?"
}

View File

@@ -148,10 +148,6 @@ class MessageLookup extends MessageLookupByLibrary {
"checking": MessageLookupByLibrary.simpleMessage("Checking..."),
"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(
@@ -167,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",
@@ -193,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?",
),
@@ -242,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",
),
@@ -260,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(
@@ -275,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",
@@ -369,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"),
@@ -392,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"),
@@ -449,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",
@@ -520,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(
@@ -638,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"),
@@ -667,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

@@ -106,8 +106,6 @@ class MessageLookup extends MessageLookupByLibrary {
"checking": MessageLookupByLibrary.simpleMessage("確認中..."),
"clipboardExport": MessageLookupByLibrary.simpleMessage("クリップボードにエクスポート"),
"clipboardImport": MessageLookupByLibrary.simpleMessage("クリップボードからインポート"),
"colorExists": MessageLookupByLibrary.simpleMessage("この色は既に存在します"),
"colorSchemes": MessageLookupByLibrary.simpleMessage("カラースキーム"),
"columns": MessageLookupByLibrary.simpleMessage(""),
"compatible": MessageLookupByLibrary.simpleMessage("互換モード"),
"compatibleDesc": MessageLookupByLibrary.simpleMessage(
@@ -119,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("リンクをコピー"),
@@ -141,7 +138,6 @@ class MessageLookup extends MessageLookupByLibrary {
"delay": MessageLookupByLibrary.simpleMessage("遅延"),
"delaySort": MessageLookupByLibrary.simpleMessage("遅延順"),
"delete": MessageLookupByLibrary.simpleMessage("削除"),
"deleteColorTip": MessageLookupByLibrary.simpleMessage("現在の色を削除しますか?"),
"deleteProfileTip": MessageLookupByLibrary.simpleMessage(
"現在のプロファイルを削除しますか?",
),
@@ -176,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で制御可能",
@@ -188,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(
@@ -201,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("地域データ"),
@@ -265,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("名前"),
@@ -280,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("なし"),
@@ -323,7 +314,6 @@ class MessageLookup extends MessageLookupByLibrary {
"有効化するとプロファイルのDNS設定を上書き",
),
"overrideOriginRules": MessageLookupByLibrary.simpleMessage("元のルールを上書き"),
"palette": MessageLookupByLibrary.simpleMessage("パレット"),
"password": MessageLookupByLibrary.simpleMessage("パスワード"),
"passwordTip": MessageLookupByLibrary.simpleMessage("パスワードは必須です"),
"paste": MessageLookupByLibrary.simpleMessage("貼り付け"),
@@ -380,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("プロファイルのみ復元"),
@@ -472,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"),
@@ -495,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

@@ -154,10 +154,6 @@ class MessageLookup extends MessageLookupByLibrary {
"clipboardImport": MessageLookupByLibrary.simpleMessage(
"Импорт из буфера обмена",
),
"colorExists": MessageLookupByLibrary.simpleMessage(
"Этот цвет уже существует",
),
"colorSchemes": MessageLookupByLibrary.simpleMessage("Цветовые схемы"),
"columns": MessageLookupByLibrary.simpleMessage("Столбцы"),
"compatible": MessageLookupByLibrary.simpleMessage("Режим совместимости"),
"compatibleDesc": MessageLookupByLibrary.simpleMessage(
@@ -173,7 +169,6 @@ class MessageLookup extends MessageLookupByLibrary {
"contentEmptyTip": MessageLookupByLibrary.simpleMessage(
"Содержание не может быть пустым",
),
"contentScheme": MessageLookupByLibrary.simpleMessage("Контентная тема"),
"copy": MessageLookupByLibrary.simpleMessage("Копировать"),
"copyEnvVar": MessageLookupByLibrary.simpleMessage(
"Копирование переменных окружения",
@@ -201,9 +196,6 @@ class MessageLookup extends MessageLookupByLibrary {
"delay": MessageLookupByLibrary.simpleMessage("Задержка"),
"delaySort": MessageLookupByLibrary.simpleMessage("Сортировка по задержке"),
"delete": MessageLookupByLibrary.simpleMessage("Удалить"),
"deleteColorTip": MessageLookupByLibrary.simpleMessage(
"Удалить текущий цвет?",
),
"deleteProfileTip": MessageLookupByLibrary.simpleMessage(
"Вы уверены, что хотите удалить текущий профиль?",
),
@@ -256,7 +248,6 @@ class MessageLookup extends MessageLookupByLibrary {
"exportFile": MessageLookupByLibrary.simpleMessage("Экспорт файла"),
"exportLogs": MessageLookupByLibrary.simpleMessage("Экспорт логов"),
"exportSuccess": MessageLookupByLibrary.simpleMessage("Экспорт успешен"),
"expressiveScheme": MessageLookupByLibrary.simpleMessage("Экспрессивные"),
"externalController": MessageLookupByLibrary.simpleMessage(
"Внешний контроллер",
),
@@ -276,7 +267,6 @@ class MessageLookup extends MessageLookupByLibrary {
"fallbackFilter": MessageLookupByLibrary.simpleMessage(
"Фильтр резервного DNS",
),
"fidelityScheme": MessageLookupByLibrary.simpleMessage("Точная передача"),
"file": MessageLookupByLibrary.simpleMessage("Файл"),
"fileDesc": MessageLookupByLibrary.simpleMessage("Прямая загрузка профиля"),
"fileIsUpdate": MessageLookupByLibrary.simpleMessage(
@@ -293,7 +283,6 @@ class MessageLookup extends MessageLookupByLibrary {
),
"fontFamily": MessageLookupByLibrary.simpleMessage("Семейство шрифтов"),
"fourColumns": MessageLookupByLibrary.simpleMessage("Четыре столбца"),
"fruitSaladScheme": MessageLookupByLibrary.simpleMessage("Фруктовый микс"),
"general": MessageLookupByLibrary.simpleMessage("Общие"),
"generalDesc": MessageLookupByLibrary.simpleMessage(
"Изменение общих настроек",
@@ -395,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("Имя"),
@@ -418,7 +406,6 @@ class MessageLookup extends MessageLookupByLibrary {
"Обнаружение сети",
),
"networkSpeed": MessageLookupByLibrary.simpleMessage("Скорость сети"),
"neutralScheme": MessageLookupByLibrary.simpleMessage("Нейтральные"),
"noData": MessageLookupByLibrary.simpleMessage("Нет данных"),
"noHotKey": MessageLookupByLibrary.simpleMessage("Нет горячей клавиши"),
"noIcon": MessageLookupByLibrary.simpleMessage("Нет иконки"),
@@ -479,7 +466,6 @@ class MessageLookup extends MessageLookupByLibrary {
"overrideOriginRules": MessageLookupByLibrary.simpleMessage(
"Переопределить оригинальное правило",
),
"palette": MessageLookupByLibrary.simpleMessage("Палитра"),
"password": MessageLookupByLibrary.simpleMessage("Пароль"),
"passwordTip": MessageLookupByLibrary.simpleMessage(
"Пароль не может быть пустым",
@@ -552,7 +538,6 @@ class MessageLookup extends MessageLookupByLibrary {
"qrcodeDesc": MessageLookupByLibrary.simpleMessage(
"Сканируйте QR-код для получения профиля",
),
"rainbowScheme": MessageLookupByLibrary.simpleMessage("Радужные"),
"recovery": MessageLookupByLibrary.simpleMessage("Восстановление"),
"recoveryAll": MessageLookupByLibrary.simpleMessage(
"Восстановить все данные",
@@ -676,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(
"Использование трафика",
@@ -711,7 +695,6 @@ class MessageLookup extends MessageLookupByLibrary {
"valueExists": MessageLookupByLibrary.simpleMessage(
"Текущее значение уже существует",
),
"vibrantScheme": MessageLookupByLibrary.simpleMessage("Яркие"),
"view": MessageLookupByLibrary.simpleMessage("Просмотр"),
"vpnDesc": MessageLookupByLibrary.simpleMessage(
"Изменение настроек, связанных с VPN",

View File

@@ -96,8 +96,6 @@ class MessageLookup extends MessageLookupByLibrary {
"checking": MessageLookupByLibrary.simpleMessage("检测中..."),
"clipboardExport": MessageLookupByLibrary.simpleMessage("导出剪贴板"),
"clipboardImport": MessageLookupByLibrary.simpleMessage("剪贴板导入"),
"colorExists": MessageLookupByLibrary.simpleMessage("该颜色已存在"),
"colorSchemes": MessageLookupByLibrary.simpleMessage("配色方案"),
"columns": MessageLookupByLibrary.simpleMessage("列数"),
"compatible": MessageLookupByLibrary.simpleMessage("兼容模式"),
"compatibleDesc": MessageLookupByLibrary.simpleMessage(
@@ -109,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("复制链接"),
@@ -129,7 +126,6 @@ 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(
@@ -160,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内核",
@@ -172,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("文件有修改,是否保存修改"),
@@ -181,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("地理数据"),
@@ -237,7 +230,6 @@ class MessageLookup extends MessageLookupByLibrary {
"minimizeOnExitDesc": MessageLookupByLibrary.simpleMessage("修改系统默认退出事件"),
"minutes": MessageLookupByLibrary.simpleMessage("分钟"),
"mode": MessageLookupByLibrary.simpleMessage("模式"),
"monochromeScheme": MessageLookupByLibrary.simpleMessage("单色"),
"months": MessageLookupByLibrary.simpleMessage(""),
"more": MessageLookupByLibrary.simpleMessage("更多"),
"name": MessageLookupByLibrary.simpleMessage("名称"),
@@ -250,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("无图标"),
@@ -285,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("粘贴"),
@@ -334,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("仅恢复配置文件"),
@@ -416,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("虚拟网卡"),
@@ -437,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,106 +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: [],
);
}
}
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

@@ -36,7 +36,7 @@ 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);
@@ -91,7 +91,7 @@ class MessageManagerState extends State<MessageManager> {
),
elevation: 10,
margin: EdgeInsets.only(
top: kToolbarHeight + 8,
top: kToolbarHeight,
left: 12,
right: 12,
),

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

@@ -36,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,7 +36,10 @@ const defaultNetworkProps = NetworkProps();
const defaultProxiesStyle = ProxiesStyle();
const defaultWindowProps = WindowProps();
const defaultAccessControl = AccessControl();
const defaultThemeProps = ThemeProps();
final defaultThemeProps = ThemeProps().copyWith(
primaryColor: defaultPrimaryColor.toARGB32(),
themeMode: ThemeMode.dark,
);
const List<DashboardWidget> defaultDashboardWidgets = [
DashboardWidget.networkSpeed,
@@ -73,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,
@@ -140,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
@@ -173,15 +175,24 @@ class ProxiesStyle with _$ProxiesStyle {
@freezed
class ThemeProps with _$ThemeProps {
const factory ThemeProps({
@Default(defaultPrimaryColor) int? primaryColor,
@Default(defaultPrimaryColors) List<int> primaryColors,
@Default(ThemeMode.dark) ThemeMode themeMode,
@Default(DynamicSchemeVariant.tonalSpot) DynamicSchemeVariant schemeVariant,
int? primaryColor,
@Default(ThemeMode.system) ThemeMode themeMode,
@Default(false) bool pureBlack,
}) = _ThemeProps;
factory ThemeProps.fromJson(Map<String, Object?>? json) =>
json == null ? defaultThemeProps : _$ThemePropsFromJson(json);
factory ThemeProps.fromJson(Map<String, Object?> json) =>
_$ThemePropsFromJson(json);
factory ThemeProps.safeFromJson(Map<String, Object?>? json) {
if (json == null) {
return defaultThemeProps;
}
try {
return ThemeProps.fromJson(json);
} catch (_) {
return defaultThemeProps;
}
}
}
@freezed
@@ -197,7 +208,7 @@ class Config with _$Config {
DAV? dav,
@Default(defaultNetworkProps) NetworkProps networkProps,
@Default(defaultVpnProps) VpnProps vpnProps,
@Default(defaultThemeProps) ThemeProps themeProps,
@JsonKey(fromJson: ThemeProps.safeFromJson) required ThemeProps themeProps,
@Default(defaultProxiesStyle) ProxiesStyle proxiesStyle,
@Default(defaultWindowProps) WindowProps windowProps,
@Default(defaultClashConfig) ClashConfig patchClashConfig,

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,

View File

@@ -301,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,
@@ -1724,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.
@@ -1745,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
@@ -1769,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(
@@ -1779,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
@@ -1807,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
@@ -1829,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(
@@ -1839,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
@@ -1863,41 +1831,25 @@ class __$$ThemePropsImplCopyWithImpl<$Res>
@JsonSerializable()
class _$ThemePropsImpl implements _ThemeProps {
const _$ThemePropsImpl(
{this.primaryColor = defaultPrimaryColor,
final List<int> primaryColors = defaultPrimaryColors,
this.themeMode = ThemeMode.dark,
this.schemeVariant = DynamicSchemeVariant.tonalSpot,
this.pureBlack = false})
: _primaryColors = primaryColors;
{this.primaryColor,
this.themeMode = ThemeMode.system,
this.pureBlack = false});
factory _$ThemePropsImpl.fromJson(Map<String, dynamic> json) =>
_$$ThemePropsImplFromJson(json);
@override
@JsonKey()
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
@@ -1907,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.
@@ -1946,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) =
@@ -1957,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
@@ -1988,6 +1925,7 @@ mixin _$Config {
DAV? get dav => throw _privateConstructorUsedError;
NetworkProps get networkProps => throw _privateConstructorUsedError;
VpnProps get vpnProps => throw _privateConstructorUsedError;
@JsonKey(fromJson: ThemeProps.safeFromJson)
ThemeProps get themeProps => throw _privateConstructorUsedError;
ProxiesStyle get proxiesStyle => throw _privateConstructorUsedError;
WindowProps get windowProps => throw _privateConstructorUsedError;
@@ -2017,7 +1955,7 @@ abstract class $ConfigCopyWith<$Res> {
DAV? dav,
NetworkProps networkProps,
VpnProps vpnProps,
ThemeProps themeProps,
@JsonKey(fromJson: ThemeProps.safeFromJson) ThemeProps themeProps,
ProxiesStyle proxiesStyle,
WindowProps windowProps,
ClashConfig patchClashConfig});
@@ -2214,7 +2152,7 @@ abstract class _$$ConfigImplCopyWith<$Res> implements $ConfigCopyWith<$Res> {
DAV? dav,
NetworkProps networkProps,
VpnProps vpnProps,
ThemeProps themeProps,
@JsonKey(fromJson: ThemeProps.safeFromJson) ThemeProps themeProps,
ProxiesStyle proxiesStyle,
WindowProps windowProps,
ClashConfig patchClashConfig});
@@ -2329,7 +2267,7 @@ class _$ConfigImpl implements _Config {
this.dav,
this.networkProps = defaultNetworkProps,
this.vpnProps = defaultVpnProps,
this.themeProps = defaultThemeProps,
@JsonKey(fromJson: ThemeProps.safeFromJson) required this.themeProps,
this.proxiesStyle = defaultProxiesStyle,
this.windowProps = defaultWindowProps,
this.patchClashConfig = defaultClashConfig})
@@ -2374,7 +2312,7 @@ class _$ConfigImpl implements _Config {
@JsonKey()
final VpnProps vpnProps;
@override
@JsonKey()
@JsonKey(fromJson: ThemeProps.safeFromJson)
final ThemeProps themeProps;
@override
@JsonKey()
@@ -2464,7 +2402,8 @@ abstract class _Config implements Config {
final DAV? dav,
final NetworkProps networkProps,
final VpnProps vpnProps,
final ThemeProps themeProps,
@JsonKey(fromJson: ThemeProps.safeFromJson)
required final ThemeProps themeProps,
final ProxiesStyle proxiesStyle,
final WindowProps windowProps,
final ClashConfig patchClashConfig}) = _$ConfigImpl;
@@ -2489,6 +2428,7 @@ abstract class _Config implements Config {
@override
VpnProps get vpnProps;
@override
@JsonKey(fromJson: ThemeProps.safeFromJson)
ThemeProps get themeProps;
@override
ProxiesStyle get proxiesStyle;

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,
@@ -221,26 +221,16 @@ const _$ProxyCardTypeEnumMap = {
_$ThemePropsImpl _$$ThemePropsImplFromJson(Map<String, dynamic> json) =>
_$ThemePropsImpl(
primaryColor:
(json['primaryColor'] as num?)?.toInt() ?? defaultPrimaryColor,
primaryColors: (json['primaryColors'] as List<dynamic>?)
?.map((e) => (e as num).toInt())
.toList() ??
defaultPrimaryColors,
primaryColor: (json['primaryColor'] as num?)?.toInt(),
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,
};
@@ -250,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
@@ -287,9 +265,8 @@ _$ConfigImpl _$$ConfigImplFromJson(Map<String, dynamic> json) => _$ConfigImpl(
vpnProps: json['vpnProps'] == null
? defaultVpnProps
: VpnProps.fromJson(json['vpnProps'] as Map<String, dynamic>?),
themeProps: json['themeProps'] == null
? defaultThemeProps
: ThemeProps.fromJson(json['themeProps'] as Map<String, dynamic>?),
themeProps:
ThemeProps.safeFromJson(json['themeProps'] as Map<String, Object?>?),
proxiesStyle: json['proxiesStyle'] == null
? defaultProxiesStyle
: ProxiesStyle.fromJson(

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

@@ -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

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)

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'a27ccae9b5c11d47cd46804f42f8e9dc7946a6c2';
/// 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 isOverride = false,
}) {
return GenColorSchemeProvider(
brightness,
color: color,
isOverride: isOverride,
);
}
@override
GenColorSchemeProvider getProviderOverride(
covariant GenColorSchemeProvider provider,
) {
return call(
provider.brightness,
color: provider.color,
isOverride: provider.isOverride,
);
}
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 isOverride = false,
}) : this._internal(
(ref) => genColorScheme(
ref as GenColorSchemeRef,
brightness,
color: color,
isOverride: isOverride,
),
from: genColorSchemeProvider,
name: r'genColorSchemeProvider',
debugGetCreateSourceHash:
const bool.fromEnvironment('dart.vm.product')
? null
: _$genColorSchemeHash,
dependencies: GenColorSchemeFamily._dependencies,
allTransitiveDependencies:
GenColorSchemeFamily._allTransitiveDependencies,
brightness: brightness,
color: color,
isOverride: isOverride,
);
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.isOverride,
}) : super.internal();
final Brightness brightness;
final Color? color;
final bool isOverride;
@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,
isOverride: isOverride,
),
);
}
@override
AutoDisposeProviderElement<ColorScheme> createElement() {
return _GenColorSchemeProviderElement(this);
}
@override
bool operator ==(Object other) {
return other is GenColorSchemeProvider &&
other.brightness == brightness &&
other.color == color &&
other.isOverride == isOverride;
}
@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, isOverride.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 `isOverride` of this provider.
bool get isOverride;
}
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 isOverride => (origin as GenColorSchemeProvider).isOverride;
}
String _$profileOverrideStateHash() =>
r'16d7c75849ed077d60553e5d2bba4ed54b307971';

View File

@@ -1,7 +1,6 @@
import 'package:fl_clash/common/common.dart';
import 'package:fl_clash/enum/enum.dart';
import 'package:fl_clash/models/models.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
@@ -206,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,
@@ -407,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(
@@ -505,32 +504,3 @@ OverrideData? getProfileOverrideData(Ref ref, String profileId) {
),
);
}
@riverpod
ColorScheme genColorScheme(
Ref ref,
Brightness brightness, {
Color? color,
bool isOverride = false,
}) {
final vm2 = ref.watch(
themeSettingProvider.select(
(state) => VM2(
a: state.primaryColor,
b: state.schemeVariant,
),
),
);
if (color == null && (isOverride == true || vm2.a == null)) {
final colorSchemes = ref.watch(appSchemesProvider);
return colorSchemes.getColorSchemeForBrightness(
brightness,
vm2.b,
);
}
return ColorScheme.fromSeed(
seedColor: color ?? Color(vm2.a!),
brightness: brightness,
dynamicSchemeVariant: vm2.b,
);
}

View File

@@ -20,7 +20,6 @@ typedef UpdateTasks = List<FutureOr Function()>;
class GlobalState {
static GlobalState? _instance;
Map<Key, double> cacheScrollPosition = {};
bool isService = false;
Timer? timer;
Timer? groupsUpdateTimer;
@@ -66,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,
isOverride: true,
),
);
return Theme(
data: themeData.copyWith(
colorScheme: colorScheme,
),
child: child,
);
}
}

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!,
],
);
},
);
@@ -497,4 +494,133 @@ Widget generateListView(List<Widget> items) {
bottom: 16,
),
);
}
}
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: () {

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

@@ -29,4 +29,3 @@ export 'wave.dart';
export 'scroll.dart';
export 'dialog.dart';
export 'effect.dart';
export 'palette.dart';

View File

@@ -744,7 +744,7 @@
"@executable_path/../Frameworks",
);
LIBRARY_SEARCH_PATHS = "";
PRODUCT_BUNDLE_IDENTIFIER = com.follow.clash.debug;
PRODUCT_BUNDLE_IDENTIFIER = com.follow.clash;
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;

View File

@@ -1,7 +1,7 @@
name: fl_clash
description: A multi-platform proxy client based on ClashMeta, simple and easy to use, open-source and ad-free.
publish_to: 'none'
version: 0.8.82+202504182
version: 0.8.82+202504152
environment:
sdk: '>=3.1.0 <4.0.0'

View File

@@ -19,26 +19,16 @@ media = []
files = {}
i = 1
releaseKeywords = [
"windows-amd64-setup",
"android-arm64",
"macos-arm64",
"macos-amd64"
]
for file in os.listdir(DIST_DIR):
file_path = os.path.join(DIST_DIR, file)
if os.path.isfile(file_path):
file_lower = file.lower()
if any(kw in file_lower for kw in releaseKeywords):
file_key = f"file{i}"
media.append({
"type": "document",
"media": f"attach://{file_key}"
})
files[file_key] = open(file_path, 'rb')
i += 1
file_key = f"file{i}"
media.append({
"type": "document",
"media": f"attach://{file_key}"
})
files[file_key] = open(file_path, 'rb')
i += 1
if TAG:
text += f"\n**{TAG}**\n"
@@ -66,4 +56,4 @@ response = requests.post(
files=files
)
print("Response JSON:", response.json())
print("Response JSON:", response.json())

View File

@@ -199,6 +199,7 @@ class Build {
required Mode mode,
required Target target,
Arch? arch,
bool stable = false,
}) async {
final isLib = mode == Mode.lib;
@@ -237,7 +238,9 @@ class Build {
if (isLib) {
env["CGO_ENABLED"] = "1";
env["CC"] = _getCc(item);
env["CFLAGS"] = "-O3 -Werror";
if (stable) {
env["CFLAGS"] = "-O3 -Werror";
}
} else {
env["CGO_ENABLED"] = "0";
}
@@ -245,7 +248,7 @@ class Build {
final execLines = [
"go",
"build",
"-ldflags=-w -s",
if (stable) "-ldflags=-w -s",
"-tags=$tags",
if (isLib) "-buildmode=c-shared",
"-o",
@@ -437,7 +440,7 @@ class BuildCommand extends Command {
await Build.exec(
name: name,
Build.getExecutable(
"flutter_distributor package --skip-clean --platform ${target.name} --targets $targets --flutter-build-args=verbose$args --build-dart-define=APP_ENV=$env",
"flutter_distributor package --skip-clean --platform ${target.name} --targets $targets --flutter-build-args=verbose $args --build-dart-define=APP_ENV=$env",
),
);
}
@@ -470,6 +473,7 @@ class BuildCommand extends Command {
target: target,
arch: arch,
mode: mode,
stable: env == "stable"
);
if (target == Target.windows) {
@@ -485,7 +489,7 @@ class BuildCommand extends Command {
_buildDistributor(
target: target,
targets: "exe,zip",
args: " --description $archName",
args: "--description $archName",
env: env,
);
return;
@@ -507,7 +511,7 @@ class BuildCommand extends Command {
target: target,
targets: targets,
args:
" --description $archName --build-target-platform $defaultTarget",
"--description $archName --build-target-platform $defaultTarget",
env: env,
);
return;
@@ -526,7 +530,7 @@ class BuildCommand extends Command {
target: target,
targets: "apk",
args:
",split-per-abi --build-target-platform ${defaultTargets.join(",")}",
"--flutter-build-args split-per-abi --build-target-platform ${defaultTargets.join(",")}",
env: env,
);
return;
@@ -535,7 +539,7 @@ class BuildCommand extends Command {
_buildDistributor(
target: target,
targets: "dmg",
args: " --description $archName",
args: "--description $archName",
env: env,
);
return;