| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 02d35ab commit 719e118
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -67,7 +67,6 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition { | |||
| 67 | 67 | public static layoutChangedEvent = "layoutChanged"; | |
| 68 | 68 | public static shownModallyEvent = "shownModally"; | |
| 69 | 69 | public static showingModallyEvent = "showingModally"; | |
| 70 | - public static popoverClosedEvent = "popoverClosed"; | ||
| 71 | 70 | ||
| 72 | 71 | protected _closeModalCallback: Function; | |
| 73 | 72 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -113,11 +113,6 @@ export abstract class View extends ViewBase { | |||
| 113 | 113 | */ | |
| 114 | 114 | public static showingModallyEvent: string; | |
| 115 | 115 | ||
| 116 | - /** | ||
| 117 | - * String value used when hooking to popoverClosed event. | ||
| 118 | - */ | ||
| 119 | - public static popoverClosedEvent: string; | ||
| 120 | - | ||
| 121 | 116 | /** | |
| 122 | 117 | * String value used when hooking to shownModally event. | |
| 123 | 118 | */ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,6 @@ | |||
| 1 | 1 | // Definitions. | |
| 2 | 2 | import { Point, View as ViewDefinition, dip } from "."; | |
| 3 | - import { ViewBase, EventData } from "../view-base"; | ||
| 3 | + import { ViewBase } from "../view-base"; | ||
| 4 | 4 | ||
| 5 | 5 | import { | |
| 6 | 6 | ViewCommon, layout, isEnabledProperty, originXProperty, originYProperty, automationTextProperty, isUserInteractionEnabledProperty, | |
@@ -44,11 +44,6 @@ export class View extends ViewCommon { | |||
| 44 | 44 | */ | |
| 45 | 45 | _nativeBackgroundState: "unset" | "invalid" | "drawn"; | |
| 46 | 46 | ||
| 47 | - constructor() { | ||
| 48 | - super(); | ||
| 49 | - this.on(ViewCommon.popoverClosedEvent, this.closeModal.bind(this)); | ||
| 50 | - } | ||
| 51 | - | ||
| 52 | 47 | get isLayoutRequired(): boolean { | |
| 53 | 48 | return (this._privateFlags & PFLAG_LAYOUT_REQUIRED) === PFLAG_LAYOUT_REQUIRED; | |
| 54 | 49 | } | |
@@ -422,7 +417,7 @@ export class View extends ViewCommon { | |||
| 422 | 417 | ||
| 423 | 418 | if (presentationStyle === UIModalPresentationStyle.Popover) { | |
| 424 | 419 | const popoverPresentationController = controller.popoverPresentationController; | |
| 425 | - this._popoverPresentationDelegate = ios.UIPopoverPresentationControllerDelegateImp.initWithOwner(new WeakRef(this)); | ||
| 420 | + this._popoverPresentationDelegate = ios.UIPopoverPresentationControllerDelegateImp.initWithOwner(new WeakRef(this), options.closeCallback); | ||
| 426 | 421 | popoverPresentationController.delegate = this._popoverPresentationDelegate; | |
| 427 | 422 | const view = parent.nativeViewProtected; | |
| 428 | 423 | // Note: sourceView and sourceRect are needed to specify the anchor location for the popover. | |
@@ -457,19 +452,10 @@ export class View extends ViewCommon { | |||
| 457 | 452 | return; | |
| 458 | 453 | } | |
| 459 | 454 | ||
| 460 | - if (!this.viewController) { | ||
| 461 | - return; | ||
| 462 | - } | ||
| 463 | - | ||
| 464 | 455 | const parentController = parent.viewController; | |
| 465 | 456 | const animated = (<any>this.viewController).animated; | |
| 466 | 457 | ||
| 467 | - if (this.viewController.popoverPresentationController && this.viewController.popoverPresentationController instanceof UIPopoverPresentationController) { | ||
| 468 | - whenClosedCallback(); | ||
| 469 | - parentController.dismissViewControllerAnimatedCompletion(animated, null); | ||
| 470 | - } else { | ||
| 471 | - parentController.dismissViewControllerAnimatedCompletion(animated, whenClosedCallback); | ||
| 472 | - } | ||
| 458 | + parentController.dismissViewControllerAnimatedCompletion(animated, whenClosedCallback); | ||
| 473 | 459 | } | |
| 474 | 460 | ||
| 475 | 461 | [isEnabledProperty.getDefault](): boolean { | |
@@ -1004,21 +990,22 @@ export namespace ios { | |||
| 1004 | 990 | public static ObjCProtocols = [UIPopoverPresentationControllerDelegate]; | |
| 1005 | 991 | ||
| 1006 | 992 | private owner: WeakRef<View>; | |
| 993 | + private whenClosedCallback: Function; | ||
| 1007 | 994 | ||
| 1008 | - public static initWithOwner(owner: WeakRef<View>): UIPopoverPresentationControllerDelegateImp { | ||
| 995 | + public static initWithOwner(owner: WeakRef<View>, whenClosedCallback: Function): UIPopoverPresentationControllerDelegateImp { | ||
| 1009 | 996 | const instance = <UIPopoverPresentationControllerDelegateImp>super.new(); | |
| 1010 | 997 | instance.owner = owner; | |
| 998 | + instance.whenClosedCallback = whenClosedCallback; | ||
| 1011 | 999 | ||
| 1012 | 1000 | return instance; | |
| 1013 | 1001 | } | |
| 1014 | 1002 | ||
| 1015 | 1003 | public popoverPresentationControllerDidDismissPopover(popoverPresentationController: UIPopoverPresentationController) { | |
| 1016 | 1004 | const owner = this.owner.get(); | |
| 1017 | 1005 | if (owner) { | |
| 1018 | - let modalClosingArgs: EventData = <EventData>{ | ||
| 1019 | - eventName: ViewCommon.popoverClosedEvent, | ||
| 1020 | - }; | ||
| 1021 | - owner.notify(modalClosingArgs); | ||
| 1006 | + if (typeof this.whenClosedCallback === "function") { | ||
| 1007 | + this.whenClosedCallback(); | ||
| 1008 | + } | ||
| 1022 | 1009 | } | |
| 1023 | 1010 | } | |
| 1024 | 1011 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments