search padding and dialog item padding

This commit is contained in:
Juan Martin Zabala Ochoa
2023-09-13 20:26:01 -05:00
parent 6ee7de3511
commit 37582edcee
2 changed files with 29 additions and 9 deletions

View File

@@ -85,6 +85,10 @@ class CountryCodePicker extends StatefulWidget {
/// with customized codes. /// with customized codes.
final List<Map<String, String>> countryList; final List<Map<String, String>> countryList;
final EdgeInsetsGeometry dialogItemPadding;
final EdgeInsetsGeometry searchPadding;
const CountryCodePicker({ const CountryCodePicker({
this.onChanged, this.onChanged,
this.onInit, this.onInit,
@@ -119,6 +123,8 @@ class CountryCodePicker extends StatefulWidget {
this.dialogBackgroundColor, this.dialogBackgroundColor,
this.closeIcon = const Icon(Icons.close), this.closeIcon = const Icon(Icons.close),
this.countryList = codes, this.countryList = codes,
this.dialogItemPadding = const EdgeInsets.symmetric(horizontal: 24, vertical: 8),
this.searchPadding = const EdgeInsets.symmetric(horizontal: 24),
Key? key, Key? key,
}) : super(key: key); }) : super(key: key);
@@ -307,6 +313,8 @@ class CountryCodePickerState extends State<CountryCodePicker> {
hideSearch: widget.hideSearch, hideSearch: widget.hideSearch,
closeIcon: widget.closeIcon, closeIcon: widget.closeIcon,
flagDecoration: widget.flagDecoration, flagDecoration: widget.flagDecoration,
dialogItemPadding: widget.dialogItemPadding,
searchPadding: widget.searchPadding,
), ),
), ),
), ),

View File

@@ -28,6 +28,10 @@ class SelectionDialog extends StatefulWidget {
/// elements passed as favorite /// elements passed as favorite
final List<CountryCode> favoriteElements; final List<CountryCode> favoriteElements;
final EdgeInsetsGeometry dialogItemPadding;
final EdgeInsetsGeometry searchPadding;
SelectionDialog( SelectionDialog(
this.elements, this.elements,
this.favoriteElements, { this.favoriteElements, {
@@ -46,6 +50,8 @@ class SelectionDialog extends StatefulWidget {
this.barrierColor, this.barrierColor,
this.hideSearch = false, this.hideSearch = false,
this.closeIcon, this.closeIcon,
this.dialogItemPadding = const EdgeInsets.symmetric(horizontal: 24, vertical: 8),
this.searchPadding = const EdgeInsets.symmetric(horizontal: 24),
}) : searchDecoration = searchDecoration.prefixIcon == null }) : searchDecoration = searchDecoration.prefixIcon == null
? searchDecoration.copyWith(prefixIcon: const Icon(Icons.search)) ? searchDecoration.copyWith(prefixIcon: const Icon(Icons.search))
: searchDecoration, : searchDecoration,
@@ -92,7 +98,7 @@ class _SelectionDialogState extends State<SelectionDialog> {
), ),
if (!widget.hideSearch) if (!widget.hideSearch)
Padding( Padding(
padding: const EdgeInsets.symmetric(horizontal: 24), padding: widget.searchPadding,
child: TextField( child: TextField(
style: widget.searchStyle, style: widget.searchStyle,
decoration: widget.searchDecoration, decoration: widget.searchDecoration,
@@ -108,12 +114,15 @@ class _SelectionDialogState extends State<SelectionDialog> {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
...widget.favoriteElements.map( ...widget.favoriteElements.map(
(f) => SimpleDialogOption( (f) => InkWell(
child: _buildOption(f), onTap: () {
onPressed: () {
_selectItem(f); _selectItem(f);
}, },
), child: Padding(
padding: widget.dialogItemPadding,
child: _buildOption(f),
)
)
), ),
const Divider(), const Divider(),
], ],
@@ -122,12 +131,15 @@ class _SelectionDialogState extends State<SelectionDialog> {
_buildEmptySearchWidget(context) _buildEmptySearchWidget(context)
else else
...filteredElements.map( ...filteredElements.map(
(e) => SimpleDialogOption( (e) => InkWell(
child: _buildOption(e), onTap: () {
onPressed: () {
_selectItem(e); _selectItem(e);
}, },
), child: Padding(
padding: widget.dialogItemPadding,
child: _buildOption(e),
)
)
), ),
], ],
), ),