Skip to content

Commit

Permalink
feat: Adding NesIconButton.badge (#149)
Browse files Browse the repository at this point in the history
* feat: Adding NesIconButton.badge

* fixing alchemist dep

* fixing tests
  • Loading branch information
erickzanardo authored Nov 6, 2024
1 parent 850b0db commit 2856a22
Show file tree
Hide file tree
Showing 23 changed files with 20 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- feat: adding `NesSelectionList.disabledItems`
- feat: `NesPressable` is only pressable when has listeners.
- feat: adding `NesIcons.block`
- feat: adding `NesIconButton.badge`

# 0.20.0
- feat: adding different frames to `NesDialog`s
Expand Down
24 changes: 18 additions & 6 deletions lib/src/widgets/nes_icon_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class NesIconButton extends StatelessWidget {
this.primaryColor,
this.secondaryColor,
this.disabled,
this.badge,
});

/// Icon of the button.
Expand Down Expand Up @@ -44,6 +45,9 @@ class NesIconButton extends StatelessWidget {
/// Disable the button
final bool? disabled;

/// An optional badge to display on the button.
final String? badge;

bool _isDisabled() =>
(disabled ?? false) ||
onPress == null && onPressStart == null && onPressEnd == null;
Expand All @@ -57,12 +61,20 @@ class NesIconButton extends StatelessWidget {
disabled: _isDisabled(),
child: Opacity(
opacity: _isDisabled() ? .2 : 1.0,
child: NesIcon(
iconData: icon,
size: size,
primaryColor: primaryColor,
secondaryColor: secondaryColor,
),
child: badge != null
? NesIconBadge(
iconData: icon,
badge: badge!,
size: size,
primaryColor: primaryColor,
secondaryColor: secondaryColor,
)
: NesIcon(
iconData: icon,
size: size,
primaryColor: primaryColor,
secondaryColor: secondaryColor,
),
),
);
}
Expand Down
4 changes: 1 addition & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ dependencies:
phased: ^0.0.3

dev_dependencies:
alchemist:
git:
url: https://github.com/erickzanardo/alchemist
alchemist: 0.10.0
flutter_test:
sdk: flutter
mocktail: ">=0.3.0 <2.0.0"
Expand Down
Binary file modified test/src/widgets/goldens/ci/nes_button/disabled_button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/widgets/goldens/ci/nes_button/error_button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/widgets/goldens/ci/nes_button/exit_hover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/widgets/goldens/ci/nes_button/hovered_button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/widgets/goldens/ci/nes_button/normal_button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/widgets/goldens/ci/nes_button/pressed_button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/widgets/goldens/ci/nes_button/primary_button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/widgets/goldens/ci/nes_button/success_button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/widgets/goldens/ci/nes_button/warning_button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/widgets/goldens/linux/nes_button/disabled_button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/widgets/goldens/linux/nes_button/error_button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/widgets/goldens/linux/nes_button/exit_hover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/widgets/goldens/linux/nes_button/hovered_button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/widgets/goldens/linux/nes_button/normal_button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/widgets/goldens/linux/nes_button/pressed_button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/widgets/goldens/linux/nes_button/primary_button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/widgets/goldens/linux/nes_button/success_button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/widgets/goldens/linux/nes_button/warning_button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2856a22

Please sign in to comment.