From 2fd056f13b6887c5ca862fa2aca8d21ad7b0f642 Mon Sep 17 00:00:00 2001 From: Erick Zanardo Date: Wed, 19 Jun 2024 10:17:02 -0300 Subject: [PATCH] feat: adding widgetbook use cases for texts --- .../lib/widgetbook/use_cases/typography.dart | 110 ++++++++++++++++++ .../widgetbook/widgetbook.directories.g.dart | 36 +++++- 2 files changed, 141 insertions(+), 5 deletions(-) create mode 100644 widgetbook/lib/widgetbook/use_cases/typography.dart diff --git a/widgetbook/lib/widgetbook/use_cases/typography.dart b/widgetbook/lib/widgetbook/use_cases/typography.dart new file mode 100644 index 0000000..d46109a --- /dev/null +++ b/widgetbook/lib/widgetbook/use_cases/typography.dart @@ -0,0 +1,110 @@ +// 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 List textStyles, + required List texts, +}) => + Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + for (var i = 0; i < textStyles.length; i++) + Padding( + padding: const EdgeInsets.all(8), + child: Text( + texts[i], + style: textStyles[i], + ), + ), + ], + ), + ); + +@widgetbook.UseCase( + name: 'body', + type: Text, +) +Widget body(BuildContext context) => build( + textStyles: [ + Theme.of(context).textTheme.bodySmall, + Theme.of(context).textTheme.bodyMedium, + Theme.of(context).textTheme.bodyLarge, + ], + texts: [ + 'Body Small', + 'Body Medium', + 'Body Large', + ], + ); + +@widgetbook.UseCase( + name: 'display', + type: Text, +) +Widget display(BuildContext context) => build( + textStyles: [ + Theme.of(context).textTheme.displaySmall, + Theme.of(context).textTheme.displayMedium, + Theme.of(context).textTheme.displayLarge, + ], + texts: [ + 'Display Small', + 'Display Medium', + 'Display Large', + ], + ); + +@widgetbook.UseCase( + name: 'headline', + type: Text, +) +Widget headline(BuildContext context) => build( + textStyles: [ + Theme.of(context).textTheme.headlineSmall, + Theme.of(context).textTheme.headlineMedium, + Theme.of(context).textTheme.headlineLarge, + ], + texts: [ + 'Headline Small', + 'Headline Medium', + 'Headline Large', + ], + ); + +@widgetbook.UseCase( + name: 'title', + type: Text, +) +Widget title(BuildContext context) => build( + textStyles: [ + Theme.of(context).textTheme.titleSmall, + Theme.of(context).textTheme.titleMedium, + Theme.of(context).textTheme.titleLarge, + ], + texts: [ + 'Title Small', + 'Title Medium', + 'Title Large', + ], + ); + +@widgetbook.UseCase( + name: 'label', + type: Text, +) +Widget label(BuildContext context) => build( + textStyles: [ + Theme.of(context).textTheme.labelSmall, + Theme.of(context).textTheme.labelMedium, + Theme.of(context).textTheme.labelLarge, + ], + texts: [ + 'Label Small', + 'Label Medium', + 'Label Large', + ], + ); diff --git a/widgetbook/lib/widgetbook/widgetbook.directories.g.dart b/widgetbook/lib/widgetbook/widgetbook.directories.g.dart index 63d6b6b..b628682 100644 --- a/widgetbook/lib/widgetbook/widgetbook.directories.g.dart +++ b/widgetbook/lib/widgetbook/widgetbook.directories.g.dart @@ -12,9 +12,10 @@ 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; -import 'package:widgetbook_app/widgetbook/use_cases/containers.dart' as _i6; +import 'package:widgetbook_app/widgetbook/use_cases/containers.dart' as _i7; import 'package:widgetbook_app/widgetbook/use_cases/dropdown_menus.dart' as _i4; import 'package:widgetbook_app/widgetbook/use_cases/running_texts.dart' as _i5; +import 'package:widgetbook_app/widgetbook/use_cases/typography.dart' as _i6; final directories = <_i1.WidgetbookNode>[ _i1.WidgetbookFolder( @@ -79,6 +80,31 @@ final directories = <_i1.WidgetbookNode>[ builder: _i5.lines, ), ), + _i1.WidgetbookComponent( + name: 'Text', + useCases: [ + _i1.WidgetbookUseCase( + name: 'body', + builder: _i6.body, + ), + _i1.WidgetbookUseCase( + name: 'display', + builder: _i6.display, + ), + _i1.WidgetbookUseCase( + name: 'headline', + builder: _i6.headline, + ), + _i1.WidgetbookUseCase( + name: 'label', + builder: _i6.label, + ), + _i1.WidgetbookUseCase( + name: 'title', + builder: _i6.title, + ), + ], + ), _i1.WidgetbookFolder( name: 'containers', children: [ @@ -87,19 +113,19 @@ final directories = <_i1.WidgetbookNode>[ useCases: [ _i1.WidgetbookUseCase( name: 'default', - builder: _i6.normal, + builder: _i7.normal, ), _i1.WidgetbookUseCase( name: 'with corner inner square painter', - builder: _i6.cornerInnerSquare, + builder: _i7.cornerInnerSquare, ), _i1.WidgetbookUseCase( name: 'with label', - builder: _i6.label, + builder: _i7.label, ), _i1.WidgetbookUseCase( name: 'with square corner painter', - builder: _i6.squareConer, + builder: _i7.squareConer, ), ], )