custom_foot_view.dart 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter_easyrefresh/easy_refresh.dart';
  4. import 'package:ftrecruiter/comm/utils/dark_theme_util.dart';
  5. class CustomFootView extends Footer {
  6. /// Key
  7. final Key? key;
  8. final LinkFooterNotifier linkNotifier = LinkFooterNotifier();
  9. CustomFootView({
  10. this.key,
  11. bool enableHapticFeedback = true,
  12. bool enableInfiniteLoad = true,
  13. bool overScroll = false,
  14. }) : super(
  15. extent: 50.0,
  16. triggerDistance: 50.0,
  17. float: false,
  18. enableHapticFeedback: enableHapticFeedback,
  19. enableInfiniteLoad: enableInfiniteLoad,
  20. overScroll: overScroll,
  21. );
  22. @override
  23. Widget contentBuilder(
  24. BuildContext context,
  25. LoadMode loadState,
  26. double pulledExtent,
  27. double loadTriggerPullDistance,
  28. double loadIndicatorExtent,
  29. AxisDirection axisDirection,
  30. bool float,
  31. Duration? completeDuration,
  32. bool enableInfiniteLoad,
  33. bool success,
  34. bool noMore) {
  35. // 不能为水平方向
  36. assert(axisDirection == AxisDirection.down || axisDirection == AxisDirection.up, 'Widget cannot be horizontal');
  37. linkNotifier.contentBuilder(context, loadState, pulledExtent, loadTriggerPullDistance, loadIndicatorExtent,
  38. axisDirection, float, completeDuration, enableInfiniteLoad, success, noMore);
  39. return CustomMoreWidget(
  40. key: key,
  41. linkNotifier: linkNotifier,
  42. );
  43. }
  44. }
  45. //LoadMore-底部加载更多的布局
  46. class CustomMoreWidget extends StatefulWidget {
  47. final LinkFooterNotifier linkNotifier;
  48. const CustomMoreWidget({Key? key, required this.linkNotifier}) : super(key: key);
  49. @override
  50. CustomFooterWidgetState createState() {
  51. return CustomFooterWidgetState();
  52. }
  53. }
  54. class CustomFooterWidgetState extends State<CustomMoreWidget> {
  55. LoadMode get _refreshState => widget.linkNotifier.loadState;
  56. bool get _noMore => widget.linkNotifier.noMore;
  57. @override
  58. Widget build(BuildContext context) {
  59. return Container(
  60. height: 50,
  61. alignment:Alignment.center ,
  62. padding: const EdgeInsets.symmetric(vertical: 10.0),
  63. child: Row(
  64. mainAxisAlignment: MainAxisAlignment.center,
  65. children: <Widget>[
  66. if (!_noMore) const CupertinoActivityIndicator(),
  67. if (!_noMore)
  68. const SizedBox(
  69. width: 5,
  70. ),
  71. // 只有一页的时候,就不显示FooterView了
  72. Text(!_noMore ? '正在加载中...' : '没有了呦~',
  73. style: TextStyle(
  74. fontSize: 14, color: DarkThemeUtil.multiColors(const Color(0x8A000000), darkColor: Colors.white54))),
  75. ],
  76. ),
  77. );
  78. }
  79. }