修复评论不能点赞的问题

修复发布任务提示文字显示问题
pull/1/head
张萌 3 years ago
parent 194be7e636
commit f8c5cc5592

@ -61,6 +61,7 @@ class _EventDetailPageState extends State<EventDetailPage> {
List<CommentListModel> _comments = []; List<CommentListModel> _comments = [];
List<bool> _folds = []; List<bool> _folds = [];
List<bool> _likes = []; List<bool> _likes = [];
List<int> _likeNums = [];
// //
FocusNode _focusNode = FocusNode(); FocusNode _focusNode = FocusNode();
@ -161,11 +162,8 @@ class _EventDetailPageState extends State<EventDetailPage> {
base.rows.map((e) => CommentListModel.fromJson(e)).toList(); base.rows.map((e) => CommentListModel.fromJson(e)).toList();
_folds = List.filled(_size, true); _folds = List.filled(_size, true);
_comments.forEach((element) { _comments.forEach((element) {
if (element.isLike) { _likes.add(element.isLike);
_likes.add(true); _likeNums.add(element.likes);
} else {
_likes.add(false);
}
}); });
setState(() {}); setState(() {});
}, },
@ -184,11 +182,8 @@ class _EventDetailPageState extends State<EventDetailPage> {
_comments.addAll(_list); _comments.addAll(_list);
_folds.addAll(List.filled(_list.length, true)); _folds.addAll(List.filled(_list.length, true));
_list.forEach((element) { _list.forEach((element) {
if (element.isLike) { _likes.add(element.isLike);
_likes.add(true); _likeNums.add(element.likes);
} else {
_likes.add(false);
}
}); });
} }
setState(() {}); setState(() {});
@ -361,17 +356,48 @@ class _EventDetailPageState extends State<EventDetailPage> {
child: Row( child: Row(
children: [ children: [
Spacer(), Spacer(),
Image.asset( GestureDetector(
R.ASSETS_ICONS_COMMUNITY_LIKE_PNG, onTap: () async {
width: 40.w, var base = await NetUtil().get(
height: 40.w, SAASAPI.community.commentLike,
params: {'commentId': model.id});
if (base.success) {
_likes[rootIndex] = !_likes[rootIndex];
if (_likes[rootIndex]) {
_likeNums[rootIndex] += 1;
} else {
_likeNums[rootIndex] -= 1;
}
BotToast.showText(
text: _likes[rootIndex] ? '点赞成功' : '取消点赞成功');
} else {
BotToast.showText(text: base.msg);
}
setState(() {});
},
child: Material(
color: Colors.transparent,
child: Row(
children: [
Image.asset(
R.ASSETS_ICONS_COMMUNITY_LIKE_PNG,
width: 32.w,
height: 32.w,
color: !_likes[rootIndex]
? Colors.black.withOpacity(0.45)
: kPrimaryColor,
),
5.wb,
'${_likeNums[rootIndex]}'
.text
.size(24.sp)
.color(Color(0xFF999999))
.make(),
],
),
),
), ),
5.wb,
'${model.likes}'
.text
.size(24.sp)
.color(Color(0xFF999999))
.make(),
32.wb, 32.wb,
GestureDetector( GestureDetector(
onTap: () { onTap: () {
@ -471,55 +497,64 @@ class _EventDetailPageState extends State<EventDetailPage> {
_focusNode.requestFocus(); _focusNode.requestFocus();
_currentCommentIndex = rootIndex; _currentCommentIndex = rootIndex;
}, },
child: RichText( child: Material(
text: TextSpan( color: Colors.transparent,
text: '${model.createName}', child: Row(
style: TextStyle( mainAxisSize: MainAxisSize.max,
color: Color(0xFF5D98F9), children: [
fontSize: 28.sp, RichText(
), text: TextSpan(
children: [ text: '${model.createName}',
if (createId == model.createId) style: TextStyle(
WidgetSpan( color: Color(0xFF5D98F9),
child: Container( fontSize: 28.sp,
width: 56.w, ),
height: 28.w, children: [
margin: EdgeInsets.only(left: 4.w, right: 4.w, bottom: 4.w), if (createId == model.createId)
alignment: Alignment.center, WidgetSpan(
decoration: BoxDecoration( child: Container(
color: Color(0xFFF8B133), width: 56.w,
borderRadius: BorderRadius.circular(4.w)), height: 28.w,
child: Text( margin:
'楼主', EdgeInsets.only(left: 4.w, right: 4.w, bottom: 4.w),
style: TextStyle( alignment: Alignment.center,
color: Colors.white, decoration: BoxDecoration(
fontSize: 24.sp, color: Color(0xFFF8B133),
height: 1.2, borderRadius: BorderRadius.circular(4.w)),
fontWeight: FontWeight.bold), child: Text(
), '楼主',
)), style: TextStyle(
if (model.parentName != null) color: Colors.white,
TextSpan( fontSize: 24.sp,
text: ' 回复 ', height: 1.2,
style: TextStyle( fontWeight: FontWeight.bold),
color: Colors.black.withOpacity(0.85), ),
fontSize: 28.sp, )),
)), if (model.parentName != null)
if (model.parentName != null) TextSpan(
TextSpan( text: ' 回复 ',
text: '${model.parentName}', style: TextStyle(
style: TextStyle( color: Colors.black.withOpacity(0.85),
color: Color(0xFF5D98F9), fontSize: 28.sp,
fontSize: 28.sp, )),
), if (model.parentName != null)
), TextSpan(
TextSpan( text: '${model.parentName}',
text: '${model.content}', style: TextStyle(
style: TextStyle( color: Color(0xFF5D98F9),
color: Colors.black.withOpacity(0.85), fontSize: 28.sp,
fontSize: 28.sp, ),
)) ),
])), TextSpan(
text: '${model.content}',
style: TextStyle(
color: Colors.black.withOpacity(0.85),
fontSize: 28.sp,
))
])),
],
),
),
); );
} }

@ -172,9 +172,12 @@ class _ChatCardDetailState extends State<ChatCardDetail> {
}, },
likeBuilder: (bool isLiked) { likeBuilder: (bool isLiked) {
return Image.asset( return Image.asset(
isLiked Assets.icons.communityLike.path,
? Assets.icons.communityLikeIs.path width: 32.w,
: Assets.icons.communityLike.path, height: 32.w,
color: !_isLiked
? Colors.black.withOpacity(0.45)
: kPrimaryColor,
); );
}, },
likeCount: _likeNum, likeCount: _likeNum,

@ -1073,7 +1073,7 @@ class _PublishTaskPageState extends State<PublishTaskPage> {
return false; return false;
} }
if (int.parse(_rewardController.text) == 0) { if (int.parse(_rewardController.text) == 0) {
BotToast.showText(text: '赏金不能为0'); BotToast.showText(text: '报酬不能为0');
return false; return false;
} }
if (_nameController.text.isEmpty) { if (_nameController.text.isEmpty) {

Loading…
Cancel
Save