From 37582edcee0ef4bd62e96f5b023b7843c9208043 Mon Sep 17 00:00:00 2001 From: Juan Martin Zabala Ochoa Date: Wed, 13 Sep 2023 20:26:01 -0500 Subject: [PATCH] search padding and dialog item padding --- lib/country_code_picker.dart | 8 ++++++++ lib/src/selection_dialog.dart | 30 +++++++++++++++++++++--------- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/lib/country_code_picker.dart b/lib/country_code_picker.dart index a2d82a7..e0be455 100644 --- a/lib/country_code_picker.dart +++ b/lib/country_code_picker.dart @@ -85,6 +85,10 @@ class CountryCodePicker extends StatefulWidget { /// with customized codes. final List> countryList; + final EdgeInsetsGeometry dialogItemPadding; + + final EdgeInsetsGeometry searchPadding; + const CountryCodePicker({ this.onChanged, this.onInit, @@ -119,6 +123,8 @@ class CountryCodePicker extends StatefulWidget { this.dialogBackgroundColor, this.closeIcon = const Icon(Icons.close), this.countryList = codes, + this.dialogItemPadding = const EdgeInsets.symmetric(horizontal: 24, vertical: 8), + this.searchPadding = const EdgeInsets.symmetric(horizontal: 24), Key? key, }) : super(key: key); @@ -307,6 +313,8 @@ class CountryCodePickerState extends State { hideSearch: widget.hideSearch, closeIcon: widget.closeIcon, flagDecoration: widget.flagDecoration, + dialogItemPadding: widget.dialogItemPadding, + searchPadding: widget.searchPadding, ), ), ), diff --git a/lib/src/selection_dialog.dart b/lib/src/selection_dialog.dart index b3434e8..d8cb501 100644 --- a/lib/src/selection_dialog.dart +++ b/lib/src/selection_dialog.dart @@ -28,6 +28,10 @@ class SelectionDialog extends StatefulWidget { /// elements passed as favorite final List favoriteElements; + final EdgeInsetsGeometry dialogItemPadding; + + final EdgeInsetsGeometry searchPadding; + SelectionDialog( this.elements, this.favoriteElements, { @@ -46,6 +50,8 @@ class SelectionDialog extends StatefulWidget { this.barrierColor, this.hideSearch = false, this.closeIcon, + this.dialogItemPadding = const EdgeInsets.symmetric(horizontal: 24, vertical: 8), + this.searchPadding = const EdgeInsets.symmetric(horizontal: 24), }) : searchDecoration = searchDecoration.prefixIcon == null ? searchDecoration.copyWith(prefixIcon: const Icon(Icons.search)) : searchDecoration, @@ -92,7 +98,7 @@ class _SelectionDialogState extends State { ), if (!widget.hideSearch) Padding( - padding: const EdgeInsets.symmetric(horizontal: 24), + padding: widget.searchPadding, child: TextField( style: widget.searchStyle, decoration: widget.searchDecoration, @@ -108,12 +114,15 @@ class _SelectionDialogState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ ...widget.favoriteElements.map( - (f) => SimpleDialogOption( - child: _buildOption(f), - onPressed: () { + (f) => InkWell( + onTap: () { _selectItem(f); }, - ), + child: Padding( + padding: widget.dialogItemPadding, + child: _buildOption(f), + ) + ) ), const Divider(), ], @@ -122,12 +131,15 @@ class _SelectionDialogState extends State { _buildEmptySearchWidget(context) else ...filteredElements.map( - (e) => SimpleDialogOption( - child: _buildOption(e), - onPressed: () { + (e) => InkWell( + onTap: () { _selectItem(e); }, - ), + child: Padding( + padding: widget.dialogItemPadding, + child: _buildOption(e), + ) + ) ), ], ),