Skip to content

Commit

Permalink
Resolve issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Osman authored and Osman committed Mar 6, 2024
1 parent 9e0aec2 commit bb4827f
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 22 deletions.
10 changes: 5 additions & 5 deletions example/lib/pages/components/button_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ class _ButtonExampleState extends State<ButtonExample> {
label: "Label",
),
GroupButton.dropdown(
onPress: () {},
onPressed: () {},
label: "Label",
),
]),
Expand All @@ -204,7 +204,7 @@ class _ButtonExampleState extends State<ButtonExample> {
label: "Label",
),
GroupButton.dropdown(
onPress: () {},
onPressed: () {},
label: "Label",
),
GroupButton.icon(
Expand All @@ -220,17 +220,17 @@ class _ButtonExampleState extends State<ButtonExample> {
GroupButton.icon(
icon: ZetaIcons.star_round,
label: "Label",
onPress: () {},
onPressed: () {},
),
GroupButton.icon(
icon: ZetaIcons.star_round,
label: "Label",
onPress: () {},
onPressed: () {},
),
GroupButton.icon(
icon: ZetaIcons.star_round,
label: "Label",
onPress: () {},
onPressed: () {},
),
],
),
Expand Down
6 changes: 3 additions & 3 deletions example/widgetbook/pages/components/button_widgetbook.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Widget buttonGroupUseCase(BuildContext context) => WidgetbookTestWidget(
buttons: [
GroupButton(
label: context.knobs.string(label: 'button1Title'),
onPress:
onPressed:
context.knobs.boolean(label: 'button1Dropdown') ? () {} : null,
icon: context.knobs.listOrNull(
label: 'button1Icon',
Expand All @@ -86,7 +86,7 @@ Widget buttonGroupUseCase(BuildContext context) => WidgetbookTestWidget(
),
GroupButton(
label: context.knobs.string(label: 'button2Title'),
onPress:
onPressed:
context.knobs.boolean(label: 'button2Dropdown') ? () {} : null,
icon: context.knobs.listOrNull(
label: 'button2Icon',
Expand All @@ -102,7 +102,7 @@ Widget buttonGroupUseCase(BuildContext context) => WidgetbookTestWidget(
),
GroupButton(
label: context.knobs.string(label: 'button3Title'),
onPress:
onPressed:
context.knobs.boolean(label: 'button3Dropdown') ? () {} : null,
icon: context.knobs.listOrNull(
label: 'button3Icon',
Expand Down
35 changes: 22 additions & 13 deletions lib/src/components/buttons/button_group.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ class ZetaButtonGroup extends StatelessWidget {

return buttons;
}
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties
..add(DiagnosticsProperty<bool>('isLarge', isLarge))
..add(DiagnosticsProperty<bool>('rounded', rounded));
}
}

/// Group Button item
Expand All @@ -53,13 +60,13 @@ class GroupButton extends StatefulWidget {
super.key,
this.label,
this.icon,
this.onPress,
this.onPressed,
});

/// Constructs dropdown group button
GroupButton.dropdown({
super.key,
required this.onPress,
required this.onPressed,
this.icon,
this.label,
});
Expand All @@ -68,7 +75,7 @@ class GroupButton extends StatefulWidget {
GroupButton.icon({
super.key,
required this.icon,
this.onPress,
this.onPressed,
this.label,
});

Expand All @@ -79,7 +86,7 @@ class GroupButton extends StatefulWidget {
final IconData? icon;

/// Function for when [GroupButton] is clicked.
final VoidCallback? onPress;
final VoidCallback? onPressed;

///If [GroupButton] is large
bool _isLarge = false;
Expand All @@ -102,9 +109,7 @@ class GroupButton extends StatefulWidget {
key: key,
label: label,
icon: icon,
onPress: onPress,
// isFinal: isFinal ?? this.isFinal,
// isInitial: isInitial ?? this.isInitial,
onPressed: onPressed,
);
}

Expand All @@ -114,7 +119,7 @@ class GroupButton extends StatefulWidget {
properties
..add(StringProperty('Label', label))
..add(DiagnosticsProperty<IconData?>('icon', icon))
..add(ObjectFlagProperty<VoidCallback?>.has('onPress', onPress));
..add(ObjectFlagProperty<VoidCallback?>.has('onPressed', onPressed));
}
}

Expand All @@ -129,11 +134,13 @@ class _GroupButtonState extends State<GroupButton> {
controller = MaterialStatesController();
}

void onPress() {
widget.onPress!();
void onPressed() {
if(widget.onPressed != null){
widget.onPressed?.call();
setState(() {
selected = !selected;
});
}
}

@override
Expand All @@ -159,15 +166,15 @@ class _GroupButtonState extends State<GroupButton> {
padding: EdgeInsets.zero,
child: FilledButton(
statesController: controller,
onPressed: onPress,
onPressed: onPressed,
style: getStyle(borderType, colors),
child: SelectionContainer.disabled(
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
if (widget.icon != null) Icon(widget.icon),
Text(widget.label!),
if (widget.onPress != null)
if (widget.onPressed != null)
const Icon(ZetaIcons.expand_more_round),
],
).paddingAll(_padding),
Expand All @@ -183,6 +190,7 @@ class _GroupButtonState extends State<GroupButton> {
ZetaColors colors,
bool finalButton,
) {
if(selected) return BorderSide(color: colors.black);
if (states.contains(MaterialState.disabled)) {
return BorderSide(color: colors.cool.shade40);
}
Expand Down Expand Up @@ -217,7 +225,8 @@ class _GroupButtonState extends State<GroupButton> {
return ButtonStyle(
shape: MaterialStateProperty.all(
RoundedRectangleBorder(
borderRadius: borderType.radius,
borderRadius: _getRadius(borderType),

),
),
backgroundColor: MaterialStateProperty.resolveWith<Color?>((states) {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/components/progress/progress_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class _ZetaProgressBarState extends ZetaProgressState<ZetaProgressBar> {
width: _weight,
height: _weight,
decoration: BoxDecoration(
color: colors.surfaceDisabled, borderRadius: ZetaRadius.rounded),
color: colors.surfaceDisabled, borderRadius: ZetaRadius.rounded,),
),
],
);
Expand Down

0 comments on commit bb4827f

Please sign in to comment.