@@ -26,7 +26,7 @@ class GFIconButton extends StatefulWidget {
2626 /// The color for the button's icon when a pointer is hovering over it.
2727 final Color hoverColor;
2828
29- /// Button type of [GFType] i.e, solid, outline, transparent
29+ /// Button type of [GFType] i.e, solid, outline, outline2x transparent
3030 final GFType type;
3131
3232 /// Button type of [GFButtonShape] i.e, standard, pills, square, shadow, icons
@@ -87,14 +87,15 @@ class GFIconButton extends StatefulWidget {
8787 this .focusNode,
8888 this .autofocus = false ,
8989 this .tooltip,
90- this .type = GFType .transparent ,
90+ this .type = GFType .solid ,
9191 this .shape = GFButtonShape .standard,
9292 this .color = GFColor .primary,
9393 this .borderShape,
9494 this .boxShadow,
9595 this .size = GFSize .medium,
9696 this .buttonBoxShadow,
97- this .borderSide})
97+ this .borderSide,
98+ })
9899 : assert (iconSize != null ),
99100 assert (padding != null ),
100101 assert (alignment != null ),
@@ -128,22 +129,45 @@ class _GFIconButtonState extends State<GFIconButton> {
128129 @override
129130 Widget build (BuildContext context) {
130131 assert (debugCheckHasMaterial (context));
131- Color currentColor;
132- if (widget.onPressed != null )
133- currentColor = widget.color;
134- else
135- currentColor = widget.disabledColor ?? Theme .of (context).disabledColor;
136132
133+ Color getBorderColor () {
134+ if (widget.onPressed != null ){
135+ return this .color;
136+ }else {
137+ if (widget.disabledColor != null )
138+ return widget.disabledColor;
139+ else {
140+ return this .color.withOpacity (0.48 );
141+ }
142+ }
143+ }
137144
145+ Color getDisabledFillColor () {
146+ if (widget.type == GFType .transparent || widget.type == GFType .outline || widget.type == GFType .outline2x)
147+ return Colors .transparent;
148+ if (widget.disabledColor != null )
149+ return widget.disabledColor;
150+ else {
151+ return this .color.withOpacity (0.48 );
152+ }
153+ }
154+
155+ Color getColor () {
156+ if (widget.type == GFType .transparent || widget.type == GFType .outline || widget.type == GFType .outline2x)
157+ return Colors .transparent;
158+ else {
159+ return this .color;
160+ }
161+ }
138162
139163 final Color themeColor =
140164 Theme .of (context).colorScheme.onSurface.withOpacity (0.12 );
141165 final BorderSide outlineBorder = BorderSide (
142- color: widget.borderSide == null ? themeColor : widget.borderSide.color,
143- width: widget.borderSide? .width ?? 1.0 ,
166+ color: widget.borderSide == null ? getBorderColor () : widget.borderSide.color,
167+ width: widget.borderSide? .width == null ? widget.type == GFType .outline2x ? 2.0 : 1.0 : widget.borderSide ? .width ,
144168 );
145169
146- final BorderSide shapeBorder = widget.type == GFType .outline
170+ final BorderSide shapeBorder = widget.type == GFType .outline || widget.type == GFType .outline2x
147171 ? outlineBorder
148172 : widget.borderSide != null
149173 ? widget.borderSide
@@ -156,16 +180,13 @@ class _GFIconButtonState extends State<GFIconButton> {
156180
157181 if (this .shape == GFButtonShape .pills) {
158182 shape = RoundedRectangleBorder (
159- borderRadius: BorderRadius .circular (50 .0 ), side: shapeBorder);
183+ borderRadius: BorderRadius .circular (20 .0 ), side: shapeBorder);
160184 } else if (this .shape == GFButtonShape .square) {
161185 shape = RoundedRectangleBorder (
162186 borderRadius: BorderRadius .circular (0.0 ), side: shapeBorder);
163187 } else if (this .shape == GFButtonShape .standard) {
164188 shape = RoundedRectangleBorder (
165- borderRadius: BorderRadius .circular (5.0 ), side: shapeBorder);
166- } else {
167- shape = RoundedRectangleBorder (
168- borderRadius: BorderRadius .circular (5.0 ), side: shapeBorder);
189+ borderRadius: BorderRadius .circular (3.0 ), side: shapeBorder);
169190 }
170191
171192 if (widget.size == GFSize .small) {
@@ -182,15 +203,26 @@ class _GFIconButtonState extends State<GFIconButton> {
182203 this .iconPixel = 18.0 ;
183204 }
184205
206+ getIconColor (){
207+ if (widget.type == GFType .transparent || widget.type == GFType .outline || widget.type == GFType .outline2x)
208+ return widget.onPressed != null ?
209+ this .color == getGFColor (GFColor .transparent) ? getGFColor (GFColor .dark) : this .color : this .color.withOpacity (0.48 );
210+ else if (this .color == getGFColor (GFColor .transparent)){
211+ return widget.onPressed != null ? getGFColor (GFColor .dark) : getGFColor (GFColor .white);
212+ }
213+ else {
214+ return getGFColor (GFColor .white);
215+ }
216+ }
217+
185218 Widget result = Container (
186- height:
187- widget.shape == GFButtonShape .pills ? this .height + 6 : this .height,
188- width: widget.shape == GFButtonShape .pills ? this .width + 6 : this .width,
219+ height: this .height,
220+ width: widget.shape == GFButtonShape .pills ? this .width + 10 : this .width,
189221 padding: widget.padding,
190222 child: IconTheme .merge (
191223 data: IconThemeData (
192224 size: widget.iconSize > 0.0 ? widget.iconSize : this .iconPixel,
193- color: currentColor ,
225+ color: getIconColor () ,
194226 ),
195227 child: widget.icon,
196228 ),
@@ -209,10 +241,7 @@ class _GFIconButtonState extends State<GFIconButton> {
209241 return null ;
210242 } else {
211243 return BoxDecoration (
212- color: widget.type == GFType .transparent ||
213- widget.type == GFType .outline
214- ? Colors .transparent
215- : this .color,
244+ color: widget.onPressed != null ? getColor () : getDisabledFillColor (),
216245 borderRadius: widget.shape == GFButtonShape .pills
217246 ? BorderRadius .circular (50.0 )
218247 : widget.shape == GFButtonShape .standard
@@ -249,21 +278,16 @@ class _GFIconButtonState extends State<GFIconButton> {
249278 child: ConstrainedBox (
250279 constraints: BoxConstraints (maxWidth: 60.0 , maxHeight: 60.0 ),
251280 child: Container (
252- height: widget.shape == GFButtonShape .pills
253- ? this .height + 6
254- : this .height,
281+ height: this .height,
255282 width: widget.shape == GFButtonShape .pills
256- ? this .width + 6
283+ ? this .width + 10
257284 : this .width,
258285 decoration: getBoxShadow (),
259286 child: Material (
260287 shape: widget.type == GFType .transparent
261288 ? null
262289 : widget.borderShape == null ? shape : widget.borderShape,
263- color: widget.type == GFType .transparent ||
264- widget.type == GFType .outline
265- ? Colors .transparent
266- : this .color,
290+ color: widget.onPressed != null ? getColor () : getDisabledFillColor (),
267291 type: widget.type == GFType .transparent
268292 ? MaterialType .transparency
269293 : MaterialType .button,
0 commit comments