You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
201 lines
7.1 KiB
201 lines
7.1 KiB
3 years ago
|
import 'package:flutter/material.dart';
|
||
|
import 'package:huixiang/generated/l10n.dart';
|
||
|
import 'package:huixiang/retrofit/data/base_data.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:huixiang/view_widget/login_tips_dialog.dart';
|
||
|
import 'package:like_button/like_button.dart';
|
||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||
|
|
||
|
|
||
|
class CommunityComment extends StatefulWidget {
|
||
|
|
||
|
MemberCommentList memberList;
|
||
|
Function(String id) queryCommentLike;
|
||
|
CommunityComment(this.memberList, this.queryCommentLike);
|
||
|
|
||
|
@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),
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
}
|