-
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.
Showing
8 changed files
with
172 additions
and
2 deletions.
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
54 changes: 54 additions & 0 deletions
54
example/lib/pages/components/filter_selection_example.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:flutter/material.dart'; | ||
import 'package:zeta_flutter/zeta_flutter.dart'; | ||
|
||
import '../../widgets.dart'; | ||
|
||
class FilterSelectionExample extends StatefulWidget { | ||
static const String name = 'FilterSelection'; | ||
|
||
const FilterSelectionExample({super.key}); | ||
|
||
@override | ||
State<FilterSelectionExample> createState() => _FilterSelectionExampleState(); | ||
} | ||
|
||
class _FilterSelectionExampleState extends State<FilterSelectionExample> { | ||
final items = List.generate(12, (index) => false); | ||
final items2 = List.generate(12, (index) => false); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return ExampleScaffold( | ||
name: FilterSelectionExample.name, | ||
child: Column( | ||
children: [ | ||
const SizedBox(height: ZetaSpacing.b), | ||
ZetaFilterSelection( | ||
items: [ | ||
for (int i = 0; i < items.length; i++) | ||
ZetaFilterChip( | ||
label: 'Label ${i + 1}', | ||
selected: items[i], | ||
onTap: (value) => setState(() => items[i] = value), | ||
), | ||
], | ||
onPressed: () {}, | ||
), | ||
const SizedBox(height: ZetaSpacing.b), | ||
ZetaFilterSelection( | ||
rounded: false, | ||
items: [ | ||
for (int i = 0; i < items2.length; i++) | ||
ZetaFilterChip( | ||
label: 'Label ${i + 1}', | ||
selected: items2[i], | ||
onTap: (value) => setState(() => items2[i] = value), | ||
), | ||
], | ||
onPressed: () {}, | ||
), | ||
], | ||
), | ||
); | ||
} | ||
} |
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
37 changes: 37 additions & 0 deletions
37
example/widgetbook/pages/components/filter_selection_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,37 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:widgetbook/widgetbook.dart'; | ||
import 'package:zeta_flutter/zeta_flutter.dart'; | ||
|
||
import '../../test/test_components.dart'; | ||
|
||
Widget filterSelectionUseCase(BuildContext context) { | ||
final items = List.generate(12, (index) => false); | ||
final rounded = context.knobs.boolean( | ||
label: 'Rounded', | ||
initialValue: true, | ||
); | ||
|
||
return WidgetbookTestWidget( | ||
widget: StatefulBuilder( | ||
builder: (_, setState) { | ||
return Column( | ||
children: [ | ||
const SizedBox(height: ZetaSpacing.m), | ||
ZetaFilterSelection( | ||
rounded: rounded, | ||
items: [ | ||
for (int i = 0; i < items.length; i++) | ||
ZetaFilterChip( | ||
label: 'Label ${i + 1}', | ||
selected: items[i], | ||
onTap: (value) => setState(() => items[i] = value), | ||
), | ||
], | ||
onPressed: () {}, | ||
), | ||
], | ||
); | ||
}, | ||
), | ||
); | ||
} |
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
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,60 @@ | ||
import 'package:flutter/foundation.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
import '../../../zeta_flutter.dart'; | ||
|
||
/// Component [ZetaFilterSelection] | ||
class ZetaFilterSelection extends StatelessWidget { | ||
/// Constructor for the component [ZetaFilterSelection] | ||
const ZetaFilterSelection({ | ||
super.key, | ||
required this.items, | ||
this.rounded = true, | ||
this.onPressed, | ||
}); | ||
|
||
/// The filter items - list of [ZetaFilterChip]. | ||
final List<ZetaFilterChip> items; | ||
|
||
/// {@macro zeta-component-rounded} | ||
final bool rounded; | ||
|
||
/// Called on filter button pressed. | ||
final VoidCallback? onPressed; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return SizedBox( | ||
height: ZetaSpacing.x11, | ||
child: Row( | ||
children: [ | ||
IconButton( | ||
visualDensity: VisualDensity.compact, | ||
onPressed: onPressed, | ||
icon: Icon( | ||
rounded ? ZetaIcons.filter_round : ZetaIcons.filter_sharp, | ||
size: ZetaSpacing.m, | ||
), | ||
), | ||
Expanded( | ||
child: ListView( | ||
shrinkWrap: true, | ||
scrollDirection: Axis.horizontal, | ||
padding: const EdgeInsets.all(ZetaSpacing.xxs), | ||
children: | ||
items.map((e) => e.copyWith(rounded: rounded)).divide(const SizedBox(width: ZetaSpacing.x2)).toList(), | ||
), | ||
), | ||
], | ||
), | ||
); | ||
} | ||
|
||
@override | ||
void debugFillProperties(DiagnosticPropertiesBuilder properties) { | ||
super.debugFillProperties(properties); | ||
properties | ||
..add(DiagnosticsProperty<bool>('rounded', rounded)) | ||
..add(ObjectFlagProperty<VoidCallback?>.has('onPressed', onPressed)); | ||
} | ||
} |
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