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

hmxc
小赖 4 years ago
parent 1d32e80891
commit a024b34a4f

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

@ -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<MyCommunityView>
class MyCommunityViewState extends State<MyCommunityView>
with AutomaticKeepAliveClientMixin {
EasyRefreshController _refreshController = EasyRefreshController();
refresh() {
_refreshController?.callRefresh();
}
@override
Widget build(BuildContext context) {
super.build(context);

@ -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<NewCommunityView>
class NewCommunityViewState extends State<NewCommunityView>
with AutomaticKeepAliveClientMixin {
EasyRefreshController _refreshController = EasyRefreshController();
refresh() {
_refreshController?.callRefresh();
}
@override
void dispose() {
_refreshController?.dispose();

@ -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<TopicCommunityView>
class TopicCommunityViewState extends State<TopicCommunityView>
with AutomaticKeepAliveClientMixin {
EasyRefreshController _refreshController = EasyRefreshController();
refresh() {
_refreshController?.callRefresh();
}
_buildItem(CommunityTopicModel model) {
return MaterialButton(

@ -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)

@ -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)

Loading…
Cancel
Save