Added header text to the dialog and updated the image
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
## 3.0.1 - May 5 2024
|
## 3.0.1 - May 5 2024
|
||||||
|
|
||||||
- Support Flutter 3.22.1
|
- Support Flutter 3.22.1
|
||||||
|
- Added Header Text
|
||||||
|
|
||||||
## 3.0.0 - March 10 2023
|
## 3.0.0 - March 10 2023
|
||||||
|
|
||||||
|
|||||||
@@ -10,15 +10,20 @@ class SelectionDialog extends StatefulWidget {
|
|||||||
final InputDecoration searchDecoration;
|
final InputDecoration searchDecoration;
|
||||||
final TextStyle? searchStyle;
|
final TextStyle? searchStyle;
|
||||||
final TextStyle? textStyle;
|
final TextStyle? textStyle;
|
||||||
|
final TextStyle headerTextStyle;
|
||||||
final BoxDecoration? boxDecoration;
|
final BoxDecoration? boxDecoration;
|
||||||
final WidgetBuilder? emptySearchBuilder;
|
final WidgetBuilder? emptySearchBuilder;
|
||||||
final bool? showFlag;
|
final bool? showFlag;
|
||||||
final double flagWidth;
|
final double flagWidth;
|
||||||
|
final String headerText;
|
||||||
final Decoration? flagDecoration;
|
final Decoration? flagDecoration;
|
||||||
final Size? size;
|
final Size? size;
|
||||||
final bool hideSearch;
|
final bool hideSearch;
|
||||||
final bool hideCloseIcon;
|
final bool hideCloseIcon;
|
||||||
|
final bool hideHeaderText;
|
||||||
final Icon? closeIcon;
|
final Icon? closeIcon;
|
||||||
|
final EdgeInsets topBarPadding;
|
||||||
|
final MainAxisAlignment headerAlignment;
|
||||||
|
|
||||||
/// Background color of SelectionDialog
|
/// Background color of SelectionDialog
|
||||||
final Color? backgroundColor;
|
final Color? backgroundColor;
|
||||||
@@ -38,10 +43,16 @@ class SelectionDialog extends StatefulWidget {
|
|||||||
this.favoriteElements, {
|
this.favoriteElements, {
|
||||||
Key? key,
|
Key? key,
|
||||||
this.showCountryOnly,
|
this.showCountryOnly,
|
||||||
this.emptySearchBuilder,
|
this.hideHeaderText = false,
|
||||||
|
this.emptySearchBuilder,this.headerAlignment = MainAxisAlignment.spaceBetween,
|
||||||
|
this.headerTextStyle =
|
||||||
|
const TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
||||||
InputDecoration searchDecoration = const InputDecoration(),
|
InputDecoration searchDecoration = const InputDecoration(),
|
||||||
this.searchStyle,
|
this.searchStyle,
|
||||||
this.textStyle,
|
this.textStyle,
|
||||||
|
this.topBarPadding =
|
||||||
|
const EdgeInsets.symmetric(vertical: 5.0, horizontal: 20),
|
||||||
|
this.headerText = "Select Country",
|
||||||
this.boxDecoration,
|
this.boxDecoration,
|
||||||
this.showFlag,
|
this.showFlag,
|
||||||
this.flagDecoration,
|
this.flagDecoration,
|
||||||
@@ -52,7 +63,8 @@ class SelectionDialog extends StatefulWidget {
|
|||||||
this.hideSearch = false,
|
this.hideSearch = false,
|
||||||
this.hideCloseIcon = false,
|
this.hideCloseIcon = false,
|
||||||
this.closeIcon,
|
this.closeIcon,
|
||||||
this.dialogItemPadding = const EdgeInsets.symmetric(horizontal: 24, vertical: 8),
|
this.dialogItemPadding =
|
||||||
|
const EdgeInsets.symmetric(horizontal: 24, vertical: 8),
|
||||||
this.searchPadding = const EdgeInsets.symmetric(horizontal: 24),
|
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))
|
||||||
@@ -92,13 +104,27 @@ class _SelectionDialogState extends State<SelectionDialog> {
|
|||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
children: [
|
children: [
|
||||||
|
Padding(
|
||||||
if (!widget.hideCloseIcon)
|
padding: widget.topBarPadding,
|
||||||
IconButton(
|
child: Row(
|
||||||
padding: const EdgeInsets.all(0),
|
mainAxisAlignment:widget.headerAlignment,
|
||||||
iconSize: 20,
|
children: [
|
||||||
icon: widget.closeIcon!,
|
!widget.hideHeaderText
|
||||||
onPressed: () => Navigator.pop(context),
|
? Text(
|
||||||
|
widget.headerText,
|
||||||
|
overflow: TextOverflow.fade,
|
||||||
|
style: widget.headerTextStyle,
|
||||||
|
)
|
||||||
|
: const SizedBox(),
|
||||||
|
if (!widget.hideCloseIcon)
|
||||||
|
IconButton(
|
||||||
|
padding: const EdgeInsets.all(0),
|
||||||
|
iconSize: 20,
|
||||||
|
icon: widget.closeIcon!,
|
||||||
|
onPressed: () => Navigator.pop(context),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
if (!widget.hideSearch)
|
if (!widget.hideSearch)
|
||||||
Padding(
|
Padding(
|
||||||
@@ -117,34 +143,28 @@ class _SelectionDialogState extends State<SelectionDialog> {
|
|||||||
: Column(
|
: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
...widget.favoriteElements.map(
|
...widget.favoriteElements.map((f) => InkWell(
|
||||||
(f) => InkWell(
|
|
||||||
onTap: () {
|
onTap: () {
|
||||||
_selectItem(f);
|
_selectItem(f);
|
||||||
},
|
},
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: widget.dialogItemPadding,
|
padding: widget.dialogItemPadding,
|
||||||
child: _buildOption(f),
|
child: _buildOption(f),
|
||||||
)
|
))),
|
||||||
)
|
|
||||||
),
|
|
||||||
const Divider(),
|
const Divider(),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
if (filteredElements.isEmpty)
|
if (filteredElements.isEmpty)
|
||||||
_buildEmptySearchWidget(context)
|
_buildEmptySearchWidget(context)
|
||||||
else
|
else
|
||||||
...filteredElements.map(
|
...filteredElements.map((e) => InkWell(
|
||||||
(e) => InkWell(
|
|
||||||
onTap: () {
|
onTap: () {
|
||||||
_selectItem(e);
|
_selectItem(e);
|
||||||
},
|
},
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: widget.dialogItemPadding,
|
padding: widget.dialogItemPadding,
|
||||||
child: _buildOption(e),
|
child: _buildOption(e),
|
||||||
)
|
))),
|
||||||
)
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 148 KiB After Width: | Height: | Size: 167 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 42 KiB |
Reference in New Issue
Block a user