feat: 长按保存封面
This commit is contained in:
@ -5,9 +5,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:pilipala/common/constants.dart';
|
||||
import 'package:pilipala/common/skeleton/video_card_v.dart';
|
||||
import 'package:pilipala/common/widgets/animated_dialog.dart';
|
||||
import 'package:pilipala/common/widgets/http_error.dart';
|
||||
import 'package:pilipala/common/widgets/overlay_pop.dart';
|
||||
import 'package:pilipala/utils/main_stream.dart';
|
||||
|
||||
import 'controller.dart';
|
||||
@ -112,16 +110,6 @@ class _LivePageState extends State<LivePage>
|
||||
);
|
||||
}
|
||||
|
||||
OverlayEntry _createPopupDialog(liveItem) {
|
||||
return OverlayEntry(
|
||||
builder: (context) => AnimatedDialog(
|
||||
closeFn: _liveController.popupDialog?.remove,
|
||||
child: OverlayPop(
|
||||
videoItem: liveItem, closeFn: _liveController.popupDialog?.remove),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget contentGrid(ctr, liveList) {
|
||||
// double maxWidth = Get.size.width;
|
||||
// int baseWidth = 500;
|
||||
@ -152,14 +140,6 @@ class _LivePageState extends State<LivePage>
|
||||
? LiveCardV(
|
||||
liveItem: liveList[index],
|
||||
crossAxisCount: crossAxisCount,
|
||||
longPress: () {
|
||||
_liveController.popupDialog =
|
||||
_createPopupDialog(liveList[index]);
|
||||
Overlay.of(context).insert(_liveController.popupDialog!);
|
||||
},
|
||||
longPressEnd: () {
|
||||
_liveController.popupDialog?.remove();
|
||||
},
|
||||
)
|
||||
: const VideoCardVSkeleton();
|
||||
},
|
||||
|
@ -1,7 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:pilipala/common/constants.dart';
|
||||
import 'package:pilipala/models/live/item.dart';
|
||||
import 'package:pilipala/utils/image_save.dart';
|
||||
import 'package:pilipala/utils/utils.dart';
|
||||
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
||||
|
||||
@ -9,81 +11,66 @@ import 'package:pilipala/common/widgets/network_img_layer.dart';
|
||||
class LiveCardV extends StatelessWidget {
|
||||
final LiveItemModel liveItem;
|
||||
final int crossAxisCount;
|
||||
final Function()? longPress;
|
||||
final Function()? longPressEnd;
|
||||
|
||||
const LiveCardV({
|
||||
Key? key,
|
||||
required this.liveItem,
|
||||
required this.crossAxisCount,
|
||||
this.longPress,
|
||||
this.longPressEnd,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
String heroTag = Utils.makeHeroTag(liveItem.roomId);
|
||||
return Card(
|
||||
elevation: 0,
|
||||
clipBehavior: Clip.hardEdge,
|
||||
margin: EdgeInsets.zero,
|
||||
child: GestureDetector(
|
||||
onLongPress: () {
|
||||
if (longPress != null) {
|
||||
longPress!();
|
||||
}
|
||||
},
|
||||
// onLongPressEnd: (details) {
|
||||
// if (longPressEnd != null) {
|
||||
// longPressEnd!();
|
||||
// }
|
||||
// },
|
||||
child: InkWell(
|
||||
onTap: () async {
|
||||
Get.toNamed('/liveRoom?roomid=${liveItem.roomId}',
|
||||
arguments: {'liveItem': liveItem, 'heroTag': heroTag});
|
||||
},
|
||||
child: Column(
|
||||
children: [
|
||||
ClipRRect(
|
||||
borderRadius: const BorderRadius.all(StyleString.imgRadius),
|
||||
child: AspectRatio(
|
||||
aspectRatio: StyleString.aspectRatio,
|
||||
child: LayoutBuilder(builder: (context, boxConstraints) {
|
||||
double maxWidth = boxConstraints.maxWidth;
|
||||
double maxHeight = boxConstraints.maxHeight;
|
||||
return Stack(
|
||||
children: [
|
||||
Hero(
|
||||
tag: heroTag,
|
||||
child: NetworkImgLayer(
|
||||
src: liveItem.cover!,
|
||||
width: maxWidth,
|
||||
height: maxHeight,
|
||||
return InkWell(
|
||||
onLongPress: () => imageSaveDialog(
|
||||
context,
|
||||
liveItem,
|
||||
SmartDialog.dismiss,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
onTap: () async {
|
||||
Get.toNamed('/liveRoom?roomid=${liveItem.roomId}',
|
||||
arguments: {'liveItem': liveItem, 'heroTag': heroTag});
|
||||
},
|
||||
child: Column(
|
||||
children: [
|
||||
ClipRRect(
|
||||
borderRadius: const BorderRadius.all(StyleString.imgRadius),
|
||||
child: AspectRatio(
|
||||
aspectRatio: StyleString.aspectRatio,
|
||||
child: LayoutBuilder(builder: (context, boxConstraints) {
|
||||
double maxWidth = boxConstraints.maxWidth;
|
||||
double maxHeight = boxConstraints.maxHeight;
|
||||
return Stack(
|
||||
children: [
|
||||
Hero(
|
||||
tag: heroTag,
|
||||
child: NetworkImgLayer(
|
||||
src: liveItem.cover!,
|
||||
width: maxWidth,
|
||||
height: maxHeight,
|
||||
),
|
||||
),
|
||||
if (crossAxisCount != 1)
|
||||
Positioned(
|
||||
left: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
child: AnimatedOpacity(
|
||||
opacity: 1,
|
||||
duration: const Duration(milliseconds: 200),
|
||||
child: VideoStat(
|
||||
liveItem: liveItem,
|
||||
),
|
||||
),
|
||||
if (crossAxisCount != 1)
|
||||
Positioned(
|
||||
left: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
child: AnimatedOpacity(
|
||||
opacity: 1,
|
||||
duration: const Duration(milliseconds: 200),
|
||||
child: VideoStat(
|
||||
liveItem: liveItem,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}),
|
||||
),
|
||||
),
|
||||
LiveContent(liveItem: liveItem, crossAxisCount: crossAxisCount)
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}),
|
||||
),
|
||||
),
|
||||
),
|
||||
LiveContent(liveItem: liveItem, crossAxisCount: crossAxisCount)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user