From 930bd3162ac100e3527402de1852e769d6586aba Mon Sep 17 00:00:00 2001 From: Erick Zanardo Date: Thu, 7 Mar 2024 15:22:09 -0300 Subject: [PATCH] feat: open sprites on mini sprite --- example/lib/gallery/sections/icons.dart | 893 +++++++++++++----------- example/pubspec.lock | 81 ++- example/pubspec.yaml | 1 + lib/src/widgets/nes_icon16.dart | 8 + 4 files changed, 561 insertions(+), 422 deletions(-) diff --git a/example/lib/gallery/sections/icons.dart b/example/lib/gallery/sections/icons.dart index d463908..bd1a750 100644 --- a/example/lib/gallery/sections/icons.dart +++ b/example/lib/gallery/sections/icons.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:nes_ui/nes_ui.dart'; +import 'package:url_launcher/url_launcher_string.dart'; class IconsSection extends StatelessWidget { const IconsSection({super.key}); @@ -15,413 +16,441 @@ class IconsSection extends StatelessWidget { style: theme.textTheme.displayMedium, ), const SizedBox(height: 16), - Wrap( - children: [ - _IconEntry( - data: NesIcons.check, - label: 'check', - ), - _IconEntry( - data: NesIcons.close, - label: 'close', - ), - _IconEntry( - data: NesIcons.handPointingRight, - label: 'handPointingRight', - ), - _IconEntry( - data: NesIcons.leftArrowIndicator, - label: 'leftArrowIndicator', - ), - _IconEntry( - data: NesIcons.rightArrowIndicator, - label: 'rightArrowIndicator', - ), - _IconEntry( - data: NesIcons.topArrowIndicator, - label: 'topArrowIndicator', - ), - _IconEntry( - data: NesIcons.bottomArrowIndicator, - label: 'bottomArrowIndicator', - ), - _IconEntry( - data: NesIcons.sword, - label: 'sword', - ), - _IconEntry( - data: NesIcons.shield, - label: 'shield', - ), - _IconEntry( - data: NesIcons.axe, - label: 'axe', - ), - _IconEntry( - data: NesIcons.arrow, - label: 'arrow', - ), - _IconEntry( - data: NesIcons.sun, - label: 'sun', - ), - _IconEntry( - data: NesIcons.moon, - label: 'moon', - ), - _IconEntry( - data: NesIcons.gallery, - label: 'gallery', - ), - _IconEntry( - data: NesIcons.gamepad, - label: 'gamepad', - ), - _IconEntry( - data: NesIcons.delete, - label: 'delete', - ), - _IconEntry( - data: NesIcons.add, - label: 'add', - ), - _IconEntry( - data: NesIcons.remove, - label: 'remove', - ), - _IconEntry( - data: NesIcons.redo, - label: 'redo', - ), - _IconEntry( - data: NesIcons.openFolder, - label: 'openFolder', - ), - _IconEntry( - data: NesIcons.closedFolder, - label: 'closedFolder', - ), - _IconEntry( - data: NesIcons.thinArrowLeft, - label: 'thinArrowLeft', - ), - _IconEntry( - data: NesIcons.thinArrowRight, - label: 'thinArrowRight', - ), - _IconEntry( - data: NesIcons.musicNote, - label: 'musicNote', - ), - _IconEntry( - data: NesIcons.keyHole, - label: 'keyHole', - ), - _IconEntry( - data: NesIcons.questionMark, - label: 'questionMark', - ), - _IconEntry( - data: NesIcons.dartLang, - label: 'dartLang', - ), - _IconEntry( - data: NesIcons.bottomConnection, - label: 'bottomConnection', - ), - _IconEntry( - data: NesIcons.middleConnection, - label: 'middleConnection', - ), - _IconEntry( - data: NesIcons.topConnection, - label: 'topConnection', - ), - _IconEntry( - data: NesIcons.threeVerticalDots, - label: 'threeVerticalDots', - ), - _IconEntry( - data: NesIcons.threeHorizontalDots, - label: 'threeHorizontalDots', - ), - _IconEntry( - data: NesIcons.newFile, - label: 'newFile', - ), - _IconEntry( - data: NesIcons.saveFile, - label: 'saveFile', - ), - _IconEntry( - data: NesIcons.openEye, - label: 'openEye', - ), - _IconEntry( - data: NesIcons.closedEye, - label: 'closedEye', - ), - _IconEntry( - data: NesIcons.window, - label: 'window', - ), - _IconEntry( - data: NesIcons.textFile, - label: 'textFile', - ), - _IconEntry( - data: NesIcons.download, - label: 'download', - ), - _IconEntry( - data: NesIcons.upload, - label: 'upload', - ), - _IconEntry( - data: NesIcons.zoomIn, - label: 'zoomIn', - ), - _IconEntry( - data: NesIcons.zoomOut, - label: 'zoomOut', - ), - _IconEntry( - data: NesIcons.yamlFile, - label: 'yamlFile', - ), - _IconEntry( - data: NesIcons.xmlFile, - label: 'xmlFile', - ), - _IconEntry( - data: NesIcons.exclamationMarkBlock, - label: 'exclamationMarkBlock', - ), - _IconEntry( - data: NesIcons.questionMarkBlock, - label: 'questionMarkBlock', - ), - _IconEntry( - data: NesIcons.leftHand, - label: 'leftHand', - ), - _IconEntry( - data: NesIcons.rightHand, - label: 'rightHand', - ), - _IconEntry( - data: NesIcons.helm, - label: 'helm', - ), - _IconEntry( - data: NesIcons.upperArmor, - label: 'upperArmor', - ), - _IconEntry( - data: NesIcons.lowerArmor, - label: 'lowerArmor', - ), - _IconEntry( - data: NesIcons.exchange, - label: 'exchange', - ), - _IconEntry( - data: NesIcons.edit, - label: 'edit', - ), - _IconEntry( - data: NesIcons.expand, - label: 'expand', - ), - _IconEntry( - data: NesIcons.cut, - label: 'cut', - ), - _IconEntry( - data: NesIcons.eraser, - label: 'eraser', - ), - _IconEntry( - data: NesIcons.copy, - label: 'copy', - ), - _IconEntry( - data: NesIcons.paste, - label: 'paste', - ), - _IconEntry( - data: NesIcons.camera, - label: 'camera', - ), - _IconEntry( - data: NesIcons.tv, - label: 'tv', - ), - _IconEntry( - data: NesIcons.radio, - label: 'radio', - ), - _IconEntry( - data: NesIcons.hourglassTopFull, - label: 'hourglassTopFull', - ), - _IconEntry( - data: NesIcons.hourglassBottomFull, - label: 'hourglassBottomFull', - ), - _IconEntry( - data: NesIcons.hourglassMiddle, - label: 'hourglassMiddle', - ), - _IconEntry( - data: NesIcons.flag, - label: 'flag', - ), - _IconEntry( - data: NesIcons.checkedFlag, - label: 'checkedFlag', - ), - _IconEntry( - data: NesIcons.infinite, - label: 'infinite', - ), - _IconEntry( - data: NesIcons.user, - label: 'user', - ), - _IconEntry( - data: NesIcons.chest, - label: 'chest', - ), - _IconEntry( - data: NesIcons.lamp, - label: 'lamp', - ), - _IconEntry( - data: NesIcons.clock, - label: 'clock', - ), - _IconEntry( - data: NesIcons.tree, - label: 'tree', - ), - _IconEntry( - data: NesIcons.energy, - label: 'energy', - ), - _IconEntry( - data: NesIcons.leaves, - label: 'leaves', - ), - _IconEntry( - data: NesIcons.fruit, - label: 'fruit', - ), - _IconEntry( - data: NesIcons.fatArrowUp, - label: 'fatArrowUp', - ), - _IconEntry( - data: NesIcons.fatArrowDown, - label: 'fatArrowDown', - ), - _IconEntry( - data: NesIcons.hammer, - label: 'hammer', - ), - _IconEntry( - data: NesIcons.owl, - label: 'owl', - ), - _IconEntry( - data: NesIcons.letter, - label: 'letter', - ), - _IconEntry( - data: NesIcons.factory, - label: 'factory', - ), - _IconEntry( - data: NesIcons.rail, - label: 'rail', - ), - _IconEntry( - data: NesIcons.robot, - label: 'robot', - ), - _IconEntry( - data: NesIcons.pickaxe, - label: 'pickaxe', - ), - _IconEntry( - data: NesIcons.oven, - label: 'oven', - ), - _IconEntry( - data: NesIcons.rotate, - label: 'rotate', - ), - _IconEntry( - data: NesIcons.penguin, - label: 'penguin', - ), - _IconEntry( - data: NesIcons.apple, - label: 'apple', - ), - _IconEntry( - data: NesIcons.windows, - label: 'windows', - ), - _IconEntry( - data: NesIcons.audio, - label: 'audio', - ), - _IconEntry( - data: NesIcons.audioMuted, - label: 'audioMuted', - ), - _IconEntry( - data: NesIcons.screen, - label: 'screen', - ), - _IconEntry( - data: NesIcons.rename, - label: 'rename', - ), - _IconEntry( - data: NesIcons.hamburgerMenu, - label: 'hamburgerMenu', - ), - _IconEntry( - data: NesIcons.arrowCursor, - label: 'arrowCursor', - ), - _IconEntry( - data: NesIcons.center, - label: 'center', - ), - _IconEntry( - data: NesIcons.market, - label: 'market', - ), - _IconEntry( - data: NesIcons.play, - label: 'play', - ), - _IconEntry( - data: NesIcons.pause, - label: 'pause', - ), - _IconEntry( - data: NesIcons.wrench, - label: 'wrench', - ), - _IconEntry( - data: NesIcons.discord, - label: 'discord', - ), - ], + const Text('Double click to open in Mini Sprites'), + const SizedBox(height: 16), + SizedBox( + height: 400, + child: NesTabView( + tabs: [ + NesTabItem( + label: '8x8', + child: NesSingleChildScrollView( + child: Wrap( + children: [ + _IconEntry( + data: NesIcons.check, + label: 'check', + ), + _IconEntry( + data: NesIcons.close, + label: 'close', + ), + _IconEntry( + data: NesIcons.handPointingRight, + label: 'handPointingRight', + ), + _IconEntry( + data: NesIcons.leftArrowIndicator, + label: 'leftArrowIndicator', + ), + _IconEntry( + data: NesIcons.rightArrowIndicator, + label: 'rightArrowIndicator', + ), + _IconEntry( + data: NesIcons.topArrowIndicator, + label: 'topArrowIndicator', + ), + _IconEntry( + data: NesIcons.bottomArrowIndicator, + label: 'bottomArrowIndicator', + ), + _IconEntry( + data: NesIcons.sword, + label: 'sword', + ), + _IconEntry( + data: NesIcons.shield, + label: 'shield', + ), + _IconEntry( + data: NesIcons.axe, + label: 'axe', + ), + _IconEntry( + data: NesIcons.arrow, + label: 'arrow', + ), + _IconEntry( + data: NesIcons.sun, + label: 'sun', + ), + _IconEntry( + data: NesIcons.moon, + label: 'moon', + ), + _IconEntry( + data: NesIcons.gallery, + label: 'gallery', + ), + _IconEntry( + data: NesIcons.gamepad, + label: 'gamepad', + ), + _IconEntry( + data: NesIcons.delete, + label: 'delete', + ), + _IconEntry( + data: NesIcons.add, + label: 'add', + ), + _IconEntry( + data: NesIcons.remove, + label: 'remove', + ), + _IconEntry( + data: NesIcons.redo, + label: 'redo', + ), + _IconEntry( + data: NesIcons.openFolder, + label: 'openFolder', + ), + _IconEntry( + data: NesIcons.closedFolder, + label: 'closedFolder', + ), + _IconEntry( + data: NesIcons.thinArrowLeft, + label: 'thinArrowLeft', + ), + _IconEntry( + data: NesIcons.thinArrowRight, + label: 'thinArrowRight', + ), + _IconEntry( + data: NesIcons.musicNote, + label: 'musicNote', + ), + _IconEntry( + data: NesIcons.keyHole, + label: 'keyHole', + ), + _IconEntry( + data: NesIcons.questionMark, + label: 'questionMark', + ), + _IconEntry( + data: NesIcons.dartLang, + label: 'dartLang', + ), + _IconEntry( + data: NesIcons.bottomConnection, + label: 'bottomConnection', + ), + _IconEntry( + data: NesIcons.middleConnection, + label: 'middleConnection', + ), + _IconEntry( + data: NesIcons.topConnection, + label: 'topConnection', + ), + _IconEntry( + data: NesIcons.threeVerticalDots, + label: 'threeVerticalDots', + ), + _IconEntry( + data: NesIcons.threeHorizontalDots, + label: 'threeHorizontalDots', + ), + _IconEntry( + data: NesIcons.newFile, + label: 'newFile', + ), + _IconEntry( + data: NesIcons.saveFile, + label: 'saveFile', + ), + _IconEntry( + data: NesIcons.openEye, + label: 'openEye', + ), + _IconEntry( + data: NesIcons.closedEye, + label: 'closedEye', + ), + _IconEntry( + data: NesIcons.window, + label: 'window', + ), + _IconEntry( + data: NesIcons.textFile, + label: 'textFile', + ), + _IconEntry( + data: NesIcons.download, + label: 'download', + ), + _IconEntry( + data: NesIcons.upload, + label: 'upload', + ), + _IconEntry( + data: NesIcons.zoomIn, + label: 'zoomIn', + ), + _IconEntry( + data: NesIcons.zoomOut, + label: 'zoomOut', + ), + _IconEntry( + data: NesIcons.yamlFile, + label: 'yamlFile', + ), + _IconEntry( + data: NesIcons.xmlFile, + label: 'xmlFile', + ), + _IconEntry( + data: NesIcons.exclamationMarkBlock, + label: 'exclamationMarkBlock', + ), + _IconEntry( + data: NesIcons.questionMarkBlock, + label: 'questionMarkBlock', + ), + _IconEntry( + data: NesIcons.leftHand, + label: 'leftHand', + ), + _IconEntry( + data: NesIcons.rightHand, + label: 'rightHand', + ), + _IconEntry( + data: NesIcons.helm, + label: 'helm', + ), + _IconEntry( + data: NesIcons.upperArmor, + label: 'upperArmor', + ), + _IconEntry( + data: NesIcons.lowerArmor, + label: 'lowerArmor', + ), + _IconEntry( + data: NesIcons.exchange, + label: 'exchange', + ), + _IconEntry( + data: NesIcons.edit, + label: 'edit', + ), + _IconEntry( + data: NesIcons.expand, + label: 'expand', + ), + _IconEntry( + data: NesIcons.cut, + label: 'cut', + ), + _IconEntry( + data: NesIcons.eraser, + label: 'eraser', + ), + _IconEntry( + data: NesIcons.copy, + label: 'copy', + ), + _IconEntry( + data: NesIcons.paste, + label: 'paste', + ), + _IconEntry( + data: NesIcons.camera, + label: 'camera', + ), + _IconEntry( + data: NesIcons.tv, + label: 'tv', + ), + _IconEntry( + data: NesIcons.radio, + label: 'radio', + ), + _IconEntry( + data: NesIcons.hourglassTopFull, + label: 'hourglassTopFull', + ), + _IconEntry( + data: NesIcons.hourglassBottomFull, + label: 'hourglassBottomFull', + ), + _IconEntry( + data: NesIcons.hourglassMiddle, + label: 'hourglassMiddle', + ), + _IconEntry( + data: NesIcons.flag, + label: 'flag', + ), + _IconEntry( + data: NesIcons.checkedFlag, + label: 'checkedFlag', + ), + _IconEntry( + data: NesIcons.infinite, + label: 'infinite', + ), + _IconEntry( + data: NesIcons.user, + label: 'user', + ), + _IconEntry( + data: NesIcons.chest, + label: 'chest', + ), + _IconEntry( + data: NesIcons.lamp, + label: 'lamp', + ), + _IconEntry( + data: NesIcons.clock, + label: 'clock', + ), + _IconEntry( + data: NesIcons.tree, + label: 'tree', + ), + _IconEntry( + data: NesIcons.energy, + label: 'energy', + ), + _IconEntry( + data: NesIcons.leaves, + label: 'leaves', + ), + _IconEntry( + data: NesIcons.fruit, + label: 'fruit', + ), + _IconEntry( + data: NesIcons.fatArrowUp, + label: 'fatArrowUp', + ), + _IconEntry( + data: NesIcons.fatArrowDown, + label: 'fatArrowDown', + ), + _IconEntry( + data: NesIcons.hammer, + label: 'hammer', + ), + _IconEntry( + data: NesIcons.owl, + label: 'owl', + ), + _IconEntry( + data: NesIcons.letter, + label: 'letter', + ), + _IconEntry( + data: NesIcons.factory, + label: 'factory', + ), + _IconEntry( + data: NesIcons.rail, + label: 'rail', + ), + _IconEntry( + data: NesIcons.robot, + label: 'robot', + ), + _IconEntry( + data: NesIcons.pickaxe, + label: 'pickaxe', + ), + _IconEntry( + data: NesIcons.oven, + label: 'oven', + ), + _IconEntry( + data: NesIcons.rotate, + label: 'rotate', + ), + _IconEntry( + data: NesIcons.penguin, + label: 'penguin', + ), + _IconEntry( + data: NesIcons.apple, + label: 'apple', + ), + _IconEntry( + data: NesIcons.windows, + label: 'windows', + ), + _IconEntry( + data: NesIcons.audio, + label: 'audio', + ), + _IconEntry( + data: NesIcons.audioMuted, + label: 'audioMuted', + ), + _IconEntry( + data: NesIcons.screen, + label: 'screen', + ), + _IconEntry( + data: NesIcons.rename, + label: 'rename', + ), + _IconEntry( + data: NesIcons.hamburgerMenu, + label: 'hamburgerMenu', + ), + _IconEntry( + data: NesIcons.arrowCursor, + label: 'arrowCursor', + ), + _IconEntry( + data: NesIcons.center, + label: 'center', + ), + _IconEntry( + data: NesIcons.market, + label: 'market', + ), + _IconEntry( + data: NesIcons.play, + label: 'play', + ), + _IconEntry( + data: NesIcons.pause, + label: 'pause', + ), + _IconEntry( + data: NesIcons.wrench, + label: 'wrench', + ), + _IconEntry( + data: NesIcons.discord, + label: 'discord', + ), + ], + ), + ), + ), + NesTabItem( + label: '16x16', + child: NesSingleChildScrollView( + child: Wrap( + children: [ + _IconEntry( + data: NesIcons16.check, + label: 'check', + is16x16: true, + ), + ], + ), + ), + ), + ], + ), ), ], ); @@ -432,27 +461,51 @@ class _IconEntry extends StatelessWidget { const _IconEntry({ required this.data, required this.label, + this.is16x16 = false, }); final NesIconData data; final String label; + final bool is16x16; @override Widget build(BuildContext context) { - return Padding( - padding: const EdgeInsets.all(8), - child: Column( - children: [ - NesIcon(iconData: data), - const SizedBox(height: 8), - SizedBox( - width: 120, - child: Text( - label, - textAlign: TextAlign.center, + return GestureDetector( + onDoubleTap: () { + final nesIconTheme = context.nesThemeExtension(); + final colors = is16x16 + ? [ + nesIconTheme.primary, + nesIconTheme.secondary, + nesIconTheme.accent, + nesIconTheme.shadow, + ] + : [ + nesIconTheme.primary, + nesIconTheme.secondary, + ]; + + final colorsParam = colors.map((c) => c.value).join(','); + + launchUrlString( + 'https://minisprit.es#?colors=$colorsParam&sprite=${data.sprite.toDataString()}', + ); + }, + child: Padding( + padding: const EdgeInsets.all(8), + child: Column( + children: [ + NesIcon(iconData: data), + const SizedBox(height: 8), + SizedBox( + width: 120, + child: Text( + label, + textAlign: TextAlign.center, + ), ), - ), - ], + ], + ), ), ); } diff --git a/example/pubspec.lock b/example/pubspec.lock index cfa3427..fe770f5 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -78,6 +78,11 @@ packages: url: "https://pub.dev" source: hosted version: "0.0.1+1" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" google_fonts: dependency: transitive description: @@ -266,6 +271,70 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.2" + url_launcher: + dependency: "direct main" + description: + name: url_launcher + sha256: "0ecc004c62fd3ed36a2ffcbe0dd9700aee63bd7532d0b642a488b1ec310f492e" + url: "https://pub.dev" + source: hosted + version: "6.2.5" + url_launcher_android: + dependency: transitive + description: + name: url_launcher_android + sha256: "507dc655b1d9cb5ebc756032eb785f114e415f91557b73bf60b7e201dfedeb2f" + url: "https://pub.dev" + source: hosted + version: "6.2.2" + url_launcher_ios: + dependency: transitive + description: + name: url_launcher_ios + sha256: "9149d493b075ed740901f3ee844a38a00b33116c7c5c10d7fb27df8987fb51d5" + url: "https://pub.dev" + source: hosted + version: "6.2.5" + url_launcher_linux: + dependency: transitive + description: + name: url_launcher_linux + sha256: ab360eb661f8879369acac07b6bb3ff09d9471155357da8443fd5d3cf7363811 + url: "https://pub.dev" + source: hosted + version: "3.1.1" + url_launcher_macos: + dependency: transitive + description: + name: url_launcher_macos + sha256: b7244901ea3cf489c5335bdacda07264a6e960b1c1b1a9f91e4bc371d9e68234 + url: "https://pub.dev" + source: hosted + version: "3.1.0" + url_launcher_platform_interface: + dependency: transitive + description: + name: url_launcher_platform_interface + sha256: "4aca1e060978e19b2998ee28503f40b5ba6226819c2b5e3e4d1821e8ccd92198" + url: "https://pub.dev" + source: hosted + version: "2.3.0" + url_launcher_web: + dependency: transitive + description: + name: url_launcher_web + sha256: "3692a459204a33e04bc94f5fb91158faf4f2c8903281ddd82915adecdb1a901d" + url: "https://pub.dev" + source: hosted + version: "2.3.0" + url_launcher_windows: + dependency: transitive + description: + name: url_launcher_windows + sha256: ecf9725510600aa2bb6d7ddabe16357691b6d2805f66216a97d1b881e21beff7 + url: "https://pub.dev" + source: hosted + version: "3.1.1" vector_math: dependency: transitive description: @@ -282,6 +351,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.1.0" + web: + dependency: transitive + description: + name: web + sha256: "97da13628db363c635202ad97068d47c5b8aa555808e7a9411963c533b449b27" + url: "https://pub.dev" + source: hosted + version: "0.5.1" win32: dependency: transitive description: @@ -299,5 +376,5 @@ packages: source: hosted version: "1.0.3" sdks: - dart: ">=3.2.0-0 <4.0.0" - flutter: ">=3.10.0" + dart: ">=3.3.0 <4.0.0" + flutter: ">=3.19.0" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 388faa2..973cc28 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -15,6 +15,7 @@ dependencies: nes_ui: path: ../ phased: ^0.0.3 + url_launcher: ^6.2.5 dev_dependencies: very_good_analysis: ^3.1.0 diff --git a/lib/src/widgets/nes_icon16.dart b/lib/src/widgets/nes_icon16.dart index a4ca3c1..1c74684 100644 --- a/lib/src/widgets/nes_icon16.dart +++ b/lib/src/widgets/nes_icon16.dart @@ -1,8 +1,16 @@ // ignore_for_file: lines_longer_than_80_chars +import 'package:mini_sprite/mini_sprite.dart'; 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._(); + + /// 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', + ), + ); }