video_upload.dart 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859
  1. import 'package:flutter/material.dart';
  2. import 'package:liftmanager/res/gaps.dart';
  3. import 'package:liftmanager/net/api_service.dart';
  4. import 'package:liftmanager/utils/toast.dart';
  5. import 'package:liftmanager/widgets/app_bar.dart';
  6. import 'package:liftmanager/internal/search/search_router.dart';
  7. import 'package:liftmanager/widgets/app_search_bar.dart';
  8. import 'package:liftmanager/res/resources.dart';
  9. import 'package:liftmanager/routers/fluro_navigator.dart';
  10. import 'package:liftmanager/widgets/load_image.dart';
  11. import 'package:liftmanager/widgets/selected_image_change.dart';
  12. import 'package:image_picker/image_picker.dart';
  13. import 'dart:io';
  14. import 'package:liftmanager/widgets/bbs_content.dart';
  15. import 'package:flutter_screenutil/flutter_screenutil.dart';
  16. import 'package:flutter_spinkit/flutter_spinkit.dart';
  17. import 'package:video_player/video_player.dart';
  18. import 'package:liftmanager/utils/image_utils.dart';
  19. import 'package:liftmanager/internal/bbs/bbs_router.dart';
  20. import 'package:liftmanager/internal/wode/wode_router.dart';
  21. import 'package:liftmanager/internal/bbs/model/video_detail.dart';
  22. import 'package:liftmanager/utils/log_util.dart';
  23. import 'dart:convert';
  24. import 'package:flustars/flustars.dart' as FlutterStars;
  25. import 'package:liftmanager/common/common.dart';
  26. import 'dart:math';
  27. import 'package:liftmanager/utils/fast_notification.dart';
  28. import 'package:liftmanager/utils/theme_utils.dart';
  29. import 'package:liftmanager/utils/oss_upload.dart';
  30. import 'package:liftmanager/utils/log_util.dart';
  31. import 'package:chewie/chewie.dart';
  32. import 'package:flutter/services.dart';
  33. import 'package:liftmanager/utils/utils.dart';
  34. import 'package:orientation/orientation.dart';
  35. import 'dart:async';
  36. import 'package:liftmanager/widgets/selected_video_change.dart';
  37. class VideoUpload extends StatefulWidget {
  38. VideoUpload(this.id);
  39. final String id;
  40. @override
  41. State<StatefulWidget> createState() {
  42. return VideoUploadState();
  43. }
  44. }
  45. class VideoUploadState extends State<VideoUpload> {
  46. // NewsDetailItem item = NewsDetailItem();
  47. ScrollController _scrollController = new ScrollController();
  48. String brandChiose='请选择';
  49. String brandName = "品牌";
  50. int brandIdss;
  51. bool sortBool = true;
  52. // List<String> imagesUrl = [];
  53. // List<String> videoUrl = [];
  54. VideoDetailModel detailObj;
  55. VideoPlayerController _controller;
  56. String videoUrl;
  57. String str;
  58. String imagesUrl;
  59. double percent = 0.0;
  60. // 焦点控制
  61. FocusNode _focusNode1 = new FocusNode();
  62. GlobalKey _formKey= new GlobalKey<FormState>();
  63. TextEditingController _titleController = new TextEditingController();
  64. TextEditingController _descController = new TextEditingController();
  65. @override
  66. void initState() {
  67. super.initState();
  68. print(widget.id);
  69. if(widget.id!=null&&widget.id!=""){
  70. NewApiService().getVideoDetail(int.parse(widget.id), 1,
  71. onSuccess: (res) {
  72. if (res != null) {
  73. detailObj = res;
  74. LogUtil.d(jsonEncode(res));
  75. print(88885);
  76. setState(() {
  77. videoUrl = null;
  78. videoUrl = res.url;
  79. _titleController.text = res.title;
  80. _descController.text = res.descr;
  81. brandIdss = res.brandId;
  82. brandChiose = res.brandName;
  83. });
  84. }
  85. }, onError: (code, msg) {
  86. toasts(msg);
  87. });
  88. }
  89. }
  90. upLoadFileOnce(path) {
  91. showLoading(context, "正在上传...");
  92. NewApiService().upload(path, onSuccess: (res) {
  93. // imagesUrl.add(res.path);
  94. dismissLoading(context);
  95. setState(() {
  96. // videoUrl = [];
  97. // imagesUrl = [];
  98. // videoUrl.add(res.pathUrl);
  99. // imagesUrl.add(res.coverUrl);
  100. });
  101. }, onError: (code, msg) {
  102. dismissLoading(context);
  103. toasts(msg);
  104. });
  105. }
  106. randomInt(int min, int max) {
  107. return new Random().nextInt(max) % (max - min + 1) + min;
  108. }
  109. List<dynamic> brandList;
  110. Future getBrandList() async {
  111. await NewApiService().getBrandListNoPage(
  112. onSuccess: (res) {
  113. if (res != null) {
  114. brandList = res;
  115. setState(() {});
  116. }
  117. }, onError: (code, msg) {
  118. toasts(msg);
  119. });
  120. }
  121. ///选择视频
  122. void selectPicker() {
  123. showDialog(
  124. context: context,
  125. builder: (BuildContext context) {
  126. return SimpleDialog(
  127. title: Text("选择方式"),
  128. children: ["拍照", '从手机相册选择'].map((String value) {
  129. print("$value");
  130. return SimpleDialogOption(
  131. child: Text(
  132. "${value}",
  133. style: TextStyle(fontSize: 16, fontWeight: FontWeight.w500),
  134. ),
  135. onPressed: () {
  136. _getImage(value == '拍照' ? 1 : 0);
  137. Navigator.of(context).pop();
  138. },
  139. );
  140. }).toList());
  141. });
  142. }
  143. void _getImage(int key) async {
  144. print(key);
  145. print(333);
  146. try {
  147. var _imageFile = await ImagePicker.pickVideo(
  148. source: key == 1 ? ImageSource.camera : ImageSource.gallery,
  149. );
  150. if (_imageFile != null) {
  151. // print(123);
  152. // print(_imageFile);
  153. // print(jsonEncode(_imageFile));
  154. LogUtil.d(_imageFile);
  155. LogUtil.d(_imageFile.hashCode);
  156. LogUtil.d(_imageFile.path);
  157. print(123);
  158. // upLoadFileOnce(_imageFile.path);
  159. _uploadImage(_imageFile.path);
  160. setState(() {});
  161. }
  162. } catch (e) {
  163. toasts("没有权限,无法打开相册!");
  164. }
  165. }
  166. void _uploadImage(filePath) async {
  167. showPercent(context, (){
  168. dismissLoading(context);
  169. toasts("上传失败");
  170. },(){
  171. if(videoUrl == null && str != null){
  172. setState(() {
  173. videoUrl = str;
  174. print("videoUrl:"+videoUrl);
  175. dismissLoading(context);
  176. toasts("上传成功");
  177. });
  178. }
  179. });
  180. String uploadName = OssUtil.instance.getImageUploadName(filePath);
  181. await NewApiService.uploadImage(context, uploadName, filePath).then((data) {
  182. if (data.statusCode == 200) {
  183. str = NewApiUrl.URL_UPLOAD_IMAGE_OSS + "/" + uploadName;
  184. print("str:"+str);
  185. print(videoUrl);
  186. if(str != null){
  187. Map obj = {
  188. "uploadName":uploadName,
  189. "success":true
  190. };
  191. FastNotification.push("percent",obj);
  192. }
  193. }else {
  194. Map obj = {
  195. "uploadName":uploadName,
  196. "success":false
  197. };
  198. FastNotification.push("percent",obj);
  199. }
  200. }).catchError((data) {
  201. Map obj = {
  202. "uploadName":uploadName,
  203. "success":false
  204. };
  205. FastNotification.push("percent",obj);
  206. });
  207. }
  208. FocusNode focusNode1 = new FocusNode();
  209. @override
  210. Widget build(BuildContext context) {
  211. double width = MediaQuery.of(context).size.width;
  212. double height = MediaQuery.of(context).size.height;
  213. // 监听FocusNode
  214. _focusNode1.addListener((){
  215. // _focusNode1.hasFocus 是否聚焦
  216. print(_focusNode1.hasFocus);
  217. });
  218. return Scaffold(
  219. resizeToAvoidBottomPadding: false,//不让键盘弹上去
  220. appBar: MyAppBar(
  221. centerTitle: "上传视频",
  222. ),
  223. body:GestureDetector(
  224. onTap: () {
  225. // 点击空白页面关闭键盘
  226. FocusScope.of(context).requestFocus(focusNode1);
  227. },
  228. child: Stack(
  229. children: <Widget>[
  230. Container(
  231. child: ListView(
  232. children: <Widget>[
  233. Form(
  234. key: _formKey, //设置globalKey,用于后面获取FormState
  235. // autovalidate: true, //开启自动校验
  236. child: Column(
  237. children: <Widget>[
  238. ChioseThisRight(label: "电梯品牌",value:brandChiose,fun:(){
  239. setState(() {
  240. // brandChiose = brandListChiose[index];
  241. sortBool = false;
  242. print(5656333);
  243. });
  244. getBrandList();
  245. // Navigator.maybePop(context);
  246. }),
  247. Row(
  248. crossAxisAlignment: CrossAxisAlignment.start,
  249. mainAxisAlignment: MainAxisAlignment.start,
  250. children: <Widget>[
  251. Container(
  252. padding:EdgeInsets.only(left:ScreenUtil().setWidth(15),top:ScreenUtil().setWidth(10),bottom:ScreenUtil().setWidth(5)),
  253. child: Text(
  254. "视频标题",
  255. style: TextStyle(
  256. color:Color(0xff222222),
  257. // fontSize:ScreenUtil().setSp(14),
  258. ),
  259. textAlign:TextAlign.left,
  260. ),
  261. ),
  262. ],
  263. ),
  264. Container(
  265. height:80,
  266. padding: EdgeInsets.only(left:ScreenUtil().setWidth(15),right:ScreenUtil().setWidth(15),bottom:ScreenUtil().setWidth(20)),
  267. child: TextFormField(
  268. // autofocus: true,
  269. maxLength: 50,
  270. cursorColor: Color(0xffcccccc),
  271. controller: _titleController,
  272. maxLines:5,
  273. decoration: InputDecoration(
  274. contentPadding: EdgeInsets.all(0),
  275. hintText: '请输入你上传视频的标题',
  276. hintStyle:TextStyle(
  277. color: Color(0xffcccccc)
  278. ),
  279. focusedBorder: InputBorder.none,
  280. border: InputBorder.none,
  281. // filled: true, // 背景色
  282. // fillColor: Colors.cyan.withAlpha(35),
  283. // icon: Icon(Icons.person)
  284. ),
  285. // 校验
  286. validator: (val) {
  287. return val.trim().length > 0 ? null : "不能为空";
  288. }
  289. ),
  290. ),
  291. SizedBox(
  292. height:6,
  293. child: Container(
  294. color:ThemeUtils.getDialogTextFieldColor(context)
  295. ),
  296. ),
  297. Row(
  298. crossAxisAlignment: CrossAxisAlignment.start,
  299. mainAxisAlignment: MainAxisAlignment.start,
  300. children: <Widget>[
  301. Container(
  302. padding:EdgeInsets.only(left:ScreenUtil().setWidth(15),top:ScreenUtil().setWidth(10),bottom:ScreenUtil().setWidth(5)),
  303. child: Text(
  304. "视频简介",
  305. style: TextStyle(
  306. color:Color(0xff222222),
  307. // fontSize:ScreenUtil().setSp(14),
  308. ),
  309. textAlign:TextAlign.left,
  310. ),
  311. ),
  312. ],
  313. ),
  314. Container(
  315. height:120,
  316. padding: EdgeInsets.only(left:ScreenUtil().setWidth(15),right:ScreenUtil().setWidth(15),bottom:ScreenUtil().setWidth(20)),
  317. child: TextFormField(
  318. // autofocus: true,
  319. maxLength: 500,
  320. cursorColor: Color(0xffcccccc),
  321. controller: _descController,
  322. maxLines:5,
  323. decoration: InputDecoration(
  324. contentPadding: EdgeInsets.all(0),
  325. hintText: '请输入您上传视频的简介',
  326. hintStyle:TextStyle(
  327. color: Color(0xffcccccc)
  328. ),
  329. focusedBorder: InputBorder.none,
  330. border: InputBorder.none,
  331. // filled: true, // 背景色
  332. // fillColor: Colors.cyan.withAlpha(35),
  333. // icon: Icon(Icons.person)
  334. ),
  335. // 校验
  336. validator: (val) {
  337. return val.trim().length > 0 ? null : "不能为空";
  338. }
  339. ),
  340. ),
  341. SizedBox(
  342. height:6,
  343. child: Container(
  344. color:ThemeUtils.getDialogTextFieldColor(context)
  345. ),
  346. ),
  347. Container(
  348. width: width,
  349. padding: EdgeInsets.only(left:15,top:15,bottom:15),
  350. child: Text(
  351. "(建议时长3分钟,建议大小50M)",
  352. style: TextStyle(
  353. color: Colors.red,
  354. fontSize:
  355. ScreenUtil()
  356. .setSp(14),
  357. ),
  358. textAlign: TextAlign.left,
  359. ),
  360. ),
  361. // Container(
  362. // color: ThemeUtils.getTabsBg(context),
  363. // child: GridView.builder(
  364. // shrinkWrap: true,
  365. // padding: const EdgeInsets.fromLTRB(8.0, 12, 8.0, 12.0),
  366. // physics: NeverScrollableScrollPhysics(),
  367. // gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
  368. // crossAxisCount: 3, childAspectRatio: 1.18),
  369. // itemCount: videoUrl.length >= 1 ? 1 : videoUrl.length + 1,
  370. // itemBuilder: (_, index) {
  371. // return Stack(
  372. // children: <Widget>[
  373. // Center(
  374. // child: SelectedImage(
  375. // image: index < videoUrl.length ? imagesUrl[index] : null,
  376. // // image: index < videoUrl.length ? videoUrl[index] : null,
  377. // index:index,
  378. // onTap: () {
  379. // if(index >= videoUrl.length){
  380. // selectPicker();
  381. // }
  382. // FocusScope.of(context).requestFocus(FocusNode());
  383. // print(index);
  384. // print(videoUrl);
  385. // }),
  386. // ),
  387. // index < videoUrl.length?Positioned(
  388. // top:0,
  389. // right:0,
  390. // child:GestureDetector(
  391. // onTap: (){
  392. // print(index);
  393. // videoUrl.remove(videoUrl[index]);
  394. // imagesUrl.remove(imagesUrl[index]);
  395. // setState(() {
  396. // });
  397. // },
  398. // child:Icon(
  399. // IconData(
  400. // 0xe62a,
  401. // fontFamily:"myfont"
  402. // ),
  403. // size: 24.0,
  404. // color:Color(0xff999999),
  405. // ),
  406. // )
  407. // ):Container(child: null,)
  408. // ],
  409. // );
  410. // },
  411. // )
  412. // ),
  413. Container(
  414. color: ThemeUtils.getDialogTextFieldColor(context),
  415. child: GridView.builder(
  416. shrinkWrap: true,
  417. padding: const EdgeInsets.fromLTRB(8.0, 12, 8.0, 12.0),
  418. physics: NeverScrollableScrollPhysics(),
  419. gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
  420. crossAxisCount: 1, childAspectRatio: 1.18),
  421. itemCount: 1,
  422. itemBuilder: (_, index) {
  423. return Stack(
  424. children: <Widget>[
  425. Center(
  426. child: SelectedVideo(
  427. image: videoUrl,
  428. index: index,
  429. videoPlay:videoPlay(),
  430. onTap: () {
  431. if(videoUrl == null){
  432. selectPicker();
  433. }
  434. },
  435. ),
  436. ),
  437. videoUrl != null
  438. ? Positioned(
  439. top: 0,
  440. right: 0,
  441. child: GestureDetector(
  442. onTap: () {
  443. print(index);
  444. // imagesUrl = null;
  445. setState(() {
  446. videoUrl = null;
  447. str = null;
  448. _controller.pause();
  449. // player.reset();
  450. });
  451. },
  452. child: Icon(
  453. IconData(0xe62a, fontFamily: "myfont"),
  454. size: 24.0,
  455. color: Color(0xff999999),
  456. ),
  457. ),
  458. )
  459. : Container(
  460. child: null,
  461. )
  462. ],
  463. );
  464. },
  465. ),
  466. ),
  467. SizedBox(
  468. height:ScreenUtil().setWidth(80),
  469. ),
  470. ],
  471. ),
  472. )
  473. ]
  474. )
  475. ),
  476. Positioned(
  477. bottom:0,
  478. left:0,
  479. child:Container(
  480. width: width,
  481. padding: EdgeInsets.only(top:ScreenUtil().setWidth(15),bottom:ScreenUtil().setWidth(15),left:ScreenUtil().setWidth(25),right:ScreenUtil().setWidth(25)),
  482. color:ThemeUtils.getDialogTextFieldColor(context),
  483. child: Container(
  484. height:ScreenUtil().setWidth(44),
  485. decoration: BoxDecoration(
  486. borderRadius: BorderRadius.circular(ScreenUtil().setWidth(22)),
  487. gradient: const LinearGradient(
  488. colors: [Color(0xFF00D9FF), Color(0xFF0287FF)]),
  489. ),
  490. child: FlatButton(
  491. // padding: EdgeInsets.all(15.0),
  492. child: Text("提交"),
  493. textColor: Colors.white,
  494. onPressed: () {
  495. if(brandIdss==null){
  496. toasts("请选择品牌");
  497. return;
  498. }
  499. if(videoUrl==null){
  500. toasts("请上传视频");
  501. return;
  502. }
  503. // String videos = videoUrl.join(",");
  504. // String images = imagesUrl.join(",");
  505. if((_formKey.currentState as FormState).validate()){
  506. showLoading(context, "正在提交...");
  507. if(widget.id!=null&&widget.id!=""){
  508. dynamic objEdit = {
  509. "brandId":brandIdss,
  510. "title":_titleController.text,
  511. "descr":_descController.text,
  512. "url":videoUrl,
  513. // "cover": images,
  514. "checkFlag":2,
  515. "statuz":1,
  516. "platformFlag":1,
  517. "userId":FlutterStars.SpUtil.getString(Constant.userId),
  518. "id":detailObj.id
  519. };
  520. NewApiService().editVideo(objEdit, onSuccess: (res) {
  521. dismissLoading(context);
  522. toasts("修改成功");
  523. String initThisMyVideo = randomInt(1111,9999).toString() + DateTime.now().millisecondsSinceEpoch.toString();
  524. FastNotification.push("initMyVideo",initThisMyVideo);
  525. Navigator.of(context)..pop()..pop();
  526. }, onError: (code, msg) {
  527. dismissLoading(context);
  528. toasts(msg);
  529. });
  530. }else {
  531. dynamic obj = {
  532. "brandId":brandIdss,
  533. "title":_titleController.text,
  534. "descr":_descController.text,
  535. "url":videoUrl,
  536. // "cover": images,
  537. "checkFlag":2,
  538. "statuz":1,
  539. "platformFlag":1,
  540. "userId":FlutterStars.SpUtil.getString(Constant.userId)
  541. };
  542. NewApiService().addVideo(obj, onSuccess: (res) {
  543. dismissLoading(context);
  544. toasts("提交成功");
  545. String initThisMyVideo = randomInt(1111,9999).toString() + DateTime.now().millisecondsSinceEpoch.toString();
  546. FastNotification.push("initMyVideo",initThisMyVideo);
  547. Navigator.pop(context);
  548. }, onError: (code, msg) {
  549. dismissLoading(context);
  550. toasts(msg);
  551. });
  552. }
  553. }
  554. },
  555. ),
  556. ),
  557. )
  558. ),
  559. !sortBool?
  560. Positioned(
  561. top:0,
  562. left:0,
  563. child: Container(
  564. width:width,
  565. height:height,
  566. color: Color.fromRGBO(0, 0, 0, 0.5)
  567. )
  568. )
  569. :Container(
  570. child:null
  571. ),
  572. !sortBool?
  573. Positioned(
  574. top:0,
  575. right:0,
  576. child:Container(
  577. width: width/4*3,
  578. height:height,
  579. color: ThemeUtils.getTabsBg(context),
  580. padding: EdgeInsets.all(10),
  581. child:ListView(
  582. children:<Widget>[
  583. Container(
  584. padding: EdgeInsets.only(left:5,top:5,bottom:10),
  585. child:Text(
  586. "品牌",
  587. style: TextStyle(
  588. color:Color(0xff666666),
  589. fontSize:ScreenUtil().setSp(16)
  590. ),
  591. textAlign:TextAlign.start,
  592. ),
  593. ),
  594. brandList!=null&&brandList!=[]?Container(
  595. child: Wrap(
  596. alignment: WrapAlignment.start,
  597. crossAxisAlignment: WrapCrossAlignment.center,
  598. children: brandList.asMap().keys.map((index){
  599. return InkWell(
  600. onTap: (){
  601. print("666");
  602. setState(() {
  603. sortBool = true;
  604. brandChiose = brandList[index].name??"";
  605. brandIdss = brandList[index].id;
  606. });
  607. },
  608. child: Container(
  609. width: width/4-17,
  610. padding: EdgeInsets.only(bottom:ScreenUtil().setWidth(10),top:ScreenUtil().setWidth(10)),
  611. margin: EdgeInsets.only(left:5,right:5,bottom:5,top:5),
  612. decoration: BoxDecoration(
  613. // border: Border(
  614. // bottom: BorderSide(width: 0.5, color: Colours.line),
  615. // ),
  616. color: Color(0xfff5f5f5)
  617. ),
  618. child:Text(
  619. brandList[index].name??"",
  620. style: TextStyle(
  621. color:Color(0xff666666),
  622. fontSize:ScreenUtil().setSp(15)
  623. ),
  624. textAlign:TextAlign.center,
  625. maxLines: 1,
  626. overflow: TextOverflow.ellipsis,
  627. ),
  628. ),
  629. );
  630. }).toList(),
  631. )
  632. ):loadCircle()
  633. ],
  634. )
  635. )
  636. ):
  637. Container(
  638. child:null
  639. ),
  640. ],
  641. ),
  642. ),
  643. );
  644. }
  645. Widget loadCircle() {
  646. return Container(
  647. padding: EdgeInsets.only(top: 10, bottom: 10),
  648. color: ThemeUtils.getTabsBg(context),
  649. child: Center(
  650. child: SpinKitFadingCircle(
  651. color: Colors.blueAccent,
  652. size: 30.0,
  653. ),
  654. ),
  655. );
  656. }
  657. Widget videoPlay() {
  658. _controller = VideoPlayerController.network(
  659. Utils.getImagePath(videoUrl)
  660. // imgFontUrl + detailObj.url
  661. );
  662. double width = MediaQuery.of(context).size.width;
  663. return
  664. // Container(
  665. // width: width,
  666. // height: width*0.6,
  667. // alignment: Alignment.center,
  668. // child: FijkView(
  669. // player: player,
  670. // color: Colors.black,
  671. // fit:FijkFit.fill,
  672. // // cover: NetworkImage(detailObj.cover),
  673. // // cover: new Image(image: detailObj.cover!=null&& detailObj.cover!=""?NetworkImage(detailObj.cover):AssetImage("assets/images/video_image.png"),).image,
  674. // //
  675. // ),
  676. // );
  677. Container(
  678. padding: EdgeInsets.only(
  679. left: ScreenUtil().setWidth(15),
  680. right: ScreenUtil().setWidth(15),
  681. top: ScreenUtil().setWidth(15)),
  682. child: ClipRRect(
  683. borderRadius: BorderRadius.circular(5),
  684. child:
  685. new Chewie(
  686. controller: ChewieController(
  687. videoPlayerController:
  688. // VideoPlayerController.network(
  689. // imgFontUrl + detailObj.url
  690. // ),
  691. _controller,
  692. aspectRatio: 3 / 2,
  693. allowFullScreen:false,
  694. autoPlay: false,
  695. looping: true,
  696. // startAt: Duration(seconds: 1,minutes: 1),
  697. showControls: true,
  698. deviceOrientationsAfterFullScreen:[DeviceOrientation.portraitUp],
  699. // 占位图
  700. // placeholder: Image.network(
  701. // imgFontUrl+detailObj.cover,
  702. // fit: BoxFit.contain,
  703. // ),
  704. // 是否在 UI 构建的时候就加载视频
  705. autoInitialize: true,
  706. // 拖动条样式颜色
  707. materialProgressColors:
  708. new ChewieProgressColors(
  709. playedColor: Colors.red,
  710. handleColor: Colors.blue,
  711. backgroundColor: Colors.grey,
  712. bufferedColor: Colors.lightGreen,
  713. ),
  714. ),
  715. ),
  716. )
  717. );
  718. }
  719. }
  720. class ChioseThisRight extends StatelessWidget {
  721. ChioseThisRight({Key key,this.value,this.label,this.fun,this.labelText='请选择'}) : super(key: key);
  722. String value;
  723. String label;
  724. Function fun;
  725. String labelText;
  726. @override
  727. Widget build(BuildContext context) {
  728. double width = MediaQuery.of(context).size.width;
  729. return InkWell(
  730. onTap: (){
  731. fun();
  732. },
  733. child: Container(
  734. padding: EdgeInsets.only(top:ScreenUtil().setWidth(15),bottom:ScreenUtil().setWidth(15)),
  735. margin: EdgeInsets.only(left:ScreenUtil().setWidth(15)),
  736. decoration: BoxDecoration(
  737. border: Border(
  738. bottom: BorderSide(width: 0.5, color: Colours.line),
  739. ),
  740. ),
  741. child: Row(
  742. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  743. children:<Widget>[
  744. Text(
  745. label,
  746. style: TextStyle(
  747. color:Color(0xff222222),
  748. // fontSize: ScreenUtil().setSp(14)
  749. ),
  750. textAlign:TextAlign.start,
  751. ),
  752. value.isEmpty? Container(
  753. child: Row(
  754. children:<Widget>[
  755. Text(
  756. labelText,
  757. style: TextStyle(
  758. color:Color(0xffcccccc),
  759. // fontSize: ScreenUtil().setSp(14)
  760. ),
  761. textAlign:TextAlign.start,
  762. ),
  763. Container(
  764. padding: EdgeInsets.only(top:3),
  765. child: Icon(
  766. Icons.keyboard_arrow_right,
  767. size: 20.0,
  768. color:Color(0xffcccccc),
  769. ),
  770. ),
  771. SizedBox(
  772. width:10
  773. )
  774. ]
  775. ),
  776. ):
  777. Container(
  778. padding: EdgeInsets.only(right:ScreenUtil().setWidth(15)),
  779. child: Row(
  780. children:<Widget>[
  781. Text(
  782. value,
  783. style: TextStyle(
  784. color:Color(0xff222222),
  785. fontSize: ScreenUtil().setSp(14)
  786. ),
  787. textAlign:TextAlign.start,
  788. ),
  789. ]
  790. ),
  791. ),
  792. ]
  793. ),
  794. ),
  795. );
  796. }
  797. }