fix: failed to remove when showing multi popup dialogs

This commit is contained in:
bggRGjQaUbCoE
2024-08-30 22:20:04 +08:00
parent 1864fa29bf
commit 40cfce3501
10 changed files with 74 additions and 47 deletions

View File

@@ -11,7 +11,7 @@ class HotController extends GetxController {
RxList<HotVideoItemModel> videoList = <HotVideoItemModel>[].obs;
bool isLoadingMore = false;
bool flag = false;
OverlayEntry? popupDialog;
List<OverlayEntry?> popupDialog = <OverlayEntry?>[];
// 获取推荐
Future queryHotFeed(type) async {

View File

@@ -102,14 +102,12 @@ class _HotPageState extends State<HotPage> with AutomaticKeepAliveClientMixin {
videoItem: _hotController.videoList[index],
showPubdate: true,
longPress: () {
_hotController.popupDialog = _createPopupDialog(
_hotController.videoList[index]);
_hotController.popupDialog
.add(_createPopupDialog(videoList[index]));
Overlay.of(context)
.insert(_hotController.popupDialog!);
},
longPressEnd: () {
_hotController.popupDialog?.remove();
.insert(_hotController.popupDialog.last!);
},
longPressEnd: _removePopupDialog,
);
}, childCount: _hotController.videoList.length),
),
@@ -151,12 +149,19 @@ class _HotPageState extends State<HotPage> with AutomaticKeepAliveClientMixin {
);
}
void _removePopupDialog() {
_hotController.popupDialog.last?.remove();
_hotController.popupDialog.removeLast();
}
OverlayEntry _createPopupDialog(videoItem) {
return OverlayEntry(
builder: (context) => AnimatedDialog(
closeFn: _hotController.popupDialog?.remove,
closeFn: _removePopupDialog,
child: OverlayPop(
videoItem: videoItem, closeFn: _hotController.popupDialog?.remove),
videoItem: videoItem,
closeFn: _removePopupDialog,
),
),
);
}