Skip to content

Commit a8d4925

Browse files
committed
toast with animations done
1 parent f5fe461 commit a8d4925

1 file changed

Lines changed: 53 additions & 41 deletions

File tree

lib/components/toast/gf_toast.dart

Lines changed: 53 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import 'dart:async';
44
import 'package:flutter/material.dart';
55
import 'package:flutter/widgets.dart';
66
import 'package:ui_kit/colors/gf_color.dart';
7+
import 'gf_floating_widget.dart';
78

89
class GFToast extends StatefulWidget {
910
///
@@ -37,10 +38,12 @@ class GFToast extends StatefulWidget {
3738

3839
class _GFToastState extends State<GFToast> with TickerProviderStateMixin {
3940
AnimationController controller, _controller;
40-
Animation<Offset> offset;
41+
Animation<Offset> offset, offset1;
4142
Animation<double> animation;
4243
Timer timer;
4344

45+
bool slide = false;
46+
4447
@override
4548
void initState() {
4649
super.initState();
@@ -55,6 +58,12 @@ class _GFToastState extends State<GFToast> with TickerProviderStateMixin {
5558
offset = Tween<Offset>(begin: Offset.zero, end: Offset(0.0, 1.0))
5659
.animate(_controller);
5760

61+
offset1 = Tween<Offset>(begin: Offset.zero, end: Offset(0.0, 0.1))
62+
.animate(_controller);
63+
64+
65+
66+
5867
controller.forward();
5968
_controller.forward();
6069
}
@@ -66,48 +75,51 @@ class _GFToastState extends State<GFToast> with TickerProviderStateMixin {
6675
super.dispose();
6776
}
6877

78+
79+
80+
6981
@override
7082
Widget build(BuildContext context) {
83+
7184
return
72-
SlideTransition(
73-
position: offset,
74-
child: FadeTransition(opacity: animation, child:
75-
ConstrainedBox(
76-
constraints: BoxConstraints(minHeight: 50.0, minWidth: 340),
77-
child: Container(
78-
margin: EdgeInsets.only(left: 10, right: 10),
79-
padding: EdgeInsets.all(10),
80-
decoration: BoxDecoration(
81-
borderRadius: BorderRadius.all(Radius.circular(3)),
82-
color: widget.backgroundColor != null
83-
? getGFColor(widget.backgroundColor)
84-
: Color(0xff323232),
85-
),
86-
child: Row(
87-
children: <Widget>[
88-
Flexible(
89-
flex: 7,
90-
fit: FlexFit.tight,
91-
child: widget.text != null
92-
? Text(widget.text, style: widget.textStyle)
93-
: (widget.child ?? Container()),
94-
),
95-
SizedBox(
96-
width: 10,
97-
),
98-
widget.button != null
99-
? Flexible(
100-
flex: 4,
101-
fit: FlexFit.tight,
102-
child: Align(
103-
alignment: Alignment.topRight,
104-
child: widget.button,
105-
))
106-
: Container()
107-
],
108-
),
109-
),
110-
)),
111-
);
85+
SlideTransition(
86+
position: offset,
87+
child: FadeTransition(opacity: animation, child:
88+
Container(
89+
constraints: BoxConstraints(minHeight: 50.0, minWidth: 340),
90+
margin: EdgeInsets.only(left: 10, right: 10),
91+
padding: EdgeInsets.all(10),
92+
decoration: BoxDecoration(
93+
borderRadius: BorderRadius.all(Radius.circular(3)),
94+
color: widget.backgroundColor != null
95+
? getGFColor(widget.backgroundColor)
96+
: Color(0xff323232),
97+
),
98+
child: Row(
99+
children: <Widget>[
100+
Flexible(
101+
flex: 7,
102+
fit: FlexFit.tight,
103+
child: widget.text != null
104+
? Text(widget.text, style: widget.textStyle)
105+
: (widget.child ?? Container()),
106+
),
107+
SizedBox(
108+
width: 10,
109+
),
110+
widget.button != null
111+
? Flexible(
112+
flex: 4,
113+
fit: FlexFit.tight,
114+
child: Align(
115+
alignment: Alignment.topRight,
116+
child: widget.button,
117+
))
118+
: Container()
119+
],
120+
),
121+
),),
122+
)
123+
;
112124
}
113125
}

0 commit comments

Comments
 (0)