Skip to content

Commit 01560c5

Browse files
Sandip KakadiyaSandip Kakadiya
authored andcommitted
GFColor changes in button, listtile, rating
1 parent fd07f1e commit 01560c5

4 files changed

Lines changed: 57 additions & 74 deletions

File tree

lib/components/button/gf_icon_button.dart

Lines changed: 33 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class GFIconButton extends StatefulWidget {
2323
this.tooltip,
2424
this.type = GFButtonType.solid,
2525
this.shape = GFIconButtonShape.standard,
26-
this.color = GFColor.primary,
26+
this.color = GFColors.PRIMARY,
2727
this.borderShape,
2828
this.boxShadow,
2929
this.size = GFSize.MEDIUM,
@@ -60,17 +60,17 @@ class GFIconButton extends StatefulWidget {
6060
/// Button type of [GFIconButtonShape] i.e, standard, pills, square, shadow, icons
6161
final GFIconButtonShape shape;
6262

63-
/// Pass [GFColor] or [Color]
64-
final dynamic color;
63+
/// Pass [GFColors] or [Color]
64+
final Color color;
6565

66-
/// Pass [GFColor] or [Color]. The primary color of the button when the button is in the down (pressed) state.
67-
final dynamic splashColor;
66+
/// Pass [GFColors] or [Color]. The primary color of the button when the button is in the down (pressed) state.
67+
final Color splashColor;
6868

69-
/// Pass [GFColor] or [Color]. The secondary color of the button when the button is in the down (pressed) state.
70-
final dynamic highlightColor;
69+
/// Pass [GFColors] or [Color]. The secondary color of the button when the button is in the down (pressed) state.
70+
final Color highlightColor;
7171

72-
/// Pass [GFColor] or [Color]. The color to use for the icon inside the button, if the icon is disabled.
73-
final dynamic disabledColor;
72+
/// Pass [GFColors] or [Color]. The color to use for the icon inside the button, if the icon is disabled.
73+
final Color disabledColor;
7474

7575
/// The callback that is called when the button is tapped or otherwise activated.
7676
final VoidCallback onPressed;
@@ -115,7 +115,7 @@ class _GFIconButtonState extends State<GFIconButton> {
115115

116116
@override
117117
void initState() {
118-
color = GFColors.getGFColor(widget.color);
118+
color = widget.color;
119119
onPressed = widget.onPressed;
120120
type = widget.type;
121121
shape = widget.shape;
@@ -162,16 +162,12 @@ class _GFIconButtonState extends State<GFIconButton> {
162162
widget.type == GFButtonType.outline ||
163163
widget.type == GFButtonType.outline2x) {
164164
return widget.onPressed != null
165-
? color == GFColors.getGFColor(GFColor.transparent)
166-
? GFColors.getGFColor(GFColor.dark)
167-
: color
165+
? color == GFColors.TRANSPARENT ? GFColors.DARK : color
168166
: color.withOpacity(0.48);
169-
} else if (color == GFColors.getGFColor(GFColor.transparent)) {
170-
return widget.onPressed != null
171-
? GFColors.getGFColor(GFColor.dark)
172-
: GFColors.getGFColor(GFColor.white);
167+
} else if (color == GFColors.TRANSPARENT) {
168+
return widget.onPressed != null ? GFColors.DARK : GFColors.WHITE;
173169
} else {
174-
return GFColors.getGFColor(GFColor.white);
170+
return GFColors.WHITE;
175171
}
176172
}
177173

@@ -193,12 +189,11 @@ class _GFIconButtonState extends State<GFIconButton> {
193189
final BorderSide shapeBorder = widget.type == GFButtonType.outline ||
194190
widget.type == GFButtonType.outline2x
195191
? outlineBorder
196-
: widget.borderSide != null
197-
? widget.borderSide
198-
: BorderSide(
199-
color: color,
200-
width: 0,
201-
);
192+
: widget.borderSide ??
193+
BorderSide(
194+
color: color,
195+
width: 0,
196+
);
202197

203198
ShapeBorder shapeBorderType;
204199

@@ -288,14 +283,13 @@ class _GFIconButtonState extends State<GFIconButton> {
288283
spreadRadius: 2,
289284
offset: Offset.zero,
290285
)
291-
: widget.boxShadow != null
292-
? widget.boxShadow
293-
: BoxShadow(
294-
color: Theme.of(context).canvasColor,
295-
blurRadius: 0,
296-
spreadRadius: 0,
297-
offset: Offset.zero,
298-
)
286+
: widget.boxShadow ??
287+
BoxShadow(
288+
color: Theme.of(context).canvasColor,
289+
blurRadius: 0,
290+
spreadRadius: 0,
291+
offset: Offset.zero,
292+
)
299293
]);
300294
}
301295
}
@@ -321,9 +315,7 @@ class _GFIconButtonState extends State<GFIconButton> {
321315
child: Material(
322316
shape: widget.type == GFButtonType.transparent
323317
? null
324-
: widget.borderShape == null
325-
? shapeBorderType
326-
: widget.borderShape,
318+
: widget.borderShape ?? shapeBorderType,
327319
color: widget.onPressed != null
328320
? getColor()
329321
: getDisabledFillColor(),
@@ -333,18 +325,12 @@ class _GFIconButtonState extends State<GFIconButton> {
333325
child: InkResponse(
334326
onTap: widget.onPressed,
335327
child: result,
336-
focusColor: widget.focusColor != null
337-
? GFColors.getGFColor(widget.focusColor)
338-
: Theme.of(context).focusColor,
339-
hoverColor: widget.hoverColor != null
340-
? GFColors.getGFColor(widget.hoverColor)
341-
: Theme.of(context).hoverColor,
342-
highlightColor: widget.highlightColor != null
343-
? GFColors.getGFColor(widget.highlightColor)
344-
: Theme.of(context).highlightColor,
345-
splashColor: widget.splashColor != null
346-
? GFColors.getGFColor(widget.splashColor)
347-
: Theme.of(context).splashColor,
328+
focusColor: widget.focusColor ?? Theme.of(context).focusColor,
329+
hoverColor: widget.hoverColor ?? Theme.of(context).hoverColor,
330+
highlightColor:
331+
widget.highlightColor ?? Theme.of(context).highlightColor,
332+
splashColor:
333+
widget.splashColor ?? Theme.of(context).splashColor,
348334
radius: math.max(
349335
Material.defaultSplashRadius,
350336
(widget.iconSize +

lib/components/button/gf_social_button.dart

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class GFSocialButton extends GFButton {
3333
this.child,
3434
this.type = GFButtonType.solid,
3535
this.shape = GFButtonShape.standard,
36-
this.color = GFColor.primary,
36+
this.color = GFColors.PRIMARY,
3737
this.textColor,
3838
this.position = GFPosition.start,
3939
this.size = GFSize.MEDIUM,
@@ -79,17 +79,17 @@ class GFSocialButton extends GFButton {
7979
/// The box shadow for the button's [Material], if GFButtonType is solid
8080
final BoxShadow boxShadow;
8181

82-
/// Pass [GFColor] or [Color]. The color for the button's [Material] when it has the input focus.
83-
final dynamic focusColor;
82+
/// Pass [GFColors] or [Color]. The color for the button's [Material] when it has the input focus.
83+
final Color focusColor;
8484

85-
/// Pass [GFColor] or [Color]. The color for the button's [Material] when a pointer is hovering over it.
86-
final dynamic hoverColor;
85+
/// Pass [GFColors] or [Color]. The color for the button's [Material] when a pointer is hovering over it.
86+
final Color hoverColor;
8787

88-
/// Pass [GFColor] or [Color]. The highlight color for the button's [InkWell].
89-
final dynamic highlightColor;
88+
/// Pass [GFColors] or [Color]. The highlight color for the button's [InkWell].
89+
final Color highlightColor;
9090

91-
/// Pass [GFColor] or [Color]. The splash color for the button's [InkWell].
92-
final dynamic splashColor;
91+
/// Pass [GFColors] or [Color]. The splash color for the button's [InkWell].
92+
final Color splashColor;
9393

9494
/// The elevation for the button's [Material] when the button is [enabled] but not pressed.
9595
final double elevation;
@@ -142,8 +142,8 @@ class GFSocialButton extends GFButton {
142142
/// Button type of GFSocialButtonShape i.e, standard, pills, square, shadow, icons
143143
final GFButtonShape shape;
144144

145-
/// Pass [GFColor] or [Color]
146-
final dynamic color;
145+
/// Pass [GFColors] or [Color]
146+
final Color color;
147147

148148
/// The fill color of the button when the button is disabled.
149149
///
@@ -153,10 +153,10 @@ class GFSocialButton extends GFButton {
153153
/// See also:
154154
///
155155
/// * [color] - the fill color of the button when the button is [enabled].
156-
final dynamic disabledColor;
156+
final Color disabledColor;
157157

158-
/// Pass [GFColor] or [Color]
159-
final dynamic textColor;
158+
/// Pass [GFColors] or [Color]
159+
final Color textColor;
160160

161161
/// The color to use for this button's text when the button is disabled.
162162
///
@@ -172,7 +172,7 @@ class GFSocialButton extends GFButton {
172172
/// See also:
173173
///
174174
/// * [textColor] - The color to use for this button's text when the button is [enabled].
175-
final dynamic disabledTextColor;
175+
final Color disabledTextColor;
176176

177177
/// size of [double] or [GFSize] i.e, 1.2, small, medium, large etc.
178178
final double size;
@@ -250,7 +250,7 @@ class GFSocialButton extends GFButton {
250250
child: child,
251251
type: GFButtonType.solid,
252252
shape: GFButtonShape.standard,
253-
color: GFColor.primary,
253+
color: GFColors.PRIMARY,
254254
textColor: textColor,
255255
position: GFPosition.start,
256256
size: size,

lib/components/list_tile/gf_list_tile.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ class GFListTile extends StatelessWidget {
2323
///type of [String] used to pass text, alternative to subtitle property and gets higher priority than subtitle
2424
final String subtitleText;
2525

26-
/// The GFListTile's background color. Can be given [Color] or [GFColor]
27-
final dynamic color;
26+
/// The GFListTile's background color. Can be given [Color] or [GFColors]
27+
final Color color;
2828

2929
/// type of [Widget] or [GFAvatar] used to create rounded user profile
3030
final Widget avatar;
@@ -68,7 +68,7 @@ class GFListTile extends StatelessWidget {
6868
style: TextStyle(
6969
fontSize: 17,
7070
fontWeight: FontWeight.w500,
71-
color: GFColors.getGFColor(GFColor.dark)),
71+
color: GFColors.DARK),
7272
)
7373
: title ?? Container(),
7474
subtitleText != null

lib/components/rating/gf_rating.dart

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ class GFRating extends StatefulWidget {
2828
final int itemCount;
2929

3030
/// defines the color of items
31-
final dynamic color;
31+
final Color color;
3232

3333
/// defines the border color of [halfFilledIcon]
34-
final dynamic borderColor;
34+
final Color borderColor;
3535

3636
/// defines the size of items. GFSize can be used for size variations like small. medium. large
3737
final double size;
@@ -86,8 +86,7 @@ class _GFRatingState extends State<GFRating> {
8686
icon = widget.defaultIcon ??
8787
Icon(
8888
Icons.star_border,
89-
color: GFColors.getGFColor(widget.borderColor) ??
90-
Theme.of(context).primaryColor,
89+
color: widget.borderColor ?? Theme.of(context).primaryColor,
9190
size: widget.size,
9291
);
9392
} else if (!widget.showTextForm
@@ -97,16 +96,14 @@ class _GFRatingState extends State<GFRating> {
9796
icon = widget.halfFilledIcon ??
9897
Icon(
9998
Icons.star_half,
100-
color: GFColors.getGFColor(widget.color) ??
101-
Theme.of(context).primaryColor,
99+
color: widget.color ?? Theme.of(context).primaryColor,
102100
size: widget.size,
103101
);
104102
} else {
105103
icon = widget.filledIcon ??
106104
Icon(
107105
Icons.star,
108-
color: GFColors.getGFColor(widget.color) ??
109-
Theme.of(context).primaryColor,
106+
color: widget.color ?? Theme.of(context).primaryColor,
110107
size: widget.size,
111108
);
112109
}

0 commit comments

Comments
 (0)