Skip to content

Commit

Permalink
fix: Widgetbook run / build (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
thelukewalton authored Feb 7, 2024
1 parent 94844c1 commit a2347ad
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 29 deletions.
4 changes: 2 additions & 2 deletions example/widgetbook/components/accordion_widgetbook.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:widgetbook/widgetbook.dart';
import 'package:zeta_flutter/zeta_flutter.dart';

import '../../test/test_components.dart';
import '../test/test_components.dart';

WidgetbookComponent accordionWidgetBook() {
return WidgetbookComponent(
Expand All @@ -11,7 +11,7 @@ WidgetbookComponent accordionWidgetBook() {
useCases: [
WidgetbookUseCase(
name: 'Accordion',
builder: (context) => TestWidget(
builder: (context) => WidgetbookTestWidget(
themeMode: ThemeMode.dark,
widget: Padding(
padding: const EdgeInsets.all(20),
Expand Down
6 changes: 3 additions & 3 deletions example/widgetbook/components/avatar_widgetbook.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:widgetbook/widgetbook.dart';
import 'package:zeta_flutter/zeta_flutter.dart';

import '../../test/test_components.dart';
import '../test/test_components.dart';

WidgetbookComponent avatarWidgetBook() {
return WidgetbookComponent(
Expand All @@ -14,7 +14,7 @@ WidgetbookComponent avatarWidgetBook() {
builder: (context) {
final Widget image = Image.network('https://i.ytimg.com/vi/KItsWUzFUOs/maxresdefault.jpg', fit: BoxFit.cover);

return TestWidget(
return WidgetbookTestWidget(
themeMode: ThemeMode.dark,
widget: Column(
children: [
Expand All @@ -39,7 +39,7 @@ WidgetbookComponent avatarWidgetBook() {
WidgetbookUseCase(
name: 'Initials Avatar',
builder: (context) {
return TestWidget(
return WidgetbookTestWidget(
themeMode: ThemeMode.dark,
widget: Column(
children: [
Expand Down
14 changes: 7 additions & 7 deletions example/widgetbook/components/badges_widgetbook.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:widgetbook/widgetbook.dart';
import 'package:zeta_flutter/zeta_flutter.dart';

import '../../test/test_components.dart';
import '../test/test_components.dart';

WidgetbookComponent badgeWidgetBook() {
return WidgetbookComponent(
Expand All @@ -12,7 +12,7 @@ WidgetbookComponent badgeWidgetBook() {
WidgetbookUseCase(
name: 'Status Label',
builder: (context) {
return TestWidget(
return WidgetbookTestWidget(
themeMode: ThemeMode.dark,
widget: Column(
children: [
Expand Down Expand Up @@ -47,7 +47,7 @@ WidgetbookComponent badgeWidgetBook() {
),
WidgetbookUseCase(
name: 'Priority Pill',
builder: (context) => TestWidget(
builder: (context) => WidgetbookTestWidget(
themeMode: ThemeMode.dark,
widget: Column(
children: [
Expand All @@ -65,7 +65,7 @@ WidgetbookComponent badgeWidgetBook() {
),
WidgetbookUseCase(
name: 'Badge',
builder: (context) => TestWidget(
builder: (context) => WidgetbookTestWidget(
themeMode: ThemeMode.dark,
widget: Row(
mainAxisAlignment: MainAxisAlignment.center,
Expand All @@ -84,7 +84,7 @@ WidgetbookComponent badgeWidgetBook() {
),
WidgetbookUseCase(
name: 'Indicators',
builder: (context) => TestWidget(
builder: (context) => WidgetbookTestWidget(
themeMode: ThemeMode.dark,
widget: Column(
mainAxisAlignment: MainAxisAlignment.center,
Expand Down Expand Up @@ -120,7 +120,7 @@ WidgetbookComponent badgeWidgetBook() {
),
WidgetbookUseCase(
name: 'Tags',
builder: (context) => TestWidget(
builder: (context) => WidgetbookTestWidget(
themeMode: ThemeMode.dark,
widget: Column(
mainAxisAlignment: MainAxisAlignment.center,
Expand All @@ -139,7 +139,7 @@ WidgetbookComponent badgeWidgetBook() {
),
WidgetbookUseCase(
name: 'Workcloud Indicators',
builder: (context) => TestWidget(
builder: (context) => WidgetbookTestWidget(
themeMode: ThemeMode.dark,
widget: Row(
mainAxisAlignment: MainAxisAlignment.center,
Expand Down
6 changes: 3 additions & 3 deletions example/widgetbook/components/banner_widgetbook.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:widgetbook/widgetbook.dart';
import 'package:zeta_flutter/zeta_flutter.dart';

import '../../test/test_components.dart';
import '../test/test_components.dart';

WidgetbookComponent BannerWidgetBook() {
return WidgetbookComponent(
Expand All @@ -11,7 +11,7 @@ WidgetbookComponent BannerWidgetBook() {
useCases: [
WidgetbookUseCase(
name: 'System Banner',
builder: (context) => TestWidget(
builder: (context) => WidgetbookTestWidget(
widget: Padding(
padding: EdgeInsets.all(20),
child: Column(
Expand Down Expand Up @@ -48,7 +48,7 @@ WidgetbookComponent BannerWidgetBook() {
),
WidgetbookUseCase(
name: 'In Page Banner',
builder: (context) => TestWidget(
builder: (context) => WidgetbookTestWidget(
themeMode: ThemeMode.dark,
widget: Padding(
padding: EdgeInsets.all(20),
Expand Down
6 changes: 3 additions & 3 deletions example/widgetbook/components/bottom_sheet_widgetbook.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:widgetbook/widgetbook.dart';
import 'package:zeta_flutter/zeta_flutter.dart';

import '../../test/test_components.dart';
import '../test/test_components.dart';

WidgetbookComponent bottomSheetWidgetBook() {
return WidgetbookComponent(
Expand All @@ -11,7 +11,7 @@ WidgetbookComponent bottomSheetWidgetBook() {
useCases: [
WidgetbookUseCase(
name: 'Content',
builder: (context) => TestWidget(
builder: (context) => WidgetbookTestWidget(
themeMode: ThemeMode.dark,
widget: Padding(
padding: const EdgeInsets.all(20),
Expand All @@ -23,7 +23,7 @@ WidgetbookComponent bottomSheetWidgetBook() {
name: 'Live',
builder: (context) {
final sheet = _bottomSheet(context);
return TestWidget(
return WidgetbookTestWidget(
themeMode: ThemeMode.dark,
widget: Padding(
padding: const EdgeInsets.all(20),
Expand Down
6 changes: 3 additions & 3 deletions example/widgetbook/components/button_widgetbook.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:widgetbook/widgetbook.dart';
import 'package:zeta_flutter/zeta_flutter.dart';

import '../../test/test_components.dart';
import '../test/test_components.dart';

WidgetbookComponent buttonWidgetBook() {
return WidgetbookComponent(
Expand All @@ -12,7 +12,7 @@ WidgetbookComponent buttonWidgetBook() {
WidgetbookUseCase(
name: 'Button',
builder: (context) {
return TestWidget(
return WidgetbookTestWidget(
widget: Padding(
padding: EdgeInsets.all(20),
child: ZetaButton(
Expand All @@ -28,7 +28,7 @@ WidgetbookComponent buttonWidgetBook() {
),
WidgetbookUseCase(
name: 'Floating Action Button',
builder: (context) => TestWidget(
builder: (context) => WidgetbookTestWidget(
widget: Padding(padding: EdgeInsets.all(20), child: FabWidget(context)),
),
)
Expand Down
4 changes: 2 additions & 2 deletions example/widgetbook/components/checkbox_widgetbook.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:widgetbook/widgetbook.dart';
import 'package:zeta_flutter/zeta_flutter.dart';

import '../../test/test_components.dart';
import '../test/test_components.dart';

WidgetbookComponent checkboxWidgetBook() {
return WidgetbookComponent(
Expand All @@ -11,7 +11,7 @@ WidgetbookComponent checkboxWidgetBook() {
useCases: [
WidgetbookUseCase(
name: 'Checkbox',
builder: (context) => TestWidget(
builder: (context) => WidgetbookTestWidget(
widget: Column(
children: [
Padding(
Expand Down
8 changes: 4 additions & 4 deletions example/widgetbook/components/chip_widgetbook.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:widgetbook/widgetbook.dart';
import 'package:zeta_flutter/zeta_flutter.dart';

import '../../test/test_components.dart';
import '../test/test_components.dart';

WidgetbookComponent chipWidgetBook() {
return WidgetbookComponent(
Expand All @@ -29,7 +29,7 @@ WidgetbookComponent chipWidgetBook() {
return '';
},
);
return TestWidget(
return WidgetbookTestWidget(
widget: ZetaInputChip(
label: context.knobs.string(label: 'Label', initialValue: 'Label'),
leading: context.knobs.boolean(label: 'Avatar')
Expand All @@ -46,7 +46,7 @@ WidgetbookComponent chipWidgetBook() {
),
WidgetbookUseCase(
name: 'Filter Chip',
builder: (context) => TestWidget(
builder: (context) => WidgetbookTestWidget(
widget: Padding(
padding: const EdgeInsets.all(20),
child: Column(
Expand All @@ -63,7 +63,7 @@ WidgetbookComponent chipWidgetBook() {
),
WidgetbookUseCase(
name: 'Assist Chip',
builder: (context) => TestWidget(
builder: (context) => WidgetbookTestWidget(
widget: Padding(
padding: const EdgeInsets.all(20),
child: Column(
Expand Down
4 changes: 2 additions & 2 deletions example/widgetbook/components/password_input_widgetbook.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:widgetbook/widgetbook.dart';
import 'package:zeta_flutter/zeta_flutter.dart';

import '../../test/test_components.dart';
import '../test/test_components.dart';

WidgetbookComponent passwordInputWidgetBook() {
return WidgetbookComponent(
Expand Down Expand Up @@ -36,7 +36,7 @@ class _PasswordState extends State<_Password> {
final validationString = context.knobs.string(label: 'Error label', initialValue: 'Incorrect');
return Form(
key: _formKey,
child: TestWidget(
child: WidgetbookTestWidget(
widget: Padding(
padding: EdgeInsets.all(ZetaSpacing.x5),
child: Column(
Expand Down
57 changes: 57 additions & 0 deletions example/widgetbook/test/test_components.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import 'package:flutter/material.dart';
import 'package:zeta_flutter/zeta_flutter.dart';

class WidgetbookTestWidget extends StatelessWidget {
final Size? screenSize;
final Widget widget;
final ThemeMode? themeMode;
final bool removeBody;

const WidgetbookTestWidget({
required this.widget,
this.screenSize,
super.key,
this.themeMode,
this.removeBody = false,
});

@override
Widget build(BuildContext context) {
final size = screenSize ?? const Size(1280, 720);

return ZetaProvider(
initialThemeMode: themeMode ?? ThemeMode.system,
builder: (context, theme, __) {
return Builder(
builder: (context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData(
fontFamily: theme.fontFamily,
colorScheme: theme.colorsLight.toScheme(),
textTheme: zetaTextTheme,
),
darkTheme: ThemeData(
fontFamily: theme.fontFamily,
colorScheme: theme.colorsDark.toScheme(),
textTheme: zetaTextTheme,
),
home: Scaffold(
body: removeBody
? widget
: SizedBox(
width: size.width,
height: size.height,
child: MediaQuery(
data: MediaQueryData(size: Size(size.width, size.height)),
child: SingleChildScrollView(child: widget),
),
),
),
);
},
);
},
);
}
}

0 comments on commit a2347ad

Please sign in to comment.