This commit is contained in:
chen08209
2026-02-06 15:38:01 +08:00
parent c46168eff8
commit b742ab76bc
12 changed files with 201 additions and 155 deletions

View File

@@ -1,9 +1,9 @@
part of 'database.dart';
@DataClassName('RawGroup')
class Groups extends Table {
@DataClassName('RawProxyGroup')
class ProxyGroups extends Table {
@override
String get tableName => 'groups';
String get tableName => 'proxy_groups';
IntColumn get profileId => integer().nullable().references(
Profiles,

View File

@@ -45,7 +45,7 @@ enum GroupType {
Relay;
static GroupType parseProfileType(String type) {
return switch (type) {
return switch (type.toLowerCase()) {
'url-test' => URLTest,
'select' => Selector,
'fallback' => Fallback,

View File

@@ -63,7 +63,6 @@ class RuleStatusItem extends StatelessWidget {
child: Container(
margin: EdgeInsets.symmetric(vertical: 4),
child: CommonCard(
padding: EdgeInsets.zero,
radius: 18,
type: CommonCardType.filled,
onPressed: () {

View File

@@ -114,7 +114,7 @@ abstract class ProxyGroup with _$ProxyGroup {
String? filter,
@JsonKey(name: 'expected-filter') String? excludeFilter,
@JsonKey(name: 'exclude-type') String? excludeType,
@JsonKey(name: 'expected-status') dynamic expectedStatus,
@JsonKey(name: 'expected-status') String? expectedStatus,
bool? hidden,
String? icon,
}) = _ProxyGroup;
@@ -211,7 +211,7 @@ abstract class FallbackFilter with _$FallbackFilter {
const factory FallbackFilter({
@Default(true) bool geoip,
@Default('CN') @JsonKey(name: 'geoip-code') String geoipCode,
@Default(['gfw']) List<String> geosite,
@Default(['']) List<String> geosite,
@Default(['240.0.0.0/4']) List<String> ipcidr,
@Default(['+.google.com', '+.facebook.com', '+.youtube.com'])
List<String> domain,
@@ -413,29 +413,29 @@ List<Rule> _genRule(List<dynamic>? rules) {
return rules.map((item) => Rule.value(item)).toList();
}
List<RuleProvider> _genRuleProviders(Map<String, dynamic> json) {
return json.entries.map((entry) => RuleProvider(name: entry.key)).toList();
}
List<SubRule> _genSubRules(Map<String, dynamic> json) {
return json.entries.map((entry) => SubRule(name: entry.key)).toList();
}
// List<RuleProvider> _genRuleProviders(Map<String, dynamic> json) {
// return json.entries.map((entry) => RuleProvider(name: entry.key)).toList();
// }
//
// List<SubRule> _genSubRules(Map<String, dynamic> json) {
// return json.entries.map((entry) => SubRule(name: entry.key)).toList();
// }
@freezed
abstract class ClashConfigSnippet with _$ClashConfigSnippet {
const factory ClashConfigSnippet({
abstract class CustomClashConfig with _$CustomClashConfig {
const factory CustomClashConfig({
@Default([]) @JsonKey(name: 'proxy-groups') List<ProxyGroup> proxyGroups,
@JsonKey(fromJson: _genRule, name: 'rules') @Default([]) List<Rule> rule,
@JsonKey(name: 'rule-providers', fromJson: _genRuleProviders)
@Default([])
List<RuleProvider> ruleProvider,
@JsonKey(name: 'sub-rules', fromJson: _genSubRules)
@Default([])
List<SubRule> subRules,
}) = _ClashConfigSnippet;
// @JsonKey(name: 'rule-providers', fromJson: _genRuleProviders)
// @Default([])
// List<RuleProvider> ruleProvider,
// @JsonKey(name: 'sub-rules', fromJson: _genSubRules)
// @Default([])
// List<SubRule> subRules,
}) = _CustomClashConfig;
factory ClashConfigSnippet.fromJson(Map<String, Object?> json) =>
_$ClashConfigSnippetFromJson(json);
factory CustomClashConfig.fromJson(Map<String, Object?> json) =>
_$CustomClashConfigFromJson(json);
}
@freezed

View File

@@ -15,7 +15,7 @@ T _$identity<T>(T value) => value;
/// @nodoc
mixin _$ProxyGroup {
String get name;@JsonKey(fromJson: GroupType.parseProfileType) GroupType get type; List<String>? get proxies; List<String>? get use; int? get interval; bool? get lazy; String? get url; int? get timeout;@JsonKey(name: 'max-failed-times') int? get maxFailedTimes; String? get filter;@JsonKey(name: 'expected-filter') String? get excludeFilter;@JsonKey(name: 'exclude-type') String? get excludeType;@JsonKey(name: 'expected-status') dynamic get expectedStatus; bool? get hidden; String? get icon;
String get name;@JsonKey(fromJson: GroupType.parseProfileType) GroupType get type; List<String>? get proxies; List<String>? get use; int? get interval; bool? get lazy; String? get url; int? get timeout;@JsonKey(name: 'max-failed-times') int? get maxFailedTimes; String? get filter;@JsonKey(name: 'expected-filter') String? get excludeFilter;@JsonKey(name: 'exclude-type') String? get excludeType;@JsonKey(name: 'expected-status') String? get expectedStatus; bool? get hidden; String? get icon;
/// Create a copy of ProxyGroup
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@@ -28,12 +28,12 @@ $ProxyGroupCopyWith<ProxyGroup> get copyWith => _$ProxyGroupCopyWithImpl<ProxyGr
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is ProxyGroup&&(identical(other.name, name) || other.name == name)&&(identical(other.type, type) || other.type == type)&&const DeepCollectionEquality().equals(other.proxies, proxies)&&const DeepCollectionEquality().equals(other.use, use)&&(identical(other.interval, interval) || other.interval == interval)&&(identical(other.lazy, lazy) || other.lazy == lazy)&&(identical(other.url, url) || other.url == url)&&(identical(other.timeout, timeout) || other.timeout == timeout)&&(identical(other.maxFailedTimes, maxFailedTimes) || other.maxFailedTimes == maxFailedTimes)&&(identical(other.filter, filter) || other.filter == filter)&&(identical(other.excludeFilter, excludeFilter) || other.excludeFilter == excludeFilter)&&(identical(other.excludeType, excludeType) || other.excludeType == excludeType)&&const DeepCollectionEquality().equals(other.expectedStatus, expectedStatus)&&(identical(other.hidden, hidden) || other.hidden == hidden)&&(identical(other.icon, icon) || other.icon == icon));
return identical(this, other) || (other.runtimeType == runtimeType&&other is ProxyGroup&&(identical(other.name, name) || other.name == name)&&(identical(other.type, type) || other.type == type)&&const DeepCollectionEquality().equals(other.proxies, proxies)&&const DeepCollectionEquality().equals(other.use, use)&&(identical(other.interval, interval) || other.interval == interval)&&(identical(other.lazy, lazy) || other.lazy == lazy)&&(identical(other.url, url) || other.url == url)&&(identical(other.timeout, timeout) || other.timeout == timeout)&&(identical(other.maxFailedTimes, maxFailedTimes) || other.maxFailedTimes == maxFailedTimes)&&(identical(other.filter, filter) || other.filter == filter)&&(identical(other.excludeFilter, excludeFilter) || other.excludeFilter == excludeFilter)&&(identical(other.excludeType, excludeType) || other.excludeType == excludeType)&&(identical(other.expectedStatus, expectedStatus) || other.expectedStatus == expectedStatus)&&(identical(other.hidden, hidden) || other.hidden == hidden)&&(identical(other.icon, icon) || other.icon == icon));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,name,type,const DeepCollectionEquality().hash(proxies),const DeepCollectionEquality().hash(use),interval,lazy,url,timeout,maxFailedTimes,filter,excludeFilter,excludeType,const DeepCollectionEquality().hash(expectedStatus),hidden,icon);
int get hashCode => Object.hash(runtimeType,name,type,const DeepCollectionEquality().hash(proxies),const DeepCollectionEquality().hash(use),interval,lazy,url,timeout,maxFailedTimes,filter,excludeFilter,excludeType,expectedStatus,hidden,icon);
@override
String toString() {
@@ -48,7 +48,7 @@ abstract mixin class $ProxyGroupCopyWith<$Res> {
factory $ProxyGroupCopyWith(ProxyGroup value, $Res Function(ProxyGroup) _then) = _$ProxyGroupCopyWithImpl;
@useResult
$Res call({
String name,@JsonKey(fromJson: GroupType.parseProfileType) GroupType type, List<String>? proxies, List<String>? use, int? interval, bool? lazy, String? url, int? timeout,@JsonKey(name: 'max-failed-times') int? maxFailedTimes, String? filter,@JsonKey(name: 'expected-filter') String? excludeFilter,@JsonKey(name: 'exclude-type') String? excludeType,@JsonKey(name: 'expected-status') dynamic expectedStatus, bool? hidden, String? icon
String name,@JsonKey(fromJson: GroupType.parseProfileType) GroupType type, List<String>? proxies, List<String>? use, int? interval, bool? lazy, String? url, int? timeout,@JsonKey(name: 'max-failed-times') int? maxFailedTimes, String? filter,@JsonKey(name: 'expected-filter') String? excludeFilter,@JsonKey(name: 'exclude-type') String? excludeType,@JsonKey(name: 'expected-status') String? expectedStatus, bool? hidden, String? icon
});
@@ -80,7 +80,7 @@ as int?,filter: freezed == filter ? _self.filter : filter // ignore: cast_nullab
as String?,excludeFilter: freezed == excludeFilter ? _self.excludeFilter : excludeFilter // ignore: cast_nullable_to_non_nullable
as String?,excludeType: freezed == excludeType ? _self.excludeType : excludeType // ignore: cast_nullable_to_non_nullable
as String?,expectedStatus: freezed == expectedStatus ? _self.expectedStatus : expectedStatus // ignore: cast_nullable_to_non_nullable
as dynamic,hidden: freezed == hidden ? _self.hidden : hidden // ignore: cast_nullable_to_non_nullable
as String?,hidden: freezed == hidden ? _self.hidden : hidden // ignore: cast_nullable_to_non_nullable
as bool?,icon: freezed == icon ? _self.icon : icon // ignore: cast_nullable_to_non_nullable
as String?,
));
@@ -167,7 +167,7 @@ return $default(_that);case _:
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String name, @JsonKey(fromJson: GroupType.parseProfileType) GroupType type, List<String>? proxies, List<String>? use, int? interval, bool? lazy, String? url, int? timeout, @JsonKey(name: 'max-failed-times') int? maxFailedTimes, String? filter, @JsonKey(name: 'expected-filter') String? excludeFilter, @JsonKey(name: 'exclude-type') String? excludeType, @JsonKey(name: 'expected-status') dynamic expectedStatus, bool? hidden, String? icon)? $default,{required TResult orElse(),}) {final _that = this;
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String name, @JsonKey(fromJson: GroupType.parseProfileType) GroupType type, List<String>? proxies, List<String>? use, int? interval, bool? lazy, String? url, int? timeout, @JsonKey(name: 'max-failed-times') int? maxFailedTimes, String? filter, @JsonKey(name: 'expected-filter') String? excludeFilter, @JsonKey(name: 'exclude-type') String? excludeType, @JsonKey(name: 'expected-status') String? expectedStatus, bool? hidden, String? icon)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _ProxyGroup() when $default != null:
return $default(_that.name,_that.type,_that.proxies,_that.use,_that.interval,_that.lazy,_that.url,_that.timeout,_that.maxFailedTimes,_that.filter,_that.excludeFilter,_that.excludeType,_that.expectedStatus,_that.hidden,_that.icon);case _:
@@ -188,7 +188,7 @@ return $default(_that.name,_that.type,_that.proxies,_that.use,_that.interval,_th
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String name, @JsonKey(fromJson: GroupType.parseProfileType) GroupType type, List<String>? proxies, List<String>? use, int? interval, bool? lazy, String? url, int? timeout, @JsonKey(name: 'max-failed-times') int? maxFailedTimes, String? filter, @JsonKey(name: 'expected-filter') String? excludeFilter, @JsonKey(name: 'exclude-type') String? excludeType, @JsonKey(name: 'expected-status') dynamic expectedStatus, bool? hidden, String? icon) $default,) {final _that = this;
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String name, @JsonKey(fromJson: GroupType.parseProfileType) GroupType type, List<String>? proxies, List<String>? use, int? interval, bool? lazy, String? url, int? timeout, @JsonKey(name: 'max-failed-times') int? maxFailedTimes, String? filter, @JsonKey(name: 'expected-filter') String? excludeFilter, @JsonKey(name: 'exclude-type') String? excludeType, @JsonKey(name: 'expected-status') String? expectedStatus, bool? hidden, String? icon) $default,) {final _that = this;
switch (_that) {
case _ProxyGroup():
return $default(_that.name,_that.type,_that.proxies,_that.use,_that.interval,_that.lazy,_that.url,_that.timeout,_that.maxFailedTimes,_that.filter,_that.excludeFilter,_that.excludeType,_that.expectedStatus,_that.hidden,_that.icon);case _:
@@ -208,7 +208,7 @@ return $default(_that.name,_that.type,_that.proxies,_that.use,_that.interval,_th
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String name, @JsonKey(fromJson: GroupType.parseProfileType) GroupType type, List<String>? proxies, List<String>? use, int? interval, bool? lazy, String? url, int? timeout, @JsonKey(name: 'max-failed-times') int? maxFailedTimes, String? filter, @JsonKey(name: 'expected-filter') String? excludeFilter, @JsonKey(name: 'exclude-type') String? excludeType, @JsonKey(name: 'expected-status') dynamic expectedStatus, bool? hidden, String? icon)? $default,) {final _that = this;
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String name, @JsonKey(fromJson: GroupType.parseProfileType) GroupType type, List<String>? proxies, List<String>? use, int? interval, bool? lazy, String? url, int? timeout, @JsonKey(name: 'max-failed-times') int? maxFailedTimes, String? filter, @JsonKey(name: 'expected-filter') String? excludeFilter, @JsonKey(name: 'exclude-type') String? excludeType, @JsonKey(name: 'expected-status') String? expectedStatus, bool? hidden, String? icon)? $default,) {final _that = this;
switch (_that) {
case _ProxyGroup() when $default != null:
return $default(_that.name,_that.type,_that.proxies,_that.use,_that.interval,_that.lazy,_that.url,_that.timeout,_that.maxFailedTimes,_that.filter,_that.excludeFilter,_that.excludeType,_that.expectedStatus,_that.hidden,_that.icon);case _:
@@ -254,7 +254,7 @@ class _ProxyGroup implements ProxyGroup {
@override final String? filter;
@override@JsonKey(name: 'expected-filter') final String? excludeFilter;
@override@JsonKey(name: 'exclude-type') final String? excludeType;
@override@JsonKey(name: 'expected-status') final dynamic expectedStatus;
@override@JsonKey(name: 'expected-status') final String? expectedStatus;
@override final bool? hidden;
@override final String? icon;
@@ -271,12 +271,12 @@ Map<String, dynamic> toJson() {
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ProxyGroup&&(identical(other.name, name) || other.name == name)&&(identical(other.type, type) || other.type == type)&&const DeepCollectionEquality().equals(other._proxies, _proxies)&&const DeepCollectionEquality().equals(other._use, _use)&&(identical(other.interval, interval) || other.interval == interval)&&(identical(other.lazy, lazy) || other.lazy == lazy)&&(identical(other.url, url) || other.url == url)&&(identical(other.timeout, timeout) || other.timeout == timeout)&&(identical(other.maxFailedTimes, maxFailedTimes) || other.maxFailedTimes == maxFailedTimes)&&(identical(other.filter, filter) || other.filter == filter)&&(identical(other.excludeFilter, excludeFilter) || other.excludeFilter == excludeFilter)&&(identical(other.excludeType, excludeType) || other.excludeType == excludeType)&&const DeepCollectionEquality().equals(other.expectedStatus, expectedStatus)&&(identical(other.hidden, hidden) || other.hidden == hidden)&&(identical(other.icon, icon) || other.icon == icon));
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ProxyGroup&&(identical(other.name, name) || other.name == name)&&(identical(other.type, type) || other.type == type)&&const DeepCollectionEquality().equals(other._proxies, _proxies)&&const DeepCollectionEquality().equals(other._use, _use)&&(identical(other.interval, interval) || other.interval == interval)&&(identical(other.lazy, lazy) || other.lazy == lazy)&&(identical(other.url, url) || other.url == url)&&(identical(other.timeout, timeout) || other.timeout == timeout)&&(identical(other.maxFailedTimes, maxFailedTimes) || other.maxFailedTimes == maxFailedTimes)&&(identical(other.filter, filter) || other.filter == filter)&&(identical(other.excludeFilter, excludeFilter) || other.excludeFilter == excludeFilter)&&(identical(other.excludeType, excludeType) || other.excludeType == excludeType)&&(identical(other.expectedStatus, expectedStatus) || other.expectedStatus == expectedStatus)&&(identical(other.hidden, hidden) || other.hidden == hidden)&&(identical(other.icon, icon) || other.icon == icon));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,name,type,const DeepCollectionEquality().hash(_proxies),const DeepCollectionEquality().hash(_use),interval,lazy,url,timeout,maxFailedTimes,filter,excludeFilter,excludeType,const DeepCollectionEquality().hash(expectedStatus),hidden,icon);
int get hashCode => Object.hash(runtimeType,name,type,const DeepCollectionEquality().hash(_proxies),const DeepCollectionEquality().hash(_use),interval,lazy,url,timeout,maxFailedTimes,filter,excludeFilter,excludeType,expectedStatus,hidden,icon);
@override
String toString() {
@@ -291,7 +291,7 @@ abstract mixin class _$ProxyGroupCopyWith<$Res> implements $ProxyGroupCopyWith<$
factory _$ProxyGroupCopyWith(_ProxyGroup value, $Res Function(_ProxyGroup) _then) = __$ProxyGroupCopyWithImpl;
@override @useResult
$Res call({
String name,@JsonKey(fromJson: GroupType.parseProfileType) GroupType type, List<String>? proxies, List<String>? use, int? interval, bool? lazy, String? url, int? timeout,@JsonKey(name: 'max-failed-times') int? maxFailedTimes, String? filter,@JsonKey(name: 'expected-filter') String? excludeFilter,@JsonKey(name: 'exclude-type') String? excludeType,@JsonKey(name: 'expected-status') dynamic expectedStatus, bool? hidden, String? icon
String name,@JsonKey(fromJson: GroupType.parseProfileType) GroupType type, List<String>? proxies, List<String>? use, int? interval, bool? lazy, String? url, int? timeout,@JsonKey(name: 'max-failed-times') int? maxFailedTimes, String? filter,@JsonKey(name: 'expected-filter') String? excludeFilter,@JsonKey(name: 'exclude-type') String? excludeType,@JsonKey(name: 'expected-status') String? expectedStatus, bool? hidden, String? icon
});
@@ -323,7 +323,7 @@ as int?,filter: freezed == filter ? _self.filter : filter // ignore: cast_nullab
as String?,excludeFilter: freezed == excludeFilter ? _self.excludeFilter : excludeFilter // ignore: cast_nullable_to_non_nullable
as String?,excludeType: freezed == excludeType ? _self.excludeType : excludeType // ignore: cast_nullable_to_non_nullable
as String?,expectedStatus: freezed == expectedStatus ? _self.expectedStatus : expectedStatus // ignore: cast_nullable_to_non_nullable
as dynamic,hidden: freezed == hidden ? _self.hidden : hidden // ignore: cast_nullable_to_non_nullable
as String?,hidden: freezed == hidden ? _self.hidden : hidden // ignore: cast_nullable_to_non_nullable
as bool?,icon: freezed == icon ? _self.icon : icon // ignore: cast_nullable_to_non_nullable
as String?,
));
@@ -1694,7 +1694,7 @@ return $default(_that.geoip,_that.geoipCode,_that.geosite,_that.ipcidr,_that.dom
@JsonSerializable()
class _FallbackFilter implements FallbackFilter {
const _FallbackFilter({this.geoip = true, @JsonKey(name: 'geoip-code') this.geoipCode = 'CN', final List<String> geosite = const ['gfw'], final List<String> ipcidr = const ['240.0.0.0/4'], final List<String> domain = const ['+.google.com', '+.facebook.com', '+.youtube.com']}): _geosite = geosite,_ipcidr = ipcidr,_domain = domain;
const _FallbackFilter({this.geoip = true, @JsonKey(name: 'geoip-code') this.geoipCode = 'CN', final List<String> geosite = const [''], final List<String> ipcidr = const ['240.0.0.0/4'], final List<String> domain = const ['+.google.com', '+.facebook.com', '+.youtube.com']}): _geosite = geosite,_ipcidr = ipcidr,_domain = domain;
factory _FallbackFilter.fromJson(Map<String, dynamic> json) => _$FallbackFilterFromJson(json);
@override@JsonKey() final bool geoip;
@@ -3228,42 +3228,42 @@ as String,
/// @nodoc
mixin _$ClashConfigSnippet {
mixin _$CustomClashConfig {
@JsonKey(name: 'proxy-groups') List<ProxyGroup> get proxyGroups;@JsonKey(fromJson: _genRule, name: 'rules') List<Rule> get rule;@JsonKey(name: 'rule-providers', fromJson: _genRuleProviders) List<RuleProvider> get ruleProvider;@JsonKey(name: 'sub-rules', fromJson: _genSubRules) List<SubRule> get subRules;
/// Create a copy of ClashConfigSnippet
@JsonKey(name: 'proxy-groups') List<ProxyGroup> get proxyGroups;@JsonKey(fromJson: _genRule, name: 'rules') List<Rule> get rule;
/// Create a copy of CustomClashConfig
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$ClashConfigSnippetCopyWith<ClashConfigSnippet> get copyWith => _$ClashConfigSnippetCopyWithImpl<ClashConfigSnippet>(this as ClashConfigSnippet, _$identity);
$CustomClashConfigCopyWith<CustomClashConfig> get copyWith => _$CustomClashConfigCopyWithImpl<CustomClashConfig>(this as CustomClashConfig, _$identity);
/// Serializes this ClashConfigSnippet to a JSON map.
/// Serializes this CustomClashConfig to a JSON map.
Map<String, dynamic> toJson();
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is ClashConfigSnippet&&const DeepCollectionEquality().equals(other.proxyGroups, proxyGroups)&&const DeepCollectionEquality().equals(other.rule, rule)&&const DeepCollectionEquality().equals(other.ruleProvider, ruleProvider)&&const DeepCollectionEquality().equals(other.subRules, subRules));
return identical(this, other) || (other.runtimeType == runtimeType&&other is CustomClashConfig&&const DeepCollectionEquality().equals(other.proxyGroups, proxyGroups)&&const DeepCollectionEquality().equals(other.rule, rule));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(proxyGroups),const DeepCollectionEquality().hash(rule),const DeepCollectionEquality().hash(ruleProvider),const DeepCollectionEquality().hash(subRules));
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(proxyGroups),const DeepCollectionEquality().hash(rule));
@override
String toString() {
return 'ClashConfigSnippet(proxyGroups: $proxyGroups, rule: $rule, ruleProvider: $ruleProvider, subRules: $subRules)';
return 'CustomClashConfig(proxyGroups: $proxyGroups, rule: $rule)';
}
}
/// @nodoc
abstract mixin class $ClashConfigSnippetCopyWith<$Res> {
factory $ClashConfigSnippetCopyWith(ClashConfigSnippet value, $Res Function(ClashConfigSnippet) _then) = _$ClashConfigSnippetCopyWithImpl;
abstract mixin class $CustomClashConfigCopyWith<$Res> {
factory $CustomClashConfigCopyWith(CustomClashConfig value, $Res Function(CustomClashConfig) _then) = _$CustomClashConfigCopyWithImpl;
@useResult
$Res call({
@JsonKey(name: 'proxy-groups') List<ProxyGroup> proxyGroups,@JsonKey(fromJson: _genRule, name: 'rules') List<Rule> rule,@JsonKey(name: 'rule-providers', fromJson: _genRuleProviders) List<RuleProvider> ruleProvider,@JsonKey(name: 'sub-rules', fromJson: _genSubRules) List<SubRule> subRules
@JsonKey(name: 'proxy-groups') List<ProxyGroup> proxyGroups,@JsonKey(fromJson: _genRule, name: 'rules') List<Rule> rule
});
@@ -3271,30 +3271,28 @@ $Res call({
}
/// @nodoc
class _$ClashConfigSnippetCopyWithImpl<$Res>
implements $ClashConfigSnippetCopyWith<$Res> {
_$ClashConfigSnippetCopyWithImpl(this._self, this._then);
class _$CustomClashConfigCopyWithImpl<$Res>
implements $CustomClashConfigCopyWith<$Res> {
_$CustomClashConfigCopyWithImpl(this._self, this._then);
final ClashConfigSnippet _self;
final $Res Function(ClashConfigSnippet) _then;
final CustomClashConfig _self;
final $Res Function(CustomClashConfig) _then;
/// Create a copy of ClashConfigSnippet
/// Create a copy of CustomClashConfig
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? proxyGroups = null,Object? rule = null,Object? ruleProvider = null,Object? subRules = null,}) {
@pragma('vm:prefer-inline') @override $Res call({Object? proxyGroups = null,Object? rule = null,}) {
return _then(_self.copyWith(
proxyGroups: null == proxyGroups ? _self.proxyGroups : proxyGroups // ignore: cast_nullable_to_non_nullable
as List<ProxyGroup>,rule: null == rule ? _self.rule : rule // ignore: cast_nullable_to_non_nullable
as List<Rule>,ruleProvider: null == ruleProvider ? _self.ruleProvider : ruleProvider // ignore: cast_nullable_to_non_nullable
as List<RuleProvider>,subRules: null == subRules ? _self.subRules : subRules // ignore: cast_nullable_to_non_nullable
as List<SubRule>,
as List<Rule>,
));
}
}
/// Adds pattern-matching-related methods to [ClashConfigSnippet].
extension ClashConfigSnippetPatterns on ClashConfigSnippet {
/// Adds pattern-matching-related methods to [CustomClashConfig].
extension CustomClashConfigPatterns on CustomClashConfig {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
@@ -3307,10 +3305,10 @@ extension ClashConfigSnippetPatterns on ClashConfigSnippet {
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _ClashConfigSnippet value)? $default,{required TResult orElse(),}){
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _CustomClashConfig value)? $default,{required TResult orElse(),}){
final _that = this;
switch (_that) {
case _ClashConfigSnippet() when $default != null:
case _CustomClashConfig() when $default != null:
return $default(_that);case _:
return orElse();
@@ -3329,10 +3327,10 @@ return $default(_that);case _:
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _ClashConfigSnippet value) $default,){
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _CustomClashConfig value) $default,){
final _that = this;
switch (_that) {
case _ClashConfigSnippet():
case _CustomClashConfig():
return $default(_that);case _:
throw StateError('Unexpected subclass');
@@ -3350,10 +3348,10 @@ return $default(_that);case _:
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _ClashConfigSnippet value)? $default,){
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _CustomClashConfig value)? $default,){
final _that = this;
switch (_that) {
case _ClashConfigSnippet() when $default != null:
case _CustomClashConfig() when $default != null:
return $default(_that);case _:
return null;
@@ -3371,10 +3369,10 @@ return $default(_that);case _:
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function(@JsonKey(name: 'proxy-groups') List<ProxyGroup> proxyGroups, @JsonKey(fromJson: _genRule, name: 'rules') List<Rule> rule, @JsonKey(name: 'rule-providers', fromJson: _genRuleProviders) List<RuleProvider> ruleProvider, @JsonKey(name: 'sub-rules', fromJson: _genSubRules) List<SubRule> subRules)? $default,{required TResult orElse(),}) {final _that = this;
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function(@JsonKey(name: 'proxy-groups') List<ProxyGroup> proxyGroups, @JsonKey(fromJson: _genRule, name: 'rules') List<Rule> rule)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _ClashConfigSnippet() when $default != null:
return $default(_that.proxyGroups,_that.rule,_that.ruleProvider,_that.subRules);case _:
case _CustomClashConfig() when $default != null:
return $default(_that.proxyGroups,_that.rule);case _:
return orElse();
}
@@ -3392,10 +3390,10 @@ return $default(_that.proxyGroups,_that.rule,_that.ruleProvider,_that.subRules);
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function(@JsonKey(name: 'proxy-groups') List<ProxyGroup> proxyGroups, @JsonKey(fromJson: _genRule, name: 'rules') List<Rule> rule, @JsonKey(name: 'rule-providers', fromJson: _genRuleProviders) List<RuleProvider> ruleProvider, @JsonKey(name: 'sub-rules', fromJson: _genSubRules) List<SubRule> subRules) $default,) {final _that = this;
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function(@JsonKey(name: 'proxy-groups') List<ProxyGroup> proxyGroups, @JsonKey(fromJson: _genRule, name: 'rules') List<Rule> rule) $default,) {final _that = this;
switch (_that) {
case _ClashConfigSnippet():
return $default(_that.proxyGroups,_that.rule,_that.ruleProvider,_that.subRules);case _:
case _CustomClashConfig():
return $default(_that.proxyGroups,_that.rule);case _:
throw StateError('Unexpected subclass');
}
@@ -3412,10 +3410,10 @@ return $default(_that.proxyGroups,_that.rule,_that.ruleProvider,_that.subRules);
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function(@JsonKey(name: 'proxy-groups') List<ProxyGroup> proxyGroups, @JsonKey(fromJson: _genRule, name: 'rules') List<Rule> rule, @JsonKey(name: 'rule-providers', fromJson: _genRuleProviders) List<RuleProvider> ruleProvider, @JsonKey(name: 'sub-rules', fromJson: _genSubRules) List<SubRule> subRules)? $default,) {final _that = this;
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function(@JsonKey(name: 'proxy-groups') List<ProxyGroup> proxyGroups, @JsonKey(fromJson: _genRule, name: 'rules') List<Rule> rule)? $default,) {final _that = this;
switch (_that) {
case _ClashConfigSnippet() when $default != null:
return $default(_that.proxyGroups,_that.rule,_that.ruleProvider,_that.subRules);case _:
case _CustomClashConfig() when $default != null:
return $default(_that.proxyGroups,_that.rule);case _:
return null;
}
@@ -3426,9 +3424,9 @@ return $default(_that.proxyGroups,_that.rule,_that.ruleProvider,_that.subRules);
/// @nodoc
@JsonSerializable()
class _ClashConfigSnippet implements ClashConfigSnippet {
const _ClashConfigSnippet({@JsonKey(name: 'proxy-groups') final List<ProxyGroup> proxyGroups = const [], @JsonKey(fromJson: _genRule, name: 'rules') final List<Rule> rule = const [], @JsonKey(name: 'rule-providers', fromJson: _genRuleProviders) final List<RuleProvider> ruleProvider = const [], @JsonKey(name: 'sub-rules', fromJson: _genSubRules) final List<SubRule> subRules = const []}): _proxyGroups = proxyGroups,_rule = rule,_ruleProvider = ruleProvider,_subRules = subRules;
factory _ClashConfigSnippet.fromJson(Map<String, dynamic> json) => _$ClashConfigSnippetFromJson(json);
class _CustomClashConfig implements CustomClashConfig {
const _CustomClashConfig({@JsonKey(name: 'proxy-groups') final List<ProxyGroup> proxyGroups = const [], @JsonKey(fromJson: _genRule, name: 'rules') final List<Rule> rule = const []}): _proxyGroups = proxyGroups,_rule = rule;
factory _CustomClashConfig.fromJson(Map<String, dynamic> json) => _$CustomClashConfigFromJson(json);
final List<ProxyGroup> _proxyGroups;
@override@JsonKey(name: 'proxy-groups') List<ProxyGroup> get proxyGroups {
@@ -3444,55 +3442,41 @@ class _ClashConfigSnippet implements ClashConfigSnippet {
return EqualUnmodifiableListView(_rule);
}
final List<RuleProvider> _ruleProvider;
@override@JsonKey(name: 'rule-providers', fromJson: _genRuleProviders) List<RuleProvider> get ruleProvider {
if (_ruleProvider is EqualUnmodifiableListView) return _ruleProvider;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_ruleProvider);
}
final List<SubRule> _subRules;
@override@JsonKey(name: 'sub-rules', fromJson: _genSubRules) List<SubRule> get subRules {
if (_subRules is EqualUnmodifiableListView) return _subRules;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_subRules);
}
/// Create a copy of ClashConfigSnippet
/// Create a copy of CustomClashConfig
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$ClashConfigSnippetCopyWith<_ClashConfigSnippet> get copyWith => __$ClashConfigSnippetCopyWithImpl<_ClashConfigSnippet>(this, _$identity);
_$CustomClashConfigCopyWith<_CustomClashConfig> get copyWith => __$CustomClashConfigCopyWithImpl<_CustomClashConfig>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$ClashConfigSnippetToJson(this, );
return _$CustomClashConfigToJson(this, );
}
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ClashConfigSnippet&&const DeepCollectionEquality().equals(other._proxyGroups, _proxyGroups)&&const DeepCollectionEquality().equals(other._rule, _rule)&&const DeepCollectionEquality().equals(other._ruleProvider, _ruleProvider)&&const DeepCollectionEquality().equals(other._subRules, _subRules));
return identical(this, other) || (other.runtimeType == runtimeType&&other is _CustomClashConfig&&const DeepCollectionEquality().equals(other._proxyGroups, _proxyGroups)&&const DeepCollectionEquality().equals(other._rule, _rule));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(_proxyGroups),const DeepCollectionEquality().hash(_rule),const DeepCollectionEquality().hash(_ruleProvider),const DeepCollectionEquality().hash(_subRules));
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(_proxyGroups),const DeepCollectionEquality().hash(_rule));
@override
String toString() {
return 'ClashConfigSnippet(proxyGroups: $proxyGroups, rule: $rule, ruleProvider: $ruleProvider, subRules: $subRules)';
return 'CustomClashConfig(proxyGroups: $proxyGroups, rule: $rule)';
}
}
/// @nodoc
abstract mixin class _$ClashConfigSnippetCopyWith<$Res> implements $ClashConfigSnippetCopyWith<$Res> {
factory _$ClashConfigSnippetCopyWith(_ClashConfigSnippet value, $Res Function(_ClashConfigSnippet) _then) = __$ClashConfigSnippetCopyWithImpl;
abstract mixin class _$CustomClashConfigCopyWith<$Res> implements $CustomClashConfigCopyWith<$Res> {
factory _$CustomClashConfigCopyWith(_CustomClashConfig value, $Res Function(_CustomClashConfig) _then) = __$CustomClashConfigCopyWithImpl;
@override @useResult
$Res call({
@JsonKey(name: 'proxy-groups') List<ProxyGroup> proxyGroups,@JsonKey(fromJson: _genRule, name: 'rules') List<Rule> rule,@JsonKey(name: 'rule-providers', fromJson: _genRuleProviders) List<RuleProvider> ruleProvider,@JsonKey(name: 'sub-rules', fromJson: _genSubRules) List<SubRule> subRules
@JsonKey(name: 'proxy-groups') List<ProxyGroup> proxyGroups,@JsonKey(fromJson: _genRule, name: 'rules') List<Rule> rule
});
@@ -3500,22 +3484,20 @@ $Res call({
}
/// @nodoc
class __$ClashConfigSnippetCopyWithImpl<$Res>
implements _$ClashConfigSnippetCopyWith<$Res> {
__$ClashConfigSnippetCopyWithImpl(this._self, this._then);
class __$CustomClashConfigCopyWithImpl<$Res>
implements _$CustomClashConfigCopyWith<$Res> {
__$CustomClashConfigCopyWithImpl(this._self, this._then);
final _ClashConfigSnippet _self;
final $Res Function(_ClashConfigSnippet) _then;
final _CustomClashConfig _self;
final $Res Function(_CustomClashConfig) _then;
/// Create a copy of ClashConfigSnippet
/// Create a copy of CustomClashConfig
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? proxyGroups = null,Object? rule = null,Object? ruleProvider = null,Object? subRules = null,}) {
return _then(_ClashConfigSnippet(
@override @pragma('vm:prefer-inline') $Res call({Object? proxyGroups = null,Object? rule = null,}) {
return _then(_CustomClashConfig(
proxyGroups: null == proxyGroups ? _self._proxyGroups : proxyGroups // ignore: cast_nullable_to_non_nullable
as List<ProxyGroup>,rule: null == rule ? _self._rule : rule // ignore: cast_nullable_to_non_nullable
as List<Rule>,ruleProvider: null == ruleProvider ? _self._ruleProvider : ruleProvider // ignore: cast_nullable_to_non_nullable
as List<RuleProvider>,subRules: null == subRules ? _self._subRules : subRules // ignore: cast_nullable_to_non_nullable
as List<SubRule>,
as List<Rule>,
));
}

View File

@@ -21,7 +21,7 @@ _ProxyGroup _$ProxyGroupFromJson(Map<String, dynamic> json) => _ProxyGroup(
filter: json['filter'] as String?,
excludeFilter: json['expected-filter'] as String?,
excludeType: json['exclude-type'] as String?,
expectedStatus: json['expected-status'],
expectedStatus: json['expected-status'] as String?,
hidden: json['hidden'] as bool?,
icon: json['icon'] as String?,
);
@@ -168,7 +168,7 @@ _FallbackFilter _$FallbackFilterFromJson(
geoipCode: json['geoip-code'] as String? ?? 'CN',
geosite:
(json['geosite'] as List<dynamic>?)?.map((e) => e as String).toList() ??
const ['gfw'],
const [''],
ipcidr:
(json['ipcidr'] as List<dynamic>?)?.map((e) => e as String).toList() ??
const ['240.0.0.0/4'],
@@ -304,28 +304,20 @@ Map<String, dynamic> _$SubRuleToJson(_SubRule instance) => <String, dynamic>{
'name': instance.name,
};
_ClashConfigSnippet _$ClashConfigSnippetFromJson(Map<String, dynamic> json) =>
_ClashConfigSnippet(
_CustomClashConfig _$CustomClashConfigFromJson(Map<String, dynamic> json) =>
_CustomClashConfig(
proxyGroups:
(json['proxy-groups'] as List<dynamic>?)
?.map((e) => ProxyGroup.fromJson(e as Map<String, dynamic>))
.toList() ??
const [],
rule: json['rules'] == null ? const [] : _genRule(json['rules'] as List?),
ruleProvider: json['rule-providers'] == null
? const []
: _genRuleProviders(json['rule-providers'] as Map<String, dynamic>),
subRules: json['sub-rules'] == null
? const []
: _genSubRules(json['sub-rules'] as Map<String, dynamic>),
);
Map<String, dynamic> _$ClashConfigSnippetToJson(_ClashConfigSnippet instance) =>
Map<String, dynamic> _$CustomClashConfigToJson(_CustomClashConfig instance) =>
<String, dynamic>{
'proxy-groups': instance.proxyGroups,
'rules': instance.rule,
'rule-providers': instance.ruleProvider,
'sub-rules': instance.subRules,
};
_ClashConfig _$ClashConfigFromJson(Map<String, dynamic> json) => _ClashConfig(

View File

@@ -110,7 +110,6 @@ class OutboundModeV2 extends StatelessWidget {
return SizedBox(
height: height,
child: CommonCard(
padding: EdgeInsets.zero,
child: Consumer(
builder: (_, ref, _) {
final mode = ref.watch(

View File

@@ -0,0 +1,97 @@
part of 'overwrite.dart';
class _CustomContent extends ConsumerWidget {
final int profileId;
const _CustomContent(this.profileId);
void _handleUseDefault() async {
final res = await appController.getProfileWithId(profileId);
}
@override
Widget build(BuildContext context, WidgetRef ref) {
return SliverMainAxisGroup(
slivers: [
SliverToBoxAdapter(child: SizedBox(height: 24)),
SliverToBoxAdapter(
child: Column(
children: [
InfoHeader(
info: Info(label: '自定义'),
actions: [
CommonMinFilledButtonTheme(
child: FilledButton.tonal(
onPressed: _handleUseDefault,
child: Text('使用默认配置'),
),
),
],
),
],
),
),
SliverToBoxAdapter(child: SizedBox(height: 8)),
_CustomProxyGroups(profileId),
// SliverToBoxAdapter(child: SizedBox(height: 8)),
// SliverToBoxAdapter(
// child: Padding(
// padding: EdgeInsets.symmetric(horizontal: 16, vertical: 4),
// child: CommonCard(
// radius: 18,
// child: ListTile(
// minTileHeight: 0,
// minVerticalPadding: 0,
// titleTextStyle: context.textTheme.bodyMedium?.toJetBrainsMono,
// contentPadding: const EdgeInsets.symmetric(
// horizontal: 16,
// vertical: 16,
// ),
// title: Row(
// crossAxisAlignment: CrossAxisAlignment.center,
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: [
// Flexible(
// child: Text('自定义规则', style: context.textTheme.bodyLarge),
// ),
// Icon(Icons.arrow_forward_ios, size: 18),
// ],
// ),
// ),
// onPressed: () {},
// ),
// ),
// ),
],
);
}
}
class _CustomProxyGroups extends ConsumerStatefulWidget {
final int profileId;
const _CustomProxyGroups(this.profileId);
@override
ConsumerState createState() => _CustomProxyGroupsState();
}
class _CustomProxyGroupsState extends ConsumerState<_CustomProxyGroups> {
@override
Widget build(BuildContext context) {
return SliverToBoxAdapter(
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 4),
child: Wrap(
children: [
CommonCard(
padding: EdgeInsets.all(16),
onPressed: () {},
child: Icon(Icons.add, size: 24),
),
],
),
),
);
}
}

View File

@@ -14,6 +14,8 @@ import 'package:fl_clash/widgets/widgets.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
part 'custom.dart';
class OverwriteView extends ConsumerStatefulWidget {
final int profileId;
@@ -319,7 +321,6 @@ class __StandardContentState extends ConsumerState<_StandardContent> {
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 4),
child: CommonCard(
padding: EdgeInsets.zero,
radius: 18,
child: ListTile(
minTileHeight: 0,
@@ -399,7 +400,6 @@ class _ScriptContent extends ConsumerWidget {
return Container(
margin: EdgeInsets.symmetric(vertical: 4),
child: CommonCard(
padding: EdgeInsets.zero,
type: CommonCardType.filled,
radius: 18,
child: ListTile(
@@ -445,7 +445,6 @@ class _ScriptContent extends ConsumerWidget {
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 4),
child: CommonCard(
padding: EdgeInsets.zero,
radius: 18,
child: ListTile(
minTileHeight: 0,
@@ -480,27 +479,6 @@ class _ScriptContent extends ConsumerWidget {
}
}
class _CustomContent extends ConsumerWidget {
final int profileId;
const _CustomContent(this.profileId);
@override
Widget build(BuildContext context, ref) {
return SliverMainAxisGroup(
slivers: [
SliverToBoxAdapter(child: SizedBox(height: 24)),
SliverToBoxAdapter(
child: Column(
children: [InfoHeader(info: Info(label: '自定义'))],
),
),
SliverToBoxAdapter(child: SizedBox(height: 8)),
],
);
}
}
class _EditGlobalAddedRules extends ConsumerWidget {
final int profileId;

View File

@@ -5,7 +5,7 @@ import 'package:fl_clash/models/models.dart';
import 'package:fl_clash/pages/editor.dart';
import 'package:fl_clash/providers/providers.dart';
import 'package:fl_clash/state.dart';
import 'package:fl_clash/views/profiles/overwrite.dart';
import 'package:fl_clash/views/profiles/overwrite/overwrite.dart';
import 'package:fl_clash/widgets/widgets.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

View File

@@ -186,7 +186,7 @@ class CommonCard extends StatelessWidget {
onLongPress: onLongPress,
clipBehavior: Clip.antiAlias,
style: ButtonStyle(
padding: const WidgetStatePropertyAll(EdgeInsets.zero),
padding: WidgetStatePropertyAll(padding ?? EdgeInsets.zero),
shape: WidgetStatePropertyAll(
RoundedSuperellipseBorder(
borderRadius: BorderRadius.circular(radius ?? 14),

View File

@@ -587,7 +587,6 @@ class CommonSelectedListItem extends StatelessWidget {
margin: EdgeInsets.symmetric(vertical: 4, horizontal: 16),
color: Colors.transparent,
child: CommonCard(
padding: EdgeInsets.zero,
radius: 18,
type: CommonCardType.filled,
isSelected: isSelected,