Skip to content

Commit 330e258

Browse files
authored
Merge pull request #83 from shravyackm/toast
Toast
2 parents 4c61094 + 3ad8c1b commit 330e258

File tree

5 files changed

+189
-8
lines changed

5 files changed

+189
-8
lines changed

example/lib/main.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,16 @@ class _MyHomePageState extends State<MyHomePage>
176176
// Container(color: Colors.blue)
177177
// ]),
178178

179+
<<<<<<< HEAD
180+
SingleChildScrollView(
181+
child: Column(
182+
mainAxisAlignment: MainAxisAlignment.center,
183+
=======
179184
// SingleChildScrollView(
180185
// child:
181186
Column(
182187
mainAxisAlignment: MainAxisAlignment.start,
188+
>>>>>>> ccc97fde38d7e90bca8ef572ba85c4254a92c687
183189
crossAxisAlignment: CrossAxisAlignment.center,
184190
children: <Widget>[
185191
GFSearchBar(

lib/components/accordian/gf_accordian.dart

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,7 @@ class _GFAccordionState extends State<GFAccordion>
107107

108108
@override
109109
Widget build(BuildContext context) => Container(
110-
margin:
111-
widget.margin != null ? widget.margin : const EdgeInsets.all(10),
110+
margin: widget.margin ?? const EdgeInsets.all(10),
112111
child: Column(
113112
crossAxisAlignment: CrossAxisAlignment.start,
114113
children: <Widget>[
@@ -152,9 +151,7 @@ class _GFAccordionState extends State<GFAccordion>
152151
? Container(
153152
decoration: BoxDecoration(
154153
border: widget.contentBorderColor,
155-
color: widget.contentbackgroundColor != null
156-
? widget.contentbackgroundColor
157-
: Colors.white70,
154+
color: widget.contentbackgroundColor ?? Colors.white70,
158155
),
159156
width: MediaQuery.of(context).size.width,
160157
padding: widget.contentPadding,

lib/components/alert/gf_alert.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,7 @@ class _GFAlertState extends State<GFAlert> with TickerProviderStateMixin {
110110
: GFColors.getGFColor(GFColor.white),
111111
boxShadow: [
112112
BoxShadow(
113-
color: Colors.black.withOpacity(0.40),
114-
blurRadius: 3,
115-
)
113+
color: Colors.black.withOpacity(0.40), blurRadius: 3)
116114
]),
117115
child: Column(
118116
crossAxisAlignment: CrossAxisAlignment.start,
Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
import 'dart:math';
2+
import 'package:flutter/material.dart';
3+
import 'package:getflutter/types/gf_loader_type.dart';
4+
5+
class GFLoader extends StatefulWidget {
6+
const GFLoader(
7+
{Key key,
8+
this.loaderColorOne = Colors.redAccent,
9+
this.loaderColorTwo = Colors.green,
10+
this.loaderColorThree = Colors.blueAccent,
11+
this.duration = const Duration(milliseconds: 1000),
12+
this.loaderType = LoaderDotType.circle,
13+
this.loaderIcon = const Icon(Icons.blur_on)})
14+
: super(key: key);
15+
16+
final Color loaderColorOne;
17+
final Color loaderColorTwo;
18+
final Color loaderColorThree;
19+
final Duration duration;
20+
final LoaderDotType loaderType;
21+
final Icon loaderIcon;
22+
23+
@override
24+
_GFLoaderState createState() => _GFLoaderState();
25+
}
26+
27+
class _GFLoaderState extends State<GFLoader>
28+
with SingleTickerProviderStateMixin {
29+
Animation<double> animation_1;
30+
Animation<double> animation_2;
31+
Animation<double> animation_3;
32+
AnimationController controller;
33+
34+
@override
35+
void initState() {
36+
super.initState();
37+
38+
controller = AnimationController(duration: widget.duration, vsync: this);
39+
40+
animation_1 = Tween(begin: 0, end: 1.0).animate(
41+
CurvedAnimation(
42+
parent: controller,
43+
curve: const Interval(
44+
0,
45+
0.70,
46+
curve: Curves.linear,
47+
),
48+
),
49+
);
50+
51+
animation_2 = Tween(begin: 0, end: 1.0).animate(
52+
CurvedAnimation(
53+
parent: controller,
54+
curve: const Interval(
55+
0.1,
56+
0.80,
57+
curve: Curves.linear,
58+
),
59+
),
60+
);
61+
62+
animation_3 = Tween(begin: 0, end: 1.0).animate(
63+
CurvedAnimation(
64+
parent: controller,
65+
curve: const Interval(
66+
0.2,
67+
0.90,
68+
curve: Curves.linear,
69+
),
70+
),
71+
);
72+
73+
controller.addListener(() {
74+
setState(() {
75+
//print(animation_1.value);
76+
});
77+
});
78+
79+
controller.repeat();
80+
}
81+
82+
@override
83+
Widget build(BuildContext context) => Container(
84+
child: Row(
85+
mainAxisAlignment: MainAxisAlignment.center,
86+
children: <Widget>[
87+
Opacity(
88+
opacity: animation_1.value <= 0.4
89+
? 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),
93+
// 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)),
94+
child: Padding(
95+
padding: const EdgeInsets.only(right: 8),
96+
child: Dot(
97+
radius: 10,
98+
color: widget.loaderColorOne,
99+
type: widget.loaderType,
100+
icon: widget.loaderIcon,
101+
),
102+
),
103+
),
104+
Opacity(
105+
opacity: animation_2.value <= 0.4
106+
? 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),
110+
child: Padding(
111+
padding: const EdgeInsets.only(right: 8),
112+
child: Dot(
113+
radius: 10,
114+
color: widget.loaderColorTwo,
115+
type: widget.loaderType,
116+
icon: widget.loaderIcon,
117+
),
118+
),
119+
),
120+
Opacity(
121+
opacity: animation_3.value <= 0.4
122+
? 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),
126+
child: Padding(
127+
padding: const EdgeInsets.only(right: 8),
128+
child: Dot(
129+
radius: 10,
130+
color: widget.loaderColorThree,
131+
type: widget.loaderType,
132+
icon: widget.loaderIcon,
133+
),
134+
),
135+
),
136+
],
137+
),
138+
);
139+
140+
@override
141+
void dispose() {
142+
controller.dispose();
143+
super.dispose();
144+
}
145+
}
146+
147+
class Dot extends StatelessWidget {
148+
const Dot({Key key, this.radius, this.color, this.type, this.icon})
149+
: super(key: key);
150+
151+
final double radius;
152+
final Color color;
153+
final LoaderDotType type;
154+
final Icon icon;
155+
156+
@override
157+
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+
),
176+
);
177+
}

lib/types/gf_loader_type.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
enum LoaderDotType {
2+
square, circle, diamond, icon
3+
}

0 commit comments

Comments
 (0)