YSSquareVideo.dart 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826
  1. import 'dart:io';
  2. import 'package:flutter/cupertino.dart';
  3. import 'package:flutter/gestures.dart';
  4. import 'package:flutter/material.dart';
  5. import 'package:flutter_easyrefresh/easy_refresh.dart';
  6. import 'package:image_picker/image_picker.dart';
  7. import 'package:qiniu_flutter_sdk/qiniu_flutter_sdk.dart';
  8. import 'package:ysairplane2/tools/YSNetWorking.dart';
  9. import 'package:ysairplane2/tools/YSTools.dart';
  10. import 'package:video_player/video_player.dart';
  11. class YSSquareVideo extends StatefulWidget {
  12. final squareId,typeId,isShow;
  13. const YSSquareVideo({Key key, this.squareId, this.typeId, this.isShow}) : super(key: key);
  14. @override
  15. _YSSquareVideoState createState() => _YSSquareVideoState();
  16. }
  17. class _YSSquareVideoState extends State<YSSquareVideo> {
  18. VideoPlayerController _controller;
  19. bool _isPlaying = false;
  20. Map _dict;
  21. int page = 1;
  22. List comments = [];
  23. var ysState;
  24. List _imageArray = [];
  25. String _tokenStr = '';
  26. String _urlStr = '';
  27. TextEditingController _textField = TextEditingController();
  28. var _imageSet;
  29. @override
  30. void initState() {
  31. Future.delayed(Duration(seconds: 0)).then((value){
  32. _getSquareDetailData();
  33. _getQiNiuTokenData();
  34. });
  35. super.initState();
  36. }
  37. @override
  38. void dispose() {
  39. _controller.dispose();
  40. super.dispose();
  41. }
  42. _onUpload(var value) async {
  43. if (value == null) {
  44. return;
  45. }
  46. print(value.path);
  47. print(_tokenStr);
  48. Storage storage = Storage();
  49. storage.putFile(
  50. File(value.path),
  51. _tokenStr,
  52. options: PutOptions(
  53. key: DateTime.now().millisecondsSinceEpoch.toString() +'.' +value.path.split('.').last,
  54. ),
  55. ).then((result) async{
  56. _imageSet(() {
  57. _imageArray.add(_urlStr+'${result.key}');
  58. });
  59. });
  60. }
  61. _getQiNiuTokenData() async{
  62. Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/getToken',parameter: {},isLoading: false,isToken: false);
  63. if(dict!=null){
  64. _tokenStr = dict['token'];
  65. _urlStr = dict['prefix'];
  66. }
  67. }
  68. @override
  69. Widget build(BuildContext context) {
  70. return Scaffold(
  71. body: SingleChildScrollView(
  72. child: Column(
  73. children: [
  74. Container(
  75. height: MediaQuery.of(context).size.height-(widget.isShow?50:0),
  76. width: MediaQuery.of(context).size.width,
  77. color: Color(0xFF1D1D1D),
  78. child: SingleChildScrollView(
  79. child: Stack(
  80. // crossAxisAlignment: CrossAxisAlignment.start,
  81. children: [
  82. if (_controller==null) Container(
  83. height: 200,
  84. color: Colors.black12,
  85. ) else Container(
  86. height: MediaQuery.of(context).size.height-50,
  87. child: Stack(
  88. alignment: Alignment.bottomCenter,
  89. children: <Widget>[
  90. Center(
  91. child: AspectRatio(
  92. child: VideoPlayer(_controller),
  93. aspectRatio: _controller.value.aspectRatio ,
  94. ),
  95. ),
  96. _PlayPauseOverlay(controller: _controller),
  97. Container(
  98. height:6.5,
  99. child: VideoProgressIndicator(
  100. _controller,
  101. allowScrubbing: true,
  102. colors: VideoProgressColors(playedColor: Color(0xFF1961E3),backgroundColor: Colors.white),
  103. )
  104. ),
  105. ],
  106. ),
  107. ),
  108. Container(
  109. child: Row(
  110. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  111. children: [
  112. GestureDetector(
  113. child: Icon(Icons.arrow_back_ios,size: 20,color: Colors.white,),
  114. onTap: (){
  115. Navigator.pop(context);
  116. },
  117. ),
  118. PopupMenuButton<String>(
  119. itemBuilder: (context) {
  120. return <PopupMenuEntry<String>>[
  121. PopupMenuItem<String>(
  122. value: '不感兴趣',
  123. child: Text('不感兴趣'),
  124. ),
  125. PopupMenuItem<String>(
  126. value: '拉黑',
  127. child: Text('拉黑'),
  128. ),
  129. PopupMenuItem<String>(
  130. value: '举报',
  131. child: Text('举报'),
  132. ),
  133. ];
  134. },
  135. icon: Icon(Icons.more_horiz_outlined,size: 25,color: Colors.white,),
  136. padding: EdgeInsets.all(0),
  137. onSelected: (value) async{
  138. if(value=='举报'){
  139. _imageArray.clear();
  140. _textField.text = '';
  141. showModalBottomSheet(
  142. context: context,
  143. builder: (context){
  144. return Container(
  145. height: hsp(700),
  146. width: MediaQuery.of(context).size.width,
  147. color: Colors.white,
  148. child: Column(
  149. children: [
  150. Container(
  151. height: hsp(100),
  152. child: Text('举报',style: TextStyle(fontSize: zsp(30),color: Colors.black),),
  153. alignment: Alignment.center,
  154. decoration: BoxDecoration(
  155. border: Border(bottom: BorderSide(color: Color(0xFFEEEEEE),width: 0.5))
  156. ),
  157. ),
  158. Container(
  159. height: hsp(300),
  160. child: CupertinoTextField(
  161. placeholder: '请输入举报理由',
  162. style: TextStyle(fontSize: zsp(30),color: Color(0xFF333739)),
  163. maxLines: 50,
  164. controller: _textField,
  165. ),
  166. padding: EdgeInsets.all(hsp(30)),
  167. ),
  168. StatefulBuilder(
  169. builder: (context,imageSet){
  170. _imageSet = imageSet;
  171. return Container(
  172. height: hsp(200),
  173. child: GridView.builder(
  174. gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
  175. crossAxisCount: 1,
  176. mainAxisSpacing: hsp(30)
  177. ),
  178. scrollDirection: Axis.horizontal,
  179. itemBuilder: (context,index){
  180. return _imageArray.length>index?Container(
  181. child: Image.network(_imageArray[index],fit: BoxFit.fill,),
  182. ):GestureDetector(
  183. onTap: () async{
  184. ImagePicker _picker = ImagePicker();
  185. showCupertinoModalPopup(
  186. context: context,
  187. builder: (context) {
  188. return CupertinoActionSheet(
  189. actions: <Widget>[
  190. CupertinoActionSheetAction(
  191. child: Text('拍摄照片'),
  192. onPressed: () {
  193. Navigator.pop(context);
  194. _picker.getImage(source: ImageSource.camera).then((value){
  195. _onUpload(value);
  196. });
  197. },
  198. ),
  199. CupertinoActionSheetAction(
  200. child: Text('选择图片'),
  201. onPressed: () {
  202. Navigator.pop(context);
  203. _picker.getImage(source: ImageSource.gallery).then((value){
  204. _onUpload(value);
  205. });
  206. },
  207. ),
  208. ],
  209. cancelButton: CupertinoActionSheetAction(
  210. child: Text('取消'),
  211. onPressed: () {
  212. Navigator.pop(context);
  213. },
  214. ),
  215. );
  216. }
  217. );
  218. },
  219. child: Container(
  220. decoration: BoxDecoration(
  221. border: Border.all(color: Color(0xFFEEEEEE),width: 1)
  222. ),
  223. child: Icon(Icons.add_photo_alternate_rounded,color: Color(0xFFEEEEEE),size: hsp(80),),
  224. alignment: Alignment.center,
  225. ),
  226. );
  227. },
  228. itemCount: _imageArray.length>0?_imageArray.length:_imageArray.length+1,
  229. ),
  230. padding: EdgeInsets.only(left: hsp(30),right: hsp(30),bottom: hsp(30)),
  231. );
  232. },
  233. ),
  234. GestureDetector(
  235. child: Container(
  236. height: hsp(100),
  237. color: Color(0xFF007AFF),
  238. margin: EdgeInsets.only(left: hsp(50),right: hsp(50)),
  239. child: Text('提交',style: TextStyle(fontSize: zsp(30),color: Colors.white),),
  240. alignment: Alignment.center,
  241. ),
  242. onTap: () async{
  243. if(_textField.text.isEmpty){
  244. ysFlutterToast(context, '请输入举报理由');
  245. return;
  246. }
  247. if(_imageArray.length==0){
  248. ysFlutterToast(context, '请添加举报图片');
  249. return;
  250. }
  251. String url = '/app/applets/feedback/toReport';
  252. Map request = {};
  253. request['type'] = 2;
  254. request['did'] = widget.squareId;
  255. request['content'] = _textField.text;
  256. request['pic'] = _imageArray[0];
  257. Map dict = await ysRequestHttp(context, type: requestType.post,api: url,parameter: request,isLoading: false,isToken: true);
  258. if (dict != null) {
  259. ysFlutterToast(context,'已举报该用户');
  260. Navigator.of(context).pop('');
  261. }
  262. },
  263. ),
  264. ],
  265. ),
  266. );
  267. }
  268. );
  269. }else{
  270. String url = '/app/black/shielding';
  271. Map request = {};
  272. request['type'] = 2;
  273. request['did'] = widget.squareId;
  274. if(value=='拉黑'){
  275. request['isBlack'] = 1;
  276. }else if(value=='不感兴趣'){
  277. request['isBlack'] = 0;
  278. }
  279. Map dict = await ysRequestHttp(context, type: requestType.post,api: url,parameter: request,isLoading: false,isToken: true);
  280. if (dict != null) {
  281. ysFlutterToast(context,'${value=='不感兴趣'?'此内容已添加为不感兴趣':'已拉黑该用户'}');
  282. Navigator.of(context).pop('');
  283. }
  284. }
  285. },
  286. )
  287. ],
  288. ),
  289. margin: EdgeInsets.only(top: MediaQuery.of(context).padding.top+15,left: 15,bottom: 65),
  290. ),
  291. _dict==null?Container():Container(
  292. margin: EdgeInsets.only(top: hsp(200)),
  293. height: 60,
  294. padding: EdgeInsets.only(left: 15,right: 15,top: 10,bottom: 10),
  295. child: Row(
  296. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  297. children: [
  298. Container(
  299. height: 40,
  300. width: 40,
  301. decoration: BoxDecoration(
  302. borderRadius: BorderRadius.all(Radius.circular(20)),
  303. image: DecorationImage(image: NetworkImage('${_dict['user']['avatar']}'),fit: BoxFit.fill)
  304. ),
  305. margin: EdgeInsets.only(right: 6),
  306. ),
  307. Column(
  308. mainAxisAlignment: MainAxisAlignment.spaceEvenly,
  309. children: [
  310. Container(
  311. width: MediaQuery.of(context).size.width-170,
  312. child: Text('${_dict['user']['nickname']}',style: TextStyle(fontSize: 14,color: Colors.white,decoration: TextDecoration.none),),
  313. ),
  314. Container(
  315. width: MediaQuery.of(context).size.width-170,
  316. child: Text('旅游达人',style: TextStyle(fontSize: 10,color: Colors.white,decoration: TextDecoration.none,fontWeight: FontWeight.normal),),
  317. )
  318. ],
  319. ),
  320. Container(
  321. height: 30,
  322. width: 65,
  323. child: Image.asset('lib/images/look.png',color: Colors.white,),
  324. ),
  325. ],
  326. ),
  327. ),
  328. _dict==null?Container():Container(
  329. width: MediaQuery.of(context).size.width,
  330. padding: EdgeInsets.only(top: MediaQuery.of(context).size.height-200,left: 10,right: 10,bottom: 15),
  331. child: Column(
  332. crossAxisAlignment: CrossAxisAlignment.start,
  333. children: [
  334. Text('${_dict['videoTitle']}',style: TextStyle(fontSize: 17,color: Colors.white,decoration: TextDecoration.none),),
  335. Container(
  336. width: MediaQuery.of(context).size.width,
  337. height: 100,
  338. padding: EdgeInsets.only(left: 10,right: 10,bottom: 15,top: 5),
  339. child: SingleChildScrollView(
  340. child: Text('${_dict['videoContent']}',
  341. style: TextStyle(fontSize: 14,color: Colors.white,decoration: TextDecoration.none,fontWeight: FontWeight.normal),),
  342. ),
  343. )
  344. ],
  345. )
  346. ),
  347. ],
  348. ),
  349. ),
  350. ),
  351. if(widget.isShow)Container(
  352. height: 50,
  353. padding: EdgeInsets.only(left: 15,right: 15),
  354. color: Color(0xFF000000),
  355. child: Row(
  356. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  357. children: [
  358. Container(
  359. width: MediaQuery.of(context).size.width-120,
  360. padding: EdgeInsets.only(left: 15,right: 15),
  361. height: 30,
  362. decoration: BoxDecoration(
  363. color: Color(0xFF3B3B3B),
  364. borderRadius: BorderRadius.all(Radius.circular(15))
  365. ),
  366. child: Row(
  367. children: [
  368. GestureDetector(
  369. onTap: (){
  370. _createCommentView();
  371. },
  372. child: Container(
  373. width: MediaQuery.of(context).size.width-175,
  374. child: Text('我来说两句',style: TextStyle(fontSize: 14,color: Color(0xFF9A9A9A),decoration: TextDecoration.none,fontWeight: FontWeight.normal),),
  375. ),
  376. ),
  377. Icon(Icons.tag_faces,size: 25,color: Color(0xFFA1A1A2),),
  378. ],
  379. ),
  380. ),
  381. GestureDetector(
  382. onTap: (){
  383. _postAgreementData(1);
  384. },
  385. child: Container(
  386. height: 20,
  387. width: 20,
  388. child: Image.asset(_dict==null?'lib/images/love.png':_dict['likeStatus']==1?'lib/images/love2.png':'lib/images/love.png',color: Colors.white,),
  389. ),
  390. ),
  391. GestureDetector(
  392. child: Icon(_dict==null?Icons.star_border:_dict['collectStatus']==1?Icons.star:Icons.star_border,size: 20,color: Colors.white,),
  393. onTap: (){
  394. _postAgreementData(0);
  395. },
  396. ),
  397. // Icon(Icons.share,size: 20,color: Colors.white,),
  398. ],
  399. ),
  400. )
  401. ],
  402. ),
  403. ),
  404. );
  405. }
  406. _createCommentView() async{
  407. page = 1;
  408. Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/piazza/SquareCommunity/comment/list',
  409. parameter: {'pageNo':page,'pageSize':10,'id':widget.squareId,'type':widget.typeId},isToken: true,isLoading: false);
  410. if(dict!=null){
  411. comments = dict['data']['resultList'];
  412. showModalBottomSheet(
  413. backgroundColor: Colors.transparent,
  414. isScrollControlled: true,
  415. context: context,
  416. builder: (context){
  417. return StatefulBuilder(
  418. builder: (context,stateSub){
  419. ysState = stateSub;
  420. return Container(
  421. height: MediaQuery.of(context).size.height*0.6,
  422. color: Color(0xFF2A2628),
  423. child: Column(
  424. children: [
  425. Container(
  426. height: 40,
  427. padding: EdgeInsets.only(left: 15,right: 15),
  428. child: Row(
  429. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  430. children: [
  431. Container(),
  432. Text('${comments.length}条评论',style: TextStyle(fontSize: 14,color: Colors.white,decoration: TextDecoration.none),),
  433. GestureDetector(
  434. onTap: (){Navigator.pop(context);},
  435. child: Icon(Icons.close,size: 20,color: Colors.white,),
  436. )
  437. ],
  438. ),
  439. ),
  440. Container(
  441. height: MediaQuery.of(context).size.height*0.6-90,
  442. child: EasyRefresh(
  443. onRefresh: _refreshData,
  444. onLoad: _loadMore,
  445. header: MaterialHeader(
  446. ),
  447. footer: BezierBounceFooter(
  448. backgroundColor: Colors.transparent,
  449. color: Colors.transparent,
  450. ),
  451. child: ListView.separated(
  452. padding: EdgeInsets.only(top: 15),
  453. shrinkWrap: true,
  454. itemBuilder: (context,index){
  455. return Container(
  456. child: Column(
  457. children: [
  458. Container(
  459. padding: EdgeInsets.only(left: 10,right: 10,bottom: 10),
  460. child: Row(
  461. crossAxisAlignment: CrossAxisAlignment.start,
  462. children: [
  463. Container(
  464. height: 40,
  465. width: 40,
  466. decoration: BoxDecoration(
  467. borderRadius: BorderRadius.all(Radius.circular(20)),
  468. image: DecorationImage(image: NetworkImage('${comments[index]['avatar']}'),fit: BoxFit.fill)
  469. ),
  470. ),
  471. Container(
  472. margin: EdgeInsets.only(left: 10),
  473. width: MediaQuery.of(context).size.width-70,
  474. child: Column(
  475. crossAxisAlignment: CrossAxisAlignment.start,
  476. children: [
  477. GestureDetector(
  478. child: Text('${comments[index]['nickname']}',style: TextStyle(fontSize: 14,color: Color(0xFF929293),decoration: TextDecoration.none,fontWeight: FontWeight.bold),),
  479. onTap: (){
  480. _showInputView(type: 1,toUserid: int.parse('${comments[index]['fromUserId']}'),
  481. fatherCommentId: int.parse('${comments[index]['id']}'),fromUserId: int.parse('${comments[index]['fromUserId']}'));
  482. },
  483. ),
  484. Text('${comments[index]['comment']}',style: TextStyle(fontSize: 15,color: Colors.white,decoration: TextDecoration.none,fontWeight: FontWeight.normal)),
  485. ],
  486. ),
  487. )
  488. ],
  489. ),
  490. ),
  491. Container(
  492. child: ListView.separated(
  493. itemBuilder: (context,indexSub){
  494. return Row(
  495. crossAxisAlignment: CrossAxisAlignment.start,
  496. children: [
  497. Container(
  498. height: 20,
  499. width: 20,
  500. decoration: BoxDecoration(
  501. borderRadius: BorderRadius.all(Radius.circular(20)),
  502. image: DecorationImage(image: NetworkImage('${comments[index]['dtSquareCommentsList'][indexSub]['avatar']}'),fit: BoxFit.fill)
  503. ),
  504. ),
  505. Container(
  506. margin: EdgeInsets.only(left: 10),
  507. width: MediaQuery.of(context).size.width-130,
  508. child: Column(
  509. crossAxisAlignment: CrossAxisAlignment.start,
  510. children: [
  511. GestureDetector(
  512. child: Text('${comments[index]['dtSquareCommentsList'][indexSub]['nickname']}',
  513. style: TextStyle(fontSize: 14,color: Color(0xFF929293),decoration: TextDecoration.none,fontWeight: FontWeight.bold),),
  514. onTap: (){
  515. _showInputView(type: 1,toUserid: comments[index]['dtSquareCommentsList'][indexSub]['toUserId'],
  516. fatherCommentId: comments[index]['dtSquareCommentsList'][indexSub]['fatherCommentId'],fromUserId: comments[index]['dtSquareCommentsList'][indexSub]['fromUserId']);
  517. },
  518. ),
  519. RichText(
  520. text: TextSpan(
  521. style: TextStyle(fontSize: 14,color: Colors.white,decoration: TextDecoration.none,fontWeight: FontWeight.normal),
  522. text: '回复',
  523. children: [
  524. TextSpan(
  525. text: ' ${comments[index]['dtSquareCommentsList'][indexSub]['otherNickname']}:',
  526. style: TextStyle(color: Color(0xFF929293),fontWeight: FontWeight.bold),
  527. recognizer: TapGestureRecognizer()..onTap = (){
  528. _showInputView(type: 1,toUserid: comments[index]['dtSquareCommentsList'][indexSub]['toUserId'],
  529. fatherCommentId: comments[index]['dtSquareCommentsList'][indexSub]['fatherCommentId'],fromUserId: comments[index]['dtSquareCommentsList'][indexSub]['fromUserId']);
  530. }
  531. ),
  532. TextSpan(
  533. text: '${comments[index]['dtSquareCommentsList'][indexSub]['comment']}',
  534. style: TextStyle(color: Colors.white)
  535. ),
  536. TextSpan(
  537. text: ' ${comments[index]['dtSquareCommentsList'][indexSub]['timeNode']}',
  538. style: TextStyle(color: Color(0xFF929293),fontSize: 12)
  539. )
  540. ]
  541. ),
  542. )
  543. ],
  544. ),
  545. )
  546. ],
  547. );
  548. },
  549. separatorBuilder: (context,index){
  550. return Container(
  551. height: 5,
  552. );
  553. },
  554. itemCount: (comments[index]['dtSquareCommentsList']).length,
  555. shrinkWrap: true,
  556. padding: EdgeInsets.only(left: 60,right: 40),
  557. physics: NeverScrollableScrollPhysics(),
  558. ),
  559. )
  560. ],
  561. ),
  562. );
  563. },
  564. separatorBuilder: (context,index){
  565. return Container(
  566. height: 5,
  567. );
  568. },
  569. itemCount: comments.length,
  570. ),
  571. ),
  572. ),
  573. Container(
  574. height: 50,
  575. padding: EdgeInsets.only(left: 15,right: 15),
  576. child: Row(
  577. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  578. children: [
  579. GestureDetector(
  580. child: Text('有爱评论,说点儿好听的~',style: TextStyle(fontSize: 15,color: Color(0xFF5A5A5A),decoration: TextDecoration.none,fontWeight: FontWeight.normal),),
  581. onTap: (){
  582. _showInputView(type: 0);
  583. }
  584. ),
  585. Icon(Icons.tag_faces,size: 25,color: Color(0xFFA1A1A2),),
  586. ],
  587. ),
  588. )
  589. ],
  590. ),
  591. );
  592. },
  593. );
  594. }
  595. );
  596. }
  597. }
  598. _showInputView({int type,int toUserid,int fatherCommentId,int fromUserId}){
  599. TextEditingController _text = TextEditingController();
  600. showModalBottomSheet(
  601. context: context,
  602. barrierColor: Colors.transparent,
  603. backgroundColor: Colors.transparent,
  604. isScrollControlled: true,
  605. builder: (context){
  606. return SingleChildScrollView(
  607. padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
  608. child: Container(
  609. height: 140,
  610. padding: EdgeInsets.only(left: hsp(30),right: hsp(30),top: hsp(30)),
  611. decoration: BoxDecoration(
  612. borderRadius: BorderRadius.only(topLeft: Radius.circular(10),topRight: Radius.circular(10)),
  613. color: Colors.white
  614. ),
  615. child: Column(
  616. children: [
  617. Row(
  618. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  619. children: [
  620. Text('评论',style: TextStyle(fontSize: 15,color: Color(0xFF424242),decoration: TextDecoration.none,fontWeight: FontWeight.bold),),
  621. GestureDetector(
  622. child: Text('发布',style: TextStyle(fontSize: 15,color: Color(0xFF4187D9),decoration: TextDecoration.none,fontWeight: FontWeight.bold),),
  623. onTap: (){
  624. if(type==0){
  625. _postCommentData({'comment':_text.text,'squareId':widget.squareId,'fatherCommentId':0,'fromUserId':0});
  626. }else{
  627. _postCommentData({'comment':_text.text,'squareId':widget.squareId,'fatherCommentId':fatherCommentId,'toUserId':toUserid,'fromUserId':fromUserId});
  628. }
  629. },
  630. ),
  631. ],
  632. ),
  633. Container(
  634. height: 50,
  635. decoration: BoxDecoration(
  636. color: Color(0xFFF7F7F7),
  637. borderRadius: BorderRadius.all(Radius.circular(10))
  638. ),
  639. margin: EdgeInsets.only(top: 10,bottom: 10),
  640. child: CupertinoTextField(
  641. placeholder: '友善发言,理性讨论,阳光你我',
  642. style: TextStyle(fontSize: 14,color: Color(0xFF999999),decoration: TextDecoration.none,fontWeight: FontWeight.normal),
  643. placeholderStyle: TextStyle(fontSize: 14,color: Color(0xFF999999),decoration: TextDecoration.none,fontWeight: FontWeight.normal),
  644. decoration: BoxDecoration(),
  645. maxLines: 50,
  646. autofocus: true,
  647. controller: _text,
  648. ),
  649. ),
  650. Row(
  651. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  652. children: [
  653. Container(),
  654. Icon(Icons.tag_faces,size: 25,color: Color(0xFF5C5C5C),),
  655. ],
  656. )
  657. ],
  658. ),
  659. ),
  660. );
  661. }
  662. );
  663. // Navigator.push(context, PopRoute(child: BottomInputDialog(
  664. // height: 140,
  665. // inputView: Column(
  666. // children: [
  667. // Row(
  668. // mainAxisAlignment: MainAxisAlignment.spaceBetween,
  669. // children: [
  670. // Text('评论',style: TextStyle(fontSize: 15,color: Color(0xFF424242),decoration: TextDecoration.none,fontWeight: FontWeight.bold),),
  671. // GestureDetector(
  672. // child: Text('发布',style: TextStyle(fontSize: 15,color: Color(0xFF4187D9),decoration: TextDecoration.none,fontWeight: FontWeight.bold),),
  673. // onTap: (){
  674. // if(type==0){
  675. // _postCommentData({'comment':_text.text,'squareId':widget.squareId,'fatherCommentId':0,'fromUserId':0});
  676. // }else{
  677. // _postCommentData({'comment':_text.text,'squareId':widget.squareId,'fatherCommentId':fatherCommentId,'toUserId':toUserid,'fromUserId':fromUserId});
  678. // }
  679. // },
  680. // ),
  681. // ],
  682. // ),
  683. // Container(
  684. // height: 50,
  685. // decoration: BoxDecoration(
  686. // color: Color(0xFFF7F7F7),
  687. // borderRadius: BorderRadius.all(Radius.circular(10))
  688. // ),
  689. // margin: EdgeInsets.only(top: 10,bottom: 10),
  690. // child: CupertinoTextField(
  691. // placeholder: '友善发言,理性讨论,阳光你我',
  692. // style: TextStyle(fontSize: 14,color: Color(0xFF999999),decoration: TextDecoration.none,fontWeight: FontWeight.normal),
  693. // placeholderStyle: TextStyle(fontSize: 14,color: Color(0xFF999999),decoration: TextDecoration.none,fontWeight: FontWeight.normal),
  694. // decoration: BoxDecoration(),
  695. // maxLines: 50,
  696. // autofocus: true,
  697. // controller: _text,
  698. // ),
  699. // ),
  700. // Row(
  701. // mainAxisAlignment: MainAxisAlignment.spaceBetween,
  702. // children: [
  703. // Container(),
  704. // Icon(Icons.tag_faces,size: 25,color: Color(0xFF5C5C5C),),
  705. // ],
  706. // )
  707. // ],
  708. // ),
  709. // )));
  710. }
  711. Future<void> _refreshData() async{
  712. page = 1;
  713. Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/piazza/SquareCommunity/comment/list',
  714. parameter: {'pageNo':page,'pageSize':10,'id':widget.squareId,'type':widget.typeId},isToken: true,isLoading: false);
  715. if(dict!=null){
  716. ysState(() {
  717. comments = dict['data']['resultList'];
  718. });
  719. }
  720. }
  721. Future<void> _loadMore() async{
  722. page++;
  723. Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/piazza/SquareCommunity/comment/list',
  724. parameter: {'pageNo':page,'pageSize':10,'id':widget.squareId,'type':widget.typeId},isToken: true,isLoading: false);
  725. if(dict!=null){
  726. ysState(() {
  727. comments.addAll(dict['data']['resultList']);
  728. });
  729. }
  730. }
  731. _postCommentData(Map parma) async{
  732. Map dict = await ysRequestHttp(context,type: requestType.post,api: '/app/piazza/SquareCommunity/comment/add',
  733. parameter: parma,isLoading: false,isToken: true);
  734. if(dict!=null){
  735. //FocusScope.of(context).requestFocus(FocusNode());
  736. Navigator.pop(context);
  737. _refreshData();
  738. }
  739. }
  740. Future<void> _getSquareDetailData() async{
  741. Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/piazza/SquareCommunity/details',
  742. parameter: {'id':widget.squareId,'type':widget.typeId},isLoading: true,isToken: true,refresh: (){
  743. _getSquareDetailData();
  744. });
  745. if(dict!=null){
  746. _controller = VideoPlayerController.network('${dict['data']['videoPath']}')
  747. // 播放状态
  748. ..addListener(() {
  749. final bool isPlaying = _controller.value.isPlaying;
  750. if (isPlaying != _isPlaying) {
  751. setState(() { _isPlaying = isPlaying; });
  752. }
  753. })
  754. // 在初始化完成后必须更新界面
  755. ..initialize().then((_) {
  756. _controller.setLooping(true);
  757. _controller.play();
  758. setState(() {});
  759. });
  760. setState(() {
  761. _dict = dict['data'];
  762. });
  763. }
  764. }
  765. _postAgreementData(int type) async{
  766. Map request = {'type':type};
  767. request['topicId'] = widget.squareId;
  768. Map dict = await ysRequestHttp(context,type: requestType.post,api: '/app/piazza/SquareCommunity/likeAndCollect',
  769. parameter: request,isLoading: false,isToken: true,refresh: (){
  770. });
  771. if(dict!=null){
  772. setState(() {
  773. if(type==1){
  774. _dict['likeStatus'] = dict['data'];
  775. }else{
  776. _dict['collectStatus'] = dict['data'];
  777. }
  778. });
  779. }
  780. }
  781. }
  782. class _PlayPauseOverlay extends StatelessWidget {
  783. const _PlayPauseOverlay({Key key, this.controller}) : super(key: key);
  784. final VideoPlayerController controller;
  785. @override
  786. Widget build(BuildContext context) {
  787. return Stack(
  788. children: <Widget>[
  789. AnimatedSwitcher(
  790. duration: Duration(milliseconds: 50),
  791. reverseDuration: Duration(milliseconds: 200),
  792. child: controller.value.isPlaying? SizedBox.shrink():Container(
  793. color: Colors.black26,
  794. child: Center(
  795. child: Icon(
  796. Icons.play_circle_filled,
  797. color: Colors.white,
  798. size: 50,
  799. ),
  800. ),
  801. ),
  802. ),
  803. GestureDetector(
  804. onTap: () {
  805. controller.value.isPlaying ? controller.pause() : controller.play();
  806. },
  807. ),
  808. ],
  809. );
  810. }
  811. }