Skip to content

Commit

Permalink
feat: bootstraing nesicon16
Browse files Browse the repository at this point in the history
  • Loading branch information
erickzanardo committed Mar 4, 2024
1 parent 25915cf commit ed72e05
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# 0.18.0
- feat: add `NesIcons.wrench`
- feat: add `NesIcons.discord`
- feat: Getting nes ui ready for 16x16 icons.

# 0.17.0
- feat: add `NesIcons.market`
Expand Down
4 changes: 4 additions & 0 deletions example/lib/app/page/app_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,14 @@ class AppPage extends StatelessWidget {
lightIconTheme: const NesIconTheme(
primary: Colors.white,
secondary: Colors.black,
accent: Color(0xff9badb7),
shadow: Color(0xff696a6a),
),
darkIconTheme: const NesIconTheme(
primary: Colors.black,
secondary: Colors.white,
accent: Color(0xff696a6a),
shadow: Color(0xff9badb7),
),
),
brightness: state.lightMode ? Brightness.light : Brightness.dark,
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.16.0"
version: "0.18.0"
nested:
dependency: transitive
description:
Expand Down
30 changes: 30 additions & 0 deletions lib/src/theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,8 @@ class NesIconTheme extends ThemeExtension<NesIconTheme> {
const NesIconTheme({
required this.primary,
required this.secondary,
required this.accent,
required this.shadow,
});

/// Primary color of the icon palette.
Expand All @@ -300,14 +302,24 @@ class NesIconTheme extends ThemeExtension<NesIconTheme> {
/// Secondary color of the icon palette.
final Color secondary;

/// Accent color of the icon palette (Only used in [NesIcons16]).
final Color accent;

/// Shadow color of the icon palette (Only used in [NesIcons16]).
final Color shadow;

@override
NesIconTheme copyWith({
Color? primary,
Color? secondary,
Color? accent,
Color? shadow,
}) {
return NesIconTheme(
primary: primary ?? this.primary,
secondary: secondary ?? this.secondary,
accent: accent ?? this.accent,
shadow: shadow ?? this.shadow,
);
}

Expand All @@ -325,6 +337,16 @@ class NesIconTheme extends ThemeExtension<NesIconTheme> {
end: otherExt?.secondary,
).lerp(t) ??
secondary,
accent: ColorTween(
begin: accent,
end: otherExt?.accent,
).lerp(t) ??
accent,
shadow: ColorTween(
begin: shadow,
end: otherExt?.shadow,
).lerp(t) ??
shadow,
);
}
}
Expand Down Expand Up @@ -752,10 +774,14 @@ ThemeData flutterNesTheme({
lightIconTheme: NesIconTheme(
primary: Color(0xffffffff),
secondary: Color(0xff000000),
accent: Color(0xff9badb7),
shadow: Color(0xff696a6a),
),
darkIconTheme: NesIconTheme(
primary: Color(0xff000000),
secondary: Color(0xffffffff),
accent: Color(0xff696a6a),
shadow: Color(0xff9badb7),
),
),
NesIconTheme? nesIconTheme,
Expand All @@ -780,10 +806,14 @@ ThemeData flutterNesTheme({
? const NesIconTheme(
primary: Color(0xff000000),
secondary: Color(0xffffffff),
accent: Color(0xff9badb7),
shadow: Color(0xff696a6a),
)
: const NesIconTheme(
primary: Color(0xff808080),
secondary: Color(0xffe5e5e5),
accent: Color(0xff696a6a),
shadow: Color(0xff9badb7),
));

final overlayTransitionTheme = nesOverlayTransitionTheme ??
Expand Down
16 changes: 16 additions & 0 deletions lib/src/widgets/nes_icon.dart
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,8 @@ class NesIcon extends StatelessWidget {
this.size,
this.primaryColor,
this.secondaryColor,
this.accentColor,
this.shadowColor,
});

/// Data of this icon.
Expand All @@ -784,6 +786,18 @@ class NesIcon extends StatelessWidget {
/// Will use value from the theme if none is provided.
final Color? secondaryColor;

/// An optional accent color for the icon.
/// Will use value from the theme if none is provided.
///
/// Only has effect in [NesIcons16].
final Color? accentColor;

/// An optional shadow color for the icon.
/// Will use value from the theme if none is provided.
///
/// Only has effect in [NesIcons16].
final Color? shadowColor;

@override
Widget build(BuildContext context) {
final nesTheme = context.nesThemeExtension<NesTheme>();
Expand All @@ -807,6 +821,8 @@ class NesIcon extends StatelessWidget {
palette: [
primaryColor ?? nesIconTheme.primary,
secondaryColor ?? nesIconTheme.secondary,
accentColor ?? nesIconTheme.accent,
shadowColor ?? nesIconTheme.shadow,
],
sprite: iconData.sprite,
);
Expand Down
8 changes: 8 additions & 0 deletions lib/src/widgets/nes_icon16.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// ignore_for_file: lines_longer_than_80_chars
import 'package:nes_ui/nes_ui.dart';

/// Built in library of 16x16 icons for the Flutter Nes Design library.
/// Use [NesIcons] to access the icons.
class NesIcons16 {
NesIcons16._();
}
1 change: 1 addition & 0 deletions lib/src/widgets/widgets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export 'nes_dropshadow.dart';
export 'nes_file_explorer.dart';
export 'nes_fixed_viewport.dart';
export 'nes_icon.dart';
export 'nes_icon16.dart';
export 'nes_icon_badge.dart';
export 'nes_icon_button.dart';
export 'nes_input.dart';
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: nes_ui
description: UI library inspired by old retro video game console
version: 0.17.0
version: 0.18.0
repository: https://github.com/erickzanardo/nes_ui

environment:
Expand Down

0 comments on commit ed72e05

Please sign in to comment.