fix:视频日志显示逻辑、视频/图片下载
This commit is contained in:
parent
9504a97bde
commit
c8b305a4f2
@ -2,4 +2,5 @@ distributionBase=GRADLE_USER_HOME
|
|||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
|
#distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
|
||||||
|
distributionUrl=https://mirrors.cloud.tencent.com/gradle/gradle-7.4-all.zip
|
||||||
|
|||||||
@ -1126,6 +1126,7 @@
|
|||||||
"通话连接失败": "Call connection failed",
|
"通话连接失败": "Call connection failed",
|
||||||
"已挂断": "Hanging up",
|
"已挂断": "Hanging up",
|
||||||
"正在说话...": "Talking now...",
|
"正在说话...": "Talking now...",
|
||||||
|
"下载完成,请到相册查看": "Download completed, please go to the album to view",
|
||||||
"重置后,该锁的遥控都将被删除哦,确认要重置吗?": "After reset, the remote control of the lock will be deleted. Do you want to reset it?",
|
"重置后,该锁的遥控都将被删除哦,确认要重置吗?": "After reset, the remote control of the lock will be deleted. Do you want to reset it?",
|
||||||
"版本说明": "Version description"
|
"版本说明": "Version description"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1126,6 +1126,7 @@
|
|||||||
"通话连接失败": "通话连接失败",
|
"通话连接失败": "通话连接失败",
|
||||||
"已挂断": "已挂断",
|
"已挂断": "已挂断",
|
||||||
"正在说话...": "正在说话...",
|
"正在说话...": "正在说话...",
|
||||||
|
"下载完成,请到相册查看": "下载完成,请到相册查看",
|
||||||
"重置后,该锁的遥控都将被删除哦,确认要重置吗?": "重置后,该锁的遥控都将被删除哦,确认要重置吗?",
|
"重置后,该锁的遥控都将被删除哦,确认要重置吗?": "重置后,该锁的遥控都将被删除哦,确认要重置吗?",
|
||||||
"版本说明": "版本说明"
|
"版本说明": "版本说明"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1126,6 +1126,7 @@
|
|||||||
"通话连接失败": "通话连接失败",
|
"通话连接失败": "通话连接失败",
|
||||||
"已挂断": "已挂断",
|
"已挂断": "已挂断",
|
||||||
"正在说话...": "正在说话...",
|
"正在说话...": "正在说话...",
|
||||||
|
"下载完成,请到相册查看": "下载完成,请到相册查看",
|
||||||
"重置后,该锁的遥控都将被删除哦,确认要重置吗?": "重置后,该锁的遥控都将被删除哦,确认要重置吗?",
|
"重置后,该锁的遥控都将被删除哦,确认要重置吗?": "重置后,该锁的遥控都将被删除哦,确认要重置吗?",
|
||||||
"版本说明": "版本说明"
|
"版本说明": "版本说明"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -403,17 +403,23 @@ class _DoorLockLogPageState extends State<DoorLockLogPage> with RouteAware {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_buildImageItem(RecordListData recordData) {
|
_buildImageItem(RecordListData recordData) {
|
||||||
return Image.network(
|
return RotatedBox(
|
||||||
recordData.imagesUrl!,
|
quarterTurns: -1,
|
||||||
fit: BoxFit.cover,
|
child: Image.network(
|
||||||
errorBuilder:
|
recordData.imagesUrl!,
|
||||||
(BuildContext context, Object error, StackTrace? stackTrace) {
|
fit: BoxFit.cover,
|
||||||
// 图片加载失败时显示错误图片
|
errorBuilder:
|
||||||
return Image.asset(
|
(BuildContext context, Object error, StackTrace? stackTrace) {
|
||||||
'images/icon_unHaveData.png', // 错误图片路径
|
// 图片加载失败时显示错误图片
|
||||||
fit: BoxFit.cover,
|
return RotatedBox(
|
||||||
);
|
quarterTurns: -1,
|
||||||
},
|
child: Image.asset(
|
||||||
|
'images/icon_unHaveData.png', // 错误图片路径
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,10 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:dio/dio.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
import 'package:image_gallery_saver/image_gallery_saver.dart';
|
||||||
|
import 'package:path_provider/path_provider.dart';
|
||||||
|
import 'package:permission_handler/permission_handler.dart';
|
||||||
import 'package:star_lock/main/lockDetail/videoLog/videoLog/videoLog_entity.dart';
|
import 'package:star_lock/main/lockDetail/videoLog/videoLog/videoLog_entity.dart';
|
||||||
import 'package:star_lock/network/api_repository.dart';
|
import 'package:star_lock/network/api_repository.dart';
|
||||||
import 'package:star_lock/tools/baseGetXController.dart';
|
import 'package:star_lock/tools/baseGetXController.dart';
|
||||||
@ -9,18 +15,20 @@ class EditVideoLogLogic extends BaseGetXController {
|
|||||||
EditVideoLogState state = EditVideoLogState();
|
EditVideoLogState state = EditVideoLogState();
|
||||||
|
|
||||||
Future<void> deleteLockCloudStorageList() async {
|
Future<void> deleteLockCloudStorageList() async {
|
||||||
final VersionUndateEntity entity = await ApiRepository.to.deleteLockCloudStorageList(
|
final VersionUndateEntity entity =
|
||||||
|
await ApiRepository.to.deleteLockCloudStorageList(
|
||||||
recordIds: state.selectVideoLogList.value.map((e) => e.recordId).toList(),
|
recordIds: state.selectVideoLogList.value.map((e) => e.recordId).toList(),
|
||||||
);
|
);
|
||||||
if (entity.errorCode!.codeIsSuccessful) {
|
if (entity.errorCode!.codeIsSuccessful) {
|
||||||
state.selectVideoLogList.value.clear();
|
|
||||||
showToast('删除成功'.tr);
|
showToast('删除成功'.tr);
|
||||||
getLockCloudStorageList();
|
await getLockCloudStorageList();
|
||||||
|
state.selectVideoLogList.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getLockCloudStorageList() async {
|
Future<void> getLockCloudStorageList() async {
|
||||||
final VideoLogEntity entity = await ApiRepository.to.getLockCloudStorageList(
|
final VideoLogEntity entity =
|
||||||
|
await ApiRepository.to.getLockCloudStorageList(
|
||||||
lockId: state.getLockId.value,
|
lockId: state.getLockId.value,
|
||||||
);
|
);
|
||||||
if (entity.errorCode!.codeIsSuccessful) {
|
if (entity.errorCode!.codeIsSuccessful) {
|
||||||
@ -28,4 +36,59 @@ class EditVideoLogLogic extends BaseGetXController {
|
|||||||
state.videoLogList.refresh();
|
state.videoLogList.refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> downloadAndSaveToGallery(String url, String fileName) async {
|
||||||
|
try {
|
||||||
|
// 请求存储权限
|
||||||
|
if (await _requestPermission()) {
|
||||||
|
final dio = Dio();
|
||||||
|
final directory = await getTemporaryDirectory();
|
||||||
|
final filePath = '${directory.path}/$fileName';
|
||||||
|
|
||||||
|
// 下载文件
|
||||||
|
await dio.download(
|
||||||
|
url,
|
||||||
|
filePath,
|
||||||
|
onReceiveProgress: (received, total) {
|
||||||
|
if (total != -1) {
|
||||||
|
final progress = (received / total) * 100;
|
||||||
|
print('下载进度: $progress%');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
// 保存到图库
|
||||||
|
if (fileName.endsWith('.jpg') || fileName.endsWith('.png')) {
|
||||||
|
// 保存图片
|
||||||
|
final result = await ImageGallerySaver.saveFile(filePath);
|
||||||
|
if (result['isSuccess']) {
|
||||||
|
print('图片已保存到图库');
|
||||||
|
} else {
|
||||||
|
print('图片保存失败');
|
||||||
|
}
|
||||||
|
} else if (fileName.endsWith('.mp4')) {
|
||||||
|
// 保存视频
|
||||||
|
final result = await ImageGallerySaver.saveFile(filePath);
|
||||||
|
if (result['isSuccess']) {
|
||||||
|
print('视频已保存到图库');
|
||||||
|
} else {
|
||||||
|
print('视频保存失败');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除临时文件
|
||||||
|
await File(filePath).delete();
|
||||||
|
} else {
|
||||||
|
print('存储权限被拒绝');
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
print('下载或保存文件失败: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 请求存储权限
|
||||||
|
Future<bool> _requestPermission() async {
|
||||||
|
final status = await Permission.storage.request();
|
||||||
|
return status.isGranted;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,10 +1,12 @@
|
|||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:star_lock/appRouters.dart';
|
import 'package:star_lock/appRouters.dart';
|
||||||
import 'package:star_lock/main/lockDetail/videoLog/editVideoLog/editVideoLog_state.dart';
|
import 'package:star_lock/main/lockDetail/videoLog/editVideoLog/editVideoLog_state.dart';
|
||||||
import 'package:star_lock/main/lockDetail/videoLog/videoLog/videoLog_entity.dart';
|
import 'package:star_lock/main/lockDetail/videoLog/videoLog/videoLog_entity.dart';
|
||||||
|
import 'package:star_lock/main/lockDetail/videoLog/widget/full_screenImage_page.dart';
|
||||||
|
import 'package:star_lock/main/lockDetail/videoLog/widget/video_thumbnail.dart';
|
||||||
import 'package:star_lock/tools/dateTool.dart';
|
import 'package:star_lock/tools/dateTool.dart';
|
||||||
|
|
||||||
import '../../../../app_settings/app_colors.dart';
|
import '../../../../app_settings/app_colors.dart';
|
||||||
@ -97,6 +99,7 @@ class _EditVideoLogPageState extends State<EditVideoLogPage> {
|
|||||||
|
|
||||||
double itemW = (1.sw - 15.w * 4) / 3;
|
double itemW = (1.sw - 15.w * 4) / 3;
|
||||||
double itemH = (1.sw - 15.w * 4) / 3 + 40.h;
|
double itemH = (1.sw - 15.w * 4) / 3 + 40.h;
|
||||||
|
|
||||||
Widget mainListView(int index, CloudStorageData itemData) {
|
Widget mainListView(int index, CloudStorageData itemData) {
|
||||||
return GridView.builder(
|
return GridView.builder(
|
||||||
padding: EdgeInsets.only(left: 15.w, right: 15.w),
|
padding: EdgeInsets.only(left: 15.w, right: 15.w),
|
||||||
@ -114,116 +117,322 @@ class _EditVideoLogPageState extends State<EditVideoLogPage> {
|
|||||||
childAspectRatio: itemW / itemH),
|
childAspectRatio: itemW / itemH),
|
||||||
itemBuilder: (BuildContext context, int index) {
|
itemBuilder: (BuildContext context, int index) {
|
||||||
final RecordListData recordData = itemData.recordList![index];
|
final RecordListData recordData = itemData.recordList![index];
|
||||||
return videoItem(recordData, index);
|
return videoItem(recordData);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget videoItem(RecordListData recordData, int index) {
|
// Widget videoItem(RecordListData recordData, int index) {
|
||||||
return Container(
|
// return Container(
|
||||||
width: itemW,
|
// width: itemW,
|
||||||
height: itemH,
|
// height: itemH,
|
||||||
color: Colors.white,
|
// color: Colors.white,
|
||||||
child: GestureDetector(
|
// child: GestureDetector(
|
||||||
onTap: () {
|
// onTap: () {
|
||||||
recordData.isSelect = !recordData.isSelect!;
|
// recordData.isSelect = !recordData.isSelect!;
|
||||||
if (recordData.isSelect! == true) {
|
// if (recordData.isSelect! == true) {
|
||||||
state.selectVideoLogList.add(recordData);
|
// state.selectVideoLogList.add(recordData);
|
||||||
} else {
|
// } else {
|
||||||
state.selectVideoLogList.remove(recordData);
|
// state.selectVideoLogList.remove(recordData);
|
||||||
}
|
// }
|
||||||
setState(() {});
|
// setState(() {});
|
||||||
},
|
// },
|
||||||
child: Stack(
|
// child: Stack(
|
||||||
children: <Widget>[
|
// children: <Widget>[
|
||||||
Column(
|
// Column(
|
||||||
children: <Widget>[
|
// children: <Widget>[
|
||||||
Container(
|
// Container(
|
||||||
width: itemW,
|
// width: itemW,
|
||||||
height: itemW,
|
// height: itemW,
|
||||||
margin: const EdgeInsets.all(0),
|
// margin: const EdgeInsets.all(0),
|
||||||
color: Colors.white,
|
// color: Colors.white,
|
||||||
child: ClipRRect(
|
// child: ClipRRect(
|
||||||
borderRadius: BorderRadius.circular(10.w),
|
// borderRadius: BorderRadius.circular(10.w),
|
||||||
child: Image(
|
// child: Image(
|
||||||
fit: BoxFit.cover,
|
// fit: BoxFit.cover,
|
||||||
image: Image.network(recordData.imagesUrl ??
|
// image: Image.network(recordData.imagesUrl ??
|
||||||
'images/icon_video_placeholder.jpg')
|
// 'images/icon_video_placeholder.jpg')
|
||||||
.image),
|
// .image),
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
SizedBox(height: 5.h),
|
// SizedBox(height: 5.h),
|
||||||
Text(
|
// Text(
|
||||||
DateTool()
|
// DateTool()
|
||||||
.dateToYMDHNString(recordData.operateDate.toString()),
|
// .dateToYMDHNString(recordData.operateDate.toString()),
|
||||||
textAlign: TextAlign.center,
|
// textAlign: TextAlign.center,
|
||||||
style: TextStyle(fontSize: 18.sp))
|
// style: TextStyle(fontSize: 18.sp))
|
||||||
],
|
// ],
|
||||||
),
|
// ),
|
||||||
Positioned(
|
// Positioned(
|
||||||
top: 0.w,
|
// top: 0.w,
|
||||||
right: 0.w,
|
// right: 0.w,
|
||||||
child: Image(
|
// child: Image(
|
||||||
width: 36.w,
|
// width: 36.w,
|
||||||
height: 36.w,
|
// height: 36.w,
|
||||||
image: state.selectVideoLogList.value.contains(recordData)
|
// image: state.selectVideoLogList.value.contains(recordData)
|
||||||
? const AssetImage('images/icon_round_select.png')
|
// ? const AssetImage('images/icon_round_select.png')
|
||||||
: const AssetImage('images/icon_round_unSelect.png')))
|
// : const AssetImage('images/icon_round_unSelect.png')))
|
||||||
],
|
// ],
|
||||||
)),
|
// )),
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
|
|
||||||
Widget bottomBottomBtnWidget() {
|
Widget bottomBottomBtnWidget() {
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
width: 1.sw,
|
width: 1.sw,
|
||||||
child: Row(mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[
|
child:
|
||||||
|
Row(mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[
|
||||||
bottomBtnItemWidget(
|
bottomBtnItemWidget(
|
||||||
'images/main/icon_lockDetail_monitoringDownloadVideo.png',
|
'images/main/icon_lockDetail_monitoringDownloadVideo.png',
|
||||||
'下载'.tr,
|
'下载'.tr,
|
||||||
Colors.white, () {
|
Colors.white,
|
||||||
if (state.selectVideoLogList.value.isNotEmpty) {
|
_onDownLoadClick,
|
||||||
Get.toNamed(Routers.videoLogDownLoadPage, arguments: <String, List<RecordListData>>{
|
),
|
||||||
'downloadVideoLogList': state.selectVideoLogList.value
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
logic.showToast('请选择要下载的视频');
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
SizedBox(width: 100.w),
|
SizedBox(width: 100.w),
|
||||||
bottomBtnItemWidget(
|
bottomBtnItemWidget(
|
||||||
'images/main/icon_lockDetail_monitoringDeletVideo.png',
|
'images/main/icon_lockDetail_monitoringDeletVideo.png',
|
||||||
'删除'.tr,
|
'删除'.tr,
|
||||||
AppColors.mainColor, () {
|
AppColors.mainColor,
|
||||||
if (state.selectVideoLogList.value.isNotEmpty) {
|
_onDelClick,
|
||||||
logic.deleteLockCloudStorageList();
|
)
|
||||||
} else {
|
|
||||||
logic.showToast('请选择要删除的视频'.tr);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> _onDownLoadClick() async {
|
||||||
|
if (state.selectVideoLogList.value.isNotEmpty) {
|
||||||
|
double _progress = 0.0;
|
||||||
|
// 开始下载
|
||||||
|
// 显示进度条
|
||||||
|
EasyLoading.showProgress(_progress, status: '加载数据中'.tr);
|
||||||
|
|
||||||
|
// 模拟进度更新
|
||||||
|
for (int i = 0; i <= state.selectVideoLogList.length - 1; i++) {
|
||||||
|
final item = state.selectVideoLogList.value[i];
|
||||||
|
|
||||||
|
// 判断 imagesUrl 是否为空
|
||||||
|
if (item.imagesUrl != null && item.imagesUrl!.isNotEmpty) {
|
||||||
|
await logic.downloadAndSaveToGallery(item.imagesUrl!, 'image_$i.jpg');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 判断 videoUrl 是否为空
|
||||||
|
if (item.videoUrl != null && item.videoUrl!.isNotEmpty) {
|
||||||
|
await logic.downloadAndSaveToGallery(item.videoUrl!, 'video_$i.mp4');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新进度
|
||||||
|
_progress = (i + 1) / state.selectVideoLogList.length;
|
||||||
|
EasyLoading.showProgress(_progress, status: '加载数据中'.tr);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加载完成后隐藏进度条
|
||||||
|
EasyLoading.dismiss();
|
||||||
|
EasyLoading.showSuccess('下载完成,请到相册查看'.tr);
|
||||||
|
state.selectVideoLogList.clear();
|
||||||
|
setState(() {});
|
||||||
|
// Get.toNamed(Routers.videoLogDownLoadPage,
|
||||||
|
// arguments: <String, List<RecordListData>>{
|
||||||
|
// 'downloadVideoLogList': state.selectVideoLogList.value
|
||||||
|
// });
|
||||||
|
} else {
|
||||||
|
logic.showToast('请选择要下载的视频');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _onDelClick() async {
|
||||||
|
if (state.selectVideoLogList.value.isNotEmpty) {
|
||||||
|
// 弹出自定义确认对话框
|
||||||
|
bool confirmDelete = await showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return Dialog(
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(16),
|
||||||
|
),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'确认删除'.tr,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 18,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(height: 16),
|
||||||
|
Text('确定要删除选中的视频吗?'.tr),
|
||||||
|
SizedBox(height: 24),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
// 用户点击取消,返回 false
|
||||||
|
Navigator.of(context).pop(false);
|
||||||
|
},
|
||||||
|
child: Text('取消'.tr),
|
||||||
|
),
|
||||||
|
SizedBox(width: 8),
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: () {
|
||||||
|
// 用户点击确认,返回 true
|
||||||
|
Navigator.of(context).pop(true);
|
||||||
|
},
|
||||||
|
child: Text('确认'.tr),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
// 如果用户确认删除,执行删除逻辑
|
||||||
|
if (confirmDelete == true) {
|
||||||
|
await logic.deleteLockCloudStorageList();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logic.showToast('请选择要删除的视频'.tr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Widget bottomBtnItemWidget(
|
Widget bottomBtnItemWidget(
|
||||||
String iconUrl, String name, Color backgroundColor, Function() onClick) {
|
String iconUrl,
|
||||||
|
String name,
|
||||||
|
Color backgroundColor,
|
||||||
|
Future<void> Function() onClick,
|
||||||
|
) {
|
||||||
final double wh = 40.w;
|
final double wh = 40.w;
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: onClick,
|
onTap: onClick,
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
height: 140.h,
|
height: 140.h,
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
SizedBox(height: 30.w),
|
SizedBox(height: 30.w),
|
||||||
Image.asset(iconUrl, width: wh, height: wh, fit: BoxFit.fitWidth),
|
Image.asset(iconUrl, width: wh, height: wh, fit: BoxFit.fitWidth),
|
||||||
SizedBox(height: 10.w),
|
SizedBox(height: 10.w),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text(name,
|
child: Text(name,
|
||||||
style: TextStyle(fontSize: 22.sp),
|
style: TextStyle(fontSize: 22.sp),
|
||||||
textAlign: TextAlign.center))
|
textAlign: TextAlign.center),
|
||||||
],
|
)
|
||||||
)),
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget videoItem(RecordListData recordData) {
|
||||||
|
return GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
if (recordData.videoUrl != null && recordData.videoUrl!.isNotEmpty) {
|
||||||
|
Get.toNamed(Routers.videoLogDetailPage, arguments: <String, Object>{
|
||||||
|
'recordData': recordData,
|
||||||
|
'videoDataList': state.videoLogList.value
|
||||||
|
});
|
||||||
|
} else if (recordData.imagesUrl != null &&
|
||||||
|
recordData.imagesUrl!.isNotEmpty) {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => FullScreenImagePage(
|
||||||
|
imageUrl: recordData.imagesUrl!,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: Stack(
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
width: itemW,
|
||||||
|
height: itemH,
|
||||||
|
child: Column(
|
||||||
|
children: <Widget>[
|
||||||
|
Container(
|
||||||
|
width: itemW,
|
||||||
|
height: itemW,
|
||||||
|
margin: const EdgeInsets.all(0),
|
||||||
|
color: Colors.white,
|
||||||
|
child: ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(10.w),
|
||||||
|
child: _buildImageOrVideoItem(recordData),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(height: 5.h),
|
||||||
|
Text(
|
||||||
|
DateTool()
|
||||||
|
.dateToYMDHNString(recordData.operateDate.toString()),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(fontSize: 18.sp),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Positioned(
|
||||||
|
top: 0.w,
|
||||||
|
right: 0.w,
|
||||||
|
child: GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
recordData.isSelect = !recordData.isSelect!;
|
||||||
|
if (recordData.isSelect! == true) {
|
||||||
|
state.selectVideoLogList.add(recordData);
|
||||||
|
} else {
|
||||||
|
state.selectVideoLogList.remove(recordData);
|
||||||
|
}
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
child: Image(
|
||||||
|
width: 36.w,
|
||||||
|
height: 36.w,
|
||||||
|
image: state.selectVideoLogList.value.contains(recordData)
|
||||||
|
? const AssetImage('images/icon_round_select.png')
|
||||||
|
: const AssetImage('images/icon_round_unSelect.png'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
_buildImageOrVideoItem(RecordListData recordData) {
|
||||||
|
if (recordData.videoUrl != null && recordData.videoUrl!.isNotEmpty) {
|
||||||
|
return _buildVideoItem(recordData);
|
||||||
|
} else {
|
||||||
|
return _buildImageItem(recordData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_buildVideoItem(RecordListData recordData) {
|
||||||
|
return VideoThumbnail(videoUrl: recordData.videoUrl!);
|
||||||
|
}
|
||||||
|
|
||||||
|
_buildImageItem(RecordListData recordData) {
|
||||||
|
return RotatedBox(
|
||||||
|
quarterTurns: -1,
|
||||||
|
child: Image.network(
|
||||||
|
recordData.imagesUrl!,
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
errorBuilder:
|
||||||
|
(BuildContext context, Object error, StackTrace? stackTrace) {
|
||||||
|
// 图片加载失败时显示错误图片
|
||||||
|
return RotatedBox(
|
||||||
|
quarterTurns: -1,
|
||||||
|
child: Image.asset(
|
||||||
|
'images/icon_unHaveData.png', // 错误图片路径
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +1,6 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
import 'dart:typed_data';
|
||||||
|
|
||||||
class VideoLogEntity {
|
class VideoLogEntity {
|
||||||
int? errorCode;
|
int? errorCode;
|
||||||
String? description;
|
String? description;
|
||||||
@ -61,21 +64,28 @@ class RecordListData {
|
|||||||
int? operateDate;
|
int? operateDate;
|
||||||
String? imagesUrl;
|
String? imagesUrl;
|
||||||
String? videoUrl;
|
String? videoUrl;
|
||||||
|
Uint8List? thumbnailData; // 将视频封面改为 Uint8List 类型
|
||||||
int? recordType;
|
int? recordType;
|
||||||
bool? isSelect = false;
|
bool? isSelect = false;
|
||||||
|
|
||||||
RecordListData(
|
RecordListData({
|
||||||
{this.recordId,
|
this.recordId,
|
||||||
this.operateDate,
|
this.operateDate,
|
||||||
this.imagesUrl,
|
this.imagesUrl,
|
||||||
this.videoUrl,
|
this.videoUrl,
|
||||||
this.recordType});
|
this.thumbnailData, // 视频封面数据
|
||||||
|
this.recordType,
|
||||||
|
});
|
||||||
|
|
||||||
RecordListData.fromJson(Map<String, dynamic> json) {
|
RecordListData.fromJson(Map<String, dynamic> json) {
|
||||||
recordId = json['recordId'];
|
recordId = json['recordId'];
|
||||||
operateDate = json['operateDate'];
|
operateDate = json['operateDate'];
|
||||||
imagesUrl = json['imagesUrl'];
|
imagesUrl = json['imagesUrl'];
|
||||||
videoUrl = json['videoUrl'];
|
videoUrl = json['videoUrl'];
|
||||||
|
// 如果 JSON 中包含 base64 编码的图片数据,可以解码为 Uint8List
|
||||||
|
if (json['thumbnailData'] != null) {
|
||||||
|
thumbnailData = base64Decode(json['thumbnailData']);
|
||||||
|
}
|
||||||
recordType = json['recordType'];
|
recordType = json['recordType'];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,6 +95,10 @@ class RecordListData {
|
|||||||
data['operateDate'] = operateDate;
|
data['operateDate'] = operateDate;
|
||||||
data['imagesUrl'] = imagesUrl;
|
data['imagesUrl'] = imagesUrl;
|
||||||
data['videoUrl'] = videoUrl;
|
data['videoUrl'] = videoUrl;
|
||||||
|
// 将 Uint8List 编码为 base64 字符串
|
||||||
|
if (thumbnailData != null) {
|
||||||
|
data['thumbnailData'] = base64Encode(thumbnailData!);
|
||||||
|
}
|
||||||
data['recordType'] = recordType;
|
data['recordType'] = recordType;
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
|
|
||||||
|
import 'package:star_lock/main/lockDetail/videoLog/videoLog/videoLog_entity.dart';
|
||||||
import 'package:star_lock/network/api_repository.dart';
|
import 'package:star_lock/network/api_repository.dart';
|
||||||
import 'package:star_lock/tools/baseGetXController.dart';
|
import 'package:star_lock/tools/baseGetXController.dart';
|
||||||
|
|
||||||
@ -14,19 +15,45 @@ class VideoLogLogic extends BaseGetXController {
|
|||||||
);
|
);
|
||||||
if (entity.errorCode!.codeIsSuccessful) {
|
if (entity.errorCode!.codeIsSuccessful) {
|
||||||
state.videoLogList.value = entity.data!;
|
state.videoLogList.value = entity.data!;
|
||||||
// state.videoLogList.value.forEach((element) {
|
state.videoLogList.value.forEach((element) {
|
||||||
// // 过滤掉 imagesUrl 和 videoUrl 都为 null 或空字符串的项
|
// 过滤掉 imagesUrl 和 videoUrl 都为 null 或空字符串的项
|
||||||
// element.recordList = element.recordList!
|
element.recordList = element.recordList!
|
||||||
// .where((record) =>
|
.where((record) =>
|
||||||
// (record.imagesUrl != null && record.imagesUrl!.isNotEmpty) ||
|
(record.imagesUrl != null && record.imagesUrl!.isNotEmpty) ||
|
||||||
// (record.videoUrl != null && record.videoUrl!.isNotEmpty))
|
(record.videoUrl != null && record.videoUrl!.isNotEmpty))
|
||||||
// .toList();
|
.toList();
|
||||||
// });
|
|
||||||
|
// // 为 videoUrl 不为空的项设置封面
|
||||||
|
// for (var record in element.recordList!) {
|
||||||
|
// if (record.videoUrl != null && record.videoUrl!.isNotEmpty) {
|
||||||
|
// _setVideoThumbnail(record); // 设置视频封面
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
});
|
||||||
|
|
||||||
state.videoLogList.refresh();
|
state.videoLogList.refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Future<void> _setVideoThumbnail(RecordListData record) async {
|
||||||
|
// try {
|
||||||
|
// final thumbnailData = await getVideoThumbnail(record.videoUrl!);
|
||||||
|
// record.thumbnailData = thumbnailData; // 设置视频封面数据
|
||||||
|
// } catch (e) {
|
||||||
|
// print('获取视频封面失败: $e');
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Future<Uint8List?> getVideoThumbnail(String videoUrl) async {
|
||||||
|
// final thumbnail = await VideoThumbnail.thumbnailData(
|
||||||
|
// video: videoUrl,
|
||||||
|
// imageFormat: ImageFormat.JPEG,
|
||||||
|
// maxWidth: 128, // 缩略图的最大宽度
|
||||||
|
// quality: 25, // 缩略图的质量(0-100)
|
||||||
|
// );
|
||||||
|
// return thumbnail;
|
||||||
|
// }
|
||||||
|
|
||||||
@override
|
@override
|
||||||
onReady() {
|
onReady() {
|
||||||
super.onReady();
|
super.onReady();
|
||||||
|
|||||||
@ -228,15 +228,18 @@ class _VideoLogPageState extends State<VideoLogPage> {
|
|||||||
child: Row(
|
child: Row(
|
||||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Text(state.isNavLocal.value == true ? '已下载'.tr : '全部视频'.tr,
|
Text(
|
||||||
style: TextStyle(fontSize: 26.sp, fontWeight: FontWeight.w500)),
|
state.isNavLocal.value == true ? '已下载'.tr : '全部视频'.tr,
|
||||||
|
style: TextStyle(fontSize: 26.sp, fontWeight: FontWeight.w500),
|
||||||
|
),
|
||||||
Expanded(child: SizedBox(width: 10.w)),
|
Expanded(child: SizedBox(width: 10.w)),
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: Image(
|
icon: Image(
|
||||||
width: 40.w,
|
width: 40.w,
|
||||||
height: 40.w,
|
height: 40.w,
|
||||||
image: const AssetImage(
|
image: const AssetImage(
|
||||||
'images/main/icon_lockDetail_monitoringEditVoice.png')),
|
'images/main/icon_lockDetail_monitoringEditVoice.png'),
|
||||||
|
),
|
||||||
iconSize: 30,
|
iconSize: 30,
|
||||||
color: Colors.black54,
|
color: Colors.black54,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
@ -342,17 +345,23 @@ class _VideoLogPageState extends State<VideoLogPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_buildImageItem(RecordListData recordData) {
|
_buildImageItem(RecordListData recordData) {
|
||||||
return Image.network(
|
return RotatedBox(
|
||||||
recordData.imagesUrl!,
|
quarterTurns: -1,
|
||||||
fit: BoxFit.cover,
|
child: Image.network(
|
||||||
errorBuilder:
|
recordData.imagesUrl!,
|
||||||
(BuildContext context, Object error, StackTrace? stackTrace) {
|
fit: BoxFit.cover,
|
||||||
// 图片加载失败时显示错误图片
|
errorBuilder:
|
||||||
return Image.asset(
|
(BuildContext context, Object error, StackTrace? stackTrace) {
|
||||||
'images/icon_unHaveData.png', // 错误图片路径
|
// 图片加载失败时显示错误图片
|
||||||
fit: BoxFit.cover,
|
return RotatedBox(
|
||||||
);
|
quarterTurns: -1,
|
||||||
},
|
child: Image.asset(
|
||||||
|
'images/icon_unHaveData.png', // 错误图片路径
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -148,9 +148,10 @@ class _ControlsOverlayState extends State<ControlsOverlay> {
|
|||||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
DateTool().dateToYMDHNString(
|
DateTool().dateToYMDHNString(
|
||||||
widget.recordData.operateDate.toString()),
|
widget.recordData.operateDate.toString()),
|
||||||
style: TextStyle(color: Colors.white, fontSize: 20.sp)),
|
style: TextStyle(color: Colors.white, fontSize: 20.sp),
|
||||||
|
),
|
||||||
// Expanded(child: SizedBox(width: 10.w)),
|
// Expanded(child: SizedBox(width: 10.w)),
|
||||||
// Container(
|
// Container(
|
||||||
// width: 50.w,
|
// width: 50.w,
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/rendering.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
@ -72,37 +73,35 @@ class _VideoLogDetailPageState extends State<VideoLogDetailPage> {
|
|||||||
? Column(
|
? Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Container(
|
Container(
|
||||||
|
color: Colors.black,
|
||||||
height: 500.h,
|
height: 500.h,
|
||||||
decoration: BoxDecoration(color: Colors.black),
|
width: 1.sw,
|
||||||
child: AspectRatio(
|
child: Stack(
|
||||||
aspectRatio: 16 / 9,
|
alignment: Alignment.bottomCenter,
|
||||||
child: Stack(
|
children: <Widget>[
|
||||||
alignment: Alignment.bottomCenter,
|
RotatedBox(
|
||||||
children: <Widget>[
|
quarterTurns: -1,
|
||||||
FittedBox(
|
child: AspectRatio(
|
||||||
child: SizedBox(
|
aspectRatio: state.videoController.value.size.width /
|
||||||
width: state.videoController.value.size.width,
|
state.videoController.value.size.height,
|
||||||
height: state.videoController.value.size.height,
|
child: VideoPlayer(state.videoController),
|
||||||
child: VideoPlayer(state.videoController),
|
|
||||||
),
|
|
||||||
fit: BoxFit.cover,
|
|
||||||
),
|
),
|
||||||
ControlsOverlay(
|
),
|
||||||
controller: state.videoController,
|
ControlsOverlay(
|
||||||
recordData: state.recordData.value,
|
controller: state.videoController,
|
||||||
|
recordData: state.recordData.value,
|
||||||
|
),
|
||||||
|
if (state.videoController.value.isPlaying ||
|
||||||
|
state.videoController.value.isBuffering)
|
||||||
|
Container()
|
||||||
|
else
|
||||||
|
VideoProgressIndicator(
|
||||||
|
state.videoController,
|
||||||
|
colors: VideoProgressColors(
|
||||||
|
playedColor: AppColors.mainColor),
|
||||||
|
allowScrubbing: true,
|
||||||
),
|
),
|
||||||
if (state.videoController.value.isPlaying ||
|
],
|
||||||
state.videoController.value.isBuffering)
|
|
||||||
Container()
|
|
||||||
else
|
|
||||||
VideoProgressIndicator(
|
|
||||||
state.videoController,
|
|
||||||
colors: VideoProgressColors(
|
|
||||||
playedColor: AppColors.mainColor),
|
|
||||||
allowScrubbing: true,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
_buildOther(),
|
_buildOther(),
|
||||||
@ -170,9 +169,23 @@ class _VideoLogDetailPageState extends State<VideoLogDetailPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_buildImageItem(RecordListData recordData) {
|
_buildImageItem(RecordListData recordData) {
|
||||||
return Image.network(
|
return RotatedBox(
|
||||||
recordData.imagesUrl!,
|
quarterTurns: 1,
|
||||||
fit: BoxFit.cover,
|
child: Image.network(
|
||||||
|
recordData.imagesUrl!,
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
errorBuilder:
|
||||||
|
(BuildContext context, Object error, StackTrace? stackTrace) {
|
||||||
|
// 图片加载失败时显示错误图片
|
||||||
|
return RotatedBox(
|
||||||
|
quarterTurns: -1,
|
||||||
|
child: Image.asset(
|
||||||
|
'images/icon_unHaveData.png', // 错误图片路径
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -10,9 +10,17 @@ class FullScreenImagePage extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
body: Container(
|
body: GestureDetector(
|
||||||
child: PhotoView(
|
onTap: (){
|
||||||
imageProvider: NetworkImage(imageUrl),
|
Navigator.pop(context); // 点击图片返回
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
child: RotatedBox(
|
||||||
|
quarterTurns: -1,
|
||||||
|
child: PhotoView(
|
||||||
|
imageProvider: NetworkImage(imageUrl),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@ -49,14 +49,17 @@ class _VideoThumbnailState extends State<VideoThumbnail> {
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
// 如果视频已经初始化,则显示视频玩家
|
// 如果视频已经初始化,则显示视频玩家
|
||||||
_controller.value.isInitialized
|
_controller.value.isInitialized
|
||||||
? AspectRatio(
|
? RotatedBox(
|
||||||
aspectRatio: 1 / 1, // 强制正方形比例
|
quarterTurns: -1,
|
||||||
child: FittedBox(
|
child: AspectRatio(
|
||||||
fit: BoxFit.cover, // 确保视频封面铺满空间
|
aspectRatio: 1 / 1, // 强制正方形比例
|
||||||
child: SizedBox(
|
child: FittedBox(
|
||||||
width: _controller.value.size.width,
|
fit: BoxFit.cover, // 确保视频封面铺满空间
|
||||||
height: _controller.value.size.height,
|
child: SizedBox(
|
||||||
child: VideoPlayer(_controller),
|
width: _controller.value.size.width,
|
||||||
|
height: _controller.value.size.height,
|
||||||
|
child: VideoPlayer(_controller),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user