From 786ce262a0088831845e57e50aca2ecd3f336778 Mon Sep 17 00:00:00 2001 From: laiiihz Date: Thu, 4 Feb 2021 19:30:41 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=9D=E9=A2=98=E7=82=B9=E8=B5=9E=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E6=8E=A5=E5=8F=A3=E5=AF=B9=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/constants/api.dart | 3 +++ .../community_views/new_community_view.dart | 2 ++ .../community_views/topic/topic_detail_page.dart | 2 ++ .../community_views/widgets/chat_card.dart | 14 ++++++++++++-- 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/constants/api.dart b/lib/constants/api.dart index e6247362..bca7b289 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -172,6 +172,9 @@ class _Community { ///社区活动: 写帖子(添加主题信息) String get addEvent => '/user/gambit/writePost'; + + ///社区话题:app用户点赞/取消点赞 + String get like => '/user/gambit/likes'; } class _Upload { diff --git a/lib/ui/community/community_views/new_community_view.dart b/lib/ui/community/community_views/new_community_view.dart index 24ca4709..8f49c4b2 100644 --- a/lib/ui/community/community_views/new_community_view.dart +++ b/lib/ui/community/community_views/new_community_view.dart @@ -42,6 +42,8 @@ class _NewCommunityViewState extends State date: item.date, id: item.createId, headImg: item.headSculptureImgUrl, + themeId: item.id, + initLike: item.isLike == 1, ); }, itemCount: items.length, diff --git a/lib/ui/community/community_views/topic/topic_detail_page.dart b/lib/ui/community/community_views/topic/topic_detail_page.dart index 02a318a8..4ee5c422 100644 --- a/lib/ui/community/community_views/topic/topic_detail_page.dart +++ b/lib/ui/community/community_views/topic/topic_detail_page.dart @@ -59,6 +59,8 @@ class _TopicDetailPageState extends State { (context, index) { final item = items[index] as EventItemModel; return ChatCard( + initLike: item.isLike == 1, + themeId: item.id, content: item.content, name: item.createName, topic: item.gambitTitle, diff --git a/lib/ui/community/community_views/widgets/chat_card.dart b/lib/ui/community/community_views/widgets/chat_card.dart index b3996497..200f7ebe 100644 --- a/lib/ui/community/community_views/widgets/chat_card.dart +++ b/lib/ui/community/community_views/widgets/chat_card.dart @@ -4,6 +4,8 @@ import 'package:akuCommunity/model/common/img_model.dart'; import 'package:akuCommunity/provider/user_provider.dart'; import 'package:akuCommunity/utils/bee_date_util.dart'; import 'package:akuCommunity/utils/headers.dart'; +import 'package:akuCommunity/utils/network/base_model.dart'; +import 'package:akuCommunity/utils/network/net_util.dart'; import 'package:akuCommunity/widget/picker/bee_image_preview.dart'; import 'package:akuCommunity/widget/views/bee_grid_image_view.dart'; import 'package:bot_toast/bot_toast.dart'; @@ -24,6 +26,9 @@ class ChatCard extends StatefulWidget { ///userID final int id; + + final int themeId; + ChatCard({ Key key, @required this.name, @@ -34,6 +39,7 @@ class ChatCard extends StatefulWidget { this.initLike = false, @required this.id, @required this.content, + @required this.themeId, }) : super(key: key); @override @@ -122,9 +128,13 @@ class _ChatCardState extends State { height: 78.w, materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, - onPressed: () { + onPressed: () async { cancel(); - //TODO 点赞 + await NetUtil().get( + API.community.like, + params: {'themeId': widget.id}, + showMessage: true, + ); setState(() { _like = !_like; });