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.07k stars 796 forks source link

Add support for container style in Flag component #451

Closed shozibabbas closed 2 years ago

shozibabbas commented 2 years ago

I was working on responsive design in react native. I've used flagSize prop to modify the font size of the flag. I came across this design when making the font size responsive:

image

While debugging this design issue, I found out that a style is being applied to the container of the Flag component. The style is as follows: (https://github.com/xcarpentier/react-native-country-picker-modal/blob/master/src/Flag.tsx#L16)

container: {
        justifyContent: 'center',
        alignItems: 'center',
        width: 30,
        marginRight: 10,
    }

The width mentioned here is the cause of this UI issue. To solve this, I would override the width property with my own. Hence, I've introduced the containerStyle prop which will allow additional styles to be added to the View component encompassing the Flag UI.

For example, by using the implementation in my PR, I can create a component like this:

<Flag
    countryCode={props.countryCode}
    flagSize={useScaledResponsiveFontSize(18)}
    containerStyle={{
        width: useScaledResponsiveFontSize(25)
    }}
/>

This will append my styles to the View container styles and solve the problem. Following is the UI after using this solution:

image

stale[bot] commented 2 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.