12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112 |
- import 'dart:math';
- import 'package:cached_network_image/cached_network_image.dart';
- import 'package:flutter/cupertino.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter_easyrefresh/easy_refresh.dart';
- import 'package:fluttertoast/fluttertoast.dart';
- import 'package:photo_view/photo_view.dart';
- import 'package:photo_view/photo_view_gallery.dart';
- import 'package:provider/provider.dart';
- import 'package:sport/bean/comment.dart';
- import 'package:sport/bean/comment_post.dart';
- import 'package:sport/pages/social/post_comment.dart';
- import 'package:sport/provider/game_info_model.dart';
- import 'package:sport/provider/lib/provider_widget.dart';
- import 'package:sport/provider/user_model.dart';
- import 'package:sport/services/api/inject_api.dart';
- import 'package:sport/services/api/resp.dart';
- import 'package:sport/widgets/box.dart';
- import 'package:sport/widgets/decoration.dart';
- import 'package:sport/widgets/dialog/bindphone_dialog.dart';
- import 'package:sport/widgets/dialog/comment_dialog.dart';
- import 'package:sport/widgets/error.dart';
- import 'package:sport/widgets/loading.dart';
- import 'package:sport/widgets/misc.dart';
- import 'package:sport/widgets/persistent_header.dart';
- import 'package:sport/widgets/small_label.dart';
- import 'package:sport/widgets/text_input.dart';
- class DetailBottom extends StatelessWidget {
- TabController _controller;
- List<dynamic> _images;
- List<dynamic> _labels;
- dynamic _fileSize;
- dynamic _publishDate;
- dynamic _developCompany;
- int _subjectId;
- DetailBottom(this._controller, this._images, this._labels, this._fileSize, this._publishDate, this._developCompany, this._subjectId);
- @override
- Widget build(BuildContext context) {
- return TabBarView(
- controller: _controller,
- children: <Widget>[
- TabDetail(_images, _labels, _fileSize, _publishDate, _developCompany),
- TabComment(_subjectId),
- ],
- );
- }
- }
- // Tab 详情 左边的tab页
- class TabDetail extends StatelessWidget {
- List<dynamic> _images;
- List<dynamic> _labels;
- dynamic _fileSize;
- dynamic _publishDate;
- dynamic _developCompany;
- TabDetail(this._images, this._labels, this._fileSize, this._publishDate, this._developCompany);
- @override
- Widget build(BuildContext context) {
- return SingleChildScrollView(
- child: Column(
- mainAxisSize: MainAxisSize.min,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[
- Padding(
- padding: const EdgeInsets.only(top: 12.0),
- child: SizedBox(
- height: 260,
- child: ListView.builder(
- scrollDirection: Axis.horizontal,
- shrinkWrap: true,
- itemBuilder: (context, index) {
- return GestureDetector(
- onTap: () => open(context, index),
- child: Padding(
- padding: EdgeInsets.only(left: (index == 0 ? 12.0 : 10.0), right: (index == _images.length - 1 ? 12.0 : 0.0)),
- child: ClipRRect(
- child: CachedNetworkImage(
- imageUrl: _images[index],
- width: 170,
- height: 226,
- fit: BoxFit.cover,
- ),
- borderRadius: BorderRadius.circular(10),
- ),
- ),
- );
- },
- itemCount: _images.length),
- ),
- ),
- SizedBox(height: 10,),
- Padding(
- padding: EdgeInsets.all(12.0),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[
- Padding(
- padding: EdgeInsets.only(bottom: 8.0),
- child: Row(
- children: <Widget>[
- Padding(
- padding: EdgeInsets.only(right: 2.0),
- child: Text(
- "运动标签:",
- style: TextStyle(color: Color.fromRGBO(102, 102, 102, 1)),
- ),
- ),
- if (_labels != null)
- Wrap(
- spacing: 4,
- runSpacing: 4,
- children: _labels.map((e) => gameTag(context, e)).toList(),
- ),
- ],
- ),
- ),
- Padding(
- padding: EdgeInsets.only(bottom: 8.0),
- child: Text("文件大小:${_fileSize}M", style: TextStyle(color: Color.fromRGBO(102, 102, 102, 1))),
- ),
- Padding(
- padding: EdgeInsets.only(bottom: 8.0),
- child: Text("发行时间:$_publishDate", style: TextStyle(color: Color.fromRGBO(102, 102, 102, 1))),
- ),
- Padding(
- padding: EdgeInsets.only(bottom: 8.0),
- child: Text("开发产商:$_developCompany", style: TextStyle(color: Color.fromRGBO(102, 102, 102, 1))),
- ),
- ],
- ),
- )
- // 第一个
- ],
- ),
- );
- }
- void open(BuildContext context, final int index) {
- Navigator.push(
- context,
- FadeRoute(
- page: GalleryPhotoViewWrapper(
- galleryItems: _images,
- backgroundDecoration: const BoxDecoration(
- color: Colors.black,
- ),
- initialIndex: index,
- scrollDirection: Axis.horizontal,
- ),
- ),
- );
- }
- }
- // 右边的tab
- class TabComment extends StatefulWidget {
- final int _subjectId;
- TabComment(this._subjectId);
- @override
- createState() => _TabCommentState();
- }
- class _TabCommentState extends State<TabComment> with InjectApi {
- FocusNode _comment = FocusNode();
- String _textFieldValue = "";
- CommentListModel _commentListModel;
- @override
- initState() {
- _commentListModel = new CommentListModel('${widget._subjectId}', by: 'created_at');
- super.initState();
- }
- Widget build(BuildContext context) {
- return ProviderWidget<CommentListModel>(
- model: _commentListModel,
- onModelReady: (model) => model.initData(),
- builder: (_, model, __) {
- return EasyRefresh.custom(
- controller: model.refreshController,
- enableControlFinishRefresh: true,
- enableControlFinishLoad: true,
- onRefresh: () => model.refresh(),
- onLoad: model.isIdle ? () => model.loadMore() : null,
- header: buildClassicalHeader(),
- footer: buildClassicalFooter(),
- slivers: [
- SliverPersistentHeader(
- delegate: PersistentHeader(
- min: 100,
- max: 100,
- child: Container(
- height: 100,
- margin: EdgeInsets.fromLTRB(12,12,12,24),
- padding: EdgeInsets.symmetric(horizontal: 12, vertical: 12.0),
- decoration: card(),
- child: InkWell(
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- crossAxisAlignment: CrossAxisAlignment.center,
- children: <Widget>[
- Row(
- children: <Widget>[
- Consumer<UserModel>(
- builder: (_, model, __) {
- return model.user == null
- ? Container()
- : Row(
- children: <Widget>[
- CircleAvatar(radius: 15, backgroundImage: CachedNetworkImageProvider(model.user.avatar)),
- SizedBox(
- width: 12,
- ),
- Text(model.user.name, style: Theme.of(context).textTheme.subtitle1.copyWith(fontWeight: FontWeight.w600))
- ],
- );
- },
- ),
- ],
- ),
- Row(
- children: <Widget>[
- Padding(
- padding: EdgeInsets.only(right: 0.0),
- child: Text(
- "发表评论",
- style: TextStyle(color: Color.fromRGBO(51, 51, 51, 1)),
- ),
- ),
- Icon(Icons.keyboard_arrow_right)
- ],
- )
- ],
- ),
- onTap: ()async {
- if (await showBindPhoneDialog(context) != true) {
- return;
- }
- // 从下面弹出个框来 输入 评论
- showModalBottomSheet(
- context: context,
- isScrollControlled: true, // !important
- builder: (BuildContext context) {
- return SingleChildScrollView(
- // !important
- child: Container(
- padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom), // !important
- child: TextInput(
- '${widget._subjectId}',
- focusNode: _comment,
- autoFocus: true,
- callback: () {
- model.refresh();
- Navigator.pop(context);
- },
- )),
- );
- },
- );
- },
- ),
- )),
- pinned: true,
- ),
- if (model.isBusy)
- SliverToBoxAdapter(
- child: RequestLoadingWidget(),
- ),
- if (model.isIdle && model.list.isNotEmpty)
- SliverList(
- delegate: SliverChildBuilderDelegate((context, index) {
- return PostCommentWidget(model.list[index]);
- // getComment(
- // 1,
- // model.list[index],
- // // initData: model.initData(),
- // );
- }, childCount: model.list.length)),
- if (model.isEmpty)
- SliverFillRemaining(
- child: Center(
- child: RequestErrorWidget(
- null,
- msg: "暂无评论~",
- assets: RequestErrorWidget.ASSETS_NO_COMMENT,
- ),
- ),
- ),
- ]);
- },
- );
- }
- }
- // type 1 bottom
- // type 2 head
- class getComment extends StatefulWidget {
- int type;
- String textType = "big";
- Function initData;
- Comment comment;
- getComment(this.type, this.comment, {this.initData});
- @override
- State<StatefulWidget> createState() {
- // TODO: implement createState
- return _getCommentState();
- }
- }
- class _getCommentState extends State<getComment> with InjectApi {
- FocusNode _comment = new FocusNode();
- String _textFieldValue = "";
- @override
- void initState() {
- // TODO: implement initState
- super.initState();
- }
- void handleLike({int type}) async {
- if (type == 1) {
- RespData<String> _data = await api.postForumLike(widget.comment.id, "comment_id");
- } else if (type == 2) {
- RespData<String> _data = await api.postForumUnLike(widget.comment.id, "comment_id");
- }
- }
- @override
- Widget build(BuildContext context) {
- // TODO: implement build
- return Container(
- padding: EdgeInsets.only(left: 12.0, right: 12.0, top: 16.0),
- child: Column(
- children: <Widget>[
- // avatar
- Padding(
- padding: EdgeInsets.only(bottom: 9.0),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: <Widget>[
- ClipRRect(
- child: CachedNetworkImage(
- imageUrl: widget.comment.socialInfo.avatar == ""
- ? "https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=2661558467,1288211245&fm=26&gp=0.jpg"
- : widget.comment.socialInfo.avatar,
- width: 40.0,
- height: 40.0,
- fit: BoxFit.cover,
- ),
- borderRadius: BorderRadius.all(Radius.circular(50.0)),
- ),
- Expanded(
- child: Container(
- padding: EdgeInsets.only(left: 12.0),
- alignment: Alignment.centerLeft,
- child: Column(
- children: <Widget>[
- Container(
- width: double.infinity,
- alignment: Alignment.centerLeft,
- child: Text(
- "${widget.comment.socialInfo.name}",
- style: TextStyle(color: Color.fromRGBO(51, 51, 51, 1), fontWeight: FontWeight.bold),
- ),
- ),
- Container(
- padding: EdgeInsets.only(top: 5.0),
- width: double.infinity,
- alignment: Alignment.centerLeft,
- child: Text("${widget.comment.createdAt}", style: TextStyle(color: Color.fromRGBO(153, 153, 153, 1), fontSize: 12.0)),
- ),
- ],
- ),
- ),
- ),
- widget.type == 2
- ? Padding(
- padding: EdgeInsets.only(left: 12.0),
- child: Row(
- children: <Widget>[
- widget.comment.isLiked
- ? InkWell(
- child: Image.asset(
- "lib/assets/img/bbslist_icon_liked.png",
- width: 16.0,
- height: 16.0,
- ),
- onTap: () {
- handleLike(type: 2);
- widget.initData();
- },
- )
- : InkWell(
- child: Image.asset(
- "lib/assets/img/bbslist_icon_like.png",
- width: 16.0,
- height: 16.0,
- ),
- onTap: () {
- handleLike(type: 1);
- widget.initData();
- },
- ),
- Padding(
- padding: EdgeInsets.only(left: 5.0),
- child: Text(
- "${widget.comment.likeCount}",
- style: TextStyle(color: Color.fromRGBO(153, 153, 153, 1), fontSize: 12.0),
- ),
- )
- ],
- ),
- )
- : Container()
- ],
- )),
- // comment-content
- Container(
- width: double.infinity,
- alignment: Alignment.centerLeft,
- child: Text(
- "${widget.comment.content}",
- textAlign: TextAlign.left,
- style: TextStyle(fontSize: widget.textType == "big" ? 16.0 : 14.0, fontWeight: FontWeight.w400, height: 1.5, color: Colors.black),
- ),
- ),
- // comment-bottom
- widget.type == 1
- ? Padding(
- padding: EdgeInsets.only(top: 12.0),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: <Widget>[
- widget.comment.subList.length != 0
- ? Row(
- children: <Widget>[
- InkWell(
- child: Text("查看${widget.comment.subList.length}条回复",
- style: TextStyle(fontSize: 12.0, fontWeight: FontWeight.w400, color: Color.fromRGBO(153, 153, 153, 1))),
- onTap: () async {
- _showCommentList(widget.comment, subjectId: widget.comment.id);
- // if (widget.comment.subList.length != 0) {
- // var data = await showModalBottomSheet(
- // context: context,
- // isScrollControlled: true,
- // shape: RoundedRectangleBorder(
- // borderRadius: BorderRadius.vertical(
- // top: Radius.circular(30))),
- // builder: (BuildContext context) {
- // return SingleChildScrollView(
- // child: Container(
- // height: MediaQuery.of(context)
- // .size
- // .height /
- // 3 *
- // 2,
- // padding: EdgeInsets.only(
- // bottom: MediaQuery.of(
- // context)
- // .viewInsets
- // .bottom), // !important
- // child: MaskComment(
- // widget.comment.id,
- // widget.comment.subjectId,
- // widget.comment.id,
- // widget.initData,
- // widget.comment,
- // )),
- // );
- // },
- // );
- // if (data == null) {
- // widget.initData();
- // }
- // }
- // else {
- // Fluttertoast.showToast(
- // msg: "没有可查看的回复",
- // toastLength: Toast.LENGTH_SHORT,
- // gravity: ToastGravity.CENTER,
- // timeInSecForIosWeb: 1,
- // backgroundColor: Colors.white,
- // textColor: Colors.black,
- // fontSize: 16.0);
- // }
- },
- ),
- Icon(
- Icons.chevron_right,
- color: Color.fromRGBO(153, 153, 153, 1),
- size: 16.0,
- )
- ],
- )
- : Container(),
- Row(
- children: <Widget>[
- Padding(
- padding: EdgeInsets.only(right: 25.0),
- child: Row(
- children: <Widget>[
- widget.comment.isLiked
- ? InkWell(
- child: Image.asset(
- "lib/assets/img/bbslist_icon_liked.png",
- width: 16.0,
- height: 16.0,
- ),
- onTap: () {
- handleLike(type: 2);
- widget.initData();
- },
- )
- : InkWell(
- child: Image.asset(
- "lib/assets/img/bbslist_icon_like.png",
- width: 16.0,
- height: 16.0,
- ),
- onTap: () {
- handleLike(type: 1);
- widget.initData();
- },
- ),
- Padding(
- padding: EdgeInsets.only(left: 5.0),
- child: Text(
- "${widget.comment.likeCount}",
- style: TextStyle(color: Color.fromRGBO(153, 153, 153, 1), fontSize: 12.0),
- ),
- )
- ],
- ),
- ),
- Row(
- children: <Widget>[
- Image.asset(
- "lib/assets/img/bbslist_icon_reply.png",
- width: 16.0,
- height: 16.0,
- ),
- InkWell(
- child: Padding(
- padding: EdgeInsets.only(left: 5.0),
- child: Text(
- "回复",
- style: TextStyle(color: Color.fromRGBO(153, 153, 153, 1), fontSize: 12.0),
- ),
- ),
- onTap: () {
- // showModalBottomSheet(
- // context: context,
- // isScrollControlled: true, // !important
- // builder: (BuildContext context) {
- // return SingleChildScrollView(
- // // !important
- // child: Container(
- // padding: EdgeInsets.only(
- // bottom: MediaQuery.of(context)
- // .viewInsets
- // .bottom), // !important
- // child: Container(
- // width: 351.0,
- // height: 44.0,
- // child: Padding(
- // padding: EdgeInsets.symmetric(
- // horizontal: 15.0),
- // child: Row(
- // mainAxisAlignment:
- // MainAxisAlignment
- // .spaceBetween,
- // crossAxisAlignment:
- // CrossAxisAlignment.center,
- // children: <Widget>[
- // Image.asset(
- // "lib/assets/img/bbs_icon_report.png",
- // width: 20.0,
- // height: 20.0,
- // ),
- // Expanded(
- // child: Container(
- // padding:
- // EdgeInsets.only(
- // left: 15.0),
- // alignment: Alignment
- // .centerLeft,
- // child: TextField(
- // focusNode: _comment,
- // autofocus: true,
- // style: TextStyle(
- // color: Color
- // .fromRGBO(
- // 153,
- // 153,
- // 153,
- // 1),
- // fontSize: 14.0),
- // onChanged: (value) {
- // setState(() {
- // _textFieldValue =
- // value;
- // });
- // },
- // decoration:
- // InputDecoration(
- // hintText:
- // '发表你的看法',
- // border:
- // InputBorder
- // .none),
- // )),
- // ),
- // InkWell(
- // child: Container(
- // width: 75.0,
- // height: 35.0,
- // alignment:
- // Alignment.center,
- // child: Text(
- // "发送",
- // style: TextStyle(
- // color:
- // Colors.white),
- // ),
- // decoration:
- // BoxDecoration(
- // borderRadius:
- // BorderRadius.all(
- // Radius
- // .circular(
- // 20.0)),
- // border: new Border
- // .all(
- // width: 1,
- // color: Theme.of(
- // context)
- // .accentColor),
- // gradient: LinearGradient(
- // begin: Alignment
- // .topCenter,
- // end: Alignment
- // .bottomCenter,
- // colors: [
- // Color.fromRGBO(
- // 255,
- // 196,
- // 0,
- // 1),
- // Color.fromRGBO(
- // 255,
- // 170,
- // 0,
- // 1),
- // ]),
- // ),
- // ),
- // onTap: () async {
- // RespData<CommentPost>
- // commentData =
- // await api.postForumComment(
- // "${widget.comment.subjectId}",
- // _textFieldValue,
- // toCommentId:
- // widget
- // .comment
- // .id,
- // parentCommentId:
- // widget
- // .comment
- // .id);
- // print(commentData);
- // print(commentData.code);
- // if (commentData.code !=
- // 0) {
- // Fluttertoast.showToast(
- // msg:
- // "${commentData.msg}",
- // toastLength: Toast
- // .LENGTH_SHORT,
- // gravity:
- // ToastGravity
- // .CENTER,
- // backgroundColor:
- // Colors.white,
- // textColor:
- // Colors.black,
- // fontSize: 13.0);
- // } else {
- // widget.initData();
- // Navigator.pop(
- // context);
- // }
- // },
- // )
- // ],
- // ),
- // ),
- // )),
- // );
- // },
- // );
- _showCommentList(widget.comment, subjectId: widget.comment.id);
- },
- ),
- ],
- ),
- ],
- ),
- ],
- ),
- )
- : Padding(
- padding: EdgeInsets.only(),
- ),
- Padding(
- padding: EdgeInsets.only(top: 17.0),
- child: Divider(),
- )
- ],
- ),
- );
- }
- void _showCommentList(Comment currentItem, {bool comment = false, String subjectId}) {
- showModalBottomSheet(
- context: context,
- isScrollControlled: true,
- shape: RoundedRectangleBorder(borderRadius: BorderRadius.vertical(top: Radius.circular(30))),
- builder: (BuildContext context) {
- return SingleChildScrollView(
- child: Container(
- height: max(520, MediaQuery.of(context).size.height / 3 * 2),
- padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom), // !important
- child: CommentDialog(subjectId, currentItem, showInput: comment),
- ),
- );
- },
- ).then((val) {
- print(val);
- });
- }
- }
- class MaskComment extends StatefulWidget {
- String parentCommentId;
- String id;
- String subjectId;
- Function initData;
- Comment comment;
- MaskComment(this.parentCommentId, this.subjectId, this.id, this.initData, this.comment);
- @override
- State<StatefulWidget> createState() {
- // TODO: implement createState
- return _MaskCommentState();
- }
- }
- class _MaskCommentState extends State<MaskComment> with InjectApi {
- FocusNode _comment;
- RespPage<Comment> _data;
- var _textFieldValue = '';
- bool _isPopupText = false;
- @override
- void initState() {
- // TODO: implement initState
- super.initState();
- // _comment = FocusNode();
- // print(widget.parentCommentId);
- initData();
- }
- @override
- void dispose() {
- // TODO: implement dispose
- super.dispose();
- // _comment.dispose();
- }
- initData() async {
- RespPage<Comment> comment = await api.getPostCommentSubs(widget.parentCommentId, sortBy: "created_at");
- setState(() {
- _data = comment;
- print(_data);
- });
- }
- void handleLike({int type}) {
- print(type);
- }
- @override
- // void didChangeMetrics() {
- //// super.didChangeMetrics();
- // WidgetsBinding.instance.addPostFrameCallback((_) {
- // // 当前是安卓系统并且在焦点聚焦的情况下
- // if (Platform.isAndroid && _comment.hasFocus) {
- // if (_isPopupText) {
- // _isPopupText = false;
- // // 使输入框失去焦点
- // _comment.unfocus();
- // return;
- // }
- // _isPopupText = true;
- // }
- // });
- // }
- @override
- Widget build(BuildContext context) {
- // TODO: implement build
- return Container(
- width: MediaQuery.of(context).size.width,
- child: _data != null
- ? Column(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: <Widget>[
- // content
- Expanded(
- child: Column(
- children: <Widget>[
- // header
- Container(
- width: double.infinity,
- height: 50,
- child: Stack(
- alignment: Alignment.center,
- children: <Widget>[
- Text(
- "回复详情",
- style: TextStyle(color: Color.fromRGBO(153, 153, 153, 1), fontSize: 14.0),
- ),
- Positioned(
- left: 12.0,
- child: IconButton(
- icon: Icon(Icons.chevron_left),
- iconSize: 28.0,
- onPressed: () {
- Navigator.pop(context);
- },
- ))
- ],
- ),
- ),
- // Content
- getComment(1, widget.comment),
- Expanded(
- child: Padding(
- padding: EdgeInsets.only(left: 24.0),
- child: ListView.builder(
- itemBuilder: (context, index) {
- print(_data.pageResult.results[index].isLiked);
- return getComment(
- 2,
- _data.pageResult.results[index],
- initData: initData,
- );
- },
- itemCount: _data.pageResult.results.length,
- ),
- ),
- ),
- // listView
- ],
- ),
- ),
- // bottom
- Container(
- height: 50.0,
- decoration: new BoxDecoration(color: Colors.white, // 底色
- boxShadow: [BoxShadow(offset: Offset(0.0, 0), blurRadius: 5, spreadRadius: 0, color: Color.fromRGBO(0, 0, 0, 0.1))]),
- child: Padding(
- padding: EdgeInsets.symmetric(vertical: 7.0, horizontal: 22.0),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- crossAxisAlignment: CrossAxisAlignment.center,
- children: <Widget>[
- Image.asset(
- "lib/assets/img/bbs_icon_report.png",
- width: 20.0,
- height: 20.0,
- ),
- Expanded(
- child: Container(
- padding: EdgeInsets.only(left: 15.0),
- alignment: Alignment.centerLeft,
- child: TextField(
- style: TextStyle(color: Color.fromRGBO(153, 153, 153, 1), fontSize: 14.0),
- onChanged: (value) {
- setState(() {
- _textFieldValue = value;
- });
- },
- decoration: InputDecoration(hintText: '发表你的看法', border: InputBorder.none),
- )),
- ),
- InkWell(
- child: Container(
- width: 75.0,
- height: 35.0,
- alignment: Alignment.center,
- child: Text(
- "发送",
- style: TextStyle(color: Colors.white),
- ),
- decoration: BoxDecoration(
- borderRadius: BorderRadius.all(Radius.circular(20.0)),
- border: new Border.all(width: 1, color: Theme.of(context).accentColor),
- gradient: LinearGradient(begin: Alignment.topCenter, end: Alignment.bottomCenter, colors: [
- Color.fromRGBO(255, 196, 0, 1),
- Color.fromRGBO(255, 170, 0, 1),
- ]),
- ),
- ),
- onTap: () async {
- RespData<CommentPost> commentData;
- if (widget.parentCommentId != 0) {
- commentData = await api.postForumComment("${widget.subjectId}", _textFieldValue,
- toCommentId: widget.id, parentCommentId: widget.parentCommentId);
- } else {
- commentData = await api.postForumComment(
- "${widget.subjectId}",
- _textFieldValue,
- toCommentId: widget.id,
- );
- }
- if (commentData.code != 0) {
- Fluttertoast.showToast(
- msg: "${commentData.msg}",
- toastLength: Toast.LENGTH_SHORT,
- gravity: ToastGravity.CENTER,
- backgroundColor: Colors.white,
- textColor: Colors.black,
- fontSize: 13.0);
- } else {
- setState(() {
- _data = null;
- });
- initData();
- // Navigator.pop(context);
- }
- },
- )
- ],
- ),
- ),
- ),
- ],
- )
- : FadeingCircleLoading(context),
- );
- }
- }
- // 自定义PopRoute
- class PopRoute extends PopupRoute {
- final Duration _duration = Duration(milliseconds: 300);
- Widget child;
- PopRoute({@required this.child});
- @override
- Color get barrierColor => null;
- @override
- bool get barrierDismissible => true;
- @override
- String get barrierLabel => null;
- @override
- Widget buildPage(BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation) {
- return child;
- }
- @override
- Duration get transitionDuration => _duration;
- }
- class FadeRoute extends PageRouteBuilder {
- final Widget page;
- FadeRoute({this.page})
- : super(
- pageBuilder: (
- BuildContext context,
- Animation<double> animation,
- Animation<double> secondaryAnimation,
- ) =>
- page,
- transitionsBuilder: (
- BuildContext context,
- Animation<double> animation,
- Animation<double> secondaryAnimation,
- Widget child,
- ) =>
- FadeTransition(
- opacity: animation,
- child: child,
- ),
- );
- }
- class GalleryPhotoViewWrapper extends StatefulWidget {
- GalleryPhotoViewWrapper({
- this.loadingBuilder,
- this.backgroundDecoration,
- this.minScale,
- this.maxScale,
- this.initialIndex,
- @required this.galleryItems,
- this.scrollDirection = Axis.horizontal,
- }) : pageController = PageController(initialPage: initialIndex);
- final LoadingBuilder loadingBuilder;
- final Decoration backgroundDecoration;
- final dynamic minScale;
- final dynamic maxScale;
- final int initialIndex;
- final PageController pageController;
- final List<String> galleryItems;
- final Axis scrollDirection;
- @override
- State<StatefulWidget> createState() {
- return _GalleryPhotoViewWrapperState();
- }
- }
- class _GalleryPhotoViewWrapperState extends State<GalleryPhotoViewWrapper> {
- int currentIndex;
- @override
- void initState() {
- currentIndex = widget.initialIndex;
- super.initState();
- }
- void onPageChanged(int index) {
- setState(() {
- currentIndex = index;
- });
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- body: Container(
- decoration: widget.backgroundDecoration,
- constraints: BoxConstraints.expand(
- height: MediaQuery.of(context).size.height,
- ),
- child: Stack(
- alignment: Alignment.bottomRight,
- children: <Widget>[
- PhotoViewGallery.builder(
- scrollPhysics: const BouncingScrollPhysics(),
- builder: _buildItem,
- itemCount: widget.galleryItems.length,
- loadingBuilder: widget.loadingBuilder,
- backgroundDecoration: widget.backgroundDecoration,
- pageController: widget.pageController,
- onPageChanged: onPageChanged,
- scrollDirection: widget.scrollDirection,
- ),
- Container(
- padding: const EdgeInsets.all(20.0),
- child: Text(
- "",
- style: const TextStyle(
- color: Colors.white,
- fontSize: 17.0,
- decoration: null,
- ),
- ),
- )
- ],
- ),
- ),
- );
- }
- PhotoViewGalleryPageOptions _buildItem(BuildContext context, int index) {
- final String item = widget.galleryItems[index];
- return PhotoViewGalleryPageOptions(
- imageProvider: CachedNetworkImageProvider(item),
- initialScale: PhotoViewComputedScale.contained,
- minScale: PhotoViewComputedScale.contained * (0.5 + index / 10),
- maxScale: PhotoViewComputedScale.covered * 1.1,
- heroAttributes: PhotoViewHeroAttributes(tag: item),
- onTapUp: (
- _,
- __,
- ___,
- ) {
- Navigator.of(context).pop();
- });
- }
- }
|