Skip to content
This repository was archived by the owner on Jul 20, 2022. It is now read-only.

Hide Splash And Custom DropDown Button Feature Added #191

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 29 additions & 13 deletions lib/country_code_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,15 @@ class CountryCodePicker extends StatefulWidget {
/// Set to true if you want to hide the search part
final bool hideSearch;

/// Set to true if you want to hide the Splash Button
final bool hideSplash;

/// Set to true if you want to show drop down button
final bool showDropDownButton;

/// Set to true if you want to show drop down button
final Widget? customDropDownButton;

/// [BoxDecoration] for the flag image
final Decoration? flagDecoration;

Expand Down Expand Up @@ -113,7 +119,9 @@ class CountryCodePicker extends StatefulWidget {
this.comparator,
this.countryFilter,
this.hideSearch = false,
this.hideSplash = false,
this.showDropDownButton = false,
this.customDropDownButton,
this.dialogSize,
this.dialogBackgroundColor,
this.closeIcon = const Icon(Icons.close),
Expand Down Expand Up @@ -159,11 +167,15 @@ class CountryCodePickerState extends State<CountryCodePicker> {
Widget _widget;
if (widget.builder != null)
_widget = InkWell(
splashFactory: widget.hideSplash ? NoSplash.splashFactory : null,
onTap: showCountryCodePickerDialog,
child: widget.builder!(selectedItem),
);
else {
_widget = TextButton(
style: TextButton.styleFrom(
splashFactory: widget.hideSplash ? NoSplash.splashFactory : null
),
onPressed: widget.enabled ? showCountryCodePickerDialog : null,
child: Padding(
padding: widget.padding,
Expand Down Expand Up @@ -205,19 +217,23 @@ class CountryCodePickerState extends State<CountryCodePicker> {
),
),
if (widget.showDropDownButton)
Flexible(
flex: widget.alignLeft ? 0 : 1,
fit: widget.alignLeft ? FlexFit.tight : FlexFit.loose,
child: Padding(
padding: widget.alignLeft
? const EdgeInsets.only(right: 16.0, left: 8.0)
: const EdgeInsets.only(right: 16.0),
child: Icon(
Icons.arrow_drop_down,
color: Colors.grey,
size: widget.flagWidth,
)),
),
if(widget.customDropDownButton==null)...[
Flexible(
flex: widget.alignLeft ? 0 : 1,
fit: widget.alignLeft ? FlexFit.tight : FlexFit.loose,
child: Padding(
padding: widget.alignLeft
? const EdgeInsets.only(right: 16.0, left: 8.0)
: const EdgeInsets.only(right: 16.0),
child: Icon(
Icons.arrow_drop_down,
color: Colors.grey,
size: widget.flagWidth,
)),
),
]else ...[
widget.customDropDownButton!,
]
],
),
),
Expand Down
79 changes: 43 additions & 36 deletions lib/selection_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,35 +79,40 @@ class _SelectionDialogState extends State<SelectionDialog> {
),
],
),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
IconButton(
padding: const EdgeInsets.all(0),
iconSize: 20,
icon: widget.closeIcon!,
onPressed: () => Navigator.pop(context),
),
if (!widget.hideSearch)
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: TextField(
style: widget.searchStyle,
decoration: widget.searchDecoration,
onChanged: _filterElements,
child: Stack(
children: [
Align(
alignment: Alignment.topRight,
child: IconButton(
padding: const EdgeInsets.all(0),
iconSize: 20,
icon: widget.closeIcon!,
onPressed: () => Navigator.pop(context),
),
),
Expanded(
child: ListView(
Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
widget.favoriteElements.isEmpty
? const DecoratedBox(decoration: BoxDecoration())
: Column(
if (!widget.hideSearch)
Padding(
padding: const EdgeInsets.only(left: 24, right: 24, top: 24),
child: TextField(
style: widget.searchStyle,
decoration: widget.searchDecoration,
onChanged: _filterElements,
),
),
Expanded(
child: ListView(
children: [
widget.favoriteElements.isEmpty
? const DecoratedBox(decoration: BoxDecoration())
: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
...widget.favoriteElements.map(
(f) => SimpleDialogOption(
(f) => SimpleDialogOption(
child: _buildOption(f),
onPressed: () {
_selectItem(f);
Expand All @@ -117,22 +122,24 @@ class _SelectionDialogState extends State<SelectionDialog> {
const Divider(),
],
),
if (filteredElements.isEmpty)
_buildEmptySearchWidget(context)
else
...filteredElements.map(
(e) => SimpleDialogOption(
child: _buildOption(e),
onPressed: () {
_selectItem(e);
},
),
if (filteredElements.isEmpty)
_buildEmptySearchWidget(context)
else
...filteredElements.map(
(e) => SimpleDialogOption(
child: _buildOption(e),
onPressed: () {
_selectItem(e);
},
),
),
],
),
),
],
),
),
],
),
],
)
),
);

Expand Down