Skip to content

Commit

Permalink
feat: add support to select current country
Browse files Browse the repository at this point in the history
  • Loading branch information
Andre Rossi committed Sep 13, 2024
1 parent 48dfc03 commit 52fc20f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions lib/blip_ds.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
7 changes: 6 additions & 1 deletion lib/src/widgets/fields/ds_phone_input.widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class DSPhoneInput extends StatefulWidget {
this.errorText,
this.onChanged,
this.shouldFocus = false,
this.initialCountry,
});

final TextEditingController controller;
Expand All @@ -36,6 +37,7 @@ class DSPhoneInput extends StatefulWidget {
final ValueChanged<String>? onChanged;
final bool shouldFocus;
final void Function(DSCountry)? onChangeCountry;
final DSCountry? initialCountry;

@override
State<DSPhoneInput> createState() => _DSPhoneInputState();
Expand Down Expand Up @@ -65,7 +67,10 @@ class _DSPhoneInputState extends State<DSPhoneInput> {
_borderColor.value = _color();
});

DSBottomSheetCountries.selectedCountry.value = null;
_dropdownValue.value =
widget.initialCountry ?? (DSUtils.countriesList.first);

DSBottomSheetCountries.selectedCountry.value = widget.initialCountry;
widget.onChangeCountry?.call(_dropdownValue.value);
}

Expand Down
10 changes: 5 additions & 5 deletions lib/src/widgets/utils/ds_bottomsheet_countries.widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
),
],
),
Expand Down

0 comments on commit 52fc20f

Please sign in to comment.