Skip to content

Commit 9ead99f

Browse files
committed
gf-button re-check
1 parent 7a32b0a commit 9ead99f

File tree

2 files changed

+132
-68
lines changed

2 files changed

+132
-68
lines changed

lib/components/badge/gf_button_badge.dart

Lines changed: 106 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import 'package:flutter/widgets.dart';
44
import 'package:flutter/material.dart';
55
import 'package:getflutter/getflutter.dart';
66

7-
class GFButtonBadge extends GFButton {
7+
8+
class GFButtonBadge extends StatefulWidget {
89
/// Create badges badges of all types. check out [GFIconButton] for icon badges, and [GFBadge] for badges
910
const GFButtonBadge({
1011
Key key,
@@ -47,9 +48,9 @@ class GFButtonBadge extends GFButton {
4748
this.disabledTextColor,
4849
this.icon,
4950
}) : materialTapTargetSize =
50-
materialTapTargetSize ?? MaterialTapTargetSize.padded,
51+
materialTapTargetSize ?? MaterialTapTargetSize.padded,
5152
assert(shape != null, 'Button shape can not be null'),
52-
// assert(elevation != null && elevation >= 0.0),
53+
// assert(elevation != null && elevation >= 0.0),
5354
assert(focusElevation != null && focusElevation >= 0.0),
5455
assert(hoverElevation != null && hoverElevation >= 0.0),
5556
assert(highlightElevation != null && highlightElevation >= 0.0),
@@ -58,7 +59,7 @@ class GFButtonBadge extends GFButton {
5859
assert(animationDuration != null),
5960
assert(clipBehavior != null),
6061
assert(autofocus != null),
61-
super(key: key, onPressed: onPressed);
62+
super(key: key, );
6263

6364
/// Called when the button is tapped or otherwise activated.
6465
final VoidCallback onPressed;
@@ -219,48 +220,106 @@ class GFButtonBadge extends GFButton {
219220
/// Can be used to display GFBadge, [Icons] inside badge design
220221
final Widget icon;
221222

223+
@override
224+
_GFButtonBadgeState createState() => _GFButtonBadgeState();
225+
}
226+
227+
class _GFButtonBadgeState extends State<GFButtonBadge> {
228+
@override
222229
Widget build(BuildContext context) => ConstrainedBox(
223-
constraints: const BoxConstraints(
224-
minHeight: 26,
225-
minWidth: 98,
226-
),
227-
child: Container(
228-
height: size,
229-
child: GFButton(
230-
onPressed: onPressed,
231-
onHighlightChanged: onHighlightChanged,
232-
textStyle: textStyle,
233-
boxShadow: boxShadow,
234-
buttonBoxShadow: badgeBoxShadow,
235-
focusColor: focusColor,
236-
hoverColor: hoverColor,
237-
highlightColor: highlightColor,
238-
splashColor: splashColor,
239-
elevation: elevation,
240-
focusElevation: focusElevation,
241-
hoverElevation: hoverElevation,
242-
highlightElevation: highlightElevation,
243-
disabledElevation: disabledElevation,
244-
constraints: constraints,
245-
borderShape: borderShape,
246-
animationDuration: animationDuration,
247-
clipBehavior: clipBehavior,
248-
focusNode: focusNode,
249-
autofocus: autofocus,
250-
type: type,
251-
shape: shape,
252-
color: color,
253-
textColor: textColor,
254-
position: position,
255-
size: size,
256-
borderSide: borderSide,
257-
text: text,
258-
icon: icon,
259-
blockButton: blockButton,
260-
fullWidthButton: fullWidthButton,
261-
disabledColor: disabledTextColor,
262-
disabledTextColor: disabledColor,
263-
),
264-
),
265-
);
230+
constraints: const BoxConstraints(
231+
minHeight: 26,
232+
minWidth: 98,
233+
),
234+
child: Container(
235+
height: widget.size,
236+
child: GFButton(
237+
onPressed: widget.onPressed,
238+
onHighlightChanged: widget.onHighlightChanged,
239+
textStyle: widget.textStyle,
240+
boxShadow: widget.boxShadow,
241+
buttonBoxShadow: widget.badgeBoxShadow,
242+
focusColor: widget.focusColor,
243+
hoverColor: widget.hoverColor,
244+
highlightColor: widget.highlightColor,
245+
splashColor: widget.splashColor,
246+
elevation: widget.elevation,
247+
focusElevation: widget.focusElevation,
248+
hoverElevation: widget.hoverElevation,
249+
highlightElevation: widget.highlightElevation,
250+
disabledElevation: widget.disabledElevation,
251+
constraints: widget.constraints,
252+
borderShape: widget.borderShape,
253+
animationDuration: widget.animationDuration,
254+
clipBehavior: widget.clipBehavior,
255+
focusNode: widget.focusNode,
256+
autofocus: widget.autofocus,
257+
type: widget.type,
258+
shape: widget.shape,
259+
color: widget.color,
260+
textColor: widget.textColor,
261+
position: widget.position,
262+
size: widget.size,
263+
borderSide: widget.borderSide,
264+
text: widget.text,
265+
icon: widget.icon,
266+
blockButton: widget.blockButton,
267+
fullWidthButton: widget.fullWidthButton,
268+
disabledColor: widget.disabledTextColor,
269+
disabledTextColor: widget.disabledColor,
270+
),
271+
),
272+
);
266273
}
274+
275+
276+
277+
//
278+
//class GFButtonBadge extends GFButton {
279+
//
280+
//
281+
// Widget build(BuildContext context) => ConstrainedBox(
282+
// constraints: const BoxConstraints(
283+
// minHeight: 26,
284+
// minWidth: 98,
285+
// ),
286+
// child: Container(
287+
// height: size,
288+
// child: GFButton(
289+
// onPressed: onPressed,
290+
// onHighlightChanged: onHighlightChanged,
291+
// textStyle: textStyle,
292+
// boxShadow: boxShadow,
293+
// buttonBoxShadow: badgeBoxShadow,
294+
// focusColor: focusColor,
295+
// hoverColor: hoverColor,
296+
// highlightColor: highlightColor,
297+
// splashColor: splashColor,
298+
// elevation: elevation,
299+
// focusElevation: focusElevation,
300+
// hoverElevation: hoverElevation,
301+
// highlightElevation: highlightElevation,
302+
// disabledElevation: disabledElevation,
303+
// constraints: constraints,
304+
// borderShape: borderShape,
305+
// animationDuration: animationDuration,
306+
// clipBehavior: clipBehavior,
307+
// focusNode: focusNode,
308+
// autofocus: autofocus,
309+
// type: type,
310+
// shape: shape,
311+
// color: color,
312+
// textColor: textColor,
313+
// position: position,
314+
// size: size,
315+
// borderSide: borderSide,
316+
// text: text,
317+
// icon: icon,
318+
// blockButton: blockButton,
319+
// fullWidthButton: fullWidthButton,
320+
// disabledColor: disabledTextColor,
321+
// disabledTextColor: disabledColor,
322+
// ),
323+
// ),
324+
// );
325+
//}

lib/components/button/gf_button.dart

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -586,27 +586,32 @@ class _GFButtonState extends State<GFButton> {
586586
child: Center(
587587
widthFactor: 1,
588588
heightFactor: 1,
589-
child: widget.child,
590-
// child: icon != null &&
591-
// (position == GFPosition.start || position == null)
592-
// ? Row(
593-
// mainAxisSize: MainAxisSize.min,
594-
// children: <Widget>[
595-
// icon,
596-
// const SizedBox(width: 8),
597-
// child
598-
// ],
599-
// )
600-
// : icon != null && (position == GFPosition.end)
601-
// ? Row(
602-
// mainAxisSize: MainAxisSize.min,
603-
// children: <Widget>[
604-
// child,
605-
// const SizedBox(width: 8),
606-
// icon
607-
// ],
608-
// )
609-
// : child,
589+
// child: widget.child !=null? widget.child:Row(
590+
// children: <Widget>[
591+
// widget.icon!=null?widget.icon:Icons.sentiment_very_satisfied,
592+
// widget.child !=null? widget.child:Text('k')
593+
// ],
594+
//),
595+
child: icon != null &&
596+
(position == GFPosition.start || position == null)
597+
? Row(
598+
mainAxisSize: MainAxisSize.min,
599+
children: <Widget>[
600+
icon,
601+
const SizedBox(width: 8),
602+
child
603+
],
604+
)
605+
: icon != null && (position == GFPosition.end)
606+
? Row(
607+
mainAxisSize: MainAxisSize.min,
608+
children: <Widget>[
609+
child,
610+
const SizedBox(width: 8),
611+
icon
612+
],
613+
)
614+
: widget.child,
610615
),
611616
),
612617
),

0 commit comments

Comments
 (0)