Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Widget Catalog with widgetbook #498

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .cspell/framework-words.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ unawaited
unfocus
utsname
vsync
widgetbook
wireframe
xcarchive
xcconfig
Expand Down
7 changes: 7 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "widget_catalog",
"cwd": "packages/widget_catalog",
"program": "lib/main.dart",
"request": "launch",
"type": "dart"
},
{
"name": "flutter_app dev-debug",
"cwd": "packages/flutter_app",
Expand Down
55 changes: 55 additions & 0 deletions packages/widget_catalog/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
migrate_working_dir/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# Editor User Setting Files
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets
*.code-workspace
!default.code-workspace
.classpath
.project

# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub-cache/
.pub/
/build/
flutter_*.png
linked_*.ds
unlinked.ds
unlinked_spec.ds

# 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
33 changes: 33 additions & 0 deletions packages/widget_catalog/.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# 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: "5874a72aa4c779a02553007c47dacbefba2374dc"
channel: "stable"

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: 5874a72aa4c779a02553007c47dacbefba2374dc
base_revision: 5874a72aa4c779a02553007c47dacbefba2374dc
- platform: macos
create_revision: 5874a72aa4c779a02553007c47dacbefba2374dc
base_revision: 5874a72aa4c779a02553007c47dacbefba2374dc
- platform: web
create_revision: 5874a72aa4c779a02553007c47dacbefba2374dc
base_revision: 5874a72aa4c779a02553007c47dacbefba2374dc

# 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'
3 changes: 3 additions & 0 deletions packages/widget_catalog/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Widget Catalog

Widget Catalog with flutter_app_template.
8 changes: 8 additions & 0 deletions packages/widget_catalog/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
include: package:altive_lints/altive_lints.yaml
analyzer:
plugins:
- custom_lint
linter:
rules:
# Because WidgetCatalog often does not use the public methods you define from other places.
- public_member_api_docs: false
8 changes: 8 additions & 0 deletions packages/widget_catalog/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
targets:
$default:
builders:
widgetbook_generator:use_case_builder:
generate_for:
- lib/widgets/**
widgetbook_generator:telemetry:
enabled: false
64 changes: 64 additions & 0 deletions packages/widget_catalog/lib/main.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:themes/themes.dart';
import 'package:widgetbook/widgetbook.dart';
import 'package:widgetbook_annotation/widgetbook_annotation.dart';

import 'main.directories.g.dart';

void main() {
runApp(const MainApp());
}

/// Widget Catalog app.
@App()
class MainApp extends StatelessWidget {
/// Creates a new instance of [MainApp].
const MainApp({super.key});

@override
Widget build(BuildContext context) {
return Widgetbook.material(
directories: directories,
lightTheme: lightThemeData,
darkTheme: darkThemeData,
addons: [
MaterialThemeAddon(
themes: [
WidgetbookTheme(name: 'Light', data: lightThemeData),
WidgetbookTheme(name: 'Dark', data: darkThemeData),
],
),
TextScaleAddon(
scales: [1.0, 2.0],
),
LocalizationAddon(
locales: [
const Locale('en', 'US'),
const Locale('ja', 'JP'),
],
localizationsDelegates: [
DefaultWidgetsLocalizations.delegate,
DefaultMaterialLocalizations.delegate,
DefaultCupertinoLocalizations.delegate,
],
),
InspectorAddon(enabled: true),
DeviceFrameAddon(
initialDevice: Devices.ios.iPhoneSE,
devices: [
Devices.ios.iPhoneSE,
Devices.ios.iPhone13ProMax,
],
),
GridAddon(44),
AlignmentAddon(),
],
appBuilder: (context, child) {
return Scaffold(
body: child,
);
},
);
}
}
60 changes: 60 additions & 0 deletions packages/widget_catalog/lib/main.directories.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions packages/widget_catalog/lib/widgets/apple_auth_button.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import 'package:convenient_widgets/convenient_widgets.dart';
import 'package:flutter/material.dart';
import 'package:widgetbook/widgetbook.dart';
import 'package:widgetbook_annotation/widgetbook_annotation.dart';

@UseCase(
name: 'Default',
type: AppleAuthButton,
path: '[Interactions]/buttons',
)
Widget appleAuthButton(BuildContext context) {
return AppleAuthButton(
onPressed: () {},
labelText: context.knobs.string(
label: 'Button label',
description: 'The text displayed on the button',
initialValue: 'Sign in with Apple',
),
);
}
27 changes: 27 additions & 0 deletions packages/widget_catalog/lib/widgets/bubble_border.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import 'package:convenient_widgets/convenient_widgets.dart';
import 'package:flutter/material.dart';
import 'package:widgetbook_annotation/widgetbook_annotation.dart';

@UseCase(name: 'Left', type: ShapeDecoration)
Widget leftBubbleBorder(BuildContext context) {
return Container(
width: 100,
height: 100,
decoration: ShapeDecoration(
shape: const BubbleBorder(),
color: Theme.of(context).colorScheme.surface,
),
);
}

@UseCase(name: 'Right', type: ShapeDecoration)
Widget rightBubbleBorder(BuildContext context) {
return Container(
width: 100,
height: 100,
decoration: ShapeDecoration(
shape: const BubbleBorder(destination: Destination.right),
color: Theme.of(context).colorScheme.surface,
),
);
}
20 changes: 20 additions & 0 deletions packages/widget_catalog/lib/widgets/google_auth_button.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import 'package:convenient_widgets/convenient_widgets.dart';
import 'package:flutter/material.dart';
import 'package:widgetbook/widgetbook.dart';
import 'package:widgetbook_annotation/widgetbook_annotation.dart';

@UseCase(
name: 'Default',
type: GoogleAuthButton,
path: '[Interactions]/buttons',
)
Widget googleAuthButton(BuildContext context) {
return GoogleAuthButton(
onPressed: () {},
labelText: context.knobs.string(
label: 'Button label',
description: 'The text displayed on the button',
initialValue: 'Sign in with Google',
),
);
}
7 changes: 7 additions & 0 deletions packages/widget_catalog/macos/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Flutter-related
**/Flutter/ephemeral/
**/Pods/

# Xcode-related
**/dgph
**/xcuserdata/
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "ephemeral/Flutter-Generated.xcconfig"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "ephemeral/Flutter-Generated.xcconfig"
Loading