Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Adding NesIcons16.check #134

Merged
merged 1 commit into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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',
),
);
}
Loading