|
|
|
import 'dart:convert';
|
|
|
|
|
|
|
|
import 'dart:io';
|
|
|
|
import 'dart:async';
|
|
|
|
|
|
|
|
import 'package:cached_network_image/cached_network_image.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_ijkplayer/flutter_ijkplayer.dart';
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
...
|
...
|
@@ -11,11 +8,9 @@ import 'package:one_key/models/upload_img_model.dart'; |
|
|
|
import 'package:one_key/pages/online_check/photo_view_wiget.dart';
|
|
|
|
import 'package:one_key/pages/online_check/progress.dart';
|
|
|
|
|
|
|
|
import 'package:one_key/provider/online_check_edit_provider.dart';
|
|
|
|
import 'package:one_key/provider/upload_img_provider.dart';
|
|
|
|
import 'package:one_key/res/colors.dart';
|
|
|
|
import 'package:one_key/utils/dialog_util.dart';
|
|
|
|
import 'package:one_key/utils/misc.dart';
|
|
|
|
|
|
|
|
import 'package:one_key/utils/navigator_util.dart';
|
|
|
|
import 'package:one_key/utils/upload_image_util.dart';
|
|
|
|
import 'package:one_key/utils/utils.dart';
|
|
...
|
...
|
@@ -23,15 +18,12 @@ import 'package:one_key/widgets/MyDivider.dart'; |
|
|
|
import 'package:one_key/widgets/v_empty_view.dart';
|
|
|
|
import 'package:permission_handler/permission_handler.dart';
|
|
|
|
import 'package:photo/photo.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
import 'package:image_picker/image_picker.dart';
|
|
|
|
import 'package:qiniu_flutter_sdk/qiniu_flutter_sdk.dart';
|
|
|
|
import 'package:video_player/video_player.dart';
|
|
|
|
import '../online_check/dispose.dart';
|
|
|
|
import 'package:photo_manager/photo_manager.dart';
|
|
|
|
// import 'package:video_thumbnail/video_thumbnail.dart';
|
|
|
|
import 'package:chewie/chewie.dart';
|
|
|
|
import 'package:video_compress/video_compress.dart';
|
|
|
|
|
|
|
|
typedef void OnPickImageCallback(
|
|
|
|
double maxWidth, double maxHeight, int quality);
|
|
...
|
...
|
@@ -41,12 +33,14 @@ class VideoPickerWidget extends StatefulWidget { |
|
|
|
final Color borderColor;
|
|
|
|
final ValueChanged onChange;
|
|
|
|
final int maxImageNumber;
|
|
|
|
final UploadImageProvider model;
|
|
|
|
VideoPickerWidget(
|
|
|
|
{Key key,
|
|
|
|
this.scrollController,
|
|
|
|
this.borderColor = Colors.blue,
|
|
|
|
this.onChange,
|
|
|
|
this.maxImageNumber = 5})
|
|
|
|
this.maxImageNumber = 5,
|
|
|
|
this.model})
|
|
|
|
: super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
...
|
...
|
@@ -55,8 +49,6 @@ class VideoPickerWidget extends StatefulWidget { |
|
|
|
|
|
|
|
class _VideoPickerWidgetState extends DisposableState<VideoPickerWidget> {
|
|
|
|
final picker = ImagePicker();
|
|
|
|
// OnlineCheckEditProvider _onlineCheckEditProvider;
|
|
|
|
UploadImageProvider _uploadImageProvider;
|
|
|
|
|
|
|
|
// 用户输入的文件名
|
|
|
|
String key;
|
|
...
|
...
|
@@ -71,63 +63,65 @@ class _VideoPickerWidgetState extends DisposableState<VideoPickerWidget> { |
|
|
|
// PutController putController = PutController();
|
|
|
|
// 当前的任务状态
|
|
|
|
|
|
|
|
// String thumbnailPath;
|
|
|
|
VideoPlayerController _controller;
|
|
|
|
Future _initializeVideoPlayerFuture;
|
|
|
|
|
|
|
|
// 声明控制器(两个)
|
|
|
|
VideoPlayerController videoPlayerController;
|
|
|
|
ChewieController chewieController;
|
|
|
|
IjkMediaController ijkMediaController = IjkMediaController();
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
// storage = Storage();
|
|
|
|
// putController = PutController();
|
|
|
|
super.initState();
|
|
|
|
|
|
|
|
// _controller.setLooping(false);
|
|
|
|
// 生成控制器(两个)
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
super.dispose();
|
|
|
|
// 销毁播放器的控制器
|
|
|
|
_controller.dispose();
|
|
|
|
chewieController.dispose();
|
|
|
|
}
|
|
|
|
|
|
|
|
///#相机拍照,单图选择
|
|
|
|
Future _getFromPictureOrCamera(imageSource) async {
|
|
|
|
final pickedFile = await picker.getVideo(
|
|
|
|
source: imageSource, maxDuration: const Duration(seconds: 15));
|
|
|
|
// thumbnailPath = await VideoThumbnail.thumbnailFile(
|
|
|
|
// video: pickedFile.path,
|
|
|
|
// imageFormat: ImageFormat.PNG,
|
|
|
|
// maxWidth: 128,
|
|
|
|
// quality: 25);
|
|
|
|
|
|
|
|
// print(thumbnailPath);
|
|
|
|
_controller = VideoPlayerController.file(File(pickedFile.path));
|
|
|
|
_initializeVideoPlayerFuture = _controller.initialize();
|
|
|
|
//////#相机拍照,单图选择
|
|
|
|
Future _getImageFromPictureOrCamera(ImageSource imageSource) async {
|
|
|
|
final pickedFile = await picker.getImage(source: imageSource);
|
|
|
|
setState(() {
|
|
|
|
if (pickedFile != null) {
|
|
|
|
UploadImgModel imgModel = UploadImgModel();
|
|
|
|
imgModel.file = File(pickedFile.path);
|
|
|
|
imgModel.process = 0.01;
|
|
|
|
_uploadImageProvider.imageList.add(imgModel);
|
|
|
|
imgModel.fileType = FileType.image;
|
|
|
|
widget.model.imageList.add(imgModel);
|
|
|
|
} else {
|
|
|
|
print('No image selected.');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if (pickedFile != null) {
|
|
|
|
UploadImageUtil().startUpload(
|
|
|
|
context,
|
|
|
|
File(pickedFile.path),
|
|
|
|
_uploadImageProvider.imageList.length - 1,
|
|
|
|
true,
|
|
|
|
_uploadImageProvider);
|
|
|
|
UploadImageUtil().startUpload(context, File(pickedFile.path),
|
|
|
|
widget.model.imageList.length - 1, true, widget.model);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///视频
|
|
|
|
Future _getVideoFromPictureOrCamera(ImageSource imageSource) async {
|
|
|
|
final pickedFile = await picker.getVideo(
|
|
|
|
source: imageSource, maxDuration: const Duration(seconds: 15));
|
|
|
|
|
|
|
|
await VideoCompress.setLogLevel(0);
|
|
|
|
final info = await VideoCompress.getMediaInfo(pickedFile.path);
|
|
|
|
String duration = '00';
|
|
|
|
if (info != null) {
|
|
|
|
if (info.duration > 15000 || info.duration < 11000) {
|
|
|
|
Utils.showToast('请选择10~15s的视频');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
duration = Utils.addZeroNumber((info.duration / 1000).round());
|
|
|
|
}
|
|
|
|
File thumbnailPath = await VideoCompress.getFileThumbnail(pickedFile.path,
|
|
|
|
quality: 100, // default(100)
|
|
|
|
position: -1 // default(-1)
|
|
|
|
);
|
|
|
|
|
|
|
|
if (pickedFile != null) {
|
|
|
|
UploadImgModel imgModel = UploadImgModel();
|
|
|
|
imgModel.file = File(pickedFile.path);
|
|
|
|
imgModel.process = 0.01;
|
|
|
|
imgModel.fileType = FileType.video;
|
|
|
|
imgModel.thumbnailPath = thumbnailPath;
|
|
|
|
imgModel.duration = duration;
|
|
|
|
widget.model.imageList.add(imgModel);
|
|
|
|
setState(() {});
|
|
|
|
UploadImageUtil().startUpload(context, File(pickedFile.path),
|
|
|
|
widget.model.imageList.length - 1, true, widget.model);
|
|
|
|
} else {
|
|
|
|
print('No image selected.');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -151,8 +145,7 @@ class _VideoPickerWidgetState extends DisposableState<VideoPickerWidget> { |
|
|
|
// the check box disable color
|
|
|
|
itemRadio: 0.88,
|
|
|
|
// the content item radio
|
|
|
|
maxSelected:
|
|
|
|
widget.maxImageNumber - _uploadImageProvider.imageList.length,
|
|
|
|
maxSelected: widget.maxImageNumber - widget.model.imageList.length,
|
|
|
|
// max picker image count
|
|
|
|
// provider: I18nProvider.english,
|
|
|
|
provider: I18nProvider.chinese,
|
|
...
|
...
|
@@ -186,14 +179,11 @@ class _VideoPickerWidgetState extends DisposableState<VideoPickerWidget> { |
|
|
|
UploadImgModel imgModel = UploadImgModel();
|
|
|
|
imgModel.file = File(file.absolute.path);
|
|
|
|
imgModel.process = 0.01;
|
|
|
|
_uploadImageProvider.imageList.add(imgModel);
|
|
|
|
imgModel.fileType = FileType.image;
|
|
|
|
widget.model.imageList.add(imgModel);
|
|
|
|
});
|
|
|
|
UploadImageUtil().startUpload(
|
|
|
|
context,
|
|
|
|
File(file.absolute.path),
|
|
|
|
_uploadImageProvider.imageList.length - 1,
|
|
|
|
false,
|
|
|
|
_uploadImageProvider);
|
|
|
|
UploadImageUtil().startUpload(context, File(file.absolute.path),
|
|
|
|
widget.model.imageList.length - 1, false, widget.model);
|
|
|
|
// startUpload(File(file.absolute.path),
|
|
|
|
// _uploadImageProvider.imageList.length - 1, false);
|
|
|
|
}
|
|
...
|
...
|
@@ -201,7 +191,7 @@ class _VideoPickerWidgetState extends DisposableState<VideoPickerWidget> { |
|
|
|
}
|
|
|
|
|
|
|
|
///添加图片UI弹出
|
|
|
|
Future _openModalBottomSheet(context) async {
|
|
|
|
Future _openModalBottomSheet(context, FileType fileType) async {
|
|
|
|
final option = await showModalBottomSheet(
|
|
|
|
context: context,
|
|
|
|
backgroundColor: Colors.transparent,
|
|
...
|
...
|
@@ -220,7 +210,12 @@ class _VideoPickerWidgetState extends DisposableState<VideoPickerWidget> { |
|
|
|
InkWell(
|
|
|
|
onTap: () {
|
|
|
|
Utils.getPickPermission(context, () {
|
|
|
|
_getFromPictureOrCamera(ImageSource.camera);
|
|
|
|
if (fileType == FileType.image) {
|
|
|
|
_getImageFromPictureOrCamera(ImageSource.camera);
|
|
|
|
} else {
|
|
|
|
_getVideoFromPictureOrCamera(ImageSource.camera);
|
|
|
|
}
|
|
|
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
}, PermissionGroup.camera);
|
|
|
|
},
|
|
...
|
...
|
@@ -245,8 +240,13 @@ class _VideoPickerWidgetState extends DisposableState<VideoPickerWidget> { |
|
|
|
InkWell(
|
|
|
|
onTap: () {
|
|
|
|
Utils.getPickPermission(context, () {
|
|
|
|
// pickAsset(PickType.onlyVideo);
|
|
|
|
_getFromPictureOrCamera(ImageSource.gallery);
|
|
|
|
if (fileType == FileType.image) {
|
|
|
|
pickAsset(PickType.onlyImage);
|
|
|
|
} else {
|
|
|
|
_getVideoFromPictureOrCamera(ImageSource.gallery);
|
|
|
|
}
|
|
|
|
// //
|
|
|
|
// _getFromPictureOrCamera(ImageSource.gallery);
|
|
|
|
Navigator.pop(context);
|
|
|
|
}, PermissionGroup.photos);
|
|
|
|
},
|
|
...
|
...
|
@@ -290,6 +290,16 @@ class _VideoPickerWidgetState extends DisposableState<VideoPickerWidget> { |
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return _getGridImg(
|
|
|
|
widget.model.imageList.length < widget.maxImageNumber
|
|
|
|
? widget.model.imageList.length + 2
|
|
|
|
: widget.model.imageList.length,
|
|
|
|
context,
|
|
|
|
widget.model.imageList.length == widget.maxImageNumber ? true : false);
|
|
|
|
}
|
|
|
|
|
|
|
|
//查看大图
|
|
|
|
_showPhotoView(BuildContext context, int index, List imgs,
|
|
|
|
{isShow = false, List dashName}) async {
|
|
...
|
...
|
@@ -298,220 +308,253 @@ class _VideoPickerWidgetState extends DisposableState<VideoPickerWidget> { |
|
|
|
// 'http://nosqn.colorcun.com/custom/lite-online/image/def-banner.png') {
|
|
|
|
// imgs[0] = 'http://nosqn.colorcun.com/app/seller-hj-empty.png';
|
|
|
|
// }
|
|
|
|
// _controller = VideoPlayerController.network(imgs[index]);
|
|
|
|
// chewieController = ChewieController(
|
|
|
|
// videoPlayerController: _controller,
|
|
|
|
// // 比例
|
|
|
|
// // aspectRatio: 16 / 9,
|
|
|
|
// // 自动播放
|
|
|
|
// autoPlay: true,
|
|
|
|
// // 循环
|
|
|
|
// looping: true,
|
|
|
|
// );
|
|
|
|
|
|
|
|
ijkMediaController.setNetworkDataSource(
|
|
|
|
imgs[index],
|
|
|
|
autoPlay: true,
|
|
|
|
);
|
|
|
|
Utils.setBarStatus(false, color: Colors.black);
|
|
|
|
dynamic result = await showGeneralDialog(
|
|
|
|
context: context,
|
|
|
|
barrierDismissible: false,
|
|
|
|
barrierColor: Colors.black,
|
|
|
|
// barrierColor: Colors.red,
|
|
|
|
barrierLabel:
|
|
|
|
MaterialLocalizations.of(context).modalBarrierDismissLabel,
|
|
|
|
transitionDuration: const Duration(milliseconds: 150),
|
|
|
|
pageBuilder: (BuildContext context, Animation animation,
|
|
|
|
Animation secondaryAnimation) {
|
|
|
|
return Column(
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
height: ScreenUtil().setWidth(100),
|
|
|
|
color: Colors.black,
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
Material(
|
|
|
|
child: InkWell(
|
|
|
|
onTap: () {
|
|
|
|
Navigator.pop(context);
|
|
|
|
},
|
|
|
|
child: Image.asset(Utils.getImgPath('invication_back')),
|
|
|
|
)),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
// Chewie(
|
|
|
|
// controller: chewieController,
|
|
|
|
// ),
|
|
|
|
IjkPlayer(mediaController: ijkMediaController),
|
|
|
|
Widget child = Stack(
|
|
|
|
children: <Widget>[
|
|
|
|
PhotoPreview(
|
|
|
|
initialIndex: index,
|
|
|
|
photoList: imgs,
|
|
|
|
isShow: isShow,
|
|
|
|
dashName: dashName)
|
|
|
|
],
|
|
|
|
);
|
|
|
|
return child;
|
|
|
|
});
|
|
|
|
// Utils.setBarStatus(true, color: Colors.white);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
_uploadImageProvider =
|
|
|
|
Provider.of<UploadImageProvider>(context, listen: true);
|
|
|
|
return _getGridImg(
|
|
|
|
_uploadImageProvider.imageList.length < widget.maxImageNumber
|
|
|
|
? _uploadImageProvider.imageList.length + 1
|
|
|
|
: _uploadImageProvider.imageList.length,
|
|
|
|
context,
|
|
|
|
_uploadImageProvider.imageList.length == widget.maxImageNumber
|
|
|
|
? true
|
|
|
|
: false);
|
|
|
|
Utils.setBarStatus(true, color: Colors.white);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// 九宫格
|
|
|
|
Widget _getGridImg(count, context, isLinjie) {
|
|
|
|
// return
|
|
|
|
// GridView.builder(
|
|
|
|
// controller: widget.scrollController,
|
|
|
|
// // padding: EdgeInsets.only(top: ScreenUtil().getAdapterSize(10)),
|
|
|
|
// shrinkWrap: true,
|
|
|
|
// itemCount: count,
|
|
|
|
// //SliverGridDelegateWithFixedCrossAxisCount 构建一个横轴固定数量Widget
|
|
|
|
// gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
|
|
|
// //横轴元素个数
|
|
|
|
// crossAxisCount: 1,
|
|
|
|
// //纵轴间距
|
|
|
|
// mainAxisSpacing: ScreenUtil().setWidth(30),
|
|
|
|
// //横轴间距
|
|
|
|
// crossAxisSpacing: ScreenUtil().setWidth(30),
|
|
|
|
// //子组件宽高长度比例
|
|
|
|
// // childAspectRatio: 1.0
|
|
|
|
// ),
|
|
|
|
// itemBuilder: (BuildContext context, int index) {
|
|
|
|
//Widget Function(BuildContext context, int index)
|
|
|
|
var linjie = widget.maxImageNumber;
|
|
|
|
if (isLinjie) {
|
|
|
|
linjie = widget.maxImageNumber - 1;
|
|
|
|
}
|
|
|
|
if (0 == count - 1 && 0 < linjie) {
|
|
|
|
return InkWell(
|
|
|
|
onTap: () {
|
|
|
|
// 触摸收起键盘
|
|
|
|
FocusScope.of(context).requestFocus(FocusNode());
|
|
|
|
_openModalBottomSheet(context);
|
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
width: ScreenUtil().setWidth(90 * 2),
|
|
|
|
height: ScreenUtil().setWidth(90 * 2),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
border: Border.all(
|
|
|
|
color: MyColours.color_E0E0E0,
|
|
|
|
width: ScreenUtil().setWidth(2)),
|
|
|
|
),
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
VEmptyView(74),
|
|
|
|
Image.asset(
|
|
|
|
Utils.getImgPath('add_image'),
|
|
|
|
width: ScreenUtil().setWidth(32),
|
|
|
|
height: ScreenUtil().setWidth(32),
|
|
|
|
),
|
|
|
|
VEmptyView(10),
|
|
|
|
Text(
|
|
|
|
'添加视频',
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: ScreenUtil().setSp(24),
|
|
|
|
color: MyColours.color_999999),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return _uploadImageProvider.imageList.length < 1
|
|
|
|
? Text('')
|
|
|
|
: InkWell(
|
|
|
|
onTap: () {
|
|
|
|
if (_uploadImageProvider.imageList[0].process == 1) {
|
|
|
|
_uploadImageProvider.imageQiniuUrlList = [];
|
|
|
|
if (_uploadImageProvider.imageList[0].qiniuUrl != null) {
|
|
|
|
for (int i = 0;
|
|
|
|
i < _uploadImageProvider.imageList.length;
|
|
|
|
i++) {
|
|
|
|
_uploadImageProvider.imageQiniuUrlList
|
|
|
|
.add(_uploadImageProvider.imageList[i].qiniuUrl);
|
|
|
|
}
|
|
|
|
return GridView.builder(
|
|
|
|
controller: widget.scrollController,
|
|
|
|
// padding: EdgeInsets.only(top: ScreenUtil().getAdapterSize(10)),
|
|
|
|
shrinkWrap: true,
|
|
|
|
itemCount: count,
|
|
|
|
//SliverGridDelegateWithFixedCrossAxisCount 构建一个横轴固定数量Widget
|
|
|
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
|
|
|
//横轴元素个数
|
|
|
|
crossAxisCount: 3,
|
|
|
|
//纵轴间距
|
|
|
|
mainAxisSpacing: ScreenUtil().setWidth(30),
|
|
|
|
//横轴间距
|
|
|
|
crossAxisSpacing: ScreenUtil().setWidth(30),
|
|
|
|
//子组件宽高长度比例
|
|
|
|
childAspectRatio: 1.0),
|
|
|
|
itemBuilder: (BuildContext context, int index) {
|
|
|
|
var linjie = widget.maxImageNumber;
|
|
|
|
if (isLinjie) {
|
|
|
|
linjie = widget.maxImageNumber - 2;
|
|
|
|
}
|
|
|
|
if (index == count - 2 && index < linjie) {
|
|
|
|
return InkWell(
|
|
|
|
onTap: () {
|
|
|
|
// 触摸收起键盘
|
|
|
|
FocusScope.of(context).requestFocus(FocusNode());
|
|
|
|
_openModalBottomSheet(context, FileType.image);
|
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
width: ScreenUtil().setWidth(90 * 2),
|
|
|
|
height: ScreenUtil().setWidth(90 * 2),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
border: Border.all(
|
|
|
|
color: MyColours.color_E0E0E0,
|
|
|
|
width: ScreenUtil().setWidth(2)),
|
|
|
|
),
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
VEmptyView(74),
|
|
|
|
Image.asset(
|
|
|
|
Utils.getImgPath('add_image'),
|
|
|
|
width: ScreenUtil().setWidth(32),
|
|
|
|
height: ScreenUtil().setWidth(32),
|
|
|
|
),
|
|
|
|
VEmptyView(10),
|
|
|
|
Text(
|
|
|
|
'添加图片',
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: ScreenUtil().setSp(24),
|
|
|
|
color: MyColours.color_999999),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
if (index == count - 1 && index <= linjie) {
|
|
|
|
return InkWell(
|
|
|
|
onTap: () {
|
|
|
|
// 触摸收起键盘
|
|
|
|
FocusScope.of(context).requestFocus(FocusNode());
|
|
|
|
_openModalBottomSheet(context, FileType.video);
|
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
width: ScreenUtil().setWidth(90 * 2),
|
|
|
|
height: ScreenUtil().setWidth(90 * 2),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
border: Border.all(
|
|
|
|
color: MyColours.color_E0E0E0,
|
|
|
|
width: ScreenUtil().setWidth(2)),
|
|
|
|
),
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
VEmptyView(74),
|
|
|
|
Image.asset(
|
|
|
|
Utils.getImgPath('add_image'),
|
|
|
|
width: ScreenUtil().setWidth(32),
|
|
|
|
height: ScreenUtil().setWidth(32),
|
|
|
|
),
|
|
|
|
VEmptyView(10),
|
|
|
|
Text(
|
|
|
|
'添加视频',
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: ScreenUtil().setSp(24),
|
|
|
|
color: MyColours.color_999999),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
///没有上传完成的不可以点击
|
|
|
|
// _showPhotoView(
|
|
|
|
// context, 0, _uploadImageProvider.imageQiniuUrlList);
|
|
|
|
NavigatorUtil.goPlayVideoPage(context,
|
|
|
|
urlStr: _uploadImageProvider.imageQiniuUrlList[0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
child: Stack(
|
|
|
|
children: [
|
|
|
|
Stack(
|
|
|
|
alignment: Alignment.topRight,
|
|
|
|
children: [
|
|
|
|
// Image.file(
|
|
|
|
// // _uploadImageProvider.imageList[index].file,
|
|
|
|
// File(thumbnailPath),
|
|
|
|
// fit: BoxFit.cover,
|
|
|
|
// width: ScreenUtil().setWidth(100 * 2),
|
|
|
|
// height: ScreenUtil().setWidth(100 * 2),
|
|
|
|
// ),
|
|
|
|
FutureBuilder(
|
|
|
|
//显示缩略图
|
|
|
|
future: _initializeVideoPlayerFuture,
|
|
|
|
builder: (context, snapshot) {
|
|
|
|
print(snapshot.connectionState);
|
|
|
|
if (snapshot.hasError) print(snapshot.error);
|
|
|
|
if (snapshot.connectionState == ConnectionState.done) {
|
|
|
|
return Container(
|
|
|
|
width: ScreenUtil().setWidth(225),
|
|
|
|
child: AspectRatio(
|
|
|
|
// aspectRatio: 1 / 1,
|
|
|
|
aspectRatio: _controller.value.aspectRatio,
|
|
|
|
child: VideoPlayer(_controller),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
return Center(
|
|
|
|
child: CircularProgressIndicator(),
|
|
|
|
);
|
|
|
|
return widget.model.imageList.length < 1
|
|
|
|
? Text('')
|
|
|
|
: InkWell(
|
|
|
|
onTap: () {
|
|
|
|
if (widget.model.imageList[index].process == 1) {
|
|
|
|
widget.model.imageQiniuUrlList = [];
|
|
|
|
if (widget.model.imageList[index].qiniuUrl != null) {
|
|
|
|
if (widget.model.imageList[index].fileType ==
|
|
|
|
FileType.image) {
|
|
|
|
List<UploadImgModel> temp = [];
|
|
|
|
temp.addAll(widget.model.imageList);
|
|
|
|
temp.removeWhere(
|
|
|
|
(element) => element.fileType == FileType.video);
|
|
|
|
for (int i = 0; i < temp.length; i++) {
|
|
|
|
widget.model.imageQiniuUrlList
|
|
|
|
.add(temp[i].qiniuUrl);
|
|
|
|
}
|
|
|
|
|
|
|
|
///没有上传完成的不可以点击
|
|
|
|
_showPhotoView(
|
|
|
|
context, index, widget.model.imageQiniuUrlList);
|
|
|
|
} else if (widget.model.imageList[index].fileType ==
|
|
|
|
FileType.video) {
|
|
|
|
NavigatorUtil.goPlayVideoPage(context,
|
|
|
|
urlStr: widget.model.imageList[index].qiniuUrl);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
child: Stack(
|
|
|
|
children: [
|
|
|
|
Stack(
|
|
|
|
alignment: Alignment.topRight,
|
|
|
|
children: [
|
|
|
|
widget.model.imageList[index].fileType ==
|
|
|
|
FileType.image
|
|
|
|
? Image.file(
|
|
|
|
widget.model.imageList[index].file,
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
width: ScreenUtil().setWidth(100 * 2),
|
|
|
|
height: ScreenUtil().setWidth(100 * 2),
|
|
|
|
)
|
|
|
|
: Image.file(
|
|
|
|
widget.model.imageList[index].thumbnailPath,
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
width: ScreenUtil().setWidth(100 * 2),
|
|
|
|
height: ScreenUtil().setWidth(100 * 2),
|
|
|
|
)
|
|
|
|
// : FutureBuilder(
|
|
|
|
// //显示缩略图
|
|
|
|
// future: _initializeVideoPlayerFuture,
|
|
|
|
// builder: (context, snapshot) {
|
|
|
|
// print(snapshot.connectionState);
|
|
|
|
// if (snapshot.hasError)
|
|
|
|
// print(snapshot.error);
|
|
|
|
// if (snapshot.connectionState ==
|
|
|
|
// ConnectionState.done) {
|
|
|
|
// return Container(
|
|
|
|
// // width: ScreenUtil().setWidth(225),
|
|
|
|
// child: AspectRatio(
|
|
|
|
// aspectRatio: 1 / 1,
|
|
|
|
|
|
|
|
Offstage(
|
|
|
|
offstage: _uploadImageProvider.imageList[0].process < 1,
|
|
|
|
child: GestureDetector(
|
|
|
|
child: Image.asset(
|
|
|
|
Utils.getImgPath("delete"),
|
|
|
|
width: ScreenUtil().setWidth(40),
|
|
|
|
height: ScreenUtil().setWidth(40),
|
|
|
|
),
|
|
|
|
onTap: () {
|
|
|
|
//点击删除按钮
|
|
|
|
setState(() {
|
|
|
|
_uploadImageProvider.imageList.removeWhere(
|
|
|
|
(element) =>
|
|
|
|
element ==
|
|
|
|
_uploadImageProvider.imageList[0]);
|
|
|
|
_uploadImageProvider.imageQiniuUrlList.removeWhere(
|
|
|
|
(element) =>
|
|
|
|
element ==
|
|
|
|
_uploadImageProvider.imageQiniuUrlList[0]);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
// // aspectRatio: _controller.value.aspectRatio,
|
|
|
|
// child: VideoPlayer(_controller),
|
|
|
|
// ),
|
|
|
|
// );
|
|
|
|
// } else {
|
|
|
|
// return Center(
|
|
|
|
// child: CircularProgressIndicator(),
|
|
|
|
// );
|
|
|
|
// }
|
|
|
|
// },
|
|
|
|
// ),
|
|
|
|
,
|
|
|
|
Offstage(
|
|
|
|
offstage: widget.model.imageList[index].process < 1,
|
|
|
|
child: GestureDetector(
|
|
|
|
child: Image.asset(
|
|
|
|
Utils.getImgPath("delete"),
|
|
|
|
width: ScreenUtil().setWidth(40),
|
|
|
|
height: ScreenUtil().setWidth(40),
|
|
|
|
),
|
|
|
|
onTap: () {
|
|
|
|
//点击删除按钮
|
|
|
|
setState(() {
|
|
|
|
widget.model.imageList.removeWhere(
|
|
|
|
(element) =>
|
|
|
|
element ==
|
|
|
|
widget.model.imageList[index]);
|
|
|
|
widget.model.imageQiniuUrlList.removeWhere(
|
|
|
|
(element) =>
|
|
|
|
element ==
|
|
|
|
widget
|
|
|
|
.model.imageQiniuUrlList[index]);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
Offstage(
|
|
|
|
offstage: _uploadImageProvider.imageList[0].process == 1,
|
|
|
|
child: Progress(_uploadImageProvider.imageList[0].process),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
));
|
|
|
|
// });
|
|
|
|
// Offstage(
|
|
|
|
// offstage: widget.model.imageList[index].process == 1,
|
|
|
|
// child: Progress(widget.model.imageList[index].process),
|
|
|
|
// ),
|
|
|
|
widget.model.imageList[index].process == 1
|
|
|
|
? widget.model.imageList[index].fileType ==
|
|
|
|
FileType.video
|
|
|
|
? Align(
|
|
|
|
alignment: Alignment.center,
|
|
|
|
child: Image.asset(
|
|
|
|
Utils.getImgPath('check_g'),
|
|
|
|
width: ScreenUtil().setWidth(40),
|
|
|
|
))
|
|
|
|
: Container()
|
|
|
|
: Progress(widget.model.imageList[index].process),
|
|
|
|
widget.model.imageList[index].fileType == FileType.video
|
|
|
|
? Align(
|
|
|
|
alignment: Alignment.bottomRight,
|
|
|
|
child: Padding(
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
bottom: ScreenUtil().setWidth(10),
|
|
|
|
right: ScreenUtil().setWidth(10)),
|
|
|
|
child: Text(
|
|
|
|
'00:${widget.model.imageList[index].duration}',
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_333333,
|
|
|
|
fontSize: ScreenUtil().setSp(24)),
|
|
|
|
)),
|
|
|
|
)
|
|
|
|
: Container()
|
|
|
|
],
|
|
|
|
));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|