Skip to content

Commit 79fcaec

Browse files
authored
feat(datetimepicker): ios permitted arrow directions (#663)
1 parent d59d969 commit 79fcaec

3 files changed

Lines changed: 11 additions & 4 deletions

File tree

packages/datetimepicker/common.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export interface PickerOptions {
3737
title?: string;
3838
okButtonText?: string;
3939
cancelButtonText?: string;
40+
iosPermittedArrowDirections?: number;
4041
}
4142

4243
export class DateTimePickerStyleBase implements DateTimePickerStyleDefinition {

packages/datetimepicker/index.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@ export interface PickerOptions {
103103
* 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)).
104104
*/
105105
cancelButtonText?: string;
106+
107+
/**
108+
* iOS only: permitted arrow directions
109+
* Defaults to `UIPopoverArrowDirection.Any` when not provided.
110+
*/
111+
iosPermittedArrowDirections?: number;
106112
}
107113

108114
/**

packages/datetimepicker/index.ios.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class DateTimePicker extends DateTimePickerBase {
2828
DateTimePicker._nativeDialog = DateTimePicker._createNativeDialog(nativeDatePicker, options, style, (result) => {
2929
resolve(result);
3030
});
31-
DateTimePicker._showNativeDialog(DateTimePicker._nativeDialog, nativeDatePicker, style);
31+
DateTimePicker._showNativeDialog(DateTimePicker._nativeDialog, nativeDatePicker, options, style);
3232
});
3333
return pickDate;
3434
}
@@ -39,7 +39,7 @@ export class DateTimePicker extends DateTimePickerBase {
3939
DateTimePicker._nativeDialog = DateTimePicker._createNativeDialog(nativeTimePicker, options, style, (result) => {
4040
resolve(result);
4141
});
42-
DateTimePicker._showNativeDialog(DateTimePicker._nativeDialog, nativeTimePicker, style);
42+
DateTimePicker._showNativeDialog(DateTimePicker._nativeDialog, nativeTimePicker, options, style);
4343
});
4444
return pickTime;
4545
}
@@ -158,7 +158,7 @@ export class DateTimePicker extends DateTimePickerBase {
158158
return alertController;
159159
}
160160

161-
static _showNativeDialog(nativeDialog: UIAlertController, nativePicker: UIDatePicker, style: DateTimePickerStyle) {
161+
static _showNativeDialog(nativeDialog: UIAlertController, nativePicker: UIDatePicker, options: PickerOptions, style: DateTimePickerStyle) {
162162
const app = UIApplication.sharedApplication;
163163
const win = app.keyWindow || (app.windows && app.windows.count > 0 && app.windows.objectAtIndex(0));
164164
let viewController = win.rootViewController;
@@ -170,7 +170,7 @@ export class DateTimePicker extends DateTimePickerBase {
170170
if (nativeDialog.popoverPresentationController) {
171171
nativeDialog.popoverPresentationController.sourceView = viewController.view;
172172
nativeDialog.popoverPresentationController.sourceRect = CGRectMake(viewController.view.bounds.size.width / 2.0, viewController.view.bounds.size.height / 2.0, 1.0, 1.0);
173-
nativeDialog.popoverPresentationController.permittedArrowDirections = UIPopoverArrowDirection.Any;
173+
nativeDialog.popoverPresentationController.permittedArrowDirections = options && options.iosPermittedArrowDirections !== undefined ? options.iosPermittedArrowDirections : UIPopoverArrowDirection.Any;
174174
}
175175

176176
viewController.presentViewControllerAnimatedCompletion(nativeDialog, true, () => {});

0 commit comments

Comments
 (0)