mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 12:57:42 +08:00
ScrollingContent is not checking innerviews anymore
This commit is contained in:
@ -530,33 +530,23 @@ export class CustomLayoutView extends View {
|
|||||||
function isScrollable(controller: UIViewController, owner: View): boolean {
|
function isScrollable(controller: UIViewController, owner: View): boolean {
|
||||||
let scrollable = (<any>owner).scrollableContent;
|
let scrollable = (<any>owner).scrollableContent;
|
||||||
if (scrollable === undefined) {
|
if (scrollable === undefined) {
|
||||||
let view = controller.view;
|
let view: UIView = controller.view.subviews.count > 0 ? controller.view.subviews[0] : null;
|
||||||
while (view) {
|
if (!(controller instanceof ios.UILayoutViewController)) {
|
||||||
if (view instanceof UIScrollView) {
|
// Propbably we are PageViewController. Consider different cases
|
||||||
scrollable = true;
|
if (view && view.subviews.count > 0) {
|
||||||
break;
|
// Take page content.
|
||||||
|
view = view.subviews[0];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
view = view.subviews.count > 0 ? view.subviews[0] : null;
|
if (view instanceof UIScrollView) {
|
||||||
|
scrollable = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return scrollable === true || scrollable === "true";;
|
return scrollable === true || scrollable === "true";;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getStatusBarHeight(controller: UIViewController): number {
|
|
||||||
let shouldReturnStatusBarHeight = false;
|
|
||||||
if (controller.presentingViewController) {
|
|
||||||
if (CGRectEqualToRect(controller.view.frame, controller.view.window.bounds)) {
|
|
||||||
shouldReturnStatusBarHeight = true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
shouldReturnStatusBarHeight = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return shouldReturnStatusBarHeight ? uiUtils.ios.getStatusBarHeight(controller) : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
const majorVersion = iosUtils.MajorVersion;
|
const majorVersion = iosUtils.MajorVersion;
|
||||||
|
|
||||||
interface ExtendedController extends UIViewController {
|
interface ExtendedController extends UIViewController {
|
||||||
@ -574,65 +564,60 @@ interface ExtendedController extends UIViewController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export namespace ios {
|
export namespace ios {
|
||||||
function constrainView(controller: UIViewController, owner: View): void {
|
function constrainView(controller: ExtendedController, owner: View): void {
|
||||||
const root = controller.view;
|
const root = controller.view;
|
||||||
const view = root.subviews[0];
|
const view = root.subviews[0];
|
||||||
const extendedController = <ExtendedController>controller;
|
|
||||||
|
|
||||||
if (!extendedController.safeAreaTop) {
|
if (!controller.safeAreaTop) {
|
||||||
view.translatesAutoresizingMaskIntoConstraints = false;
|
view.translatesAutoresizingMaskIntoConstraints = false;
|
||||||
if (majorVersion > 10) {
|
if (majorVersion > 10) {
|
||||||
const safeArea = root.safeAreaLayoutGuide;
|
const safeArea = root.safeAreaLayoutGuide;
|
||||||
extendedController.safeAreaTop = view.topAnchor.constraintEqualToAnchor(safeArea.topAnchor);
|
controller.safeAreaTop = view.topAnchor.constraintEqualToAnchor(safeArea.topAnchor);
|
||||||
extendedController.fullscreenTop = view.topAnchor.constraintEqualToAnchor(root.topAnchor);
|
controller.fullscreenTop = view.topAnchor.constraintEqualToAnchor(root.topAnchor);
|
||||||
extendedController.safeAreaBottom = view.bottomAnchor.constraintEqualToAnchor(safeArea.bottomAnchor);
|
controller.safeAreaBottom = view.bottomAnchor.constraintEqualToAnchor(safeArea.bottomAnchor);
|
||||||
extendedController.fullscreenBottom = view.bottomAnchor.constraintEqualToAnchor(root.bottomAnchor);
|
controller.fullscreenBottom = view.bottomAnchor.constraintEqualToAnchor(root.bottomAnchor);
|
||||||
extendedController.safeAreaLeft = view.leftAnchor.constraintEqualToAnchor(safeArea.leftAnchor);
|
controller.safeAreaLeft = view.leftAnchor.constraintEqualToAnchor(safeArea.leftAnchor);
|
||||||
extendedController.safeAreaRight = view.rightAnchor.constraintEqualToAnchor(safeArea.rightAnchor);
|
controller.safeAreaRight = view.rightAnchor.constraintEqualToAnchor(safeArea.rightAnchor);
|
||||||
} else {
|
} else {
|
||||||
extendedController.safeAreaTop = view.topAnchor.constraintEqualToAnchor(controller.topLayoutGuide.bottomAnchor);
|
controller.safeAreaTop = view.topAnchor.constraintEqualToAnchor(controller.topLayoutGuide.bottomAnchor);
|
||||||
extendedController.fullscreenTop = view.topAnchor.constraintEqualToAnchor(root.topAnchor);
|
controller.fullscreenTop = view.topAnchor.constraintEqualToAnchor(root.topAnchor);
|
||||||
extendedController.safeAreaBottom = view.bottomAnchor.constraintEqualToAnchor(controller.bottomLayoutGuide.topAnchor);
|
controller.safeAreaBottom = view.bottomAnchor.constraintEqualToAnchor(controller.bottomLayoutGuide.topAnchor);
|
||||||
extendedController.fullscreenBottom = view.bottomAnchor.constraintEqualToAnchor(root.bottomAnchor);
|
controller.fullscreenBottom = view.bottomAnchor.constraintEqualToAnchor(root.bottomAnchor);
|
||||||
extendedController.safeAreaLeft = view.leadingAnchor.constraintEqualToAnchor(root.leadingAnchor);
|
controller.safeAreaLeft = view.leadingAnchor.constraintEqualToAnchor(root.leadingAnchor);
|
||||||
extendedController.safeAreaRight = view.trailingAnchor.constraintEqualToAnchor(root.trailingAnchor);
|
controller.safeAreaRight = view.trailingAnchor.constraintEqualToAnchor(root.trailingAnchor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const navController = controller.navigationController;
|
const navBarHidden = controller.navBarHidden;
|
||||||
const navBarHidden = navController ? navController.navigationBarHidden : true;
|
const scrollable = controller.scrollable;;
|
||||||
const scrollable = (owner && isScrollable(controller, owner));
|
const hasChildControllers = controller.hasChildControllers;
|
||||||
const hasChildControllers = controller.childViewControllers.count > 0;
|
|
||||||
const constraints = [
|
const constraints = [
|
||||||
hasChildControllers || scrollable ? extendedController.fullscreenBottom : extendedController.safeAreaBottom,
|
hasChildControllers || scrollable ? controller.fullscreenBottom : controller.safeAreaBottom,
|
||||||
extendedController.safeAreaLeft,
|
controller.safeAreaLeft,
|
||||||
extendedController.safeAreaRight
|
controller.safeAreaRight
|
||||||
];
|
];
|
||||||
|
|
||||||
if (hasChildControllers) {
|
if (hasChildControllers) {
|
||||||
// If not inner most extend to fullscreen
|
// If not inner most extend to fullscreen
|
||||||
constraints.push(extendedController.fullscreenTop);
|
constraints.push(controller.fullscreenTop);
|
||||||
} else if (!scrollable) {
|
} else if (!scrollable) {
|
||||||
// If not scrollable dock under safe area
|
// If not scrollable dock under safe area
|
||||||
constraints.push(extendedController.safeAreaTop);
|
constraints.push(controller.safeAreaTop);
|
||||||
} else if (navBarHidden) {
|
} else if (navBarHidden) {
|
||||||
// If scrollable but no navigation bar dock under safe area
|
// If scrollable but no navigation bar dock under safe area
|
||||||
constraints.push(extendedController.safeAreaTop);
|
constraints.push(controller.safeAreaTop);
|
||||||
} else {
|
} else {
|
||||||
// If scrollable and navigation bar extend to fullscreen
|
// If scrollable and navigation bar extend to fullscreen
|
||||||
constraints.push(extendedController.fullscreenTop);
|
constraints.push(controller.fullscreenTop);
|
||||||
}
|
}
|
||||||
|
|
||||||
const activeConstraints = extendedController.activeConstraints;
|
const activeConstraints = controller.activeConstraints;
|
||||||
if (activeConstraints) {
|
if (activeConstraints) {
|
||||||
NSLayoutConstraint.deactivateConstraints(<any>activeConstraints);
|
NSLayoutConstraint.deactivateConstraints(<any>activeConstraints);
|
||||||
}
|
}
|
||||||
NSLayoutConstraint.activateConstraints(<any>constraints);
|
|
||||||
|
|
||||||
extendedController.scrollable = scrollable;
|
NSLayoutConstraint.activateConstraints(<any>constraints);
|
||||||
extendedController.navBarHidden = navBarHidden;
|
controller.activeConstraints = constraints;
|
||||||
extendedController.hasChildControllers = hasChildControllers;
|
|
||||||
extendedController.activeConstraints = constraints;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function updateConstraints(controller: UIViewController, owner: View): void {
|
export function updateConstraints(controller: UIViewController, owner: View): void {
|
||||||
@ -645,13 +630,16 @@ export namespace ios {
|
|||||||
if (extendedController.scrollable !== scrollable
|
if (extendedController.scrollable !== scrollable
|
||||||
|| extendedController.navBarHidden !== navBarHidden
|
|| extendedController.navBarHidden !== navBarHidden
|
||||||
|| extendedController.hasChildControllers !== hasChildControllers) {
|
|| extendedController.hasChildControllers !== hasChildControllers) {
|
||||||
|
extendedController.scrollable = scrollable;
|
||||||
|
extendedController.navBarHidden = navBarHidden;
|
||||||
|
extendedController.hasChildControllers = hasChildControllers;
|
||||||
constrainView(extendedController, owner);
|
constrainView(extendedController, owner);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function layoutView(controller: UIViewController, owner: View): void {
|
export function layoutView(controller: UIViewController, owner: View): void {
|
||||||
// If we are not last controller - don't
|
// If we are not most inner controller - don't layout
|
||||||
if (controller.childViewControllers.count > 0) {// || controller.view !== owner.nativeView.superview) {
|
if (controller.childViewControllers.count > 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user