mobile_skt/lib/widgets/refresh_header.dart

68 lines
1.8 KiB
Dart
Raw Normal View History

import 'package:flutter/cupertino.dart';
2024-03-25 14:16:00 +08:00
import 'package:loading_animation_widget/loading_animation_widget.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
2024-03-25 14:16:00 +08:00
import 'package:sk_base_mobile/app_theme.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';
class RefreshHeader extends RefreshIndicator {
RefreshHeader()
: super(
height: ScreenAdaper.height(100),
refreshStyle: RefreshStyle.Follow);
@override
State<StatefulWidget> createState() {
// TODO: implement createState
return RefreshHeaderState();
}
}
class RefreshHeaderState extends RefreshIndicatorState<RefreshHeader>
with SingleTickerProviderStateMixin {
@override
void initState() {
super.initState();
}
@override
void onModeChange(RefreshStatus? mode) {
super.onModeChange(mode);
}
@override
Future<void> endRefresh() async {}
@override
void resetValue() {
super.resetValue();
}
@override
Widget buildContent(BuildContext context, RefreshStatus mode) {
2024-03-28 17:18:46 +08:00
TextStyle style = TextStyle(fontSize: ScreenAdaper.height(18));
Widget body;
if (mode == RefreshStatus.refreshing) {
2024-03-25 14:16:00 +08:00
body = const LoadingIndicator();
} else if (mode == RefreshStatus.canRefresh) {
2024-03-25 14:16:00 +08:00
body = const LoadingIndicator(
animating: false,
);
} else if (mode == RefreshStatus.completed) {
body = const SizedBox();
} else if (mode == RefreshStatus.failed) {
2024-03-25 14:16:00 +08:00
body = Text("没有更多数据了", style: style);
} else {
2024-03-25 14:16:00 +08:00
body = const LoadingIndicator();
}
return SizedBox(
height: ScreenAdaper.height(40),
child: Center(child: body),
);
}
@override
void dispose() {
super.dispose();
}
}