Remove proxies position animation, improve performance

Add Telegram Link
This commit is contained in:
chen08209
2024-05-06 14:03:45 +08:00
parent 9aa9180f1f
commit 85eb903402
9 changed files with 253 additions and 173 deletions

View File

@@ -69,7 +69,7 @@ class ClashCore {
final completer = Completer<String>();
final receiver = ReceivePort();
receiver.listen((message) {
if(!completer.isCompleted){
if (!completer.isCompleted) {
completer.complete(message);
receiver.close();
}
@@ -97,12 +97,12 @@ class ClashCore {
final groupsRaw = groupNames.map((groupName) {
final group = proxies[groupName];
group["all"] = ((group["all"] ?? []) as List)
.where(
(name) => !groupNames.contains(groupNames),
)
.map(
(name) => proxies[name],
)
.where(
(proxy) => proxy["type"] != GroupType.Selector.value,
)
.toList();
return group;
}).toList();
@@ -124,7 +124,7 @@ class ClashCore {
return true;
}
healthcheck(){
healthcheck() {
clashFFI.healthcheck();
}

View File

@@ -234,19 +234,6 @@ class AppController {
if (!config.silentLaunch) {
window?.show();
}
periodicUpdateGroups();
}
periodicUpdateGroups() {
WidgetsBinding.instance.addPostFrameCallback((_) {
if (globalState.updateGroupsTimer != null) {
globalState.updateGroupsTimer!.cancel();
}
globalState.updateGroupsTimer =
Timer.periodic(const Duration(seconds: 5), (Timer t) {
updateGroups();
});
});
}
setDelay(Delay delay) {

View File

@@ -80,6 +80,15 @@ class AboutFragment extends StatelessWidget {
});
},
),
ListTile(
title: const Text("Telegram"),
onTap: () {
launchUrl(
Uri.parse("https://t.me/+G-veVtwBOl4wODc1"),
);
},
trailing: const Icon(Icons.launch),
),
ListTile(
title: Text(appLocalizations.project),
onTap: () {

View File

@@ -70,6 +70,7 @@ class _ProxiesFragmentState extends State<ProxiesFragment>
child: Selector3<AppState, Config, ClashConfig, ProxiesSelectorState>(
selector: (_, appState, config, clashConfig) {
final currentGroups = appState.getCurrentGroups(clashConfig.mode);
final groupNames = currentGroups.map((e) => e.name).toList();
final currentProxyName = appState.getCurrentGroupNameWithGroups(
currentGroups,
config.currentGroupName,
@@ -78,13 +79,13 @@ class _ProxiesFragmentState extends State<ProxiesFragment>
final currentIndex = currentGroups
.indexWhere((element) => element.name == currentProxyName);
return ProxiesSelectorState(
currentIndex: currentIndex != -1 ? currentIndex : 0,
groups: currentGroups,
currentIndex: currentIndex,
groupNames: groupNames,
);
},
builder: (_, state, __) {
_tabController ??= TabController(
length: state.groups.length,
length: state.groupNames.length,
vsync: this,
initialIndex: state.currentIndex,
);
@@ -101,9 +102,9 @@ class _ProxiesFragmentState extends State<ProxiesFragment>
overlayColor:
const MaterialStatePropertyAll(Colors.transparent),
tabs: [
for (final group in state.groups)
for (final groupName in state.groupNames)
Tab(
text: group.name,
text: groupName,
),
],
),
@@ -111,10 +112,11 @@ class _ProxiesFragmentState extends State<ProxiesFragment>
child: TabBarView(
controller: _tabController,
children: [
for (final group in state.groups)
for (final groupName in state.groupNames)
KeepContainer(
key: ObjectKey(groupName),
child: ProxiesTabView(
group: group,
groupName: groupName,
),
),
],
@@ -129,23 +131,14 @@ class _ProxiesFragmentState extends State<ProxiesFragment>
}
}
class ProxiesTabView extends StatefulWidget {
final Group group;
class ProxiesTabView extends StatelessWidget {
final String groupName;
const ProxiesTabView({
super.key,
required this.group,
required this.groupName,
});
@override
State<ProxiesTabView> createState() => _ProxiesTabViewState();
}
class _ProxiesTabViewState extends State<ProxiesTabView> {
Group get group => widget.group;
get measure => context.appController.measure;
List<Proxy> _sortOfName(List<Proxy> proxies) {
return List.of(proxies)
..sort(
@@ -153,7 +146,7 @@ class _ProxiesTabViewState extends State<ProxiesTabView> {
);
}
List<Proxy> _sortOfDelay(List<Proxy> proxies) {
List<Proxy> _sortOfDelay(BuildContext context, List<Proxy> proxies) {
final appState = context.read<AppState>();
final delayMap = appState.delayMap;
return proxies = List.of(proxies)
@@ -176,15 +169,19 @@ class _ProxiesTabViewState extends State<ProxiesTabView> {
}
_getProxies(
BuildContext context,
List<Proxy> proxies,
ProxiesSortType proxiesSortType,
) {
if (proxiesSortType == ProxiesSortType.delay) return _sortOfDelay(proxies);
if (proxiesSortType == ProxiesSortType.delay) {
return _sortOfDelay(context, proxies);
}
if (proxiesSortType == ProxiesSortType.name) return _sortOfName(proxies);
return proxies;
}
double _getItemHeight() {
double _getItemHeight(BuildContext context) {
final measure = context.appController.measure;
return 12 * 2 +
measure.bodyMediumHeight * 2 +
measure.bodySmallHeight +
@@ -192,11 +189,13 @@ class _ProxiesTabViewState extends State<ProxiesTabView> {
8 * 2;
}
_card({
_card(
BuildContext context, {
required void Function() onPressed,
required bool isSelected,
required Proxy proxy,
}) {
final measure = context.appController.measure;
return CommonCard(
isSelected: isSelected,
onPressed: onPressed,
@@ -285,66 +284,83 @@ class _ProxiesTabViewState extends State<ProxiesTabView> {
);
}
_buildGrid({
Widget _buildGrid(
BuildContext context, {
required List<Proxy> proxies,
required int columns,
}) {
return SingleChildScrollView(
return GridView.builder(
padding: const EdgeInsets.all(16),
child: Selector3<AppState, Config, ClashConfig, ProxiesCardSelectorState>(
selector: (_, appState, config, clashConfig) =>
ProxiesCardSelectorState(
currentGroupName: appState.getCurrentGroupName(
config.currentGroupName,
clashConfig.mode,
),
currentProxyName: appState.getCurrentProxyName(
config.currentProxyName,
clashConfig.mode,
),
),
builder: (_, state, __) {
return AnimateGrid<Proxy>(
items: proxies,
columns: columns,
itemHeight: _getItemHeight(),
keyBuilder: (item) {
return ObjectKey(item);
},
builder: (_, proxy) {
final isSelected = group.type == GroupType.Selector
? group.name == state.currentGroupName &&
proxy.name == state.currentProxyName
: group.now == proxy.name;
return _card(
isSelected: isSelected,
onPressed: () {
if (group.type == GroupType.Selector) {
final config = context.read<Config>();
config.currentProfile?.groupName = group.name;
config.currentProfile?.proxyName = proxy.name;
config.update();
context.appController.changeProxy();
}
},
proxy: proxy,
);
},
);
},
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: columns,
mainAxisSpacing: 8,
crossAxisSpacing: 8,
mainAxisExtent: _getItemHeight(context),
),
itemCount: proxies.length,
itemBuilder: (_, index) {
final proxy = proxies[index];
return Selector3<AppState, Config, ClashConfig,
ProxiesCardSelectorState>(
selector: (_, appState, config, clashConfig) {
final currentGroupName = appState.getCurrentGroupName(
config.currentGroupName,
clashConfig.mode,
);
final currentProxyName = appState.getCurrentProxyName(
config.currentProxyName,
clashConfig.mode,
);
final group = appState.getGroupWithName(groupName);
final isSelected = group.type == GroupType.Selector
? group.name == currentGroupName &&
proxy.name == currentProxyName
: group.now == proxy.name;
return ProxiesCardSelectorState(
isSelected: isSelected,
currentGroupName: currentGroupName,
currentProxyName: currentProxyName,
);
},
builder: (_, state, __) {
return _card(
context,
isSelected: state.isSelected,
onPressed: () {
final group =
context.appController.appState.getGroupWithName(groupName);
if (group.type == GroupType.Selector) {
final config = context.read<Config>();
config.currentProfile?.groupName = group.name;
config.currentProfile?.proxyName = proxy.name;
config.update();
context.appController.changeProxy();
}
},
proxy: proxy,
);
},
);
},
);
}
@override
Widget build(BuildContext context) {
return Selector2<AppState, Config, ProxiesSortSelectorState>(
selector: (_, appState, config) => ProxiesSortSelectorState(
proxiesSortType: config.proxiesSortType,
sortNum: appState.sortNum,
),
return Selector2<AppState, Config, ProxiesTabViewSelectorState>(
selector: (_, appState, config) {
return ProxiesTabViewSelectorState(
proxiesSortType: config.proxiesSortType,
sortNum: appState.sortNum,
group: appState.getGroupWithName(groupName),
);
},
builder: (_, state, __) {
final proxies = _getProxies(group.all, state.proxiesSortType);
final proxies = _getProxies(
context,
state.group.all,
state.proxiesSortType,
);
return Align(
alignment: Alignment.topCenter,
child: SlotLayout(
@@ -352,6 +368,7 @@ class _ProxiesTabViewState extends State<ProxiesTabView> {
Breakpoints.small: SlotLayout.from(
key: const Key('proxies_grid_small'),
builder: (_) => _buildGrid(
context,
proxies: proxies,
columns: 2,
),
@@ -359,6 +376,7 @@ class _ProxiesTabViewState extends State<ProxiesTabView> {
Breakpoints.medium: SlotLayout.from(
key: const Key('proxies_grid_medium'),
builder: (_) => _buildGrid(
context,
proxies: proxies,
columns: 3,
),
@@ -366,6 +384,7 @@ class _ProxiesTabViewState extends State<ProxiesTabView> {
Breakpoints.large: SlotLayout.from(
key: const Key('proxies_grid_large'),
builder: (_) => _buildGrid(
context,
proxies: proxies,
columns: 4,
),
@@ -409,6 +428,7 @@ class _DelayTestButtonContainerState extends State<DelayTestButtonContainer>
await Future.delayed(
appConstant.httpTimeoutDuration + appConstant.moreDuration,
);
context.appController.appState.sortNum++;
_controller.reverse();
}

View File

@@ -205,6 +205,10 @@ class AppState with ChangeNotifier {
return getCurrentGroupNameWithGroups(currentGroups, groupName, mode);
}
Group getGroupWithName(String groupName) {
return groups.firstWhere((e) => e.name == groupName);
}
String? getCurrentProxyName(String? proxyName, Mode mode) {
final currentGroups = getCurrentGroups(mode);
switch (mode) {

View File

@@ -1744,7 +1744,7 @@ abstract class _HomeNavigationSelectorState
/// @nodoc
mixin _$ProxiesSelectorState {
int get currentIndex => throw _privateConstructorUsedError;
List<Group> get groups => throw _privateConstructorUsedError;
List<String> get groupNames => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$ProxiesSelectorStateCopyWith<ProxiesSelectorState> get copyWith =>
@@ -1757,7 +1757,7 @@ abstract class $ProxiesSelectorStateCopyWith<$Res> {
$Res Function(ProxiesSelectorState) then) =
_$ProxiesSelectorStateCopyWithImpl<$Res, ProxiesSelectorState>;
@useResult
$Res call({int currentIndex, List<Group> groups});
$Res call({int currentIndex, List<String> groupNames});
}
/// @nodoc
@@ -1775,17 +1775,17 @@ class _$ProxiesSelectorStateCopyWithImpl<$Res,
@override
$Res call({
Object? currentIndex = null,
Object? groups = null,
Object? groupNames = null,
}) {
return _then(_value.copyWith(
currentIndex: null == currentIndex
? _value.currentIndex
: currentIndex // ignore: cast_nullable_to_non_nullable
as int,
groups: null == groups
? _value.groups
: groups // ignore: cast_nullable_to_non_nullable
as List<Group>,
groupNames: null == groupNames
? _value.groupNames
: groupNames // ignore: cast_nullable_to_non_nullable
as List<String>,
) as $Val);
}
}
@@ -1798,7 +1798,7 @@ abstract class _$$ProxiesSelectorStateImplCopyWith<$Res>
__$$ProxiesSelectorStateImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({int currentIndex, List<Group> groups});
$Res call({int currentIndex, List<String> groupNames});
}
/// @nodoc
@@ -1813,17 +1813,17 @@ class __$$ProxiesSelectorStateImplCopyWithImpl<$Res>
@override
$Res call({
Object? currentIndex = null,
Object? groups = null,
Object? groupNames = null,
}) {
return _then(_$ProxiesSelectorStateImpl(
currentIndex: null == currentIndex
? _value.currentIndex
: currentIndex // ignore: cast_nullable_to_non_nullable
as int,
groups: null == groups
? _value._groups
: groups // ignore: cast_nullable_to_non_nullable
as List<Group>,
groupNames: null == groupNames
? _value._groupNames
: groupNames // ignore: cast_nullable_to_non_nullable
as List<String>,
));
}
}
@@ -1832,22 +1832,22 @@ class __$$ProxiesSelectorStateImplCopyWithImpl<$Res>
class _$ProxiesSelectorStateImpl implements _ProxiesSelectorState {
const _$ProxiesSelectorStateImpl(
{required this.currentIndex, required final List<Group> groups})
: _groups = groups;
{required this.currentIndex, required final List<String> groupNames})
: _groupNames = groupNames;
@override
final int currentIndex;
final List<Group> _groups;
final List<String> _groupNames;
@override
List<Group> get groups {
if (_groups is EqualUnmodifiableListView) return _groups;
List<String> get groupNames {
if (_groupNames is EqualUnmodifiableListView) return _groupNames;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_groups);
return EqualUnmodifiableListView(_groupNames);
}
@override
String toString() {
return 'ProxiesSelectorState(currentIndex: $currentIndex, groups: $groups)';
return 'ProxiesSelectorState(currentIndex: $currentIndex, groupNames: $groupNames)';
}
@override
@@ -1857,12 +1857,13 @@ class _$ProxiesSelectorStateImpl implements _ProxiesSelectorState {
other is _$ProxiesSelectorStateImpl &&
(identical(other.currentIndex, currentIndex) ||
other.currentIndex == currentIndex) &&
const DeepCollectionEquality().equals(other._groups, _groups));
const DeepCollectionEquality()
.equals(other._groupNames, _groupNames));
}
@override
int get hashCode => Object.hash(
runtimeType, currentIndex, const DeepCollectionEquality().hash(_groups));
int get hashCode => Object.hash(runtimeType, currentIndex,
const DeepCollectionEquality().hash(_groupNames));
@JsonKey(ignore: true)
@override
@@ -1876,12 +1877,12 @@ class _$ProxiesSelectorStateImpl implements _ProxiesSelectorState {
abstract class _ProxiesSelectorState implements ProxiesSelectorState {
const factory _ProxiesSelectorState(
{required final int currentIndex,
required final List<Group> groups}) = _$ProxiesSelectorStateImpl;
required final List<String> groupNames}) = _$ProxiesSelectorStateImpl;
@override
int get currentIndex;
@override
List<Group> get groups;
List<String> get groupNames;
@override
@JsonKey(ignore: true)
_$$ProxiesSelectorStateImplCopyWith<_$ProxiesSelectorStateImpl>
@@ -1892,6 +1893,7 @@ abstract class _ProxiesSelectorState implements ProxiesSelectorState {
mixin _$ProxiesCardSelectorState {
String? get currentGroupName => throw _privateConstructorUsedError;
String? get currentProxyName => throw _privateConstructorUsedError;
bool get isSelected => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$ProxiesCardSelectorStateCopyWith<ProxiesCardSelectorState> get copyWith =>
@@ -1904,7 +1906,8 @@ abstract class $ProxiesCardSelectorStateCopyWith<$Res> {
$Res Function(ProxiesCardSelectorState) then) =
_$ProxiesCardSelectorStateCopyWithImpl<$Res, ProxiesCardSelectorState>;
@useResult
$Res call({String? currentGroupName, String? currentProxyName});
$Res call(
{String? currentGroupName, String? currentProxyName, bool isSelected});
}
/// @nodoc
@@ -1923,6 +1926,7 @@ class _$ProxiesCardSelectorStateCopyWithImpl<$Res,
$Res call({
Object? currentGroupName = freezed,
Object? currentProxyName = freezed,
Object? isSelected = null,
}) {
return _then(_value.copyWith(
currentGroupName: freezed == currentGroupName
@@ -1933,6 +1937,10 @@ class _$ProxiesCardSelectorStateCopyWithImpl<$Res,
? _value.currentProxyName
: currentProxyName // ignore: cast_nullable_to_non_nullable
as String?,
isSelected: null == isSelected
? _value.isSelected
: isSelected // ignore: cast_nullable_to_non_nullable
as bool,
) as $Val);
}
}
@@ -1946,7 +1954,8 @@ abstract class _$$ProxiesCardSelectorStateImplCopyWith<$Res>
__$$ProxiesCardSelectorStateImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({String? currentGroupName, String? currentProxyName});
$Res call(
{String? currentGroupName, String? currentProxyName, bool isSelected});
}
/// @nodoc
@@ -1964,6 +1973,7 @@ class __$$ProxiesCardSelectorStateImplCopyWithImpl<$Res>
$Res call({
Object? currentGroupName = freezed,
Object? currentProxyName = freezed,
Object? isSelected = null,
}) {
return _then(_$ProxiesCardSelectorStateImpl(
currentGroupName: freezed == currentGroupName
@@ -1974,6 +1984,10 @@ class __$$ProxiesCardSelectorStateImplCopyWithImpl<$Res>
? _value.currentProxyName
: currentProxyName // ignore: cast_nullable_to_non_nullable
as String?,
isSelected: null == isSelected
? _value.isSelected
: isSelected // ignore: cast_nullable_to_non_nullable
as bool,
));
}
}
@@ -1982,16 +1996,20 @@ class __$$ProxiesCardSelectorStateImplCopyWithImpl<$Res>
class _$ProxiesCardSelectorStateImpl implements _ProxiesCardSelectorState {
const _$ProxiesCardSelectorStateImpl(
{required this.currentGroupName, required this.currentProxyName});
{required this.currentGroupName,
required this.currentProxyName,
required this.isSelected});
@override
final String? currentGroupName;
@override
final String? currentProxyName;
@override
final bool isSelected;
@override
String toString() {
return 'ProxiesCardSelectorState(currentGroupName: $currentGroupName, currentProxyName: $currentProxyName)';
return 'ProxiesCardSelectorState(currentGroupName: $currentGroupName, currentProxyName: $currentProxyName, isSelected: $isSelected)';
}
@override
@@ -2002,12 +2020,14 @@ class _$ProxiesCardSelectorStateImpl implements _ProxiesCardSelectorState {
(identical(other.currentGroupName, currentGroupName) ||
other.currentGroupName == currentGroupName) &&
(identical(other.currentProxyName, currentProxyName) ||
other.currentProxyName == currentProxyName));
other.currentProxyName == currentProxyName) &&
(identical(other.isSelected, isSelected) ||
other.isSelected == isSelected));
}
@override
int get hashCode =>
Object.hash(runtimeType, currentGroupName, currentProxyName);
Object.hash(runtimeType, currentGroupName, currentProxyName, isSelected);
@JsonKey(ignore: true)
@override
@@ -2019,44 +2039,51 @@ class _$ProxiesCardSelectorStateImpl implements _ProxiesCardSelectorState {
abstract class _ProxiesCardSelectorState implements ProxiesCardSelectorState {
const factory _ProxiesCardSelectorState(
{required final String? currentGroupName,
required final String? currentProxyName}) =
_$ProxiesCardSelectorStateImpl;
{required final String? currentGroupName,
required final String? currentProxyName,
required final bool isSelected}) = _$ProxiesCardSelectorStateImpl;
@override
String? get currentGroupName;
@override
String? get currentProxyName;
@override
bool get isSelected;
@override
@JsonKey(ignore: true)
_$$ProxiesCardSelectorStateImplCopyWith<_$ProxiesCardSelectorStateImpl>
get copyWith => throw _privateConstructorUsedError;
}
/// @nodoc
mixin _$ProxiesSortSelectorState {
mixin _$ProxiesTabViewSelectorState {
ProxiesSortType get proxiesSortType => throw _privateConstructorUsedError;
num get sortNum => throw _privateConstructorUsedError;
Group get group => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$ProxiesSortSelectorStateCopyWith<ProxiesSortSelectorState> get copyWith =>
throw _privateConstructorUsedError;
$ProxiesTabViewSelectorStateCopyWith<ProxiesTabViewSelectorState>
get copyWith => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $ProxiesSortSelectorStateCopyWith<$Res> {
factory $ProxiesSortSelectorStateCopyWith(ProxiesSortSelectorState value,
$Res Function(ProxiesSortSelectorState) then) =
_$ProxiesSortSelectorStateCopyWithImpl<$Res, ProxiesSortSelectorState>;
abstract class $ProxiesTabViewSelectorStateCopyWith<$Res> {
factory $ProxiesTabViewSelectorStateCopyWith(
ProxiesTabViewSelectorState value,
$Res Function(ProxiesTabViewSelectorState) then) =
_$ProxiesTabViewSelectorStateCopyWithImpl<$Res,
ProxiesTabViewSelectorState>;
@useResult
$Res call({ProxiesSortType proxiesSortType, num sortNum});
$Res call({ProxiesSortType proxiesSortType, num sortNum, Group group});
$GroupCopyWith<$Res> get group;
}
/// @nodoc
class _$ProxiesSortSelectorStateCopyWithImpl<$Res,
$Val extends ProxiesSortSelectorState>
implements $ProxiesSortSelectorStateCopyWith<$Res> {
_$ProxiesSortSelectorStateCopyWithImpl(this._value, this._then);
class _$ProxiesTabViewSelectorStateCopyWithImpl<$Res,
$Val extends ProxiesTabViewSelectorState>
implements $ProxiesTabViewSelectorStateCopyWith<$Res> {
_$ProxiesTabViewSelectorStateCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
@@ -2068,6 +2095,7 @@ class _$ProxiesSortSelectorStateCopyWithImpl<$Res,
$Res call({
Object? proxiesSortType = null,
Object? sortNum = null,
Object? group = null,
}) {
return _then(_value.copyWith(
proxiesSortType: null == proxiesSortType
@@ -2078,30 +2106,45 @@ class _$ProxiesSortSelectorStateCopyWithImpl<$Res,
? _value.sortNum
: sortNum // ignore: cast_nullable_to_non_nullable
as num,
group: null == group
? _value.group
: group // ignore: cast_nullable_to_non_nullable
as Group,
) as $Val);
}
@override
@pragma('vm:prefer-inline')
$GroupCopyWith<$Res> get group {
return $GroupCopyWith<$Res>(_value.group, (value) {
return _then(_value.copyWith(group: value) as $Val);
});
}
}
/// @nodoc
abstract class _$$ProxiesSortSelectorStateImplCopyWith<$Res>
implements $ProxiesSortSelectorStateCopyWith<$Res> {
factory _$$ProxiesSortSelectorStateImplCopyWith(
_$ProxiesSortSelectorStateImpl value,
$Res Function(_$ProxiesSortSelectorStateImpl) then) =
__$$ProxiesSortSelectorStateImplCopyWithImpl<$Res>;
abstract class _$$ProxiesTabViewSelectorStateImplCopyWith<$Res>
implements $ProxiesTabViewSelectorStateCopyWith<$Res> {
factory _$$ProxiesTabViewSelectorStateImplCopyWith(
_$ProxiesTabViewSelectorStateImpl value,
$Res Function(_$ProxiesTabViewSelectorStateImpl) then) =
__$$ProxiesTabViewSelectorStateImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({ProxiesSortType proxiesSortType, num sortNum});
$Res call({ProxiesSortType proxiesSortType, num sortNum, Group group});
@override
$GroupCopyWith<$Res> get group;
}
/// @nodoc
class __$$ProxiesSortSelectorStateImplCopyWithImpl<$Res>
extends _$ProxiesSortSelectorStateCopyWithImpl<$Res,
_$ProxiesSortSelectorStateImpl>
implements _$$ProxiesSortSelectorStateImplCopyWith<$Res> {
__$$ProxiesSortSelectorStateImplCopyWithImpl(
_$ProxiesSortSelectorStateImpl _value,
$Res Function(_$ProxiesSortSelectorStateImpl) _then)
class __$$ProxiesTabViewSelectorStateImplCopyWithImpl<$Res>
extends _$ProxiesTabViewSelectorStateCopyWithImpl<$Res,
_$ProxiesTabViewSelectorStateImpl>
implements _$$ProxiesTabViewSelectorStateImplCopyWith<$Res> {
__$$ProxiesTabViewSelectorStateImplCopyWithImpl(
_$ProxiesTabViewSelectorStateImpl _value,
$Res Function(_$ProxiesTabViewSelectorStateImpl) _then)
: super(_value, _then);
@pragma('vm:prefer-inline')
@@ -2109,8 +2152,9 @@ class __$$ProxiesSortSelectorStateImplCopyWithImpl<$Res>
$Res call({
Object? proxiesSortType = null,
Object? sortNum = null,
Object? group = null,
}) {
return _then(_$ProxiesSortSelectorStateImpl(
return _then(_$ProxiesTabViewSelectorStateImpl(
proxiesSortType: null == proxiesSortType
? _value.proxiesSortType
: proxiesSortType // ignore: cast_nullable_to_non_nullable
@@ -2119,58 +2163,72 @@ class __$$ProxiesSortSelectorStateImplCopyWithImpl<$Res>
? _value.sortNum
: sortNum // ignore: cast_nullable_to_non_nullable
as num,
group: null == group
? _value.group
: group // ignore: cast_nullable_to_non_nullable
as Group,
));
}
}
/// @nodoc
class _$ProxiesSortSelectorStateImpl implements _ProxiesSortSelectorState {
const _$ProxiesSortSelectorStateImpl(
{required this.proxiesSortType, required this.sortNum});
class _$ProxiesTabViewSelectorStateImpl
implements _ProxiesTabViewSelectorState {
const _$ProxiesTabViewSelectorStateImpl(
{required this.proxiesSortType,
required this.sortNum,
required this.group});
@override
final ProxiesSortType proxiesSortType;
@override
final num sortNum;
@override
final Group group;
@override
String toString() {
return 'ProxiesSortSelectorState(proxiesSortType: $proxiesSortType, sortNum: $sortNum)';
return 'ProxiesTabViewSelectorState(proxiesSortType: $proxiesSortType, sortNum: $sortNum, group: $group)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$ProxiesSortSelectorStateImpl &&
other is _$ProxiesTabViewSelectorStateImpl &&
(identical(other.proxiesSortType, proxiesSortType) ||
other.proxiesSortType == proxiesSortType) &&
(identical(other.sortNum, sortNum) || other.sortNum == sortNum));
(identical(other.sortNum, sortNum) || other.sortNum == sortNum) &&
(identical(other.group, group) || other.group == group));
}
@override
int get hashCode => Object.hash(runtimeType, proxiesSortType, sortNum);
int get hashCode => Object.hash(runtimeType, proxiesSortType, sortNum, group);
@JsonKey(ignore: true)
@override
@pragma('vm:prefer-inline')
_$$ProxiesSortSelectorStateImplCopyWith<_$ProxiesSortSelectorStateImpl>
get copyWith => __$$ProxiesSortSelectorStateImplCopyWithImpl<
_$ProxiesSortSelectorStateImpl>(this, _$identity);
_$$ProxiesTabViewSelectorStateImplCopyWith<_$ProxiesTabViewSelectorStateImpl>
get copyWith => __$$ProxiesTabViewSelectorStateImplCopyWithImpl<
_$ProxiesTabViewSelectorStateImpl>(this, _$identity);
}
abstract class _ProxiesSortSelectorState implements ProxiesSortSelectorState {
const factory _ProxiesSortSelectorState(
abstract class _ProxiesTabViewSelectorState
implements ProxiesTabViewSelectorState {
const factory _ProxiesTabViewSelectorState(
{required final ProxiesSortType proxiesSortType,
required final num sortNum}) = _$ProxiesSortSelectorStateImpl;
required final num sortNum,
required final Group group}) = _$ProxiesTabViewSelectorStateImpl;
@override
ProxiesSortType get proxiesSortType;
@override
num get sortNum;
@override
Group get group;
@override
@JsonKey(ignore: true)
_$$ProxiesSortSelectorStateImplCopyWith<_$ProxiesSortSelectorStateImpl>
_$$ProxiesTabViewSelectorStateImplCopyWith<_$ProxiesTabViewSelectorStateImpl>
get copyWith => throw _privateConstructorUsedError;
}

View File

@@ -107,7 +107,7 @@ class HomeNavigationSelectorState with _$HomeNavigationSelectorState{
class ProxiesSelectorState with _$ProxiesSelectorState{
const factory ProxiesSelectorState({
required int currentIndex,
required List<Group> groups,
required List<String> groupNames,
}) = _ProxiesSelectorState;
}
@@ -116,13 +116,15 @@ class ProxiesCardSelectorState with _$ProxiesCardSelectorState{
const factory ProxiesCardSelectorState({
required String? currentGroupName,
required String? currentProxyName,
required bool isSelected,
}) = _ProxiesCardSelectorState;
}
@freezed
class ProxiesSortSelectorState with _$ProxiesSortSelectorState{
const factory ProxiesSortSelectorState({
class ProxiesTabViewSelectorState with _$ProxiesTabViewSelectorState{
const factory ProxiesTabViewSelectorState({
required ProxiesSortType proxiesSortType,
required num sortNum,
}) = _ProxiesSortSelectorState;
required Group group,
}) = _ProxiesTabViewSelectorState;
}

View File

@@ -41,10 +41,11 @@ class _ClashMessageContainerState extends State<ClashMessageContainer>
context.appController.setDelay(delay);
WidgetsBinding.instance.addPostFrameCallback((_) {
globalState.updateSortNumDebounce ??= debounce<Function()>(
() {
() {
context.appController.updateGroups();
context.appController.appState.sortNum++;
},
milliseconds: appConstant.httpTimeoutDuration.inMilliseconds,
milliseconds: 5000,
);
globalState.updateSortNumDebounce!();
});
@@ -53,7 +54,6 @@ class _ClashMessageContainerState extends State<ClashMessageContainer>
@override
void onLog(Log log) {
debugPrint("$log");
context.appController.appState.addLog(log);
super.onLog(log);
}