mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-18 13:51:27 +08:00

recycleNativeView filed now accepts: "always" | "never" | "auto". Always will recycle the nativeView no matter if its nativeView or android proprties are accessed. Never will disable recycling. Auto will recycle it only if nativeView and android properties are not accessed.
51 lines
1.6 KiB
TypeScript
51 lines
1.6 KiB
TypeScript
import { View } from "./core/view";
|
|
import * as utils from "../utils/utils";
|
|
import getter = utils.ios.getter;
|
|
|
|
export module ios {
|
|
export function getActualHeight(view: UIView): number {
|
|
if (view.window && !view.hidden) {
|
|
return view.frame.size.height;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
export function getStatusBarHeight(): number {
|
|
var app = getter(UIApplication, UIApplication.sharedApplication);
|
|
if (!app || app.statusBarHidden) {
|
|
return 0;
|
|
}
|
|
|
|
var statusFrame = app.statusBarFrame;
|
|
let min = Math.min(statusFrame.size.width, statusFrame.size.height);
|
|
return utils.layout.toDevicePixels(min);
|
|
}
|
|
|
|
export function _layoutRootView(rootView: View, parentBounds: CGRect) {
|
|
if (!rootView || !parentBounds) {
|
|
return;
|
|
}
|
|
|
|
let size = parentBounds.size;
|
|
let width = utils.layout.toDevicePixels(size.width);
|
|
let height = utils.layout.toDevicePixels(size.height);
|
|
|
|
var superview = (<UIView>rootView.nativeViewProtected).superview;
|
|
var superViewRotationRadians;
|
|
if (superview) {
|
|
superViewRotationRadians = atan2f(superview.transform.b, superview.transform.a);
|
|
}
|
|
|
|
var origin = parentBounds.origin;
|
|
var left = origin.x;
|
|
var top = origin.y;
|
|
|
|
var widthSpec = utils.layout.makeMeasureSpec(width, utils.layout.EXACTLY);
|
|
var heightSpec = utils.layout.makeMeasureSpec(height, utils.layout.EXACTLY);
|
|
|
|
rootView.measure(widthSpec, heightSpec);
|
|
rootView.layout(left, top, width, height);
|
|
}
|
|
}
|