Skip to content

Commit 3866d74

Browse files
Merge pull request #12 from ionicfirebaseapp/master
master pull
2 parents 24784ee + c677216 commit 3866d74

File tree

7 files changed

+131
-91
lines changed

7 files changed

+131
-91
lines changed

LICENSE

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
The MIT License (MIT)
2-
Copyright (c) 2020 GetFlutter.dev
2+
3+
All the components that we reused from flutter has Copyright (c) 2020 Flutter Author.
4+
5+
All the components that we developed or customized has Copyright (c) 2020 Getflutter.
6+
37
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
48
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
5-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
9+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

example/lib/main.dart

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,18 @@ import 'package:getflutter/colors/gf_color.dart';
33
import 'package:getflutter/components/button/gf_button.dart';
44
import 'package:getflutter/components/badge/gf_button_badge.dart';
55
import 'package:getflutter/components/avatar/gf_avatar.dart';
6-
import 'package:getflutter/components/badge/gf_badge.dart';
7-
// import 'package:getflutter/components/list/gf_list.dart';
86
import 'package:getflutter/components/tabs/gf_segment_tabs.dart';
9-
import 'package:getflutter/size/gf_size.dart';
107
import 'package:getflutter/types/gf_button_type.dart';
118
import 'package:getflutter/shape/gf_button_shape.dart';
12-
import 'package:getflutter/shape/gf_badge_shape.dart';
139
import 'package:flutter/cupertino.dart';
14-
import 'package:getflutter/components/tabs/gf_tabs.dart';
15-
import 'package:getflutter/components/drawer/gf_drawer.dart';
16-
import 'package:getflutter/components/drawer/gf_drawer_header.dart';
1710
import 'package:getflutter/components/toast/gf_toast.dart';
1811
import 'package:getflutter/components/appbar/gf_appbar.dart';
19-
import 'package:getflutter/components/tabs/gf_tabBarView.dart';
20-
import 'package:getflutter/components/button/gf_icon_button.dart';
21-
import 'package:getflutter/components/button/gf_social_button.dart';
22-
import 'package:getflutter/components/carousel/gf_carousel.dart';
23-
import 'package:getflutter/components/carousel/gf_items_carousel.dart';
24-
import 'package:getflutter/shape/gf_avatar_shape.dart';
2512
import 'package:getflutter/components/card/gf_card.dart';
26-
import 'package:getflutter/components/image/gf_image_overlay.dart';
2713
import 'package:getflutter/components/list_tile/gf_list_tile.dart';
28-
import 'package:getflutter/position/gf_position.dart';
2914
import 'package:getflutter/components/button/gf_button_bar.dart';
30-
import 'package:getflutter/components/badge/gf_icon_badge.dart';
31-
import 'package:getflutter/shape/gf_icon_button_shape.dart';
32-
import 'package:getflutter/components/tabs/gf_tabBar.dart';
3315
import 'package:getflutter/components/typography/gf_typography.dart';
3416
import 'package:getflutter/types/gf_typography_type.dart';
3517
import 'package:getflutter/components/toast/gf_floating_widget.dart';
36-
import 'package:getflutter/components/toggle/gf_toggle.dart';
37-
import 'package:getflutter/types/gf_toggle_type.dart';
3818

3919
final List<String> imageList = [
4020
"https://cdn.pixabay.com/photo/2017/12/03/18/04/christmas-balls-2995437_960_720.jpg",
@@ -185,12 +165,12 @@ class _MyHomePageState extends State<MyHomePage>
185165
),
186166
GFButtonBar(
187167
children: <Widget>[
188-
GFButton(),
189-
GFButton(),
190-
GFButton(),
191-
GFButton(),
192-
GFButton(),
193-
GFButton(),
168+
GFButton(
169+
onPressed: () {},
170+
),
171+
GFButton(
172+
onPressed: () {},
173+
),
194174
],
195175
),
196176
SizedBox(

lib/components/badge/gf_badge.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class GFBadge extends StatefulWidget {
3939
this.shape = GFBadgeShape.standard,
4040
this.color = GFColor.danger,
4141
this.textColor = GFColor.white,
42-
this.size = GFSize.medium,
42+
this.size = GFSize.small,
4343
this.border,
4444
this.text,
4545
this.child,

lib/components/badge/gf_icon_badge.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ class GFIconBadge extends StatefulWidget {
2727
}
2828

2929
class _GFIconBadgeState extends State<GFIconBadge> {
30-
double size;
31-
3230
@override
3331
Widget build(BuildContext context) {
3432
return Container(
@@ -37,8 +35,9 @@ class _GFIconBadgeState extends State<GFIconBadge> {
3735
children: <Widget>[
3836
widget.child ?? Container(),
3937
new Positioned(
40-
top: 2,
41-
left: 22,
38+
// top: 2,
39+
// left: 22,
40+
right: 0,
4241
child: widget.counterChild ?? Container(),
4342
),
4443
],

lib/components/button/gf_icon_button.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ class _GFIconButtonState extends State<GFIconButton> {
226226
this.width = 35.0;
227227
this.iconPixel = 18.0;
228228
} else if (widget.size == GFSize.large) {
229-
print('her');
230229
this.height = 40.0;
231230
this.width = 40.0;
232231
this.iconPixel = 18.0;

lib/components/toast/gf_toast.dart

Lines changed: 114 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
33
import 'package:flutter/widgets.dart';
44
import 'package:getflutter/colors/gf_color.dart';
55
import 'package:getflutter/components/toast/gf_floating_widget.dart';
6+
import 'package:getflutter/types/gf_toast_type.dart';
67

78
class GFToast extends StatefulWidget {
89
///Creates [GFToast] that can be used to display quick warning or error messages.
@@ -14,6 +15,11 @@ class GFToast extends StatefulWidget {
1415
this.backgroundColor,
1516
this.text,
1617
this.width,
18+
this.type = GFToastType.basic,
19+
this.autoDismiss = true,
20+
this.alignment,
21+
this.animationDuration = const Duration(seconds: 2),
22+
this.duration = const Duration(seconds: 2),
1723
this.textStyle = const TextStyle(color: Colors.white70),
1824
}) : super(key: key);
1925

@@ -32,86 +38,137 @@ class GFToast extends StatefulWidget {
3238
/// textStyle of type [textStyle] will be applicable to text only and not for the child
3339
final TextStyle textStyle;
3440

35-
/// width od type [double] used to control the width od the [GFToast]
41+
/// width of type [double] used to control the width of the [GFToast]
3642
final double width;
3743

44+
///type of [GFToastType] which takes the type ie, basic, rounded and fullWidth for the [GFToast]
45+
final GFToastType type;
46+
47+
///type of [bool] which takes bool values ie, true or false to automatically hide the [GFToast] message
48+
final bool autoDismiss;
49+
50+
///type of [Duration] which takes the duration of the fade in animation
51+
final Duration animationDuration;
52+
53+
///type of [Duration] which takes the duration of the animation
54+
final Duration duration;
55+
56+
/// type of [Alignment] used to align the text inside the toast
57+
final Alignment alignment;
58+
3859
@override
3960
_GFToastState createState() => _GFToastState();
4061
}
4162

4263
class _GFToastState extends State<GFToast> with TickerProviderStateMixin {
43-
AnimationController controller, _controller;
44-
Animation<Offset> offset, offset1;
45-
Animation<double> animation;
46-
Timer timer;
47-
48-
bool slide = false;
64+
AnimationController animationController, fadeanimationController;
65+
Animation<double> animation, fadeanimation;
66+
bool hideToast = false;
4967

5068
@override
5169
void initState() {
52-
super.initState();
70+
animationController = AnimationController(
71+
duration: const Duration(milliseconds: 2000), vsync: this);
72+
animation =
73+
CurvedAnimation(parent: animationController, curve: Curves.easeIn);
5374

54-
controller = AnimationController(
55-
duration: const Duration(milliseconds: 300), vsync: this);
56-
animation = CurvedAnimation(parent: controller, curve: Curves.easeIn);
57-
_controller =
58-
AnimationController(vsync: this, duration: Duration(milliseconds: 200));
59-
offset = Tween<Offset>(begin: Offset.zero, end: Offset(0.0, 1.0))
60-
.animate(_controller);
61-
controller.forward();
62-
_controller.forward();
75+
animationController.forward();
76+
77+
fadeanimationController = AnimationController(
78+
vsync: this,
79+
duration: widget.animationDuration,
80+
)..addListener(() => setState(() {}));
81+
fadeanimation = Tween<double>(
82+
begin: 0.0,
83+
end: 1.0,
84+
).animate(fadeanimationController);
85+
Timer(widget.duration, () {
86+
fadeanimationController.forward();
87+
});
88+
89+
fadeanimation = Tween<double>(
90+
begin: 1.0,
91+
end: 0.0,
92+
).animate(fadeanimationController);
93+
94+
fadeanimation.addStatusListener((AnimationStatus state) {
95+
if (fadeanimation.isCompleted && widget.autoDismiss) {
96+
setState(() {
97+
hideToast = true;
98+
});
99+
}
100+
});
101+
super.initState();
63102
}
64103

65104
@override
66105
void dispose() {
67-
controller.dispose();
106+
animationController.dispose();
107+
fadeanimationController.dispose();
68108
super.dispose();
69109
}
70110

71111
@override
72112
Widget build(BuildContext context) {
73-
return FadeTransition(
74-
opacity: animation,
75-
child: Column(
76-
children: <Widget>[
77-
Container(
78-
width: widget.width != null ? widget.width : null,
79-
constraints: BoxConstraints(minHeight: 50.0),
80-
// width: 100,
81-
margin: EdgeInsets.only(left: 10, right: 10),
82-
padding: EdgeInsets.all(10),
83-
decoration: BoxDecoration(
84-
borderRadius: BorderRadius.all(Radius.circular(3)),
85-
color: widget.backgroundColor != null
86-
? GFColors.getGFColor(widget.backgroundColor)
87-
: Color(0xff323232),
88-
),
89-
child: Row(
113+
return hideToast
114+
? Container()
115+
: FadeTransition(
116+
opacity: widget.autoDismiss ? fadeanimation : animation,
117+
child: Column(
90118
children: <Widget>[
91-
Flexible(
92-
flex: 7,
93-
fit: FlexFit.tight,
94-
child: widget.text != null
95-
? Text(widget.text, style: widget.textStyle)
96-
: (widget.child ?? Container()),
97-
),
98-
SizedBox(
99-
width: 10,
119+
Container(
120+
width: widget.type == GFToastType.fullWidth
121+
? MediaQuery.of(context).size.width
122+
: widget.width,
123+
constraints: BoxConstraints(minHeight: 50.0),
124+
margin: widget.type == GFToastType.fullWidth
125+
? EdgeInsets.only(left: 0, right: 0)
126+
: EdgeInsets.only(left: 10, right: 10),
127+
padding: EdgeInsets.all(10),
128+
decoration: BoxDecoration(
129+
borderRadius: widget.type == GFToastType.basic
130+
? BorderRadius.circular(0.0)
131+
: widget.type == GFToastType.rounded
132+
? BorderRadius.circular(10.0)
133+
: BorderRadius.zero,
134+
color: widget.backgroundColor != null
135+
? GFColors.getGFColor(widget.backgroundColor)
136+
: Color(0xff323232),
137+
boxShadow: [
138+
BoxShadow(
139+
color: Colors.black.withOpacity(0.40),
140+
blurRadius: 6.0)
141+
]),
142+
child: Row(
143+
children: <Widget>[
144+
Flexible(
145+
flex: 7,
146+
fit: FlexFit.tight,
147+
child: Align(
148+
alignment: widget.alignment != null
149+
? widget.alignment
150+
: Alignment.topLeft,
151+
child: widget.text != null
152+
? Text(widget.text, style: widget.textStyle)
153+
: (widget.child ?? Container()),
154+
)),
155+
SizedBox(
156+
width: 10,
157+
),
158+
widget.button != null
159+
? Flexible(
160+
flex: 4,
161+
fit: FlexFit.tight,
162+
child: Align(
163+
alignment: Alignment.topRight,
164+
child: widget.button,
165+
))
166+
: Container()
167+
],
168+
),
100169
),
101-
widget.button != null
102-
? Flexible(
103-
flex: 4,
104-
fit: FlexFit.tight,
105-
child: Align(
106-
alignment: Alignment.topRight,
107-
child: widget.button,
108-
))
109-
: Container()
110170
],
111171
),
112-
),
113-
],
114-
),
115-
);
172+
);
116173
}
117174
}

lib/types/gf_toast_type.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
enum GFToastType { basic, rounded, fullWidth }

0 commit comments

Comments
 (0)