fix:调整云存页面内容

This commit is contained in:
liyi 2025-08-20 10:06:03 +08:00
parent 9fdf8377ee
commit 026e06a79f
6 changed files with 659 additions and 361 deletions

View File

@ -145,9 +145,9 @@ class EditVideoLogLogic extends BaseGetXController {
} }
// URL生成唯一的文件名MD5哈希值 // URL生成唯一的文件名MD5哈希值
String getFileNameFromUrl(String url, String extension) { String getFileNameFromUrl(String url, String extension, int recordType) {
final hash = md5.convert(utf8.encode(url)).toString(); // 使 md5 final hash = md5.convert(utf8.encode(url)).toString(); // 使 md5
return '$hash.$extension'; return '$recordType' + '_' + '$hash.$extension';
} }
Future<void> recordDownloadTime(String filePath) async { Future<void> recordDownloadTime(String filePath) async {
@ -169,7 +169,7 @@ class EditVideoLogLogic extends BaseGetXController {
} }
// //
Future<String?> downloadFile(String? url) async { Future<String?> downloadFile(String? url, int recordType) async {
if (url == null || url.isEmpty) { if (url == null || url.isEmpty) {
print('URL不能为空'); print('URL不能为空');
return null; return null;
@ -183,7 +183,8 @@ class EditVideoLogLogic extends BaseGetXController {
// URL生成唯一文件名 // URL生成唯一文件名
String extension = _getFileTypeFromUrl(url); // String extension = _getFileTypeFromUrl(url); //
String fileName = getFileNameFromUrl(url, extension); // URL生成唯一文件名 String fileName =
getFileNameFromUrl(url, extension, recordType); // URL生成唯一文件名
String savePath = '${appDocDir.path}/downloads/$fileName'; // String savePath = '${appDocDir.path}/downloads/$fileName'; //
// //

View File

@ -76,23 +76,31 @@ class _EditVideoLogPageState extends State<EditVideoLogPage> {
body: Column( body: Column(
children: <Widget>[ children: <Widget>[
Expanded( Expanded(
child: Obx(() => ListView.builder( child: Obx(
() => ListView.builder(
itemCount: state.videoLogList.length, itemCount: state.videoLogList.length,
itemBuilder: (BuildContext c, int index) { itemBuilder: (BuildContext c, int index) {
final CloudStorageData item = state.videoLogList[index]; final CloudStorageData item = state.videoLogList[index];
return Column( return ExpansionTile(
children: <Widget>[ shape: Border(),
Container( collapsedShape: Border(),
margin: EdgeInsets.only( expansionAnimationStyle: AnimationStyle(
left: 20.w, top: 15.w, bottom: 15.w), curve: Curves.easeInOut,
child: Row(children: <Widget>[ duration: Duration(milliseconds: 400),
Text(item.date ?? '', ),
style: TextStyle(fontSize: 20.sp)), initiallyExpanded: true,
])), title: Text(
mainListView(index, item) item.date ?? '',
], style: TextStyle(
fontSize: 24.sp,
fontWeight: FontWeight.w600,
),
),
children: mainListView(index, item),
); );
})), },
),
),
), ),
bottomBottomBtnWidget() bottomBottomBtnWidget()
], ],
@ -100,29 +108,35 @@ class _EditVideoLogPageState extends State<EditVideoLogPage> {
); );
} }
Widget _buildNotData() {
return Expanded(
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Image.asset(
'images/icon_noData.png',
width: 160.w,
height: 180.h,
),
Text(
'暂无数据'.tr,
style: TextStyle(
color: AppColors.darkGrayTextColor, fontSize: 22.sp),
)
],
),
),
);
}
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) { //
return GridView.builder( List<Widget> mainListView(int index, CloudStorageData itemData) {
padding: EdgeInsets.only(left: 15.w, right: 15.w), return itemData.recordList!.map((e) => videoItem(e)).toList();
itemCount: itemData.recordList!.length,
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
//
crossAxisCount: 3,
//
mainAxisSpacing: 10.w,
//
crossAxisSpacing: 15.w,
//
childAspectRatio: itemW / itemH),
itemBuilder: (BuildContext context, int index) {
final RecordListData recordData = itemData.recordList![index];
return videoItem(recordData);
},
);
} }
// Widget videoItem(RecordListData recordData, int index) { // Widget videoItem(RecordListData recordData, int index) {
@ -237,9 +251,9 @@ class _EditVideoLogPageState extends State<EditVideoLogPage> {
if (state.selectVideoLogList.value.isNotEmpty) { if (state.selectVideoLogList.value.isNotEmpty) {
state.selectVideoLogList.value.forEach((element) { state.selectVideoLogList.value.forEach((element) {
if (element.videoUrl != null && element.videoUrl != '') { if (element.videoUrl != null && element.videoUrl != '') {
logic.downloadFile(element.videoUrl ?? ''); logic.downloadFile(element.videoUrl ?? '', element.recordType!);
} else if (element.imagesUrl != null && element.imagesUrl != '') { } else if (element.imagesUrl != null && element.imagesUrl != '') {
logic.downloadFile(element.imagesUrl ?? ''); logic.downloadFile(element.imagesUrl ?? '', element.recordType!);
} }
}); });
// double _progress = 0.0; // double _progress = 0.0;
@ -339,77 +353,154 @@ class _EditVideoLogPageState extends State<EditVideoLogPage> {
Widget videoItem(RecordListData recordData) { Widget videoItem(RecordListData recordData) {
return GestureDetector( return GestureDetector(
onTap: () { onTap: () {
if (recordData.videoUrl != null && recordData.videoUrl!.isNotEmpty) { recordData.isSelect = !recordData.isSelect!;
Get.toNamed(Routers.videoLogDetailPage, arguments: <String, Object>{ if (recordData.isSelect! == true) {
'recordData': recordData, state.selectVideoLogList.add(recordData);
'videoDataList': state.videoLogList.value } else {
}); state.selectVideoLogList.remove(recordData);
} else if (recordData.imagesUrl != null &&
recordData.imagesUrl!.isNotEmpty) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => FullScreenImagePage(
imageUrl: recordData.imagesUrl!,
),
),
);
} }
setState(() {});
}, },
child: Stack( child: Container(
children: [ padding: EdgeInsets.symmetric(horizontal: 20.w),
SizedBox( margin: EdgeInsets.only(
width: itemW, bottom: 20.h,
height: itemH, left: 18.w,
child: Column( right: 18.w,
children: <Widget>[ ),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10.w),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.2),
spreadRadius: 1,
blurRadius: 5,
offset: const Offset(0, 3), // changes position of shadow
),
],
),
width: 1.sw,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Row(
children: [
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'),
),
SizedBox(
width: 14.w,
),
Container( Container(
width: itemW, padding: EdgeInsets.all(10.w),
height: itemW, decoration: BoxDecoration(
margin: const EdgeInsets.all(0), borderRadius: BorderRadius.circular(58.w),
color: Colors.white, color: AppColors.mainColor,
child: ClipRRect( ),
borderRadius: BorderRadius.circular(10.w), child: Icon(
child: _buildImageOrVideoItem(recordData), _buildIconByType(recordData),
size: 48.sp,
color: Colors.white,
),
),
SizedBox(
width: 14.w,
),
Container(
height: itemW,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
_buildTitleByType(recordData),
style: TextStyle(
fontSize: 24.sp,
fontWeight: FontWeight.w600,
),
),
SizedBox(
height: 8.h,
),
Text(
DateTool()
.dateToHNString(recordData.operateDate.toString()),
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 20.sp,
fontWeight: FontWeight.w600,
),
),
],
), ),
), ),
SizedBox(height: 5.h),
Text(
DateTool()
.dateToYMDHNString(recordData.operateDate.toString()),
textAlign: TextAlign.center,
style: TextStyle(fontSize: 18.sp),
)
], ],
), ),
), Container(
Positioned( width: 118.w,
top: 0.w, height: 118.w,
right: 0.w, margin: const EdgeInsets.all(0),
child: GestureDetector( color: Colors.white,
onTap: () { child: ClipRRect(
recordData.isSelect = !recordData.isSelect!; borderRadius: BorderRadius.circular(10.w),
if (recordData.isSelect! == true) { child: _buildImageOrVideoItem(recordData),
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'),
), ),
), ),
) ],
], ),
), ),
); );
} }
String _buildTitleByType(RecordListData item) {
final recordType = item.recordType;
switch (recordType) {
case 130:
return '防拆报警'.tr;
case 160:
return '人脸'.tr + '开锁'.tr;
case 220:
return '逗留警告'.tr;
default:
return '';
}
}
IconData _buildIconByType(RecordListData item) {
final recordType = item.recordType;
switch (recordType) {
case 130:
return Icons.fmd_bad_outlined;
case 160:
return Icons.tag_faces_outlined;
case 220:
return Icons.wifi_tethering_error_rounded_outlined;
default:
return Icons.priority_high_rounded;
}
}
Color _buildTextColorByType(RecordListData item) {
final recordType = item.recordType;
switch (recordType) {
case 120:
case 150:
case 130:
case 190:
case 200:
case 210:
case 220:
return Colors.red;
default:
return Colors.black;
}
}
_buildImageOrVideoItem(RecordListData recordData) { _buildImageOrVideoItem(RecordListData recordData) {
if (recordData.videoUrl != null && recordData.videoUrl!.isNotEmpty) { if (recordData.videoUrl != null && recordData.videoUrl!.isNotEmpty) {
return _buildVideoItem(recordData); return _buildVideoItem(recordData);

View File

@ -1,7 +1,7 @@
import 'dart:convert'; import 'dart:convert';
import 'dart:io'; import 'dart:io';
import 'dart:typed_data';
import 'package:crypto/crypto.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:path_provider/path_provider.dart'; import 'package:path_provider/path_provider.dart';
import 'package:star_lock/appRouters.dart'; import 'package:star_lock/appRouters.dart';
@ -63,8 +63,17 @@ class VideoLogLogic extends BaseGetXController {
final content = await File(logFilePath).readAsString(); final content = await File(logFilePath).readAsString();
final logData = Map<String, int>.from(json.decode(content)); final logData = Map<String, int>.from(json.decode(content));
//
logData.forEach((filePath, timestamp) { logData.forEach((filePath, timestamp) {
String fileName = filePath
.split('/')
.last; // : 220_f5e371111918ff70cb3532bec20e38c4.mp4
String withoutExt = fileName.replaceAll('.mp4', ''); // 使 substring
String numberStr = withoutExt.split('_').first; // : 220
int number = int.parse(numberStr);
print(number); // : 220
final downloadDateTime = DateTime.fromMillisecondsSinceEpoch(timestamp); final downloadDateTime = DateTime.fromMillisecondsSinceEpoch(timestamp);
final dateKey = final dateKey =
'${downloadDateTime.year}-${downloadDateTime.month.toString().padLeft(2, '0')}-${downloadDateTime.day.toString().padLeft(2, '0')}'; '${downloadDateTime.year}-${downloadDateTime.month.toString().padLeft(2, '0')}-${downloadDateTime.day.toString().padLeft(2, '0')}';
@ -77,11 +86,15 @@ class VideoLogLogic extends BaseGetXController {
// //
if (filePath.endsWith('.jpg')) { if (filePath.endsWith('.jpg')) {
groupedDownloads[dateKey]?.add( groupedDownloads[dateKey]?.add(
RecordListData(operateDate: timestamp, imagesUrl: filePath), RecordListData(
operateDate: timestamp,
imagesUrl: filePath,
recordType: number),
); );
} else if (filePath.endsWith('.mp4')) { } else if (filePath.endsWith('.mp4')) {
groupedDownloads[dateKey]?.add( groupedDownloads[dateKey]?.add(
RecordListData(operateDate: timestamp, videoUrl: filePath), RecordListData(
operateDate: timestamp, videoUrl: filePath, recordType: number),
); );
} }
}); });

View File

@ -4,6 +4,7 @@ import 'package:flutter/material.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/app_settings/app_settings.dart';
import 'package:star_lock/flavors.dart'; import 'package:star_lock/flavors.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/videoLog/videoLog_state.dart'; import 'package:star_lock/main/lockDetail/videoLog/videoLog/videoLog_state.dart';
@ -26,9 +27,7 @@ class VideoLogPage extends StatefulWidget {
class _VideoLogPageState extends State<VideoLogPage> { class _VideoLogPageState extends State<VideoLogPage> {
final VideoLogLogic logic = Get.put(VideoLogLogic()); final VideoLogLogic logic = Get.put(VideoLogLogic());
final VideoLogState state = Get final VideoLogState state = Get.find<VideoLogLogic>().state;
.find<VideoLogLogic>()
.state;
@override @override
void initState() { void initState() {
@ -56,66 +55,71 @@ class _VideoLogPageState extends State<VideoLogPage> {
// title加编辑按钮 // title加编辑按钮
editVideoTip(), editVideoTip(),
Obx( Obx(
() => () => Visibility(
Visibility( visible: !state.isNavLocal.value,
visible: !state.isNavLocal.value, child: state.videoLogList.length > 0
child: state.videoLogList.length > 0 ? Expanded(
? Expanded( child: ListView.builder(
child: ListView.builder( itemCount: state.videoLogList.length,
itemCount: state.videoLogList.length, itemBuilder: (BuildContext c, int index) {
itemBuilder: (BuildContext c, int index) { final CloudStorageData item =
final CloudStorageData item = state.videoLogList[index];
state.videoLogList[index]; return ExpansionTile(
return Column( shape: Border(),
children: <Widget>[ collapsedShape: Border(),
Container( expansionAnimationStyle: AnimationStyle(
margin: EdgeInsets.only( curve: Curves.easeInOut,
left: 20.w, top: 15.w, bottom: 15.w), duration: Duration(milliseconds: 400),
child: Row(children: <Widget>[ ),
Text(item.date ?? '', initiallyExpanded: true,
style: TextStyle(fontSize: 20.sp)), title: Text(
])), item.date ?? '',
mainListView(index, item) style: TextStyle(
], fontSize: 24.sp,
); fontWeight: FontWeight.w600,
}, ),
), ),
) children: mainListView(index, item),
: _buildNotData(), );
), },
),
)
: _buildNotData(),
),
), ),
// //
Obx( Obx(
() => () => Visibility(
Visibility( visible: state.isNavLocal.value,
visible: state.isNavLocal.value, child: state.lockVideoList.length > 0
child: state.lockVideoList.length > 0 ? Expanded(
? Expanded( child: ListView.builder(
child: ListView.builder( itemCount: state.lockVideoList.length,
itemCount: state.lockVideoList.length, itemBuilder: (BuildContext c, int index) {
itemBuilder: (BuildContext c, int index) { final CloudStorageData item =
final CloudStorageData item = state.lockVideoList[index];
state.lockVideoList[index]; return ExpansionTile(
return Column( shape: Border(),
children: <Widget>[ collapsedShape: Border(),
Container( expansionAnimationStyle: AnimationStyle(
margin: EdgeInsets.only( curve: Curves.easeInOut,
left: 20.w, top: 15.w, bottom: 15.w), duration: Duration(milliseconds: 400),
child: Row( ),
children: <Widget>[ initiallyExpanded: true,
Text(item.date ?? '', title: Text(
style: TextStyle(fontSize: 20.sp)), item.date ?? '',
], style: TextStyle(
fontSize: 24.sp,
fontWeight: FontWeight.w600,
), ),
), ),
lockMainListView(index, item) children: mainListView(index, item),
], );
); },
}, ),
), )
) : _buildNotData(),
: _buildNotData(), ),
),
), ),
], ],
), ),
@ -154,24 +158,28 @@ class _VideoLogPageState extends State<VideoLogPage> {
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[ children: <Widget>[
TextButton( TextButton(
onPressed: () { onPressed: () {
setState(() { setState(() {
state.isNavLocal.value = false; state.isNavLocal.value = false;
state.lockVideoList.clear(); state.lockVideoList.clear();
// logic.clearDownloads(); // logic.clearDownloads();
}); });
}, },
child: Obx(() => child: Obx(
Text('云存'.tr, () => Text(
style: state.isNavLocal.value == true '云存'.tr,
? TextStyle( style: state.isNavLocal.value == true
color: Colors.grey, ? TextStyle(
fontSize: 26.sp, color: Colors.grey,
fontWeight: FontWeight.w600) fontSize: 26.sp,
: TextStyle( fontWeight: FontWeight.w600)
color: Colors.white, : TextStyle(
fontSize: 28.sp, color: Colors.white,
fontWeight: FontWeight.w600)))), fontSize: 28.sp,
fontWeight: FontWeight.w600),
),
),
),
TextButton( TextButton(
onPressed: () { onPressed: () {
setState(() { setState(() {
@ -180,19 +188,18 @@ class _VideoLogPageState extends State<VideoLogPage> {
}); });
}, },
child: Obx( child: Obx(
() => () => Text(
Text( '已下载'.tr,
'已下载'.tr, style: state.isNavLocal.value == true
style: state.isNavLocal.value == true ? TextStyle(
? TextStyle(
color: Colors.white, color: Colors.white,
fontSize: 28.sp, fontSize: 28.sp,
fontWeight: FontWeight.w600) fontWeight: FontWeight.w600)
: TextStyle( : TextStyle(
color: Colors.grey, color: Colors.grey,
fontSize: 26.sp, fontSize: 26.sp,
fontWeight: FontWeight.w600), fontWeight: FontWeight.w600),
), ),
), ),
), ),
], ],
@ -212,93 +219,88 @@ class _VideoLogPageState extends State<VideoLogPage> {
// height: 150.h, // height: 150.h,
margin: EdgeInsets.all(15.w), margin: EdgeInsets.all(15.w),
padding: padding:
EdgeInsets.only(left: 20.w, top: 20.w, bottom: 20.w, right: 10.w), EdgeInsets.only(left: 20.w, top: 20.w, bottom: 20.w, right: 10.w),
decoration: BoxDecoration( decoration: BoxDecoration(
color: const Color(0xFFF6F7F8), color: const Color(0xFFF6F7F8),
borderRadius: BorderRadius.circular(20.h)), borderRadius: BorderRadius.circular(
20.h,
),
),
child: Obx( child: Obx(
() => () => Column(
Column( crossAxisAlignment: CrossAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, children: [
children: [ Row(
Row( children: <Widget>[
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Expanded( Text('3天滚动储存'.tr, style: TextStyle(fontSize: 24.sp)),
child: Column( SizedBox(height: 10.h),
crossAxisAlignment: CrossAxisAlignment.start, Text("${F.navTitle}${"已为本设备免费提供3大滚动视频储存服务".tr}",
children: <Widget>[ style:
Text('3天滚动储存'.tr, TextStyle(fontSize: 22.sp, color: Colors.grey)),
style: TextStyle(fontSize: 24.sp)),
SizedBox(height: 10.h),
Text("${F
.navTitle}${"已为本设备免费提供3大滚动视频储存服务"
.tr}",
style:
TextStyle(fontSize: 22.sp, color: Colors
.grey)),
],
)),
SizedBox(width: 15.w),
Text('去升级'.tr, style: TextStyle(fontSize: 22.sp)),
Image(
width: 40.w,
height: 24.w,
image: const AssetImage(
'images/icon_right_black.png'))
], ],
), )),
SizedBox( SizedBox(width: 15.w),
height: 16.h, Text('去升级'.tr, style: TextStyle(fontSize: 22.sp)),
), Image(
Text( width: 40.w,
'云存服务状态:${_handlerValidityPeriodStatsText()}', height: 24.w,
style: TextStyle( image: const AssetImage('images/icon_right_black.png'))
fontSize: 24.sp,
),
),
SizedBox(
height: 8.h,
),
Visibility(
visible: state.validityPeriodInfo.value != null &&
state.validityPeriodInfo.value?.status == 1,
child: Text(
'过期时间:${state.validityPeriodInfo.value
?.validityPeriodEnd}',
style: TextStyle(
fontSize: 24.sp,
),
),
),
SizedBox(
height: 8.h,
),
Visibility(
visible: state.validityPeriodInfo.value != null &&
state.validityPeriodInfo.value?.status == 1,
child: Text(
'滚动存储天数:${state.validityPeriodInfo.value?.rollingStorageDays}',
style: TextStyle(
fontSize: 24.sp,
),
),
),
SizedBox(
height: 8.h,
),
Visibility(
visible: state.validityPeriodInfo.value != null &&
state.validityPeriodInfo.value?.status == 1,
child: Text(
'剩余天数:${state.validityPeriodInfo.value
?.remainingDays} ',
style: TextStyle(
fontSize: 24.sp,
),
),
),
], ],
), ),
SizedBox(
height: 16.h,
),
Text(
'云存服务状态:${_handlerValidityPeriodStatsText()}',
style: TextStyle(
fontSize: 24.sp,
),
),
SizedBox(
height: 8.h,
),
Visibility(
visible: state.validityPeriodInfo.value != null &&
state.validityPeriodInfo.value?.status == 1,
child: Text(
'过期时间:${state.validityPeriodInfo.value?.validityPeriodEnd}',
style: TextStyle(
fontSize: 24.sp,
),
),
),
SizedBox(
height: 8.h,
),
Visibility(
visible: state.validityPeriodInfo.value != null &&
state.validityPeriodInfo.value?.status == 1,
child: Text(
'滚动存储天数:${state.validityPeriodInfo.value?.rollingStorageDays}',
style: TextStyle(
fontSize: 24.sp,
),
),
),
SizedBox(
height: 8.h,
),
Visibility(
visible: state.validityPeriodInfo.value != null &&
state.validityPeriodInfo.value?.status == 1,
child: Text(
'剩余天数:${state.validityPeriodInfo.value?.remainingDays}',
style: TextStyle(
fontSize: 24.sp,
),
),
),
],
),
), ),
), ),
); );
@ -329,7 +331,7 @@ class _VideoLogPageState extends State<VideoLogPage> {
// height: 130.h, // height: 130.h,
margin: EdgeInsets.all(15.w), margin: EdgeInsets.all(15.w),
padding: padding:
EdgeInsets.only(left: 20.w, top: 30.w, bottom: 30.w, right: 10.w), EdgeInsets.only(left: 20.w, top: 30.w, bottom: 30.w, right: 10.w),
decoration: BoxDecoration( decoration: BoxDecoration(
color: const Color(0xFFF6F7F8), color: const Color(0xFFF6F7F8),
borderRadius: BorderRadius.circular(20.h)), borderRadius: BorderRadius.circular(20.h)),
@ -337,15 +339,15 @@ class _VideoLogPageState extends State<VideoLogPage> {
children: <Widget>[ children: <Widget>[
Expanded( Expanded(
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
// SizedBox(height: 20.h), // SizedBox(height: 20.h),
Text('下载列表'.tr, style: TextStyle(fontSize: 24.sp)), Text('下载列表'.tr, style: TextStyle(fontSize: 24.sp)),
SizedBox(height: 15.h), SizedBox(height: 15.h),
Text('暂无下载内容'.tr, Text('暂无下载内容'.tr,
style: TextStyle(fontSize: 22.sp, color: Colors.grey)), style: TextStyle(fontSize: 22.sp, color: Colors.grey)),
], ],
)), )),
SizedBox(width: 15.w), SizedBox(width: 15.w),
// Text("去升级", style: TextStyle(fontSize: 24.sp)), // Text("去升级", style: TextStyle(fontSize: 24.sp)),
Image( Image(
@ -412,48 +414,12 @@ class _VideoLogPageState extends State<VideoLogPage> {
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) { List<Widget> mainListView(int index, CloudStorageData itemData) {
return GridView.builder( return itemData.recordList!.map((e) => videoItem(e)).toList();
padding: EdgeInsets.only(left: 15.w, right: 15.w),
itemCount: itemData.recordList!.length,
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
//
crossAxisCount: 3,
//
mainAxisSpacing: 15.w,
//
crossAxisSpacing: 15.w,
//
childAspectRatio: itemW / itemH),
itemBuilder: (BuildContext context, int index) {
final RecordListData recordData = itemData.recordList![index];
return videoItem(recordData);
},
);
} }
Widget lockMainListView(int index, CloudStorageData itemData) { List<Widget> lockMainListView(int index, CloudStorageData itemData) {
return GridView.builder( return itemData.recordList!.map((e) => videoItem(e)).toList();
padding: EdgeInsets.only(left: 15.w, right: 15.w),
itemCount: itemData.recordList!.length,
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
//
crossAxisCount: 3,
//
mainAxisSpacing: 15.w,
//
crossAxisSpacing: 15.w,
//
childAspectRatio: itemW / itemH),
itemBuilder: (BuildContext context, int index) {
final RecordListData recordData = itemData.recordList![index];
return videoItem(recordData);
},
);
} }
Widget videoItem(RecordListData recordData) { Widget videoItem(RecordListData recordData) {
@ -469,22 +435,86 @@ class _VideoLogPageState extends State<VideoLogPage> {
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (context) => builder: (context) => FullScreenImagePage(
FullScreenImagePage( imageUrl: recordData.imagesUrl!,
imageUrl: recordData.imagesUrl!, ),
),
), ),
); );
} }
}, },
child: SizedBox( child: Container(
width: itemW, padding: EdgeInsets.symmetric(horizontal: 20.w),
height: itemH, margin: EdgeInsets.only(
child: Column( bottom: 20.h,
left: 18.w,
right: 18.w,
),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10.w),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.2),
spreadRadius: 1,
blurRadius: 5,
offset: const Offset(0, 3), // changes position of shadow
),
],
),
width: 1.sw,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[ children: <Widget>[
Row(
children: [
Container(
padding: EdgeInsets.all(10.w),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(58.w),
color: AppColors.mainColor,
),
child: Icon(
_buildIconByType(recordData),
size: 48.sp,
color: Colors.white,
),
),
SizedBox(
width: 14.w,
),
Container(
height: itemW,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
_buildTitleByType(recordData),
style: TextStyle(
fontSize: 24.sp,
fontWeight: FontWeight.w600,
),
),
SizedBox(
height: 8.h,
),
Text(
DateTool()
.dateToHNString(recordData.operateDate.toString()),
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 20.sp,
fontWeight: FontWeight.w600,
),
),
],
),
),
],
),
Container( Container(
width: itemW, width: 118.w,
height: itemW, height: 118.w,
margin: const EdgeInsets.all(0), margin: const EdgeInsets.all(0),
color: Colors.white, color: Colors.white,
child: ClipRRect( child: ClipRRect(
@ -492,12 +522,6 @@ class _VideoLogPageState extends State<VideoLogPage> {
child: _buildImageOrVideoItem(recordData), child: _buildImageOrVideoItem(recordData),
), ),
), ),
SizedBox(height: 5.h),
Text(
DateTool().dateToYMDHNString(recordData.operateDate.toString()),
textAlign: TextAlign.center,
style: TextStyle(fontSize: 18.sp),
)
], ],
), ),
), ),
@ -512,6 +536,50 @@ class _VideoLogPageState extends State<VideoLogPage> {
} }
} }
String _buildTitleByType(RecordListData item) {
final recordType = item.recordType;
switch (recordType) {
case 130:
return '防拆报警'.tr;
case 160:
return '人脸'.tr + '开锁'.tr;
case 220:
return '逗留警告'.tr;
default:
return '';
}
}
IconData _buildIconByType(RecordListData item) {
final recordType = item.recordType;
switch (recordType) {
case 130:
return Icons.fmd_bad_outlined;
case 160:
return Icons.tag_faces_outlined;
case 220:
return Icons.wifi_tethering_error_rounded_outlined;
default:
return Icons.priority_high_rounded;
}
}
Color _buildTextColorByType(RecordListData item) {
final recordType = item.recordType;
switch (recordType) {
case 120:
case 150:
case 130:
case 190:
case 200:
case 210:
case 220:
return Colors.red;
default:
return Colors.black;
}
}
_buildVideoItem(RecordListData recordData) { _buildVideoItem(RecordListData recordData) {
return VideoThumbnailImage(videoUrl: recordData.videoUrl!); return VideoThumbnailImage(videoUrl: recordData.videoUrl!);
} }

View File

@ -1,9 +1,13 @@
import 'dart:io';
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/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';
import 'package:star_lock/appRouters.dart';
import 'package:star_lock/app_settings/app_settings.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/videoLogDetail/controlsOverlay_page.dart'; import 'package:star_lock/main/lockDetail/videoLog/videoLogDetail/controlsOverlay_page.dart';
import 'package:star_lock/main/lockDetail/videoLog/videoLogDetail/videoLogDetail_state.dart'; import 'package:star_lock/main/lockDetail/videoLog/videoLogDetail/videoLogDetail_state.dart';
@ -30,11 +34,11 @@ class _VideoLogDetailPageState extends State<VideoLogDetailPage> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
AppLog.log(
'state.recordData.value.videoUrl!' + state.recordData.value.videoUrl!);
state.videoController = VideoPlayerController.networkUrl( state.videoController =
Uri.parse(state.recordData.value.videoUrl!), createVideoController(state.recordData.value.videoUrl!);
videoPlayerOptions: VideoPlayerOptions(mixWithOthers: true),
);
state.videoController.addListener(() { state.videoController.addListener(() {
setState(() {}); setState(() {});
@ -47,10 +51,8 @@ class _VideoLogDetailPageState extends State<VideoLogDetailPage> {
if (state.videoController != null) { if (state.videoController != null) {
await state.videoController.dispose(); // await state.videoController.dispose(); //
} }
state.videoController = VideoPlayerController.networkUrl( state.videoController =
Uri.parse(videoUrl), createVideoController(state.recordData.value.videoUrl!);
videoPlayerOptions: VideoPlayerOptions(mixWithOthers: true),
);
// //
await state.videoController.initialize(); await state.videoController.initialize();
@ -60,6 +62,22 @@ class _VideoLogDetailPageState extends State<VideoLogDetailPage> {
setState(() {}); setState(() {});
} }
VideoPlayerController createVideoController(String url) {
if (url.startsWith('http://') || url.startsWith('https://')) {
return VideoPlayerController.networkUrl(
Uri.parse(url),
videoPlayerOptions: VideoPlayerOptions(mixWithOthers: true),
);
} else {
final file = File(
url.startsWith('file://') ? url.replaceFirst('file://', '') : url);
return VideoPlayerController.file(
file,
videoPlayerOptions: VideoPlayerOptions(mixWithOthers: true),
);
}
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
@ -104,6 +122,7 @@ class _VideoLogDetailPageState extends State<VideoLogDetailPage> {
], ],
), ),
), ),
// _buildTitleRow(),
_buildOther(), _buildOther(),
], ],
) )
@ -135,14 +154,79 @@ class _VideoLogDetailPageState extends State<VideoLogDetailPage> {
); );
} }
}, },
child: SizedBox( child: Container(
width: itemW, padding: EdgeInsets.symmetric(horizontal: 20.w),
height: itemH, margin: EdgeInsets.only(
child: Column( bottom: 20.h,
left: 18.w,
right: 18.w,
),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10.w),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.2),
spreadRadius: 1,
blurRadius: 5,
offset: const Offset(0, 3), // changes position of shadow
),
],
),
width: 1.sw,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[ children: <Widget>[
Row(
children: [
Container(
padding: EdgeInsets.all(10.w),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(58.w),
color: AppColors.mainColor,
),
child: Icon(
_buildIconByType(recordData),
size: 48.sp,
color: Colors.white,
),
),
SizedBox(
width: 14.w,
),
Container(
height: itemW,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
_buildTitleByType(recordData),
style: TextStyle(
fontSize: 24.sp,
fontWeight: FontWeight.w600,
),
),
SizedBox(
height: 8.h,
),
Text(
DateTool()
.dateToHNString(recordData.operateDate.toString()),
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 20.sp,
fontWeight: FontWeight.w600,
),
),
],
),
),
],
),
Container( Container(
width: itemW, width: 118.w,
height: itemW, height: 118.w,
margin: const EdgeInsets.all(0), margin: const EdgeInsets.all(0),
color: Colors.white, color: Colors.white,
child: ClipRRect( child: ClipRRect(
@ -213,11 +297,13 @@ class _VideoLogDetailPageState extends State<VideoLogDetailPage> {
margin: EdgeInsets.only(left: 20.w, top: 15.w, bottom: 15.w), margin: EdgeInsets.only(left: 20.w, top: 15.w, bottom: 15.w),
child: Row( child: Row(
children: <Widget>[ children: <Widget>[
Text(item.date ?? '', style: TextStyle(fontSize: 20.sp)), Text(item.date ?? '',
style: TextStyle(
fontSize: 24.sp, fontWeight: FontWeight.w600)),
], ],
), ),
), ),
mainListView(index, item), ...mainListView(index, item),
], ],
); );
}, },
@ -225,22 +311,60 @@ class _VideoLogDetailPageState extends State<VideoLogDetailPage> {
); );
} }
Widget mainListView(int index, CloudStorageData itemData) { //
return GridView.builder( List<Widget> mainListView(int index, CloudStorageData itemData) {
itemCount: itemData.recordList!.length, return itemData.recordList!.map((e) => videoItem(e)).toList();
shrinkWrap: true, }
physics: const NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( String _buildTitleByType(RecordListData item) {
// final recordType = item.recordType;
crossAxisCount: 3, switch (recordType) {
), case 130:
itemBuilder: (BuildContext context, int index) { return '防拆报警'.tr;
return _buildItem(itemData.recordList![index]); case 160:
}, return '人脸'.tr + '开锁'.tr;
); case 220:
return '逗留警告'.tr;
default:
return '';
}
}
IconData _buildIconByType(RecordListData item) {
final recordType = item.recordType;
switch (recordType) {
case 130:
return Icons.fmd_bad_outlined;
case 160:
return Icons.tag_faces_outlined;
case 220:
return Icons.wifi_tethering_error_rounded_outlined;
default:
return Icons.priority_high_rounded;
}
} }
_buildItem(itemData) { _buildItem(itemData) {
return videoItem(itemData); return videoItem(itemData);
} }
_buildTitleRow() {
return Container(
decoration: BoxDecoration(
color: Colors.white,
),
padding: EdgeInsets.only(left: 15.w, top: 24.w, bottom: 24.w),
child: Row(
children: [
Text(
_buildTitleByType(state.recordData.value) ?? '',
style: TextStyle(
fontSize: 24.sp,
fontWeight: FontWeight.w600,
),
),
],
),
);
}
} }

View File

@ -2,6 +2,7 @@ import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:path_provider/path_provider.dart'; import 'package:path_provider/path_provider.dart';
import 'package:video_thumbnail/video_thumbnail.dart'; import 'package:video_thumbnail/video_thumbnail.dart';
@ -77,7 +78,7 @@ class _VideoThumbnailState extends State<VideoThumbnailImage> {
), ),
Icon( Icon(
Icons.play_arrow_rounded, Icons.play_arrow_rounded,
size: 80, size: 88.sp,
color: Colors.white.withOpacity(0.8), color: Colors.white.withOpacity(0.8),
), ),
], ],