UNPKG

3.11 kBJavaScriptView Raw
1import { LayoutBaseCommon, clipToBoundsProperty, isPassThroughParentEnabledProperty } from './layout-base-common';
2import { Length, paddingLeftProperty, paddingTopProperty, paddingRightProperty, paddingBottomProperty } from '../styling/style-properties';
3export * from './layout-base-common';
4export class LayoutBase extends LayoutBaseCommon {
5 [clipToBoundsProperty.getDefault]() {
6 return true;
7 }
8 [clipToBoundsProperty.setNative](value) {
9 // TODO: Use ClipRectangle if API > 16!
10 // We can't implement this without calling setClipChildren(false) on every ancestor up in the visual tree,
11 // which will kill performance. It will also lead to unwanted side effects such as other totally unrelated
12 // views being affected by setting the parents' setClipChildren to false.
13 // The problem in Android is that a ViewGroup either clips ALL of its children or it does not. Unlike iOS, the clipping
14 // cannot be controlled on a per view basis. So clipToBounds=false will have to be somehow achieved with stacking different
15 // views on top of one another in an AbsoluteLayout or GridLayout. There is always a workaround when playing with layouts.
16 //
17 // The following article explains this in detail:
18 // http://stackoverflow.com/questions/25044085/when-drawing-outside-the-view-clip-bounds-with-android-how-do-i-prevent-underli
19 console.warn(`clipToBounds with value false is not supported on Android. You can use this.android.getParent().setClipChildren(false) as an alternative`);
20 }
21 [isPassThroughParentEnabledProperty.setNative](value) {
22 this.nativeViewProtected.setPassThroughParent(value);
23 }
24 [paddingTopProperty.getDefault]() {
25 return { value: this._defaultPaddingTop, unit: 'px' };
26 }
27 [paddingTopProperty.setNative](value) {
28 org.nativescript.widgets.ViewHelper.setPaddingTop(this.nativeViewProtected, Length.toDevicePixels(value, 0) + Length.toDevicePixels(this.style.borderTopWidth, 0));
29 }
30 [paddingRightProperty.getDefault]() {
31 return { value: this._defaultPaddingRight, unit: 'px' };
32 }
33 [paddingRightProperty.setNative](value) {
34 org.nativescript.widgets.ViewHelper.setPaddingRight(this.nativeViewProtected, Length.toDevicePixels(value, 0) + Length.toDevicePixels(this.style.borderRightWidth, 0));
35 }
36 [paddingBottomProperty.getDefault]() {
37 return { value: this._defaultPaddingBottom, unit: 'px' };
38 }
39 [paddingBottomProperty.setNative](value) {
40 org.nativescript.widgets.ViewHelper.setPaddingBottom(this.nativeViewProtected, Length.toDevicePixels(value, 0) + Length.toDevicePixels(this.style.borderBottomWidth, 0));
41 }
42 [paddingLeftProperty.getDefault]() {
43 return { value: this._defaultPaddingLeft, unit: 'px' };
44 }
45 [paddingLeftProperty.setNative](value) {
46 org.nativescript.widgets.ViewHelper.setPaddingLeft(this.nativeViewProtected, Length.toDevicePixels(value, 0) + Length.toDevicePixels(this.style.borderLeftWidth, 0));
47 }
48}
49//# sourceMappingURL=layout-base.android.js.map
\No newline at end of file