diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ea331d..4103ddb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## 3.0.1 - May 5 2024 - Support Flutter 3.22.1 +- Added Header Text ## 3.0.0 - March 10 2023 diff --git a/lib/src/selection_dialog.dart b/lib/src/selection_dialog.dart index 2f3ca9b..8c4b3fd 100644 --- a/lib/src/selection_dialog.dart +++ b/lib/src/selection_dialog.dart @@ -10,15 +10,20 @@ class SelectionDialog extends StatefulWidget { final InputDecoration searchDecoration; final TextStyle? searchStyle; final TextStyle? textStyle; + final TextStyle headerTextStyle; final BoxDecoration? boxDecoration; final WidgetBuilder? emptySearchBuilder; final bool? showFlag; final double flagWidth; + final String headerText; final Decoration? flagDecoration; final Size? size; final bool hideSearch; final bool hideCloseIcon; + final bool hideHeaderText; final Icon? closeIcon; + final EdgeInsets topBarPadding; + final MainAxisAlignment headerAlignment; /// Background color of SelectionDialog final Color? backgroundColor; @@ -38,10 +43,16 @@ class SelectionDialog extends StatefulWidget { this.favoriteElements, { Key? key, 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(), this.searchStyle, this.textStyle, + this.topBarPadding = + const EdgeInsets.symmetric(vertical: 5.0, horizontal: 20), + this.headerText = "Select Country", this.boxDecoration, this.showFlag, this.flagDecoration, @@ -52,7 +63,8 @@ class SelectionDialog extends StatefulWidget { this.hideSearch = false, this.hideCloseIcon = false, 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), }) : searchDecoration = searchDecoration.prefixIcon == null ? searchDecoration.copyWith(prefixIcon: const Icon(Icons.search)) @@ -92,13 +104,27 @@ class _SelectionDialogState extends State { mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.end, children: [ - - if (!widget.hideCloseIcon) - IconButton( - padding: const EdgeInsets.all(0), - iconSize: 20, - icon: widget.closeIcon!, - onPressed: () => Navigator.pop(context), + Padding( + padding: widget.topBarPadding, + child: Row( + mainAxisAlignment:widget.headerAlignment, + children: [ + !widget.hideHeaderText + ? 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) Padding( @@ -117,34 +143,28 @@ class _SelectionDialogState extends State { : Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - ...widget.favoriteElements.map( - (f) => InkWell( + ...widget.favoriteElements.map((f) => InkWell( onTap: () { _selectItem(f); }, child: Padding( padding: widget.dialogItemPadding, child: _buildOption(f), - ) - ) - ), + ))), const Divider(), ], ), if (filteredElements.isEmpty) _buildEmptySearchWidget(context) else - ...filteredElements.map( - (e) => InkWell( + ...filteredElements.map((e) => InkWell( onTap: () { _selectItem(e); }, child: Padding( - padding: widget.dialogItemPadding, + padding: widget.dialogItemPadding, child: _buildOption(e), - ) - ) - ), + ))), ], ), ), diff --git a/screenshots/screen1.png b/screenshots/screen1.png index ebb6a19..2b33cf1 100644 Binary files a/screenshots/screen1.png and b/screenshots/screen1.png differ diff --git a/screenshots/screen2.png b/screenshots/screen2.png index 9c02d84..ea35c36 100644 Binary files a/screenshots/screen2.png and b/screenshots/screen2.png differ