mod: 推荐视频长按

This commit is contained in:
guozhigq
2023-05-15 10:28:48 +08:00
parent 1c1b951df7
commit a9ae6941f3
4 changed files with 34 additions and 5 deletions

View File

@ -25,10 +25,14 @@ class VideoCardH extends StatelessWidget {
String heroTag = Utils.makeHeroTag(aid);
return GestureDetector(
onLongPress: () {
if (longPress != null) {
longPress!();
}
},
onLongPressEnd: (details) {
if (longPressEnd != null) {
longPressEnd!();
}
},
child: InkWell(
onTap: () async {

View File

@ -32,10 +32,14 @@ class VideoCardV extends StatelessWidget {
margin: EdgeInsets.zero,
child: GestureDetector(
onLongPress: () {
if (longPress != null) {
longPress!();
}
},
onLongPressEnd: (details) {
if (longPressEnd != null) {
longPressEnd!();
}
},
child: InkWell(
onTap: () async {

View File

@ -1,3 +1,4 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:pilipala/http/video.dart';
@ -7,5 +8,7 @@ class ReleatedController extends GetxController {
// 推荐视频列表
List relatedVideoList = [];
OverlayEntry? popupDialog;
Future<dynamic> queryRelatedVideo() => VideoHttp.relatedVideoList(aid: aid);
}

View File

@ -1,8 +1,9 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:pilipala/common/skeleton/video_card_h.dart';
import 'package:pilipala/common/widgets/animated_dialog.dart';
import 'package:pilipala/common/widgets/overlay_pop.dart';
import 'package:pilipala/common/widgets/video_card_h.dart';
import 'package:pilipala/common/widgets/video_card_v.dart';
import './controller.dart';
class RelatedVideoPanel extends StatefulWidget {
@ -31,6 +32,15 @@ class _RelatedVideoPanelState extends State<RelatedVideoPanel> {
} else {
return VideoCardH(
videoItem: snapshot.data['data'][index],
longPress: () {
_releatedController.popupDialog =
_createPopupDialog(snapshot.data['data'][index]);
Overlay.of(context)
.insert(_releatedController.popupDialog!);
},
longPressEnd: () {
_releatedController.popupDialog?.remove();
},
);
}
}, childCount: snapshot.data['data'].length + 1));
@ -51,4 +61,12 @@ class _RelatedVideoPanelState extends State<RelatedVideoPanel> {
},
);
}
OverlayEntry _createPopupDialog(videoItem) {
return OverlayEntry(
builder: (context) => AnimatedDialog(
child: OverlayPop(videoItem: videoItem),
),
);
}
}