mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Minor fixes + more green tests
This commit is contained in:
@@ -80,6 +80,6 @@ export function stopMonitoring(): void {
|
||||
if (_monitorReachabilityRef) {
|
||||
SCNetworkReachabilityUnscheduleFromRunLoop(_monitorReachabilityRef, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
|
||||
_monitorReachabilityRef = undefined;
|
||||
_connectionTypeChangedCallback = undefined;;
|
||||
_connectionTypeChangedCallback = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ export class ImageSource implements definition.ImageSource {
|
||||
|
||||
public toBase64String(format: string, quality = 100): string {
|
||||
if (!this.android) {
|
||||
return null;;
|
||||
return null;
|
||||
}
|
||||
|
||||
var targetFormat = getTargetFormat(format);
|
||||
|
||||
@@ -38,6 +38,6 @@ export class ActivityIndicator extends ActivityIndicatorBase {
|
||||
return this.nativeView.color;
|
||||
}
|
||||
set [colorProperty.native](value: UIColor | Color) {
|
||||
this.nativeView.color = value instanceof Color ? value.ios : value;;
|
||||
this.nativeView.color = value instanceof Color ? value.ios : value;
|
||||
}
|
||||
}
|
||||
@@ -104,7 +104,7 @@ export class ViewBase extends Observable implements ViewBaseDefinition {
|
||||
public bindingContext: any;
|
||||
public nativeView: any;
|
||||
public parent: ViewBase;
|
||||
public isCollapsed = false;
|
||||
public isCollapsed; // Default(false) set in prototype
|
||||
|
||||
public id: string;
|
||||
public className: string;
|
||||
@@ -487,7 +487,8 @@ export class ViewBase extends Observable implements ViewBaseDefinition {
|
||||
this._initNativeView();
|
||||
|
||||
if (this.parent) {
|
||||
this._isAddedToNativeVisualTree = this.parent._addViewToNativeVisualTree(this, atIndex);
|
||||
let nativeIndex = this.parent._childIndexToNativeChildIndex(atIndex);
|
||||
this._isAddedToNativeVisualTree = this.parent._addViewToNativeVisualTree(this, nativeIndex);
|
||||
}
|
||||
|
||||
if (this.nativeView) {
|
||||
@@ -614,6 +615,8 @@ export class ViewBase extends Observable implements ViewBaseDefinition {
|
||||
}
|
||||
}
|
||||
|
||||
ViewBase.prototype.isCollapsed = false;
|
||||
|
||||
export const bindingContextProperty = new InheritedProperty<ViewBase, any>({ name: "bindingContext" });
|
||||
bindingContextProperty.register(ViewBase);
|
||||
|
||||
|
||||
@@ -785,14 +785,6 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition {
|
||||
return callback(this);
|
||||
}
|
||||
|
||||
_addToSuperview(superview: any, index?: number): boolean {
|
||||
// IOS specific
|
||||
return false;
|
||||
}
|
||||
_removeFromSuperview(): void {
|
||||
// IOS specific
|
||||
}
|
||||
|
||||
// public unsetInheritedProperties(): void {
|
||||
// // this._setValue(ProxyObject.bindingContextProperty, undefined, ValueSource.Inherited);
|
||||
// // this._eachSetProperty((property) => {
|
||||
|
||||
3
tns-core-modules/ui/core/view.d.ts
vendored
3
tns-core-modules/ui/core/view.d.ts
vendored
@@ -536,9 +536,6 @@ declare module "ui/core/view" {
|
||||
|
||||
_eachLayoutView(callback: (View) => void): void;
|
||||
|
||||
_addToSuperview(superview: any, index?: number): boolean;
|
||||
_removeFromSuperview();
|
||||
|
||||
public _applyXmlAttribute(attribute: string, value: any): boolean;
|
||||
public eachChildView(callback: (view: View) => boolean): void;
|
||||
|
||||
|
||||
@@ -268,26 +268,6 @@ export class View extends ViewCommon {
|
||||
}
|
||||
}
|
||||
|
||||
public _addToSuperview(superview: any, atIndex: number = Number.POSITIVE_INFINITY): boolean {
|
||||
if (superview && this.nativeView) {
|
||||
if (atIndex >= superview.subviews.count) {
|
||||
superview.addSubview(this.nativeView);
|
||||
} else {
|
||||
superview.insertSubviewAtIndex(this.nativeView, atIndex);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public _removeFromSuperview() {
|
||||
if (this.nativeView) {
|
||||
this.nativeView.removeFromSuperview();
|
||||
}
|
||||
}
|
||||
|
||||
// By default we update the view's presentation layer when setting backgroundColor and opacity properties.
|
||||
// This is done by calling CATransaction begin and commit methods.
|
||||
// This action should be disabled when updating those properties during an animation.
|
||||
@@ -457,12 +437,27 @@ export class CustomLayoutView extends View {
|
||||
public _addViewToNativeVisualTree(child: View, atIndex: number): boolean {
|
||||
super._addViewToNativeVisualTree(child, atIndex);
|
||||
|
||||
return child._addToSuperview(this.nativeView, atIndex);
|
||||
const parentNativeView = this.nativeView;
|
||||
const childNativeView = child.nativeView;
|
||||
|
||||
if (parentNativeView && childNativeView) {
|
||||
if (typeof atIndex !== "number" || atIndex >= parentNativeView.subviews.count) {
|
||||
parentNativeView.addSubview(childNativeView);
|
||||
} else {
|
||||
parentNativeView.insertSubviewAtIndex(childNativeView, atIndex);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public _removeViewFromNativeVisualTree(child: View): void {
|
||||
super._removeViewFromNativeVisualTree(child);
|
||||
|
||||
child._removeFromSuperview();
|
||||
if (child.nativeView) {
|
||||
child.nativeView.removeFromSuperview();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import {
|
||||
traceEnabled, traceWrite, traceCategories
|
||||
} from "./image-common";
|
||||
|
||||
export * from "./image-common";;
|
||||
export * from "./image-common";
|
||||
|
||||
export class Image extends ImageBase {
|
||||
private _ios: UIImageView;
|
||||
|
||||
@@ -126,10 +126,10 @@ export class LayoutBaseCommon extends CustomLayoutView implements LayoutBaseDefi
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public eachLayoutChild(callback: (child: View, isLast: boolean) => void): void {
|
||||
var lastChild: View = null;
|
||||
|
||||
|
||||
this.eachChildView((cv) => {
|
||||
cv._eachLayoutView((lv) => {
|
||||
if (lastChild && !lastChild.isCollapsed) {
|
||||
@@ -141,7 +141,7 @@ export class LayoutBaseCommon extends CustomLayoutView implements LayoutBaseDefi
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
|
||||
if (lastChild && !lastChild.isCollapsed) {
|
||||
callback(lastChild, true);
|
||||
}
|
||||
@@ -149,5 +149,5 @@ export class LayoutBaseCommon extends CustomLayoutView implements LayoutBaseDefi
|
||||
}
|
||||
}
|
||||
|
||||
export const clipToBoundsProperty = new Property<LayoutBaseCommon, boolean>({name: "clipToBounds", defaultValue: true});
|
||||
export const clipToBoundsProperty = new Property<LayoutBaseCommon, boolean>({ name: "clipToBounds", defaultValue: true });
|
||||
clipToBoundsProperty.register(LayoutBaseCommon);
|
||||
@@ -37,8 +37,8 @@ export class Progress extends ProgressBase {
|
||||
get [colorProperty.native](): UIColor {
|
||||
return this._ios.progressTintColor;
|
||||
}
|
||||
set [colorProperty.native](value: Color) {
|
||||
this._ios.progressTintColor = value instanceof Color ? value.ios : value;;
|
||||
set [colorProperty.native](value: Color | UIColor) {
|
||||
this._ios.progressTintColor = value instanceof Color ? value.ios : value;
|
||||
}
|
||||
|
||||
get [backgroundColorProperty.native](): UIColor {
|
||||
|
||||
@@ -6,13 +6,9 @@ import { LayoutBase, View, traceEnabled, traceWrite, traceCategories } from "ui/
|
||||
*/
|
||||
// Cases to cover:
|
||||
// * Child is added to the attached proxy. Handled in _addViewToNativeVisualTree.
|
||||
// * Proxy (with children) is added to the DOM.
|
||||
// - IOS: Handled in _addToSuperview - when the proxy is added, it adds all its children to the new parent.
|
||||
// - Android: _onAttached calls _addViewToNativeVisualTree recursively when the proxy is added to the parent.
|
||||
// * Proxy (with children) is added to the DOM. In _addViewToNativeVisualTree _addViewToNativeVisualTree recursively when the proxy is added to the parent.
|
||||
// * Child is removed from attached proxy. Handled in _removeViewFromNativeVisualTree.
|
||||
// * Proxy (with children) is removed form the DOM.
|
||||
// - IOS: Handled in _removeFromSuperview - when the proxy is removed, it removes all its children from its parent.
|
||||
// - Android: _onDetached calls _removeViewFromNativeVisualTree recursively when the proxy is removed from its parent.
|
||||
// * Proxy (with children) is removed form the DOM. In _removeViewFromNativeVisualTree recursively when the proxy is removed from its parent.
|
||||
export class ProxyViewContainer extends LayoutBase implements ProxyViewContainerDefinition {
|
||||
// No native view for proxy container.
|
||||
get ios(): any {
|
||||
@@ -97,27 +93,6 @@ export class ProxyViewContainer extends LayoutBase implements ProxyViewContainer
|
||||
}
|
||||
}
|
||||
|
||||
public _addToSuperview(superview: any, atIndex?: number): boolean {
|
||||
let index = 0;
|
||||
this.eachChildView((cv) => {
|
||||
if (!cv._isAddedToNativeVisualTree) {
|
||||
cv._isAddedToNativeVisualTree = this._addViewToNativeVisualTree(cv, index++);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public _removeFromSuperview() {
|
||||
this.eachChildView((cv) => {
|
||||
if (cv._isAddedToNativeVisualTree) {
|
||||
this._removeViewFromNativeVisualTree(cv);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* Some layouts (e.g. GridLayout) need to get notified when adding and
|
||||
* removing children, so that they can update private measure data.
|
||||
|
||||
Reference in New Issue
Block a user