video_upload.dart 34 KB

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