loading.dart 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_easyrefresh/easy_refresh.dart';
  3. import 'package:sport/widgets/misc.dart';
  4. import 'package:sport/widgets/refresh_header.dart' as loading;
  5. class RequestLoadingWidget extends StatelessWidget {
  6. @override
  7. Widget build(BuildContext context) {
  8. return Container(
  9. height: 150.0,
  10. padding: const EdgeInsets.symmetric(vertical: 32.0),
  11. child: Center(
  12. child: loading.ClassicalHeaderWidget(
  13. refreshState: RefreshMode.refresh,
  14. pulledExtent: 90.0,
  15. refreshTriggerPullDistance: 80.0,
  16. refreshIndicatorExtent: 80.0,
  17. classicalHeader: buildClassicalHeader(),
  18. axisDirection: AxisDirection.up,
  19. noMore: false,
  20. enableInfiniteRefresh: true,
  21. ),
  22. ),
  23. );
  24. }
  25. }
  26. Widget FadeingCircleLoading(BuildContext context,
  27. {Color? backgroundColor, Function? callBack}) {
  28. return Positioned(
  29. top: 0,
  30. left: 0,
  31. right: 0,
  32. bottom: 0,
  33. child: callBack != null
  34. ? InkWell(
  35. child: Container(
  36. color: backgroundColor != null
  37. ? backgroundColor
  38. : Color.fromRGBO(255, 255, 255, 0.5),
  39. width: 100,
  40. height: 100,
  41. child: CircularProgressIndicator(),
  42. ),
  43. onTap: () {
  44. callBack();
  45. },
  46. )
  47. : Container(
  48. color: backgroundColor != null
  49. ? backgroundColor
  50. : Color.fromRGBO(255, 255, 255, 0.5),
  51. width: 100,
  52. height: 100,
  53. child: CircularProgressIndicator(),
  54. ),
  55. );
  56. }
  57. class LoadingWidget extends StatelessWidget {
  58. bool loading = false;
  59. bool willPop = true;
  60. Widget child;
  61. LoadingWidget({this.loading = false, this.willPop = true, required this.child});
  62. @override
  63. Widget build(BuildContext context) {
  64. return WillPopScope(
  65. onWillPop: () async {
  66. if(willPop == true) {
  67. bool result = !loading;
  68. return result;
  69. }
  70. return true;
  71. },
  72. child: Stack(
  73. alignment: Alignment.center,
  74. children: <Widget>[
  75. Center(child: child),
  76. Offstage(
  77. offstage: !loading,
  78. child: Container(
  79. padding: EdgeInsets.all(16.0),
  80. child: Column(
  81. mainAxisSize: MainAxisSize.min,
  82. children: <Widget>[
  83. Container(
  84. width: 100,
  85. height: 100,
  86. decoration: BoxDecoration(
  87. borderRadius: BorderRadius.all(Radius.circular(10.0)),
  88. color: Colors.black45,
  89. ),
  90. child: Padding(
  91. padding: const EdgeInsets.all(20.0),
  92. child: CircularProgressIndicator(),
  93. )
  94. ),
  95. ],
  96. )),
  97. )
  98. ],
  99. ),
  100. );
  101. }
  102. }