Skip to content

Commit

Permalink
feat: Adding NesIcons16.check (#134)
Browse files Browse the repository at this point in the history
  • Loading branch information
erickzanardo authored Mar 7, 2024
1 parent 930bd31 commit f0972ce
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# 0.19.0
- feat: adding `NesSectionHeader`
- feat: adding `NesIcons16.check`

# 0.18.0
- feat: add `NesIcons.wrench`
Expand Down
10 changes: 10 additions & 0 deletions lib/src/theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,12 @@ class NesIconTheme extends ThemeExtension<NesIconTheme> {
required this.secondary,
required this.accent,
required this.shadow,
this.size = 32,
});

/// The size of the icon.
final double size;

/// Primary color of the icon palette.
final Color primary;

Expand All @@ -310,12 +314,14 @@ class NesIconTheme extends ThemeExtension<NesIconTheme> {

@override
NesIconTheme copyWith({
double? size,
Color? primary,
Color? secondary,
Color? accent,
Color? shadow,
}) {
return NesIconTheme(
size: size ?? this.size,
primary: primary ?? this.primary,
secondary: secondary ?? this.secondary,
accent: accent ?? this.accent,
Expand All @@ -327,6 +333,10 @@ class NesIconTheme extends ThemeExtension<NesIconTheme> {
NesIconTheme lerp(ThemeExtension<NesIconTheme>? other, double t) {
final otherExt = other as NesIconTheme?;
return NesIconTheme(
size: Tween<double>(
begin: size,
end: otherExt?.size ?? size,
).transform(t),
primary: ColorTween(
begin: primary,
end: otherExt?.primary,
Expand Down
14 changes: 6 additions & 8 deletions lib/src/widgets/nes_icon.dart
Original file line number Diff line number Diff line change
Expand Up @@ -805,16 +805,14 @@ class NesIcon extends StatelessWidget {

var pixelSize = nesTheme.pixelSize.toDouble();

final customSize = size;
if (customSize != null) {
final spriteHorizontalUnits = iconData.sprite.pixels[0].length;
final spriteVerticalUnits = iconData.sprite.pixels.length;
final iconSize = size ?? Size.square(nesIconTheme.size);
final spriteHorizontalUnits = iconData.sprite.pixels[0].length;
final spriteVerticalUnits = iconData.sprite.pixels.length;

final width = customSize.width / spriteHorizontalUnits;
final height = customSize.height / spriteVerticalUnits;
final width = iconSize.width / spriteHorizontalUnits;
final height = iconSize.height / spriteVerticalUnits;

pixelSize = math.min(width, height).roundToDouble();
}
pixelSize = math.min(width, height).roundToDouble();

return MiniSpriteWidget(
pixelSize: pixelSize,
Expand Down
2 changes: 1 addition & 1 deletion lib/src/widgets/nes_icon16.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class NesIcons16 {
/// A check icon.
static final check = NesIconData(
MiniSprite.fromDataString(
'8,8;6,-1;2,0;5,-1;1,0;1,1;1,0;4,-1;1,0;2,1;3,0;1,-1;1,0;2,1;1,0;1,-1;1,0;1,1;1,0;2,1;1,0;2,-1;1,0;3,1;1,0;4,-1;1,0;1,1;1,0;6,-1;1,0;5,-1',
'16,16;14,-1;2,0;13,-1;1,0;1,2;1,0;12,-1;1,0;1,2;1,3;1,0;11,-1;1,0;1,2;1,1;1,2;1,0;10,-1;1,0;1,2;2,1;1,3;1,0;9,-1;1,0;1,2;2,1;1,3;1,0;9,-1;1,0;1,2;2,1;1,3;1,0;3,-1;2,0;4,-1;1,0;1,2;2,1;1,3;1,0;3,-1;1,0;2,2;1,0;2,-1;1,0;1,2;2,1;1,3;1,0;4,-1;1,0;1,3;1,2;1,0;1,-1;1,0;1,2;2,1;1,3;1,0;5,-1;1,0;1,2;1,1;1,2;1,0;1,2;2,1;1,3;1,0;6,-1;1,0;1,3;2,1;1,2;2,1;1,3;1,0;8,-1;1,0;1,3;3,1;1,3;1,0;10,-1;1,0;1,3;1,1;1,3;1,0;12,-1;1,0;1,3;1,0;14,-1;1,0;11,-1',
),
);
}

0 comments on commit f0972ce

Please sign in to comment.