Skip to content

Commit 8f2c27c

Browse files
add loading
1 parent fd15f59 commit 8f2c27c

File tree

100 files changed

+4512
-540
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+4512
-540
lines changed

README.md

Lines changed: 16 additions & 387 deletions

img/loading.gif

1.33 MB

m_loading_sample/README.md

Lines changed: 23 additions & 13 deletions
8.94 KB
19 KB
10.8 KB
17.3 KB
21.4 KB
31.7 KB
35.1 KB
18.1 KB
11.4 KB
5.52 KB
16.9 KB
6.22 KB
21.8 KB
8.34 KB
9.67 KB
9.52 KB
7.56 KB
14 KB
12.8 KB
18.8 KB
77.2 KB
14.7 KB
21.5 KB
5.94 KB

m_loading_sample/img/RingRotate.gif

18.1 KB
9.81 KB
20.8 KB
21.4 KB
10.2 KB
22.7 KB
22.5 KB
20.4 KB

m_loading_sample/img/WaterRipple.gif

63.8 KB

m_loading_sample/lib/main.dart

Lines changed: 97 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:flutter/material.dart';
2+
import 'package:m_loading/m_loading.dart';
23

34
void main() {
45
runApp(MyApp());
@@ -11,107 +12,130 @@ class MyApp extends StatelessWidget {
1112
return MaterialApp(
1213
title: 'Flutter Demo',
1314
theme: ThemeData(
14-
// This is the theme of your application.
15-
//
16-
// Try running your application with "flutter run". You'll see the
17-
// application has a blue toolbar. Then, without quitting the app, try
18-
// changing the primarySwatch below to Colors.green and then invoke
19-
// "hot reload" (press "r" in the console where you ran "flutter run",
20-
// or simply save your changes to "hot reload" in a Flutter IDE).
21-
// Notice that the counter didn't reset back to zero; the application
22-
// is not restarted.
2315
primarySwatch: Colors.blue,
24-
// This makes the visual density adapt to the platform that you run
25-
// the app on. For desktop platforms, the controls will be smaller and
26-
// closer together (more dense) than on mobile platforms.
2716
visualDensity: VisualDensity.adaptivePlatformDensity,
2817
),
29-
home: MyHomePage(title: 'Flutter Demo Home Page'),
18+
home: MyHomePage(title: 'MLoading Demo'),
3019
);
3120
}
3221
}
3322

3423
class MyHomePage extends StatefulWidget {
3524
MyHomePage({Key key, this.title}) : super(key: key);
3625

37-
// This widget is the home page of your application. It is stateful, meaning
38-
// that it has a State object (defined below) that contains fields that affect
39-
// how it looks.
40-
41-
// This class is the configuration for the state. It holds the values (in this
42-
// case the title) provided by the parent (in this case the App widget) and
43-
// used by the build method of the State. Fields in a Widget subclass are
44-
// always marked "final".
45-
4626
final String title;
4727

4828
@override
4929
_MyHomePageState createState() => _MyHomePageState();
5030
}
5131

5232
class _MyHomePageState extends State<MyHomePage> {
53-
int _counter = 0;
5433

55-
void _incrementCounter() {
56-
setState(() {
57-
// This call to setState tells the Flutter framework that something has
58-
// changed in this State, which causes it to rerun the build method below
59-
// so that the display can reflect the updated values. If we changed
60-
// _counter without calling setState(), then the build method would not be
61-
// called again, and so nothing would appear to happen.
62-
_counter++;
63-
});
64-
}
6534

6635
@override
6736
Widget build(BuildContext context) {
68-
// This method is rerun every time setState is called, for instance as done
69-
// by the _incrementCounter method above.
70-
//
71-
// The Flutter framework has been optimized to make rerunning build methods
72-
// fast, so that you can just rebuild anything that needs updating rather
73-
// than having to individually change instances of widgets.
37+
Color _color =Theme.of(context).primaryColor;
38+
Duration _duration = Duration(seconds: 10);
39+
Curve _curve = Curves.bounceIn;
40+
41+
BallStyle _ballStyle=BallStyle(
42+
color: _color,
43+
);
44+
7445
return Scaffold(
7546
appBar: AppBar(
76-
// Here we take the value from the MyHomePage object that was created by
77-
// the App.build method, and use it to set our appbar title.
7847
title: Text(widget.title),
7948
),
80-
body: Center(
81-
// Center is a layout widget. It takes a single child and positions it
82-
// in the middle of the parent.
83-
child: Column(
84-
// Column is also a layout widget. It takes a list of children and
85-
// arranges them vertically. By default, it sizes itself to fit its
86-
// children horizontally, and tries to be as tall as its parent.
87-
//
88-
// Invoke "debug painting" (press "p" in the console, choose the
89-
// "Toggle Debug Paint" action from the Flutter Inspector in Android
90-
// Studio, or the "Toggle Debug Paint" command in Visual Studio Code)
91-
// to see the wireframe for each widget.
92-
//
93-
// Column has various properties to control how it sizes itself and
94-
// how it positions its children. Here we use mainAxisAlignment to
95-
// center the children vertically; the main axis here is the vertical
96-
// axis because Columns are vertical (the cross axis would be
97-
// horizontal).
98-
mainAxisAlignment: MainAxisAlignment.center,
99-
children: <Widget>[
100-
Text(
101-
'You have pushed the button this many times:',
102-
),
103-
Text(
104-
'$_counter',
105-
style: Theme.of(context).textTheme.headline4,
49+
// backgroundColor: Color(0xFFBBDEFB),
50+
body: GridView(
51+
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
52+
crossAxisCount: 4,
53+
),
54+
children: [
55+
_item(BallPulseLoading(ballStyle: _ballStyle,)),
56+
_item(Ball4ScaleLoading(ballStyle: _ballStyle,)),
57+
_item(BallGridPulseLoading(ballStyle: _ballStyle,)),
58+
_item(BallCirclePulseLoading(ballStyle: _ballStyle,)),
59+
_item(Ball3OpacityLoading(ballStyle: _ballStyle,)),
60+
_item(Ball4OpacityLoading(ballStyle: _ballStyle,)),
61+
_item(BallGridOpacityLoading(ballStyle: _ballStyle,)),
62+
_item(BallCircleRotateLoading(ballStyle: _ballStyle,)),
63+
_item(BallBounceLoading(ballStyle: _ballStyle,)),
64+
_item(BallRotateScaleLoading(ballStyle: _ballStyle,)),
65+
_item(Ball2TrianglePathLoading(ballStyle: _ballStyle,), width: 40, height: 40),
66+
_item(BallCircleOpacityLoading(ballStyle: _ballStyle,), width: 40, height: 40),
67+
_item(Ball3TrianglePathLoading(ballStyle: _ballStyle,)),
68+
_item(BallInsideBallLoading(ballStyle: _ballStyle,backgroundColor: _color.withOpacity(0.3),), width: 40, height: 40),
69+
_item(BallClipRotatePulseLoading(ballStyle: _ballStyle,ringColor: _color,), width: 40, height: 40),
70+
71+
_item(BallCircleInsideRotateLoading(ballStyle: _ballStyle,), width: 40, height: 40),
72+
73+
_item(RingRotate(color: _color,), width: 40, height: 40),
74+
_item(Ring2InsideLoading(color: _color,), width: 40, height: 40),
75+
_item(Ring2SymmetryLoading(color: _color,), width: 40, height: 40),
76+
_item(RingBallRotateLoading(ballColor: _color,circleColor: _color.withOpacity(0.3),), width: 40, height: 40),
77+
_item(RingClipRotateMultiple(innerColor: _color,outerColor: _color,), width: 40, height: 40),
78+
_item(WaterCircleLoading(color: _color,)),
79+
_item(Water2CircleLoading(color: _color,)),
80+
_item(WaterRipple(color: _color,)),
81+
_item(WaterMultipleCircleLoading(color: _color,)),
82+
_item(WaterPulseLoading(color: _color,)),
83+
_item(BarPulseLoading(color: _color,), width: 40, height: 40),
84+
_item(BarScaleLoading(color: _color,), width: 40, height: 40),
85+
_item(BarScale1Loading(color: _color,), width: 40, height: 40),
86+
_item(BarScalePulseOutLoading(color: _color,), width: 40, height: 40),
87+
_item(BarMusicLoading(color: _color,), width: 26, height: 40),
88+
// _item(Square4RotateLoading(color: _color,)),
89+
_item(Square4OpacityLoading(color: _color,), width: 40, height: 40),
90+
_item(SquareFadingLoading(color: _color,), width: 40, height: 40),
91+
_item(SquareRotateLoading(color: _color,), width: 40, height: 40),
92+
_item(SquareGridScaleLoading(color: _color,)),
93+
_item(CircleRotateLoading(color: _color,), width: 40, height: 40),
94+
_item(CirclePulseLoading(color: _color,), width: 40, height: 40),
95+
_item(
96+
CircleSquareLoading(
97+
size: 30,
98+
color: _color,
99+
),
100+
width: 30,
101+
height: 30),
102+
_item(Circle2InsideScaleLoading(smallCircleColor: _color,), width: 40, height: 40),
103+
_item(PouringHourGlassLoading(color: _color,), width: 30, height: 40),
104+
_item(PacmanLoading(mouthColor: _color,ballColor: _color,), width: 80, height: 40),
105+
],
106+
),
107+
);
108+
}
109+
110+
_item(
111+
Widget loading, {
112+
double width = 60,
113+
double height = 60,
114+
}) {
115+
return GestureDetector(
116+
behavior: HitTestBehavior.opaque,
117+
onTap: () {
118+
Navigator.of(context)
119+
.push(MaterialPageRoute(builder: (BuildContext context) {
120+
return Scaffold(
121+
appBar: AppBar(),
122+
body: Center(
123+
child: Container(
124+
height: height,
125+
width: width,
126+
child: loading,
127+
),
106128
),
107-
],
129+
);
130+
}));
131+
},
132+
child: Center(
133+
child: Container(
134+
height: height,
135+
width: width,
136+
child: loading,
108137
),
109138
),
110-
floatingActionButton: FloatingActionButton(
111-
onPressed: _incrementCounter,
112-
tooltip: 'Increment',
113-
child: Icon(Icons.add),
114-
), // This trailing comma makes auto-formatting nicer for build methods.
115139
);
116140
}
117141
}
Lines changed: 58 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,60 @@
1+
12
library m_loading;
23

3-
/// A Calculator.
4-
class Calculator {
5-
/// Returns [value] plus 1.
6-
int addOne(int value) => value + 1;
7-
}
4+
export './src/ball/ball.dart';
5+
export './src/ball/ball_style.dart';
6+
export './src/ball/ball_pulse_loading.dart';
7+
export './src/ball/ball_grid_pulse_loading.dart';
8+
export './src/ball/ball_circle_pulse_loading.dart';
9+
export './src/ball/ball_inside_ball_loading.dart';
10+
export './src/ball/ball_bounce_loading.dart';
11+
export './src/ball/ball_3_opacity.dart';
12+
export './src/ball/ball_grid_opacity.dart';
13+
export './src/ball/ball_rotate_scale.dart';
14+
export './src/ball/ball_2_triangle_path.dart';
15+
export './src/ball/ball_3_triangle_path.dart';
16+
export './src/ball/ball_4_opacity.dart';
17+
export './src/ball/ball_4_scale.dart';
18+
export './src/ball/ball_circle_rotate.dart';
19+
export './src/ball/ball_circle_opacity.dart';
20+
export './src/ball/ball_clip_rotate_pulse.dart';
21+
export './src/ball/ball_circle_inside_rotate.dart';
22+
23+
24+
export './src/ring/ring_rotate.dart';
25+
export './src/ring/ring_2_inside.dart';
26+
export './src/ring/ring_2_symmetry.dart';
27+
export './src/ring/ring_ball_rotate.dart';
28+
export './src/ring/ring_clip_rotate_multiple.dart';
29+
30+
31+
export './src/water/water_ripple.dart';
32+
export './src/water/water_circle.dart';
33+
export './src/water/water_2_circle.dart';
34+
export './src/water/water_multiple_circle.dart';
35+
export './src/water/water_pulse.dart';
36+
37+
38+
export './src/bar/bar_pulse_loading.dart';
39+
export './src/bar/bar_scale.dart';
40+
export './src/bar/bar_scale_1.dart';
41+
export './src/bar/bar_scale_pulse_out.dart';
42+
export './src/bar/bar_music.dart';
43+
44+
45+
export './src/pacman/pacman_loading.dart';
46+
47+
export './src/square/square_4_opacity.dart';
48+
export './src/square/square_rotate.dart';
49+
export './src/square/square_grid_scale_loading.dart';
50+
export './src/square/square_4_fading.dart';
51+
export './src/square/square_4_rotate.dart';
52+
53+
54+
export './src/circle/circle_rotate.dart';
55+
export './src/circle/circle_2_inside_scale.dart';
56+
export './src/circle/circle_pulse.dart';
57+
export './src/circle/circle_square.dart';
58+
59+
60+
export './src/custom/pouring_hour_glass.dart';
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import 'package:flutter/material.dart';
2+
import '../common/broken_line_curve.dart';
3+
///
4+
/// desc:
5+
///
6+
class AnimatedDelayBuilder extends StatefulWidget {
7+
final Duration duration;
8+
final int animationCount;
9+
final double begin;
10+
final double end;
11+
final Curve curve;
12+
final double delay;
13+
final AnimatedDelayItemBuilder itemBuilder;
14+
15+
const AnimatedDelayBuilder({
16+
Key key,
17+
this.duration = const Duration(milliseconds: 800),
18+
this.animationCount = 3,
19+
this.begin = 1.0,
20+
this.end = 0.0,
21+
this.curve = Curves.linear,
22+
this.delay = 0.2,
23+
@required this.itemBuilder,
24+
}) : super(key: key);
25+
26+
@override
27+
_AnimatedDelayBuilderState createState() => _AnimatedDelayBuilderState();
28+
}
29+
30+
class _AnimatedDelayBuilderState extends State<AnimatedDelayBuilder>
31+
with SingleTickerProviderStateMixin {
32+
AnimationController _controller;
33+
List<Animation> _animations = [];
34+
35+
@override
36+
void initState() {
37+
_controller = AnimationController(vsync: this, duration: widget.duration)
38+
..repeat();
39+
40+
List.generate(widget.animationCount, (index) {
41+
_animations.add(
42+
Tween(begin: widget.begin, end: widget.end).animate(CurvedAnimation(
43+
parent: _controller,
44+
curve: Interval(
45+
0.0 + index * widget.delay,
46+
1 -
47+
(widget.animationCount - 1) * widget.delay +
48+
index * widget.delay,
49+
curve: BrokenLineCurve()),
50+
)));
51+
});
52+
super.initState();
53+
}
54+
55+
@override
56+
void dispose() {
57+
_controller.dispose();
58+
super.dispose();
59+
}
60+
61+
@override
62+
Widget build(BuildContext context) {
63+
return widget.itemBuilder(context, _animations);
64+
}
65+
}
66+
67+
typedef AnimatedDelayItemBuilder = Function(
68+
BuildContext context, List<Animation> animations);

0 commit comments

Comments
 (0)