xcarpentier / react-native-country-picker-modal

🇦🇶 Country picker provides a modal allowing a user to select a country from a list. It display a flag next to each country name.
https://reactnative.gallery/xcarpentier/country-picker
MIT License
1.08k stars 802 forks source link

The countries dependency is using a very old version #339

Closed aleksitaipale closed 4 years ago

aleksitaipale commented 4 years ago

Issue Description

The countries dependency is using a very old version, 2.1.0 as defined in package.json. The newest release in countries is v4.0.0. Mostly the update would be pretty straightforward, but there are some changes to the JSON structure, which means that transform-world-countries.js would need a bit of fixing.

The biggest changes would be:

callingCode doesn't exist anymore. Instead, it's replaced with idd, in the format of:

idd: {
  root: "+2",
    suffixes: [
      "97"
    ]
},

There's no one single currency defined anymore. Instead, for each country, there's currencies, an object of objects:

currencies: {
  AWG: {
    name: "Aruban florin",
    symbol: "ƒ"
  }
}

I have some ideas to base a PR on, namely:

For the calling code, how does the below feel?

callingCode:
  idd.suffixes.length > 1 
  ? [idd.root.replace('+', '')]
  : [idd.root.replace('+', '') + idd.suffixes[0]],

For the currencies: how would you deal with that? One of my ideas would be to generate an array from the object, sort it alphabetically, and always take the first element from there. This isn't perfect, but would somewhat align with how the code nowadays works.

So I would like to open a discussion on how I should best structure my countries bump PR in your opinion. :)

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.