12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- import 'package:flutter/cupertino.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter_easyrefresh/easy_refresh.dart';
- import 'package:ftrecruiter/comm/utils/dark_theme_util.dart';
- class CustomFootView extends Footer {
- /// Key
- final Key? key;
- final LinkFooterNotifier linkNotifier = LinkFooterNotifier();
- CustomFootView({
- this.key,
- bool enableHapticFeedback = true,
- bool enableInfiniteLoad = true,
- bool overScroll = false,
- }) : super(
- extent: 50.0,
- triggerDistance: 50.0,
- float: false,
- enableHapticFeedback: enableHapticFeedback,
- enableInfiniteLoad: enableInfiniteLoad,
- overScroll: overScroll,
- );
- @override
- Widget contentBuilder(
- BuildContext context,
- LoadMode loadState,
- double pulledExtent,
- double loadTriggerPullDistance,
- double loadIndicatorExtent,
- AxisDirection axisDirection,
- bool float,
- Duration? completeDuration,
- bool enableInfiniteLoad,
- bool success,
- bool noMore) {
- // 不能为水平方向
- assert(axisDirection == AxisDirection.down || axisDirection == AxisDirection.up, 'Widget cannot be horizontal');
- linkNotifier.contentBuilder(context, loadState, pulledExtent, loadTriggerPullDistance, loadIndicatorExtent,
- axisDirection, float, completeDuration, enableInfiniteLoad, success, noMore);
- return CustomMoreWidget(
- key: key,
- linkNotifier: linkNotifier,
- );
- }
- }
- //LoadMore-底部加载更多的布局
- class CustomMoreWidget extends StatefulWidget {
- final LinkFooterNotifier linkNotifier;
- const CustomMoreWidget({Key? key, required this.linkNotifier}) : super(key: key);
- @override
- CustomFooterWidgetState createState() {
- return CustomFooterWidgetState();
- }
- }
- class CustomFooterWidgetState extends State<CustomMoreWidget> {
- LoadMode get _refreshState => widget.linkNotifier.loadState;
- bool get _noMore => widget.linkNotifier.noMore;
- @override
- Widget build(BuildContext context) {
- return Container(
- height: 50,
- alignment:Alignment.center ,
- padding: const EdgeInsets.symmetric(vertical: 10.0),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: <Widget>[
- if (!_noMore) const CupertinoActivityIndicator(),
- if (!_noMore)
- const SizedBox(
- width: 5,
- ),
- // 只有一页的时候,就不显示FooterView了
- Text(!_noMore ? '正在加载中...' : '没有了呦~',
- style: TextStyle(
- fontSize: 14, color: DarkThemeUtil.multiColors(const Color(0x8A000000), darkColor: Colors.white54))),
- ],
- ),
- );
- }
- }
|