修改圈子列表加载问题
This commit is contained in:
parent
b2934d29a6
commit
6a7dc210ea
@ -1,6 +1,6 @@
|
||||
class CircleState {
|
||||
String msg = '';
|
||||
int index = 1;
|
||||
int index = 0;
|
||||
CircleState() {
|
||||
///Initialize variables
|
||||
}
|
||||
|
||||
@ -62,15 +62,17 @@ class _CirclePageState extends State<CirclePage>
|
||||
controller.state.index = index;
|
||||
if (index == logic.circle.lists.length - 1) {
|
||||
logic.loadMore();
|
||||
|
||||
}
|
||||
print(index.toString());
|
||||
controller.update();
|
||||
|
||||
},
|
||||
index: controller.state.index,
|
||||
itemCount: logic.circle.lists.length,
|
||||
viewportFraction: 0.93,
|
||||
// scale: 0.9,
|
||||
loop: false,
|
||||
key: UniqueKey(),
|
||||
// pagination: new SwiperPagination(),//如果不填则不显示指示点
|
||||
// control: new SwiperControl(),//如果不填则不显示左右按钮
|
||||
))
|
||||
|
||||
@ -5,6 +5,7 @@ import 'package:circle_app/app/circle/logic.dart';
|
||||
import 'package:circle_app/app/circle/state.dart';
|
||||
import 'package:circle_app/app/circle/widgets/list_logic.dart';
|
||||
import 'package:circle_app/app/circle/widgets/video_item.dart';
|
||||
import 'package:circle_app/network/dio_manager.dart';
|
||||
import 'package:circle_app/router/app_routers.dart';
|
||||
import 'package:circle_app/util/util.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@ -12,6 +13,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:get/get_core/src/get_main.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class InfoListView extends StatefulWidget {
|
||||
// Get.lazyPut(() => ListLogic());
|
||||
@ -26,7 +28,10 @@ class InfoListView extends StatefulWidget {
|
||||
State<InfoListView> createState() => _InfoListViewState();
|
||||
}
|
||||
|
||||
class _InfoListViewState extends State<InfoListView> {
|
||||
class _InfoListViewState extends State<InfoListView> with AutomaticKeepAliveClientMixin {
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
|
||||
List<String> genderList = ['男', '女,' 'MTF', 'FTM', 'CD', '酷儿'];
|
||||
|
||||
List<String> orientationList = [
|
||||
@ -43,14 +48,120 @@ class _InfoListViewState extends State<InfoListView> {
|
||||
|
||||
ListLogic? listsLg;
|
||||
|
||||
int callOutPage = 1;
|
||||
|
||||
bool isLoad = true;
|
||||
bool callOutMore = true;
|
||||
var circleId = '';
|
||||
List<Lists> lists = [];
|
||||
final ScrollController scrollController = ScrollController();
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
// TODO: implement dispose
|
||||
super.dispose();
|
||||
scrollController.dispose();
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
super.initState();
|
||||
Get.lazyPut(() => ListLogic());
|
||||
listsLg = Get.find<ListLogic>();
|
||||
listsLg!.loadCallOutListData(widget.bean.id.toString());
|
||||
scrollController.addListener(() {
|
||||
try {
|
||||
if (scrollController.position.pixels ==
|
||||
scrollController.position.maxScrollExtent) {
|
||||
loadMore();
|
||||
}
|
||||
} catch (e) {}
|
||||
});
|
||||
circleId = widget.bean.id
|
||||
.toString();
|
||||
loadCallOutListData();
|
||||
}
|
||||
|
||||
|
||||
|
||||
loadCallOutListData() async {
|
||||
var data = await DioManager.instance.get(
|
||||
url: "/up-service/interest/$circleId/callouts",
|
||||
params: {"page": callOutPage, "page_size": "20"});
|
||||
if (data["code"] == 200) {
|
||||
List dataList = data["data"]["lists"] ?? [];
|
||||
if (callOutPage == 1) {
|
||||
if (lists.isNotEmpty) {
|
||||
lists.clear();
|
||||
}
|
||||
}
|
||||
if (dataList.isNotEmpty) {
|
||||
callOutMore = true;
|
||||
for (var element in dataList) {
|
||||
lists.add(Lists.fromJson(element));
|
||||
}
|
||||
callOutPage++;
|
||||
}
|
||||
callOutMore = dataList.length == 20;
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
} else {
|
||||
showToast(data["msg"]);
|
||||
}
|
||||
}
|
||||
|
||||
setCircleId(String id) {
|
||||
circleId = id;
|
||||
loadCallOutListData();
|
||||
}
|
||||
|
||||
void refreshData() {
|
||||
callOutPage = 1;
|
||||
callOutMore = true;
|
||||
loadCallOutListData();
|
||||
}
|
||||
|
||||
void loadMore() {
|
||||
if (callOutMore == false) return;
|
||||
loadCallOutListData();
|
||||
}
|
||||
|
||||
void pushOtherPeopleHomePage(String userId) {
|
||||
Get.toNamed(AppRoutes.UserInfoActivity, arguments: userId);
|
||||
|
||||
// if (bean.isQueen) {
|
||||
// showJoinCiclePiker(cicleId);
|
||||
// } else {
|
||||
//跳转消息页面
|
||||
// Get.bottomSheet(Open_vip_tipPage(),
|
||||
// isScrollControlled: true,
|
||||
// enableDrag: false,
|
||||
// );
|
||||
// }
|
||||
}
|
||||
|
||||
void pushHomePage(Lists bean, String cicleId) async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
int userId = prefs.getInt("userId") ?? 0;
|
||||
if (bean.user!.id == userId) {
|
||||
Get.toNamed(AppRoutes.UserInfoActivity);
|
||||
} else {
|
||||
Get.toNamed(AppRoutes.UserInfoActivity,
|
||||
arguments: bean.user!.id!.toString());
|
||||
}
|
||||
|
||||
// if (bean.isQueen) {
|
||||
// showJoinCiclePiker(cicleId);
|
||||
// } else {
|
||||
//跳转消息页面
|
||||
// Get.bottomSheet(Open_vip_tipPage(),
|
||||
// isScrollControlled: true,
|
||||
// enableDrag: false,
|
||||
// );
|
||||
// }
|
||||
}
|
||||
|
||||
void pushMsgPage(Lists bean, String cicleId) async {}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -88,15 +199,12 @@ class _InfoListViewState extends State<InfoListView> {
|
||||
i++;
|
||||
});
|
||||
|
||||
return GetBuilder<ListLogic>(
|
||||
assignId: true,
|
||||
builder: (listLogic) {
|
||||
return ClipRRect(
|
||||
borderRadius: BorderRadius.circular(10.sp),
|
||||
child: Container(
|
||||
width: Get.width,
|
||||
margin: EdgeInsets.only(
|
||||
left: widget.index > 0 ? 4.sp : 0, right: 4.sp),
|
||||
margin:
|
||||
EdgeInsets.only(left: widget.index > 0 ? 4.sp : 0, right: 4.sp),
|
||||
child: Stack(
|
||||
children: [
|
||||
ClipRRect(
|
||||
@ -114,15 +222,17 @@ class _InfoListViewState extends State<InfoListView> {
|
||||
margin: EdgeInsets.only(top: 72.sp),
|
||||
child: RefreshIndicator(
|
||||
onRefresh: () async {
|
||||
listLogic.refreshData();
|
||||
refreshData();
|
||||
},
|
||||
child: listLogic.lists.isEmpty
|
||||
? !listLogic.callOutMore ? noResultWidget() : loaddingWidget(true)
|
||||
child: lists.isEmpty
|
||||
? !callOutMore
|
||||
? noResultWidget()
|
||||
: loaddingWidget(true)
|
||||
: ListView.builder(
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
scrollDirection: Axis.vertical,
|
||||
controller: listLogic.scrollController,
|
||||
itemCount: listLogic.lists.length + 2,
|
||||
controller: scrollController,
|
||||
itemCount: lists.length + 2,
|
||||
itemBuilder: (context, index) {
|
||||
if (index == 0) {
|
||||
return Container(
|
||||
@ -132,8 +242,8 @@ class _InfoListViewState extends State<InfoListView> {
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
fit: BoxFit.fill,
|
||||
image: AssetImage(getCircleImage(
|
||||
'circle_desc')))),
|
||||
image: AssetImage(
|
||||
getCircleImage('circle_desc')))),
|
||||
child: Container(
|
||||
margin: EdgeInsets.only(top: 14.sp),
|
||||
child: Column(
|
||||
@ -144,8 +254,7 @@ class _InfoListViewState extends State<InfoListView> {
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
_showTextContentDialog(
|
||||
context,
|
||||
widget.bean.intro);
|
||||
context, widget.bean.intro);
|
||||
},
|
||||
child: RichText(
|
||||
overflow: TextOverflow.fade,
|
||||
@ -197,19 +306,18 @@ class _InfoListViewState extends State<InfoListView> {
|
||||
),
|
||||
),
|
||||
);
|
||||
} else if (listLogic.lists.length + 1 >
|
||||
index) {
|
||||
Lists lists = listLogic.lists[index - 1];
|
||||
if (lists.isQueen!) {
|
||||
return vipDynamicItem(lists);
|
||||
} else if (lists.length + 1 > index) {
|
||||
Lists list = lists[index - 1];
|
||||
if (list.isQueen!) {
|
||||
return vipDynamicItem(list);
|
||||
} else {
|
||||
return normalDynamicItem(lists);
|
||||
return normalDynamicItem(list);
|
||||
}
|
||||
} else {
|
||||
return Container(
|
||||
margin: EdgeInsets.only(top: listLogic.callOutMore ? 0 : 10.sp),
|
||||
child: loaddingWidget(
|
||||
listLogic.callOutMore));
|
||||
margin: EdgeInsets.only(
|
||||
top: callOutMore ? 0 : 10.sp),
|
||||
child: loaddingWidget(callOutMore));
|
||||
}
|
||||
}),
|
||||
),
|
||||
@ -224,8 +332,8 @@ class _InfoListViewState extends State<InfoListView> {
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
fit: BoxFit.fill,
|
||||
image: AssetImage(
|
||||
getCircleImage('top_circle_bg')))),
|
||||
image:
|
||||
AssetImage(getCircleImage('top_circle_bg')))),
|
||||
child: Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
@ -256,8 +364,7 @@ class _InfoListViewState extends State<InfoListView> {
|
||||
),
|
||||
Expanded(
|
||||
child: Container(
|
||||
padding:
|
||||
EdgeInsets.only(left: 8.sp, top: 12.sp),
|
||||
padding: EdgeInsets.only(left: 8.sp, top: 12.sp),
|
||||
// alignment: Alignment.,
|
||||
height: 72.sp,
|
||||
child: Column(
|
||||
@ -306,8 +413,7 @@ class _InfoListViewState extends State<InfoListView> {
|
||||
Text(
|
||||
!widget.bean.isJoin ? '申请加入' : '已加入',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 12.sp),
|
||||
color: Colors.white, fontSize: 12.sp),
|
||||
)
|
||||
],
|
||||
))
|
||||
@ -322,8 +428,6 @@ class _InfoListViewState extends State<InfoListView> {
|
||||
)),
|
||||
],
|
||||
)));
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void _showTextContentDialog(BuildContext context, String msg) {
|
||||
@ -450,8 +554,7 @@ class _InfoListViewState extends State<InfoListView> {
|
||||
image: AssetImage(
|
||||
getCircleImage('pic_bg'),
|
||||
))),
|
||||
child: Stack(
|
||||
children: [
|
||||
child: Stack(children: [
|
||||
Positioned(
|
||||
left: 0,
|
||||
top: 2.sp,
|
||||
@ -497,8 +600,7 @@ class _InfoListViewState extends State<InfoListView> {
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
listsLg?.pushHomePage(
|
||||
lists, lists.id.toString());
|
||||
listsLg?.pushHomePage(lists, lists.id.toString());
|
||||
},
|
||||
child: ClipOval(
|
||||
child: Image.network(
|
||||
@ -679,7 +781,8 @@ class _InfoListViewState extends State<InfoListView> {
|
||||
)
|
||||
],
|
||||
),
|
||||
)]));
|
||||
)
|
||||
]));
|
||||
}
|
||||
|
||||
///普通图文喊话
|
||||
@ -831,10 +934,11 @@ class _InfoListViewState extends State<InfoListView> {
|
||||
Container(
|
||||
alignment: Alignment.center,
|
||||
height: 18.sp,
|
||||
padding:
|
||||
EdgeInsets.only(left: 6.sp, right: 6.sp),
|
||||
padding: EdgeInsets.only(
|
||||
left: 6.sp, right: 6.sp),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(9.sp),
|
||||
borderRadius:
|
||||
BorderRadius.circular(9.sp),
|
||||
gradient: const LinearGradient(
|
||||
begin: Alignment(0.25, 0.5),
|
||||
end: Alignment(0.75, 0.5),
|
||||
@ -896,13 +1000,15 @@ class _InfoListViewState extends State<InfoListView> {
|
||||
for (var element in lists.album!) {
|
||||
imgList.add(element.url!);
|
||||
}
|
||||
Get.toNamed(AppRoutes.Swiper, arguments: {
|
||||
Get.toNamed(AppRoutes.Swiper,
|
||||
arguments: {
|
||||
'imaglist': imgList,
|
||||
'index': currentIndex
|
||||
});
|
||||
},
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(6.sp),
|
||||
borderRadius:
|
||||
BorderRadius.circular(6.sp),
|
||||
child: CachedNetworkImage(
|
||||
imageUrl: album.url!,
|
||||
// placeholder: (context, url) =>
|
||||
@ -973,8 +1079,7 @@ class _InfoListViewState extends State<InfoListView> {
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
circleWidget(String url, {double width = 30}) {
|
||||
|
||||
@ -13,12 +13,11 @@ class ListLogic extends GetxController {
|
||||
|
||||
bool isLoad = true;
|
||||
bool callOutMore = true;
|
||||
var _circleId = '';
|
||||
var circleId = '';
|
||||
List<Lists> lists = [];
|
||||
final ScrollController scrollController = ScrollController();
|
||||
|
||||
loadCallOutListData(String circleId) async {
|
||||
_circleId = circleId;
|
||||
loadCallOutListData() async {
|
||||
var data = await DioManager.instance.get(
|
||||
url: "/up-service/interest/$circleId/callouts",
|
||||
params: {"page": callOutPage, "page_size": "20"});
|
||||
@ -43,17 +42,22 @@ class ListLogic extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
setCircleId(String id) {
|
||||
circleId = id;
|
||||
loadCallOutListData();
|
||||
}
|
||||
|
||||
void refreshData() {
|
||||
callOutPage = 1;
|
||||
callOutMore = true;
|
||||
loadCallOutListData(_circleId);
|
||||
loadCallOutListData();
|
||||
|
||||
|
||||
}
|
||||
|
||||
void loadMore() {
|
||||
if (callOutMore == false) return;
|
||||
loadCallOutListData(_circleId);
|
||||
loadCallOutListData();
|
||||
}
|
||||
|
||||
|
||||
@ -100,18 +104,23 @@ class ListLogic extends GetxController {
|
||||
void onInit() {
|
||||
// TODO: implement onInit
|
||||
super.onInit();
|
||||
scrollController.addListener(() {
|
||||
try {
|
||||
if (scrollController.position.pixels == scrollController.position.maxScrollExtent) {
|
||||
loadMore();
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
super.onReady();
|
||||
scrollController.addListener(() {
|
||||
if (scrollController.position.pixels == scrollController.position.maxScrollExtent && callOutMore) {
|
||||
loadMore();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
@override
|
||||
void onClose() {
|
||||
|
||||
@ -54,12 +54,12 @@ class _My_circlePageState extends State<My_circlePage>
|
||||
// Text(controller.state.msg),
|
||||
//组件使用
|
||||
Expanded(
|
||||
child: Swiper(
|
||||
child: logic.circle.lists.isEmpty ? loaddingWidget(true) : Swiper(
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
var bean = logic.circle.lists[index];
|
||||
return InfoListView(index, bean, controller);
|
||||
},
|
||||
index: logic.circle.lists.isNotEmpty ? 0 : controller.state.index,
|
||||
index: controller.state.index,
|
||||
itemCount: logic.circle.lists.length,
|
||||
viewportFraction: 0.93,
|
||||
// scale: 0.9,
|
||||
@ -69,8 +69,8 @@ class _My_circlePageState extends State<My_circlePage>
|
||||
if (index == logic.circle.lists.length - 1 && controller.isMore) {
|
||||
|
||||
logic.loadMore();
|
||||
controller.update();
|
||||
}
|
||||
|
||||
},
|
||||
// pagination: new SwiperPagination(),//如果不填则不显示指示点
|
||||
// control: new SwiperControl(),//如果不填则不显示左右按钮
|
||||
|
||||
Loading…
Reference in New Issue
Block a user