mod: 关注、粉丝页面优化
This commit is contained in:
@ -1,6 +1,8 @@
|
||||
import 'package:easy_debounce/easy_throttle.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:pilipala/common/widgets/http_error.dart';
|
||||
import 'package:pilipala/common/widgets/no_data.dart';
|
||||
import 'package:pilipala/models/fans/result.dart';
|
||||
|
||||
import 'controller.dart';
|
||||
@ -17,7 +19,6 @@ class _FansPageState extends State<FansPage> {
|
||||
final FansController _fansController = Get.put(FansController());
|
||||
final ScrollController scrollController = ScrollController();
|
||||
Future? _futureBuilderFuture;
|
||||
bool _isLoadingMore = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@ -27,11 +28,9 @@ class _FansPageState extends State<FansPage> {
|
||||
() async {
|
||||
if (scrollController.position.pixels >=
|
||||
scrollController.position.maxScrollExtent - 200) {
|
||||
if (!_isLoadingMore) {
|
||||
_isLoadingMore = true;
|
||||
await _fansController.queryFans('onLoad');
|
||||
_isLoadingMore = false;
|
||||
}
|
||||
EasyThrottle.throttle('follow', const Duration(seconds: 1), () {
|
||||
_fansController.queryFans('onLoad');
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
@ -66,14 +65,38 @@ class _FansPageState extends State<FansPage> {
|
||||
if (data['status']) {
|
||||
List<FansItemModel> list = _fansController.fansList;
|
||||
return Obx(
|
||||
() => list.length == 1
|
||||
? const SizedBox()
|
||||
: ListView.builder(
|
||||
() => list.isNotEmpty
|
||||
? ListView.builder(
|
||||
controller: scrollController,
|
||||
itemCount: list.length,
|
||||
itemCount: list.length + 1,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return fanItem(item: list[index]);
|
||||
if (index == list.length) {
|
||||
return Container(
|
||||
height:
|
||||
MediaQuery.of(context).padding.bottom + 60,
|
||||
padding: EdgeInsets.only(
|
||||
bottom:
|
||||
MediaQuery.of(context).padding.bottom),
|
||||
child: Center(
|
||||
child: Obx(
|
||||
() => Text(
|
||||
_fansController.loadingText.value,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.outline,
|
||||
fontSize: 13),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return fanItem(item: list[index]);
|
||||
}
|
||||
},
|
||||
)
|
||||
: const CustomScrollView(
|
||||
slivers: [NoData()],
|
||||
),
|
||||
);
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user