-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
387 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:zeta_example/widgets.dart'; | ||
import 'package:zeta_flutter/zeta_flutter.dart'; | ||
|
||
class ListItemExample extends StatefulWidget { | ||
static const String name = 'ListItem'; | ||
|
||
const ListItemExample({super.key}); | ||
|
||
@override | ||
State<ListItemExample> createState() => _ListItemExampleState(); | ||
} | ||
|
||
class _ListItemExampleState extends State<ListItemExample> { | ||
bool _isCheckBoxEnabled = false; | ||
bool _isSelected = true; | ||
|
||
_onDefaultListItemTap() { | ||
setState(() => _isCheckBoxEnabled = !_isCheckBoxEnabled); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final zetaColors = Zeta.of(context).colors; | ||
|
||
return ExampleScaffold( | ||
name: ListItemExample.name, | ||
child: Container( | ||
color: zetaColors.surfaceSecondary, | ||
child: SingleChildScrollView( | ||
child: Column( | ||
children: [ | ||
// List Item with descriptor | ||
Padding( | ||
padding: const EdgeInsets.only(top: ZetaSpacing.x4), | ||
child: ZetaListItem( | ||
dense: true, | ||
leading: Container( | ||
width: 48, | ||
height: 48, | ||
decoration: BoxDecoration(borderRadius: ZetaRadius.rounded), | ||
child: Placeholder(), | ||
), | ||
subtitle: Text("Descriptor"), | ||
title: Text("List Item"), | ||
trailing: ZetaCheckbox( | ||
value: _isCheckBoxEnabled, | ||
onChanged: (_) => _onDefaultListItemTap(), | ||
), | ||
onTap: _onDefaultListItemTap, | ||
), | ||
), | ||
|
||
// Enabled | ||
Padding( | ||
padding: const EdgeInsets.only(top: ZetaSpacing.l), | ||
child: Text( | ||
"Enabled", | ||
style: ZetaTextStyles.titleLarge, | ||
), | ||
), | ||
Padding( | ||
padding: const EdgeInsets.only(top: ZetaSpacing.m), | ||
child: ZetaListItem(title: Text("List Item")), | ||
), | ||
|
||
// Selected | ||
Padding( | ||
padding: const EdgeInsets.only(top: ZetaSpacing.l), | ||
child: Padding( | ||
padding: const EdgeInsets.all(8.0), | ||
child: Text( | ||
"Selected", | ||
style: ZetaTextStyles.titleLarge, | ||
), | ||
), | ||
), | ||
Padding( | ||
padding: const EdgeInsets.only(top: ZetaSpacing.m), | ||
child: ZetaListItem( | ||
title: Text("List Item"), | ||
selected: _isSelected, | ||
trailing: _isSelected | ||
? Icon( | ||
ZetaIcons.check_mark_sharp, | ||
color: zetaColors.primary, | ||
) | ||
: null, | ||
onTap: () => setState(() => _isSelected = !_isSelected), | ||
), | ||
), | ||
|
||
// Disabled | ||
Padding( | ||
padding: const EdgeInsets.only(top: ZetaSpacing.l), | ||
child: Text( | ||
"Disabled", | ||
style: ZetaTextStyles.titleLarge, | ||
), | ||
), | ||
Padding( | ||
padding: const EdgeInsets.only(top: ZetaSpacing.m), | ||
child: ZetaListItem( | ||
title: Text("List Item"), | ||
enabled: false, | ||
onTap: () {}, | ||
), | ||
), | ||
], | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
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
49 changes: 49 additions & 0 deletions
49
example/widgetbook/pages/components/list_item_widgetbook.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,49 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:widgetbook/widgetbook.dart'; | ||
import 'package:zeta_flutter/zeta_flutter.dart'; | ||
|
||
import '../../test/test_components.dart'; | ||
|
||
Widget listItemUseCase(BuildContext context) { | ||
return WidgetbookTestWidget( | ||
widget: StatefulBuilder( | ||
builder: (context, setState) { | ||
final subtitle = | ||
context.knobs.stringOrNull(label: 'Descriptor', initialValue: null); | ||
|
||
final trailing = | ||
context.knobs.boolean(label: 'Trailing', initialValue: false) | ||
? Checkbox(value: false, onChanged: (_) {}) | ||
: null; | ||
|
||
final leading = | ||
context.knobs.boolean(label: 'Leading', initialValue: false) | ||
? Container( | ||
width: 48, | ||
height: 48, | ||
decoration: BoxDecoration(borderRadius: ZetaRadius.rounded), | ||
child: Placeholder(), | ||
) | ||
: null; | ||
|
||
return ZetaListItem( | ||
dense: context.knobs.boolean(label: 'Dense', initialValue: false), | ||
enabled: context.knobs.boolean(label: 'Enabled', initialValue: true), | ||
enabledDivider: context.knobs.boolean( | ||
label: 'Enabled Divider', | ||
initialValue: true, | ||
), | ||
selected: | ||
context.knobs.boolean(label: 'Selected', initialValue: true), | ||
leading: leading, | ||
title: Text( | ||
context.knobs.string(label: 'Title', initialValue: 'List Item'), | ||
), | ||
subtitle: subtitle != null ? Text(subtitle) : null, | ||
trailing: trailing, | ||
onTap: () {}, | ||
); | ||
}, | ||
), | ||
); | ||
} |
Oops, something went wrong.