gusparis / react-native-month-year-picker

React Native Month Picker component for iOS & Android
MIT License
106 stars 74 forks source link

Customizable buttons #46

Closed apgsn closed 3 years ago

apgsn commented 3 years ago

Hi @gusparis, first of all, thanks for developing this component, it's working great for me. I was wondering if there's a way to customize the button section. Apart from "Cancel" and "Done", I'd like to add an extra button to perform a custom action (in my case, to trigger a date deletion in the component calling the picker), and I'd like to include it in the button section. Do you think it's feasible, perhaps by giving us a way to inject the whole button section component as an array of buttons or a customized component? Thanks

gusparis commented 3 years ago

Hello @apgsn! Thanks for using the library! Hrmm interesting change request...the array you're suggesting could work for iOS out of the box, the issue with will be for Android and the dialog implementation I'm using. It will take me a little more to refactor to inflate the Dialog with custom buttons. An easy way would be to add an optional third button (called neutral on Android). Let me know your thoughts.

apgsn commented 3 years ago

I was able to hack an extra button in iOS by adding it as a child of your component, but Android gives me an error so it's impossible right now to do it. I'd say any solution that gives me an extra button on both platforms is golden.

Another idea would be to give the users a way to import the bare calendars and use them as they please without extra modals, buttons, or fade animations.

gusparis commented 3 years ago

Again the issue here is Android 🤪. You can have the iOS bare component right now, importing the ViewComponent directly (without the wrapper). On Android this cannot be done because is not a component, but a module that fires a Java method. To have the bare Android it will require a huge refactor.

apgsn commented 3 years ago

I was digging through the code and saw that, bummer. But there's still a way to add a neutral button, right?

gusparis commented 3 years ago

Yes. It will give you an error for what I said on my previous comment, is not a component but a module. Let me work on a poc for the buttons and then I'll upload it after working. 😞

gusparis commented 3 years ago

@apgsn check new version 1.5.0 and let me know your thoughts about the new button. I will work next on a decouple version of the component, to give the freedom to use it anywhere, but leaving the Dialog/Modal available through props.

apgsn commented 3 years ago

Hey man, great job! The neutral button is working as intended. Thank you so much for this new feature. 👍