Fix some issues

This commit is contained in:
chen08209
2025-02-03 02:24:45 +08:00
parent 683e6a58ea
commit e04a0094b1
6 changed files with 30 additions and 30 deletions

View File

@@ -289,6 +289,7 @@ class ProfileItem extends StatelessWidget {
@override
Widget build(BuildContext context) {
final key = GlobalKey<CommonPopupBoxState>();
return CommonCard(
isSelected: profile.id == groupValue,
onPressed: () {
@@ -308,6 +309,7 @@ class ProfileItem extends StatelessWidget {
child: CircularProgressIndicator(),
)
: CommonPopupBox(
key: key,
popup: CommonPopupMenu(
items: [
ActionItemData(
@@ -352,7 +354,9 @@ class ProfileItem extends StatelessWidget {
],
),
target: IconButton(
onPressed: () {},
onPressed: () {
key.currentState?.pop();
},
icon: Icon(Icons.more_vert),
),
),

View File

@@ -99,6 +99,10 @@ Future<void> _service(List<String> flags) async {
)
.then(
(res) async {
if (res.isNotEmpty) {
await vpn?.stop();
exit(0);
}
await vpn?.start(
clashLibHandler.getAndroidVpnOptions(),
);

View File

@@ -182,9 +182,6 @@ class CommonCard extends StatelessWidget {
return OutlinedButton(
clipBehavior: Clip.antiAlias,
onLongPress: (){
},
style: ButtonStyle(
padding: const WidgetStatePropertyAll(EdgeInsets.zero),
shape: WidgetStatePropertyAll(

View File

@@ -93,16 +93,14 @@ class CommonPopupBox extends StatefulWidget {
});
@override
State<CommonPopupBox> createState() => _CommonPopupBoxState();
State<CommonPopupBox> createState() => CommonPopupBoxState();
}
class _CommonPopupBoxState extends State<CommonPopupBox> {
final _targetKey = GlobalKey();
class CommonPopupBoxState extends State<CommonPopupBox> {
final _targetOffsetValueNotifier = ValueNotifier(Offset.zero);
_handleTargetOffset() {
final renderBox =
_targetKey.currentContext?.findRenderObject() as RenderBox?;
final renderBox = context.findRenderObject() as RenderBox?;
if (renderBox == null) {
return;
}
@@ -111,29 +109,23 @@ class _CommonPopupBoxState extends State<CommonPopupBox> {
);
}
@override
Widget build(BuildContext context) {
return Listener(
onPointerDown: (details) {
_handleTargetOffset();
Navigator.of(context).push(
CommonPopupRoute(
barrierLabel: other.id,
builder: (BuildContext context) {
return widget.popup;
},
offsetNotifier: _targetOffsetValueNotifier,
),
);
},
key: _targetKey,
child: LayoutBuilder(
builder: (_, __) {
return widget.target;
pop() {
_handleTargetOffset();
Navigator.of(context).push(
CommonPopupRoute(
barrierLabel: other.id,
builder: (BuildContext context) {
return widget.popup;
},
offsetNotifier: _targetOffsetValueNotifier,
),
);
}
@override
Widget build(BuildContext context) {
return widget.target;
}
}
class OverflowAwareLayoutDelegate extends SingleChildLayoutDelegate {