fix_个人中心&博主主页
This commit is contained in:
parent
314aeddf23
commit
67ed131eeb
@ -543,16 +543,6 @@ class _IndexPageState extends State<IndexPage> with TickerProviderStateMixin {
|
|||||||
SliverToBoxAdapter(
|
SliverToBoxAdapter(
|
||||||
child: Obx(
|
child: Obx(
|
||||||
() {
|
() {
|
||||||
// if (isInitLoading.value) {
|
|
||||||
// return Column(
|
|
||||||
// children: [
|
|
||||||
// RefreshProgressIndicator(
|
|
||||||
// backgroundColor: Colors.white,
|
|
||||||
// color: Color(0xFFFF5000),
|
|
||||||
// ),
|
|
||||||
// ],
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
if (dataList.isEmpty) {
|
if (dataList.isEmpty) {
|
||||||
return EmptyTip();
|
return EmptyTip();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,7 +28,7 @@ import '../../utils/common.dart';
|
|||||||
class PageParams {
|
class PageParams {
|
||||||
int page;
|
int page;
|
||||||
int pageSize;
|
int pageSize;
|
||||||
bool isLoading;
|
RxBool isLoading;
|
||||||
RxBool hasMore;
|
RxBool hasMore;
|
||||||
int total;
|
int total;
|
||||||
bool isInitLoading;
|
bool isInitLoading;
|
||||||
@ -36,16 +36,21 @@ class PageParams {
|
|||||||
PageParams({
|
PageParams({
|
||||||
this.page = 1,
|
this.page = 1,
|
||||||
this.pageSize = 10,
|
this.pageSize = 10,
|
||||||
this.isLoading = false,
|
bool isLoading = false,
|
||||||
bool hasMore = true,
|
bool hasMore = true,
|
||||||
this.total = 0,
|
this.total = 0,
|
||||||
this.isInitLoading = true,
|
this.isInitLoading = true,
|
||||||
}) : hasMore = hasMore.obs;
|
}) : hasMore = hasMore.obs,
|
||||||
|
isLoading = isLoading.obs;
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'PageParams(page: $page, pageSize: $pageSize, isLoading: ${isLoading.value}, hasMore: ${hasMore.value})';
|
||||||
|
}
|
||||||
|
|
||||||
void init() {
|
void init() {
|
||||||
page = 1;
|
page = 1;
|
||||||
pageSize = 10;
|
pageSize = 10;
|
||||||
isLoading = false;
|
isLoading.value = false;
|
||||||
hasMore.value = true;
|
hasMore.value = true;
|
||||||
total = 0;
|
total = 0;
|
||||||
isInitLoading = true;
|
isInitLoading = true;
|
||||||
@ -98,16 +103,16 @@ class MyPageState extends State<MyPage> with SingleTickerProviderStateMixin {
|
|||||||
super.initState();
|
super.initState();
|
||||||
imUserInfoController = Get.find<ImUserInfoController>();
|
imUserInfoController = Get.find<ImUserInfoController>();
|
||||||
initControllers();
|
initControllers();
|
||||||
|
// 这里保证委托父类处理滚动时的触底加载
|
||||||
scrollListener = () {
|
scrollListener = () {
|
||||||
final pos = scrollController.position;
|
final pos = scrollController.position;
|
||||||
final isNearBottom = pos.pixels >= pos.maxScrollExtent - 100;
|
final isNearBottom = pos.pixels >= pos.maxScrollExtent - 100;
|
||||||
|
|
||||||
if (!isNearBottom) return;
|
if (!isNearBottom) return;
|
||||||
|
|
||||||
if (currentTabIndex.value == 0 && !itemsParams.isLoading && itemsParams.hasMore.value) {
|
if (currentTabIndex.value == 0 && !itemsParams.isLoading.value && itemsParams.hasMore.value) {
|
||||||
loadData(0);
|
loadData(0);
|
||||||
} else if (currentTabIndex.value == 1 && !favoriteParams.isLoading && favoriteParams.hasMore.value) {
|
} else if (currentTabIndex.value == 1 && !favoriteParams.isLoading.value && favoriteParams.hasMore.value) {
|
||||||
loadData(1);
|
loadData(1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -124,8 +129,6 @@ class MyPageState extends State<MyPage> with SingleTickerProviderStateMixin {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
tabController.addListener(tabListener);
|
tabController.addListener(tabListener);
|
||||||
|
|
||||||
// loadData(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -165,10 +168,10 @@ class MyPageState extends State<MyPage> with SingleTickerProviderStateMixin {
|
|||||||
Future<void> loadData([int? tabIndex]) async {
|
Future<void> loadData([int? tabIndex]) async {
|
||||||
final index = tabIndex ?? currentTabIndex.value;
|
final index = tabIndex ?? currentTabIndex.value;
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
if (itemsParams.isLoading || !itemsParams.hasMore.value) return;
|
if (itemsParams.isLoading.value || !itemsParams.hasMore.value) return;
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
itemsParams.isLoading = true;
|
itemsParams.isLoading.value = true;
|
||||||
// itemsParams.isInitLoading = true;
|
});
|
||||||
|
|
||||||
final res = await Http.post(VideoApi.myPublicList, data: {
|
final res = await Http.post(VideoApi.myPublicList, data: {
|
||||||
"userId": imUserInfoController.userID.value,
|
"userId": imUserInfoController.userID.value,
|
||||||
@ -179,25 +182,22 @@ class MyPageState extends State<MyPage> with SingleTickerProviderStateMixin {
|
|||||||
final obj = res['data'];
|
final obj = res['data'];
|
||||||
final total = obj['total'];
|
final total = obj['total'];
|
||||||
final row = obj['records'] ?? [];
|
final row = obj['records'] ?? [];
|
||||||
logger.i(res['data']);
|
|
||||||
// 判断是否还有更多数据
|
// 判断是否还有更多数据
|
||||||
logger.e(items.length);
|
logger.e(items.length);
|
||||||
// 添加新数据,触发响应式更新
|
// 添加新数据,触发响应式更新
|
||||||
items.addAll(row);
|
items.addAll(row);
|
||||||
logger.e(obj);
|
itemsParams.page++;
|
||||||
|
|
||||||
if (items.length >= total) {
|
if (items.length >= total) {
|
||||||
itemsParams.hasMore.value = false;
|
itemsParams.hasMore.value = false;
|
||||||
}
|
}
|
||||||
// 页码加一
|
itemsParams.isLoading.value = false;
|
||||||
itemsParams.page++;
|
|
||||||
//
|
|
||||||
itemsParams.isLoading = false;
|
|
||||||
itemsParams.isInitLoading = false;
|
itemsParams.isInitLoading = false;
|
||||||
} else if (index == 1) {
|
} else if (index == 1) {
|
||||||
if (favoriteParams.isLoading || !favoriteParams.hasMore.value) return;
|
if (favoriteParams.isLoading.value || !favoriteParams.hasMore.value) return;
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
favoriteParams.isLoading = true;
|
favoriteParams.isLoading.value = true;
|
||||||
// favoriteParams.isInitLoading = true;
|
});
|
||||||
|
|
||||||
final res = await Http.post(VideoApi.myLikedList, data: {
|
final res = await Http.post(VideoApi.myLikedList, data: {
|
||||||
"userId": imUserInfoController.userID.value,
|
"userId": imUserInfoController.userID.value,
|
||||||
@ -209,14 +209,14 @@ class MyPageState extends State<MyPage> with SingleTickerProviderStateMixin {
|
|||||||
final total = obj['total'];
|
final total = obj['total'];
|
||||||
final row = obj['records'] ?? [];
|
final row = obj['records'] ?? [];
|
||||||
favoriteItems.addAll(row);
|
favoriteItems.addAll(row);
|
||||||
|
favoriteParams.page++;
|
||||||
|
|
||||||
if (favoriteItems.length >= total) {
|
if (favoriteItems.length >= total) {
|
||||||
favoriteParams.hasMore.value = false;
|
favoriteParams.hasMore.value = false;
|
||||||
}
|
}
|
||||||
|
favoriteParams.isLoading.value = false;
|
||||||
favoriteParams.page++;
|
|
||||||
favoriteParams.isLoading = false;
|
|
||||||
favoriteParams.isInitLoading = false;
|
favoriteParams.isInitLoading = false;
|
||||||
|
logger.e(favoriteParams.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -583,9 +583,19 @@ class MyPageState extends State<MyPage> with SingleTickerProviderStateMixin {
|
|||||||
if (listToShow.isEmpty) {
|
if (listToShow.isEmpty) {
|
||||||
return emptyTip('暂无相关数据');
|
return emptyTip('暂无相关数据');
|
||||||
}
|
}
|
||||||
return CustomScrollView(
|
return NotificationListener<ScrollNotification>(
|
||||||
// physics: !isPinned.value ? NeverScrollableScrollPhysics() : AlwaysScrollableScrollPhysics(),
|
onNotification: (notification) {
|
||||||
// physics: AlwaysScrollableScrollPhysics(),
|
if (notification is ScrollUpdateNotification) {
|
||||||
|
final metrics = notification.metrics;
|
||||||
|
final isNearBottom = metrics.pixels == metrics.maxScrollExtent;
|
||||||
|
|
||||||
|
if (isNearBottom && !params.isLoading.value && params.hasMore.value) {
|
||||||
|
loadData(tabIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
child: CustomScrollView(
|
||||||
key: PageStorageKey('myindex_$tabIndex'),
|
key: PageStorageKey('myindex_$tabIndex'),
|
||||||
slivers: [
|
slivers: [
|
||||||
SliverPadding(
|
SliverPadding(
|
||||||
@ -614,15 +624,24 @@ class MyPageState extends State<MyPage> with SingleTickerProviderStateMixin {
|
|||||||
),
|
),
|
||||||
SliverToBoxAdapter(
|
SliverToBoxAdapter(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 20.0),
|
padding: EdgeInsets.symmetric(vertical: 20.0),
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Obx(
|
child: Obx(
|
||||||
() => params.hasMore.value ? CircularProgressIndicator() : Text('没有更多数据了'),
|
() {
|
||||||
|
if (params.isLoading.value) {
|
||||||
|
return SafeArea(top: false, child: CircularProgressIndicator());
|
||||||
|
} else if (!params.hasMore.value) {
|
||||||
|
return SafeArea(top: false, child: Text('没有更多数据了'));
|
||||||
|
} else {
|
||||||
|
return SizedBox(height: 20);
|
||||||
|
}
|
||||||
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -23,15 +23,20 @@ import 'package:tencent_cloud_chat_sdk/models/v2_tim_user_full_info.dart';
|
|||||||
class PageParams {
|
class PageParams {
|
||||||
int page;
|
int page;
|
||||||
int pageSize;
|
int pageSize;
|
||||||
bool isLoading;
|
RxBool isLoading;
|
||||||
bool hasMore;
|
RxBool hasMore;
|
||||||
|
|
||||||
PageParams({
|
PageParams({
|
||||||
this.page = 1,
|
this.page = 1,
|
||||||
this.pageSize = 10,
|
this.pageSize = 12,
|
||||||
this.isLoading = false,
|
bool isLoading = false,
|
||||||
this.hasMore = true,
|
bool hasMore = true,
|
||||||
});
|
}) : hasMore = hasMore.obs,
|
||||||
|
isLoading = isLoading.obs;
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'PageParams(page: $page, pageSize: $pageSize, isLoading: ${isLoading.value}, hasMore: ${hasMore.value})';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Vloger extends StatefulWidget {
|
class Vloger extends StatefulWidget {
|
||||||
@ -67,7 +72,7 @@ class MyPageState extends State<Vloger> with SingleTickerProviderStateMixin {
|
|||||||
));
|
));
|
||||||
|
|
||||||
RxBool get shouldFixHeader => (currentTabIndex.value == 0 && items.isEmpty) || (currentTabIndex.value == 1 && favoriteItems.isEmpty) ? true.obs : false.obs;
|
RxBool get shouldFixHeader => (currentTabIndex.value == 0 && items.isEmpty) || (currentTabIndex.value == 1 && favoriteItems.isEmpty) ? true.obs : false.obs;
|
||||||
|
RxInt totalCount = 0.obs;
|
||||||
List tabList = [
|
List tabList = [
|
||||||
{'name': "作品"},
|
{'name': "作品"},
|
||||||
];
|
];
|
||||||
@ -85,24 +90,21 @@ class MyPageState extends State<Vloger> with SingleTickerProviderStateMixin {
|
|||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
args = Get.arguments ?? {};
|
args = Get.arguments ?? {};
|
||||||
print('argsssssssssssssssssssssss$args');
|
logger.e(args);
|
||||||
itemsParams = PageParams();
|
itemsParams = PageParams();
|
||||||
favoriteParams = PageParams();
|
favoriteParams = PageParams();
|
||||||
selfInfo();
|
selfInfo();
|
||||||
flowInfo();
|
flowInfo();
|
||||||
checkFollowType();
|
checkFollowType();
|
||||||
initControllers();
|
initControllers();
|
||||||
|
// 这里保证委托父类处理滚动时的触底加载
|
||||||
scrollListener = () {
|
scrollListener = () {
|
||||||
final pos = scrollController.position;
|
final pos = scrollController.position;
|
||||||
final isNearBottom = pos.pixels >= pos.maxScrollExtent - 100;
|
final isNearBottom = pos.pixels >= pos.maxScrollExtent - 100;
|
||||||
|
|
||||||
if (!isNearBottom) return;
|
if (!isNearBottom) return;
|
||||||
|
|
||||||
if (currentTabIndex.value == 0 && !itemsParams.isLoading && itemsParams.hasMore) {
|
if (currentTabIndex.value == 0 && !itemsParams.isLoading.value && itemsParams.hasMore.value) {
|
||||||
loadData(0);
|
loadData(0);
|
||||||
} else if (currentTabIndex.value == 1 && !favoriteParams.isLoading && favoriteParams.hasMore) {
|
|
||||||
loadData(1);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
scrollController.addListener(scrollListener);
|
scrollController.addListener(scrollListener);
|
||||||
@ -133,18 +135,27 @@ class MyPageState extends State<Vloger> with SingleTickerProviderStateMixin {
|
|||||||
void getUserLikesCount() async {
|
void getUserLikesCount() async {
|
||||||
try {
|
try {
|
||||||
final resData = await Http.get('${CommonApi.accountInfo}?memberId=${args['memberId']}');
|
final resData = await Http.get('${CommonApi.accountInfo}?memberId=${args['memberId']}');
|
||||||
print('aaaaaaaaaaaaaaaaaaa$resData');
|
logger.e('$resData');
|
||||||
if (resData != null && resData['code'] == 200) {
|
if (resData != null && resData['code'] == 200) {
|
||||||
vlogLikeCount = resData['data']['vlogLikeCount'] ?? 0;
|
vlogLikeCount = resData['data']['vlogLikeCount'] ?? 0;
|
||||||
}
|
}
|
||||||
} catch (e) {}
|
} catch (e) {
|
||||||
|
logger.e(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadData([int? tabIndex]) async {
|
void loadData([int? tabIndex]) async {
|
||||||
final index = tabIndex ?? currentTabIndex.value;
|
final index = tabIndex ?? currentTabIndex.value;
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
if (itemsParams.isLoading || !itemsParams.hasMore) return;
|
if (itemsParams.isLoading.value || !itemsParams.hasMore.value) return;
|
||||||
itemsParams.isLoading = true;
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
itemsParams.isLoading.value = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
// await Future.delayed(Duration(seconds: 5), () {
|
||||||
|
// logger.e('5秒后执行完毕');
|
||||||
|
// });
|
||||||
|
|
||||||
final res = await Http.post(VideoApi.getVideoListByMemberId, data: {
|
final res = await Http.post(VideoApi.getVideoListByMemberId, data: {
|
||||||
"memberId": args['memberId'],
|
"memberId": args['memberId'],
|
||||||
"current": itemsParams.page,
|
"current": itemsParams.page,
|
||||||
@ -153,19 +164,20 @@ class MyPageState extends State<Vloger> with SingleTickerProviderStateMixin {
|
|||||||
final obj = res['data'];
|
final obj = res['data'];
|
||||||
final total = obj['total'];
|
final total = obj['total'];
|
||||||
final row = obj['records'] ?? [];
|
final row = obj['records'] ?? [];
|
||||||
logger.i(res['data']);
|
// logger.i(res['data']);
|
||||||
|
totalCount.value = total;
|
||||||
// 判断是否还有更多数据
|
// 判断是否还有更多数据
|
||||||
logger.e(items.length);
|
logger.e(items.length);
|
||||||
// 添加新数据,触发响应式更新
|
// 添加新数据,触发响应式更新
|
||||||
items.addAll(row);
|
items.addAll(row);
|
||||||
logger.e(obj);
|
|
||||||
if (items.length >= total) {
|
|
||||||
itemsParams.hasMore = false;
|
|
||||||
}
|
|
||||||
// 页码加一
|
|
||||||
itemsParams.page++;
|
itemsParams.page++;
|
||||||
//
|
|
||||||
itemsParams.isLoading = false;
|
if (items.length >= total) {
|
||||||
|
itemsParams.hasMore.value = false;
|
||||||
|
}
|
||||||
|
itemsParams.isLoading.value = false;
|
||||||
|
|
||||||
|
logger.e(itemsParams.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -418,14 +430,20 @@ class MyPageState extends State<Vloger> with SingleTickerProviderStateMixin {
|
|||||||
controller: tabController,
|
controller: tabController,
|
||||||
tabs: tabList.map((item) {
|
tabs: tabList.map((item) {
|
||||||
return Tab(
|
return Tab(
|
||||||
child: Badge.count(
|
child: Obx(
|
||||||
backgroundColor: Colors.red,
|
() => Text(
|
||||||
count: item['badge'] ?? 0,
|
'${item['name']}(${totalCount.value})',
|
||||||
isLabelVisible: item['badge'] != null,
|
style: TextStyle(fontWeight: FontWeight.bold),
|
||||||
alignment: Alignment.topRight,
|
|
||||||
offset: const Offset(14, -6),
|
|
||||||
child: Text(item['name'], style: const TextStyle(fontWeight: FontWeight.bold)),
|
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
// child: Badge.count(
|
||||||
|
// backgroundColor: Colors.red,
|
||||||
|
// count: item['badge'] ?? 0,
|
||||||
|
// isLabelVisible: item['badge'] != null,
|
||||||
|
// alignment: Alignment.topRight,
|
||||||
|
// offset: const Offset(14, -6),
|
||||||
|
// child: Text(item['name'], style: const TextStyle(fontWeight: FontWeight.bold)),
|
||||||
|
// ),
|
||||||
);
|
);
|
||||||
}).toList(),
|
}).toList(),
|
||||||
isScrollable: true, //禁止左右滑动
|
isScrollable: true, //禁止左右滑动
|
||||||
@ -496,8 +514,19 @@ class MyPageState extends State<Vloger> with SingleTickerProviderStateMixin {
|
|||||||
if (listToShow.isEmpty) {
|
if (listToShow.isEmpty) {
|
||||||
return emptyTip('暂无相关数据');
|
return emptyTip('暂无相关数据');
|
||||||
}
|
}
|
||||||
|
return NotificationListener<ScrollNotification>(
|
||||||
|
onNotification: (notification) {
|
||||||
|
if (notification is ScrollUpdateNotification) {
|
||||||
|
final metrics = notification.metrics;
|
||||||
|
final isNearBottom = metrics.pixels >= metrics.maxScrollExtent;
|
||||||
|
|
||||||
return CustomScrollView(
|
if (isNearBottom && !params.isLoading.value && params.hasMore.value) {
|
||||||
|
loadData(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
child: CustomScrollView(
|
||||||
slivers: [
|
slivers: [
|
||||||
SliverPadding(
|
SliverPadding(
|
||||||
padding: const EdgeInsets.all(10.0),
|
padding: const EdgeInsets.all(10.0),
|
||||||
@ -588,7 +617,7 @@ class MyPageState extends State<Vloger> with SingleTickerProviderStateMixin {
|
|||||||
crossAxisCount: 3,
|
crossAxisCount: 3,
|
||||||
crossAxisSpacing: 10.0,
|
crossAxisSpacing: 10.0,
|
||||||
mainAxisSpacing: 10.0,
|
mainAxisSpacing: 10.0,
|
||||||
childAspectRatio: 0.7, // 调整为更适合视频封面的比例
|
childAspectRatio: 0.6, // 宽高比1=正方
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -596,11 +625,22 @@ class MyPageState extends State<Vloger> with SingleTickerProviderStateMixin {
|
|||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 20.0),
|
padding: const EdgeInsets.symmetric(vertical: 20.0),
|
||||||
child: Center(
|
child: Center(
|
||||||
child: params.hasMore ? const CircularProgressIndicator() : const Text('没有更多数据了'),
|
child: Obx(
|
||||||
|
() {
|
||||||
|
if (params.isLoading.value) {
|
||||||
|
return SafeArea(top: false, child: CircularProgressIndicator());
|
||||||
|
} else if (!params.hasMore.value) {
|
||||||
|
return SafeArea(top: false, child: Text('没有更多数据了'));
|
||||||
|
} else {
|
||||||
|
return SizedBox(height: 20);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user