mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
feat(view): "hidden" property binding is now supported
This commit is contained in:
@@ -1163,6 +1163,19 @@ export const bindingContextProperty = new InheritedProperty<ViewBase, any>({
|
||||
});
|
||||
bindingContextProperty.register(ViewBase);
|
||||
|
||||
export const hiddenProperty = new Property<ViewBase, boolean>({
|
||||
name: 'hidden',
|
||||
defaultValue: false,
|
||||
affectsLayout: global.isIOS,
|
||||
valueConverter: booleanConverter,
|
||||
valueChanged: (target, oldValue, newValue) => {
|
||||
if (target) {
|
||||
target.isCollapsed = !!newValue;
|
||||
}
|
||||
},
|
||||
});
|
||||
hiddenProperty.register(ViewBase);
|
||||
|
||||
export const classNameProperty = new Property<ViewBase, string>({
|
||||
name: 'className',
|
||||
valueChanged(view: ViewBase, oldValue: string, newValue: string) {
|
||||
|
||||
@@ -7,7 +7,7 @@ import { ViewCommon, isEnabledProperty, originXProperty, originYProperty, isUser
|
||||
import { paddingLeftProperty, paddingTopProperty, paddingRightProperty, paddingBottomProperty } from '../../styling/style-properties';
|
||||
import { layout } from '../../../utils';
|
||||
import { Trace } from '../../../trace';
|
||||
import { ShowModalOptions } from '../view-base';
|
||||
import { ShowModalOptions, hiddenProperty } from '../view-base';
|
||||
import { EventData } from '../../../data/observable';
|
||||
|
||||
import { perspectiveProperty, visibilityProperty, opacityProperty, horizontalAlignmentProperty, verticalAlignmentProperty, minWidthProperty, minHeightProperty, widthProperty, heightProperty, marginLeftProperty, marginTopProperty, marginRightProperty, marginBottomProperty, rotateProperty, rotateXProperty, rotateYProperty, scaleXProperty, scaleYProperty, translateXProperty, translateYProperty, zIndexProperty, backgroundInternalProperty, androidElevationProperty, androidDynamicElevationOffsetProperty } from '../../styling/style-properties';
|
||||
@@ -730,6 +730,13 @@ export class View extends ViewCommon {
|
||||
this.nativeViewProtected.setFocusable(value);
|
||||
}
|
||||
|
||||
[hiddenProperty.getDefault](): boolean {
|
||||
return this.nativeViewProtected.getVisibility() === android.view.View.GONE;
|
||||
}
|
||||
[hiddenProperty.setNative](value: boolean) {
|
||||
this.nativeViewProtected.setVisibility(value ? android.view.View.GONE : android.view.View.VISIBLE);
|
||||
}
|
||||
|
||||
[visibilityProperty.getDefault](): CoreTypes.VisibilityType {
|
||||
const nativeVisibility = this.nativeViewProtected.getVisibility();
|
||||
switch (nativeVisibility) {
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Point, View as ViewDefinition } from '.';
|
||||
|
||||
// Requires
|
||||
import { ViewCommon, isEnabledProperty, originXProperty, originYProperty, isUserInteractionEnabledProperty } from './view-common';
|
||||
import { ShowModalOptions } from '../view-base';
|
||||
import { ShowModalOptions, hiddenProperty } from '../view-base';
|
||||
import { Trace } from '../../../trace';
|
||||
import { layout, iOSNativeHelper } from '../../../utils';
|
||||
import { IOSHelper } from './view-helper';
|
||||
@@ -643,6 +643,13 @@ export class View extends ViewCommon implements ViewDefinition {
|
||||
this.nativeViewProtected.userInteractionEnabled = value;
|
||||
}
|
||||
|
||||
[hiddenProperty.getDefault](): boolean {
|
||||
return this.nativeViewProtected.hidden;
|
||||
}
|
||||
[hiddenProperty.setNative](value: boolean) {
|
||||
this.nativeViewProtected.hidden = value;
|
||||
}
|
||||
|
||||
[visibilityProperty.getDefault](): CoreTypes.VisibilityType {
|
||||
return this.nativeViewProtected.hidden ? CoreTypes.Visibility.collapse : CoreTypes.Visibility.visible;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user