Merge pull request #18 from juanmartin8a/custom-dialog-padding

Custom search bar padding and dialog item padding
This commit is contained in:
Chandra Abdul Fattah
2023-10-20 10:08:19 +07:00
committed by GitHub
2 changed files with 29 additions and 9 deletions

View File

@@ -29,6 +29,10 @@ class SelectionDialog extends StatefulWidget {
/// elements passed as favorite
final List<CountryCode> favoriteElements;
final EdgeInsetsGeometry dialogItemPadding;
final EdgeInsetsGeometry searchPadding;
SelectionDialog(
this.elements,
this.favoriteElements, {
@@ -48,6 +52,8 @@ class SelectionDialog extends StatefulWidget {
this.hideSearch = false,
this.hideCloseIcon = 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,
@@ -95,7 +101,7 @@ class _SelectionDialogState extends State<SelectionDialog> {
),
if (!widget.hideSearch)
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
padding: widget.searchPadding,
child: TextField(
style: widget.searchStyle,
decoration: widget.searchDecoration,
@@ -111,12 +117,15 @@ class _SelectionDialogState extends State<SelectionDialog> {
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(),
],
@@ -125,12 +134,15 @@ class _SelectionDialogState extends State<SelectionDialog> {
_buildEmptySearchWidget(context)
else
...filteredElements.map(
(e) => SimpleDialogOption(
child: _buildOption(e),
onPressed: () {
(e) => InkWell(
onTap: () {
_selectItem(e);
},
),
child: Padding(
padding: widget.dialogItemPadding,
child: _buildOption(e),
)
)
),
],
),