diff --git a/lib/ui/community/community_views/community_page.dart b/lib/ui/community/community_views/community_page.dart index 1e93c3d5..502b81d8 100644 --- a/lib/ui/community/community_views/community_page.dart +++ b/lib/ui/community/community_views/community_page.dart @@ -25,6 +25,11 @@ class _CommunityPageState extends State with TickerProviderStateMixin, AutomaticKeepAliveClientMixin { TabController _tabController; List _tabs = ['最新', '话题', '我的']; + GlobalKey topicKey = + GlobalKey(); + GlobalKey myKey = GlobalKey(); + GlobalKey newKey = GlobalKey(); + @override void initState() { super.initState(); @@ -47,7 +52,22 @@ class _CommunityPageState extends State ), ], fab: FloatingActionButton( - onPressed: () => Get.to(AddNewEventPage()), + onPressed: () async { + bool result = await Get.to(AddNewEventPage()); + if (result == true) { + switch (_tabController.index) { + case 0: + newKey.currentState.refresh(); + break; + case 1: + topicKey.currentState.refresh(); + break; + case 2: + myKey.currentState.refresh(); + break; + } + } + }, heroTag: 'event_add', child: Icon(Icons.add), ), @@ -64,9 +84,9 @@ class _CommunityPageState extends State ), body: TabBarView( children: [ - NewCommunityView(), - TopicCommunityView(), - MyCommunityView(), + NewCommunityView(key: newKey), + TopicCommunityView(key: topicKey), + MyCommunityView(key: myKey), ], controller: _tabController, ), diff --git a/lib/ui/community/community_views/my_community_view.dart b/lib/ui/community/community_views/my_community_view.dart index 6e99a1ed..5c128a9f 100644 --- a/lib/ui/community/community_views/my_community_view.dart +++ b/lib/ui/community/community_views/my_community_view.dart @@ -15,12 +15,17 @@ class MyCommunityView extends StatefulWidget { MyCommunityView({Key key}) : super(key: key); @override - _MyCommunityViewState createState() => _MyCommunityViewState(); + MyCommunityViewState createState() => MyCommunityViewState(); } -class _MyCommunityViewState extends State +class MyCommunityViewState extends State with AutomaticKeepAliveClientMixin { EasyRefreshController _refreshController = EasyRefreshController(); + + refresh() { + _refreshController?.callRefresh(); + } + @override Widget build(BuildContext context) { super.build(context); diff --git a/lib/ui/community/community_views/new_community_view.dart b/lib/ui/community/community_views/new_community_view.dart index 1d29dca6..d7ad3e4a 100644 --- a/lib/ui/community/community_views/new_community_view.dart +++ b/lib/ui/community/community_views/new_community_view.dart @@ -14,12 +14,17 @@ class NewCommunityView extends StatefulWidget { NewCommunityView({Key key}) : super(key: key); @override - _NewCommunityViewState createState() => _NewCommunityViewState(); + NewCommunityViewState createState() => NewCommunityViewState(); } -class _NewCommunityViewState extends State +class NewCommunityViewState extends State with AutomaticKeepAliveClientMixin { EasyRefreshController _refreshController = EasyRefreshController(); + + refresh() { + _refreshController?.callRefresh(); + } + @override void dispose() { _refreshController?.dispose(); diff --git a/lib/ui/community/community_views/topic/topic_community_view.dart b/lib/ui/community/community_views/topic/topic_community_view.dart index 053bd06f..e23df610 100644 --- a/lib/ui/community/community_views/topic/topic_community_view.dart +++ b/lib/ui/community/community_views/topic/topic_community_view.dart @@ -19,12 +19,15 @@ class TopicCommunityView extends StatefulWidget { TopicCommunityView({Key key}) : super(key: key); @override - _TopicCommunityViewState createState() => _TopicCommunityViewState(); + TopicCommunityViewState createState() => TopicCommunityViewState(); } -class _TopicCommunityViewState extends State +class TopicCommunityViewState extends State with AutomaticKeepAliveClientMixin { EasyRefreshController _refreshController = EasyRefreshController(); + refresh() { + _refreshController?.callRefresh(); + } _buildItem(CommunityTopicModel model) { return MaterialButton( 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 90fe2457..20391928 100644 --- a/lib/ui/community/community_views/widgets/my_event_card.dart +++ b/lib/ui/community/community_views/widgets/my_event_card.dart @@ -28,6 +28,11 @@ class MyEventCard extends StatelessWidget { BeeDateUtil get beeDate => BeeDateUtil(model.date); + bool get sameDay => + model.date.year == (preModel?.date?.year ?? 0) && + model.date.month == (preModel?.date?.month ?? 0) && + model.date.day == (preModel?.date?.day ?? 0); + Widget title() { if (beeDate.sameDay) return '今天'.text.size(52.sp).bold.make(); if (beeDate.isYesterday) @@ -65,7 +70,7 @@ class MyEventCard extends StatelessWidget { width: 200.w, padding: EdgeInsets.only(left: 32.w), alignment: Alignment.topLeft, - child: beeDate.sameDay ? title() : SizedBox(), + child: sameDay ? SizedBox() : title(), ), model.imgUrl.length == 0 ? SizedBox(height: 152.w) diff --git a/lib/ui/community/notice/notice_card.dart b/lib/ui/community/notice/notice_card.dart index ee7ec89c..ac3c1337 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 ? title() : SizedBox(), + child: sameDay ? SizedBox() : title(), ), model.imgUrls.length == 0 ? SizedBox(height: 152.w)