-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add YaruSearchField and YaruSearchTitleField (#734)
* feat: add YaruSearchField and YaruSearchFieldTitle * Separate button from field and add clear icon * add onchanged and docs * Add alignment to title and improve example * Fix issues found in review * rename kYaruTitleBarItemHeight * height and width wording * add radius parameter * Fix example * Limit clear button width and add style * default to filled * forward text, better clip, hide clear btn if empty * Provide focusnode and controller parameters Co-authored-by: J-P Nurmi <[email protected]> * apply suggestions --------- Co-authored-by: J-P Nurmi <[email protected]>
- Loading branch information
1 parent
dc4b20c
commit 0cc96d8
Showing
5 changed files
with
496 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:yaru_widgets/yaru_widgets.dart'; | ||
|
||
class SearchFieldPage extends StatefulWidget { | ||
const SearchFieldPage({super.key}); | ||
|
||
@override | ||
State<SearchFieldPage> createState() => _SearchFieldPageState(); | ||
} | ||
|
||
class _SearchFieldPageState extends State<SearchFieldPage> { | ||
var _titleSearchActive = false; | ||
var _fieldSearchActive = false; | ||
|
||
String _titleText = 'The text you submitted'; | ||
String _fieldText = 'Or the things you changed'; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final theme = Theme.of(context); | ||
final light = theme.brightness == Brightness.light; | ||
|
||
return Center( | ||
child: ListView( | ||
children: [ | ||
SimpleDialog( | ||
shadowColor: light ? Colors.black : null, | ||
titlePadding: EdgeInsets.zero, | ||
title: YaruDialogTitleBar( | ||
titleSpacing: 0, | ||
centerTitle: true, | ||
title: YaruSearchTitleField( | ||
text: _titleText, | ||
onClear: () => setState(() => _titleText = ''), | ||
onSubmitted: (value) => | ||
setState(() => _titleText = value ?? ''), | ||
searchActive: _titleSearchActive, | ||
onSearchActive: () => | ||
setState(() => _titleSearchActive = !_titleSearchActive), | ||
title: const Text( | ||
'Any Widget Here', | ||
), | ||
), | ||
), | ||
children: [ | ||
SizedBox( | ||
height: 300, | ||
width: 450, | ||
child: Center( | ||
child: Text( | ||
_titleText, | ||
), | ||
), | ||
) | ||
], | ||
), | ||
SimpleDialog( | ||
shadowColor: light ? Colors.black : null, | ||
titlePadding: EdgeInsets.zero, | ||
title: YaruDialogTitleBar( | ||
heroTag: 'bar2', | ||
titleSpacing: 0, | ||
centerTitle: true, | ||
title: _fieldSearchActive | ||
? YaruSearchField( | ||
onClear: () {}, | ||
onChanged: (value) => setState( | ||
() => _fieldText = value, | ||
), | ||
) | ||
: const Text('Title'), | ||
leading: YaruSearchButton( | ||
searchActive: _fieldSearchActive, | ||
onPressed: () => | ||
setState(() => _fieldSearchActive = !_fieldSearchActive), | ||
), | ||
), | ||
children: [ | ||
SizedBox( | ||
height: 300, | ||
width: 450, | ||
child: Center( | ||
child: Text(_fieldText), | ||
), | ||
) | ||
], | ||
), | ||
], | ||
), | ||
); | ||
} | ||
} |
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
Oops, something went wrong.