Skip to content

Commit

Permalink
feat: Remove disable confirm (#370)
Browse files Browse the repository at this point in the history
Since we can't precisely know when/if the user started spinning the component (on IOS) to picker a date, we can't disable the "Confirm" button without bugs popping up continously.
This PR removes the logic that disables the "Confirm" button until the component has stopped spinning.
  • Loading branch information
mmazzarolo authored Feb 21, 2020
1 parent 4da925b commit 23c0c43
Showing 1 changed file with 7 additions and 18 deletions.
25 changes: 7 additions & 18 deletions src/DateTimePickerModal.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ export class DateTimePickerModal extends React.PureComponent {

state = {
currentDate: this.props.date,
isPickerVisible: this.props.isVisible,
isPickerSpinning: false
isPickerVisible: this.props.isVisible
};

didPressConfirm = false;
Expand Down Expand Up @@ -129,12 +128,7 @@ export class DateTimePickerModal extends React.PureComponent {
if (this.props.onChange) {
this.props.onChange(date);
}
this.setState({ currentDate: date, isPickerSpinning: false });
};

handleUserTouchInit = () => {
this.setState({ isPickerSpinning: true });
return false;
this.setState({ currentDate: date });
};

render() {
Expand Down Expand Up @@ -190,16 +184,13 @@ export class DateTimePickerModal extends React.PureComponent {
]}
>
<HeaderComponent label={titleIOS || headerTextIOS} />
<View onStartShouldSetResponderCapture={this.handleUserTouchInit}>
<PickerComponent
{...otherProps}
value={this.state.currentDate}
onChange={this.handleChange}
/>
</View>
<PickerComponent
{...otherProps}
value={this.state.currentDate}
onChange={this.handleChange}
/>
<ConfirmButtonComponent
isDarkModeEnabled={isDarkModeEnabled}
isDisabled={this.state.isPickerSpinning}
onPress={this.handleConfirm}
label={confirmTextIOS}
/>
Expand Down Expand Up @@ -256,7 +247,6 @@ export const headerStyles = StyleSheet.create({

export const ConfirmButton = ({
isDarkModeEnabled,
isDisabled,
onPress,
label,
style = confirmButtonStyles
Expand All @@ -269,7 +259,6 @@ export const ConfirmButton = ({
style={style.button}
underlayColor={underlayColor}
onPress={onPress}
disabled={isDisabled}
>
<Text style={style.text}>{label}</Text>
</TouchableHighlight>
Expand Down

0 comments on commit 23c0c43

Please sign in to comment.