diff --git a/.github/workflows/widgetbook.yaml b/.github/workflows/widgetbook.yaml new file mode 100644 index 0000000..f74d82f --- /dev/null +++ b/.github/workflows/widgetbook.yaml @@ -0,0 +1,23 @@ +name: widgetbook + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +on: + push: + paths: + - "widgetbook/**" + - ".github/workflows/widgetbook.yaml" + + pull_request: + paths: + - "widgetbook/**" + - ".github/workflows/widgetbook.yaml" + +jobs: + build: + uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/flutter_package.yml@v1.16.0 + with: + min_coverage: 0 + working_directory: widgetbook diff --git a/widgetbook/.gitignore b/widgetbook/.gitignore new file mode 100644 index 0000000..29a3a50 --- /dev/null +++ b/widgetbook/.gitignore @@ -0,0 +1,43 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +**/ios/Flutter/.last_build_id +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +.pub-cache/ +.pub/ +/build/ + +# Symbolication related +app.*.symbols + +# Obfuscation related +app.*.map.json + +# Android Studio will place build artifacts here +/android/app/debug +/android/app/profile +/android/app/release diff --git a/widgetbook/.metadata b/widgetbook/.metadata new file mode 100644 index 0000000..de0ebcd --- /dev/null +++ b/widgetbook/.metadata @@ -0,0 +1,30 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: "b0366e0a3f089e15fd89c97604ab402fe26b724c" + channel: "stable" + +project_type: app + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: b0366e0a3f089e15fd89c97604ab402fe26b724c + base_revision: b0366e0a3f089e15fd89c97604ab402fe26b724c + - platform: web + create_revision: b0366e0a3f089e15fd89c97604ab402fe26b724c + base_revision: b0366e0a3f089e15fd89c97604ab402fe26b724c + + # User provided section + + # List of Local paths (relative to this file) that should be + # ignored by the migrate tool. + # + # Files that are not part of the templates will be ignored by default. + unmanaged_files: + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/widgetbook/README.md b/widgetbook/README.md new file mode 100644 index 0000000..8dbe811 --- /dev/null +++ b/widgetbook/README.md @@ -0,0 +1,3 @@ +# widgetbook + +Widgetbook for NES UI diff --git a/widgetbook/analysis_options.yaml b/widgetbook/analysis_options.yaml new file mode 100644 index 0000000..799268d --- /dev/null +++ b/widgetbook/analysis_options.yaml @@ -0,0 +1 @@ +include: package:very_good_analysis/analysis_options.5.1.0.yaml diff --git a/widgetbook/lib/main.dart b/widgetbook/lib/main.dart new file mode 100644 index 0000000..1ece278 --- /dev/null +++ b/widgetbook/lib/main.dart @@ -0,0 +1,6 @@ +import 'package:flutter/material.dart'; +import 'package:widgetbook_app/widgetbook/widgetbook.dart'; + +void main() { + runApp(const WidgetbookApp()); +} diff --git a/widgetbook/lib/widgetbook/use_cases/buttons.dart b/widgetbook/lib/widgetbook/use_cases/buttons.dart new file mode 100644 index 0000000..cd98ee9 --- /dev/null +++ b/widgetbook/lib/widgetbook/use_cases/buttons.dart @@ -0,0 +1,62 @@ +// ignore_for_file: public_member_api_docs + +import 'package:flutter/material.dart'; +import 'package:nes_ui/nes_ui.dart'; +import 'package:widgetbook_annotation/widgetbook_annotation.dart' as widgetbook; + +Widget build({ + required NesButtonType type, + required String text, +}) => + Center( + child: NesButton( + onPressed: () {}, + type: type, + child: Text(text), + ), + ); + +@widgetbook.UseCase( + name: 'normal', + type: NesButton, +) +Widget normal(BuildContext context) => build( + type: NesButtonType.normal, + text: 'Normal', + ); + +@widgetbook.UseCase( + name: 'primary', + type: NesButton, +) +Widget primary(BuildContext context) => build( + type: NesButtonType.primary, + text: 'Primary', + ); + +@widgetbook.UseCase( + name: 'success', + type: NesButton, +) +Widget success(BuildContext context) => build( + type: NesButtonType.success, + text: 'Success', + ); + +@widgetbook.UseCase( + name: 'warning', + type: NesButton, +) +Widget warning(BuildContext context) => build( + type: NesButtonType.warning, + text: 'Warning', + ); + +@widgetbook.UseCase( + name: 'error', + type: NesButton, +) +Widget error(BuildContext context) => build( + type: NesButtonType.error, + text: 'Error', + ); diff --git a/widgetbook/lib/widgetbook/use_cases/checkboxes.dart b/widgetbook/lib/widgetbook/use_cases/checkboxes.dart new file mode 100644 index 0000000..57ff06b --- /dev/null +++ b/widgetbook/lib/widgetbook/use_cases/checkboxes.dart @@ -0,0 +1,29 @@ +// ignore_for_file: public_member_api_docs + +import 'package:flutter/material.dart'; +import 'package:nes_ui/nes_ui.dart'; +import 'package:widgetbook_annotation/widgetbook_annotation.dart' as widgetbook; + +Widget build() { + var selected = false; + return Center( + child: StatefulBuilder( + builder: (context, setState) { + return NesCheckBox( + onChange: (value) { + setState(() { + selected = value; + }); + }, + value: selected, + ); + }, + ), + ); +} + +@widgetbook.UseCase( + name: 'default', + type: NesCheckBox, +) +Widget checkbox(BuildContext context) => build(); diff --git a/widgetbook/lib/widgetbook/widgetbook.dart b/widgetbook/lib/widgetbook/widgetbook.dart new file mode 100644 index 0000000..e1f4482 --- /dev/null +++ b/widgetbook/lib/widgetbook/widgetbook.dart @@ -0,0 +1,49 @@ +// ignore_for_file: public_member_api_docs + +import 'package:flutter/material.dart'; +import 'package:nes_ui/nes_ui.dart'; +import 'package:widgetbook/widgetbook.dart'; +import 'package:widgetbook_annotation/widgetbook_annotation.dart' as widgetbook; +import 'package:widgetbook_app/widgetbook/widgetbook.directories.g.dart'; +import 'package:widgetbook_app/widgetbook/widgets/widgets.dart'; + +@widgetbook.App() +class WidgetbookApp extends StatelessWidget { + const WidgetbookApp({super.key}); + + @override + Widget build(BuildContext context) { + return Widgetbook.material( + directories: directories, + integrations: [ + WidgetbookCloudIntegration(), + ], + addons: [ + BuilderAddon( + name: 'Decorator', + builder: (context, child) { + return UseCaseDecorator(child: child); + }, + ), + ThemeAddon( + themes: [ + WidgetbookTheme( + name: 'Light', + data: flutterNesTheme(), + ), + WidgetbookTheme( + name: 'Dark', + data: flutterNesTheme(brightness: Brightness.dark), + ), + ], + themeBuilder: (context, theme, child) { + return Theme( + data: theme, + child: child, + ); + }, + ), + ], + ); + } +} diff --git a/widgetbook/lib/widgetbook/widgetbook.directories.g.dart b/widgetbook/lib/widgetbook/widgetbook.directories.g.dart new file mode 100644 index 0000000..2b67b31 --- /dev/null +++ b/widgetbook/lib/widgetbook/widgetbook.directories.g.dart @@ -0,0 +1,54 @@ +// coverage:ignore-file +// ignore_for_file: type=lint +// ignore_for_file: unused_import, prefer_relative_imports, directives_ordering + +// GENERATED CODE - DO NOT MODIFY BY HAND + +// ************************************************************************** +// AppGenerator +// ************************************************************************** + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:widgetbook/widgetbook.dart' as _i1; +import 'package:widgetbook_app/widgetbook/use_cases/buttons.dart' as _i2; +import 'package:widgetbook_app/widgetbook/use_cases/checkboxes.dart' as _i3; + +final directories = <_i1.WidgetbookNode>[ + _i1.WidgetbookFolder( + name: 'widgets', + children: [ + _i1.WidgetbookComponent( + name: 'NesButton', + useCases: [ + _i1.WidgetbookUseCase( + name: 'error', + builder: _i2.error, + ), + _i1.WidgetbookUseCase( + name: 'normal', + builder: _i2.normal, + ), + _i1.WidgetbookUseCase( + name: 'primary', + builder: _i2.primary, + ), + _i1.WidgetbookUseCase( + name: 'success', + builder: _i2.success, + ), + _i1.WidgetbookUseCase( + name: 'warning', + builder: _i2.warning, + ), + ], + ), + _i1.WidgetbookLeafComponent( + name: 'NesCheckBox', + useCase: _i1.WidgetbookUseCase( + name: 'default', + builder: _i3.checkbox, + ), + ), + ], + ) +]; diff --git a/widgetbook/lib/widgetbook/widgets/use_case_decorator.dart b/widgetbook/lib/widgetbook/widgets/use_case_decorator.dart new file mode 100644 index 0000000..058ca54 --- /dev/null +++ b/widgetbook/lib/widgetbook/widgets/use_case_decorator.dart @@ -0,0 +1,24 @@ +// ignore_for_file: public_member_api_docs + +import 'package:flutter/material.dart'; + +class UseCaseDecorator extends StatelessWidget { + const UseCaseDecorator({ + required this.child, + super.key, + }); + + final Widget child; + + @override + Widget build(BuildContext context) { + return DecoratedBox( + decoration: BoxDecoration( + color: Colors.grey[600], + ), + child: SizedBox.expand( + child: child, + ), + ); + } +} diff --git a/widgetbook/lib/widgetbook/widgets/widgets.dart b/widgetbook/lib/widgetbook/widgets/widgets.dart new file mode 100644 index 0000000..a4827d8 --- /dev/null +++ b/widgetbook/lib/widgetbook/widgets/widgets.dart @@ -0,0 +1 @@ +export 'use_case_decorator.dart'; diff --git a/widgetbook/pubspec.yaml b/widgetbook/pubspec.yaml new file mode 100644 index 0000000..0017daa --- /dev/null +++ b/widgetbook/pubspec.yaml @@ -0,0 +1,28 @@ +name: widgetbook_app +description: "Widgetbook for NES UI" + +publish_to: 'none' # Remove this line if you wish to publish to pub.dev + +version: 1.0.0+1 + +environment: + sdk: '>=3.2.3 <4.0.0' + +dependencies: + cupertino_icons: ^1.0.2 + flutter: + sdk: flutter + nes_ui: + path: .. + widgetbook: ^3.7.0 + widgetbook_annotation: ^3.1.0 + +dev_dependencies: + build_runner: ^2.4.7 + flutter_test: + sdk: flutter + very_good_analysis: ">=3.1.0 <6.0.0" + widgetbook_generator: ^3.7.0 + +flutter: + uses-material-design: true diff --git a/widgetbook/test/widgetbook_test.dart b/widgetbook/test/widgetbook_test.dart new file mode 100644 index 0000000..d5cd8d7 --- /dev/null +++ b/widgetbook/test/widgetbook_test.dart @@ -0,0 +1,12 @@ +// ignore_for_file: prefer_const_constructors + +import 'package:flutter_test/flutter_test.dart'; +import 'package:widgetbook_app/widgetbook/widgetbook.dart'; + +void main() { + testWidgets('renders', (WidgetTester tester) async { + await tester.pumpWidget(WidgetbookApp()); + + expect(find.byType(WidgetbookApp), findsOneWidget); + }); +} diff --git a/widgetbook/web/favicon.png b/widgetbook/web/favicon.png new file mode 100644 index 0000000..8aaa46a Binary files /dev/null and b/widgetbook/web/favicon.png differ diff --git a/widgetbook/web/icons/Icon-192.png b/widgetbook/web/icons/Icon-192.png new file mode 100644 index 0000000..b749bfe Binary files /dev/null and b/widgetbook/web/icons/Icon-192.png differ diff --git a/widgetbook/web/icons/Icon-512.png b/widgetbook/web/icons/Icon-512.png new file mode 100644 index 0000000..88cfd48 Binary files /dev/null and b/widgetbook/web/icons/Icon-512.png differ diff --git a/widgetbook/web/icons/Icon-maskable-192.png b/widgetbook/web/icons/Icon-maskable-192.png new file mode 100644 index 0000000..eb9b4d7 Binary files /dev/null and b/widgetbook/web/icons/Icon-maskable-192.png differ diff --git a/widgetbook/web/icons/Icon-maskable-512.png b/widgetbook/web/icons/Icon-maskable-512.png new file mode 100644 index 0000000..d69c566 Binary files /dev/null and b/widgetbook/web/icons/Icon-maskable-512.png differ diff --git a/widgetbook/web/index.html b/widgetbook/web/index.html new file mode 100644 index 0000000..260b7b0 --- /dev/null +++ b/widgetbook/web/index.html @@ -0,0 +1,59 @@ + + +
+ +