Browse Source

布局更改;

zyh
w-R 3 years ago
parent
commit
b901995bd3
  1. 37
      lib/community/community_child_page.dart

37
lib/community/community_child_page.dart

@ -20,7 +20,8 @@ class CommunityChildPage extends StatefulWidget {
final Function onScroll; final Function onScroll;
final Function toRelease; final Function toRelease;
CommunityChildPage(Key key, this.typeStr,this.onScroll,this.toRelease): super(key: key); CommunityChildPage(Key key, this.typeStr, this.onScroll, this.toRelease)
: super(key: key);
@override @override
State<StatefulWidget> createState() { State<StatefulWidget> createState() {
@ -28,7 +29,8 @@ class CommunityChildPage extends StatefulWidget {
} }
} }
class CommunityChildPageState extends State<CommunityChildPage> with AutomaticKeepAliveClientMixin { class CommunityChildPageState extends State<CommunityChildPage>
with AutomaticKeepAliveClientMixin {
RefreshController refreshController = RefreshController(); RefreshController refreshController = RefreshController();
ApiService apiService; ApiService apiService;
int pageNum = 1; int pageNum = 1;
@ -65,18 +67,15 @@ class CommunityChildPageState extends State<CommunityChildPage> with AutomaticKe
if (apiService == null) { if (apiService == null) {
SharedPreferences value = await SharedPreferences.getInstance(); SharedPreferences value = await SharedPreferences.getInstance();
userId = value.getString('userId'); userId = value.getString('userId');
apiService = ApiService( apiService = ApiService(Dio(),
Dio(),
context: context, context: context,
token: value.getString("token"), token: value.getString("token"),
showLoading: false showLoading: false);
);
} }
if (isLoadMore) { if (isLoadMore) {
pageNum += 1; pageNum += 1;
isLoadMore = false; isLoadMore = false;
} } else if (searchKey == null) pageNum = 1;
else if(searchKey == null)pageNum = 1;
BaseData<PageInfo<ComunityComment>> baseData = await apiService.trendList({ BaseData<PageInfo<ComunityComment>> baseData = await apiService.trendList({
"mid": "", "mid": "",
"onlyFollow": widget.typeStr == "关注" ? true : false, "onlyFollow": widget.typeStr == "关注" ? true : false,
@ -111,8 +110,7 @@ class CommunityChildPageState extends State<CommunityChildPage> with AutomaticKe
element.likes = baseData.data.list[0]?.likes; element.likes = baseData.data.list[0]?.likes;
element.comments = baseData.data.list[0]?.comments; element.comments = baseData.data.list[0]?.comments;
this.isRefresh = false; this.isRefresh = false;
setState(() { setState(() {});
});
} }
}); });
} else { } else {
@ -152,7 +150,10 @@ class CommunityChildPageState extends State<CommunityChildPage> with AutomaticKe
return FutureBuilder( return FutureBuilder(
future: queryCommunity(null), future: queryCommunity(null),
builder: (context, position) { builder: (context, position) {
return SmartRefresher( return Stack(
alignment: Alignment.bottomRight,
children: [
SmartRefresher(
controller: refreshController, controller: refreshController,
enablePullDown: true, enablePullDown: true,
enablePullUp: true, enablePullUp: true,
@ -168,18 +169,16 @@ class CommunityChildPageState extends State<CommunityChildPage> with AutomaticKe
isLoadMore = true; isLoadMore = true;
setState(() {}); setState(() {});
}, },
child: Stack( child: (articles == null || articles.length == 0)
alignment: Alignment.bottomRight, ? NoDataView(
children: [
(articles == null || articles.length == 0)? NoDataView(
src: "assets/image/guan_zhu.webp", src: "assets/image/guan_zhu.webp",
isShowBtn: false, isShowBtn: false,
text: "目前暂无添加关注,可在推荐中关注自己喜欢的人哦~", text: "目前暂无添加关注,可在推荐中关注自己喜欢的人哦~",
fontSize: 16.sp, fontSize: 16.sp,
margin: EdgeInsets.only(top: 120.h,left: 60.w,right: 60.w), margin:
EdgeInsets.only(top: 120.h, left: 60.w, right: 60.w),
) )
: : ListView.builder(
ListView.builder(
controller: sc, controller: sc,
shrinkWrap: true, shrinkWrap: true,
itemBuilder: (context, position) { itemBuilder: (context, position) {
@ -212,6 +211,7 @@ class CommunityChildPageState extends State<CommunityChildPage> with AutomaticKe
}, },
itemCount: articles.length, itemCount: articles.length,
), ),
),
GestureDetector( GestureDetector(
onTap: () { onTap: () {
widget.toRelease(); widget.toRelease();
@ -226,7 +226,6 @@ class CommunityChildPageState extends State<CommunityChildPage> with AutomaticKe
), ),
) )
], ],
),
); );
}, },
); );

Loading…
Cancel
Save