-
-
Notifications
You must be signed in to change notification settings - Fork 36
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
1 parent
17c7dd3
commit 26e5b9c
Showing
19 changed files
with
702 additions
and
188 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
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
32 changes: 32 additions & 0 deletions
32
docs/lib/pages/docs/components/formatted_input/formatted_input_example_1.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,32 @@ | ||
import 'package:shadcn_flutter/shadcn_flutter.dart'; | ||
|
||
class FormattedInputExample1 extends StatelessWidget { | ||
const FormattedInputExample1({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return FormattedInput( | ||
parts: [ | ||
InputPart.editable(length: 2, width: 40), | ||
InputPart.static('/'), | ||
InputPart.editable(length: 2, width: 40), | ||
InputPart.static('/'), | ||
InputPart.editable(length: 4, width: 60), | ||
], | ||
trailing: IconButton.text( | ||
density: ButtonDensity.compact, | ||
icon: Icon(Icons.calendar_month), | ||
onPressed: () {}, | ||
), | ||
initialValue: FormattedValue( | ||
[ | ||
'12', | ||
'/', | ||
'34', | ||
'/', | ||
'5678', | ||
], | ||
), | ||
); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
docs/lib/pages/docs/components/formatted_input_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,26 @@ | ||
import 'package:shadcn_flutter/shadcn_flutter.dart'; | ||
|
||
import '../../widget_usage_example.dart'; | ||
import '../component_page.dart'; | ||
import 'formatted_input/formatted_input_example_1.dart'; | ||
|
||
class FormattedInputExample extends StatelessWidget { | ||
const FormattedInputExample({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return const ComponentPage( | ||
name: 'formatted_input', | ||
description: 'Text input with formatted parts.', | ||
displayName: 'Formatted Input', | ||
children: [ | ||
WidgetUsageExample( | ||
title: 'Formatted Input Example', | ||
path: | ||
'lib/pages/docs/components/formatted_input/formatted_input_example_1.dart', | ||
child: FormattedInputExample1(), | ||
), | ||
], | ||
); | ||
} | ||
} |
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
82 changes: 82 additions & 0 deletions
82
docs/lib/pages/docs/components/multiselect/multiselect_example_2.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,82 @@ | ||
import 'package:shadcn_flutter/shadcn_flutter.dart'; | ||
|
||
class MultiSelectExample2 extends StatefulWidget { | ||
const MultiSelectExample2({super.key}); | ||
|
||
@override | ||
State<MultiSelectExample2> createState() => _MultiSelectExample2State(); | ||
} | ||
|
||
class _MultiSelectExample2State extends State<MultiSelectExample2> { | ||
final Map<String, List<String>> fruits = { | ||
'Apple': ['Red Apple', 'Green Apple'], | ||
'Banana': ['Yellow Banana', 'Brown Banana'], | ||
'Lemon': ['Yellow Lemon', 'Green Lemon'], | ||
'Tomato': ['Red', 'Green', 'Yellow', 'Brown'], | ||
}; | ||
Iterable<String>? selectedValues; | ||
|
||
Iterable<MapEntry<String, List<String>>> _filteredFruits( | ||
String searchQuery) sync* { | ||
for (final entry in fruits.entries) { | ||
final filteredValues = entry.value | ||
.where((value) => _filterName(value, searchQuery)) | ||
.toList(); | ||
if (filteredValues.isNotEmpty) { | ||
yield MapEntry(entry.key, filteredValues); | ||
} else if (_filterName(entry.key, searchQuery)) { | ||
yield entry; | ||
} | ||
} | ||
} | ||
|
||
bool _filterName(String name, String searchQuery) { | ||
return name.toLowerCase().contains(searchQuery); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return MultiSelect<String>( | ||
itemBuilder: (context, item) { | ||
return Text(item); | ||
}, | ||
popup: SelectPopup.builder( | ||
searchPlaceholder: const Text('Search fruit'), | ||
builder: (context, searchQuery) { | ||
final filteredFruits = searchQuery == null | ||
? fruits.entries | ||
: _filteredFruits(searchQuery); | ||
return SelectItemList( | ||
children: [ | ||
for (final entry in filteredFruits) | ||
SelectGroup( | ||
headers: [ | ||
SelectLabel( | ||
child: Text(entry.key), | ||
), | ||
], | ||
children: [ | ||
for (final value in entry.value) | ||
SelectItemButton( | ||
value: value, | ||
child: Text(value), | ||
), | ||
], | ||
), | ||
], | ||
); | ||
}, | ||
), | ||
onChanged: (value) { | ||
setState(() { | ||
selectedValues = value; | ||
}); | ||
}, | ||
constraints: BoxConstraints( | ||
minWidth: 200, | ||
), | ||
value: selectedValues, | ||
placeholder: const Text('Select a fruit'), | ||
); | ||
} | ||
} |
Oops, something went wrong.