|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:huixiang/generated/l10n.dart';
|
|
|
|
import 'package:huixiang/retrofit/data/member_comment_list.dart';
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
import 'package:huixiang/view_widget/custom_image.dart';
|
|
|
|
import 'package:like_button/like_button.dart';
|
|
|
|
|
|
|
|
|
|
|
|
class CommunityComment extends StatefulWidget {
|
|
|
|
|
|
|
|
final MemberCommentList memberList;
|
|
|
|
final Function(String id) queryCommentLike;
|
|
|
|
final int footType;
|
|
|
|
CommunityComment(this.memberList, this.queryCommentLike,this.footType);
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<StatefulWidget> createState() {
|
|
|
|
return _CommunityComment();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
class _CommunityComment extends State<CommunityComment> {
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Container(
|
|
|
|
padding: EdgeInsets.symmetric(vertical: 8.w),
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 16.w),
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
MImage(
|
|
|
|
widget.memberList.userAvatarUrl ?? "",
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
isCircle: true,
|
|
|
|
width: 40,
|
|
|
|
height: 40,
|
|
|
|
fadeSrc: "assets/image/default_user.png",
|
|
|
|
errorSrc: "assets/image/default_user.png",
|
|
|
|
),
|
|
|
|
SizedBox(
|
|
|
|
width: 12.w,
|
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
child: Container(
|
|
|
|
// height: 60.h,
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Text.rich(
|
|
|
|
TextSpan(
|
|
|
|
children: [
|
|
|
|
TextSpan(
|
|
|
|
text: widget.memberList.username,
|
|
|
|
style: TextStyle(
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
fontSize: 12,
|
|
|
|
color: Colors.black,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
textDirection: TextDirection.ltr,
|
|
|
|
),
|
|
|
|
SizedBox(
|
|
|
|
height: 3.h,
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
widget.memberList.createTime,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
maxLines: 2,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 14,
|
|
|
|
color: Color(0xff808080),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
flex: 1,
|
|
|
|
),
|
|
|
|
Tooltip(
|
|
|
|
message: S.of(context).dianzanxihuan_(S.of(context).pinglun),
|
|
|
|
child: Container(
|
|
|
|
alignment: Alignment.topRight,
|
|
|
|
child: LikeButton(
|
|
|
|
padding: EdgeInsets.all(10),
|
|
|
|
circleSize: 16,
|
|
|
|
circleColor: CircleColor(
|
|
|
|
start: Color(0xff00ddff),
|
|
|
|
end: Color(0xff0099cc),
|
|
|
|
),
|
|
|
|
bubblesColor: BubblesColor(
|
|
|
|
dotPrimaryColor: Color(0xff33b5e5),
|
|
|
|
dotSecondaryColor: Color(0xff0099cc),
|
|
|
|
),
|
|
|
|
bubblesSize: 15,
|
|
|
|
likeBuilder: (bool isLiked) {
|
|
|
|
return isLiked
|
|
|
|
? Image.asset(
|
|
|
|
"assets/image/icon_like.png",
|
|
|
|
width: 16,
|
|
|
|
height: 16,
|
|
|
|
)
|
|
|
|
: Image.asset(
|
|
|
|
"assets/image/icon_like_h.png",
|
|
|
|
width: 16,
|
|
|
|
height: 16,
|
|
|
|
);
|
|
|
|
},
|
|
|
|
isLiked: widget.memberList.liked ?? false,
|
|
|
|
onTap: (isLiked) async {
|
|
|
|
widget.queryCommentLike(widget.memberList.id);
|
|
|
|
return (widget.memberList == null || widget.memberList.liked == null)
|
|
|
|
? false
|
|
|
|
: widget.memberList.liked;
|
|
|
|
},
|
|
|
|
likeCount: widget.memberList.likes,
|
|
|
|
countBuilder: (int count, bool isLiked, String text) {
|
|
|
|
return Text(
|
|
|
|
text,
|
|
|
|
style: TextStyle(
|
|
|
|
color: Color(0xFF1A1A1A),
|
|
|
|
fontSize: 14,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
left: 68.w,
|
|
|
|
right: 16.w,
|
|
|
|
top: 16.h,
|
|
|
|
bottom: 16.h,
|
|
|
|
),
|
|
|
|
child: Align(
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
child: Text(
|
|
|
|
widget.memberList.content,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 12,
|
|
|
|
color: Color(0xff1A1A1A),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
SizedBox(
|
|
|
|
height: 12.h,
|
|
|
|
),
|
|
|
|
if (widget.memberList.parentContent != null)
|
|
|
|
Container(
|
|
|
|
margin: EdgeInsets.only(left: 68.w, right: 16.w),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: Color(0xffF2F2F2),
|
|
|
|
borderRadius: BorderRadius.circular(2.0),
|
|
|
|
),
|
|
|
|
child: Padding(
|
|
|
|
padding: EdgeInsets.only(left: 4.w, top: 4.h, bottom: 4.h),
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
"${widget.memberList.parentUserName}:" ?? "",
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 14,
|
|
|
|
color: Color(0xff808080),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
flex: 1,
|
|
|
|
child: Text(
|
|
|
|
widget.memberList.parentContent ?? "",
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 14,
|
|
|
|
color: Color(0xff808080),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
if (widget.footType == 1)
|
|
|
|
Container(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: Color(0xFFF2F2F2),
|
|
|
|
boxShadow: [
|
|
|
|
BoxShadow(
|
|
|
|
color: Colors.black.withAlpha(12),
|
|
|
|
offset: Offset(0, 2),
|
|
|
|
blurRadius: 14,
|
|
|
|
spreadRadius: 0,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
alignment: Alignment.topCenter,
|
|
|
|
padding: EdgeInsets.only(top: 22.h,bottom: 22),
|
|
|
|
child: Text(
|
|
|
|
S.of(context).yixiansquanbupinglun,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 12,
|
|
|
|
color: Color(0xff353535),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|