feat:更新组件UI
This commit is contained in:
65
lib/widgets/common/easy_refresh.dart
Normal file
65
lib/widgets/common/easy_refresh.dart
Normal file
@@ -0,0 +1,65 @@
|
||||
import 'package:easy_refresh/easy_refresh.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
Widget buildEasyRefresh({
|
||||
required EasyRefreshController freshController,
|
||||
required Future<void> Function()? onRefresh,
|
||||
required Future<void> Function()? onLoad,
|
||||
required Widget body,
|
||||
}) {
|
||||
return EasyRefresh(
|
||||
controller: freshController,
|
||||
header: ClassicHeader(
|
||||
dragText: '下拉刷新',
|
||||
armedText: '释放刷新',
|
||||
readyText: '准备刷新',
|
||||
processingText: '刷新中...',
|
||||
processedText: '刷新完成',
|
||||
failedText: '刷新失败',
|
||||
noMoreText: '没有更多数据',
|
||||
showText: true,
|
||||
messageText: '更新于 %T',
|
||||
showMessage: true,
|
||||
),
|
||||
footer: ClassicFooter(
|
||||
dragText: '上拉加载',
|
||||
armedText: '释放加载',
|
||||
readyText: '准备加载',
|
||||
processingText: '加载中...',
|
||||
processedText: '加载完成',
|
||||
failedText: '加载失败',
|
||||
noMoreText: '没有更多数据',
|
||||
showText: true,
|
||||
messageText: '更新于 %T',
|
||||
showMessage: true,
|
||||
),
|
||||
onRefresh: onRefresh,
|
||||
onLoad: onLoad,
|
||||
child: body,
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildScrollToTop({
|
||||
required BuildContext context,
|
||||
required VoidCallback scrollToTop,
|
||||
}) {
|
||||
return Positioned(
|
||||
right: 0,
|
||||
bottom: 20,
|
||||
child: FloatingActionButton(
|
||||
onPressed: scrollToTop,
|
||||
backgroundColor: Theme.of(context).colorScheme.primary,
|
||||
elevation: 2,
|
||||
mini: true,
|
||||
child: const Icon(Icons.arrow_upward, color: Colors.white),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void scrollToTopAnimateTo(ScrollController controller) {
|
||||
controller.animateTo(
|
||||
0,
|
||||
duration: const Duration(milliseconds: 500), // 滚动动画时长
|
||||
curve: Curves.easeInOut, // 滚动动画曲线
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user