From 02a038501a91a31b2945b722ae427cf564a66134 Mon Sep 17 00:00:00 2001 From: Henning Hall Date: Fri, 24 May 2024 17:33:55 +0200 Subject: [PATCH] fix: disable confirm while scrolling Regression, introduced in 5.0.2 by https://github.com/henninghall/react-native-date-picker/pull/804 --- .../date_picker/DatePickerModuleImpl.java | 14 ++++++++++++++ .../com/henninghall/date_picker/PickerView.java | 9 ++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/android/src/main/java/com/henninghall/date_picker/DatePickerModuleImpl.java b/android/src/main/java/com/henninghall/date_picker/DatePickerModuleImpl.java index d874b57c..40a38f66 100644 --- a/android/src/main/java/com/henninghall/date_picker/DatePickerModuleImpl.java +++ b/android/src/main/java/com/henninghall/date_picker/DatePickerModuleImpl.java @@ -13,6 +13,8 @@ import com.facebook.react.bridge.Dynamic; import com.facebook.react.bridge.ReadableMap; import com.facebook.react.bridge.ReadableMapKeySetIterator; +import com.henninghall.date_picker.ui.SpinnerState; +import com.henninghall.date_picker.ui.SpinnerStateListener; import net.time4j.android.ApplicationStarter; @@ -126,9 +128,21 @@ private PickerView createPicker(ReadableMap props){ } } picker.update(); + + picker.addSpinnerStateListener(new SpinnerStateListener() { + @Override + public void onChange(SpinnerState state) { + setEnabledConfirmButton(state == SpinnerState.idle); + } + }); + return picker; } + private void setEnabledConfirmButton(boolean enabled) { + dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(enabled); + } + private View withTopMargin(PickerView view) { LinearLayout linearLayout = new LinearLayout(DatePickerPackage.context); linearLayout.setLayoutParams(new LinearLayout.LayoutParams( diff --git a/android/src/main/java/com/henninghall/date_picker/PickerView.java b/android/src/main/java/com/henninghall/date_picker/PickerView.java index 5061238a..0ed4dc16 100644 --- a/android/src/main/java/com/henninghall/date_picker/PickerView.java +++ b/android/src/main/java/com/henninghall/date_picker/PickerView.java @@ -6,19 +6,19 @@ import android.widget.RelativeLayout; import com.facebook.react.bridge.Dynamic; +import com.henninghall.date_picker.props.DateProp; import com.henninghall.date_picker.props.DividerColorProp; import com.henninghall.date_picker.props.Is24hourSourceProp; +import com.henninghall.date_picker.props.LocaleProp; import com.henninghall.date_picker.props.MaximumDateProp; import com.henninghall.date_picker.props.MinimumDateProp; import com.henninghall.date_picker.props.MinuteIntervalProp; -import com.henninghall.date_picker.props.TimezoneOffsetInMinutesProp; -import com.henninghall.date_picker.props.DateProp; -import com.henninghall.date_picker.props.LocaleProp; import com.henninghall.date_picker.props.ModeProp; import com.henninghall.date_picker.props.TextColorProp; +import com.henninghall.date_picker.props.TimezoneOffsetInMinutesProp; +import com.henninghall.date_picker.ui.Accessibility; import com.henninghall.date_picker.ui.SpinnerStateListener; import com.henninghall.date_picker.ui.UIManager; -import com.henninghall.date_picker.ui.Accessibility; import java.util.ArrayList; @@ -114,5 +114,4 @@ public void requestLayout() { post(measureAndLayout); } - }