YSSquareVideo.dart 42 KB

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