selvamk-js / sharingan-rn-modal-dropdown

A simple and customizable react-native dropdown created using react-native-modal and react-native-paper.
MIT License
85 stars 28 forks source link

Accepting different avatar components than Avatar.Image #21

Closed mariohmol closed 3 years ago

mariohmol commented 3 years ago

Nowadays its possible to include an option avatar just with a Avatar.Image.

Would be great if the sourceAvatar could accept any component, so it can inject an Avatar.Icon or any other that he might to.

Based on request: #20

In sake of keeping the existing docs and code correct, I did create a new property

{
    value: '1',
    label: 'Tiger Nixon',
    employee_salary: '320800',
    employee_age: '61',
    avatarComponent: <Avatar.Icon size={24} icon="folder" />,
  },

Thanks!

selvamk-js commented 3 years ago

Did you try executing the changes in the simulator? Because I don't get the Icon when I added it. Also, avatarComponent props can not be FC.

selvamk-js commented 3 years ago

Also, the check condition on the item seems to be incorrect, {enableAvatar && avatarComponent ? ( avatarComponent ) : ( <Avatar.Image size={avatarSize} style={styles.avatarView} source={avatarSource || defaultAvatar} /> )}

If I don't pass the enableAvatar prop, It should not set the avatar but the above condition will set the default image avatar as the item avatar when the enableAvatar prop is not given.

mariohmol commented 3 years ago

Yes.. now I realized.. the problem was the linter.. when I did commit he asked me to remove the parentesis

mariohmol commented 3 years ago

Ok, I did submit a change that fits the linter and the logic

mariohmol commented 3 years ago

avatarComponent

why it cant be FC? what it should be instead?

selvamk-js commented 3 years ago

The avatar prop from the Chip expects the ReactNode, here I need the component with the signature of children. So FC isn't the correct prop to use.

Screenshot 2021-03-04 at 8 57 20 AM

Also, my lint scolding me for not using ReactNode 🤪

mariohmol commented 3 years ago

So what we should use as a type here? kind lost

selvamk-js commented 3 years ago

ReactNode should work.

mariohmol commented 3 years ago

awesome.. thank you! pushed the change!

mariohmol commented 3 years ago

Hi, when u can please release a version with this.. would be awesome to incorporate the icons on the dropdown =)

selvamk-js commented 3 years ago

I am planning to do it tomorrow(Saturday). Since I am little engaged with other work. Also, I need to do a quick test for this, all of this will take quite a lot of time.

mariohmol commented 3 years ago

You rock!!