63 lines
1.6 KiB
Dart
63 lines
1.6 KiB
Dart
|
import 'package:flutter/cupertino.dart';
|
||
|
import 'package:pull_to_refresh/pull_to_refresh.dart';
|
||
|
import 'package:sk_base_mobile/util/screen_adaper_util.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) {
|
||
|
TextStyle style = TextStyle(fontSize: ScreenAdaper.sp(18));
|
||
|
Widget body;
|
||
|
if (mode == RefreshStatus.refreshing) {
|
||
|
body = const CupertinoActivityIndicator();
|
||
|
} else if (mode == RefreshStatus.canRefresh) {
|
||
|
body = const CupertinoActivityIndicator(animating: false);
|
||
|
} else if (mode == RefreshStatus.completed) {
|
||
|
body = const SizedBox();
|
||
|
} else if (mode == RefreshStatus.failed) {
|
||
|
body = Text("No more Data)", style: style);
|
||
|
} else {
|
||
|
body = const CupertinoActivityIndicator();
|
||
|
}
|
||
|
return SizedBox(
|
||
|
height: ScreenAdaper.height(40),
|
||
|
child: Center(child: body),
|
||
|
);
|
||
|
}
|
||
|
|
||
|
@override
|
||
|
void dispose() {
|
||
|
super.dispose();
|
||
|
}
|
||
|
}
|