Skip to content

Improve performance and country picker customization#876

Merged
bguidolim merged 16 commits intomarmelroy:masterfrom
Splash04:master
Nov 25, 2025
Merged

Improve performance and country picker customization#876
bguidolim merged 16 commits intomarmelroy:masterfrom
Splash04:master

Conversation

@Splash04
Copy link
Contributor

Performance improvements:

  • Load and sort country cell models in background Queue
  • Using fixed cell height to improve cell rendering performance
  • Move configuration of CountryCodePickerViewController to didLoad to speed up controller creation time
  • Make CellOptions Equatable to avoid excessive cell reconfiguration

Customization:

  • Add CountryCodePickerCellOptions and CountryCodePickerHeaderOptions to customize in CountryCodePickerViewController
  • Add support of custom cells and header provided externally
  • Add PhoneNumberTextFieldDelegate to allow handle events when CountryCodePickerViewController is showing. For ex. we can hide keyboard before opening picker and show it just after it will be closed.
  • Make setup and didPressFlagButton open to be able to override it and handle outside.
  • Make PhoneNumberTextField properties @IBInspectable to configure from xib

Add CustomCountryPickerCells example project to test cell customization.

And other small changes.

Tested only on iOS 15+.
P.S.: You are free to decline it if fill that this changes is not needed in the main repo.

@bguidolim
Copy link
Collaborator

Hey @Splash04

Thanks for your contribution.

To be honest, I'm not giving much attention to the UI part of PNK anymore, I was even thinking to remove it from the library and keep only the parsing and formatting logic.

However, if it's useful for you, it can be useful for other, so I'm merging this.

Thanks again.

@bguidolim bguidolim merged commit 3946d6d into marmelroy:master Nov 25, 2025
3 checks passed
@Splash04
Copy link
Contributor Author

I needed more flexibly with UI to make it works without issues in SwiftUI view in my project. So I spend some time learning how it implemented and how it can be updated.

In general, I prefer a bite different structure of UI code. But I was trying to make it similar to your implementation to not create a lot of migration issue for lib users.

If you don't have time to update UI part, I can take a look at it one more time and make some additional changes according to issue requests. This might be useful while I remember how everything works :)
Will see when I will find time for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants