mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +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.
48 lines
1.5 KiB
TypeScript
48 lines
1.5 KiB
TypeScript
import { DockLayoutBase, View, dockProperty, stretchLastChildProperty } from "./dock-layout-common";
|
|
|
|
export * from "./dock-layout-common";
|
|
|
|
View.prototype[dockProperty.setNative] = function(this: View, value: "left" | "top" | "right" | "bottom") {
|
|
const nativeView: android.view.View = this.nativeViewProtected;
|
|
const lp = nativeView.getLayoutParams() || new org.nativescript.widgets.CommonLayoutParams();
|
|
if (lp instanceof org.nativescript.widgets.CommonLayoutParams) {
|
|
switch (value) {
|
|
case "left":
|
|
lp.dock = org.nativescript.widgets.Dock.left;
|
|
break;
|
|
|
|
case "top":
|
|
lp.dock = org.nativescript.widgets.Dock.top;
|
|
break;
|
|
|
|
case "right":
|
|
lp.dock = org.nativescript.widgets.Dock.right;
|
|
break;
|
|
|
|
case "bottom":
|
|
lp.dock = org.nativescript.widgets.Dock.bottom;
|
|
break;
|
|
|
|
default:
|
|
throw new Error(`Invalid value for dock property: ${value}`);
|
|
}
|
|
|
|
nativeView.setLayoutParams(lp);
|
|
}
|
|
}
|
|
|
|
export class DockLayout extends DockLayoutBase {
|
|
nativeViewProtected: org.nativescript.widgets.DockLayout;
|
|
|
|
public createNativeView() {
|
|
return new org.nativescript.widgets.DockLayout(this._context);
|
|
}
|
|
|
|
[stretchLastChildProperty.getDefault](): boolean {
|
|
return true;
|
|
}
|
|
[stretchLastChildProperty.setNative](value: boolean) {
|
|
this.nativeViewProtected.setStretchLastChild(value);
|
|
}
|
|
}
|