Fix fab issues

This commit is contained in:
chen08209
2024-07-14 01:37:44 +08:00
parent 3d25298639
commit aa4ffbe4fb
5 changed files with 241 additions and 250 deletions
+2 -2
View File
@@ -325,8 +325,8 @@ func overwriteConfig(targetConfig *config.RawConfig, patchConfig config.RawConfi
//targetConfig.GeodataMode = false //targetConfig.GeodataMode = false
targetConfig.IPv6 = patchConfig.IPv6 targetConfig.IPv6 = patchConfig.IPv6
targetConfig.LogLevel = patchConfig.LogLevel targetConfig.LogLevel = patchConfig.LogLevel
targetConfig.Port = 0 //targetConfig.Port = 0
targetConfig.SocksPort = 0 //targetConfig.SocksPort = 0
targetConfig.MixedPort = patchConfig.MixedPort targetConfig.MixedPort = patchConfig.MixedPort
targetConfig.FindProcessMode = patchConfig.FindProcessMode targetConfig.FindProcessMode = patchConfig.FindProcessMode
targetConfig.AllowLan = patchConfig.AllowLan targetConfig.AllowLan = patchConfig.AllowLan
+161 -165
View File
@@ -35,7 +35,6 @@ class _AccessFragmentState extends State<AccessFragment> {
}); });
} }
@override @override
void dispose() { void dispose() {
super.dispose(); super.dispose();
@@ -112,55 +111,48 @@ class _AccessFragmentState extends State<AccessFragment> {
); );
} }
_buildSelectedAllButton({ Widget _buildSelectedAllButton({
required bool isAccessControl, required bool isAccessControl,
required bool isSelectedAll, required bool isSelectedAll,
required List<String> allValueList, required List<String> allValueList,
}) { }) {
WidgetsBinding.instance.addPostFrameCallback((_) { final tooltip = isSelectedAll
final tooltip = isSelectedAll ? appLocalizations.cancelSelectAll
? appLocalizations.cancelSelectAll : appLocalizations.selectAll;
: appLocalizations.selectAll; return AbsorbPointer(
final commonScaffoldState = absorbing: !isAccessControl,
context.findAncestorStateOfType<CommonScaffoldState>(); child: FloatingActionButton(
commonScaffoldState?.floatingActionButton = DisabledMask( tooltip: tooltip,
status: !isAccessControl, onPressed: () {
child: AbsorbPointer( final config = globalState.appController.config;
absorbing: !isAccessControl, final isAccept =
child: FloatingActionButton ( config.accessControl.mode == AccessControlMode.acceptSelected;
tooltip: tooltip,
onPressed: () {
final config = globalState.appController.config;
final isAccept =
config.accessControl.mode == AccessControlMode.acceptSelected;
if (isSelectedAll) { if (isSelectedAll) {
config.accessControl = switch (isAccept) { config.accessControl = switch (isAccept) {
true => config.accessControl.copyWith( true => config.accessControl.copyWith(
acceptList: [], acceptList: [],
), ),
false => config.accessControl.copyWith( false => config.accessControl.copyWith(
rejectList: [], rejectList: [],
), ),
}; };
} else { } else {
config.accessControl = switch (isAccept) { config.accessControl = switch (isAccept) {
true => config.accessControl.copyWith( true => config.accessControl.copyWith(
acceptList: allValueList, acceptList: allValueList,
), ),
false => config.accessControl.copyWith( false => config.accessControl.copyWith(
rejectList: allValueList, rejectList: allValueList,
), ),
}; };
} }
}, },
child: isSelectedAll child: isSelectedAll
? const Icon(Icons.deselect) ? const Icon(Icons.deselect)
: const Icon(Icons.select_all), : const Icon(Icons.select_all),
), ),
), );
);
});
} }
Widget _buildPackageList() { Widget _buildPackageList() {
@@ -213,137 +205,141 @@ class _AccessFragmentState extends State<AccessFragment> {
accessControlMode == AccessControlMode.acceptSelected accessControlMode == AccessControlMode.acceptSelected
? appLocalizations.accessControlAllowDesc ? appLocalizations.accessControlAllowDesc
: appLocalizations.accessControlNotAllowDesc; : appLocalizations.accessControlNotAllowDesc;
_buildSelectedAllButton(
isAccessControl: isAccessControl,
isSelectedAll: valueList.length == packageNameList.length,
allValueList: packageNameList,
);
return DisabledMask( return DisabledMask(
status: !isAccessControl, status: !isAccessControl,
child: Column( child: FloatLayout(
children: [ floatingWidget: FloatWrapper(
AbsorbPointer( child: _buildSelectedAllButton(
absorbing: !isAccessControl, isAccessControl: isAccessControl,
child: Padding( isSelectedAll: valueList.length == packageNameList.length,
padding: const EdgeInsets.only( allValueList: packageNameList,
top: 4, ),
bottom: 4, ),
left: 16, child: Column(
right: 8, children: [
), AbsorbPointer(
child: Row( absorbing: !isAccessControl,
mainAxisAlignment: MainAxisAlignment.spaceBetween, child: Padding(
mainAxisSize: MainAxisSize.max, padding: const EdgeInsets.only(
children: [ top: 4,
Expanded( bottom: 4,
child: IntrinsicHeight( left: 16,
child: Column( right: 8,
mainAxisSize: MainAxisSize.max, ),
crossAxisAlignment: CrossAxisAlignment.start, child: Row(
children: [ mainAxisAlignment: MainAxisAlignment.spaceBetween,
Expanded( mainAxisSize: MainAxisSize.max,
child: Row( children: [
children: [ Expanded(
Flexible( child: IntrinsicHeight(
child: Text( child: Column(
appLocalizations.selected, mainAxisSize: MainAxisSize.max,
style: Theme.of(context) crossAxisAlignment: CrossAxisAlignment.start,
.textTheme children: [
.labelLarge Expanded(
?.copyWith( child: Row(
color: Theme.of(context) children: [
.colorScheme Flexible(
.primary, child: Text(
), appLocalizations.selected,
style: Theme.of(context)
.textTheme
.labelLarge
?.copyWith(
color: Theme.of(context)
.colorScheme
.primary,
),
),
), ),
), const Flexible(
const Flexible( child: SizedBox(
child: SizedBox( width: 8,
width: 8, ),
), ),
), Flexible(
Flexible( child: Text(
child: Text( "${valueList.length}",
"${valueList.length}", style: Theme.of(context)
style: Theme.of(context) .textTheme
.textTheme .labelLarge
.labelLarge ?.copyWith(
?.copyWith( color: Theme.of(context)
color: Theme.of(context) .colorScheme
.colorScheme .primary,
.primary, ),
), ),
), ),
), ],
], ),
), ),
), Flexible(
Flexible( child: Text(describe),
child: Text(describe), )
) ],
], ),
), ),
), ),
), Row(
Row( mainAxisSize: MainAxisSize.min,
mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.end,
mainAxisAlignment: MainAxisAlignment.end, children: [
children: [ Flexible(
Flexible( child: _buildSearchButton(currentPackages)),
child: _buildSearchButton(currentPackages)), Flexible(child: _buildFilterSystemAppButton()),
Flexible(child: _buildFilterSystemAppButton()), Flexible(child: _buildAppProxyModePopup()),
Flexible(child: _buildAppProxyModePopup()), ],
], ),
), ],
], ),
), ),
), ),
), Expanded(
Expanded( flex: 1,
flex: 1, child: FadeBox(
child: FadeBox( key: const Key("fade_box"),
key: const Key("fade_box"), child: currentPackages.isEmpty
child: currentPackages.isEmpty ? const Center(
? const Center( child: CircularProgressIndicator(),
child: CircularProgressIndicator(), )
) : ListView.builder(
: ListView.builder( itemCount: currentPackages.length,
itemCount: currentPackages.length, itemBuilder: (_, index) {
itemBuilder: (_, index) { final package = currentPackages[index];
final package = currentPackages[index]; return PackageListItem(
return PackageListItem( key: Key(package.packageName),
key: Key(package.packageName), package: package,
package: package, value:
value: valueList.contains(package.packageName),
valueList.contains(package.packageName), isActive: isAccessControl,
isActive: isAccessControl, onChanged: (value) {
onChanged: (value) { if (value == true) {
if (value == true) { valueList.add(package.packageName);
valueList.add(package.packageName); } else {
} else { valueList.remove(package.packageName);
valueList.remove(package.packageName); }
} final config =
final config = globalState.appController.config;
globalState.appController.config; if (accessControlMode ==
if (accessControlMode == AccessControlMode.acceptSelected) {
AccessControlMode.acceptSelected) { config.accessControl =
config.accessControl = config.accessControl.copyWith(
config.accessControl.copyWith( acceptList: valueList,
acceptList: valueList, );
); } else {
} else { config.accessControl =
config.accessControl = config.accessControl.copyWith(
config.accessControl.copyWith( rejectList: valueList,
rejectList: valueList, );
); }
} },
}, );
); },
}, ),
), ),
), ),
), ],
], ),
), ),
); );
}, },
+77 -72
View File
@@ -76,13 +76,6 @@ class _ProfilesFragmentState extends State<ProfilesFragment> {
width: 8, width: 8,
) )
]; ];
commonScaffoldState?.floatingActionButton = FloatingActionButton(
heroTag: null,
onPressed: _handleShowAddExtendPage,
child: const Icon(
Icons.add,
),
);
}, },
); );
} }
@@ -113,74 +106,86 @@ class _ProfilesFragmentState extends State<ProfilesFragment> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Selector<AppState, bool>( return FloatLayout(
selector: (_, appState) => appState.currentLabel == 'profiles', floatingWidget: FloatWrapper(
builder: (_, isCurrent, child) { child: FloatingActionButton(
if (isCurrent) { heroTag: null,
_initScaffoldState(); onPressed: _handleShowAddExtendPage,
} child: const Icon(
return child!; Icons.add,
}, ),
child: Selector2<AppState, Config, ProfilesSelectorState>(
selector: (_, appState, config) => ProfilesSelectorState(
profiles: config.profiles,
currentProfileId: config.currentProfileId,
viewMode: appState.viewMode,
), ),
builder: (context, state, child) { ),
if (state.profiles.isEmpty) { child: Selector<AppState, bool>(
return NullStatus( selector: (_, appState) => appState.currentLabel == 'profiles',
label: appLocalizations.nullProfileDesc, builder: (_, isCurrent, child) {
); if (isCurrent) {
_initScaffoldState();
} }
profileItemKeys = state.profiles return child!;
.map((profile) => GlobalObjectKey<_ProfileItemState>(profile.id))
.toList();
final columns = _getColumns(state.viewMode);
return Align(
alignment: Alignment.topCenter,
child: NotificationListener<ScrollNotification>(
onNotification: (scrollNotification) {
WidgetsBinding.instance.addPostFrameCallback(
(_) {
hasPadding.value =
scrollNotification.metrics.maxScrollExtent > 0;
},
);
return true;
},
child: ValueListenableBuilder(
valueListenable: hasPadding,
builder: (_, hasPadding, __) {
return SingleChildScrollView(
padding: EdgeInsets.only(
left: 16,
right: 16,
top: 16,
bottom: 16 + (hasPadding ? 56 : 0),
),
child: Grid(
mainAxisSpacing: 16,
crossAxisSpacing: 16,
crossAxisCount: columns,
children: [
for (int i = 0; i < state.profiles.length; i++)
GridItem(
child: ProfileItem(
key: profileItemKeys[i],
profile: state.profiles[i],
groupValue: state.currentProfileId,
onChanged: _changeProfile,
),
),
],
),
);
},
),
),
);
}, },
child: Selector2<AppState, Config, ProfilesSelectorState>(
selector: (_, appState, config) => ProfilesSelectorState(
profiles: config.profiles,
currentProfileId: config.currentProfileId,
viewMode: appState.viewMode,
),
builder: (context, state, child) {
if (state.profiles.isEmpty) {
return NullStatus(
label: appLocalizations.nullProfileDesc,
);
}
profileItemKeys = state.profiles
.map(
(profile) => GlobalObjectKey<_ProfileItemState>(profile.id))
.toList();
final columns = _getColumns(state.viewMode);
return Align(
alignment: Alignment.topCenter,
child: NotificationListener<ScrollNotification>(
onNotification: (scrollNotification) {
WidgetsBinding.instance.addPostFrameCallback(
(_) {
hasPadding.value =
scrollNotification.metrics.maxScrollExtent > 0;
},
);
return true;
},
child: ValueListenableBuilder(
valueListenable: hasPadding,
builder: (_, hasPadding, __) {
return SingleChildScrollView(
padding: EdgeInsets.only(
left: 16,
right: 16,
top: 16,
bottom: 16 + (hasPadding ? 56 : 0),
),
child: Grid(
mainAxisSpacing: 16,
crossAxisSpacing: 16,
crossAxisCount: columns,
children: [
for (int i = 0; i < state.profiles.length; i++)
GridItem(
child: ProfileItem(
key: profileItemKeys[i],
profile: state.profiles[i],
groupValue: state.currentProfileId,
onChanged: _changeProfile,
),
),
],
),
);
},
),
),
);
},
),
), ),
); );
} }
-10
View File
@@ -49,8 +49,6 @@ class CommonScaffold extends StatefulWidget {
class CommonScaffoldState extends State<CommonScaffold> { class CommonScaffoldState extends State<CommonScaffold> {
final ValueNotifier<List<Widget>> _actions = ValueNotifier([]); final ValueNotifier<List<Widget>> _actions = ValueNotifier([]);
final ValueNotifier<Widget?> _floatingActionButton = ValueNotifier(null);
final ValueNotifier<bool> _loading = ValueNotifier(false); final ValueNotifier<bool> _loading = ValueNotifier(false);
set actions(List<Widget> actions) { set actions(List<Widget> actions) {
@@ -59,12 +57,6 @@ class CommonScaffoldState extends State<CommonScaffold> {
} }
} }
set floatingActionButton(Widget? actions) {
if (_floatingActionButton.value != actions) {
_floatingActionButton.value = actions;
}
}
Future<T?> loadingRun<T>( Future<T?> loadingRun<T>(
Future<T> Function() futureFunction, { Future<T> Function() futureFunction, {
String? title, String? title,
@@ -89,7 +81,6 @@ class CommonScaffoldState extends State<CommonScaffold> {
@override @override
void dispose() { void dispose() {
_actions.dispose(); _actions.dispose();
_floatingActionButton.dispose();
super.dispose(); super.dispose();
} }
@@ -98,7 +89,6 @@ class CommonScaffoldState extends State<CommonScaffold> {
super.didUpdateWidget(oldWidget); super.didUpdateWidget(oldWidget);
if (oldWidget.title != widget.title) { if (oldWidget.title != widget.title) {
_actions.value = []; _actions.value = [];
_floatingActionButton.value = null;
} }
} }
+1 -1
View File
@@ -1,7 +1,7 @@
name: fl_clash name: fl_clash
description: A multi-platform proxy client based on ClashMeta, simple and easy to use, open-source and ad-free. description: A multi-platform proxy client based on ClashMeta, simple and easy to use, open-source and ad-free.
publish_to: 'none' publish_to: 'none'
version: 0.8.37+202407141 version: 0.8.38+202407142
environment: environment:
sdk: '>=3.1.0 <4.0.0' sdk: '>=3.1.0 <4.0.0'