Skip to content

Commit df45070

Browse files
authored
Merge pull request #73 from shravyackm/toast
Toast
2 parents b224f20 + e7a0590 commit df45070

3 files changed

Lines changed: 38 additions & 46 deletions

File tree

lib/components/accordian/gf_accordian.dart

Lines changed: 22 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,18 @@ class GFAccordion extends StatefulWidget {
66
{Key key,
77
this.child,
88
this.content,
9-
this.titlebackgroundColor,
9+
this.collapsedTitlebackgroundColor = Colors.white,
10+
this.expandedTitlebackgroundColor= const Color(0xFFE0E0E0),
1011
this.collapsedIcon = const Icon(Icons.keyboard_arrow_down),
1112
this.expandedIcon = const Icon(Icons.keyboard_arrow_up),
1213
this.title,
1314
this.textStyle = const TextStyle(color: Colors.black, fontSize: 16),
14-
this.titlePadding,
15+
this.titlePadding = const EdgeInsets.all(10),
1516
this.contentbackgroundColor,
16-
this.contentPadding,
17+
this.contentPadding = const EdgeInsets.all(10),
1718
this.contentChild,
18-
this.titleborderColor,
19-
this.contentBorderColor,
19+
this.titleborderColor = const Border(),
20+
this.contentBorderColor = const Border(),
2021
this.margin})
2122
: super(key: key);
2223

@@ -29,8 +30,11 @@ class GFAccordion extends StatefulWidget {
2930
/// contentChild of type [Widget]is alternative to content key. content will get priority over contentChild
3031
final Widget contentChild;
3132

32-
/// type of [Color] or [GFColor] which is used to change the background color of the [GFAccordion] title
33-
final dynamic titlebackgroundColor;
33+
/// type of [Color] or [GFColor] which is used to change the background color of the [GFAccordion] title when it is collapsed
34+
final dynamic collapsedTitlebackgroundColor;
35+
36+
/// type of [Color] or [GFColor] which is used to change the background color of the [GFAccordion] title when it is expanded
37+
final dynamic expandedTitlebackgroundColor;
3438

3539
///collapsedIcon of type [Widget] which is used to show when the [GFAccordion] is collapsed
3640
final Widget collapsedIcon;
@@ -86,6 +90,11 @@ class _GFAccordionState extends State<GFAccordion>
8690
),
8791
);
8892
}
93+
@override
94+
void dispose() {
95+
animationController.dispose();
96+
super.dispose();
97+
}
8998

9099
bool showAccordion = false;
91100

@@ -113,21 +122,10 @@ class _GFAccordionState extends State<GFAccordion>
113122
},
114123
child: Container(
115124
decoration: BoxDecoration(
116-
border: widget.titleborderColor == null
117-
? widget.titleborderColor
118-
: Border(
119-
top: BorderSide(color: Colors.black38),
120-
left: BorderSide(color: Colors.black38),
121-
right: BorderSide(color: Colors.black38),
122-
bottom: BorderSide(color: Colors.black38)),
123-
color: showAccordion
124-
? widget.titlebackgroundColor != null
125-
? widget.titlebackgroundColor
126-
: Color(0xFFE0E0E0)
127-
: widget.titlebackgroundColor),
128-
padding: widget.titlePadding != null
129-
? widget.titlePadding
130-
: EdgeInsets.all(10),
125+
border: widget.titleborderColor,
126+
color: showAccordion ? widget.expandedTitlebackgroundColor: widget.collapsedTitlebackgroundColor),
127+
padding: widget.titlePadding
128+
,
131129
child: Row(
132130
mainAxisAlignment: MainAxisAlignment.spaceBetween,
133131
children: <Widget>[
@@ -144,20 +142,13 @@ class _GFAccordionState extends State<GFAccordion>
144142
showAccordion
145143
? Container(
146144
decoration: BoxDecoration(
147-
border: widget.contentBorderColor == null
148-
? widget.contentBorderColor
149-
: Border(
150-
bottom: BorderSide(color: Colors.black38),
151-
left: BorderSide(color: Colors.black38),
152-
right: BorderSide(color: Colors.black38)),
145+
border: widget.contentBorderColor,
153146
color: widget.contentbackgroundColor != null
154147
? widget.contentbackgroundColor
155148
: Colors.white70,
156149
),
157150
width: MediaQuery.of(context).size.width,
158-
padding: widget.contentPadding != null
159-
? widget.contentPadding
160-
: EdgeInsets.all(10),
151+
padding: widget.contentPadding ,
161152
child: SlideTransition(
162153
position: offset,
163154
child: widget.content != null

lib/components/alert/gf_alert.dart

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,15 @@ class GFAlert extends StatefulWidget {
1616
this.contentChild,
1717
this.title,
1818
this.bottombar,
19-
this.animationDuration = const Duration(milliseconds: 300),
20-
this.textStyle = const TextStyle(color: Colors.black87),
19+
this.contentTextStyle = const TextStyle(color: Colors.black87),
2120
this.titleTextStyle = const TextStyle(
2221
color: Colors.black87, fontSize: 17, fontWeight: FontWeight.w500)})
2322
: super(key: key);
2423

25-
/// child of type [Widget]is alternative to text key. text will get priority over child
24+
/// child of type [Widget]is alternative to title key. title will get priority over child
2625
final Widget child;
2726

28-
/// title of type [String] used to descripe the title of the [GFAlert]
27+
/// title of type [String] used to describe the title of the [GFAlert]
2928
final String title;
3029

3130
/// child of type [Widget]is alternative to title key. title will get priority over contentchild
@@ -34,24 +33,22 @@ class GFAlert extends StatefulWidget {
3433
/// title of type [String] used to describe the content of the [GFAlert]
3534
final String content;
3635

36+
///type of [TextStyle] to change the style of the title not for the child
3737
final TextStyle titleTextStyle;
3838

3939
///pass color of type [Color] or [GFColor] for background of [GFAlert]
4040
final dynamic backgroundColor;
4141

42-
/// textStyle of type [textStyle] will be applicable to text only and not for the child
43-
final TextStyle textStyle;
42+
///type of [TextStyle] to change the style of the content not for the contentchild
43+
final TextStyle contentTextStyle;
4444

4545
/// width of type [double] used to control the width of the [GFAlert]
4646
final double width;
4747

4848
///type of [GFAlertType] which takes the type ie, basic, rounded and fullWidth for the [GFAlert]
4949
final GFAlertType type;
5050

51-
///type of [Duration] which takes the duration of the fade in animation
52-
final Duration animationDuration;
53-
54-
/// type of [Alignment] used to align the text inside the toast
51+
/// type of [Alignment] used to align the text inside the [GFAlert]
5552
final Alignment alignment;
5653

5754
///type of [Widget] used for the buttons ie, OK, Cancel for the action in [GFAlert]
@@ -71,7 +68,6 @@ class _GFAlertState extends State<GFAlert> with TickerProviderStateMixin {
7168
duration: const Duration(milliseconds: 300), vsync: this);
7269
animation = CurvedAnimation(
7370
parent: animationController, curve: Curves.fastOutSlowIn);
74-
7571
animationController.forward();
7672
super.initState();
7773
}
@@ -113,9 +109,13 @@ class _GFAlertState extends State<GFAlert> with TickerProviderStateMixin {
113109
child: Column(
114110
crossAxisAlignment: CrossAxisAlignment.start,
115111
children: <Widget>[
116-
widget.title != null
117-
? Text(widget.title, style: widget.titleTextStyle)
118-
: (widget.child ?? Container()),
112+
Align(
113+
alignment: widget.alignment!=null? widget.alignment:Alignment.topLeft,
114+
child: widget.title != null
115+
? Text(widget.title, style: widget.titleTextStyle)
116+
: (widget.child ?? Container()),
117+
),
118+
119119
SizedBox(
120120
height: 10,
121121
),
@@ -124,7 +124,7 @@ class _GFAlertState extends State<GFAlert> with TickerProviderStateMixin {
124124
? widget.alignment
125125
: Alignment.topLeft,
126126
child: widget.content != null
127-
? Text(widget.content, style: widget.textStyle)
127+
? Text(widget.content, style: widget.contentTextStyle)
128128
: (widget.contentChild ?? Container()),
129129
),
130130
SizedBox(

lib/components/toast/gf_toast.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ class _GFToastState extends State<GFToast> with TickerProviderStateMixin {
7676
vsync: this,
7777
duration: widget.animationDuration,
7878
)..addListener(() => setState(() {}));
79+
7980
fadeanimation = Tween<double>(
8081
begin: 0.0,
8182
end: 1.0,

0 commit comments

Comments
 (0)