Skip to content

Commit

Permalink
[iOS] Refactor date/time form controls on iOS to use a popover presen…
Browse files Browse the repository at this point in the history
…tation

https://bugs.webkit.org/show_bug.cgi?id=261627
rdar://115581849

Reviewed by Aditya Keerthi.

Change date and time inputs on iOS to use a `UIDatePicker` view hosted inside of
`UIPopoverPresentationController`, rather than `_UIDatePickerOverlayPresentation`. This also
changes the behavior and appearance of the form accessory view, such that it presents with an arrow
pointing to the source rect in the content view, instead of a context-menu-like appearance. See
comments below for more information.

* LayoutTests/fast/forms/ios/input-peripherals-with-validation-message.html:

Adjust this test to use the new `UIHelper.isShowingFormValidationBubble()` method; this is necessary
because the current method, `isShowingPopover()`, returns `true` when *either* the date picker or
validation bubble is presented (due to adopting `UIPopoverPresentationController`), but the test
expects it to be `true` only when the validation bubble is presented.

* LayoutTests/resources/ui-helper.js:
(window.UIHelper.isShowingFormValidationBubble):
(window.UIHelper.isShowingPopover): Deleted.

See above for more details; we can also just remove `isShowingPopover()` here, since the test above
was the only caller.

* Source/WTF/wtf/PlatformHave.h:

Remove the now-unnecessary `HAVE(UIDATEPICKER_OVERLAY_PRESENTATION)` compile-time flag.

* Source/WebKit/Platform/spi/ios/UIKitSPI.h:
* Source/WebKit/SourcesCocoa.txt:
* Source/WebKit/UIProcess/API/ios/WKWebViewIOS.h:
* Source/WebKit/UIProcess/ios/forms/WKDatePickerPopoverController.h: Added.
* Source/WebKit/UIProcess/ios/forms/WKDatePickerPopoverController.mm: Added.
(-[WKDatePickerPopoverView initWithDatePicker:]):
(-[WKDatePickerPopoverView datePicker]):

Add a `WKDatePickerPopoverView` to encapsulate and help manage the toolbar (accessory view), date
picker view, and backdrop view in the background.

(-[WKDatePickerPopoverView accessoryView]):
(-[WKDatePickerPopoverController initWithDatePicker:delegate:]):
(-[WKDatePickerPopoverController resetDatePicker]):
(-[WKDatePickerPopoverController dismissDatePicker]):
(-[WKDatePickerPopoverController viewDidLoad]):
(-[WKDatePickerPopoverController presentInView:sourceRect:interactionBounds:completion:]):
(-[WKDatePickerPopoverController adaptivePresentationStyleForPresentationController:traitCollection:]):
(-[WKDatePickerPopoverController presentationControllerDidDismiss:]):

Add a new `WKDatePickerPopoverController` that takes a date picker and delegate, knows how to
present the date picker, and also calls back into the `WKDateTimePicker` via delegate methods.

* Source/WebKit/UIProcess/ios/forms/WKDateTimeInputControl.mm:
(-[WKDateTimePicker initWithView:datePickerMode:]):
(-[WKDateTimePicker datePickerPopoverControllerDidDismiss:]):
(-[WKDateTimePicker datePickerPopoverControllerDidReset:]):
(-[WKDateTimePicker handleDatePickerPresentationDismissal]):
(-[WKDateTimePicker removeDatePickerPresentation]):
(-[WKDateTimePicker showDateTimePicker]):

Replace `_UIDatePickerOverlayPresentation` with this new `WKDatePickerPopoverController`.

(-[WKDateTimePicker dateFormatterForPicker]):
(-[WKDateTimePicker _dateChanged]):
(-[WKDateTimePicker controlBeginEditing]):

Make a slight adjustment here for Catalyst, so that we always relinquish first responder to the
imminently-presenting popover when focusing a date/time input. With the new popover (but without
this change), we'll immediately dismiss the popover upon focus because the popover causes the web
view to resign first responder, which would otherwise cause us to hide the popover.

Note that this new design *also* generally fixes date time inputs in Catalyst; while we don't run
into the problem described above, we currently have a different serious bug, wherein the contents of
the date picker don't respond to clicks until switching to a different window and switching back.
This patch makes date pickers work without this weird caveat.

(-[WKDateTimePicker controlEndEditing]):
(-[WKDateTimeInputControl initWithView:]):
(-[WKDateTimePicker datePickerChanged:]): Deleted.
(-[WKDateTimePicker reset:]): Deleted.
(-[WKDateTimePicker done:]): Deleted.

Replace these action selectors with `WKDatePickerPopoverControllerDelegate` method implementations
instead.

* Source/WebKit/UIProcess/mac/WKImmediateActionController.h:

Fix a unified-source build failure that's surfaced by the new file in this patch.

* Source/WebKit/WebKit.xcodeproj/project.pbxproj:
* Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
* Tools/TestRunnerShared/UIScriptContext/UIScriptController.h:
(WTR::UIScriptController::isShowingFormValidationBubble const):

Add support for a new testing hook; see above for more details.

* Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.h:
* Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.mm:
(-[TestRunnerWKWebView initWithFrame:configuration:]):
(-[TestRunnerWKWebView _willPresentPopover:]):
(-[TestRunnerWKWebView _didDismissPopover]):

Adjust the test harness to set `showingFormValidationBubble` when observing a popover presentation
notification, only if the object's delegate is a `WebValidationBubbleDelegate`. While a bit hacky,
I opted for this approach since it keeps all the testing code within the test harness, and doesn't
require additional (intrusive) test-only code in the engine itself.

(-[TestRunnerWKWebView _willPresentPopover]): Deleted.
* Tools/WebKitTestRunner/ios/UIScriptControllerIOS.h:
* Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm:
(WTR::UIScriptControllerIOS::isShowingFormValidationBubble const):

Canonical link: https://commits.webkit.org/268069@main
  • Loading branch information
whsieh committed Sep 17, 2023
1 parent ba61b70 commit 9cb30cc
Show file tree
Hide file tree
Showing 17 changed files with 334 additions and 129 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
debug("Tap on submit button with an empty required date input.");
await UIHelper.activateElementAndWaitForInputSession(submit);

isShowingValidationMessage = await UIHelper.isShowingPopover();
isShowingValidationMessage = await UIHelper.isShowingFormValidationBubble();

shouldBe("document.activeElement", "date");
shouldBeTrue("isShowingValidationMessage");
Expand All @@ -37,7 +37,7 @@
await UIHelper.waitForPopoverToDismiss();
await UIHelper.activateElementAndWaitForInputSession(date);

isShowingValidationMessage = await UIHelper.isShowingPopover();
isShowingValidationMessage = await UIHelper.isShowingFormValidationBubble();
shouldBe("document.activeElement", "date");
shouldBeFalse("isShowingValidationMessage");

Expand All @@ -53,7 +53,7 @@
debug("\nTap on submit button with an empty required text input.");
await UIHelper.activateElementAndWaitForInputSession(submit);

isShowingValidationMessage = await UIHelper.isShowingPopover();
isShowingValidationMessage = await UIHelper.isShowingFormValidationBubble();
shouldBe("document.activeElement", "text");
shouldBeTrue("isShowingValidationMessage");

Expand Down
4 changes: 2 additions & 2 deletions LayoutTests/resources/ui-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -710,10 +710,10 @@ window.UIHelper = class UIHelper {
});
}

static isShowingPopover()
static isShowingFormValidationBubble()
{
return new Promise(resolve => {
testRunner.runUIScript("uiController.isShowingPopover", result => resolve(result === "true"));
testRunner.runUIScript("uiController.isShowingFormValidationBubble", result => resolve(result === "true"));
});
}

Expand Down
4 changes: 0 additions & 4 deletions Source/WTF/wtf/PlatformHave.h
Original file line number Diff line number Diff line change
Expand Up @@ -939,10 +939,6 @@
#define HAVE_NSURLPROTOCOL_WITH_SKIPAPPSSO 1
#endif

#if PLATFORM(IOS) || PLATFORM(MACCATALYST) || PLATFORM(VISION)
#define HAVE_UIDATEPICKER_OVERLAY_PRESENTATION 1
#endif

#if (PLATFORM(IOS) || PLATFORM(MACCATALYST)) \
|| PLATFORM(MAC) \
|| PLATFORM(VISION)
Expand Down
44 changes: 0 additions & 44 deletions Source/WebKit/Platform/spi/ios/UIKitSPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,6 @@
#import <UIKit/UIMenu_Private.h>
#endif

#if HAVE(UIDATEPICKER_OVERLAY_PRESENTATION)
#import <UIKit/_UIDatePickerOverlayPresentation.h>
#endif

#if ENABLE(DRAG_SUPPORT)
#import <UIKit/NSItemProvider+UIKitAdditions_Private.h>
#endif
Expand Down Expand Up @@ -230,46 +226,6 @@ WTF_EXTERN_C_END
+ (UIColor *)systemBackgroundColor;
@end

typedef NS_ENUM(NSInteger, UIDatePickerPrivateMode) {
UIDatePickerModeYearAndMonth = 4269,
};

#if HAVE(UIDATEPICKER_STYLE)
typedef NS_ENUM(NSInteger, UIDatePickerStyle) {
UIDatePickerStyleAutomatic = 0
}
#endif

@interface UIDatePicker ()
@property (nonatomic, readonly, getter=_contentWidth) CGFloat contentWidth;
#if HAVE(UIDATEPICKER_STYLE)
@property (nonatomic, readwrite, assign) UIDatePickerStyle preferredDatePickerStyle;
#endif
- (UIEdgeInsets)_appliedInsetsToEdgeOfContent;
@end

#if HAVE(UIDATEPICKER_OVERLAY_PRESENTATION)

typedef NS_ENUM(NSInteger, _UIDatePickerOverlayAnchor) {
_UIDatePickerOverlayAnchorSourceRect = 2
};

@interface _UIDatePickerOverlayPresentation : NSObject

- (instancetype)initWithSourceView:(UIView *)sourceView;
- (void)presentDatePicker:(UIDatePicker *)datePicker onDismiss:(void(^)(BOOL retargeted))dismissHandler;
- (void)dismissPresentationAnimated:(BOOL)animated;

@property (nonatomic, weak, readonly) UIView *sourceView;
@property (nonatomic, assign) CGRect sourceRect;
@property (nonatomic, assign) _UIDatePickerOverlayAnchor overlayAnchor;
@property (nonatomic, strong) UIView *accessoryView;
@property (nonatomic, assign) BOOL accessoryViewIgnoresDefaultInsets;

@end

#endif

@interface UIDevice ()
- (void)setOrientation:(UIDeviceOrientation)orientation animated:(BOOL)animated;
@property (nonatomic, readonly, retain) NSString *buildVersion;
Expand Down
1 change: 1 addition & 0 deletions Source/WebKit/SourcesCocoa.txt
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ UIProcess/Inspector/mac/WKInspectorWKWebView.mm
UIProcess/Network/NetworkProcessProxyCocoa.mm

UIProcess/ios/forms/WKAirPlayRoutePicker.mm
UIProcess/ios/forms/WKDatePickerPopoverController.mm
UIProcess/ios/forms/WKDatePickerViewController.mm
UIProcess/ios/forms/WKDateTimeInputControl.mm
UIProcess/ios/forms/WKFileUploadPanel.mm
Expand Down
2 changes: 2 additions & 0 deletions Source/WebKit/UIProcess/API/ios/WKWebViewIOS.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ class VisibleContentRectUpdateInfo;
@property (nonatomic, readonly) BOOL _isWindowResizingEnabled;
#endif

@property (nonatomic, readonly) CGRect _contentRectForUserInteraction;

@end

_WKTapHandlingResult wkTapHandlingResult(WebKit::TapHandlingResult);
Expand Down
44 changes: 44 additions & 0 deletions Source/WebKit/UIProcess/ios/forms/WKDatePickerPopoverController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright (C) 2023 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/

#pragma once

#if PLATFORM(IOS_FAMILY)

#import <UIKit/UIKit.h>

@class WKDatePickerPopoverController;

@protocol WKDatePickerPopoverControllerDelegate <NSObject>
- (void)datePickerPopoverControllerDidDismiss:(WKDatePickerPopoverController *)controller;
- (void)datePickerPopoverControllerDidReset:(WKDatePickerPopoverController *)controller;
@end

@interface WKDatePickerPopoverController : UIViewController
- (instancetype)initWithDatePicker:(UIDatePicker *)datePicker delegate:(id<WKDatePickerPopoverControllerDelegate>)delegate;
- (void)presentInView:(UIView *)view sourceRect:(CGRect)rect interactionBounds:(CGRect)interactionBounds completion:(void(^)())completion;
@end

#endif // PLATFORM(IOS_FAMILY)
221 changes: 221 additions & 0 deletions Source/WebKit/UIProcess/ios/forms/WKDatePickerPopoverController.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,221 @@
/*
* Copyright (C) 2023 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/

#import "config.h"
#import "WKDatePickerPopoverController.h"

#if PLATFORM(IOS_FAMILY)

#import "UIKitSPI.h"
#import <WebCore/LocalizedStrings.h>
#import <wtf/BlockPtr.h>
#import <wtf/RetainPtr.h>
#import <wtf/text/WTFString.h>

@interface WKDatePickerPopoverView : UIView

@property (readonly, nonatomic) UIDatePicker *datePicker;
@property (readonly, nonatomic) UIToolbar *accessoryView;

@end

@implementation WKDatePickerPopoverView {
RetainPtr<UIVisualEffectView> _backgroundView;
__weak UIDatePicker *_datePicker;
RetainPtr<UIToolbar> _accessoryView;
}

- (instancetype)initWithDatePicker:(UIDatePicker *)datePicker
{
if (!(self = [super initWithFrame:CGRectZero]))
return nil;

_backgroundView = adoptNS([[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleSystemMaterial]]);
_datePicker = datePicker;
_accessoryView = adoptNS([UIToolbar new]);

[_backgroundView setTranslatesAutoresizingMaskIntoConstraints:NO];
[self addSubview:_backgroundView.get()];

static constexpr auto marginSize = 16;
_datePicker.translatesAutoresizingMaskIntoConstraints = NO;
_datePicker.layoutMargins = UIEdgeInsetsMake(marginSize, marginSize, marginSize, marginSize);
[[_backgroundView contentView] addSubview:_datePicker];

[_accessoryView setTranslatesAutoresizingMaskIntoConstraints:NO];
[_accessoryView setStandardAppearance:^{
auto appearance = adoptNS([UIToolbarAppearance new]);
[appearance setBackgroundEffect:nil];
return appearance.autorelease();
}()];
[_accessoryView sizeToFit];
[[_backgroundView contentView] addSubview:_accessoryView.get()];

CGFloat toolbarBottomMargin = _datePicker.datePickerMode == UIDatePickerModeDateAndTime ? 10 : 2;
[NSLayoutConstraint activateConstraints:@[
[[_backgroundView leadingAnchor] constraintEqualToAnchor:self.leadingAnchor],
[[_backgroundView trailingAnchor] constraintEqualToAnchor:self.trailingAnchor],
[[_backgroundView topAnchor] constraintEqualToAnchor:self.topAnchor],
[[_backgroundView bottomAnchor] constraintEqualToAnchor:self.bottomAnchor],
[[_datePicker leadingAnchor] constraintEqualToAnchor:self.leadingAnchor],
[[_datePicker trailingAnchor] constraintEqualToAnchor:self.trailingAnchor],
[[_datePicker topAnchor] constraintEqualToAnchor:self.topAnchor],
[[_datePicker bottomAnchor] constraintEqualToSystemSpacingBelowAnchor:[_accessoryView topAnchor] multiplier:1],
[[_accessoryView leadingAnchor] constraintEqualToAnchor:self.leadingAnchor],
[[_accessoryView trailingAnchor] constraintEqualToAnchor:self.trailingAnchor],
[[_accessoryView bottomAnchor] constraintEqualToAnchor:self.bottomAnchor constant:-toolbarBottomMargin],
]];

return self;
}

- (UIDatePicker *)datePicker
{
return _datePicker;
}

- (UIToolbar *)accessoryView
{
return _accessoryView.get();
}

@end

@interface WKDatePickerPopoverController () <UIPopoverPresentationControllerDelegate>

@end

@implementation WKDatePickerPopoverController {
RetainPtr<WKDatePickerPopoverView> _contentView;
__weak id<WKDatePickerPopoverControllerDelegate> _delegate;
}

- (instancetype)initWithDatePicker:(UIDatePicker *)datePicker delegate:(id<WKDatePickerPopoverControllerDelegate>)delegate
{
if (!(self = [super init]))
return nil;

_contentView = adoptNS([[WKDatePickerPopoverView alloc] initWithDatePicker:datePicker]);
_delegate = delegate;
self.modalPresentationStyle = UIModalPresentationPopover;
self.popoverPresentationController.delegate = self;
return self;
}

- (void)resetDatePicker
{
[_delegate datePickerPopoverControllerDidReset:self];
}

- (void)dismissDatePicker
{
[self.presentingViewController dismissViewControllerAnimated:YES completion:[strongSelf = retainPtr(self)] {
#if PLATFORM(MACCATALYST)
[strongSelf->_delegate datePickerPopoverControllerDidDismiss:strongSelf.get()];
#endif
}];
}

- (void)viewDidLoad
{
[super viewDidLoad];

auto resetButton = adoptNS([[UIBarButtonItem alloc] initWithTitle:WEB_UI_STRING_KEY("Reset", "Reset Button Date/Time Context Menu", "Reset button in date input context menu") style:UIBarButtonItemStylePlain target:self action:@selector(resetDatePicker)]);
auto doneButton = adoptNS([[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(dismissDatePicker)]);

[_contentView setTranslatesAutoresizingMaskIntoConstraints:NO];
[_contentView accessoryView].items = @[ resetButton.get(), UIBarButtonItem.flexibleSpaceItem, doneButton.get() ];

[self.view addSubview:_contentView.get()];

[NSLayoutConstraint activateConstraints:@[
[[_contentView leadingAnchor] constraintEqualToAnchor:self.view.leadingAnchor],
[[_contentView trailingAnchor] constraintEqualToAnchor:self.view.trailingAnchor],
[[_contentView topAnchor] constraintEqualToAnchor:self.view.topAnchor],
[[_contentView bottomAnchor] constraintGreaterThanOrEqualToAnchor:self.view.layoutMarginsGuide.bottomAnchor]
]];

self.preferredContentSize = [_contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize];
}

- (void)presentInView:(UIView *)view sourceRect:(CGRect)rect interactionBounds:(CGRect)interactionBounds completion:(void(^)())completion
{
RetainPtr controller = [UIViewController _viewControllerForFullScreenPresentationFromView:view];

while ([controller isBeingDismissed]) {
// When tabbing between date pickers, it's possible for the view controller for fullscreen presentation
// to be the previously focused input's popover. To ensure that we don't try to present our new
// `WKDatePickerPopoverController` out of the previous `WKDatePickerPopoverController`, march up the
// -presentingViewController chain until we find a view controller that isn't being dismissed.
controller = [controller presentingViewController];
}

if (!controller)
return completion();

// Specifying arrow directions is necessary here because UIKit will prefer to show the popover below the
// source rect and cover the source rect with the arrow, even if `-canOverlapSourceViewRect` is `NO`.
// To prevent the popover arrow from covering the element, we force UIKit to choose the direction that
// has the most available space, so won't cover the element with the popover arrow unless we really have
// no other choice.
auto presentationController = self.popoverPresentationController;
auto distanceFromTop = CGRectGetMinY(rect) - CGRectGetMinY(interactionBounds);
auto distanceFromLeft = CGRectGetMinX(rect) - CGRectGetMinX(interactionBounds);
auto distanceFromRight = CGRectGetMaxX(interactionBounds) - CGRectGetMaxX(rect);
auto distanceFromBottom = CGRectGetMaxY(interactionBounds) - CGRectGetMaxY(rect);
auto maxDistance = std::max<CGFloat>({ distanceFromTop, distanceFromLeft, distanceFromRight, distanceFromBottom });
UIPopoverArrowDirection permittedDirections = 0;
if (distanceFromTop >= maxDistance)
permittedDirections |= UIPopoverArrowDirectionDown;
if (distanceFromLeft >= maxDistance)
permittedDirections |= UIPopoverArrowDirectionRight;
if (distanceFromRight >= maxDistance)
permittedDirections |= UIPopoverArrowDirectionLeft;
if (distanceFromBottom >= maxDistance)
permittedDirections |= UIPopoverArrowDirectionUp;
if (!permittedDirections)
permittedDirections = UIPopoverArrowDirectionAny;
presentationController.permittedArrowDirections = permittedDirections;
presentationController.sourceView = view;
presentationController.sourceRect = rect;
presentationController.canOverlapSourceViewRect = NO;
[controller presentViewController:self animated:YES completion:completion];
}

#pragma mark - UIPopoverPresentationControllerDelegate

- (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller traitCollection:(UITraitCollection *)traitCollection
{
return UIModalPresentationNone;
}

- (void)presentationControllerDidDismiss:(UIPresentationController *)presentationController
{
[_delegate datePickerPopoverControllerDidDismiss:self];
}

@end

#endif // PLATFORM(IOS_FAMILY)
Loading

0 comments on commit 9cb30cc

Please sign in to comment.