From d6ea2b129efcfa92d8a872d921bf6ca6443e450e Mon Sep 17 00:00:00 2001 From: Felix Peters Date: Tue, 19 May 2026 19:31:19 +0200 Subject: [PATCH] feat(datetimepicker): ios permitted arrow directions --- packages/datetimepicker/common.ts | 1 + packages/datetimepicker/index.d.ts | 6 ++++++ packages/datetimepicker/index.ios.ts | 8 ++++---- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/datetimepicker/common.ts b/packages/datetimepicker/common.ts index ef41e236..673d92fb 100644 --- a/packages/datetimepicker/common.ts +++ b/packages/datetimepicker/common.ts @@ -37,6 +37,7 @@ export interface PickerOptions { title?: string; okButtonText?: string; cancelButtonText?: string; + iosPermittedArrowDirections?: number; } export class DateTimePickerStyleBase implements DateTimePickerStyleDefinition { diff --git a/packages/datetimepicker/index.d.ts b/packages/datetimepicker/index.d.ts index 03d5fdd4..35903fa2 100644 --- a/packages/datetimepicker/index.d.ts +++ b/packages/datetimepicker/index.d.ts @@ -103,6 +103,12 @@ export interface PickerOptions { * Text for the cancel button of the picker (default is Cancel on iOS, localized version of Cancel on android (based on the devices locale settings)). */ cancelButtonText?: string; + + /** + * iOS only: permitted arrow directions + * Defaults to `UIPopoverArrowDirection.Any` when not provided. + */ + iosPermittedArrowDirections?: number; } /** diff --git a/packages/datetimepicker/index.ios.ts b/packages/datetimepicker/index.ios.ts index 33af253c..4abf7b28 100644 --- a/packages/datetimepicker/index.ios.ts +++ b/packages/datetimepicker/index.ios.ts @@ -28,7 +28,7 @@ export class DateTimePicker extends DateTimePickerBase { DateTimePicker._nativeDialog = DateTimePicker._createNativeDialog(nativeDatePicker, options, style, (result) => { resolve(result); }); - DateTimePicker._showNativeDialog(DateTimePicker._nativeDialog, nativeDatePicker, style); + DateTimePicker._showNativeDialog(DateTimePicker._nativeDialog, nativeDatePicker, options, style); }); return pickDate; } @@ -39,7 +39,7 @@ export class DateTimePicker extends DateTimePickerBase { DateTimePicker._nativeDialog = DateTimePicker._createNativeDialog(nativeTimePicker, options, style, (result) => { resolve(result); }); - DateTimePicker._showNativeDialog(DateTimePicker._nativeDialog, nativeTimePicker, style); + DateTimePicker._showNativeDialog(DateTimePicker._nativeDialog, nativeTimePicker, options, style); }); return pickTime; } @@ -158,7 +158,7 @@ export class DateTimePicker extends DateTimePickerBase { return alertController; } - static _showNativeDialog(nativeDialog: UIAlertController, nativePicker: UIDatePicker, style: DateTimePickerStyle) { + static _showNativeDialog(nativeDialog: UIAlertController, nativePicker: UIDatePicker, options: PickerOptions, style: DateTimePickerStyle) { const app = UIApplication.sharedApplication; const win = app.keyWindow || (app.windows && app.windows.count > 0 && app.windows.objectAtIndex(0)); let viewController = win.rootViewController; @@ -170,7 +170,7 @@ export class DateTimePicker extends DateTimePickerBase { if (nativeDialog.popoverPresentationController) { nativeDialog.popoverPresentationController.sourceView = viewController.view; nativeDialog.popoverPresentationController.sourceRect = CGRectMake(viewController.view.bounds.size.width / 2.0, viewController.view.bounds.size.height / 2.0, 1.0, 1.0); - nativeDialog.popoverPresentationController.permittedArrowDirections = UIPopoverArrowDirection.Any; + nativeDialog.popoverPresentationController.permittedArrowDirections = options && options.iosPermittedArrowDirections !== undefined ? options.iosPermittedArrowDirections : UIPopoverArrowDirection.Any; } viewController.presentViewControllerAnimatedCompletion(nativeDialog, true, () => {});