Skip to content

Commit f5843ae

Browse files
committed
gf-loader is in proress
1 parent e7a0590 commit f5843ae

6 files changed

Lines changed: 179 additions & 23 deletions

File tree

example/lib/main.dart

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

179-
180179
SingleChildScrollView(
181180
child: Column(
182181
mainAxisAlignment: MainAxisAlignment.center,

lib/components/accordian/gf_accordian.dart

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ class GFAccordion extends StatefulWidget {
66
{Key key,
77
this.child,
88
this.content,
9-
this.collapsedTitlebackgroundColor = Colors.white,
10-
this.expandedTitlebackgroundColor= const Color(0xFFE0E0E0),
9+
this.collapsedTitlebackgroundColor = Colors.white,
10+
this.expandedTitlebackgroundColor = const Color(0xFFE0E0E0),
1111
this.collapsedIcon = const Icon(Icons.keyboard_arrow_down),
1212
this.expandedIcon = const Icon(Icons.keyboard_arrow_up),
1313
this.title,
@@ -90,6 +90,7 @@ class _GFAccordionState extends State<GFAccordion>
9090
),
9191
);
9292
}
93+
9394
@override
9495
void dispose() {
9596
animationController.dispose();
@@ -122,10 +123,11 @@ class _GFAccordionState extends State<GFAccordion>
122123
},
123124
child: Container(
124125
decoration: BoxDecoration(
125-
border: widget.titleborderColor,
126-
color: showAccordion ? widget.expandedTitlebackgroundColor: widget.collapsedTitlebackgroundColor),
127-
padding: widget.titlePadding
128-
,
126+
border: widget.titleborderColor,
127+
color: showAccordion
128+
? widget.expandedTitlebackgroundColor
129+
: widget.collapsedTitlebackgroundColor),
130+
padding: widget.titlePadding,
129131
child: Row(
130132
mainAxisAlignment: MainAxisAlignment.spaceBetween,
131133
children: <Widget>[
@@ -148,7 +150,7 @@ class _GFAccordionState extends State<GFAccordion>
148150
: Colors.white70,
149151
),
150152
width: MediaQuery.of(context).size.width,
151-
padding: widget.contentPadding ,
153+
padding: widget.contentPadding,
152154
child: SlideTransition(
153155
position: offset,
154156
child: widget.content != null

lib/components/alert/gf_alert.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,13 @@ class _GFAlertState extends State<GFAlert> with TickerProviderStateMixin {
110110
crossAxisAlignment: CrossAxisAlignment.start,
111111
children: <Widget>[
112112
Align(
113-
alignment: widget.alignment!=null? widget.alignment:Alignment.topLeft,
114-
child: widget.title != null
113+
alignment: widget.alignment != null
114+
? widget.alignment
115+
: Alignment.topLeft,
116+
child: widget.title != null
115117
? Text(widget.title, style: widget.titleTextStyle)
116118
: (widget.child ?? Container()),
117119
),
118-
119120
SizedBox(
120121
height: 10,
121122
),

lib/components/drawer/gf_drawer_header.dart

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class GFDrawerHeaderPictures extends StatelessWidget {
2828
Icons.close,
2929
color: Colors.white,
3030
),
31-
onPressed: (){
31+
onPressed: () {
3232
Navigator.pop(context);
3333
},
3434
type: GFButtonType.transparent,
@@ -80,17 +80,17 @@ class GFDrawerHeader extends StatefulWidget {
8080
/// Creates a material design drawer header.
8181
///
8282
/// Requires one of its ancestors to be a [Material] widget.
83-
const GFDrawerHeader({
84-
Key key,
85-
this.decoration,
86-
this.margin = const EdgeInsets.only(bottom: 8.0),
87-
this.currentAccountPicture,
88-
this.otherAccountsPictures,
89-
this.child,
90-
this.duration = const Duration(milliseconds: 250),
91-
this.curve = Curves.fastOutSlowIn,
92-
this.closeButton
93-
}) : super(key: key);
83+
const GFDrawerHeader(
84+
{Key key,
85+
this.decoration,
86+
this.margin = const EdgeInsets.only(bottom: 8.0),
87+
this.currentAccountPicture,
88+
this.otherAccountsPictures,
89+
this.child,
90+
this.duration = const Duration(milliseconds: 250),
91+
this.curve = Curves.fastOutSlowIn,
92+
this.closeButton})
93+
: super(key: key);
9494

9595
/// The header's background. If decoration is null then a [BoxDecoration]
9696
/// with its background color set to the current theme's primaryColor is used.
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
import 'package:flutter/material.dart';
2+
import 'dart:math';
3+
import 'package:getflutter/types/gf_loader_type.dart';
4+
5+
6+
class GFLoader extends StatefulWidget {
7+
8+
final Color dotOneColor;
9+
final Color dotTwoColor;
10+
final Color dotThreeColor;
11+
final Duration duration;
12+
final LoaderDotType dotType;
13+
final Icon dotIcon;
14+
15+
GFLoader({
16+
this.dotOneColor = Colors.redAccent,
17+
this.dotTwoColor = Colors.green,
18+
this.dotThreeColor = Colors.blueAccent,
19+
this.duration = const Duration(milliseconds: 1000),
20+
this.dotType = LoaderDotType.circle,
21+
this.dotIcon = const Icon(Icons.blur_on)
22+
});
23+
24+
@override
25+
_GFLoaderState createState() => _GFLoaderState();
26+
}
27+
28+
class _GFLoaderState extends State<GFLoader>
29+
with SingleTickerProviderStateMixin {
30+
Animation<double> animation_1;
31+
Animation<double> animation_2;
32+
Animation<double> animation_3;
33+
AnimationController controller;
34+
35+
@override
36+
void initState() {
37+
super.initState();
38+
39+
controller = AnimationController(
40+
duration: widget.duration, vsync: this);
41+
42+
animation_1 = Tween(begin: 0.0, end: 1.0).animate(
43+
CurvedAnimation(
44+
parent: controller,
45+
curve: Interval(0.0, 0.70, curve: Curves.linear),
46+
),
47+
);
48+
49+
animation_2 = Tween(begin: 0.0, end: 1.0).animate(
50+
CurvedAnimation(
51+
parent: controller,
52+
curve: Interval(0.1, 0.80, curve: Curves.linear),
53+
),
54+
);
55+
56+
animation_3 = Tween(begin: 0.0, end: 1.0).animate(
57+
CurvedAnimation(
58+
parent: controller,
59+
curve: Interval(0.2, 0.90, curve: Curves.linear),
60+
),
61+
);
62+
63+
controller.addListener(() {
64+
setState(() {
65+
//print(animation_1.value);
66+
});
67+
});
68+
69+
controller.repeat();
70+
}
71+
72+
@override
73+
Widget build(BuildContext context) {
74+
//print(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));
75+
return Container(
76+
child: new Row(
77+
mainAxisAlignment: MainAxisAlignment.center,
78+
children: <Widget>[
79+
Opacity(
80+
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)),
81+
child: new Padding(
82+
padding: const EdgeInsets.only(right: 8.0),
83+
child: Dot(
84+
radius: 10.0,
85+
color: widget.dotOneColor,
86+
type: widget.dotType,
87+
icon: widget.dotIcon,
88+
),
89+
),
90+
),
91+
Opacity(
92+
opacity: (animation_2.value <= 0.4 ? 2.5 * animation_2.value : (animation_2.value > 0.40 && animation_2.value <= 0.60)? 1.0 : 2.5 - (2.5 * animation_2.value)),
93+
child: new Padding(
94+
padding: const EdgeInsets.only(right: 8.0),
95+
child: Dot(
96+
radius: 10.0,
97+
color: widget.dotTwoColor,
98+
type: widget.dotType,
99+
icon: widget.dotIcon,
100+
),
101+
),
102+
),
103+
Opacity(
104+
opacity: (animation_3.value <= 0.4 ? 2.5 * animation_3.value : (animation_3.value > 0.40 && animation_3.value <= 0.60) ? 1.0 : 2.5 - (2.5 * animation_3.value)),
105+
child: new Padding(
106+
padding: const EdgeInsets.only(right: 8.0),
107+
child: Dot(
108+
radius: 10.0,
109+
color: widget.dotThreeColor,
110+
type: widget.dotType,
111+
icon: widget.dotIcon,
112+
),
113+
),
114+
),
115+
],
116+
),
117+
);
118+
}
119+
120+
@override
121+
void dispose() {
122+
123+
controller.dispose();
124+
super.dispose();
125+
}
126+
}
127+
128+
class Dot extends StatelessWidget {
129+
final double radius;
130+
final Color color;
131+
final LoaderDotType type;
132+
final Icon icon;
133+
134+
Dot({this.radius, this.color, this.type, this.icon});
135+
136+
@override
137+
Widget build(BuildContext context) {
138+
return new Center(
139+
child: type == LoaderDotType.icon ?
140+
Icon(icon.icon, color: color, size: 1.3 * radius,)
141+
: new Transform.rotate(
142+
angle: type == LoaderDotType.diamond ? pi/4 : 0.0,
143+
child: Container(
144+
width: radius,
145+
height: radius,
146+
decoration: BoxDecoration(color: color, shape: type == LoaderDotType.circle? BoxShape.circle : BoxShape.rectangle),
147+
),
148+
),
149+
);
150+
}
151+
}

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)