From ed72e05e41957ece76e1a1a80e400d39f2391800 Mon Sep 17 00:00:00 2001 From: Erick Date: Mon, 4 Mar 2024 09:38:54 -0300 Subject: [PATCH] feat: bootstraing nesicon16 --- CHANGELOG.md | 1 + example/lib/app/page/app_page.dart | 4 ++++ example/pubspec.lock | 2 +- lib/src/theme.dart | 30 ++++++++++++++++++++++++++++++ lib/src/widgets/nes_icon.dart | 16 ++++++++++++++++ lib/src/widgets/nes_icon16.dart | 8 ++++++++ lib/src/widgets/widgets.dart | 1 + pubspec.yaml | 2 +- 8 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 lib/src/widgets/nes_icon16.dart diff --git a/CHANGELOG.md b/CHANGELOG.md index 743dce3..3002a2f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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` diff --git a/example/lib/app/page/app_page.dart b/example/lib/app/page/app_page.dart index 5d45e62..decf9cd 100644 --- a/example/lib/app/page/app_page.dart +++ b/example/lib/app/page/app_page.dart @@ -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, diff --git a/example/pubspec.lock b/example/pubspec.lock index 6f95189..cfa3427 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -132,7 +132,7 @@ packages: path: ".." relative: true source: path - version: "0.16.0" + version: "0.18.0" nested: dependency: transitive description: diff --git a/lib/src/theme.dart b/lib/src/theme.dart index 5dc2f76..736c19e 100644 --- a/lib/src/theme.dart +++ b/lib/src/theme.dart @@ -292,6 +292,8 @@ class NesIconTheme extends ThemeExtension { const NesIconTheme({ required this.primary, required this.secondary, + required this.accent, + required this.shadow, }); /// Primary color of the icon palette. @@ -300,14 +302,24 @@ class NesIconTheme extends ThemeExtension { /// 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, ); } @@ -325,6 +337,16 @@ class NesIconTheme extends ThemeExtension { 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, ); } } @@ -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, @@ -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 ?? diff --git a/lib/src/widgets/nes_icon.dart b/lib/src/widgets/nes_icon.dart index c5f4d92..f362f3b 100644 --- a/lib/src/widgets/nes_icon.dart +++ b/lib/src/widgets/nes_icon.dart @@ -765,6 +765,8 @@ class NesIcon extends StatelessWidget { this.size, this.primaryColor, this.secondaryColor, + this.accentColor, + this.shadowColor, }); /// Data of this icon. @@ -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(); @@ -807,6 +821,8 @@ class NesIcon extends StatelessWidget { palette: [ primaryColor ?? nesIconTheme.primary, secondaryColor ?? nesIconTheme.secondary, + accentColor ?? nesIconTheme.accent, + shadowColor ?? nesIconTheme.shadow, ], sprite: iconData.sprite, ); diff --git a/lib/src/widgets/nes_icon16.dart b/lib/src/widgets/nes_icon16.dart new file mode 100644 index 0000000..a4ca3c1 --- /dev/null +++ b/lib/src/widgets/nes_icon16.dart @@ -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._(); +} diff --git a/lib/src/widgets/widgets.dart b/lib/src/widgets/widgets.dart index c3b1050..d1a385e 100644 --- a/lib/src/widgets/widgets.dart +++ b/lib/src/widgets/widgets.dart @@ -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'; diff --git a/pubspec.yaml b/pubspec.yaml index 6881a9a..b20db44 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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: