feat: 锁定按钮非全屏时隐藏;截图新增结果确认弹窗避免误触

This commit is contained in:
orz12
2024-07-07 15:16:38 +08:00
parent 391c11831d
commit 6167288af2

View File

@@ -983,7 +983,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
child: FractionalTranslation( child: FractionalTranslation(
translation: const Offset(1, -0.4), translation: const Offset(1, -0.4),
child: Visibility( child: Visibility(
visible: _.showControls.value, visible: _.showControls.value && _.isFullScreen.value,
child: ComBtn( child: ComBtn(
tooltip: _.controlsLock.value ? '解锁' : '锁定', tooltip: _.controlsLock.value ? '解锁' : '锁定',
icon: Icon( icon: Icon(
@@ -1016,20 +1016,58 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
size: 20, size: 20,
color: Colors.white, color: Colors.white,
), ),
fuc: () => { fuc: () {
SmartDialog.showToast('截图中');
_.videoPlayerController _.videoPlayerController
?.screenshot(format: 'image/png') ?.screenshot(format: 'image/png')
.then((value) { .then((value) {
if (value != null) { if (value != null) {
SmartDialog.showToast('截图成功'); SmartDialog.showToast('点击弹窗保存截图');
String _name = DateTime.now().toString(); showDialog(
SaverGallery.saveImage(value, context: context,
name: _name, builder: (BuildContext context) {
androidRelativePath: "Pictures/Screenshots", return AlertDialog(
androidExistNotSave: false); // title: const Text('点击保存'),
SmartDialog.showToast('$_name.png已保存到相册/截图'); titlePadding: EdgeInsets.zero,
contentPadding: const EdgeInsets.all(8),
insetPadding:
EdgeInsets.only(left: context.width / 2),
//移除圆角
shape: const RoundedRectangleBorder(),
content: GestureDetector(
onTap: () async {
String name = DateTime.now().toString();
final SaveResult result =
await SaverGallery.saveImage(
value,
name: name,
androidRelativePath: "Pictures/Screenshots",
androidExistNotSave: false,
);
if (result.isSuccess) {
Get.back();
SmartDialog.showToast('$name.png已保存到相册/截图');
} else {
await SmartDialog.showToast(
'保存失败,${result.errorMessage}');
}
},
child: ConstrainedBox(
constraints: BoxConstraints(
maxWidth: context.width / 3,
maxHeight: context.height / 3,
),
child: Image.memory(value),
),
),
);
},
);
} else {
SmartDialog.showToast('截图失败');
} }
}) });
}, },
), ),
), ),