Skip to content

Commit b27c6e8

Browse files
authored
Merge pull request #11 from ionicfirebaseapp/master
master pull
2 parents a97d877 + b906c69 commit b27c6e8

File tree

3 files changed

+61
-35
lines changed

3 files changed

+61
-35
lines changed

example/lib/main.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,17 +192,19 @@ class _MyHomePageState extends State<MyHomePage>
192192
// disabledTextColor: GFColor.light,
193193
blockButton: true,
194194
// fullWidthButton: true,
195+
// borderSide: BorderSide(color: Colors.pink, width: 1.0, style: BorderStyle.solid),
196+
// borderShape: RoundedRectangleBorder(side: BorderSide(color: Colors.pink, width: 2.0, style: BorderStyle.solid), borderRadius: BorderRadius.zero),
195197
),
196198

197199
GFIconButton(
198200
onPressed: null,
199-
icon: Icon(Icons.ac_unit),
201+
icon: Icon(Icons.ac_unit,),
200202
// iconSize: 12.0,
201203
type: GFType.outline2x,
202204
// shape: GFButtonShape.pills,
203205
// size: GFSize.large,
204206
// buttonBoxShadow: true,
205-
// color: GFColor.primary,
207+
color: GFColor.secondary,
206208
// boxShadow: BoxShadow(
207209
// color: Colors.pink,
208210
// blurRadius: 2.0,

lib/components/button/gf_button.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ class _GFButtonState extends State<GFButton> {
422422
color: this.color == null
423423
? themeColor
424424
: widget.borderSide == null ? getBorderColor() : widget.borderSide.color,
425-
width: widget.borderSide?.width ?? widget.type == GFType.outline2x ? 2.0 : 1.0,
425+
width: widget.borderSide?.width == null ? widget.type == GFType.outline2x ? 2.0 : 1.0 : widget.borderSide?.width,
426426
);
427427

428428
Size minSize;

lib/components/button/gf_icon_button.dart

Lines changed: 56 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)