import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/retrofit/data/activity.dart'; import 'package:huixiang/retrofit/data/article.dart'; import 'package:like_button/like_button.dart'; class InputComment extends StatefulWidget { final String hintText; final Activity activity; final Article article; final bool isKeyBoardShow; final FocusNode commentFocus; final Function toComment; final Function(String text) queryMemberComment; final Function() queryInformationLikes; final TextEditingController commentTextController; InputComment( Key key, this.hintText, this.activity, this.article, this.isKeyBoardShow, this.commentFocus, this.commentTextController, this.toComment, this.queryMemberComment, this.queryInformationLikes, ) : super(key: key); @override State createState() { return _InputComment(); } } class _InputComment extends State { @override Widget build(BuildContext context) { return Container( padding: EdgeInsets.all(16), decoration: BoxDecoration( color: Colors.white, boxShadow: [ BoxShadow( color: Colors.black.withAlpha(12), offset: Offset(0, 2), blurRadius: 14, spreadRadius: 0, ), ], borderRadius: BorderRadius.vertical( top: Radius.circular(8), ), ), child: Row( children: [ Expanded( flex: 1, child: Container( decoration: BoxDecoration( color: Color(0xffF2F2F2), borderRadius: BorderRadius.circular(2.0), ), child: Column( children: [ Container( margin: EdgeInsets.symmetric(horizontal: 4.w), alignment: Alignment.topLeft, child: TextField( maxLines: 8, minLines: 1, focusNode: widget.commentFocus, controller: widget.commentTextController, decoration: InputDecoration( border: InputBorder.none, hintText: widget.hintText, hintStyle: TextStyle( fontSize: 14.sp, color: Color(0xFF868686), ), ), ), ), ], ), ), ), if (widget.isKeyBoardShow) GestureDetector( onTap: () { var commentText = widget.commentTextController.text; if (commentText == "") { return; } widget.queryMemberComment(commentText); }, child: Container( padding: EdgeInsets.symmetric(horizontal: 20.w), child: Text( S.of(context).fasong, style: TextStyle( fontSize: 16.sp, fontWeight: FontWeight.bold, color: Color(0XFF1A1A1A), ), ), ), ), if (!widget.isKeyBoardShow) InkWell( onTap: widget.toComment, child: Tooltip( message: S.of(context).daopinglunliebiaodingbu, child: Container( padding: EdgeInsets.only(left: 20.w, right: 10.w), child: Image.asset( "assets/image/icon_comment.png", width: 24, height: 24, ), ), ), ), if (!widget.isKeyBoardShow) Tooltip( message: S.of(context).dianzanxihuan_(widget.activity == null ? S.of(context).wenzhang : S.of(context).huodong), child: LikeButton( padding: EdgeInsets.all(10), size: 24, circleSize: 24, circleColor: CircleColor( start: Color(0xff00ddff), end: Color(0xff0099cc), ), bubblesColor: BubblesColor( dotPrimaryColor: Color(0xff33b5e5), dotSecondaryColor: Color(0xff0099cc), ), bubblesSize: 24, likeBuilder: (bool isLiked) { return isLiked ? Image.asset( "assets/image/icon_like.png", width: 24, height: 24, ) : Image.asset( "assets/image/icon_like_h.png", width: 24, height: 24, ); }, isLiked: (widget.activity != null ? widget.activity.liked : widget.article != null ? widget.article.liked : false), onTap: (isLiked) async { await widget.queryInformationLikes(); return (widget.activity != null ? widget.activity.liked : widget.article != null ? widget.article.liked : false); }, countBuilder: (int count, bool isLiked, String text) { return Text( text, style: TextStyle( color: Color(0xFF1A1A1A), fontSize: 12.sp, ), ); }, ), ), ], ), ); } }