From 52fc20fc263bbbba00fbbd3f5ffccc6dd8cd97bc Mon Sep 17 00:00:00 2001 From: Andre Rossi Date: Fri, 13 Sep 2024 15:29:15 -0300 Subject: [PATCH 1/2] feat: add support to select current country --- lib/blip_ds.dart | 1 + lib/src/widgets/fields/ds_phone_input.widget.dart | 7 ++++++- .../widgets/utils/ds_bottomsheet_countries.widget.dart | 10 +++++----- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/blip_ds.dart b/lib/blip_ds.dart index 624125b6..c7f25ac5 100644 --- a/lib/blip_ds.dart +++ b/lib/blip_ds.dart @@ -18,6 +18,7 @@ export 'src/extensions/ds_delivery_report_status.extension.dart' show DSDeliveryReportStatusExtension; export 'src/extensions/ds_string.extension.dart' show DSStringExtension; export 'src/models/ds_calls_media_message.model.dart' show DSCallsMediaMessage; +export 'src/models/ds_country.model.dart' show DSCountry; export 'src/models/ds_message_bubble_avatar_config.model.dart' show DSMessageBubbleAvatarConfig; export 'src/models/ds_message_bubble_style.model.dart' diff --git a/lib/src/widgets/fields/ds_phone_input.widget.dart b/lib/src/widgets/fields/ds_phone_input.widget.dart index bc72bbbb..a1f774c9 100644 --- a/lib/src/widgets/fields/ds_phone_input.widget.dart +++ b/lib/src/widgets/fields/ds_phone_input.widget.dart @@ -27,6 +27,7 @@ class DSPhoneInput extends StatefulWidget { this.errorText, this.onChanged, this.shouldFocus = false, + this.initialCountry, }); final TextEditingController controller; @@ -36,6 +37,7 @@ class DSPhoneInput extends StatefulWidget { final ValueChanged? onChanged; final bool shouldFocus; final void Function(DSCountry)? onChangeCountry; + final DSCountry? initialCountry; @override State createState() => _DSPhoneInputState(); @@ -65,7 +67,10 @@ class _DSPhoneInputState extends State { _borderColor.value = _color(); }); - DSBottomSheetCountries.selectedCountry.value = null; + _dropdownValue.value = + widget.initialCountry ?? (DSUtils.countriesList.first); + + DSBottomSheetCountries.selectedCountry.value = widget.initialCountry; widget.onChangeCountry?.call(_dropdownValue.value); } diff --git a/lib/src/widgets/utils/ds_bottomsheet_countries.widget.dart b/lib/src/widgets/utils/ds_bottomsheet_countries.widget.dart index d038983e..af5679ac 100644 --- a/lib/src/widgets/utils/ds_bottomsheet_countries.widget.dart +++ b/lib/src/widgets/utils/ds_bottomsheet_countries.widget.dart @@ -45,12 +45,12 @@ abstract class DSBottomSheetCountries { ), DSIconButton( onPressed: () { - Get.back( - result: selectedCountry.value, - ); + Get.back(); }, - icon: const Icon(DSIcons.close_outline, - color: DSColors.neutralDarkRooftop), + icon: const Icon( + DSIcons.close_outline, + color: DSColors.neutralDarkRooftop, + ), ), ], ), From bcca5e9ed8462e80ee32d79e666866a83ad55c9a Mon Sep 17 00:00:00 2001 From: Andre Rossi Date: Fri, 13 Sep 2024 16:45:05 -0300 Subject: [PATCH 2/2] chore: upgrade version --- CHANGELOG.md | 4 ++++ pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 36be446b..3823e506 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.2.3 + +- [DSPhoneInput] Add support to select current country code. + ## 0.2.2 - [DSButton] Removed border color when `borderColor` property is not informed. diff --git a/pubspec.yaml b/pubspec.yaml index 8eb35b17..6d433e07 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: blip_ds description: Blip Design System for Flutter. -version: 0.2.2 +version: 0.2.3 homepage: https://github.com/takenet/blip-ds-flutter#readme repository: https://github.com/takenet/blip-ds-flutter