|
1 | 1 | import 'package:custom_refresh_indicator/custom_refresh_indicator.dart'; |
2 | 2 | import 'package:example/utils/infinite_rotation.dart'; |
3 | | -import 'package:example/utils/positioned_indicator_container.dart'; |
4 | 3 | import 'package:flutter/material.dart'; |
5 | 4 |
|
6 | 5 | import 'custom_indicator.dart'; |
7 | 6 |
|
8 | | -class SimpleIndicatorContent extends StatelessWidget { |
9 | | - const SimpleIndicatorContent({ |
10 | | - Key? key, |
11 | | - required this.controller, |
12 | | - this.indicatorSize = _defaultIndicatorSize, |
13 | | - }) : assert(indicatorSize > 0), |
14 | | - super(key: key); |
15 | | - |
16 | | - final IndicatorController controller; |
17 | | - static const _defaultIndicatorSize = 40.0; |
18 | | - final double indicatorSize; |
19 | | - |
20 | | - @override |
21 | | - Widget build(BuildContext context) { |
22 | | - return Container( |
23 | | - height: indicatorSize, |
24 | | - width: indicatorSize, |
25 | | - decoration: const BoxDecoration( |
26 | | - color: Color(0xFFFFFFFF), |
27 | | - shape: BoxShape.circle, |
28 | | - boxShadow: [BoxShadow(blurRadius: 5, color: Color(0x42000000))], |
29 | | - ), |
30 | | - child: Align( |
31 | | - alignment: Alignment.center, |
32 | | - child: Stack( |
33 | | - children: <Widget>[ |
34 | | - AnimatedBuilder( |
35 | | - animation: controller, |
36 | | - child: const Icon( |
37 | | - Icons.refresh, |
38 | | - color: Colors.blueAccent, |
39 | | - size: 30, |
40 | | - ), |
41 | | - builder: (context, child) => InfiniteRatation( |
42 | | - running: controller.isLoading, |
43 | | - child: child, |
44 | | - ), |
45 | | - ), |
46 | | - ], |
47 | | - ), |
48 | | - ), |
49 | | - ); |
50 | | - } |
51 | | -} |
52 | | - |
53 | 7 | final simpleIndicator = CustomIndicatorConfig( |
54 | | - builder: (context, child, controller) => |
55 | | - LayoutBuilder(builder: (context, constraints) { |
56 | | - return Stack( |
57 | | - children: <Widget>[ |
58 | | - child, |
59 | | - PositionedIndicatorContainer( |
60 | | - constraints: constraints, |
61 | | - controller: controller, |
62 | | - child: SimpleIndicatorContent( |
63 | | - controller: controller, |
64 | | - ), |
| 8 | + builder: MaterialIndicatorDelegate( |
| 9 | + builder: (context, controller) { |
| 10 | + return InfiniteRatation( |
| 11 | + running: controller.isLoading, |
| 12 | + child: Icon( |
| 13 | + Icons.ac_unit, |
| 14 | + color: Theme.of(context).colorScheme.primary, |
| 15 | + size: 30, |
65 | 16 | ), |
66 | | - ], |
67 | | - ); |
68 | | - }), |
| 17 | + ); |
| 18 | + }, |
| 19 | + ), |
69 | 20 | ); |
70 | 21 |
|
71 | 22 | final simpleIndicatorWithOpacity = CustomIndicatorConfig( |
72 | | - builder: (context, child, controller) => |
73 | | - LayoutBuilder(builder: (context, constraints) { |
74 | | - return Stack(children: <Widget>[ |
75 | | - Opacity( |
| 23 | + builder: MaterialIndicatorDelegate( |
| 24 | + builder: (context, controller) { |
| 25 | + return InfiniteRatation( |
| 26 | + running: controller.isLoading, |
| 27 | + child: Icon( |
| 28 | + Icons.ac_unit, |
| 29 | + color: Theme.of(context).colorScheme.primary, |
| 30 | + size: 30, |
| 31 | + ), |
| 32 | + ); |
| 33 | + }, |
| 34 | + scrollableBuilder: (context, child, controller) { |
| 35 | + return Opacity( |
76 | 36 | opacity: 1.0 - controller.value.clamp(0.0, 1.0), |
77 | 37 | child: child, |
78 | | - ), |
79 | | - PositionedIndicatorContainer( |
80 | | - constraints: constraints, |
81 | | - controller: controller, |
82 | | - child: SimpleIndicatorContent(controller: controller), |
83 | | - ), |
84 | | - ]); |
85 | | - }), |
| 38 | + ); |
| 39 | + }, |
| 40 | + ), |
86 | 41 | ); |
0 commit comments