Skip to content

Commit

Permalink
Update AutoSuggestBox
Browse files Browse the repository at this point in the history
  • Loading branch information
bdlukaa committed Dec 26, 2021
1 parent c520289 commit 900bfe4
Show file tree
Hide file tree
Showing 10 changed files with 337 additions and 178 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ Date format: DD/MM/YYYY
- Updated selected tab paint
- Added `TabView.tabWidthBehavior`. Defaults to `TabWidthBehavior.equal`
- Added `TabView.header` and `TabView.footer`
- `Slider`'s mouse cursor is now [MouseCursor.defer]
- Added `SmallIconButton`, which makes an [IconButton] small if wrapped. It's used by `TextBox`
- Added `ButtonStyle.iconSize`
- **BREAKING** `AutoSuggestBox` updates:
- Added `FluentLocalizations.noResultsFoundLabel`. "No results found" is the default text
- Removed `itemBuilder`, `sorter`, `noResultsFound`, `textBoxBuilder`, `defaultNoResultsFound` and `defaultTextBoxBuilder`
- Added `onChanged`, `trailingIcon`, `clearButtonEnabled` and `placeholder`
- `controller` is now nullable. If null, an internal controller is creted

## [3.5.2] - [17/12/2021]

Expand Down
45 changes: 23 additions & 22 deletions example/lib/screens/forms.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,25 @@ class Forms extends StatefulWidget {
}

class _FormsState extends State<Forms> {
final autoSuggestBox = TextEditingController();

final _clearController = TextEditingController();
bool _showPassword = false;

final values = ['Blue', 'Green', 'Yellow', 'Red'];
static const values = <String>[
'Red',
'Yellow',
'Green',
'Cyan',
'Blue',
'Magenta',
'Orange',
'Violet',
'Pink',
'Brown',
'Purple',
'Gray',
'Black',
'White',
];
String? comboBoxValue;

DateTime date = DateTime.now();
Expand Down Expand Up @@ -53,29 +66,17 @@ class _FormsState extends State<Forms> {
const SizedBox(width: 10),
Expanded(
child: AutoSuggestBox<String>(
controller: autoSuggestBox,
items: values,
placeholder: 'Pick a color',
trailingIcon: IconButton(
icon: const Icon(FluentIcons.search),
onPressed: () {
debugPrint('trailing button pressed');
},
),
onSelected: (text) {
print(text);
},
textBoxBuilder: (context, controller, focusNode, key) {
return TextBox(
key: key,
controller: controller,
focusNode: focusNode,
suffixMode: OverlayVisibilityMode.editing,
suffix: IconButton(
icon: const Icon(FluentIcons.close),
onPressed: () {
controller.clear();
focusNode.unfocus();
},
),
placeholder: 'Type a color',
clipBehavior:
focusNode.hasFocus ? Clip.none : Clip.antiAlias,
);
},
),
),
]),
Expand Down
Loading

0 comments on commit 900bfe4

Please sign in to comment.