diff --git a/lib/country_code_picker.dart b/lib/country_code_picker.dart index 6016fe6..276aaa9 100644 --- a/lib/country_code_picker.dart +++ b/lib/country_code_picker.dart @@ -37,6 +37,9 @@ class CountryCodePicker extends StatefulWidget { /// the size of the selection dialog final Size dialogSize; + /// Background color of selection dialog + final Color dialogBackgroundColor; + /// used to customize the country list final List countryFilter; @@ -101,6 +104,7 @@ class CountryCodePicker extends StatefulWidget { this.hideSearch = false, this.showDropDownButton = false, this.dialogSize, + this.dialogBackgroundColor, this.closeIcon = const Icon(Icons.close), Key key, }) : super(key: key); @@ -266,26 +270,27 @@ class CountryCodePickerState extends State { barrierColor: widget.barrierColor ?? Colors.grey.withOpacity(0.5), backgroundColor: widget.backgroundColor ?? Colors.transparent, context: context, - builder: (context) => - Center( - child: SelectionDialog( - elements, - favoriteElements, - showCountryOnly: widget.showCountryOnly, - emptySearchBuilder: widget.emptySearchBuilder, - searchDecoration: widget.searchDecoration, - searchStyle: widget.searchStyle, - textStyle: widget.dialogTextStyle, - boxDecoration: widget.boxDecoration, - showFlag: widget.showFlagDialog != null - ? widget.showFlagDialog - : widget.showFlag, - flagWidth: widget.flagWidth, - size: widget.dialogSize, - hideSearch: widget.hideSearch, - closeIcon: widget.closeIcon, - ), - ), + builder: (context) => Center( + child: SelectionDialog( + elements, + favoriteElements, + showCountryOnly: widget.showCountryOnly, + emptySearchBuilder: widget.emptySearchBuilder, + searchDecoration: widget.searchDecoration, + searchStyle: widget.searchStyle, + textStyle: widget.dialogTextStyle, + boxDecoration: widget.boxDecoration, + showFlag: widget.showFlagDialog != null + ? widget.showFlagDialog + : widget.showFlag, + flagWidth: widget.flagWidth, + size: widget.dialogSize, + backgroundColor: widget.dialogBackgroundColor, + barrierColor: widget.barrierColor, + hideSearch: widget.hideSearch, + closeIcon: widget.closeIcon, + ), + ), ).then((e) { if (e != null) { setState(() { diff --git a/lib/i18n/zh.json b/lib/i18n/zh.json index 5e91677..0863ae4 100644 --- a/lib/i18n/zh.json +++ b/lib/i18n/zh.json @@ -226,7 +226,7 @@ "TR": "土耳其", "TT": "特立尼达和多巴哥", "TV": "图瓦卢", - "TW": "中国台湾", + "TW": "台湾", "TZ": "坦桑尼亚", "UA": "乌克兰", "UG": "乌干达", diff --git a/lib/selection_dialog.dart b/lib/selection_dialog.dart index ad7c168..1b7f883 100644 --- a/lib/selection_dialog.dart +++ b/lib/selection_dialog.dart @@ -16,6 +16,12 @@ class SelectionDialog extends StatefulWidget { final bool hideSearch; final Icon closeIcon; + /// Background color of SelectionDialog + final Color backgroundColor; + + /// Boxshaow color of SelectionDialog that matches CountryCodePicker barrier color + final Color barrierColor; + /// elements passed as favorite final List favoriteElements; @@ -32,6 +38,8 @@ class SelectionDialog extends StatefulWidget { this.showFlag, this.flagWidth = 32, this.size, + this.backgroundColor, + this.barrierColor, this.hideSearch = false, this.closeIcon, }) : assert(searchDecoration != null, 'searchDecoration must not be null!'), @@ -58,11 +66,11 @@ class _SelectionDialogState extends State { widget.size?.height ?? MediaQuery.of(context).size.height * 0.85, decoration: widget.boxDecoration ?? BoxDecoration( - color: Colors.white, + color: widget.backgroundColor ?? Colors.white, borderRadius: BorderRadius.all(Radius.circular(25.0)), boxShadow: [ BoxShadow( - color: Colors.grey.withOpacity(1), + color: widget.barrierColor ?? Colors.grey.withOpacity(1), spreadRadius: 5, blurRadius: 7, offset: Offset(0, 3), // changes position of shadow diff --git a/pubspec.yaml b/pubspec.yaml index b44398a..beac8eb 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -10,7 +10,7 @@ dependencies: flutter: sdk: flutter - modal_bottom_sheet: ^1.0.1-dev + modal_bottom_sheet: ^1.0.0+1 flutter: assets: