diff --git a/lib/constants/api.dart b/lib/constants/api.dart index 42f6f6b5..4b270c3e 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -187,6 +187,9 @@ class _Community { ///社区话题:我的动态 String get myEvent => '/user/gambit/myTidings'; + + ///社区话题:假删除主题信息(只能删除自己的) + String get deleteMyEvent => '/user/gambit/falseDelete'; } 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 ec672982..1d29dca6 100644 --- a/lib/ui/community/community_views/new_community_view.dart +++ b/lib/ui/community/community_views/new_community_view.dart @@ -49,6 +49,9 @@ class _NewCommunityViewState extends State headImg: item.headSculptureImgUrl, themeId: item.id, initLike: item.isLike == 1, + onDelete: () { + _refreshController.callRefresh(); + }, ); }, 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 5e415359..abfb4a63 100644 --- a/lib/ui/community/community_views/topic/topic_detail_page.dart +++ b/lib/ui/community/community_views/topic/topic_detail_page.dart @@ -73,6 +73,9 @@ class _TopicDetailPageState extends State { contentImg: item.imgUrls, date: item.date, id: item.createId, + onDelete: () { + _refreshController.callRefresh(); + }, ); }, childCount: items.length, diff --git a/lib/ui/community/community_views/widgets/chat_card.dart b/lib/ui/community/community_views/widgets/chat_card.dart index b5e2be2c..a88a13b6 100644 --- a/lib/ui/community/community_views/widgets/chat_card.dart +++ b/lib/ui/community/community_views/widgets/chat_card.dart @@ -33,6 +33,8 @@ class ChatCard extends StatefulWidget { final int themeId; + final VoidCallback onDelete; + ChatCard({ Key key, @required this.name, @@ -44,6 +46,7 @@ class ChatCard extends StatefulWidget { @required this.id, @required this.content, @required this.themeId, + this.onDelete, }) : super(key: key); @override @@ -136,7 +139,7 @@ class _ChatCardState extends State { cancel(); await NetUtil().get( API.community.like, - params: {'themeId': widget.id}, + params: {'themeId': widget.themeId}, showMessage: true, ); setState(() { @@ -291,7 +294,12 @@ class _ChatCardState extends State { )); if (result == true) { - //TODO delete operation + await NetUtil().get( + API.community.deleteMyEvent, + params: {'themeId': widget.themeId}, + showMessage: true, + ); + if (widget.onDelete != null) widget.onDelete(); } }, child: '删除'.text.black.size(28.sp).make(), diff --git a/lib/ui/community/community_views/widgets/my_event_card.dart b/lib/ui/community/community_views/widgets/my_event_card.dart index 516851ed..90fe2457 100644 --- a/lib/ui/community/community_views/widgets/my_event_card.dart +++ b/lib/ui/community/community_views/widgets/my_event_card.dart @@ -65,19 +65,22 @@ class MyEventCard extends StatelessWidget { width: 200.w, padding: EdgeInsets.only(left: 32.w), alignment: Alignment.topLeft, - child: beeDate.sameDay ? SizedBox() : title(), + child: beeDate.sameDay ? title() : SizedBox(), ), model.imgUrl.length == 0 ? SizedBox(height: 152.w) : GestureDetector( onTap: () { Get.to( - BeeImagePreview.path(path: model.imgUrl.first.url), + BeeImagePreview.path( + path: model.imgUrl.first.url, + tag: API.image(model.imgUrl.first.url), + ), opaque: false, ); }, child: Hero( - tag: model.imgUrl.first.url, + tag: API.image(model.imgUrl.first.url), child: Container( clipBehavior: Clip.antiAlias, decoration: BoxDecoration( diff --git a/lib/ui/community/notice/notice_card.dart b/lib/ui/community/notice/notice_card.dart index ac3c1337..ee7ec89c 100644 --- a/lib/ui/community/notice/notice_card.dart +++ b/lib/ui/community/notice/notice_card.dart @@ -81,7 +81,7 @@ class NoticeCard extends StatelessWidget { width: 200.w, padding: EdgeInsets.only(left: 32.w), alignment: Alignment.topLeft, - child: sameDay ? SizedBox() : title(), + child: sameDay ? title() : SizedBox(), ), model.imgUrls.length == 0 ? SizedBox(height: 152.w) diff --git a/lib/utils/bee_date_util.dart b/lib/utils/bee_date_util.dart index d28e14fa..3837de22 100644 --- a/lib/utils/bee_date_util.dart +++ b/lib/utils/bee_date_util.dart @@ -8,12 +8,14 @@ class BeeDateUtil { bool get sameYear => _now.year == this.date.year; bool get sameMonth => sameYear && _now.month == this.date.month; bool get sameDay => sameMonth && _now.day == this.date.day; - bool get isYesterday => (DateTime(_now.year, _now.month, _now.day - 1) - .compareTo(DateTime(this.date.year)) == - 0); - bool get isDoubleYesterday => (DateTime(_now.year, _now.month, _now.day - 2) - .compareTo(DateTime(this.date.year)) == - 0); + bool get isYesterday => + (DateTime(_now.year, _now.month, _now.day - 1).compareTo( + DateTime(this.date.year, this.date.month, this.date.day)) == + 0); + bool get isDoubleYesterday => + (DateTime(_now.year, _now.month, _now.day - 2).compareTo( + DateTime(this.date.year, this.date.month, this.date.day)) == + 0); String get timeAgo { Duration duration = _now.difference(date); diff --git a/lib/widget/picker/bee_image_preview.dart b/lib/widget/picker/bee_image_preview.dart index 4ad8561e..b9bd46b5 100644 --- a/lib/widget/picker/bee_image_preview.dart +++ b/lib/widget/picker/bee_image_preview.dart @@ -15,11 +15,12 @@ import 'package:akuCommunity/constants/api.dart'; class BeeImagePreview extends StatefulWidget { final File file; final String path; - BeeImagePreview.file({Key key, @required this.file}) + final String tag; + BeeImagePreview.file({Key key, @required this.file, this.tag}) : path = null, super(key: key); - BeeImagePreview.path({Key key, @required this.path}) + BeeImagePreview.path({Key key, @required this.path, this.tag}) : file = null, super(key: key); @@ -31,7 +32,7 @@ class _BeeImagePreviewState extends State { Widget get image { if (widget.file == null) return Hero( - tag: widget.path, + tag: widget.tag ?? widget.path, child: FadeInImage.assetNetwork( placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, image: API.image(widget.path), @@ -39,7 +40,7 @@ class _BeeImagePreviewState extends State { ); else return Hero( - tag: widget.file.hashCode, + tag: widget.tag ?? widget.file.hashCode, child: Image.file(widget.file), ); }