Skip to content

Commit 72a2cab

Browse files
committed
gf-accordion done
1 parent 0b80cda commit 72a2cab

File tree

5 files changed

+227
-43
lines changed

5 files changed

+227
-43
lines changed

example/lib/main.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import 'package:flutter/material.dart';
22
import 'package:getflutter/getflutter.dart';
3-
import 'package:getflutter/components/search_bar/gf_search_bar.dart';
43

54
final List<String> imageList = [
65
"https://cdn.pixabay.com/photo/2017/12/03/18/04/christmas-balls-2995437_960_720.jpg",
@@ -799,7 +798,7 @@ class _MyHomePageState extends State<MyHomePage>
799798
).toList(),
800799
onPageChanged: (index) {
801800
setState(() {
802-
index;
801+
803802
});
804803
},
805804
),

lib/components/accordian/gf_accordian.dart

Lines changed: 36 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,66 @@
11
import 'package:flutter/material.dart';
22
import 'package:getflutter/colors/gf_color.dart';
33

4-
class GFAccordian extends StatefulWidget {
5-
const GFAccordian(
4+
class GFAccordion extends StatefulWidget {
5+
6+
const GFAccordion(
67
{Key key,
78
this.child,
8-
this.description,
9+
this.content,
910
this.titlebackgroundColor,
1011
this.collapsedIcon = const Icon(Icons.keyboard_arrow_down),
11-
this.expandedIcon = const Icon(Icons.keyboard_arrow_up),
12-
this.text,
12+
this.expandedIcon =
13+
const Icon(Icons.keyboard_arrow_up, color: Colors.red),
14+
this.title,
1315
this.textStyle = const TextStyle(color: Colors.black, fontSize: 16),
1416
this.titlePadding,
1517
this.descriptionPadding,
1618
this.descriptionbackgroundColor,
19+
this.contentChild,
1720
this.margin})
1821
: super(key: key);
1922

20-
/// child of type [Widget]is alternative to text key. text will get priority over child
23+
/// child of type [Widget]is alternative to title key. title will get priority over child
2124
final Widget child;
2225

23-
/// description of type[Widget] which shows the messages after the [GFAccordian] is expanded
24-
final Widget description;
26+
/// content of type[String] which shows the messages after the [GFAccordion] is expanded
27+
final String content;
28+
29+
/// contentChild of type [Widget]is alternative to content key. content will get priority over contentChild
30+
final Widget contentChild;
2531

26-
/// type of [Color] or [GFColor] which is used to change the background color of the [GFAccordian] title
32+
/// type of [Color] or [GFColor] which is used to change the background color of the [GFAccordion] title
2733
final dynamic titlebackgroundColor;
2834

29-
///collapsedIcon of type [Widget] which is used to show when the [GFAccordian] is collapsed
35+
///collapsedIcon of type [Widget] which is used to show when the [GFAccordion] is collapsed
3036
final Widget collapsedIcon;
3137

32-
///expandedIcon of type[Widget] which is used when the [GFAccordian] is expanded
38+
///expandedIcon of type[Widget] which is used when the [GFAccordion] is expanded
3339
final Widget expandedIcon;
3440

3541
/// text of type [String] is alternative to child. text will get priority over child
36-
final String text;
42+
final String title;
3743

3844
/// textStyle of type [textStyle] will be applicable to text only and not for the child
3945
final TextStyle textStyle;
4046

41-
///titlePadding of type [EdgeInsets] which is used to set the padding of the [GFAccordian] title
47+
///titlePadding of type [EdgeInsets] which is used to set the padding of the [GFAccordion] title
4248
final EdgeInsets titlePadding;
4349

44-
///descriptionPadding of type [EdgeInsets] which is used to set the padding of the [GFAccordian] description
50+
///descriptionPadding of type [EdgeInsets] which is used to set the padding of the [GFAccordion] description
4551
final EdgeInsets descriptionPadding;
4652

47-
/// type of [Color] or [GFColor] which is used to change the background color of the [GFAccordian] description
53+
/// type of [Color] or [GFColor] which is used to change the background color of the [GFAccordion] description
4854
final dynamic descriptionbackgroundColor;
4955

50-
///margin of type [EdgeInsets] which is used to set the margin of the [GFAccordian]
56+
///margin of type [EdgeInsets] which is used to set the margin of the [GFAccordion]
5157
final EdgeInsets margin;
5258

5359
@override
54-
_GFAccordianState createState() => _GFAccordianState();
60+
_GFAccordionState createState() => _GFAccordionState();
5561
}
5662

57-
class _GFAccordianState extends State<GFAccordian>
63+
class _GFAccordionState extends State<GFAccordion>
5864
with TickerProviderStateMixin {
5965
AnimationController animationController;
6066
AnimationController controller;
@@ -75,7 +81,7 @@ class _GFAccordianState extends State<GFAccordian>
7581
);
7682
}
7783

78-
bool showAccordian = false;
84+
bool showAccordion = false;
7985

8086
@override
8187
Widget build(BuildContext context) {
@@ -96,7 +102,7 @@ class _GFAccordianState extends State<GFAccordian>
96102
break;
97103
default:
98104
}
99-
showAccordian = !showAccordian;
105+
showAccordion = !showAccordion;
100106
});
101107
},
102108
child: Container(
@@ -110,28 +116,30 @@ class _GFAccordianState extends State<GFAccordian>
110116
mainAxisAlignment: MainAxisAlignment.spaceBetween,
111117
children: <Widget>[
112118
Expanded(
113-
child: widget.text != null
114-
? Text(widget.text, style: widget.textStyle)
119+
child: widget.title != null
120+
? Text(widget.title, style: widget.textStyle)
115121
: (widget.child ?? Container()),
116122
),
117-
showAccordian ? widget.expandedIcon : widget.collapsedIcon
123+
showAccordion ? widget.expandedIcon : widget.collapsedIcon
118124
],
119125
),
120126
),
121127
),
122-
showAccordian
128+
showAccordion
123129
? Container(
130+
width: MediaQuery.of(context).size.width,
124131
color: widget.descriptionbackgroundColor != null
125132
? widget.descriptionbackgroundColor
126133
: Colors.white70,
127134
padding: widget.descriptionPadding != null
128135
? widget.descriptionPadding
129136
: EdgeInsets.all(10),
130137
child: SlideTransition(
131-
position: offset,
132-
child: widget.description != null
133-
? widget.description
134-
: Container()))
138+
position: offset,
139+
child: widget.content != null
140+
? Text(widget.content)
141+
: (widget.contentChild ?? Container()),
142+
))
135143
: Container()
136144
],
137145
),

lib/components/alert/gf_alert.dart

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:flutter/widgets.dart';
3+
import 'package:getflutter/getflutter.dart';
4+
import 'package:getflutter/types/gf_alert_type.dart';
5+
6+
class GFAlert extends StatefulWidget {
7+
8+
/// Alert has to be wrap inside the body like [GFFloatingWidget]. See [GFFloatingWidget]
9+
GFAlert(
10+
{Key key,
11+
this.child,
12+
this.backgroundColor,
13+
this.content,
14+
this.width,
15+
this.type = GFAlertType.basic,
16+
this.alignment,
17+
this.contentChild,
18+
this.title,
19+
this.bottombar,
20+
this.animationDuration = const Duration(milliseconds: 300),
21+
this.textStyle = const TextStyle(color: Colors.black87),
22+
this.titleTextStyle = const TextStyle(
23+
color: Colors.black87, fontSize: 17, fontWeight: FontWeight.w500)})
24+
: super(key: key);
25+
26+
/// child of type [Widget]is alternative to text key. text will get priority over child
27+
final Widget child;
28+
29+
/// title of type [String] used to descripe the title of the [GFAlert]
30+
final String title;
31+
32+
/// child of type [Widget]is alternative to title key. title will get priority over contentchild
33+
final Widget contentChild;
34+
35+
/// title of type [String] used to describe the content of the [GFAlert]
36+
final String content;
37+
38+
final TextStyle titleTextStyle;
39+
40+
///pass color of type [Color] or [GFColor] for background of [GFAlert]
41+
final dynamic backgroundColor;
42+
43+
/// textStyle of type [textStyle] will be applicable to text only and not for the child
44+
final TextStyle textStyle;
45+
46+
/// width of type [double] used to control the width of the [GFAlert]
47+
final double width;
48+
49+
///type of [GFAlertType] which takes the type ie, basic, rounded and fullWidth for the [GFAlert]
50+
final GFAlertType type;
51+
52+
///type of [Duration] which takes the duration of the fade in animation
53+
final Duration animationDuration;
54+
55+
/// type of [Alignment] used to align the text inside the toast
56+
final Alignment alignment;
57+
58+
///type of [Widget] used for the buttons ie, OK, Cancel for the action in [GFAlert]
59+
final Widget bottombar;
60+
@override
61+
_GFAlertState createState() => _GFAlertState();
62+
}
63+
64+
class _GFAlertState extends State<GFAlert> with TickerProviderStateMixin {
65+
AnimationController animationController;
66+
Animation<double> animation;
67+
68+
@override
69+
void initState() {
70+
animationController = AnimationController(
71+
duration: const Duration(milliseconds: 300), vsync: this);
72+
animation = CurvedAnimation(
73+
parent: animationController, curve: Curves.fastOutSlowIn);
74+
75+
animationController.forward();
76+
super.initState();
77+
}
78+
79+
@override
80+
void dispose() {
81+
animationController.dispose();
82+
super.dispose();
83+
}
84+
85+
@override
86+
Widget build(BuildContext context) {
87+
return Stack(
88+
children: <Widget>[
89+
Container(
90+
height: MediaQuery.of(context).size.height,
91+
),
92+
FadeTransition(
93+
opacity: animation,
94+
child: Column(
95+
children: <Widget>[
96+
Container(
97+
width: widget.type == GFAlertType.fullWidth
98+
? MediaQuery.of(context).size.width
99+
: widget.width,
100+
constraints: BoxConstraints(minHeight: 50.0),
101+
margin: widget.type == GFAlertType.fullWidth
102+
? EdgeInsets.only(left: 0, right: 0)
103+
: EdgeInsets.only(left: 20, right: 20),
104+
padding: EdgeInsets.all(15),
105+
decoration: BoxDecoration(
106+
borderRadius: widget.type == GFAlertType.basic
107+
? BorderRadius.circular(3.0)
108+
: widget.type == GFAlertType.rounded
109+
? BorderRadius.circular(10.0)
110+
: BorderRadius.zero,
111+
color: widget.backgroundColor != null
112+
? GFColors.getGFColor(widget.backgroundColor)
113+
: GFColors.getGFColor(GFColor.white),
114+
boxShadow: [
115+
BoxShadow(
116+
color: Colors.black.withOpacity(0.40),
117+
blurRadius: 3.0)
118+
]),
119+
child: Column(
120+
crossAxisAlignment: CrossAxisAlignment.start,
121+
children: <Widget>[
122+
widget.title != null
123+
? Text(widget.title, style: widget.titleTextStyle)
124+
: (widget.child ?? Container()),
125+
SizedBox(
126+
height: 10,
127+
),
128+
Align(
129+
alignment: widget.alignment != null
130+
? widget.alignment
131+
: Alignment.topLeft,
132+
child: widget.content != null
133+
? Text(widget.content, style: widget.textStyle)
134+
: (widget.contentChild ?? Container()),
135+
),
136+
SizedBox(
137+
height: 10,
138+
),
139+
widget.bottombar != null ? widget.bottombar : Container(),
140+
],
141+
),
142+
),
143+
],
144+
),
145+
),
146+
],
147+
);
148+
}
149+
}

lib/components/toast/gf_floating_widget.dart

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ class GFFloatingWidget extends StatefulWidget {
99
this.child,
1010
this.horizontalPosition,
1111
this.verticalPosition,
12+
this.color,
13+
this.blur=false,
1214
this.body})
1315
: super(key: key);
1416

@@ -24,6 +26,17 @@ class GFFloatingWidget extends StatefulWidget {
2426
/// verticalPosition of type [double] which aligns the child vertically across the body
2527
final double verticalPosition;
2628

29+
30+
final dynamic color;
31+
32+
final bool blur;
33+
34+
35+
36+
37+
38+
39+
2740
@override
2841
_GFFloatingWidgetState createState() => _GFFloatingWidgetState();
2942
}
@@ -39,19 +52,33 @@ class _GFFloatingWidgetState extends State<GFFloatingWidget> {
3952
height: MediaQuery.of(context).size.height,
4053
child: widget.body ?? Container(),
4154
),
42-
Positioned(
43-
top:
44-
widget.verticalPosition != null ? widget.verticalPosition : 0.0,
45-
left: widget.horizontalPosition != null
46-
? widget.horizontalPosition
47-
: 0.0,
48-
right: widget.horizontalPosition != null
49-
? widget.horizontalPosition
50-
: 0.0,
51-
child: Container(
52-
width: MediaQuery.of(context).size.width,
53-
child: widget.child ?? Container(),
54-
)),
55+
Container(
56+
// color: widget.child!=null? widget.color: null,
57+
child: Stack(
58+
children: <Widget>[
59+
Positioned(
60+
child:Container(
61+
alignment: Alignment.topLeft,
62+
// color: widget.child!=null? widget.color: null,
63+
color: widget.blur?Colors.black38:null,
64+
child: Stack(
65+
children: <Widget>[
66+
Positioned( top:
67+
widget.verticalPosition != null ? widget.verticalPosition : 0.0,
68+
left: widget.horizontalPosition != null
69+
? widget.horizontalPosition
70+
: 0.0,
71+
right: widget.horizontalPosition != null
72+
? widget.horizontalPosition
73+
: 0.0,child: widget.child??Container(),)
74+
],
75+
)
76+
)
77+
),
78+
],
79+
)
80+
)
81+
5582
],
5683
);
5784
}

lib/types/gf_alert_type.dart

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

0 commit comments

Comments
 (0)