2024-03-18 13:23:58 +08:00
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
import 'package:pull_to_refresh/pull_to_refresh.dart';
|
|
|
|
import 'package:sk_base_mobile/util/screen_adaper_util.dart';
|
2024-03-25 14:16:00 +08:00
|
|
|
import 'package:sk_base_mobile/widgets/loading_indicator.dart';
|
2024-03-18 13:23:58 +08:00
|
|
|
|
|
|
|
class RefreshFooter extends StatefulWidget {
|
2024-03-31 17:13:29 +08:00
|
|
|
const RefreshFooter({super.key});
|
2024-03-18 13:23:58 +08:00
|
|
|
|
|
|
|
@override
|
|
|
|
State<RefreshFooter> createState() => _RefreshFooterState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _RefreshFooterState extends State<RefreshFooter>
|
|
|
|
with SingleTickerProviderStateMixin {
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return buildBody();
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget buildBody() {
|
2024-03-28 17:18:46 +08:00
|
|
|
TextStyle style = TextStyle(fontSize: ScreenAdaper.height(18));
|
2024-03-18 13:23:58 +08:00
|
|
|
return CustomFooter(
|
|
|
|
builder: (BuildContext context, LoadStatus? status) {
|
|
|
|
Widget body;
|
|
|
|
if (status == LoadStatus.idle) {
|
2024-03-25 14:16:00 +08:00
|
|
|
body = const Text("上拉获取更多");
|
2024-03-18 13:23:58 +08:00
|
|
|
} else if (status == LoadStatus.loading) {
|
2024-03-25 14:16:00 +08:00
|
|
|
body = const LoadingIndicator();
|
2024-03-18 13:23:58 +08:00
|
|
|
} else if (status == LoadStatus.failed) {
|
|
|
|
body = Text(
|
2024-03-25 14:16:00 +08:00
|
|
|
"获取失败,请重试",
|
2024-03-18 13:23:58 +08:00
|
|
|
style: style,
|
|
|
|
);
|
|
|
|
} else if (status == LoadStatus.canLoading) {
|
2024-03-25 14:16:00 +08:00
|
|
|
body = const LoadingIndicator(
|
2024-03-18 13:23:58 +08:00
|
|
|
animating: false,
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
body = const SizedBox();
|
|
|
|
}
|
|
|
|
return SizedBox(
|
|
|
|
height: ScreenAdaper.height(20),
|
|
|
|
child: Center(child: body),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|