Showing
12 changed files
with
905 additions
and
295 deletions
| @@ -57,6 +57,8 @@ PODS: | @@ -57,6 +57,8 @@ PODS: | ||
| 57 | - TPNS-iOS (= 1.2.7.2) | 57 | - TPNS-iOS (= 1.2.7.2) |
| 58 | - url_launcher (0.0.1): | 58 | - url_launcher (0.0.1): |
| 59 | - Flutter | 59 | - Flutter |
| 60 | + - video_compress (0.3.0): | ||
| 61 | + - Flutter | ||
| 60 | - video_player (0.0.1): | 62 | - video_player (0.0.1): |
| 61 | - Flutter | 63 | - Flutter |
| 62 | - wakelock (0.0.1): | 64 | - wakelock (0.0.1): |
| @@ -89,6 +91,7 @@ DEPENDENCIES: | @@ -89,6 +91,7 @@ DEPENDENCIES: | ||
| 89 | - sqflite (from `.symlinks/plugins/sqflite/ios`) | 91 | - sqflite (from `.symlinks/plugins/sqflite/ios`) |
| 90 | - tpns_flutter_plugin (from `.symlinks/plugins/tpns_flutter_plugin/ios`) | 92 | - tpns_flutter_plugin (from `.symlinks/plugins/tpns_flutter_plugin/ios`) |
| 91 | - url_launcher (from `.symlinks/plugins/url_launcher/ios`) | 93 | - url_launcher (from `.symlinks/plugins/url_launcher/ios`) |
| 94 | + - video_compress (from `.symlinks/plugins/video_compress/ios`) | ||
| 92 | - video_player (from `.symlinks/plugins/video_player/ios`) | 95 | - video_player (from `.symlinks/plugins/video_player/ios`) |
| 93 | - wakelock (from `.symlinks/plugins/wakelock/ios`) | 96 | - wakelock (from `.symlinks/plugins/wakelock/ios`) |
| 94 | - webview_flutter (from `.symlinks/plugins/webview_flutter/ios`) | 97 | - webview_flutter (from `.symlinks/plugins/webview_flutter/ios`) |
| @@ -149,6 +152,8 @@ EXTERNAL SOURCES: | @@ -149,6 +152,8 @@ EXTERNAL SOURCES: | ||
| 149 | :path: ".symlinks/plugins/tpns_flutter_plugin/ios" | 152 | :path: ".symlinks/plugins/tpns_flutter_plugin/ios" |
| 150 | url_launcher: | 153 | url_launcher: |
| 151 | :path: ".symlinks/plugins/url_launcher/ios" | 154 | :path: ".symlinks/plugins/url_launcher/ios" |
| 155 | + video_compress: | ||
| 156 | + :path: ".symlinks/plugins/video_compress/ios" | ||
| 152 | video_player: | 157 | video_player: |
| 153 | :path: ".symlinks/plugins/video_player/ios" | 158 | :path: ".symlinks/plugins/video_player/ios" |
| 154 | wakelock: | 159 | wakelock: |
| @@ -185,6 +190,7 @@ SPEC CHECKSUMS: | @@ -185,6 +190,7 @@ SPEC CHECKSUMS: | ||
| 185 | TPNS-iOS: 9b35473a4a0d07f2c2730ea1e66c6749c2b98095 | 190 | TPNS-iOS: 9b35473a4a0d07f2c2730ea1e66c6749c2b98095 |
| 186 | tpns_flutter_plugin: 8dbbee157aab91a878f64d056c1383726a6c5c4d | 191 | tpns_flutter_plugin: 8dbbee157aab91a878f64d056c1383726a6c5c4d |
| 187 | url_launcher: 6fef411d543ceb26efce54b05a0a40bfd74cbbef | 192 | url_launcher: 6fef411d543ceb26efce54b05a0a40bfd74cbbef |
| 193 | + video_compress: fce97e4fb1dfd88175aa07d2ffc8a2f297f87fbe | ||
| 188 | video_player: 9cc823b1d9da7e8427ee591e8438bfbcde500e6e | 194 | video_player: 9cc823b1d9da7e8427ee591e8438bfbcde500e6e |
| 189 | wakelock: 0d4a70faf8950410735e3f61fb15d517c8a6efc4 | 195 | wakelock: 0d4a70faf8950410735e3f61fb15d517c8a6efc4 |
| 190 | webview_flutter: d2b4d6c66968ad042ad94cbb791f5b72b4678a96 | 196 | webview_flutter: d2b4d6c66968ad042ad94cbb791f5b72b4678a96 |
| @@ -298,6 +298,7 @@ | @@ -298,6 +298,7 @@ | ||
| 298 | "${BUILT_PRODUCTS_DIR}/sign_in_with_apple/sign_in_with_apple.framework", | 298 | "${BUILT_PRODUCTS_DIR}/sign_in_with_apple/sign_in_with_apple.framework", |
| 299 | "${BUILT_PRODUCTS_DIR}/sqflite/sqflite.framework", | 299 | "${BUILT_PRODUCTS_DIR}/sqflite/sqflite.framework", |
| 300 | "${BUILT_PRODUCTS_DIR}/url_launcher/url_launcher.framework", | 300 | "${BUILT_PRODUCTS_DIR}/url_launcher/url_launcher.framework", |
| 301 | + "${BUILT_PRODUCTS_DIR}/video_compress/video_compress.framework", | ||
| 301 | "${BUILT_PRODUCTS_DIR}/video_player/video_player.framework", | 302 | "${BUILT_PRODUCTS_DIR}/video_player/video_player.framework", |
| 302 | "${BUILT_PRODUCTS_DIR}/wakelock/wakelock.framework", | 303 | "${BUILT_PRODUCTS_DIR}/wakelock/wakelock.framework", |
| 303 | "${BUILT_PRODUCTS_DIR}/webview_flutter/webview_flutter.framework", | 304 | "${BUILT_PRODUCTS_DIR}/webview_flutter/webview_flutter.framework", |
| @@ -324,6 +325,7 @@ | @@ -324,6 +325,7 @@ | ||
| 324 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/sign_in_with_apple.framework", | 325 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/sign_in_with_apple.framework", |
| 325 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/sqflite.framework", | 326 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/sqflite.framework", |
| 326 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/url_launcher.framework", | 327 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/url_launcher.framework", |
| 328 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/video_compress.framework", | ||
| 327 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/video_player.framework", | 329 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/video_player.framework", |
| 328 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/wakelock.framework", | 330 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/wakelock.framework", |
| 329 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/webview_flutter.framework", | 331 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/webview_flutter.framework", |
| @@ -67,9 +67,9 @@ Future<void> main() async { | @@ -67,9 +67,9 @@ Future<void> main() async { | ||
| 67 | ChangeNotifierProvider<CouponProvider>( | 67 | ChangeNotifierProvider<CouponProvider>( |
| 68 | create: (_) => CouponProvider(), | 68 | create: (_) => CouponProvider(), |
| 69 | ), | 69 | ), |
| 70 | - ChangeNotifierProvider<UploadImageProvider>( | ||
| 71 | - create: (_) => UploadImageProvider(), | ||
| 72 | - ), | 70 | + // ChangeNotifierProvider<UploadImageProvider>( |
| 71 | + // create: (_) => UploadImageProvider(), | ||
| 72 | + // ), | ||
| 73 | ChangeNotifierProvider<BaseIndoProvider>( | 73 | ChangeNotifierProvider<BaseIndoProvider>( |
| 74 | create: (_) => BaseIndoProvider(), | 74 | create: (_) => BaseIndoProvider(), |
| 75 | ), | 75 | ), |
| @@ -6,4 +6,12 @@ class UploadImgModel { | @@ -6,4 +6,12 @@ class UploadImgModel { | ||
| 6 | File file; //本地图片地址 | 6 | File file; //本地图片地址 |
| 7 | String qiniuUrl; //七牛云地址 | 7 | String qiniuUrl; //七牛云地址 |
| 8 | double process; //图片上传进度 | 8 | double process; //图片上传进度 |
| 9 | + FileType fileType; | ||
| 10 | + File thumbnailPath; // 视频封面 | ||
| 11 | + String duration; //视频时长 | ||
| 12 | +} | ||
| 13 | + | ||
| 14 | +enum FileType { | ||
| 15 | + image, | ||
| 16 | + video, | ||
| 9 | } | 17 | } |
| 1 | import 'package:flutter/material.dart'; | 1 | import 'package:flutter/material.dart'; |
| 2 | import 'package:flutter_screenutil/flutter_screenutil.dart'; | 2 | import 'package:flutter_screenutil/flutter_screenutil.dart'; |
| 3 | import 'package:one_key/pages/create_store/video_widget.dart'; | 3 | import 'package:one_key/pages/create_store/video_widget.dart'; |
| 4 | +import 'package:one_key/provider/upload_img_provider.dart'; | ||
| 4 | import 'package:one_key/res/colors.dart'; | 5 | import 'package:one_key/res/colors.dart'; |
| 5 | import 'package:one_key/utils/navigator_util.dart'; | 6 | import 'package:one_key/utils/navigator_util.dart'; |
| 6 | import 'package:one_key/widgets/round_button.dart'; | 7 | import 'package:one_key/widgets/round_button.dart'; |
| 7 | import 'package:one_key/widgets/system_app_bar.dart'; | 8 | import 'package:one_key/widgets/system_app_bar.dart'; |
| 8 | import 'package:one_key/widgets/v_empty_view.dart'; | 9 | import 'package:one_key/widgets/v_empty_view.dart'; |
| 10 | +import 'package:provider/provider.dart'; | ||
| 9 | 11 | ||
| 10 | class CreateStorePage extends StatefulWidget { | 12 | class CreateStorePage extends StatefulWidget { |
| 11 | CreateStorePage({Key key}) : super(key: key); | 13 | CreateStorePage({Key key}) : super(key: key); |
| @@ -100,7 +102,10 @@ class _CreateStorePageState extends State<CreateStorePage> { | @@ -100,7 +102,10 @@ class _CreateStorePageState extends State<CreateStorePage> { | ||
| 100 | style: TextStyle( | 102 | style: TextStyle( |
| 101 | fontSize: ScreenUtil().setSp(30), fontWeight: FontWeight.bold)), | 103 | fontSize: ScreenUtil().setSp(30), fontWeight: FontWeight.bold)), |
| 102 | VEmptyView(30), | 104 | VEmptyView(30), |
| 103 | - VideoPickerWidget(maxImageNumber: 1) | 105 | + Consumer<UploadImageProvider>(builder: (context, model, _) { |
| 106 | + return VideoPickerWidget( | ||
| 107 | + maxImageNumber: 9, model: model, scrollController: _controller); | ||
| 108 | + }) | ||
| 104 | ], | 109 | ], |
| 105 | ); | 110 | ); |
| 106 | } | 111 | } |
lib/pages/create_store/old_video_widget.dart
0 → 100644
| 1 | +// import 'dart:convert'; | ||
| 2 | + | ||
| 3 | +// import 'dart:io'; | ||
| 4 | +// import 'dart:async'; | ||
| 5 | + | ||
| 6 | +// import 'package:cached_network_image/cached_network_image.dart'; | ||
| 7 | +// import 'package:flutter/material.dart'; | ||
| 8 | +// import 'package:flutter_ijkplayer/flutter_ijkplayer.dart'; | ||
| 9 | +// import 'package:flutter_screenutil/flutter_screenutil.dart'; | ||
| 10 | +// import 'package:one_key/models/upload_img_model.dart'; | ||
| 11 | +// import 'package:one_key/pages/online_check/photo_view_wiget.dart'; | ||
| 12 | +// import 'package:one_key/pages/online_check/progress.dart'; | ||
| 13 | + | ||
| 14 | +// import 'package:one_key/provider/online_check_edit_provider.dart'; | ||
| 15 | +// import 'package:one_key/provider/upload_img_provider.dart'; | ||
| 16 | +// import 'package:one_key/res/colors.dart'; | ||
| 17 | +// import 'package:one_key/utils/dialog_util.dart'; | ||
| 18 | +// import 'package:one_key/utils/misc.dart'; | ||
| 19 | +// import 'package:one_key/utils/navigator_util.dart'; | ||
| 20 | +// import 'package:one_key/utils/upload_image_util.dart'; | ||
| 21 | +// import 'package:one_key/utils/utils.dart'; | ||
| 22 | +// import 'package:one_key/widgets/MyDivider.dart'; | ||
| 23 | +// import 'package:one_key/widgets/v_empty_view.dart'; | ||
| 24 | +// import 'package:permission_handler/permission_handler.dart'; | ||
| 25 | +// import 'package:photo/photo.dart'; | ||
| 26 | +// import 'package:provider/provider.dart'; | ||
| 27 | + | ||
| 28 | +// import 'package:image_picker/image_picker.dart'; | ||
| 29 | +// import 'package:qiniu_flutter_sdk/qiniu_flutter_sdk.dart'; | ||
| 30 | +// import 'package:video_player/video_player.dart'; | ||
| 31 | +// import '../online_check/dispose.dart'; | ||
| 32 | +// import 'package:photo_manager/photo_manager.dart'; | ||
| 33 | +// // import 'package:video_thumbnail/video_thumbnail.dart'; | ||
| 34 | +// import 'package:chewie/chewie.dart'; | ||
| 35 | + | ||
| 36 | +// typedef void OnPickImageCallback( | ||
| 37 | +// double maxWidth, double maxHeight, int quality); | ||
| 38 | + | ||
| 39 | +// class VideoPickerWidget extends StatefulWidget { | ||
| 40 | +// final ScrollController scrollController; | ||
| 41 | +// final Color borderColor; | ||
| 42 | +// final ValueChanged onChange; | ||
| 43 | +// final int maxImageNumber; | ||
| 44 | +// VideoPickerWidget( | ||
| 45 | +// {Key key, | ||
| 46 | +// this.scrollController, | ||
| 47 | +// this.borderColor = Colors.blue, | ||
| 48 | +// this.onChange, | ||
| 49 | +// this.maxImageNumber = 5}) | ||
| 50 | +// : super(key: key); | ||
| 51 | + | ||
| 52 | +// @override | ||
| 53 | +// _VideoPickerWidgetState createState() => _VideoPickerWidgetState(); | ||
| 54 | +// } | ||
| 55 | + | ||
| 56 | +// class _VideoPickerWidgetState extends DisposableState<VideoPickerWidget> { | ||
| 57 | +// final picker = ImagePicker(); | ||
| 58 | +// // OnlineCheckEditProvider _onlineCheckEditProvider; | ||
| 59 | +// UploadImageProvider _uploadImageProvider; | ||
| 60 | + | ||
| 61 | +// // 用户输入的文件名 | ||
| 62 | +// String key; | ||
| 63 | +// // 用户输入的 partSize | ||
| 64 | +// int partSize = 4; | ||
| 65 | +// // 用户输入的 token | ||
| 66 | +// String token; | ||
| 67 | + | ||
| 68 | +// /// storage 实例 | ||
| 69 | +// final Storage storage = Storage(); | ||
| 70 | +// // 控制器,可以用于取消任务、获取上述的状态,进度等信息 | ||
| 71 | +// // PutController putController = PutController(); | ||
| 72 | +// // 当前的任务状态 | ||
| 73 | + | ||
| 74 | +// // String thumbnailPath; | ||
| 75 | +// VideoPlayerController _controller; | ||
| 76 | +// Future _initializeVideoPlayerFuture; | ||
| 77 | + | ||
| 78 | +// // 声明控制器(两个) | ||
| 79 | +// VideoPlayerController videoPlayerController; | ||
| 80 | +// ChewieController chewieController; | ||
| 81 | +// IjkMediaController ijkMediaController = IjkMediaController(); | ||
| 82 | + | ||
| 83 | +// @override | ||
| 84 | +// void initState() { | ||
| 85 | +// // storage = Storage(); | ||
| 86 | +// // putController = PutController(); | ||
| 87 | +// super.initState(); | ||
| 88 | + | ||
| 89 | +// // _controller.setLooping(false); | ||
| 90 | +// // 生成控制器(两个) | ||
| 91 | +// } | ||
| 92 | + | ||
| 93 | +// @override | ||
| 94 | +// void dispose() { | ||
| 95 | +// super.dispose(); | ||
| 96 | +// // 销毁播放器的控制器 | ||
| 97 | +// _controller.dispose(); | ||
| 98 | +// chewieController.dispose(); | ||
| 99 | +// } | ||
| 100 | + | ||
| 101 | +// ///#相机拍照,单图选择 | ||
| 102 | +// Future _getFromPictureOrCamera(imageSource) async { | ||
| 103 | +// final pickedFile = await picker.getVideo( | ||
| 104 | +// source: imageSource, maxDuration: const Duration(seconds: 15)); | ||
| 105 | +// // thumbnailPath = await VideoThumbnail.thumbnailFile( | ||
| 106 | +// // video: pickedFile.path, | ||
| 107 | +// // imageFormat: ImageFormat.PNG, | ||
| 108 | +// // maxWidth: 128, | ||
| 109 | +// // quality: 25); | ||
| 110 | + | ||
| 111 | +// // print(thumbnailPath); | ||
| 112 | +// _controller = VideoPlayerController.file(File(pickedFile.path)); | ||
| 113 | +// _initializeVideoPlayerFuture = _controller.initialize(); | ||
| 114 | +// setState(() { | ||
| 115 | +// if (pickedFile != null) { | ||
| 116 | +// UploadImgModel imgModel = UploadImgModel(); | ||
| 117 | +// imgModel.file = File(pickedFile.path); | ||
| 118 | +// imgModel.process = 0.01; | ||
| 119 | +// _uploadImageProvider.imageList.add(imgModel); | ||
| 120 | +// } else { | ||
| 121 | +// print('No image selected.'); | ||
| 122 | +// } | ||
| 123 | +// }); | ||
| 124 | +// if (pickedFile != null) { | ||
| 125 | +// UploadImageUtil().startUpload( | ||
| 126 | +// context, | ||
| 127 | +// File(pickedFile.path), | ||
| 128 | +// _uploadImageProvider.imageList.length - 1, | ||
| 129 | +// true, | ||
| 130 | +// _uploadImageProvider); | ||
| 131 | +// } | ||
| 132 | +// } | ||
| 133 | + | ||
| 134 | +// ///多图片选择 | ||
| 135 | +// void pickAsset(PickType type, {List<AssetPathEntity> pathList}) async { | ||
| 136 | +// /// context is required, other params is optional. | ||
| 137 | +// List<AssetEntity> imgList = await PhotoPicker.pickAsset( | ||
| 138 | +// // BuildContext required | ||
| 139 | +// context: context, | ||
| 140 | + | ||
| 141 | +// /// The following are optional parameters. | ||
| 142 | +// themeColor: MyColours.color_199095, | ||
| 143 | +// // the title color and bottom color | ||
| 144 | +// textColor: Colors.white, | ||
| 145 | +// // text color | ||
| 146 | +// padding: 1.0, | ||
| 147 | +// // item padding | ||
| 148 | +// dividerColor: Colors.grey, | ||
| 149 | +// // divider color | ||
| 150 | +// disableColor: Colors.grey.shade300, | ||
| 151 | +// // the check box disable color | ||
| 152 | +// itemRadio: 0.88, | ||
| 153 | +// // the content item radio | ||
| 154 | +// maxSelected: | ||
| 155 | +// widget.maxImageNumber - _uploadImageProvider.imageList.length, | ||
| 156 | +// // max picker image count | ||
| 157 | +// // provider: I18nProvider.english, | ||
| 158 | +// provider: I18nProvider.chinese, | ||
| 159 | +// // i18n provider ,default is chinese. , you can custom I18nProvider or use ENProvider() | ||
| 160 | +// rowCount: 3, | ||
| 161 | +// // item row count | ||
| 162 | +// thumbSize: 150, | ||
| 163 | +// // preview thumb size , default is 64 | ||
| 164 | +// sortDelegate: SortDelegate.common, | ||
| 165 | +// // default is common ,or you make custom delegate to sort your gallery | ||
| 166 | +// checkBoxBuilderDelegate: DefaultCheckBoxBuilderDelegate( | ||
| 167 | +// activeColor: MyColours.color_353535, | ||
| 168 | +// unselectedColor: Colors.white, | ||
| 169 | +// checkColor: MyColours.color_199095, | ||
| 170 | +// ), | ||
| 171 | +// // default is DefaultCheckBoxBuilderDelegate ,or you make custom delegate to create checkbox | ||
| 172 | +// // loadingDelegate: this, | ||
| 173 | +// // if you want to build custom loading widget,extends LoadingDelegate, [see example/lib/main.dart] | ||
| 174 | +// badgeDelegate: const DurationBadgeDelegate(), | ||
| 175 | +// // badgeDelegate to show badge widget | ||
| 176 | +// pickType: type, | ||
| 177 | +// photoPathList: pathList, | ||
| 178 | +// ); | ||
| 179 | +// if (imgList == null || imgList.isEmpty) { | ||
| 180 | +// print("No pick item."); | ||
| 181 | +// return; | ||
| 182 | +// } else { | ||
| 183 | +// for (int i = 0; i < imgList.length; i++) { | ||
| 184 | +// var file = await imgList[i].file; | ||
| 185 | +// setState(() { | ||
| 186 | +// UploadImgModel imgModel = UploadImgModel(); | ||
| 187 | +// imgModel.file = File(file.absolute.path); | ||
| 188 | +// imgModel.process = 0.01; | ||
| 189 | +// _uploadImageProvider.imageList.add(imgModel); | ||
| 190 | +// }); | ||
| 191 | +// UploadImageUtil().startUpload( | ||
| 192 | +// context, | ||
| 193 | +// File(file.absolute.path), | ||
| 194 | +// _uploadImageProvider.imageList.length - 1, | ||
| 195 | +// false, | ||
| 196 | +// _uploadImageProvider); | ||
| 197 | +// // startUpload(File(file.absolute.path), | ||
| 198 | +// // _uploadImageProvider.imageList.length - 1, false); | ||
| 199 | +// } | ||
| 200 | +// } | ||
| 201 | +// } | ||
| 202 | + | ||
| 203 | +// ///添加图片UI弹出 | ||
| 204 | +// Future _openModalBottomSheet(context) async { | ||
| 205 | +// final option = await showModalBottomSheet( | ||
| 206 | +// context: context, | ||
| 207 | +// backgroundColor: Colors.transparent, | ||
| 208 | +// isDismissible: false, | ||
| 209 | +// builder: (BuildContext context) { | ||
| 210 | +// return Container( | ||
| 211 | +// // height: ScreenUtil().setWidth(180 * 2), | ||
| 212 | +// decoration: BoxDecoration( | ||
| 213 | +// color: MyColours.color_ffffff, | ||
| 214 | +// borderRadius: BorderRadius.only( | ||
| 215 | +// topLeft: Radius.circular(ScreenUtil().setWidth(24)), | ||
| 216 | +// topRight: Radius.circular(ScreenUtil().setWidth(24)))), | ||
| 217 | +// child: Column( | ||
| 218 | +// mainAxisSize: MainAxisSize.min, | ||
| 219 | +// children: <Widget>[ | ||
| 220 | +// InkWell( | ||
| 221 | +// onTap: () { | ||
| 222 | +// Utils.getPickPermission(context, () { | ||
| 223 | +// _getFromPictureOrCamera(ImageSource.camera); | ||
| 224 | +// Navigator.pop(context); | ||
| 225 | +// }, PermissionGroup.camera); | ||
| 226 | +// }, | ||
| 227 | +// child: Container( | ||
| 228 | +// width: double.infinity, | ||
| 229 | +// height: ScreenUtil().setWidth(58 * 2), | ||
| 230 | +// child: Center( | ||
| 231 | +// child: Text( | ||
| 232 | +// '拍摄', | ||
| 233 | +// style: TextStyle( | ||
| 234 | +// fontSize: ScreenUtil().setSp(32), | ||
| 235 | +// color: MyColours.color_353535, | ||
| 236 | +// fontWeight: FontWeight.bold), | ||
| 237 | +// ), | ||
| 238 | +// )), | ||
| 239 | +// ), | ||
| 240 | +// MyDivider( | ||
| 241 | +// double.infinity, | ||
| 242 | +// ScreenUtil().setWidth(2), | ||
| 243 | +// color: MyColours.color_EEEEEE, | ||
| 244 | +// ), | ||
| 245 | +// InkWell( | ||
| 246 | +// onTap: () { | ||
| 247 | +// Utils.getPickPermission(context, () { | ||
| 248 | +// // pickAsset(PickType.onlyVideo); | ||
| 249 | +// _getFromPictureOrCamera(ImageSource.gallery); | ||
| 250 | +// Navigator.pop(context); | ||
| 251 | +// }, PermissionGroup.photos); | ||
| 252 | +// }, | ||
| 253 | +// child: Container( | ||
| 254 | +// width: double.infinity, | ||
| 255 | +// height: ScreenUtil().setWidth(58 * 2), | ||
| 256 | +// child: Center( | ||
| 257 | +// child: Text( | ||
| 258 | +// '从相册选择', | ||
| 259 | +// style: TextStyle( | ||
| 260 | +// fontSize: ScreenUtil().setSp(32), | ||
| 261 | +// color: MyColours.color_353535, | ||
| 262 | +// fontWeight: FontWeight.bold), | ||
| 263 | +// ), | ||
| 264 | +// )), | ||
| 265 | +// ), | ||
| 266 | +// MyDivider( | ||
| 267 | +// double.infinity, | ||
| 268 | +// ScreenUtil().setWidth(10), | ||
| 269 | +// color: MyColours.color_EEEEEE, | ||
| 270 | +// ), | ||
| 271 | +// InkWell( | ||
| 272 | +// onTap: () { | ||
| 273 | +// Navigator.pop(context, '取消'); | ||
| 274 | +// }, | ||
| 275 | +// child: Container( | ||
| 276 | +// width: double.infinity, | ||
| 277 | +// height: ScreenUtil().setWidth(58 * 2), | ||
| 278 | +// child: Center( | ||
| 279 | +// child: Text( | ||
| 280 | +// '取消', | ||
| 281 | +// style: TextStyle( | ||
| 282 | +// fontSize: ScreenUtil().setSp(32), | ||
| 283 | +// color: MyColours.color_353535, | ||
| 284 | +// fontWeight: FontWeight.bold), | ||
| 285 | +// ), | ||
| 286 | +// ))) | ||
| 287 | +// ], | ||
| 288 | +// ), | ||
| 289 | +// ); | ||
| 290 | +// }); | ||
| 291 | +// } | ||
| 292 | + | ||
| 293 | +// //查看大图 | ||
| 294 | +// _showPhotoView(BuildContext context, int index, List imgs, | ||
| 295 | +// {isShow = false, List dashName}) async { | ||
| 296 | +// // if (imgs.length == 1 && | ||
| 297 | +// // imgs[0] == | ||
| 298 | +// // 'http://nosqn.colorcun.com/custom/lite-online/image/def-banner.png') { | ||
| 299 | +// // imgs[0] = 'http://nosqn.colorcun.com/app/seller-hj-empty.png'; | ||
| 300 | +// // } | ||
| 301 | +// // _controller = VideoPlayerController.network(imgs[index]); | ||
| 302 | +// // chewieController = ChewieController( | ||
| 303 | +// // videoPlayerController: _controller, | ||
| 304 | +// // // 比例 | ||
| 305 | +// // // aspectRatio: 16 / 9, | ||
| 306 | +// // // 自动播放 | ||
| 307 | +// // autoPlay: true, | ||
| 308 | +// // // 循环 | ||
| 309 | +// // looping: true, | ||
| 310 | +// // ); | ||
| 311 | + | ||
| 312 | +// ijkMediaController.setNetworkDataSource( | ||
| 313 | +// imgs[index], | ||
| 314 | +// autoPlay: true, | ||
| 315 | +// ); | ||
| 316 | +// Utils.setBarStatus(false, color: Colors.black); | ||
| 317 | +// dynamic result = await showGeneralDialog( | ||
| 318 | +// context: context, | ||
| 319 | +// barrierDismissible: false, | ||
| 320 | +// barrierColor: Colors.black, | ||
| 321 | +// barrierLabel: | ||
| 322 | +// MaterialLocalizations.of(context).modalBarrierDismissLabel, | ||
| 323 | +// transitionDuration: const Duration(milliseconds: 150), | ||
| 324 | +// pageBuilder: (BuildContext context, Animation animation, | ||
| 325 | +// Animation secondaryAnimation) { | ||
| 326 | +// return Column( | ||
| 327 | +// children: [ | ||
| 328 | +// Container( | ||
| 329 | +// height: ScreenUtil().setWidth(100), | ||
| 330 | +// color: Colors.black, | ||
| 331 | +// child: Row( | ||
| 332 | +// children: [ | ||
| 333 | +// Material( | ||
| 334 | +// child: InkWell( | ||
| 335 | +// onTap: () { | ||
| 336 | +// Navigator.pop(context); | ||
| 337 | +// }, | ||
| 338 | +// child: Image.asset(Utils.getImgPath('invication_back')), | ||
| 339 | +// )), | ||
| 340 | +// ], | ||
| 341 | +// ), | ||
| 342 | +// ), | ||
| 343 | + | ||
| 344 | +// // Chewie( | ||
| 345 | +// // controller: chewieController, | ||
| 346 | +// // ), | ||
| 347 | +// IjkPlayer(mediaController: ijkMediaController), | ||
| 348 | +// ], | ||
| 349 | +// ); | ||
| 350 | +// }); | ||
| 351 | +// // Utils.setBarStatus(true, color: Colors.white); | ||
| 352 | +// } | ||
| 353 | + | ||
| 354 | +// @override | ||
| 355 | +// Widget build(BuildContext context) { | ||
| 356 | +// _uploadImageProvider = | ||
| 357 | +// Provider.of<UploadImageProvider>(context, listen: true); | ||
| 358 | +// return _getGridImg( | ||
| 359 | +// _uploadImageProvider.imageList.length < widget.maxImageNumber | ||
| 360 | +// ? _uploadImageProvider.imageList.length + 1 | ||
| 361 | +// : _uploadImageProvider.imageList.length, | ||
| 362 | +// context, | ||
| 363 | +// _uploadImageProvider.imageList.length == widget.maxImageNumber | ||
| 364 | +// ? true | ||
| 365 | +// : false); | ||
| 366 | +// } | ||
| 367 | + | ||
| 368 | +// /// 九宫格 | ||
| 369 | +// Widget _getGridImg(count, context, isLinjie) { | ||
| 370 | +// // return | ||
| 371 | +// // GridView.builder( | ||
| 372 | +// // controller: widget.scrollController, | ||
| 373 | +// // // padding: EdgeInsets.only(top: ScreenUtil().getAdapterSize(10)), | ||
| 374 | +// // shrinkWrap: true, | ||
| 375 | +// // itemCount: count, | ||
| 376 | +// // //SliverGridDelegateWithFixedCrossAxisCount 构建一个横轴固定数量Widget | ||
| 377 | +// // gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( | ||
| 378 | +// // //横轴元素个数 | ||
| 379 | +// // crossAxisCount: 1, | ||
| 380 | +// // //纵轴间距 | ||
| 381 | +// // mainAxisSpacing: ScreenUtil().setWidth(30), | ||
| 382 | +// // //横轴间距 | ||
| 383 | +// // crossAxisSpacing: ScreenUtil().setWidth(30), | ||
| 384 | +// // //子组件宽高长度比例 | ||
| 385 | +// // // childAspectRatio: 1.0 | ||
| 386 | +// // ), | ||
| 387 | +// // itemBuilder: (BuildContext context, int index) { | ||
| 388 | +// //Widget Function(BuildContext context, int index) | ||
| 389 | +// var linjie = widget.maxImageNumber; | ||
| 390 | +// if (isLinjie) { | ||
| 391 | +// linjie = widget.maxImageNumber - 1; | ||
| 392 | +// } | ||
| 393 | +// if (0 == count - 1 && 0 < linjie) { | ||
| 394 | +// return InkWell( | ||
| 395 | +// onTap: () { | ||
| 396 | +// // 触摸收起键盘 | ||
| 397 | +// FocusScope.of(context).requestFocus(FocusNode()); | ||
| 398 | +// _openModalBottomSheet(context); | ||
| 399 | +// }, | ||
| 400 | +// child: Container( | ||
| 401 | +// width: ScreenUtil().setWidth(90 * 2), | ||
| 402 | +// height: ScreenUtil().setWidth(90 * 2), | ||
| 403 | +// decoration: BoxDecoration( | ||
| 404 | +// border: Border.all( | ||
| 405 | +// color: MyColours.color_E0E0E0, | ||
| 406 | +// width: ScreenUtil().setWidth(2)), | ||
| 407 | +// ), | ||
| 408 | +// child: Column( | ||
| 409 | +// children: [ | ||
| 410 | +// VEmptyView(74), | ||
| 411 | +// Image.asset( | ||
| 412 | +// Utils.getImgPath('add_image'), | ||
| 413 | +// width: ScreenUtil().setWidth(32), | ||
| 414 | +// height: ScreenUtil().setWidth(32), | ||
| 415 | +// ), | ||
| 416 | +// VEmptyView(10), | ||
| 417 | +// Text( | ||
| 418 | +// '添加视频', | ||
| 419 | +// style: TextStyle( | ||
| 420 | +// fontSize: ScreenUtil().setSp(24), | ||
| 421 | +// color: MyColours.color_999999), | ||
| 422 | +// ) | ||
| 423 | +// ], | ||
| 424 | +// )), | ||
| 425 | +// ); | ||
| 426 | +// } | ||
| 427 | +// return _uploadImageProvider.imageList.length < 1 | ||
| 428 | +// ? Text('') | ||
| 429 | +// : InkWell( | ||
| 430 | +// onTap: () { | ||
| 431 | +// if (_uploadImageProvider.imageList[0].process == 1) { | ||
| 432 | +// _uploadImageProvider.imageQiniuUrlList = []; | ||
| 433 | +// if (_uploadImageProvider.imageList[0].qiniuUrl != null) { | ||
| 434 | +// for (int i = 0; | ||
| 435 | +// i < _uploadImageProvider.imageList.length; | ||
| 436 | +// i++) { | ||
| 437 | +// _uploadImageProvider.imageQiniuUrlList | ||
| 438 | +// .add(_uploadImageProvider.imageList[i].qiniuUrl); | ||
| 439 | +// } | ||
| 440 | + | ||
| 441 | +// ///没有上传完成的不可以点击 | ||
| 442 | +// // _showPhotoView( | ||
| 443 | +// // context, 0, _uploadImageProvider.imageQiniuUrlList); | ||
| 444 | +// NavigatorUtil.goPlayVideoPage(context, | ||
| 445 | +// urlStr: _uploadImageProvider.imageQiniuUrlList[0]); | ||
| 446 | +// } | ||
| 447 | +// } | ||
| 448 | +// }, | ||
| 449 | +// child: Stack( | ||
| 450 | +// children: [ | ||
| 451 | +// Stack( | ||
| 452 | +// alignment: Alignment.topRight, | ||
| 453 | +// children: [ | ||
| 454 | +// // Image.file( | ||
| 455 | +// // // _uploadImageProvider.imageList[index].file, | ||
| 456 | +// // File(thumbnailPath), | ||
| 457 | +// // fit: BoxFit.cover, | ||
| 458 | +// // width: ScreenUtil().setWidth(100 * 2), | ||
| 459 | +// // height: ScreenUtil().setWidth(100 * 2), | ||
| 460 | +// // ), | ||
| 461 | +// FutureBuilder( | ||
| 462 | +// //显示缩略图 | ||
| 463 | +// future: _initializeVideoPlayerFuture, | ||
| 464 | +// builder: (context, snapshot) { | ||
| 465 | +// print(snapshot.connectionState); | ||
| 466 | +// if (snapshot.hasError) print(snapshot.error); | ||
| 467 | +// if (snapshot.connectionState == ConnectionState.done) { | ||
| 468 | +// return Container( | ||
| 469 | +// width: ScreenUtil().setWidth(225), | ||
| 470 | +// child: AspectRatio( | ||
| 471 | +// // aspectRatio: 1 / 1, | ||
| 472 | +// aspectRatio: _controller.value.aspectRatio, | ||
| 473 | +// child: VideoPlayer(_controller), | ||
| 474 | +// ), | ||
| 475 | +// ); | ||
| 476 | +// } else { | ||
| 477 | +// return Center( | ||
| 478 | +// child: CircularProgressIndicator(), | ||
| 479 | +// ); | ||
| 480 | +// } | ||
| 481 | +// }, | ||
| 482 | +// ), | ||
| 483 | + | ||
| 484 | +// Offstage( | ||
| 485 | +// offstage: _uploadImageProvider.imageList[0].process < 1, | ||
| 486 | +// child: GestureDetector( | ||
| 487 | +// child: Image.asset( | ||
| 488 | +// Utils.getImgPath("delete"), | ||
| 489 | +// width: ScreenUtil().setWidth(40), | ||
| 490 | +// height: ScreenUtil().setWidth(40), | ||
| 491 | +// ), | ||
| 492 | +// onTap: () { | ||
| 493 | +// //点击删除按钮 | ||
| 494 | +// setState(() { | ||
| 495 | +// _uploadImageProvider.imageList.removeWhere( | ||
| 496 | +// (element) => | ||
| 497 | +// element == | ||
| 498 | +// _uploadImageProvider.imageList[0]); | ||
| 499 | +// _uploadImageProvider.imageQiniuUrlList.removeWhere( | ||
| 500 | +// (element) => | ||
| 501 | +// element == | ||
| 502 | +// _uploadImageProvider.imageQiniuUrlList[0]); | ||
| 503 | +// }); | ||
| 504 | +// }, | ||
| 505 | +// ), | ||
| 506 | +// ), | ||
| 507 | +// ], | ||
| 508 | +// ), | ||
| 509 | +// Offstage( | ||
| 510 | +// offstage: _uploadImageProvider.imageList[0].process == 1, | ||
| 511 | +// child: Progress(_uploadImageProvider.imageList[0].process), | ||
| 512 | +// ) | ||
| 513 | +// ], | ||
| 514 | +// )); | ||
| 515 | +// // }); | ||
| 516 | +// } | ||
| 517 | +// } |
| 1 | import 'package:flutter/material.dart'; | 1 | import 'package:flutter/material.dart'; |
| 2 | import 'package:flutter_ijkplayer/flutter_ijkplayer.dart'; | 2 | import 'package:flutter_ijkplayer/flutter_ijkplayer.dart'; |
| 3 | +import 'package:one_key/pages/online_check/progress.dart'; | ||
| 3 | import 'package:one_key/utils/navigator_util.dart'; | 4 | import 'package:one_key/utils/navigator_util.dart'; |
| 4 | import 'package:one_key/widgets/system_app_bar.dart'; | 5 | import 'package:one_key/widgets/system_app_bar.dart'; |
| 6 | +import 'package:video_player/video_player.dart'; | ||
| 5 | 7 | ||
| 6 | class PlayVideoPage extends StatefulWidget { | 8 | class PlayVideoPage extends StatefulWidget { |
| 7 | final String url; | 9 | final String url; |
| @@ -12,28 +14,51 @@ class PlayVideoPage extends StatefulWidget { | @@ -12,28 +14,51 @@ class PlayVideoPage extends StatefulWidget { | ||
| 12 | } | 14 | } |
| 13 | 15 | ||
| 14 | class _PlayVideoPageState extends State<PlayVideoPage> { | 16 | class _PlayVideoPageState extends State<PlayVideoPage> { |
| 15 | - IjkMediaController ijkMediaController = IjkMediaController(); | 17 | + // IjkMediaController ijkMediaController = IjkMediaController(); |
| 16 | 18 | ||
| 19 | + VideoPlayerController _controller; | ||
| 17 | @override | 20 | @override |
| 18 | void initState() { | 21 | void initState() { |
| 19 | // TODO: implement initState | 22 | // TODO: implement initState |
| 20 | super.initState(); | 23 | super.initState(); |
| 21 | - ijkMediaController.setNetworkDataSource( | ||
| 22 | - widget.url, | ||
| 23 | - autoPlay: true, | ||
| 24 | - ); | 24 | + // ijkMediaController.setNetworkDataSource( |
| 25 | + // widget.url, | ||
| 26 | + // autoPlay: true, | ||
| 27 | + // ); | ||
| 28 | + _controller = VideoPlayerController.network(widget.url) | ||
| 29 | + ..initialize().then((_) { | ||
| 30 | + setState(() {}); | ||
| 31 | + }); | ||
| 32 | + _controller.play(); | ||
| 33 | + _controller.setLooping(true); | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + @override | ||
| 37 | + void dispose() { | ||
| 38 | + super.dispose(); | ||
| 39 | + _controller.dispose(); | ||
| 25 | } | 40 | } |
| 26 | 41 | ||
| 27 | @override | 42 | @override |
| 28 | Widget build(BuildContext context) { | 43 | Widget build(BuildContext context) { |
| 29 | return Scaffold( | 44 | return Scaffold( |
| 30 | - appBar: SystemAppBar( | ||
| 31 | - 'cannnn', | ||
| 32 | - onTap: () { | ||
| 33 | - Navigator.pop(context); | ||
| 34 | - }, | ||
| 35 | - ), | ||
| 36 | - body: IjkPlayer(mediaController: ijkMediaController), | ||
| 37 | - ); | 45 | + appBar: SystemAppBar( |
| 46 | + '', | ||
| 47 | + onTap: () { | ||
| 48 | + Navigator.pop(context); | ||
| 49 | + }, | ||
| 50 | + ), | ||
| 51 | + // body: IjkPlayer(mediaController: ijkMediaController), | ||
| 52 | + body: Container( | ||
| 53 | + color: Colors.black, | ||
| 54 | + child: Center( | ||
| 55 | + child: _controller.value.initialized | ||
| 56 | + ? AspectRatio( | ||
| 57 | + aspectRatio: _controller.value.aspectRatio, | ||
| 58 | + child: VideoPlayer(_controller), | ||
| 59 | + ) | ||
| 60 | + : CircularProgressIndicator(), | ||
| 61 | + ), | ||
| 62 | + )); | ||
| 38 | } | 63 | } |
| 39 | } | 64 | } |
| 1 | -import 'dart:convert'; | ||
| 2 | - | ||
| 3 | import 'dart:io'; | 1 | import 'dart:io'; |
| 4 | import 'dart:async'; | 2 | import 'dart:async'; |
| 5 | 3 | ||
| 6 | -import 'package:cached_network_image/cached_network_image.dart'; | ||
| 7 | import 'package:flutter/material.dart'; | 4 | import 'package:flutter/material.dart'; |
| 8 | import 'package:flutter_ijkplayer/flutter_ijkplayer.dart'; | 5 | import 'package:flutter_ijkplayer/flutter_ijkplayer.dart'; |
| 9 | import 'package:flutter_screenutil/flutter_screenutil.dart'; | 6 | import 'package:flutter_screenutil/flutter_screenutil.dart'; |
| @@ -11,11 +8,9 @@ import 'package:one_key/models/upload_img_model.dart'; | @@ -11,11 +8,9 @@ import 'package:one_key/models/upload_img_model.dart'; | ||
| 11 | import 'package:one_key/pages/online_check/photo_view_wiget.dart'; | 8 | import 'package:one_key/pages/online_check/photo_view_wiget.dart'; |
| 12 | import 'package:one_key/pages/online_check/progress.dart'; | 9 | import 'package:one_key/pages/online_check/progress.dart'; |
| 13 | 10 | ||
| 14 | -import 'package:one_key/provider/online_check_edit_provider.dart'; | ||
| 15 | import 'package:one_key/provider/upload_img_provider.dart'; | 11 | import 'package:one_key/provider/upload_img_provider.dart'; |
| 16 | import 'package:one_key/res/colors.dart'; | 12 | import 'package:one_key/res/colors.dart'; |
| 17 | -import 'package:one_key/utils/dialog_util.dart'; | ||
| 18 | -import 'package:one_key/utils/misc.dart'; | 13 | + |
| 19 | import 'package:one_key/utils/navigator_util.dart'; | 14 | import 'package:one_key/utils/navigator_util.dart'; |
| 20 | import 'package:one_key/utils/upload_image_util.dart'; | 15 | import 'package:one_key/utils/upload_image_util.dart'; |
| 21 | import 'package:one_key/utils/utils.dart'; | 16 | import 'package:one_key/utils/utils.dart'; |
| @@ -23,15 +18,12 @@ import 'package:one_key/widgets/MyDivider.dart'; | @@ -23,15 +18,12 @@ import 'package:one_key/widgets/MyDivider.dart'; | ||
| 23 | import 'package:one_key/widgets/v_empty_view.dart'; | 18 | import 'package:one_key/widgets/v_empty_view.dart'; |
| 24 | import 'package:permission_handler/permission_handler.dart'; | 19 | import 'package:permission_handler/permission_handler.dart'; |
| 25 | import 'package:photo/photo.dart'; | 20 | import 'package:photo/photo.dart'; |
| 26 | -import 'package:provider/provider.dart'; | ||
| 27 | 21 | ||
| 28 | import 'package:image_picker/image_picker.dart'; | 22 | import 'package:image_picker/image_picker.dart'; |
| 29 | import 'package:qiniu_flutter_sdk/qiniu_flutter_sdk.dart'; | 23 | import 'package:qiniu_flutter_sdk/qiniu_flutter_sdk.dart'; |
| 30 | -import 'package:video_player/video_player.dart'; | ||
| 31 | import '../online_check/dispose.dart'; | 24 | import '../online_check/dispose.dart'; |
| 32 | import 'package:photo_manager/photo_manager.dart'; | 25 | import 'package:photo_manager/photo_manager.dart'; |
| 33 | -// import 'package:video_thumbnail/video_thumbnail.dart'; | ||
| 34 | -import 'package:chewie/chewie.dart'; | 26 | +import 'package:video_compress/video_compress.dart'; |
| 35 | 27 | ||
| 36 | typedef void OnPickImageCallback( | 28 | typedef void OnPickImageCallback( |
| 37 | double maxWidth, double maxHeight, int quality); | 29 | double maxWidth, double maxHeight, int quality); |
| @@ -41,12 +33,14 @@ class VideoPickerWidget extends StatefulWidget { | @@ -41,12 +33,14 @@ class VideoPickerWidget extends StatefulWidget { | ||
| 41 | final Color borderColor; | 33 | final Color borderColor; |
| 42 | final ValueChanged onChange; | 34 | final ValueChanged onChange; |
| 43 | final int maxImageNumber; | 35 | final int maxImageNumber; |
| 36 | + final UploadImageProvider model; | ||
| 44 | VideoPickerWidget( | 37 | VideoPickerWidget( |
| 45 | {Key key, | 38 | {Key key, |
| 46 | this.scrollController, | 39 | this.scrollController, |
| 47 | this.borderColor = Colors.blue, | 40 | this.borderColor = Colors.blue, |
| 48 | this.onChange, | 41 | this.onChange, |
| 49 | - this.maxImageNumber = 5}) | 42 | + this.maxImageNumber = 5, |
| 43 | + this.model}) | ||
| 50 | : super(key: key); | 44 | : super(key: key); |
| 51 | 45 | ||
| 52 | @override | 46 | @override |
| @@ -55,8 +49,6 @@ class VideoPickerWidget extends StatefulWidget { | @@ -55,8 +49,6 @@ class VideoPickerWidget extends StatefulWidget { | ||
| 55 | 49 | ||
| 56 | class _VideoPickerWidgetState extends DisposableState<VideoPickerWidget> { | 50 | class _VideoPickerWidgetState extends DisposableState<VideoPickerWidget> { |
| 57 | final picker = ImagePicker(); | 51 | final picker = ImagePicker(); |
| 58 | - // OnlineCheckEditProvider _onlineCheckEditProvider; | ||
| 59 | - UploadImageProvider _uploadImageProvider; | ||
| 60 | 52 | ||
| 61 | // 用户输入的文件名 | 53 | // 用户输入的文件名 |
| 62 | String key; | 54 | String key; |
| @@ -71,63 +63,65 @@ class _VideoPickerWidgetState extends DisposableState<VideoPickerWidget> { | @@ -71,63 +63,65 @@ class _VideoPickerWidgetState extends DisposableState<VideoPickerWidget> { | ||
| 71 | // PutController putController = PutController(); | 63 | // PutController putController = PutController(); |
| 72 | // 当前的任务状态 | 64 | // 当前的任务状态 |
| 73 | 65 | ||
| 74 | - // String thumbnailPath; | ||
| 75 | - VideoPlayerController _controller; | ||
| 76 | - Future _initializeVideoPlayerFuture; | ||
| 77 | - | ||
| 78 | - // 声明控制器(两个) | ||
| 79 | - VideoPlayerController videoPlayerController; | ||
| 80 | - ChewieController chewieController; | ||
| 81 | - IjkMediaController ijkMediaController = IjkMediaController(); | ||
| 82 | - | ||
| 83 | @override | 66 | @override |
| 84 | void initState() { | 67 | void initState() { |
| 85 | - // storage = Storage(); | ||
| 86 | - // putController = PutController(); | ||
| 87 | super.initState(); | 68 | super.initState(); |
| 88 | - | ||
| 89 | - // _controller.setLooping(false); | ||
| 90 | - // 生成控制器(两个) | ||
| 91 | - } | ||
| 92 | - | ||
| 93 | - @override | ||
| 94 | - void dispose() { | ||
| 95 | - super.dispose(); | ||
| 96 | - // 销毁播放器的控制器 | ||
| 97 | - _controller.dispose(); | ||
| 98 | - chewieController.dispose(); | ||
| 99 | } | 69 | } |
| 100 | 70 | ||
| 101 | ///#相机拍照,单图选择 | 71 | ///#相机拍照,单图选择 |
| 102 | - Future _getFromPictureOrCamera(imageSource) async { | ||
| 103 | - final pickedFile = await picker.getVideo( | ||
| 104 | - source: imageSource, maxDuration: const Duration(seconds: 15)); | ||
| 105 | - // thumbnailPath = await VideoThumbnail.thumbnailFile( | ||
| 106 | - // video: pickedFile.path, | ||
| 107 | - // imageFormat: ImageFormat.PNG, | ||
| 108 | - // maxWidth: 128, | ||
| 109 | - // quality: 25); | ||
| 110 | - | ||
| 111 | - // print(thumbnailPath); | ||
| 112 | - _controller = VideoPlayerController.file(File(pickedFile.path)); | ||
| 113 | - _initializeVideoPlayerFuture = _controller.initialize(); | 72 | + //////#相机拍照,单图选择 |
| 73 | + Future _getImageFromPictureOrCamera(ImageSource imageSource) async { | ||
| 74 | + final pickedFile = await picker.getImage(source: imageSource); | ||
| 114 | setState(() { | 75 | setState(() { |
| 115 | if (pickedFile != null) { | 76 | if (pickedFile != null) { |
| 116 | UploadImgModel imgModel = UploadImgModel(); | 77 | UploadImgModel imgModel = UploadImgModel(); |
| 117 | imgModel.file = File(pickedFile.path); | 78 | imgModel.file = File(pickedFile.path); |
| 118 | imgModel.process = 0.01; | 79 | imgModel.process = 0.01; |
| 119 | - _uploadImageProvider.imageList.add(imgModel); | 80 | + imgModel.fileType = FileType.image; |
| 81 | + widget.model.imageList.add(imgModel); | ||
| 120 | } else { | 82 | } else { |
| 121 | print('No image selected.'); | 83 | print('No image selected.'); |
| 122 | } | 84 | } |
| 123 | }); | 85 | }); |
| 124 | if (pickedFile != null) { | 86 | if (pickedFile != null) { |
| 125 | - UploadImageUtil().startUpload( | ||
| 126 | - context, | ||
| 127 | - File(pickedFile.path), | ||
| 128 | - _uploadImageProvider.imageList.length - 1, | ||
| 129 | - true, | ||
| 130 | - _uploadImageProvider); | 87 | + UploadImageUtil().startUpload(context, File(pickedFile.path), |
| 88 | + widget.model.imageList.length - 1, true, widget.model); | ||
| 89 | + } | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + ///视频 | ||
| 93 | + Future _getVideoFromPictureOrCamera(ImageSource imageSource) async { | ||
| 94 | + final pickedFile = await picker.getVideo( | ||
| 95 | + source: imageSource, maxDuration: const Duration(seconds: 15)); | ||
| 96 | + | ||
| 97 | + await VideoCompress.setLogLevel(0); | ||
| 98 | + final info = await VideoCompress.getMediaInfo(pickedFile.path); | ||
| 99 | + String duration = '00'; | ||
| 100 | + if (info != null) { | ||
| 101 | + if (info.duration > 15000 || info.duration < 11000) { | ||
| 102 | + Utils.showToast('请选择10~15s的视频'); | ||
| 103 | + return; | ||
| 104 | + } | ||
| 105 | + duration = Utils.addZeroNumber((info.duration / 1000).round()); | ||
| 106 | + } | ||
| 107 | + File thumbnailPath = await VideoCompress.getFileThumbnail(pickedFile.path, | ||
| 108 | + quality: 100, // default(100) | ||
| 109 | + position: -1 // default(-1) | ||
| 110 | + ); | ||
| 111 | + | ||
| 112 | + if (pickedFile != null) { | ||
| 113 | + UploadImgModel imgModel = UploadImgModel(); | ||
| 114 | + imgModel.file = File(pickedFile.path); | ||
| 115 | + imgModel.process = 0.01; | ||
| 116 | + imgModel.fileType = FileType.video; | ||
| 117 | + imgModel.thumbnailPath = thumbnailPath; | ||
| 118 | + imgModel.duration = duration; | ||
| 119 | + widget.model.imageList.add(imgModel); | ||
| 120 | + setState(() {}); | ||
| 121 | + UploadImageUtil().startUpload(context, File(pickedFile.path), | ||
| 122 | + widget.model.imageList.length - 1, true, widget.model); | ||
| 123 | + } else { | ||
| 124 | + print('No image selected.'); | ||
| 131 | } | 125 | } |
| 132 | } | 126 | } |
| 133 | 127 | ||
| @@ -151,8 +145,7 @@ class _VideoPickerWidgetState extends DisposableState<VideoPickerWidget> { | @@ -151,8 +145,7 @@ class _VideoPickerWidgetState extends DisposableState<VideoPickerWidget> { | ||
| 151 | // the check box disable color | 145 | // the check box disable color |
| 152 | itemRadio: 0.88, | 146 | itemRadio: 0.88, |
| 153 | // the content item radio | 147 | // the content item radio |
| 154 | - maxSelected: | ||
| 155 | - widget.maxImageNumber - _uploadImageProvider.imageList.length, | 148 | + maxSelected: widget.maxImageNumber - widget.model.imageList.length, |
| 156 | // max picker image count | 149 | // max picker image count |
| 157 | // provider: I18nProvider.english, | 150 | // provider: I18nProvider.english, |
| 158 | provider: I18nProvider.chinese, | 151 | provider: I18nProvider.chinese, |
| @@ -186,14 +179,11 @@ class _VideoPickerWidgetState extends DisposableState<VideoPickerWidget> { | @@ -186,14 +179,11 @@ class _VideoPickerWidgetState extends DisposableState<VideoPickerWidget> { | ||
| 186 | UploadImgModel imgModel = UploadImgModel(); | 179 | UploadImgModel imgModel = UploadImgModel(); |
| 187 | imgModel.file = File(file.absolute.path); | 180 | imgModel.file = File(file.absolute.path); |
| 188 | imgModel.process = 0.01; | 181 | imgModel.process = 0.01; |
| 189 | - _uploadImageProvider.imageList.add(imgModel); | 182 | + imgModel.fileType = FileType.image; |
| 183 | + widget.model.imageList.add(imgModel); | ||
| 190 | }); | 184 | }); |
| 191 | - UploadImageUtil().startUpload( | ||
| 192 | - context, | ||
| 193 | - File(file.absolute.path), | ||
| 194 | - _uploadImageProvider.imageList.length - 1, | ||
| 195 | - false, | ||
| 196 | - _uploadImageProvider); | 185 | + UploadImageUtil().startUpload(context, File(file.absolute.path), |
| 186 | + widget.model.imageList.length - 1, false, widget.model); | ||
| 197 | // startUpload(File(file.absolute.path), | 187 | // startUpload(File(file.absolute.path), |
| 198 | // _uploadImageProvider.imageList.length - 1, false); | 188 | // _uploadImageProvider.imageList.length - 1, false); |
| 199 | } | 189 | } |
| @@ -201,7 +191,7 @@ class _VideoPickerWidgetState extends DisposableState<VideoPickerWidget> { | @@ -201,7 +191,7 @@ class _VideoPickerWidgetState extends DisposableState<VideoPickerWidget> { | ||
| 201 | } | 191 | } |
| 202 | 192 | ||
| 203 | ///添加图片UI弹出 | 193 | ///添加图片UI弹出 |
| 204 | - Future _openModalBottomSheet(context) async { | 194 | + Future _openModalBottomSheet(context, FileType fileType) async { |
| 205 | final option = await showModalBottomSheet( | 195 | final option = await showModalBottomSheet( |
| 206 | context: context, | 196 | context: context, |
| 207 | backgroundColor: Colors.transparent, | 197 | backgroundColor: Colors.transparent, |
| @@ -220,7 +210,12 @@ class _VideoPickerWidgetState extends DisposableState<VideoPickerWidget> { | @@ -220,7 +210,12 @@ class _VideoPickerWidgetState extends DisposableState<VideoPickerWidget> { | ||
| 220 | InkWell( | 210 | InkWell( |
| 221 | onTap: () { | 211 | onTap: () { |
| 222 | Utils.getPickPermission(context, () { | 212 | Utils.getPickPermission(context, () { |
| 223 | - _getFromPictureOrCamera(ImageSource.camera); | 213 | + if (fileType == FileType.image) { |
| 214 | + _getImageFromPictureOrCamera(ImageSource.camera); | ||
| 215 | + } else { | ||
| 216 | + _getVideoFromPictureOrCamera(ImageSource.camera); | ||
| 217 | + } | ||
| 218 | + | ||
| 224 | Navigator.pop(context); | 219 | Navigator.pop(context); |
| 225 | }, PermissionGroup.camera); | 220 | }, PermissionGroup.camera); |
| 226 | }, | 221 | }, |
| @@ -245,8 +240,13 @@ class _VideoPickerWidgetState extends DisposableState<VideoPickerWidget> { | @@ -245,8 +240,13 @@ class _VideoPickerWidgetState extends DisposableState<VideoPickerWidget> { | ||
| 245 | InkWell( | 240 | InkWell( |
| 246 | onTap: () { | 241 | onTap: () { |
| 247 | Utils.getPickPermission(context, () { | 242 | Utils.getPickPermission(context, () { |
| 248 | - // pickAsset(PickType.onlyVideo); | ||
| 249 | - _getFromPictureOrCamera(ImageSource.gallery); | 243 | + if (fileType == FileType.image) { |
| 244 | + pickAsset(PickType.onlyImage); | ||
| 245 | + } else { | ||
| 246 | + _getVideoFromPictureOrCamera(ImageSource.gallery); | ||
| 247 | + } | ||
| 248 | + // // | ||
| 249 | + // _getFromPictureOrCamera(ImageSource.gallery); | ||
| 250 | Navigator.pop(context); | 250 | Navigator.pop(context); |
| 251 | }, PermissionGroup.photos); | 251 | }, PermissionGroup.photos); |
| 252 | }, | 252 | }, |
| @@ -290,6 +290,16 @@ class _VideoPickerWidgetState extends DisposableState<VideoPickerWidget> { | @@ -290,6 +290,16 @@ class _VideoPickerWidgetState extends DisposableState<VideoPickerWidget> { | ||
| 290 | }); | 290 | }); |
| 291 | } | 291 | } |
| 292 | 292 | ||
| 293 | + @override | ||
| 294 | + Widget build(BuildContext context) { | ||
| 295 | + return _getGridImg( | ||
| 296 | + widget.model.imageList.length < widget.maxImageNumber | ||
| 297 | + ? widget.model.imageList.length + 2 | ||
| 298 | + : widget.model.imageList.length, | ||
| 299 | + context, | ||
| 300 | + widget.model.imageList.length == widget.maxImageNumber ? true : false); | ||
| 301 | + } | ||
| 302 | + | ||
| 293 | //查看大图 | 303 | //查看大图 |
| 294 | _showPhotoView(BuildContext context, int index, List imgs, | 304 | _showPhotoView(BuildContext context, int index, List imgs, |
| 295 | {isShow = false, List dashName}) async { | 305 | {isShow = false, List dashName}) async { |
| @@ -298,220 +308,253 @@ class _VideoPickerWidgetState extends DisposableState<VideoPickerWidget> { | @@ -298,220 +308,253 @@ class _VideoPickerWidgetState extends DisposableState<VideoPickerWidget> { | ||
| 298 | // 'http://nosqn.colorcun.com/custom/lite-online/image/def-banner.png') { | 308 | // 'http://nosqn.colorcun.com/custom/lite-online/image/def-banner.png') { |
| 299 | // imgs[0] = 'http://nosqn.colorcun.com/app/seller-hj-empty.png'; | 309 | // imgs[0] = 'http://nosqn.colorcun.com/app/seller-hj-empty.png'; |
| 300 | // } | 310 | // } |
| 301 | - // _controller = VideoPlayerController.network(imgs[index]); | ||
| 302 | - // chewieController = ChewieController( | ||
| 303 | - // videoPlayerController: _controller, | ||
| 304 | - // // 比例 | ||
| 305 | - // // aspectRatio: 16 / 9, | ||
| 306 | - // // 自动播放 | ||
| 307 | - // autoPlay: true, | ||
| 308 | - // // 循环 | ||
| 309 | - // looping: true, | ||
| 310 | - // ); | ||
| 311 | - | ||
| 312 | - ijkMediaController.setNetworkDataSource( | ||
| 313 | - imgs[index], | ||
| 314 | - autoPlay: true, | ||
| 315 | - ); | ||
| 316 | Utils.setBarStatus(false, color: Colors.black); | 311 | Utils.setBarStatus(false, color: Colors.black); |
| 317 | dynamic result = await showGeneralDialog( | 312 | dynamic result = await showGeneralDialog( |
| 318 | context: context, | 313 | context: context, |
| 319 | barrierDismissible: false, | 314 | barrierDismissible: false, |
| 320 | - barrierColor: Colors.black, | 315 | + // barrierColor: Colors.red, |
| 321 | barrierLabel: | 316 | barrierLabel: |
| 322 | MaterialLocalizations.of(context).modalBarrierDismissLabel, | 317 | MaterialLocalizations.of(context).modalBarrierDismissLabel, |
| 323 | transitionDuration: const Duration(milliseconds: 150), | 318 | transitionDuration: const Duration(milliseconds: 150), |
| 324 | pageBuilder: (BuildContext context, Animation animation, | 319 | pageBuilder: (BuildContext context, Animation animation, |
| 325 | Animation secondaryAnimation) { | 320 | Animation secondaryAnimation) { |
| 326 | - return Column( | ||
| 327 | - children: [ | ||
| 328 | - Container( | ||
| 329 | - height: ScreenUtil().setWidth(100), | ||
| 330 | - color: Colors.black, | ||
| 331 | - child: Row( | ||
| 332 | - children: [ | ||
| 333 | - Material( | ||
| 334 | - child: InkWell( | ||
| 335 | - onTap: () { | ||
| 336 | - Navigator.pop(context); | ||
| 337 | - }, | ||
| 338 | - child: Image.asset(Utils.getImgPath('invication_back')), | ||
| 339 | - )), | ||
| 340 | - ], | ||
| 341 | - ), | ||
| 342 | - ), | ||
| 343 | - | ||
| 344 | - // Chewie( | ||
| 345 | - // controller: chewieController, | ||
| 346 | - // ), | ||
| 347 | - IjkPlayer(mediaController: ijkMediaController), | 321 | + Widget child = Stack( |
| 322 | + children: <Widget>[ | ||
| 323 | + PhotoPreview( | ||
| 324 | + initialIndex: index, | ||
| 325 | + photoList: imgs, | ||
| 326 | + isShow: isShow, | ||
| 327 | + dashName: dashName) | ||
| 348 | ], | 328 | ], |
| 349 | ); | 329 | ); |
| 330 | + return child; | ||
| 350 | }); | 331 | }); |
| 351 | - // Utils.setBarStatus(true, color: Colors.white); | ||
| 352 | - } | ||
| 353 | - | ||
| 354 | - @override | ||
| 355 | - Widget build(BuildContext context) { | ||
| 356 | - _uploadImageProvider = | ||
| 357 | - Provider.of<UploadImageProvider>(context, listen: true); | ||
| 358 | - return _getGridImg( | ||
| 359 | - _uploadImageProvider.imageList.length < widget.maxImageNumber | ||
| 360 | - ? _uploadImageProvider.imageList.length + 1 | ||
| 361 | - : _uploadImageProvider.imageList.length, | ||
| 362 | - context, | ||
| 363 | - _uploadImageProvider.imageList.length == widget.maxImageNumber | ||
| 364 | - ? true | ||
| 365 | - : false); | 332 | + Utils.setBarStatus(true, color: Colors.white); |
| 366 | } | 333 | } |
| 367 | 334 | ||
| 368 | /// 九宫格 | 335 | /// 九宫格 |
| 369 | Widget _getGridImg(count, context, isLinjie) { | 336 | Widget _getGridImg(count, context, isLinjie) { |
| 370 | - // return | ||
| 371 | - // GridView.builder( | ||
| 372 | - // controller: widget.scrollController, | ||
| 373 | - // // padding: EdgeInsets.only(top: ScreenUtil().getAdapterSize(10)), | ||
| 374 | - // shrinkWrap: true, | ||
| 375 | - // itemCount: count, | ||
| 376 | - // //SliverGridDelegateWithFixedCrossAxisCount 构建一个横轴固定数量Widget | ||
| 377 | - // gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( | ||
| 378 | - // //横轴元素个数 | ||
| 379 | - // crossAxisCount: 1, | ||
| 380 | - // //纵轴间距 | ||
| 381 | - // mainAxisSpacing: ScreenUtil().setWidth(30), | ||
| 382 | - // //横轴间距 | ||
| 383 | - // crossAxisSpacing: ScreenUtil().setWidth(30), | ||
| 384 | - // //子组件宽高长度比例 | ||
| 385 | - // // childAspectRatio: 1.0 | ||
| 386 | - // ), | ||
| 387 | - // itemBuilder: (BuildContext context, int index) { | ||
| 388 | - //Widget Function(BuildContext context, int index) | ||
| 389 | - var linjie = widget.maxImageNumber; | ||
| 390 | - if (isLinjie) { | ||
| 391 | - linjie = widget.maxImageNumber - 1; | ||
| 392 | - } | ||
| 393 | - if (0 == count - 1 && 0 < linjie) { | ||
| 394 | - return InkWell( | ||
| 395 | - onTap: () { | ||
| 396 | - // 触摸收起键盘 | ||
| 397 | - FocusScope.of(context).requestFocus(FocusNode()); | ||
| 398 | - _openModalBottomSheet(context); | ||
| 399 | - }, | ||
| 400 | - child: Container( | ||
| 401 | - width: ScreenUtil().setWidth(90 * 2), | ||
| 402 | - height: ScreenUtil().setWidth(90 * 2), | ||
| 403 | - decoration: BoxDecoration( | ||
| 404 | - border: Border.all( | ||
| 405 | - color: MyColours.color_E0E0E0, | ||
| 406 | - width: ScreenUtil().setWidth(2)), | ||
| 407 | - ), | ||
| 408 | - child: Column( | ||
| 409 | - children: [ | ||
| 410 | - VEmptyView(74), | ||
| 411 | - Image.asset( | ||
| 412 | - Utils.getImgPath('add_image'), | ||
| 413 | - width: ScreenUtil().setWidth(32), | ||
| 414 | - height: ScreenUtil().setWidth(32), | ||
| 415 | - ), | ||
| 416 | - VEmptyView(10), | ||
| 417 | - Text( | ||
| 418 | - '添加视频', | ||
| 419 | - style: TextStyle( | ||
| 420 | - fontSize: ScreenUtil().setSp(24), | ||
| 421 | - color: MyColours.color_999999), | ||
| 422 | - ) | ||
| 423 | - ], | ||
| 424 | - )), | ||
| 425 | - ); | ||
| 426 | - } | ||
| 427 | - return _uploadImageProvider.imageList.length < 1 | ||
| 428 | - ? Text('') | ||
| 429 | - : InkWell( | ||
| 430 | - onTap: () { | ||
| 431 | - if (_uploadImageProvider.imageList[0].process == 1) { | ||
| 432 | - _uploadImageProvider.imageQiniuUrlList = []; | ||
| 433 | - if (_uploadImageProvider.imageList[0].qiniuUrl != null) { | ||
| 434 | - for (int i = 0; | ||
| 435 | - i < _uploadImageProvider.imageList.length; | ||
| 436 | - i++) { | ||
| 437 | - _uploadImageProvider.imageQiniuUrlList | ||
| 438 | - .add(_uploadImageProvider.imageList[i].qiniuUrl); | ||
| 439 | - } | 337 | + return GridView.builder( |
| 338 | + controller: widget.scrollController, | ||
| 339 | + // padding: EdgeInsets.only(top: ScreenUtil().getAdapterSize(10)), | ||
| 340 | + shrinkWrap: true, | ||
| 341 | + itemCount: count, | ||
| 342 | + //SliverGridDelegateWithFixedCrossAxisCount 构建一个横轴固定数量Widget | ||
| 343 | + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( | ||
| 344 | + //横轴元素个数 | ||
| 345 | + crossAxisCount: 3, | ||
| 346 | + //纵轴间距 | ||
| 347 | + mainAxisSpacing: ScreenUtil().setWidth(30), | ||
| 348 | + //横轴间距 | ||
| 349 | + crossAxisSpacing: ScreenUtil().setWidth(30), | ||
| 350 | + //子组件宽高长度比例 | ||
| 351 | + childAspectRatio: 1.0), | ||
| 352 | + itemBuilder: (BuildContext context, int index) { | ||
| 353 | + var linjie = widget.maxImageNumber; | ||
| 354 | + if (isLinjie) { | ||
| 355 | + linjie = widget.maxImageNumber - 2; | ||
| 356 | + } | ||
| 357 | + if (index == count - 2 && index < linjie) { | ||
| 358 | + return InkWell( | ||
| 359 | + onTap: () { | ||
| 360 | + // 触摸收起键盘 | ||
| 361 | + FocusScope.of(context).requestFocus(FocusNode()); | ||
| 362 | + _openModalBottomSheet(context, FileType.image); | ||
| 363 | + }, | ||
| 364 | + child: Container( | ||
| 365 | + width: ScreenUtil().setWidth(90 * 2), | ||
| 366 | + height: ScreenUtil().setWidth(90 * 2), | ||
| 367 | + decoration: BoxDecoration( | ||
| 368 | + border: Border.all( | ||
| 369 | + color: MyColours.color_E0E0E0, | ||
| 370 | + width: ScreenUtil().setWidth(2)), | ||
| 371 | + ), | ||
| 372 | + child: Column( | ||
| 373 | + children: [ | ||
| 374 | + VEmptyView(74), | ||
| 375 | + Image.asset( | ||
| 376 | + Utils.getImgPath('add_image'), | ||
| 377 | + width: ScreenUtil().setWidth(32), | ||
| 378 | + height: ScreenUtil().setWidth(32), | ||
| 379 | + ), | ||
| 380 | + VEmptyView(10), | ||
| 381 | + Text( | ||
| 382 | + '添加图片', | ||
| 383 | + style: TextStyle( | ||
| 384 | + fontSize: ScreenUtil().setSp(24), | ||
| 385 | + color: MyColours.color_999999), | ||
| 386 | + ) | ||
| 387 | + ], | ||
| 388 | + )), | ||
| 389 | + ); | ||
| 390 | + } | ||
| 391 | + if (index == count - 1 && index <= linjie) { | ||
| 392 | + return InkWell( | ||
| 393 | + onTap: () { | ||
| 394 | + // 触摸收起键盘 | ||
| 395 | + FocusScope.of(context).requestFocus(FocusNode()); | ||
| 396 | + _openModalBottomSheet(context, FileType.video); | ||
| 397 | + }, | ||
| 398 | + child: Container( | ||
| 399 | + width: ScreenUtil().setWidth(90 * 2), | ||
| 400 | + height: ScreenUtil().setWidth(90 * 2), | ||
| 401 | + decoration: BoxDecoration( | ||
| 402 | + border: Border.all( | ||
| 403 | + color: MyColours.color_E0E0E0, | ||
| 404 | + width: ScreenUtil().setWidth(2)), | ||
| 405 | + ), | ||
| 406 | + child: Column( | ||
| 407 | + children: [ | ||
| 408 | + VEmptyView(74), | ||
| 409 | + Image.asset( | ||
| 410 | + Utils.getImgPath('add_image'), | ||
| 411 | + width: ScreenUtil().setWidth(32), | ||
| 412 | + height: ScreenUtil().setWidth(32), | ||
| 413 | + ), | ||
| 414 | + VEmptyView(10), | ||
| 415 | + Text( | ||
| 416 | + '添加视频', | ||
| 417 | + style: TextStyle( | ||
| 418 | + fontSize: ScreenUtil().setSp(24), | ||
| 419 | + color: MyColours.color_999999), | ||
| 420 | + ) | ||
| 421 | + ], | ||
| 422 | + )), | ||
| 423 | + ); | ||
| 424 | + } | ||
| 440 | 425 | ||
| 441 | - ///没有上传完成的不可以点击 | ||
| 442 | - // _showPhotoView( | ||
| 443 | - // context, 0, _uploadImageProvider.imageQiniuUrlList); | ||
| 444 | - NavigatorUtil.goPlayVideoPage(context, | ||
| 445 | - urlStr: _uploadImageProvider.imageQiniuUrlList[0]); | ||
| 446 | - } | ||
| 447 | - } | ||
| 448 | - }, | ||
| 449 | - child: Stack( | ||
| 450 | - children: [ | ||
| 451 | - Stack( | ||
| 452 | - alignment: Alignment.topRight, | ||
| 453 | - children: [ | ||
| 454 | - // Image.file( | ||
| 455 | - // // _uploadImageProvider.imageList[index].file, | ||
| 456 | - // File(thumbnailPath), | ||
| 457 | - // fit: BoxFit.cover, | ||
| 458 | - // width: ScreenUtil().setWidth(100 * 2), | ||
| 459 | - // height: ScreenUtil().setWidth(100 * 2), | ||
| 460 | - // ), | ||
| 461 | - FutureBuilder( | ||
| 462 | - //显示缩略图 | ||
| 463 | - future: _initializeVideoPlayerFuture, | ||
| 464 | - builder: (context, snapshot) { | ||
| 465 | - print(snapshot.connectionState); | ||
| 466 | - if (snapshot.hasError) print(snapshot.error); | ||
| 467 | - if (snapshot.connectionState == ConnectionState.done) { | ||
| 468 | - return Container( | ||
| 469 | - width: ScreenUtil().setWidth(225), | ||
| 470 | - child: AspectRatio( | ||
| 471 | - // aspectRatio: 1 / 1, | ||
| 472 | - aspectRatio: _controller.value.aspectRatio, | ||
| 473 | - child: VideoPlayer(_controller), | ||
| 474 | - ), | ||
| 475 | - ); | ||
| 476 | - } else { | ||
| 477 | - return Center( | ||
| 478 | - child: CircularProgressIndicator(), | ||
| 479 | - ); | 426 | + return widget.model.imageList.length < 1 |
| 427 | + ? Text('') | ||
| 428 | + : InkWell( | ||
| 429 | + onTap: () { | ||
| 430 | + if (widget.model.imageList[index].process == 1) { | ||
| 431 | + widget.model.imageQiniuUrlList = []; | ||
| 432 | + if (widget.model.imageList[index].qiniuUrl != null) { | ||
| 433 | + if (widget.model.imageList[index].fileType == | ||
| 434 | + FileType.image) { | ||
| 435 | + List<UploadImgModel> temp = []; | ||
| 436 | + temp.addAll(widget.model.imageList); | ||
| 437 | + temp.removeWhere( | ||
| 438 | + (element) => element.fileType == FileType.video); | ||
| 439 | + for (int i = 0; i < temp.length; i++) { | ||
| 440 | + widget.model.imageQiniuUrlList | ||
| 441 | + .add(temp[i].qiniuUrl); | ||
| 442 | + } | ||
| 443 | + | ||
| 444 | + ///没有上传完成的不可以点击 | ||
| 445 | + _showPhotoView( | ||
| 446 | + context, index, widget.model.imageQiniuUrlList); | ||
| 447 | + } else if (widget.model.imageList[index].fileType == | ||
| 448 | + FileType.video) { | ||
| 449 | + NavigatorUtil.goPlayVideoPage(context, | ||
| 450 | + urlStr: widget.model.imageList[index].qiniuUrl); | ||
| 480 | } | 451 | } |
| 481 | - }, | ||
| 482 | - ), | 452 | + } |
| 453 | + } | ||
| 454 | + }, | ||
| 455 | + child: Stack( | ||
| 456 | + children: [ | ||
| 457 | + Stack( | ||
| 458 | + alignment: Alignment.topRight, | ||
| 459 | + children: [ | ||
| 460 | + widget.model.imageList[index].fileType == | ||
| 461 | + FileType.image | ||
| 462 | + ? Image.file( | ||
| 463 | + widget.model.imageList[index].file, | ||
| 464 | + fit: BoxFit.cover, | ||
| 465 | + width: ScreenUtil().setWidth(100 * 2), | ||
| 466 | + height: ScreenUtil().setWidth(100 * 2), | ||
| 467 | + ) | ||
| 468 | + : Image.file( | ||
| 469 | + widget.model.imageList[index].thumbnailPath, | ||
| 470 | + fit: BoxFit.cover, | ||
| 471 | + width: ScreenUtil().setWidth(100 * 2), | ||
| 472 | + height: ScreenUtil().setWidth(100 * 2), | ||
| 473 | + ) | ||
| 474 | + // : FutureBuilder( | ||
| 475 | + // //显示缩略图 | ||
| 476 | + // future: _initializeVideoPlayerFuture, | ||
| 477 | + // builder: (context, snapshot) { | ||
| 478 | + // print(snapshot.connectionState); | ||
| 479 | + // if (snapshot.hasError) | ||
| 480 | + // print(snapshot.error); | ||
| 481 | + // if (snapshot.connectionState == | ||
| 482 | + // ConnectionState.done) { | ||
| 483 | + // return Container( | ||
| 484 | + // // width: ScreenUtil().setWidth(225), | ||
| 485 | + // child: AspectRatio( | ||
| 486 | + // aspectRatio: 1 / 1, | ||
| 483 | 487 | ||
| 484 | - Offstage( | ||
| 485 | - offstage: _uploadImageProvider.imageList[0].process < 1, | ||
| 486 | - child: GestureDetector( | ||
| 487 | - child: Image.asset( | ||
| 488 | - Utils.getImgPath("delete"), | ||
| 489 | - width: ScreenUtil().setWidth(40), | ||
| 490 | - height: ScreenUtil().setWidth(40), | ||
| 491 | - ), | ||
| 492 | - onTap: () { | ||
| 493 | - //点击删除按钮 | ||
| 494 | - setState(() { | ||
| 495 | - _uploadImageProvider.imageList.removeWhere( | ||
| 496 | - (element) => | ||
| 497 | - element == | ||
| 498 | - _uploadImageProvider.imageList[0]); | ||
| 499 | - _uploadImageProvider.imageQiniuUrlList.removeWhere( | ||
| 500 | - (element) => | ||
| 501 | - element == | ||
| 502 | - _uploadImageProvider.imageQiniuUrlList[0]); | ||
| 503 | - }); | ||
| 504 | - }, | 488 | + // // aspectRatio: _controller.value.aspectRatio, |
| 489 | + // child: VideoPlayer(_controller), | ||
| 490 | + // ), | ||
| 491 | + // ); | ||
| 492 | + // } else { | ||
| 493 | + // return Center( | ||
| 494 | + // child: CircularProgressIndicator(), | ||
| 495 | + // ); | ||
| 496 | + // } | ||
| 497 | + // }, | ||
| 498 | + // ), | ||
| 499 | + , | ||
| 500 | + Offstage( | ||
| 501 | + offstage: widget.model.imageList[index].process < 1, | ||
| 502 | + child: GestureDetector( | ||
| 503 | + child: Image.asset( | ||
| 504 | + Utils.getImgPath("delete"), | ||
| 505 | + width: ScreenUtil().setWidth(40), | ||
| 506 | + height: ScreenUtil().setWidth(40), | ||
| 507 | + ), | ||
| 508 | + onTap: () { | ||
| 509 | + //点击删除按钮 | ||
| 510 | + setState(() { | ||
| 511 | + widget.model.imageList.removeWhere( | ||
| 512 | + (element) => | ||
| 513 | + element == | ||
| 514 | + widget.model.imageList[index]); | ||
| 515 | + widget.model.imageQiniuUrlList.removeWhere( | ||
| 516 | + (element) => | ||
| 517 | + element == | ||
| 518 | + widget | ||
| 519 | + .model.imageQiniuUrlList[index]); | ||
| 520 | + }); | ||
| 521 | + }, | ||
| 522 | + ), | ||
| 523 | + ), | ||
| 524 | + ], | ||
| 505 | ), | 525 | ), |
| 506 | - ), | ||
| 507 | - ], | ||
| 508 | - ), | ||
| 509 | - Offstage( | ||
| 510 | - offstage: _uploadImageProvider.imageList[0].process == 1, | ||
| 511 | - child: Progress(_uploadImageProvider.imageList[0].process), | ||
| 512 | - ) | ||
| 513 | - ], | ||
| 514 | - )); | ||
| 515 | - // }); | 526 | + // Offstage( |
| 527 | + // offstage: widget.model.imageList[index].process == 1, | ||
| 528 | + // child: Progress(widget.model.imageList[index].process), | ||
| 529 | + // ), | ||
| 530 | + widget.model.imageList[index].process == 1 | ||
| 531 | + ? widget.model.imageList[index].fileType == | ||
| 532 | + FileType.video | ||
| 533 | + ? Align( | ||
| 534 | + alignment: Alignment.center, | ||
| 535 | + child: Image.asset( | ||
| 536 | + Utils.getImgPath('check_g'), | ||
| 537 | + width: ScreenUtil().setWidth(40), | ||
| 538 | + )) | ||
| 539 | + : Container() | ||
| 540 | + : Progress(widget.model.imageList[index].process), | ||
| 541 | + widget.model.imageList[index].fileType == FileType.video | ||
| 542 | + ? Align( | ||
| 543 | + alignment: Alignment.bottomRight, | ||
| 544 | + child: Padding( | ||
| 545 | + padding: EdgeInsets.only( | ||
| 546 | + bottom: ScreenUtil().setWidth(10), | ||
| 547 | + right: ScreenUtil().setWidth(10)), | ||
| 548 | + child: Text( | ||
| 549 | + '00:${widget.model.imageList[index].duration}', | ||
| 550 | + style: TextStyle( | ||
| 551 | + color: MyColours.color_333333, | ||
| 552 | + fontSize: ScreenUtil().setSp(24)), | ||
| 553 | + )), | ||
| 554 | + ) | ||
| 555 | + : Container() | ||
| 556 | + ], | ||
| 557 | + )); | ||
| 558 | + }); | ||
| 516 | } | 559 | } |
| 517 | } | 560 | } |
| @@ -39,6 +39,7 @@ import 'package:one_key/provider/notebook_detail_change_model.dart'; | @@ -39,6 +39,7 @@ import 'package:one_key/provider/notebook_detail_change_model.dart'; | ||
| 39 | import 'package:one_key/provider/notebook_detail_model.dart'; | 39 | import 'package:one_key/provider/notebook_detail_model.dart'; |
| 40 | import 'package:one_key/provider/order_food_provider.dart'; | 40 | import 'package:one_key/provider/order_food_provider.dart'; |
| 41 | import 'package:one_key/provider/remark_manager_model.dart'; | 41 | import 'package:one_key/provider/remark_manager_model.dart'; |
| 42 | +import 'package:one_key/provider/upload_img_provider.dart'; | ||
| 42 | import 'package:one_key/utils/fluro_convert_utils.dart'; | 43 | import 'package:one_key/utils/fluro_convert_utils.dart'; |
| 43 | import 'package:provider/provider.dart'; | 44 | import 'package:provider/provider.dart'; |
| 44 | 45 | ||
| @@ -197,11 +198,13 @@ var handleOnlineCheckEditHandler = new Handler( | @@ -197,11 +198,13 @@ var handleOnlineCheckEditHandler = new Handler( | ||
| 197 | bool fromNotify = FluroConvertUtils.string2bool(params["fromNotify"].first); | 198 | bool fromNotify = FluroConvertUtils.string2bool(params["fromNotify"].first); |
| 198 | return ChangeNotifierProvider<OrderFoodProvider>( | 199 | return ChangeNotifierProvider<OrderFoodProvider>( |
| 199 | create: (_) => OrderFoodProvider(), | 200 | create: (_) => OrderFoodProvider(), |
| 200 | - child: OnlineCheckEditPage( | ||
| 201 | - fromNotify: fromNotify, | ||
| 202 | - rid: rid, | ||
| 203 | - mid: mid, | ||
| 204 | - )); | 201 | + child: ChangeNotifierProvider<UploadImageProvider>( |
| 202 | + create: (_) => UploadImageProvider(), | ||
| 203 | + child: OnlineCheckEditPage( | ||
| 204 | + fromNotify: fromNotify, | ||
| 205 | + rid: rid, | ||
| 206 | + mid: mid, | ||
| 207 | + ))); | ||
| 205 | }); | 208 | }); |
| 206 | 209 | ||
| 207 | ///提前买单查看页面 | 210 | ///提前买单查看页面 |
| @@ -297,8 +300,8 @@ var createStorePageHandler = new Handler( | @@ -297,8 +300,8 @@ var createStorePageHandler = new Handler( | ||
| 297 | handlerFunc: (BuildContext context, Map<String, List<Object>> params) { | 300 | handlerFunc: (BuildContext context, Map<String, List<Object>> params) { |
| 298 | // CouponSunModel couponSunModel = CouponSunModel.fromJson(json.decode( | 301 | // CouponSunModel couponSunModel = CouponSunModel.fromJson(json.decode( |
| 299 | // FluroConvertUtils.fluroCnParamsDecode(params["couponSunModel"].first))); | 302 | // FluroConvertUtils.fluroCnParamsDecode(params["couponSunModel"].first))); |
| 300 | - | ||
| 301 | - return CreateStorePage(); | 303 | + return ChangeNotifierProvider<UploadImageProvider>( |
| 304 | + create: (_) => UploadImageProvider(), child: CreateStorePage()); | ||
| 302 | }); | 305 | }); |
| 303 | 306 | ||
| 304 | ///播放视频页 | 307 | ///播放视频页 |
| @@ -221,15 +221,7 @@ class NavigatorUtil { | @@ -221,15 +221,7 @@ class NavigatorUtil { | ||
| 221 | context, | 221 | context, |
| 222 | "${Routes.play_video}?urlStr=${FluroConvertUtils.fluroCnParamsEncode(urlStr)}", | 222 | "${Routes.play_video}?urlStr=${FluroConvertUtils.fluroCnParamsEncode(urlStr)}", |
| 223 | replace: replace, | 223 | replace: replace, |
| 224 | - transitionBuilder: (BuildContext context, Animation<double> animation, | ||
| 225 | - Animation<double> secondaryAnimation, Widget child) { | ||
| 226 | - return FadeTransition( | ||
| 227 | - opacity: CurvedAnimation( | ||
| 228 | - parent: animation, | ||
| 229 | - curve: Curves.linear, | ||
| 230 | - ), | ||
| 231 | - child: child); | ||
| 232 | - }, | 224 | + transitionType:TransitionType.materialFullScreenDialog |
| 233 | ); | 225 | ); |
| 234 | } | 226 | } |
| 235 | } | 227 | } |
| @@ -1038,6 +1038,13 @@ packages: | @@ -1038,6 +1038,13 @@ packages: | ||
| 1038 | url: "https://pub.flutter-io.cn" | 1038 | url: "https://pub.flutter-io.cn" |
| 1039 | source: hosted | 1039 | source: hosted |
| 1040 | version: "2.1.0-nullsafety.3" | 1040 | version: "2.1.0-nullsafety.3" |
| 1041 | + video_compress: | ||
| 1042 | + dependency: "direct main" | ||
| 1043 | + description: | ||
| 1044 | + name: video_compress | ||
| 1045 | + url: "https://pub.flutter-io.cn" | ||
| 1046 | + source: hosted | ||
| 1047 | + version: "2.1.1" | ||
| 1041 | video_player: | 1048 | video_player: |
| 1042 | dependency: "direct main" | 1049 | dependency: "direct main" |
| 1043 | description: | 1050 | description: |
-
Please register or login to post a comment