Skip to content

Commit f5fe461

Browse files
committed
slideTransition is in completed in gf_toast
1 parent 5fb915c commit f5fe461

4 files changed

Lines changed: 170 additions & 142 deletions

File tree

example/lib/main.dart

Lines changed: 117 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class _MyHomePageState extends State<MyHomePage> {
8686
title: Text(widget.title),
8787
),
8888
body: GFFloatingWidget(
89-
// horizontalPosition: screenWidth * 0.9,
89+
// horizontalPosition: screenHeight* 0.8,
9090
child: showToast? GFToast(
9191
text: 'xfcgvhjk',
9292

@@ -191,36 +191,36 @@ class _MyHomePageState extends State<MyHomePage> {
191191
)
192192
),
193193

194-
GFSlider(
195-
// pagerSize: 12.0,
196-
// activeIndicator: Colors.pink,
197-
// passiveIndicator: Colors.pink.withOpacity(0.4),
198-
viewportFraction: 0.9,
199-
aspectRatio: 2.0,
200-
// autoPlay: true,
201-
enlargeMainPage: true,
202-
pagination: true,
203-
items: imageList.map(
204-
(url) {
205-
return Container(
206-
margin: EdgeInsets.all(5.0),
207-
child: ClipRRect(
208-
borderRadius: BorderRadius.all(Radius.circular(5.0)),
209-
child: Image.network(
210-
url,
211-
fit: BoxFit.cover,
212-
width: 1000.0,
213-
),
214-
),
215-
);
216-
},
217-
).toList(),
218-
onPageChanged: (index) {
219-
setState(() {
220-
index;
221-
});
222-
},
223-
),
194+
// GFSlider(
195+
//// pagerSize: 12.0,
196+
//// activeIndicator: Colors.pink,
197+
//// passiveIndicator: Colors.pink.withOpacity(0.4),
198+
// viewportFraction: 0.9,
199+
// aspectRatio: 2.0,
200+
//// autoPlay: true,
201+
// enlargeMainPage: true,
202+
// pagination: true,
203+
// items: imageList.map(
204+
// (url) {
205+
// return Container(
206+
// margin: EdgeInsets.all(5.0),
207+
// child: ClipRRect(
208+
// borderRadius: BorderRadius.all(Radius.circular(5.0)),
209+
// child: Image.network(
210+
// url,
211+
// fit: BoxFit.cover,
212+
// width: 1000.0,
213+
// ),
214+
// ),
215+
// );
216+
// },
217+
// ).toList(),
218+
// onPageChanged: (index) {
219+
// setState(() {
220+
// index;
221+
// });
222+
// },
223+
// ),
224224

225225
GFButton(onPressed: (){
226226
setState(() {
@@ -247,6 +247,21 @@ class _MyHomePageState extends State<MyHomePage> {
247247
// ),
248248
),
249249

250+
GFButton(
251+
color: Colors.orange,
252+
onPressed: null,
253+
child: Text("share"),
254+
type: GFType.outline,
255+
shape: GFShape.pills,
256+
// buttonBoxShadow: true,
257+
// boxShadow: BoxShadow(
258+
// color: Colors.pink,
259+
// blurRadius: 1.5,
260+
// spreadRadius: 2.0,
261+
// offset: Offset.zero,
262+
// ),
263+
),
264+
250265
GFTabs(
251266
initialIndex: 0,
252267
length: 3,
@@ -298,77 +313,77 @@ class _MyHomePageState extends State<MyHomePage> {
298313
],
299314
),
300315
),
301-
GFCard(
302-
boxFit: BoxFit.cover,
303-
colorFilter: new ColorFilter.mode(
304-
Colors.black.withOpacity(0.67), BlendMode.darken),
305-
image: Image.asset("lib/assets/food.jpeg"),
306-
// imageOverlay: AssetImage("lib/assets/food.jpeg"),
307-
titlePosition: GFPosition.end,
308-
title: GFListTile(
309-
avatar: GFAvatar(
310-
child: Text("tb"),
311-
),
312-
title: Text(
313-
'title',
314-
style: TextStyle(color: Colors.grey),
315-
),
316-
subTitle: Text(
317-
'subtitle',
318-
style: TextStyle(color: Colors.grey),
319-
),
320-
icon: GFIconButton(
321-
onPressed: null,
322-
icon: Icon(Icons.favorite_border),
323-
type: GFType.transparent,
324-
),
325-
),
326-
content: Text(
327-
"Flutter "
328-
"Flutter is Google's mobile UI framework for crafting"
329-
" high-quality native interfaces on iOS and Android in "
330-
"Flutter ",
331-
style: TextStyle(color: Colors.grey),
332-
),
333-
buttonBar: GFButtonBar(
334-
mainAxisSize: MainAxisSize.min,
335-
children: <Widget>[
336-
GFButton(
337-
onPressed: null,
338-
child: Text("favorite"),
339-
icon: Icon(Icons.favorite_border),
340-
type: GFType.transparent,
341-
),
342-
GFButton(
343-
onPressed: null,
344-
child: Text("share"),
345-
icon: Icon(Icons.share),
346-
type: GFType.outline,
347-
),
348-
],
349-
),
350-
),
351-
GFButtonBar(
352-
mainAxisSize: MainAxisSize.min,
353-
children: <Widget>[
354-
GFButton(
355-
onPressed: null,
356-
child: Text("like"),
357-
icon: Icon(Icons.favorite_border),
358-
type: GFType.transparent,
359-
),
360-
GFButton(
361-
onPressed: null,
362-
child: Text("comment"),
363-
),
364-
GFButton(
365-
onPressed: null,
366-
child: Text("share"),
367-
icon: Icon(Icons.share),
368-
type: GFType.outline,
369-
),
370-
],
371-
),
316+
// GFCard(
317+
// boxFit: BoxFit.cover,
318+
// colorFilter: new ColorFilter.mode(
319+
// Colors.black.withOpacity(0.67), BlendMode.darken),
320+
// image: Image.asset("lib/assets/food.jpeg"),
321+
//// imageOverlay: AssetImage("lib/assets/food.jpeg"),
322+
// titlePosition: GFPosition.end,
323+
// title: GFListTile(
324+
// avatar: GFAvatar(
325+
// child: Text("tb"),
326+
// ),
327+
// title: Text(
328+
// 'title',
329+
// style: TextStyle(color: Colors.grey),
330+
// ),
331+
// subTitle: Text(
332+
// 'subtitle',
333+
// style: TextStyle(color: Colors.grey),
334+
// ),
335+
// icon: GFIconButton(
336+
// onPressed: null,
337+
// icon: Icon(Icons.favorite_border),
338+
// type: GFType.transparent,
339+
// ),
340+
// ),
341+
// content: Text(
342+
// "Flutter "
343+
// "Flutter is Google's mobile UI framework for crafting"
344+
// " high-quality native interfaces on iOS and Android in "
345+
// "Flutter ",
346+
// style: TextStyle(color: Colors.grey),
347+
// ),
348+
// buttonBar: GFButtonBar(
349+
// mainAxisSize: MainAxisSize.min,
350+
// children: <Widget>[
351+
// GFButton(
352+
// onPressed: null,
353+
// child: Text("favorite"),
354+
// icon: Icon(Icons.favorite_border),
355+
// type: GFType.transparent,
356+
// ),
357+
// GFButton(
358+
// onPressed: null,
359+
// child: Text("share"),
360+
// icon: Icon(Icons.share),
361+
// type: GFType.outline,
362+
// ),
363+
// ],
364+
// ),
365+
// ),
366+
// GFButtonBar(
367+
// mainAxisSize: MainAxisSize.min,
368+
// children: <Widget>[
369+
// GFButton(
370+
// onPressed: null,
371+
// child: Text("like"),
372+
// icon: Icon(Icons.favorite_border),
373+
// type: GFType.transparent,
374+
// ),
375+
// GFButton(
376+
// onPressed: null,
377+
// child: Text("comment"),
378+
// ),
379+
// GFButton(
380+
// onPressed: null,
381+
// child: Text("share"),
382+
// icon: Icon(Icons.share),
383+
// type: GFType.outline,
384+
// ),
385+
// ],
386+
// ),
372387
],
373388
),
374389
),

lib/components/toast/gf_floating_widget.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class _GFFloatingWidgetState extends State<GFFloatingWidget> {
3232
return Stack(
3333
children: <Widget>[
3434
Container(
35+
height: MediaQuery.of(context).size.height,
3536
child: widget.body ?? Container(),
3637
),
3738
Positioned(

lib/components/toast/gf_toast.dart

Lines changed: 51 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'dart:async';
22

3+
34
import 'package:flutter/material.dart';
45
import 'package:flutter/widgets.dart';
56
import 'package:ui_kit/colors/gf_color.dart';
@@ -34,22 +35,28 @@ class GFToast extends StatefulWidget {
3435
_GFToastState createState() => _GFToastState();
3536
}
3637

37-
class _GFToastState extends State<GFToast> with SingleTickerProviderStateMixin {
38-
AnimationController controller;
38+
class _GFToastState extends State<GFToast> with TickerProviderStateMixin {
39+
AnimationController controller, _controller;
3940
Animation<Offset> offset;
41+
Animation<double> animation;
4042
Timer timer;
4143

4244
@override
4345
void initState() {
4446
super.initState();
4547

46-
controller =
47-
AnimationController(vsync: this, duration: Duration(milliseconds: 500));
48+
controller = AnimationController(
49+
duration: const Duration(milliseconds: 300), vsync: this);
50+
animation = CurvedAnimation(parent: controller, curve: Curves.easeIn);
51+
52+
_controller =
53+
AnimationController(vsync: this, duration: Duration(milliseconds: 200));
4854

49-
offset = Tween<Offset>(begin: Offset.zero, end: Offset(0.0, 0.1))
50-
.animate(controller);
55+
offset = Tween<Offset>(begin: Offset.zero, end: Offset(0.0, 1.0))
56+
.animate(_controller);
5157

5258
controller.forward();
59+
_controller.forward();
5360
}
5461

5562

@@ -61,42 +68,46 @@ class _GFToastState extends State<GFToast> with SingleTickerProviderStateMixin {
6168

6269
@override
6370
Widget build(BuildContext context) {
64-
return SlideTransition(position: offset, child:
71+
return
72+
SlideTransition(
73+
position: offset,
74+
child: FadeTransition(opacity: animation, child:
6575
ConstrainedBox(
66-
constraints: BoxConstraints(minHeight: 50.0, minWidth: 340),
67-
child: Container(
68-
margin: EdgeInsets.only(left: 10, right: 10),
69-
padding: EdgeInsets.all(10),
70-
decoration: BoxDecoration(
71-
borderRadius: BorderRadius.all(Radius.circular(3)),
72-
color: widget.backgroundColor != null
73-
? getGFColor(widget.backgroundColor)
74-
: Color(0xff323232),
75-
),
76-
child: Row(
77-
children: <Widget>[
78-
Flexible(
79-
flex: 7,
80-
fit: FlexFit.tight,
81-
child: widget.text != null
82-
? Text(widget.text, style: widget.textStyle)
83-
: (widget.child ?? Container()),
84-
),
85-
SizedBox(
86-
width: 10,
87-
),
88-
widget.button != null
89-
? Flexible(
90-
flex: 4,
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,
9190
fit: FlexFit.tight,
92-
child: Align(
93-
alignment: Alignment.topRight,
94-
child: widget.button,
95-
))
96-
: Container()
97-
],
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+
),
98109
),
99-
),
100-
));
110+
)),
111+
);
101112
}
102113
}

lib/components/toggle/gf_toggle.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ class _GFToggleState extends State<GFToggle> with TickerProviderStateMixin {
8787
void dispose() {
8888
animationController.dispose();
8989
super.dispose();
90+
controller.dispose();
9091
}
9192

9293
@override

0 commit comments

Comments
 (0)