2024-04-30 23:38:49 +08:00
|
|
|
import 'package:fl_clash/enum/enum.dart';
|
2026-10-16 22:42:17 +08:00
|
|
|
import 'package:fl_clash/ui/color.dart';
|
2026-09-05 20:09:39 +08:00
|
|
|
import 'package:material_ui/material_ui.dart';
|
2024-04-30 23:38:49 +08:00
|
|
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
|
|
|
|
|
2025-12-16 11:23:09 +08:00
|
|
|
import 'app.dart';
|
|
|
|
|
import 'clash_config.dart';
|
|
|
|
|
import 'common.dart';
|
|
|
|
|
import 'core.dart';
|
|
|
|
|
import 'profile.dart';
|
|
|
|
|
|
|
|
|
|
part 'generated/state.freezed.dart';
|
|
|
|
|
part 'generated/state.g.dart';
|
2024-04-30 23:38:49 +08:00
|
|
|
|
2026-02-02 10:14:13 +08:00
|
|
|
@freezed
|
2026-09-05 20:09:39 +08:00
|
|
|
abstract class SelectValue<T> with _$SelectValue<T> {
|
|
|
|
|
const factory SelectValue(T value) = _SelectValue;
|
2025-12-16 11:23:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@freezed
|
|
|
|
|
abstract class CommonMessage with _$CommonMessage {
|
|
|
|
|
const factory CommonMessage({
|
|
|
|
|
required String id,
|
|
|
|
|
required String text,
|
2026-09-05 20:09:39 +08:00
|
|
|
@Default(MessageLevel.info) MessageLevel level,
|
2025-12-16 11:23:09 +08:00
|
|
|
@Default(Duration(seconds: 3)) Duration duration,
|
|
|
|
|
MessageActionState? actionState,
|
|
|
|
|
}) = _CommonMessage;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@freezed
|
|
|
|
|
abstract class MessageActionState with _$MessageActionState {
|
|
|
|
|
const factory MessageActionState({
|
|
|
|
|
required String actionText,
|
|
|
|
|
required VoidCallback action,
|
|
|
|
|
}) = _MessageActionState;
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-30 23:38:49 +08:00
|
|
|
@freezed
|
2025-12-16 11:23:09 +08:00
|
|
|
abstract class ProfilesState with _$ProfilesState {
|
|
|
|
|
const factory ProfilesState({
|
2024-04-30 23:38:49 +08:00
|
|
|
required List<Profile> profiles,
|
2025-12-16 11:23:09 +08:00
|
|
|
required int? currentProfileId,
|
|
|
|
|
}) = _ProfilesState;
|
2024-04-30 23:38:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@freezed
|
2025-07-31 17:09:18 +08:00
|
|
|
abstract class TrayState with _$TrayState {
|
2024-09-08 21:21:21 +08:00
|
|
|
const factory TrayState({
|
2024-04-30 23:38:49 +08:00
|
|
|
required Mode mode,
|
2024-12-03 21:47:12 +08:00
|
|
|
required int port,
|
2024-04-30 23:38:49 +08:00
|
|
|
required bool autoLaunch,
|
2024-08-23 18:33:40 +08:00
|
|
|
required bool systemProxy,
|
|
|
|
|
required bool tunEnable,
|
|
|
|
|
required bool isStart,
|
2026-10-16 22:42:17 +08:00
|
|
|
@Default(false) bool suspended,
|
2024-12-03 21:47:12 +08:00
|
|
|
required List<Group> groups,
|
2025-10-14 15:13:52 +08:00
|
|
|
required Map<String, String> selectedMap,
|
|
|
|
|
required bool showTrayTitle,
|
2026-09-25 03:57:04 +08:00
|
|
|
required bool safeMode,
|
|
|
|
|
@Default({}) Map<HotAction, HotKeyAction> hotKeys,
|
2024-09-08 21:21:21 +08:00
|
|
|
}) = _TrayState;
|
2024-04-30 23:38:49 +08:00
|
|
|
}
|
|
|
|
|
|
2025-10-14 15:13:52 +08:00
|
|
|
@freezed
|
|
|
|
|
abstract class TrayTitleState with _$TrayTitleState {
|
|
|
|
|
const factory TrayTitleState({
|
|
|
|
|
required Traffic traffic,
|
|
|
|
|
required bool showTrayTitle,
|
|
|
|
|
}) = _TrayTitleState;
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-30 23:38:49 +08:00
|
|
|
@freezed
|
2025-07-31 17:09:18 +08:00
|
|
|
abstract class NavigationState with _$NavigationState {
|
2025-06-07 01:48:34 +08:00
|
|
|
const factory NavigationState({
|
2025-02-09 18:39:38 +08:00
|
|
|
required PageLabel pageLabel,
|
2024-05-20 15:15:09 +08:00
|
|
|
required List<NavigationItem> navigationItems,
|
|
|
|
|
required ViewMode viewMode,
|
2024-04-30 23:38:49 +08:00
|
|
|
required String? locale,
|
2025-06-07 01:48:34 +08:00
|
|
|
required int currentIndex,
|
|
|
|
|
}) = _NavigationState;
|
2025-02-09 18:39:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@freezed
|
2025-07-31 17:09:18 +08:00
|
|
|
abstract class GroupsState with _$GroupsState {
|
|
|
|
|
const factory GroupsState({required List<Group> value}) = _GroupsState;
|
2025-02-09 18:39:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@freezed
|
2025-07-31 17:09:18 +08:00
|
|
|
abstract class NavigationItemsState with _$NavigationItemsState {
|
|
|
|
|
const factory NavigationItemsState({required List<NavigationItem> value}) =
|
|
|
|
|
_NavigationItemsState;
|
2025-02-09 18:39:38 +08:00
|
|
|
}
|
|
|
|
|
|
2024-07-24 01:27:49 +08:00
|
|
|
@freezed
|
2025-07-31 17:09:18 +08:00
|
|
|
abstract class ProxiesListState with _$ProxiesListState {
|
2025-06-07 01:48:34 +08:00
|
|
|
const factory ProxiesListState({
|
|
|
|
|
required List<Group> groups,
|
2024-07-24 01:27:49 +08:00
|
|
|
required Set<String> currentUnfoldSet,
|
|
|
|
|
required ProxyCardType proxyCardType,
|
2025-06-07 01:48:34 +08:00
|
|
|
}) = _ProxiesListState;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@freezed
|
2025-07-31 17:09:18 +08:00
|
|
|
abstract class ProxiesTabState with _$ProxiesTabState {
|
2025-06-07 01:48:34 +08:00
|
|
|
const factory ProxiesTabState({
|
|
|
|
|
required List<Group> groups,
|
|
|
|
|
required String? currentGroupName,
|
|
|
|
|
required ProxyCardType proxyCardType,
|
|
|
|
|
}) = _ProxiesTabState;
|
2024-07-24 01:27:49 +08:00
|
|
|
}
|
|
|
|
|
|
2026-09-05 20:09:39 +08:00
|
|
|
@freezed
|
|
|
|
|
abstract class ProxiesTabControllerState with _$ProxiesTabControllerState {
|
|
|
|
|
const factory ProxiesTabControllerState({
|
|
|
|
|
required List<String> groupNames,
|
|
|
|
|
required String? currentGroupName,
|
|
|
|
|
}) = _ProxiesTabControllerState;
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-20 15:15:09 +08:00
|
|
|
@freezed
|
2025-07-31 17:09:18 +08:00
|
|
|
abstract class MoreToolsSelectorState with _$MoreToolsSelectorState {
|
2024-05-20 15:15:09 +08:00
|
|
|
const factory MoreToolsSelectorState({
|
|
|
|
|
required List<NavigationItem> navigationItems,
|
|
|
|
|
}) = _MoreToolsSelectorState;
|
2024-06-03 11:24:41 +08:00
|
|
|
}
|
|
|
|
|
|
2024-08-15 16:18:00 +08:00
|
|
|
@freezed
|
2025-07-31 17:09:18 +08:00
|
|
|
abstract class ProxyState with _$ProxyState {
|
2024-08-15 16:18:00 +08:00
|
|
|
const factory ProxyState({
|
|
|
|
|
required bool isStart,
|
|
|
|
|
required bool systemProxy,
|
2024-11-09 20:17:57 +08:00
|
|
|
required List<String> bassDomain,
|
2024-08-15 16:18:00 +08:00
|
|
|
required int port,
|
|
|
|
|
}) = _ProxyState;
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-05 20:09:39 +08:00
|
|
|
@freezed
|
|
|
|
|
abstract class ThemeColorsSelectorState with _$ThemeColorsSelectorState {
|
|
|
|
|
const factory ThemeColorsSelectorState({
|
|
|
|
|
required int? primaryColor,
|
|
|
|
|
required List<int> primaryColors,
|
2026-10-16 22:42:17 +08:00
|
|
|
required ColorStyle colorStyle,
|
2026-09-05 20:09:39 +08:00
|
|
|
required bool isDefault,
|
|
|
|
|
}) = _ThemeColorsSelectorState;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@freezed
|
|
|
|
|
abstract class SystemProxySelectorState with _$SystemProxySelectorState {
|
|
|
|
|
const factory SystemProxySelectorState({
|
|
|
|
|
required bool systemProxy,
|
|
|
|
|
required List<String> bypassDomain,
|
|
|
|
|
}) = _SystemProxySelectorState;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@freezed
|
|
|
|
|
abstract class CurrentProfileSelectorState with _$CurrentProfileSelectorState {
|
|
|
|
|
const factory CurrentProfileSelectorState({
|
|
|
|
|
required String label,
|
|
|
|
|
required Map<String, String> selectedMap,
|
|
|
|
|
}) = _CurrentProfileSelectorState;
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-09 01:40:39 +08:00
|
|
|
@freezed
|
2025-07-31 17:09:18 +08:00
|
|
|
abstract class DashboardState with _$DashboardState {
|
2024-12-09 01:40:39 +08:00
|
|
|
const factory DashboardState({
|
|
|
|
|
required List<DashboardWidget> dashboardWidgets,
|
|
|
|
|
}) = _DashboardState;
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-05 16:08:50 +08:00
|
|
|
@freezed
|
2025-07-31 17:09:18 +08:00
|
|
|
abstract class SelectedProxyState with _$SelectedProxyState {
|
|
|
|
|
const factory SelectedProxyState({
|
2025-03-05 16:08:50 +08:00
|
|
|
required String proxyName,
|
2025-07-31 17:09:18 +08:00
|
|
|
@Default(false) bool group,
|
2025-03-05 16:08:50 +08:00
|
|
|
String? testUrl,
|
2025-07-31 17:09:18 +08:00
|
|
|
}) = _SelectedProxyState;
|
2025-03-05 16:08:50 +08:00
|
|
|
}
|
|
|
|
|
|
2025-03-12 17:15:31 +08:00
|
|
|
@freezed
|
2025-12-16 11:23:09 +08:00
|
|
|
abstract class SharedState with _$SharedState {
|
|
|
|
|
const factory SharedState({
|
|
|
|
|
SetupParams? setupParams,
|
|
|
|
|
VpnOptions? vpnOptions,
|
|
|
|
|
required String stopTip,
|
|
|
|
|
required String startTip,
|
2026-09-25 03:57:04 +08:00
|
|
|
required String localNetworkTip,
|
2025-12-16 11:23:09 +08:00
|
|
|
required String currentProfileName,
|
|
|
|
|
required String stopText,
|
|
|
|
|
required bool onlyStatisticsProxy,
|
2026-09-05 20:09:39 +08:00
|
|
|
@Default(true) bool showStopAction,
|
2025-12-16 11:23:09 +08:00
|
|
|
}) = _SharedState;
|
|
|
|
|
|
|
|
|
|
factory SharedState.fromJson(Map<String, Object?> json) =>
|
|
|
|
|
_$SharedStateFromJson(json);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
extension SharedStateExt on SharedState {
|
|
|
|
|
SharedState get needSyncSharedState => copyWith(setupParams: null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@freezed
|
|
|
|
|
abstract class ComputeGroupsState with _$ComputeGroupsState {
|
|
|
|
|
const factory ComputeGroupsState({
|
|
|
|
|
required ProxiesData proxiesData,
|
|
|
|
|
required ProxiesSortType sortType,
|
|
|
|
|
required DelayMap delayMap,
|
|
|
|
|
required Map<String, String> selectedMap,
|
|
|
|
|
required String defaultTestUrl,
|
|
|
|
|
}) = _ComputeGroupsState;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@freezed
|
|
|
|
|
abstract class MakeRealProfileState with _$MakeRealProfileState {
|
|
|
|
|
const factory MakeRealProfileState({
|
|
|
|
|
required String profilesPath,
|
|
|
|
|
required int profileId,
|
|
|
|
|
required Map<String, dynamic> rawConfig,
|
2026-02-02 10:14:13 +08:00
|
|
|
required PatchClashConfig realPatchConfig,
|
2026-10-08 17:58:43 +08:00
|
|
|
@Default(ProfileOverrides()) ProfileOverrides overrides,
|
2026-10-16 22:42:17 +08:00
|
|
|
@Default(false) bool bypassPrivateRoute,
|
2026-10-08 17:58:43 +08:00
|
|
|
|
|
|
|
|
/// Set for a subscription, whose own DNS values an emptied entry replaces.
|
|
|
|
|
@Default(false) bool keepEmptyDnsOverrides,
|
2025-12-16 11:23:09 +08:00
|
|
|
required bool appendSystemDns,
|
2026-02-02 10:14:13 +08:00
|
|
|
required List<ProxyGroup> proxyGroups,
|
|
|
|
|
required List<Rule> rules,
|
2025-12-16 11:23:09 +08:00
|
|
|
required List<Rule> addedRules,
|
|
|
|
|
required String defaultUA,
|
2026-09-05 20:09:39 +08:00
|
|
|
@Default([]) List<String> authentication,
|
2026-09-25 03:57:04 +08:00
|
|
|
@Default({}) Map<String, dynamic> injectedProxyProviders,
|
|
|
|
|
@Default({}) Map<String, dynamic> injectedRuleProviders,
|
2026-09-05 20:09:39 +08:00
|
|
|
String? matchTarget,
|
2026-09-25 03:57:04 +08:00
|
|
|
@Default(false) bool safeMode,
|
2025-12-16 11:23:09 +08:00
|
|
|
}) = _MakeRealProfileState;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@freezed
|
|
|
|
|
abstract class MigrationData with _$MigrationData {
|
|
|
|
|
const factory MigrationData({
|
|
|
|
|
Map<String, Object?>? configMap,
|
|
|
|
|
@Default([]) List<Rule> rules,
|
|
|
|
|
@Default([]) List<Script> scripts,
|
|
|
|
|
@Default([]) List<Profile> profiles,
|
2026-10-08 17:58:43 +08:00
|
|
|
@Default([]) List<DisabledRule> disabledRules,
|
2026-02-02 10:14:13 +08:00
|
|
|
@Default([]) List<ProxyGroup> proxyGroups,
|
2026-09-25 03:57:04 +08:00
|
|
|
@Default([]) List<ClashProvider> clashProviders,
|
|
|
|
|
@Default([]) List<CustomProxy> customProxies,
|
2026-10-08 17:58:43 +08:00
|
|
|
@Default([]) List<ProxyDialer> proxyDialers,
|
2025-12-16 11:23:09 +08:00
|
|
|
}) = _MigrationData;
|
2025-04-09 16:46:14 +08:00
|
|
|
}
|
2025-10-14 15:13:52 +08:00
|
|
|
|
|
|
|
|
@freezed
|
|
|
|
|
abstract class SetupState with _$SetupState {
|
|
|
|
|
const factory SetupState({
|
2025-12-16 11:23:09 +08:00
|
|
|
required int? profileId,
|
2025-10-14 15:13:52 +08:00
|
|
|
required int? profileLastUpdateDate,
|
2026-10-08 17:58:43 +08:00
|
|
|
required ProfileType profileType,
|
|
|
|
|
required ExtendType extendType,
|
2026-02-02 10:14:13 +08:00
|
|
|
required List<Rule> rules,
|
|
|
|
|
required List<ProxyGroup> proxyGroups,
|
2025-10-14 15:13:52 +08:00
|
|
|
required List<Rule> addedRules,
|
2025-12-16 11:23:09 +08:00
|
|
|
required Script? script,
|
2026-10-08 17:58:43 +08:00
|
|
|
required ProfileOverrides overrides,
|
2026-09-25 03:57:04 +08:00
|
|
|
@Default([]) List<ClashProvider> clashProviders,
|
|
|
|
|
@Default({}) Map<String, int> profileProviders,
|
2026-10-08 17:58:43 +08:00
|
|
|
@Default([]) List<CustomProxy> appProxies,
|
|
|
|
|
@Default({}) Map<int, String> proxyDialers,
|
2026-09-05 20:09:39 +08:00
|
|
|
String? matchTarget,
|
2025-10-14 15:13:52 +08:00
|
|
|
}) = _SetupState;
|
|
|
|
|
}
|