Skip to content

Commit 7186082

Browse files
committed
gf-loader in progress
1 parent 166bae6 commit 7186082

File tree

3 files changed

+102
-57
lines changed

3 files changed

+102
-57
lines changed
Lines changed: 99 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import 'dart:math';
2+
import 'package:flutter/cupertino.dart';
23
import 'package:flutter/material.dart';
34
import 'package:getflutter/types/gf_loader_type.dart';
5+
import 'package:getflutter/size/gf_size.dart';
6+
import 'package:getflutter/colors/gf_color.dart';
47

58
class GFLoader extends StatefulWidget {
69
const GFLoader(
@@ -9,16 +12,40 @@ class GFLoader extends StatefulWidget {
912
this.loaderColorTwo = Colors.green,
1013
this.loaderColorThree = Colors.blueAccent,
1114
this.duration = const Duration(milliseconds: 1000),
12-
this.loaderType = LoaderDotType.circle,
13-
this.loaderIcon = const Icon(Icons.blur_on)})
15+
this.type = GFLoaderType.android,
16+
this.loaderIconOne = const Icon(Icons.blur_on),
17+
this.loaderIconTwo,
18+
this.loaderIconThree,
19+
// this.loaderSizeOne,
20+
// this.loaderSizeTwo,
21+
// this.loaderSizeThree,
22+
this.androidLoaderColor,
23+
this.loaderSize = 15.0,
24+
this.loaderstrokeWidth= 4.0,
25+
this.size = GFSize.medium,
26+
this.child
27+
28+
29+
30+
})
1431
: super(key: key);
1532

1633
final Color loaderColorOne;
1734
final Color loaderColorTwo;
1835
final Color loaderColorThree;
1936
final Duration duration;
20-
final LoaderDotType loaderType;
21-
final Icon loaderIcon;
37+
final GFLoaderType type;
38+
final Widget loaderIconOne;
39+
// final dynamic loaderSize;
40+
// final double loaderSizeTwo;
41+
// final double loaderSizeThree;
42+
final Widget loaderIconTwo;
43+
final Widget loaderIconThree;
44+
final Animation<Color> androidLoaderColor;
45+
final dynamic loaderSize;
46+
final double loaderstrokeWidth;
47+
final dynamic size;
48+
final Widget child;
2249

2350
@override
2451
_GFLoaderState createState() => _GFLoaderState();
@@ -37,34 +64,35 @@ class _GFLoaderState extends State<GFLoader>
3764

3865
controller = AnimationController(duration: widget.duration, vsync: this);
3966

40-
animation_1 = Tween(begin: 0, end: 1.0).animate(
67+
animation_1 = Tween<double>(begin: 0, end: 1.0).animate(
4168
CurvedAnimation(
4269
parent: controller,
4370
curve: const Interval(
4471
0,
45-
0.70,
72+
0.71,
4673
curve: Curves.linear,
4774
),
4875
),
4976
);
5077

51-
animation_2 = Tween(begin: 0, end: 1.0).animate(
78+
79+
animation_2 = Tween<double>(begin: 0, end: 1.0).animate(
5280
CurvedAnimation(
5381
parent: controller,
5482
curve: const Interval(
5583
0.1,
56-
0.80,
84+
0.81,
5785
curve: Curves.linear,
5886
),
5987
),
6088
);
6189

62-
animation_3 = Tween(begin: 0, end: 1.0).animate(
90+
animation_3 = Tween<double>(begin: 0, end: 1.0).animate(
6391
CurvedAnimation(
6492
parent: controller,
6593
curve: const Interval(
6694
0.2,
67-
0.90,
95+
0.91,
6896
curve: Curves.linear,
6997
),
7098
),
@@ -81,55 +109,78 @@ class _GFLoaderState extends State<GFLoader>
81109

82110
@override
83111
Widget build(BuildContext context) => Container(
84-
child: Row(
112+
child: widget.type==GFLoaderType.android? Center(
113+
child:Container(
114+
height: GFSizesClass.getGFSize(widget.size)* 0.7,
115+
width: GFSizesClass.getGFSize(widget.size)* 0.7,
116+
child: CircularProgressIndicator(
117+
valueColor: widget.androidLoaderColor,
118+
strokeWidth: widget.loaderstrokeWidth,
119+
// value: 20,
120+
),
121+
)
122+
):widget.type==GFLoaderType.ios?Center(
123+
child: CupertinoActivityIndicator(
124+
radius: GFSizesClass.getGFSize(widget.size)* 0.4
125+
126+
),
127+
):widget.type==GFLoaderType.custom?
128+
Container(
129+
// color: Colors.amber,
130+
// height: GFSizesClass.getGFSize(widget.size)* 10,
131+
// width: GFSizesClass.getGFSize(widget.size)* 10,
132+
child: widget.child,
133+
134+
):Row(
85135
mainAxisAlignment: MainAxisAlignment.center,
86136
children: <Widget>[
87137
Opacity(
88-
opacity: animation_1.value <= 0.4
138+
opacity: animation_1.value <= 0.3
89139
? 2.5 * animation_1.value
90-
: (animation_1.value > 0.40 && animation_1.value <= 0.60)
91-
? 1.0
92-
: 2.5 - (2.5 * animation_1.value),
140+
: (animation_1.value > 0.30 && animation_1.value <= 0.70)
141+
? 1.0
142+
: 2.5 - (2.5 * animation_1.value),
93143
// opacity: (animation_1.value <= 0.4 ? 2.5 * animation_1.value : (animation_1.value > 0.40 && animation_1.value <= 0.60) ? 1.0 : 2.5 - (2.5 * animation_1.value)),
94144
child: Padding(
95145
padding: const EdgeInsets.only(right: 8),
96-
child: Dot(
97-
radius: 10,
146+
child: Loader(
147+
radius:GFSizesClass.getGFSize(widget.size)*0.3,
98148
color: widget.loaderColorOne,
99-
type: widget.loaderType,
100-
icon: widget.loaderIcon,
149+
type: widget.type,
150+
icon: widget.loaderIconOne,
101151
),
102152
),
103153
),
104154
Opacity(
105-
opacity: animation_2.value <= 0.4
155+
opacity: animation_2.value <= 0.3
106156
? 2.5 * animation_2.value
107-
: (animation_2.value > 0.40 && animation_2.value <= 0.60)
108-
? 1.0
109-
: 2.5 - (2.5 * animation_2.value),
157+
: (animation_2.value > 0.30 && animation_2.value <= 0.70)
158+
? 1.0
159+
: 2.5 - (2.5 * animation_2.value),
110160
child: Padding(
111161
padding: const EdgeInsets.only(right: 8),
112-
child: Dot(
113-
radius: 10,
162+
child: Loader(
163+
radius: GFSizesClass.getGFSize(widget.size)*0.44,
114164
color: widget.loaderColorTwo,
115-
type: widget.loaderType,
116-
icon: widget.loaderIcon,
165+
type: widget.type,
166+
icon: widget.loaderIconTwo,
117167
),
118168
),
119169
),
120170
Opacity(
121-
opacity: animation_3.value <= 0.4
171+
opacity: animation_3.value <= 0.3
122172
? 2.5 * animation_3.value
123-
: (animation_3.value > 0.40 && animation_3.value <= 0.60)
124-
? 1.0
125-
: 2.5 - (2.5 * animation_3.value),
173+
: (animation_3.value > 0.30 && animation_3.value <= 0.70)
174+
? 1.0
175+
: 2.5 - (2.5 * animation_3.value),
126176
child: Padding(
127177
padding: const EdgeInsets.only(right: 8),
128-
child: Dot(
129-
radius: 10,
178+
child: Loader(
179+
radius: GFSizesClass.getGFSize(widget.size)*0.3,
130180
color: widget.loaderColorThree,
131-
type: widget.loaderType,
132-
icon: widget.loaderIcon,
181+
type: widget.type,
182+
icon: widget.loaderIconThree
183+
,
133184
),
134185
),
135186
),
@@ -144,34 +195,26 @@ class _GFLoaderState extends State<GFLoader>
144195
}
145196
}
146197

147-
class Dot extends StatelessWidget {
148-
const Dot({Key key, this.radius, this.color, this.type, this.icon})
198+
class Loader extends StatelessWidget {
199+
const Loader({Key key, this.radius, this.color, this.type, this.icon})
149200
: super(key: key);
150201

151202
final double radius;
152203
final Color color;
153-
final LoaderDotType type;
204+
final GFLoaderType type;
154205
final Icon icon;
155206

207+
156208
@override
157209
Widget build(BuildContext context) => Center(
158-
child: type == LoaderDotType.icon
159-
? Icon(
160-
icon.icon,
161-
color: color,
162-
size: 1.3 * radius,
163-
)
164-
: Transform.rotate(
165-
angle: type == LoaderDotType.diamond ? pi / 4 : 0.0,
166-
child: Container(
167-
width: radius,
168-
height: radius,
169-
decoration: BoxDecoration(
170-
color: color,
171-
shape: type == LoaderDotType.circle
172-
? BoxShape.circle
173-
: BoxShape.rectangle),
174-
),
175-
),
210+
child:Container(
211+
width: radius,
212+
height: radius,
213+
decoration: BoxDecoration(
214+
color: color,
215+
shape: type == GFLoaderType.circle
216+
? BoxShape.circle
217+
: BoxShape.rectangle),
218+
)
176219
);
177220
}

lib/components/toast/gf_toast.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ class _GFToastState extends State<GFToast> with TickerProviderStateMixin {
7272
animation = CurvedAnimation(
7373
parent: animationController,
7474
curve: Curves.easeIn,
75+
7576
);
77+
7678
animationController.forward();
7779
fadeanimationController = AnimationController(
7880
vsync: this,

lib/types/gf_loader_type.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
enum LoaderDotType { square, circle, diamond, icon }
1+
enum GFLoaderType { android, ios, square, circle, custom ,}

0 commit comments

Comments
 (0)