diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index efae1e0d..701f3bbb 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -12,6 +12,14 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + with: + # Required because pr.yml uses `pull_request_target`, which + # otherwise checks out the base branch (master) instead of the + # PR head. Without this override, lint runs against master and + # PR-side fixes (or breaks) are invisible to the check. + # Mirrors the pattern already used in build-android.yml / + # build-ios.yml / test-android-*.yml. + ref: ${{ github.event.pull_request.head.sha }} - name: Node uses: actions/setup-node@v4 diff --git a/android/src/newarch/java/com/henninghall/date_picker/DatePickerModule.java b/android/src/newarch/java/com/henninghall/date_picker/DatePickerModule.java index 0fce9a78..6676ba31 100644 --- a/android/src/newarch/java/com/henninghall/date_picker/DatePickerModule.java +++ b/android/src/newarch/java/com/henninghall/date_picker/DatePickerModule.java @@ -2,6 +2,7 @@ import androidx.annotation.NonNull; +import com.facebook.react.bridge.Callback; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReadableMap; @@ -28,7 +29,13 @@ public void removeListeners(double type) { } @Override - public void openPicker(ReadableMap props){ + public void openPicker(ReadableMap props, Callback onConfirm, Callback onCancel){ + // Android delivers confirm/cancel to JS via the RCTDeviceEventEmitter + // (see DatePickerModuleImpl), so the callbacks supplied here are + // unused. They exist only to keep the TurboModule signature + // consistent with the iOS native module, where iOS *does* use the + // callbacks. Without them the spec would have to diverge by + // platform, which the codegen tooling does not allow. module.openPicker(props); } diff --git a/src/DatePickerIOS.js b/src/DatePickerIOS.js index 987cbcac..268519bc 100644 --- a/src/DatePickerIOS.js +++ b/src/DatePickerIOS.js @@ -23,8 +23,12 @@ export const DatePickerIOS = (props) => { style: [styles.datePickerIOS, props.style], date: props.date ? props.date.toISOString() : undefined, locale: props.locale ? props.locale : undefined, - maximumDate: props.maximumDate ? props.maximumDate.toISOString() : undefined, - minimumDate: props.minimumDate ? props.minimumDate.toISOString() : undefined, + maximumDate: props.maximumDate + ? props.maximumDate.toISOString() + : undefined, + minimumDate: props.minimumDate + ? props.minimumDate.toISOString() + : undefined, theme: props.theme ? props.theme : 'auto', } diff --git a/src/fabric/NativeRNDatePicker.ts b/src/fabric/NativeRNDatePicker.ts index 1633d7a1..c3c187e8 100644 --- a/src/fabric/NativeRNDatePicker.ts +++ b/src/fabric/NativeRNDatePicker.ts @@ -5,7 +5,11 @@ import { Double, UnsafeObject } from 'react-native/Libraries/Types/CodegenTypes' export interface Spec extends TurboModule { readonly getConstants: () => {} closePicker(): void - openPicker(props: UnsafeObject): void + openPicker( + props: UnsafeObject, + onConfirm: (result: UnsafeObject) => void, + onCancel: () => void + ): void removeListeners(type: Double): void addListener(eventName: string): void } diff --git a/src/modal.js b/src/modal.js index fe02e33e..b1cc0ab5 100644 --- a/src/modal.js +++ b/src/modal.js @@ -76,8 +76,13 @@ export const useModal = ({ props, id }) => { useEffect(() => { if (shouldOpenModal(props, previousProps)) { closing.current = false + // The TurboModule spec for `openPicker` declares 3 args because iOS + // native uses the callbacks directly. Android routes confirm/cancel + // through the `NativeEventEmitter` registered below, so the + // callbacks here are no-ops — they exist only to satisfy the + // strict arg-count check in the new architecture. const params = Platform.select({ - android: [props], + android: [props, () => {}, () => {}], ios: [props, onConfirm, onCancel], }) if (!params) throw Error('Unsupported platform')