修复社区卡片、公告卡片的显示问题

hmxc
小赖 4 years ago
parent 1d32e80891
commit a024b34a4f

@ -25,6 +25,11 @@ class _CommunityPageState extends State<CommunityPage>
with TickerProviderStateMixin, AutomaticKeepAliveClientMixin { with TickerProviderStateMixin, AutomaticKeepAliveClientMixin {
TabController _tabController; TabController _tabController;
List<String> _tabs = ['最新', '话题', '我的']; List<String> _tabs = ['最新', '话题', '我的'];
GlobalKey<TopicCommunityViewState> topicKey =
GlobalKey<TopicCommunityViewState>();
GlobalKey<MyCommunityViewState> myKey = GlobalKey<MyCommunityViewState>();
GlobalKey<NewCommunityViewState> newKey = GlobalKey<NewCommunityViewState>();
@override @override
void initState() { void initState() {
super.initState(); super.initState();
@ -47,7 +52,22 @@ class _CommunityPageState extends State<CommunityPage>
), ),
], ],
fab: FloatingActionButton( 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', heroTag: 'event_add',
child: Icon(Icons.add), child: Icon(Icons.add),
), ),
@ -64,9 +84,9 @@ class _CommunityPageState extends State<CommunityPage>
), ),
body: TabBarView( body: TabBarView(
children: [ children: [
NewCommunityView(), NewCommunityView(key: newKey),
TopicCommunityView(), TopicCommunityView(key: topicKey),
MyCommunityView(), MyCommunityView(key: myKey),
], ],
controller: _tabController, controller: _tabController,
), ),

@ -15,12 +15,17 @@ class MyCommunityView extends StatefulWidget {
MyCommunityView({Key key}) : super(key: key); MyCommunityView({Key key}) : super(key: key);
@override @override
_MyCommunityViewState createState() => _MyCommunityViewState(); MyCommunityViewState createState() => MyCommunityViewState();
} }
class _MyCommunityViewState extends State<MyCommunityView> class MyCommunityViewState extends State<MyCommunityView>
with AutomaticKeepAliveClientMixin { with AutomaticKeepAliveClientMixin {
EasyRefreshController _refreshController = EasyRefreshController(); EasyRefreshController _refreshController = EasyRefreshController();
refresh() {
_refreshController?.callRefresh();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
super.build(context); super.build(context);

@ -14,12 +14,17 @@ class NewCommunityView extends StatefulWidget {
NewCommunityView({Key key}) : super(key: key); NewCommunityView({Key key}) : super(key: key);
@override @override
_NewCommunityViewState createState() => _NewCommunityViewState(); NewCommunityViewState createState() => NewCommunityViewState();
} }
class _NewCommunityViewState extends State<NewCommunityView> class NewCommunityViewState extends State<NewCommunityView>
with AutomaticKeepAliveClientMixin { with AutomaticKeepAliveClientMixin {
EasyRefreshController _refreshController = EasyRefreshController(); EasyRefreshController _refreshController = EasyRefreshController();
refresh() {
_refreshController?.callRefresh();
}
@override @override
void dispose() { void dispose() {
_refreshController?.dispose(); _refreshController?.dispose();

@ -19,12 +19,15 @@ class TopicCommunityView extends StatefulWidget {
TopicCommunityView({Key key}) : super(key: key); TopicCommunityView({Key key}) : super(key: key);
@override @override
_TopicCommunityViewState createState() => _TopicCommunityViewState(); TopicCommunityViewState createState() => TopicCommunityViewState();
} }
class _TopicCommunityViewState extends State<TopicCommunityView> class TopicCommunityViewState extends State<TopicCommunityView>
with AutomaticKeepAliveClientMixin { with AutomaticKeepAliveClientMixin {
EasyRefreshController _refreshController = EasyRefreshController(); EasyRefreshController _refreshController = EasyRefreshController();
refresh() {
_refreshController?.callRefresh();
}
_buildItem(CommunityTopicModel model) { _buildItem(CommunityTopicModel model) {
return MaterialButton( return MaterialButton(

@ -28,6 +28,11 @@ class MyEventCard extends StatelessWidget {
BeeDateUtil get beeDate => BeeDateUtil(model.date); 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() { Widget title() {
if (beeDate.sameDay) return '今天'.text.size(52.sp).bold.make(); if (beeDate.sameDay) return '今天'.text.size(52.sp).bold.make();
if (beeDate.isYesterday) if (beeDate.isYesterday)
@ -65,7 +70,7 @@ class MyEventCard extends StatelessWidget {
width: 200.w, width: 200.w,
padding: EdgeInsets.only(left: 32.w), padding: EdgeInsets.only(left: 32.w),
alignment: Alignment.topLeft, alignment: Alignment.topLeft,
child: beeDate.sameDay ? title() : SizedBox(), child: sameDay ? SizedBox() : title(),
), ),
model.imgUrl.length == 0 model.imgUrl.length == 0
? SizedBox(height: 152.w) ? SizedBox(height: 152.w)

@ -81,7 +81,7 @@ class NoticeCard extends StatelessWidget {
width: 200.w, width: 200.w,
padding: EdgeInsets.only(left: 32.w), padding: EdgeInsets.only(left: 32.w),
alignment: Alignment.topLeft, alignment: Alignment.topLeft,
child: sameDay ? title() : SizedBox(), child: sameDay ? SizedBox() : title(),
), ),
model.imgUrls.length == 0 model.imgUrls.length == 0
? SizedBox(height: 152.w) ? SizedBox(height: 152.w)

Loading…
Cancel
Save