Skip to content
This repository has been archived by the owner on Feb 9, 2024. It is now read-only.

Commit

Permalink
Oops - forgot to add widgetbook theme
Browse files Browse the repository at this point in the history
  • Loading branch information
rh-concordium committed Dec 19, 2023
1 parent 0a327ee commit de8054c
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/design_system/components/buttons/button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Button extends StatelessWidget {
final BoxDecoration decoration;
final double width;
final double height;
final CcdTheme? theme;

const Button({
super.key,
Expand All @@ -29,6 +30,7 @@ class Button extends StatelessWidget {
this.decoration = _defaultButtonDecoration,
this.width = double.infinity,
this.height = 40,
this.theme,
});

@override
Expand All @@ -38,7 +40,7 @@ class Button extends StatelessWidget {
boxShadow: _boxShadow,
);
final enabled = onTap != null;
final theme = context.theme;
final theme = this.theme ?? context.theme;

return GestureDetector(
onTap: onTap,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:concordium_wallet/design_system/components/account_summary_card/account_summary_card.dart';
import 'package:concordium_wallet/design_system/components/account_summary_card/card_decorations.dart';
import 'package:concordium_wallet/widgetbook/helpers/ccd_widgetbook_theme.dart';
import 'package:concordium_wallet/widgetbook/helpers/default_component.dart';
import 'package:flutter/widgets.dart';
import 'package:widgetbook/widgetbook.dart';
Expand All @@ -17,5 +18,6 @@ class ViewAccountSummaryCard extends DefaultComponent {
fiatAmount: context.knobs.double.input(label: 'dollar amount', initialValue: 100),
decoration: context.knobs.list(label: 'gradients', options: [CardDecorations.teal, CardDecorations.orange, CardDecorations.purple]),
balanceLabel: context.knobs.string(label: 'balanceLabel', initialValue: 'Total Wallet Balance'),
theme: context.widgetBookTheme,
);
}
15 changes: 15 additions & 0 deletions lib/widgetbook/components/buttons/view_button.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import 'package:concordium_wallet/design_system/components/buttons/button.dart';
import 'package:concordium_wallet/widgetbook/helpers/ccd_widgetbook_theme.dart';
import 'package:concordium_wallet/widgetbook/helpers/default_component.dart';
import 'package:flutter/widgets.dart';
import 'package:widgetbook/widgetbook.dart';

class ViewButton extends DefaultComponent {
ViewButton() : super(name: 'Button');

@override
Widget buildDefault(BuildContext context) => Button(
text: context.knobs.string(label: 'Text', initialValue: 'Label'),
theme: context.widgetBookTheme,
);
}
2 changes: 2 additions & 0 deletions lib/widgetbook/components/component_folder.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import 'package:concordium_wallet/widgetbook/components/account_summary_card/view_account_summary_card.dart';
import 'package:concordium_wallet/widgetbook/components/buttons/view_button.dart';
import 'package:concordium_wallet/widgetbook/helpers/default_folder.dart';

class ComponentFolder extends DefaultFolder {
ComponentFolder()
: super(name: 'Components', children: [
ViewAccountSummaryCard().component,
ViewButton().component,
]);
}
4 changes: 4 additions & 0 deletions lib/widgetbook/helpers/ccd_widgetbook_theme.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import 'package:concordium_wallet/design_system/ccd_theme.dart';
import 'package:flutter/widgets.dart';

extension ThemeGetter on BuildContext {
CcdTheme get widgetBookTheme => CcdWidgetbookTheme.of(this);
}

class CcdWidgetbookTheme extends InheritedWidget {
const CcdWidgetbookTheme({
super.key,
Expand Down

0 comments on commit de8054c

Please sign in to comment.