loading.dart 2.9 KB

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