-
Notifications
You must be signed in to change notification settings - Fork 399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
We can now use a custom DatePicker component #115
Conversation
- Need this to be able to replace DatePickerIOS w/ something like dgladkov/react-native-uncontrolled-date-picker-ios
This allows us to use a custom date picker like https://github.com/dgladkov/react-native-uncontrolled-date-picker-ios. Why? Because we need it to get around this: facebook/react-native#8169 |
Thanks @SudoPlz ! |
@SudoPlz is this tested with https://github.com/dgladkov/react-native-uncontrolled-date-picker-ios latest version? Because |
@abarisic86 I'm using this PR w/ https://github.com/dgladkov/react-native-uncontrolled-date-picker-ios on production already. Notice the
<TimerPicker
pickerRefCb={(datePicker) => { this.datepickerRef = datePicker; }}
neverDisableConfirmIOS
customDatePickerIOS={Platform.OS === 'ios' ? UncontrolledDatePickerIOS : null}
... and then this.datepickerRef.getDate((date) => {
// do something with the date
}); |
@SudoPlz it only works if I set Can you explain this line? |
Before my pull request, we used to disable the confirm button while the user was interacting with the picker. Now because we'll be using Some people may still want that behaviour so it's optional. |
@SudoPlz Yes, the usage of this parameter is clear. But is setting The proper solution would be to modify |
Or quit using the We don't need Any reason why you don't want to use that flag? |
Yes, I had to add Option to disable confirm button while interacting with date picker is still useful to stop users that click on confirm before the picker is done spinning.
I admit it is just an edge case and it's not the way datePicker should be used. But, if we want to fix this component for good - this option should be covered. If we leave it as is I would suggest:
_handleUserTouchInit = () => {
// custom date picker shouldn't change this param
if(!customDatePickerIOS){
this.setState({
userIsInteractingWithPicker: true,
})
}
return false;
}; |
@abarisic86 That's a good suggestion, I'll do that. Also, are you sure your steps are correct?
|
All set. @mmazzarolo Can you merge? This doesn't change anything to the existing usage, it only adds an extra feature that lot's of people require. |
@@ -148,8 +162,9 @@ export default class CustomDatePickerIOS extends PureComponent { | |||
> | |||
<View style={[styles.datepickerContainer, datePickerContainerStyleIOS]}> | |||
{customTitleContainerIOS || titleContainer} | |||
<View onStartShouldSetResponderCapture={this._handleUserTouchInit}> | |||
<DatePickerIOS | |||
<View onStartShouldSetResponderCapture={neverDisableConfirmIOS !== true ? this._handleUserTouchInit : null}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should revert this to <View onStartShouldSetResponderCapture={this._handleUserTouchInit}>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm any reason why we should do that?
People may want to disable the confirmation buttons while the date picker is scrolling, even if they're not using a Custom date picker.
Can you think of any scenarios were that becomes a problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any reason to make this change? any scenario where we need this condition?
Although it doesn't generate any bugs:
- neverDisableConfirmIOS feature works without this condition (when using default datepicker)
- The main problem I see is readability. It's easier to follow code if we leave this condition out
- "neverDisableConfirmIOS !== true" is confusing
So, can we leave it out?
Hey @SudoPlz and @abarisic86 @SudoPlz could you address the last @abarisic86 suggestion before the merge? |
@mmazzarolo |
Ahm, but I did make those changes back then. I don't think it needs anything else, right? |
Need this to be able to replace DatePickerIOS w/ something like dgladkov/react-native-uncontrolled-date-picker-ios
Usage: