Added iosSwipeBackNavigationEnabled

This commit is contained in:
vakrilov
2016-10-04 13:31:17 +03:00
parent 702b7eadd3
commit 53a60e2553
3 changed files with 57 additions and 9 deletions

View File

@ -41,9 +41,21 @@ function onActionBarHiddenPropertyChanged(data: PropertyChangeData) {
(<proxy.PropertyMetadata>actionBarHiddenProperty.metadata).onSetNativeValue = onActionBarHiddenPropertyChanged;
const iosSwipeBackNavigationEnabledProperty = new Property("isoSwipeBackNavigationEnabled", "Page", new proxy.PropertyMetadata(true));
function iosSwipeBackNavigationEnabledPropertyChanged(data: PropertyChangeData) {
const page = <Page>data.object;
if (page.isLoaded) {
page._updateSwipeBackNavigationEnabled(data.newValue);
}
}
(<proxy.PropertyMetadata>iosSwipeBackNavigationEnabledProperty.metadata).onSetNativeValue = iosSwipeBackNavigationEnabledPropertyChanged;
export class Page extends ContentView implements dts.Page {
public static backgroundSpanUnderStatusBarProperty = backgroundSpanUnderStatusBarProperty;
public static actionBarHiddenProperty = actionBarHiddenProperty;
public static iosSwipeBackNavigationEnabledProperty = iosSwipeBackNavigationEnabledProperty;
public static navigatingToEvent = "navigatingTo";
public static navigatedToEvent = "navigatedTo";
public static navigatingFromEvent = "navigatingFrom";
@ -97,10 +109,22 @@ export class Page extends ContentView implements dts.Page {
this._setValue(Page.actionBarHiddenProperty, value);
}
get iosSwipeBackNavigationEnabled(): boolean {
return this._getValue(Page.iosSwipeBackNavigationEnabledProperty);
}
set iosSwipeBackNavigationEnabled(value: boolean) {
this._setValue(Page.iosSwipeBackNavigationEnabledProperty, value);
}
public _updateActionBar(hidden: boolean) {
//
}
public _updateSwipeBackNavigationEnabled(hidden: boolean) {
//
}
get navigationContext(): any {
return this._navigationContext;
}

View File

@ -61,6 +61,11 @@ declare module "ui/page" {
*/
public static actionBarHiddenProperty: dependencyObservable.Property;
/**
* Dependency property used to control if swipe back navigation in IOS is enabled. Default value: true
*/
public static isoSwipeBackNavigationEnabledProperty: dependencyObservable.Property;
/**
* String value used when hooking to showingModally event.
*/
@ -101,6 +106,11 @@ declare module "ui/page" {
*/
actionBarHidden: boolean;
/**
* Used to control if swipe back navigation in IOS is enabled. Default value: true
*/
iosSwipeBackNavigationEnabled: boolean;
/**
* A valid css string which will be applied for all nested UI components (based on css rules).
*/

View File

@ -216,7 +216,12 @@ class UIViewControllerImpl extends UIViewController {
frame.ios.controller.delegate = this[DELEGATE];
// Workaround for disabled backswipe on second custom native transition
if (frame.canGoBack()) {
this.navigationController.interactivePopGestureRecognizer.delegate = this.navigationController;
this.navigationController.interactivePopGestureRecognizer.enabled = page.iosSwipeBackNavigationEnabled;
} else {
this.navigationController.interactivePopGestureRecognizer.enabled = false;
}
frame._processNavigationQueue(page);
}
@ -424,6 +429,15 @@ export class Page extends pageCommon.Page {
}
}
public _updateSwipeBackNavigationEnabled(enabled: boolean) {
const navController = this._ios.navigationController;
if (this.frame && navController && navController.interactivePopGestureRecognizer) {
// Make sure we don't set true if cannot go back
enabled = enabled && this.frame.canGoBack();
navController.interactivePopGestureRecognizer.enabled = enabled;
}
}
public onMeasure(widthMeasureSpec: number, heightMeasureSpec: number) {
let width = utils.layout.getMeasureSpecSize(widthMeasureSpec);
let widthMode = utils.layout.getMeasureSpecMode(widthMeasureSpec);