Git Product home page Git Product logo

Comments (6)

mmazzarolo avatar mmazzarolo commented on July 22, 2024 1

Glad it worked.

but doing the same with the confirmation button didnt work

Probably because the cancel button doesn't return any parameter (so you can handle it even without the onCancel), while the confirm button returns the time (that is handled by onConfirm).

from react-native-modal-datetime-picker.

mmazzarolo avatar mmazzarolo commented on July 22, 2024

Hey @temitope,
ad you can see here I'm already wrapping your custom button with a TouchableOpacity.
This means that you should remove your onPress prop from your component and simply use the onConfirm prop (of react-native-modal-datetime-picker) just like you'll do with the build-in confirm button.
Let me know if it fixes your issue :)

from react-native-modal-datetime-picker.

temitope avatar temitope commented on July 22, 2024

ahh yes, that makes sense. but im still not getting the desired behavior. It may be because I am using the Button component from the [https://github.com/react-native-community/react-native-elements](react-native-elements module? [ https://github.com/react-native-community/react-native-elements) ]

I am getting a debug message of

please attach method to this component

from line 12 in the Button.js of that module...hmm i shouldnt need it to be their button, i will try the native buttons not in the module as well.

P.S. it is maybe a little incongruous with the customCancelButtonIOS property and onCancel, in that i think i had to create an onPress attribute and call a function to have it close (it does not seem to autocarry the onCancel prop), then again i am a React newbie and could be missing something about syntax/paradigm shift of React itself

from react-native-modal-datetime-picker.

mmazzarolo avatar mmazzarolo commented on July 22, 2024

First of all: yes, that log line is indeed caused by the button you're using.
Honestly I didn't understand you question regarding customCancelButton 🤔 ...

Basically both customCancelButtonIOS and customConfirmButtonIOS are simple views that you can pass to react-native-datetime-picker and they will trigger onCancel/ onConfirm when pressed.
The button press interactions are handled internally by react-native-datetime-picker and you should not pass a button with an already defined onPress (like you were doing).
Try to pass a simple styled <View /> to customConfirmButtonIOS: you'll see that it will trigger onConfirm when pressed :)

I'm going to sleep now, if you have any more question I'll answer them tomorrow!

from react-native-modal-datetime-picker.

temitope avatar temitope commented on July 22, 2024

Boom! Passing in a simple View with some text did the job. Thanks for the help there.

this is maybe moot now, but to give more clarity regarding the customCancelButton, i was saying that I was able to actually pass an event to the onPress handler using that react-native-element button and have everything worked just fine, but doing the same with the confirmation button didnt work so i didnt suspect that the type of element i was passing in was the issue, since it worked for one and not the other.

from react-native-modal-datetime-picker.

mahamIqbal825 avatar mahamIqbal825 commented on July 22, 2024

Hi there,
this solution is not working for me i am giving the simple view but it's not triggering to the onConfirm function automatically
<DateTimePickerModal
isVisible={isDatePickerVisible}
mode="date"
dateFormat="dayofweek day month"
onConfirm={date => {
handleConfirmShedule(date);
}}
onCancel={hideDatePicker}
textColor={Theme.primaryColor}
style={styles.datePicker}
confirmTextIOS="Done"
customConfirmButtonIOS={() => {
return (
<View
style={{
justifyContent: 'center',
alignItems: 'center',
marginBottom: 10,
height: 50,
width: '100%',
backgroundColor: 'red',
}}
>
);
}}

      //backdropStyleIOS={{backgroundColor: 'transparent'}}
    />

from react-native-modal-datetime-picker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.