-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* create menu item * menu item * review names
- Loading branch information
1 parent
e263b47
commit 405a068
Showing
9 changed files
with
659 additions
and
14 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
packages/remix/demo/lib/components/menu_item_use_case.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import 'package:demo/helpers/knob_builder.dart'; | ||
import 'package:flutter/material.dart' hide Scaffold; | ||
import 'package:remix/remix.dart'; | ||
import 'package:widgetbook/widgetbook.dart'; | ||
import 'package:widgetbook_annotation/widgetbook_annotation.dart' as widgetbook; | ||
|
||
final _key = GlobalKey(); | ||
|
||
@widgetbook.UseCase( | ||
name: 'Menu Item Component', | ||
type: MenuItem, | ||
) | ||
Widget buildButtonUseCase(BuildContext context) { | ||
return KeyedSubtree( | ||
key: _key, | ||
child: Scaffold( | ||
body: Center( | ||
child: SizedBox( | ||
width: 350, | ||
child: MenuItem( | ||
variants: [ | ||
context.knobs.variant(FortalezaButtonStyle.variants), | ||
], | ||
title: context.knobs.string( | ||
label: 'Title', | ||
initialValue: 'Menu Item', | ||
), | ||
subtitle: context.knobs.stringOrNull( | ||
label: 'Subtitle', | ||
initialValue: 'Subtitle', | ||
), | ||
onPress: () {}, | ||
disabled: context.knobs.boolean( | ||
label: 'Disabled', | ||
initialValue: false, | ||
), | ||
leadingWidgetBuilder: (icon) => context.knobs.boolean( | ||
label: 'Show leading widget', | ||
initialValue: false, | ||
) | ||
? Avatar(fallbackBuilder: (spec) => spec('LF')) | ||
: const SizedBox.shrink(), | ||
trailingWidgetBuilder: (icon) => context.knobs.boolean( | ||
label: 'Show trailing widget', | ||
initialValue: false, | ||
) | ||
? icon(Icons.chevron_right) | ||
: const SizedBox.shrink(), | ||
), | ||
), | ||
), | ||
), | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
packages/remix/lib/src/components/menu_item/menu_item.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import 'package:flutter/foundation.dart'; | ||
import 'package:flutter/widgets.dart'; | ||
import 'package:mix/mix.dart'; | ||
import 'package:mix_annotations/mix_annotations.dart'; | ||
|
||
import '../../helpers/component_builder.dart'; | ||
import '../../theme/remix_theme.dart'; | ||
import '../../theme/remix_tokens.dart'; | ||
|
||
part 'menu_item.g.dart'; | ||
part 'menu_item_style.dart'; | ||
part 'menu_item_theme.dart'; | ||
part 'menu_item_widget.dart'; | ||
|
||
@MixableSpec() | ||
class MenuItemSpec extends Spec<MenuItemSpec> | ||
with _$MenuItemSpec, Diagnosticable { | ||
final BoxSpec outerContainer; | ||
final FlexSpec contentLayout; | ||
final FlexSpec titleSubtitleLayout; | ||
final IconSpec icon; | ||
final TextSpec title; | ||
final TextSpec subtitle; | ||
|
||
/// {@macro button_spec_of} | ||
static const of = _$MenuItemSpec.of; | ||
|
||
static const from = _$MenuItemSpec.from; | ||
|
||
const MenuItemSpec({ | ||
BoxSpec? outerContainer, | ||
FlexSpec? contentLayout, | ||
FlexSpec? titleSubtitleLayout, | ||
IconSpec? icon, | ||
TextSpec? title, | ||
TextSpec? subtitle, | ||
super.modifiers, | ||
super.animated, | ||
}) : outerContainer = outerContainer ?? const BoxSpec(), | ||
contentLayout = contentLayout ?? const FlexSpec(), | ||
titleSubtitleLayout = titleSubtitleLayout ?? const FlexSpec(), | ||
icon = icon ?? const IconSpec(), | ||
title = title ?? const TextSpec(), | ||
subtitle = subtitle ?? const TextSpec(); | ||
|
||
@override | ||
void debugFillProperties(DiagnosticPropertiesBuilder properties) { | ||
super.debugFillProperties(properties); | ||
_debugFillProperties(properties); | ||
} | ||
} |
Oops, something went wrong.