123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826 |
- import 'dart:io';
- import 'package:flutter/cupertino.dart';
- import 'package:flutter/gestures.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter_easyrefresh/easy_refresh.dart';
- import 'package:image_picker/image_picker.dart';
- import 'package:qiniu_flutter_sdk/qiniu_flutter_sdk.dart';
- import 'package:ysairplane2/tools/YSNetWorking.dart';
- import 'package:ysairplane2/tools/YSTools.dart';
- import 'package:video_player/video_player.dart';
- class YSSquareVideo extends StatefulWidget {
- final squareId,typeId,isShow;
- const YSSquareVideo({Key key, this.squareId, this.typeId, this.isShow}) : super(key: key);
- @override
- _YSSquareVideoState createState() => _YSSquareVideoState();
- }
- class _YSSquareVideoState extends State<YSSquareVideo> {
- VideoPlayerController _controller;
- bool _isPlaying = false;
- Map _dict;
- int page = 1;
- List comments = [];
- var ysState;
- List _imageArray = [];
- String _tokenStr = '';
- String _urlStr = '';
- TextEditingController _textField = TextEditingController();
- var _imageSet;
- @override
- void initState() {
- Future.delayed(Duration(seconds: 0)).then((value){
- _getSquareDetailData();
- _getQiNiuTokenData();
- });
- super.initState();
- }
- @override
- void dispose() {
- _controller.dispose();
- super.dispose();
- }
- _onUpload(var value) async {
- if (value == null) {
- return;
- }
- print(value.path);
- print(_tokenStr);
- Storage storage = Storage();
- storage.putFile(
- File(value.path),
- _tokenStr,
- options: PutOptions(
- key: DateTime.now().millisecondsSinceEpoch.toString() +'.' +value.path.split('.').last,
- ),
- ).then((result) async{
- _imageSet(() {
- _imageArray.add(_urlStr+'${result.key}');
- });
- });
- }
- _getQiNiuTokenData() async{
- Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/getToken',parameter: {},isLoading: false,isToken: false);
- if(dict!=null){
- _tokenStr = dict['token'];
- _urlStr = dict['prefix'];
- }
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- body: SingleChildScrollView(
- child: Column(
- children: [
- Container(
- height: MediaQuery.of(context).size.height-(widget.isShow?50:0),
- width: MediaQuery.of(context).size.width,
- color: Color(0xFF1D1D1D),
- child: SingleChildScrollView(
- child: Stack(
- // crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- if (_controller==null) Container(
- height: 200,
- color: Colors.black12,
- ) else Container(
- height: MediaQuery.of(context).size.height-50,
- child: Stack(
- alignment: Alignment.bottomCenter,
- children: <Widget>[
- Center(
- child: AspectRatio(
- child: VideoPlayer(_controller),
- aspectRatio: _controller.value.aspectRatio ,
- ),
- ),
- _PlayPauseOverlay(controller: _controller),
- Container(
- height:6.5,
- child: VideoProgressIndicator(
- _controller,
- allowScrubbing: true,
- colors: VideoProgressColors(playedColor: Color(0xFF1961E3),backgroundColor: Colors.white),
- )
- ),
- ],
- ),
- ),
- Container(
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- GestureDetector(
- child: Icon(Icons.arrow_back_ios,size: 20,color: Colors.white,),
- onTap: (){
- Navigator.pop(context);
- },
- ),
- PopupMenuButton<String>(
- itemBuilder: (context) {
- return <PopupMenuEntry<String>>[
- PopupMenuItem<String>(
- value: '不感兴趣',
- child: Text('不感兴趣'),
- ),
- PopupMenuItem<String>(
- value: '拉黑',
- child: Text('拉黑'),
- ),
- PopupMenuItem<String>(
- value: '举报',
- child: Text('举报'),
- ),
- ];
- },
- icon: Icon(Icons.more_horiz_outlined,size: 25,color: Colors.white,),
- padding: EdgeInsets.all(0),
- onSelected: (value) async{
- if(value=='举报'){
- _imageArray.clear();
- _textField.text = '';
- showModalBottomSheet(
- context: context,
- builder: (context){
- return Container(
- height: hsp(700),
- width: MediaQuery.of(context).size.width,
- color: Colors.white,
- child: Column(
- children: [
- Container(
- height: hsp(100),
- child: Text('举报',style: TextStyle(fontSize: zsp(30),color: Colors.black),),
- alignment: Alignment.center,
- decoration: BoxDecoration(
- border: Border(bottom: BorderSide(color: Color(0xFFEEEEEE),width: 0.5))
- ),
- ),
- Container(
- height: hsp(300),
- child: CupertinoTextField(
- placeholder: '请输入举报理由',
- style: TextStyle(fontSize: zsp(30),color: Color(0xFF333739)),
- maxLines: 50,
- controller: _textField,
- ),
- padding: EdgeInsets.all(hsp(30)),
- ),
- StatefulBuilder(
- builder: (context,imageSet){
- _imageSet = imageSet;
- return Container(
- height: hsp(200),
- child: GridView.builder(
- gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
- crossAxisCount: 1,
- mainAxisSpacing: hsp(30)
- ),
- scrollDirection: Axis.horizontal,
- itemBuilder: (context,index){
- return _imageArray.length>index?Container(
- child: Image.network(_imageArray[index],fit: BoxFit.fill,),
- ):GestureDetector(
- onTap: () async{
- ImagePicker _picker = ImagePicker();
- showCupertinoModalPopup(
- context: context,
- builder: (context) {
- return CupertinoActionSheet(
- actions: <Widget>[
- CupertinoActionSheetAction(
- child: Text('拍摄照片'),
- onPressed: () {
- Navigator.pop(context);
- _picker.getImage(source: ImageSource.camera).then((value){
- _onUpload(value);
- });
- },
- ),
- CupertinoActionSheetAction(
- child: Text('选择图片'),
- onPressed: () {
- Navigator.pop(context);
- _picker.getImage(source: ImageSource.gallery).then((value){
- _onUpload(value);
- });
- },
- ),
- ],
- cancelButton: CupertinoActionSheetAction(
- child: Text('取消'),
- onPressed: () {
- Navigator.pop(context);
- },
- ),
- );
- }
- );
- },
- child: Container(
- decoration: BoxDecoration(
- border: Border.all(color: Color(0xFFEEEEEE),width: 1)
- ),
- child: Icon(Icons.add_photo_alternate_rounded,color: Color(0xFFEEEEEE),size: hsp(80),),
- alignment: Alignment.center,
- ),
- );
- },
- itemCount: _imageArray.length>0?_imageArray.length:_imageArray.length+1,
- ),
- padding: EdgeInsets.only(left: hsp(30),right: hsp(30),bottom: hsp(30)),
- );
- },
- ),
- GestureDetector(
- child: Container(
- height: hsp(100),
- color: Color(0xFF007AFF),
- margin: EdgeInsets.only(left: hsp(50),right: hsp(50)),
- child: Text('提交',style: TextStyle(fontSize: zsp(30),color: Colors.white),),
- alignment: Alignment.center,
- ),
- onTap: () async{
- if(_textField.text.isEmpty){
- ysFlutterToast(context, '请输入举报理由');
- return;
- }
- if(_imageArray.length==0){
- ysFlutterToast(context, '请添加举报图片');
- return;
- }
- String url = '/app/applets/feedback/toReport';
- Map request = {};
- request['type'] = 2;
- request['did'] = widget.squareId;
- request['content'] = _textField.text;
- request['pic'] = _imageArray[0];
- Map dict = await ysRequestHttp(context, type: requestType.post,api: url,parameter: request,isLoading: false,isToken: true);
- if (dict != null) {
- ysFlutterToast(context,'已举报该用户');
- Navigator.of(context).pop('');
- }
- },
- ),
- ],
- ),
- );
- }
- );
- }else{
- String url = '/app/black/shielding';
- Map request = {};
- request['type'] = 2;
- request['did'] = widget.squareId;
- if(value=='拉黑'){
- request['isBlack'] = 1;
- }else if(value=='不感兴趣'){
- request['isBlack'] = 0;
- }
- Map dict = await ysRequestHttp(context, type: requestType.post,api: url,parameter: request,isLoading: false,isToken: true);
- if (dict != null) {
- ysFlutterToast(context,'${value=='不感兴趣'?'此内容已添加为不感兴趣':'已拉黑该用户'}');
- Navigator.of(context).pop('');
- }
- }
- },
- )
- ],
- ),
- margin: EdgeInsets.only(top: MediaQuery.of(context).padding.top+15,left: 15,bottom: 65),
- ),
- _dict==null?Container():Container(
- margin: EdgeInsets.only(top: hsp(200)),
- height: 60,
- padding: EdgeInsets.only(left: 15,right: 15,top: 10,bottom: 10),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Container(
- height: 40,
- width: 40,
- decoration: BoxDecoration(
- borderRadius: BorderRadius.all(Radius.circular(20)),
- image: DecorationImage(image: NetworkImage('${_dict['user']['avatar']}'),fit: BoxFit.fill)
- ),
- margin: EdgeInsets.only(right: 6),
- ),
- Column(
- mainAxisAlignment: MainAxisAlignment.spaceEvenly,
- children: [
- Container(
- width: MediaQuery.of(context).size.width-170,
- child: Text('${_dict['user']['nickname']}',style: TextStyle(fontSize: 14,color: Colors.white,decoration: TextDecoration.none),),
- ),
- Container(
- width: MediaQuery.of(context).size.width-170,
- child: Text('旅游达人',style: TextStyle(fontSize: 10,color: Colors.white,decoration: TextDecoration.none,fontWeight: FontWeight.normal),),
- )
- ],
- ),
- Container(
- height: 30,
- width: 65,
- child: Image.asset('lib/images/look.png',color: Colors.white,),
- ),
- ],
- ),
- ),
- _dict==null?Container():Container(
- width: MediaQuery.of(context).size.width,
- padding: EdgeInsets.only(top: MediaQuery.of(context).size.height-200,left: 10,right: 10,bottom: 15),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text('${_dict['videoTitle']}',style: TextStyle(fontSize: 17,color: Colors.white,decoration: TextDecoration.none),),
- Container(
- width: MediaQuery.of(context).size.width,
- height: 100,
- padding: EdgeInsets.only(left: 10,right: 10,bottom: 15,top: 5),
- child: SingleChildScrollView(
- child: Text('${_dict['videoContent']}',
- style: TextStyle(fontSize: 14,color: Colors.white,decoration: TextDecoration.none,fontWeight: FontWeight.normal),),
- ),
- )
- ],
- )
- ),
- ],
- ),
- ),
- ),
- if(widget.isShow)Container(
- height: 50,
- padding: EdgeInsets.only(left: 15,right: 15),
- color: Color(0xFF000000),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Container(
- width: MediaQuery.of(context).size.width-120,
- padding: EdgeInsets.only(left: 15,right: 15),
- height: 30,
- decoration: BoxDecoration(
- color: Color(0xFF3B3B3B),
- borderRadius: BorderRadius.all(Radius.circular(15))
- ),
- child: Row(
- children: [
- GestureDetector(
- onTap: (){
- _createCommentView();
- },
- child: Container(
- width: MediaQuery.of(context).size.width-175,
- child: Text('我来说两句',style: TextStyle(fontSize: 14,color: Color(0xFF9A9A9A),decoration: TextDecoration.none,fontWeight: FontWeight.normal),),
- ),
- ),
- Icon(Icons.tag_faces,size: 25,color: Color(0xFFA1A1A2),),
- ],
- ),
- ),
- GestureDetector(
- onTap: (){
- _postAgreementData(1);
- },
- child: Container(
- height: 20,
- width: 20,
- child: Image.asset(_dict==null?'lib/images/love.png':_dict['likeStatus']==1?'lib/images/love2.png':'lib/images/love.png',color: Colors.white,),
- ),
- ),
- GestureDetector(
- child: Icon(_dict==null?Icons.star_border:_dict['collectStatus']==1?Icons.star:Icons.star_border,size: 20,color: Colors.white,),
- onTap: (){
- _postAgreementData(0);
- },
- ),
- // Icon(Icons.share,size: 20,color: Colors.white,),
- ],
- ),
- )
- ],
- ),
- ),
- );
- }
- _createCommentView() async{
- page = 1;
- Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/piazza/SquareCommunity/comment/list',
- parameter: {'pageNo':page,'pageSize':10,'id':widget.squareId,'type':widget.typeId},isToken: true,isLoading: false);
- if(dict!=null){
- comments = dict['data']['resultList'];
- showModalBottomSheet(
- backgroundColor: Colors.transparent,
- isScrollControlled: true,
- context: context,
- builder: (context){
- return StatefulBuilder(
- builder: (context,stateSub){
- ysState = stateSub;
- return Container(
- height: MediaQuery.of(context).size.height*0.6,
- color: Color(0xFF2A2628),
- child: Column(
- children: [
- Container(
- height: 40,
- padding: EdgeInsets.only(left: 15,right: 15),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Container(),
- Text('${comments.length}条评论',style: TextStyle(fontSize: 14,color: Colors.white,decoration: TextDecoration.none),),
- GestureDetector(
- onTap: (){Navigator.pop(context);},
- child: Icon(Icons.close,size: 20,color: Colors.white,),
- )
- ],
- ),
- ),
- Container(
- height: MediaQuery.of(context).size.height*0.6-90,
- child: EasyRefresh(
- onRefresh: _refreshData,
- onLoad: _loadMore,
- header: MaterialHeader(
- ),
- footer: BezierBounceFooter(
- backgroundColor: Colors.transparent,
- color: Colors.transparent,
- ),
- child: ListView.separated(
- padding: EdgeInsets.only(top: 15),
- shrinkWrap: true,
- itemBuilder: (context,index){
- return Container(
- child: Column(
- children: [
- Container(
- padding: EdgeInsets.only(left: 10,right: 10,bottom: 10),
- child: Row(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Container(
- height: 40,
- width: 40,
- decoration: BoxDecoration(
- borderRadius: BorderRadius.all(Radius.circular(20)),
- image: DecorationImage(image: NetworkImage('${comments[index]['avatar']}'),fit: BoxFit.fill)
- ),
- ),
- Container(
- margin: EdgeInsets.only(left: 10),
- width: MediaQuery.of(context).size.width-70,
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- GestureDetector(
- child: Text('${comments[index]['nickname']}',style: TextStyle(fontSize: 14,color: Color(0xFF929293),decoration: TextDecoration.none,fontWeight: FontWeight.bold),),
- onTap: (){
- _showInputView(type: 1,toUserid: int.parse('${comments[index]['fromUserId']}'),
- fatherCommentId: int.parse('${comments[index]['id']}'),fromUserId: int.parse('${comments[index]['fromUserId']}'));
- },
- ),
- Text('${comments[index]['comment']}',style: TextStyle(fontSize: 15,color: Colors.white,decoration: TextDecoration.none,fontWeight: FontWeight.normal)),
- ],
- ),
- )
- ],
- ),
- ),
- Container(
- child: ListView.separated(
- itemBuilder: (context,indexSub){
- return Row(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Container(
- height: 20,
- width: 20,
- decoration: BoxDecoration(
- borderRadius: BorderRadius.all(Radius.circular(20)),
- image: DecorationImage(image: NetworkImage('${comments[index]['dtSquareCommentsList'][indexSub]['avatar']}'),fit: BoxFit.fill)
- ),
- ),
- Container(
- margin: EdgeInsets.only(left: 10),
- width: MediaQuery.of(context).size.width-130,
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- GestureDetector(
- child: Text('${comments[index]['dtSquareCommentsList'][indexSub]['nickname']}',
- style: TextStyle(fontSize: 14,color: Color(0xFF929293),decoration: TextDecoration.none,fontWeight: FontWeight.bold),),
- onTap: (){
- _showInputView(type: 1,toUserid: comments[index]['dtSquareCommentsList'][indexSub]['toUserId'],
- fatherCommentId: comments[index]['dtSquareCommentsList'][indexSub]['fatherCommentId'],fromUserId: comments[index]['dtSquareCommentsList'][indexSub]['fromUserId']);
- },
- ),
- RichText(
- text: TextSpan(
- style: TextStyle(fontSize: 14,color: Colors.white,decoration: TextDecoration.none,fontWeight: FontWeight.normal),
- text: '回复',
- children: [
- TextSpan(
- text: ' ${comments[index]['dtSquareCommentsList'][indexSub]['otherNickname']}:',
- style: TextStyle(color: Color(0xFF929293),fontWeight: FontWeight.bold),
- recognizer: TapGestureRecognizer()..onTap = (){
- _showInputView(type: 1,toUserid: comments[index]['dtSquareCommentsList'][indexSub]['toUserId'],
- fatherCommentId: comments[index]['dtSquareCommentsList'][indexSub]['fatherCommentId'],fromUserId: comments[index]['dtSquareCommentsList'][indexSub]['fromUserId']);
- }
- ),
- TextSpan(
- text: '${comments[index]['dtSquareCommentsList'][indexSub]['comment']}',
- style: TextStyle(color: Colors.white)
- ),
- TextSpan(
- text: ' ${comments[index]['dtSquareCommentsList'][indexSub]['timeNode']}',
- style: TextStyle(color: Color(0xFF929293),fontSize: 12)
- )
- ]
- ),
- )
- ],
- ),
- )
- ],
- );
- },
- separatorBuilder: (context,index){
- return Container(
- height: 5,
- );
- },
- itemCount: (comments[index]['dtSquareCommentsList']).length,
- shrinkWrap: true,
- padding: EdgeInsets.only(left: 60,right: 40),
- physics: NeverScrollableScrollPhysics(),
- ),
- )
- ],
- ),
- );
- },
- separatorBuilder: (context,index){
- return Container(
- height: 5,
- );
- },
- itemCount: comments.length,
- ),
- ),
- ),
- Container(
- height: 50,
- padding: EdgeInsets.only(left: 15,right: 15),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- GestureDetector(
- child: Text('有爱评论,说点儿好听的~',style: TextStyle(fontSize: 15,color: Color(0xFF5A5A5A),decoration: TextDecoration.none,fontWeight: FontWeight.normal),),
- onTap: (){
- _showInputView(type: 0);
- }
- ),
- Icon(Icons.tag_faces,size: 25,color: Color(0xFFA1A1A2),),
- ],
- ),
- )
- ],
- ),
- );
- },
- );
- }
- );
- }
- }
- _showInputView({int type,int toUserid,int fatherCommentId,int fromUserId}){
- TextEditingController _text = TextEditingController();
- showModalBottomSheet(
- context: context,
- barrierColor: Colors.transparent,
- backgroundColor: Colors.transparent,
- isScrollControlled: true,
- builder: (context){
- return SingleChildScrollView(
- padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
- child: Container(
- height: 140,
- padding: EdgeInsets.only(left: hsp(30),right: hsp(30),top: hsp(30)),
- decoration: BoxDecoration(
- borderRadius: BorderRadius.only(topLeft: Radius.circular(10),topRight: Radius.circular(10)),
- color: Colors.white
- ),
- child: Column(
- children: [
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Text('评论',style: TextStyle(fontSize: 15,color: Color(0xFF424242),decoration: TextDecoration.none,fontWeight: FontWeight.bold),),
- GestureDetector(
- child: Text('发布',style: TextStyle(fontSize: 15,color: Color(0xFF4187D9),decoration: TextDecoration.none,fontWeight: FontWeight.bold),),
- onTap: (){
- if(type==0){
- _postCommentData({'comment':_text.text,'squareId':widget.squareId,'fatherCommentId':0,'fromUserId':0});
- }else{
- _postCommentData({'comment':_text.text,'squareId':widget.squareId,'fatherCommentId':fatherCommentId,'toUserId':toUserid,'fromUserId':fromUserId});
- }
- },
- ),
- ],
- ),
- Container(
- height: 50,
- decoration: BoxDecoration(
- color: Color(0xFFF7F7F7),
- borderRadius: BorderRadius.all(Radius.circular(10))
- ),
- margin: EdgeInsets.only(top: 10,bottom: 10),
- child: CupertinoTextField(
- placeholder: '友善发言,理性讨论,阳光你我',
- style: TextStyle(fontSize: 14,color: Color(0xFF999999),decoration: TextDecoration.none,fontWeight: FontWeight.normal),
- placeholderStyle: TextStyle(fontSize: 14,color: Color(0xFF999999),decoration: TextDecoration.none,fontWeight: FontWeight.normal),
- decoration: BoxDecoration(),
- maxLines: 50,
- autofocus: true,
- controller: _text,
- ),
- ),
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Container(),
- Icon(Icons.tag_faces,size: 25,color: Color(0xFF5C5C5C),),
- ],
- )
- ],
- ),
- ),
- );
- }
- );
- // Navigator.push(context, PopRoute(child: BottomInputDialog(
- // height: 140,
- // inputView: Column(
- // children: [
- // Row(
- // mainAxisAlignment: MainAxisAlignment.spaceBetween,
- // children: [
- // Text('评论',style: TextStyle(fontSize: 15,color: Color(0xFF424242),decoration: TextDecoration.none,fontWeight: FontWeight.bold),),
- // GestureDetector(
- // child: Text('发布',style: TextStyle(fontSize: 15,color: Color(0xFF4187D9),decoration: TextDecoration.none,fontWeight: FontWeight.bold),),
- // onTap: (){
- // if(type==0){
- // _postCommentData({'comment':_text.text,'squareId':widget.squareId,'fatherCommentId':0,'fromUserId':0});
- // }else{
- // _postCommentData({'comment':_text.text,'squareId':widget.squareId,'fatherCommentId':fatherCommentId,'toUserId':toUserid,'fromUserId':fromUserId});
- // }
- // },
- // ),
- // ],
- // ),
- // Container(
- // height: 50,
- // decoration: BoxDecoration(
- // color: Color(0xFFF7F7F7),
- // borderRadius: BorderRadius.all(Radius.circular(10))
- // ),
- // margin: EdgeInsets.only(top: 10,bottom: 10),
- // child: CupertinoTextField(
- // placeholder: '友善发言,理性讨论,阳光你我',
- // style: TextStyle(fontSize: 14,color: Color(0xFF999999),decoration: TextDecoration.none,fontWeight: FontWeight.normal),
- // placeholderStyle: TextStyle(fontSize: 14,color: Color(0xFF999999),decoration: TextDecoration.none,fontWeight: FontWeight.normal),
- // decoration: BoxDecoration(),
- // maxLines: 50,
- // autofocus: true,
- // controller: _text,
- // ),
- // ),
- // Row(
- // mainAxisAlignment: MainAxisAlignment.spaceBetween,
- // children: [
- // Container(),
- // Icon(Icons.tag_faces,size: 25,color: Color(0xFF5C5C5C),),
- // ],
- // )
- // ],
- // ),
- // )));
- }
- Future<void> _refreshData() async{
- page = 1;
- Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/piazza/SquareCommunity/comment/list',
- parameter: {'pageNo':page,'pageSize':10,'id':widget.squareId,'type':widget.typeId},isToken: true,isLoading: false);
- if(dict!=null){
- ysState(() {
- comments = dict['data']['resultList'];
- });
- }
- }
- Future<void> _loadMore() async{
- page++;
- Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/piazza/SquareCommunity/comment/list',
- parameter: {'pageNo':page,'pageSize':10,'id':widget.squareId,'type':widget.typeId},isToken: true,isLoading: false);
- if(dict!=null){
- ysState(() {
- comments.addAll(dict['data']['resultList']);
- });
- }
- }
- _postCommentData(Map parma) async{
- Map dict = await ysRequestHttp(context,type: requestType.post,api: '/app/piazza/SquareCommunity/comment/add',
- parameter: parma,isLoading: false,isToken: true);
- if(dict!=null){
- //FocusScope.of(context).requestFocus(FocusNode());
- Navigator.pop(context);
- _refreshData();
- }
- }
- Future<void> _getSquareDetailData() async{
- Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/piazza/SquareCommunity/details',
- parameter: {'id':widget.squareId,'type':widget.typeId},isLoading: true,isToken: true,refresh: (){
- _getSquareDetailData();
- });
- if(dict!=null){
- _controller = VideoPlayerController.network('${dict['data']['videoPath']}')
- // 播放状态
- ..addListener(() {
- final bool isPlaying = _controller.value.isPlaying;
- if (isPlaying != _isPlaying) {
- setState(() { _isPlaying = isPlaying; });
- }
- })
- // 在初始化完成后必须更新界面
- ..initialize().then((_) {
- _controller.setLooping(true);
- _controller.play();
- setState(() {});
- });
- setState(() {
- _dict = dict['data'];
- });
- }
- }
- _postAgreementData(int type) async{
- Map request = {'type':type};
- request['topicId'] = widget.squareId;
- Map dict = await ysRequestHttp(context,type: requestType.post,api: '/app/piazza/SquareCommunity/likeAndCollect',
- parameter: request,isLoading: false,isToken: true,refresh: (){
- });
- if(dict!=null){
- setState(() {
- if(type==1){
- _dict['likeStatus'] = dict['data'];
- }else{
- _dict['collectStatus'] = dict['data'];
- }
- });
- }
- }
- }
- class _PlayPauseOverlay extends StatelessWidget {
- const _PlayPauseOverlay({Key key, this.controller}) : super(key: key);
- final VideoPlayerController controller;
- @override
- Widget build(BuildContext context) {
- return Stack(
- children: <Widget>[
- AnimatedSwitcher(
- duration: Duration(milliseconds: 50),
- reverseDuration: Duration(milliseconds: 200),
- child: controller.value.isPlaying? SizedBox.shrink():Container(
- color: Colors.black26,
- child: Center(
- child: Icon(
- Icons.play_circle_filled,
- color: Colors.white,
- size: 50,
- ),
- ),
- ),
- ),
- GestureDetector(
- onTap: () {
- controller.value.isPlaying ? controller.pause() : controller.play();
- },
- ),
- ],
- );
- }
- }
|