Files
NativeScript/tns-core-modules/ui/layouts/dock-layout/dock-layout-common.ts
Hristo Hristov 0f14101238 recycling now happens only if nativeView and android properties are not accessed. (#4627)
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.
2017-08-01 15:04:16 +03:00

49 lines
1.6 KiB
TypeScript

import { DockLayout as DockLayoutDefinition, Dock } from ".";
import { LayoutBase, View, Property, isIOS, booleanConverter, makeValidator, makeParser } from "../layout-base";
function validateArgs(element: View): View {
if (!element) {
throw new Error("element cannot be null or undefinied.");
}
return element;
}
export * from "../layout-base";
export class DockLayoutBase extends LayoutBase implements DockLayoutDefinition {
public static getDock(element: View): Dock {
return validateArgs(element).dock;
}
public static setDock(element: View, value: Dock): void {
validateArgs(element).dock = value;
}
public stretchLastChild: boolean;
public onDockChanged(view: View, oldValue: Dock, newValue: Dock) {
//
}
}
DockLayoutBase.prototype.recycleNativeView = "auto";
const dockConverter = makeParser<Dock>(makeValidator<Dock>("left", "top", "right", "bottom"));
export const dockProperty = new Property<View, Dock>({
name: "dock", defaultValue: "left", valueChanged: (target, oldValue, newValue) => {
if (target instanceof View) {
const layout = target.parent;
if (layout instanceof DockLayoutBase) {
layout.onDockChanged(target, oldValue, newValue);
}
}
}, valueConverter: dockConverter
});
dockProperty.register(View);
export const stretchLastChildProperty = new Property<DockLayoutBase, boolean>({
name: "stretchLastChild", defaultValue: true, affectsLayout: isIOS, valueConverter: booleanConverter
});
stretchLastChildProperty.register(DockLayoutBase);