mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 11:01:21 +08:00
feat: Scoped Packages (#7911)
* chore: move tns-core-modules to nativescript-core * chore: preparing compat generate script * chore: add missing definitions * chore: no need for http-request to be private * chore: packages chore * test: generate tests for tns-core-modules * chore: add anroid module for consistency * chore: add .npmignore * chore: added privateModulesWhitelist * chore(webpack): added bundle-entry-points * chore: scripts * chore: tests changed to use @ns/core * test: add scoped-packages test project * test: fix types * test: update test project * chore: build scripts * chore: update build script * chore: npm scripts cleanup * chore: make the compat pgk work with old wp config * test: generate diff friendly tests * chore: create barrel exports * chore: move files after rebase * chore: typedoc config * chore: compat mode * chore: review of barrels * chore: remove tns-core-modules import after rebase * chore: dev workflow setup * chore: update developer-workflow * docs: experiment with API extractor * chore: api-extractor and barrel exports * chore: api-extractor configs * chore: generate d.ts rollup with api-extractor * refactor: move methods inside Frame * chore: fic tests to use Frame static methods * refactor: create Builder class * refactor: use Builder class in tests * refactor: include Style in ui barrel * chore: separate compat build script * chore: fix tslint errors * chore: update NATIVESCRIPT_CORE_ARGS * chore: fix compat pack * chore: fix ui-test-app build with linked modules * chore: Application, ApplicationSettings, Connectivity and Http * chore: export Trace, Profiling and Utils * refactor: Static create methods for ImageSource * chore: fix deprecated usages of ImageSource * chore: move Span and FormattedString to ui * chore: add events-args and ImageSource to index files * chore: check for CLI >= 6.2 when building for IOS * chore: update travis build * chore: copy Pod file to compat package * chore: update error msg ui-tests-app * refactor: Apply suggestions from code review Co-Authored-By: Martin Yankov <m.i.yankov@gmail.com> * chore: typings and refs * chore: add missing d.ts files for public API * chore: adress code review FB * chore: update api-report * chore: dev-workflow for other apps * chore: api update * chore: update api-report
This commit is contained in:

committed by
GitHub

parent
6c7139477e
commit
cc97a16800
5
nativescript-core/ui/proxy-view-container/package.json
Normal file
5
nativescript-core/ui/proxy-view-container/package.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"name": "proxy-view-container",
|
||||
"main": "proxy-view-container",
|
||||
"types": "proxy-view-container.d.ts"
|
||||
}
|
8
nativescript-core/ui/proxy-view-container/proxy-view-container.d.ts
vendored
Normal file
8
nativescript-core/ui/proxy-view-container/proxy-view-container.d.ts
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
/**
|
||||
* @module "ui/proxy-view-container"
|
||||
*/ /** */
|
||||
|
||||
import { LayoutBase } from "../layouts/layout-base";
|
||||
|
||||
export class ProxyViewContainer extends LayoutBase {
|
||||
}
|
@ -0,0 +1,150 @@
|
||||
import { ProxyViewContainer as ProxyViewContainerDefinition } from ".";
|
||||
import { LayoutBase, View, traceEnabled, traceWrite, traceCategories, CSSType } from "../layouts/layout-base";
|
||||
/**
|
||||
* Proxy view container that adds all its native children directly to the parent.
|
||||
* To be used as a logical grouping container of views.
|
||||
*/
|
||||
// Cases to cover:
|
||||
// * Child is added to the attached proxy. Handled in _addViewToNativeVisualTree.
|
||||
// * 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. In _removeViewFromNativeVisualTree recursively when the proxy is removed from its parent.
|
||||
@CSSType("ProxyViewContainer")
|
||||
export class ProxyViewContainer extends LayoutBase implements ProxyViewContainerDefinition {
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.nativeViewProtected = undefined;
|
||||
}
|
||||
|
||||
// No native view for proxy container.
|
||||
get ios(): any {
|
||||
return null;
|
||||
}
|
||||
|
||||
get android(): any {
|
||||
return null;
|
||||
}
|
||||
|
||||
// get nativeView(): any {
|
||||
// return null;
|
||||
// }
|
||||
|
||||
get isLayoutRequested(): boolean {
|
||||
// Always return false so all layout requests from children bubble up.
|
||||
return false;
|
||||
}
|
||||
|
||||
public createNativeView() {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public _getNativeViewsCount(): number {
|
||||
let result = 0;
|
||||
this.eachChildView((cv) => {
|
||||
result += cv._getNativeViewsCount();
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public _eachLayoutView(callback: (View) => void): void {
|
||||
this.eachChildView((cv) => {
|
||||
if (!cv.isCollapsed) {
|
||||
cv._eachLayoutView(callback);
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
public _addViewToNativeVisualTree(child: View, atIndex?: number): boolean {
|
||||
if (traceEnabled()) {
|
||||
traceWrite("ViewContainer._addViewToNativeVisualTree for a child " + child + " ViewContainer.parent: " + this.parent, traceCategories.ViewHierarchy);
|
||||
}
|
||||
super._addViewToNativeVisualTree(child);
|
||||
|
||||
const parent = this.parent;
|
||||
if (parent instanceof View) {
|
||||
let baseIndex = 0;
|
||||
let insideIndex = 0;
|
||||
if (parent instanceof LayoutBase) {
|
||||
// Get my index in parent and convert it to native index.
|
||||
baseIndex = parent._childIndexToNativeChildIndex(parent.getChildIndex(this));
|
||||
}
|
||||
|
||||
if (atIndex !== undefined) {
|
||||
insideIndex = this._childIndexToNativeChildIndex(atIndex);
|
||||
} else {
|
||||
// Add last;
|
||||
insideIndex = this._getNativeViewsCount();
|
||||
}
|
||||
if (traceEnabled()) {
|
||||
traceWrite("ProxyViewContainer._addViewToNativeVisualTree at: " + atIndex + " base: " + baseIndex + " additional: " + insideIndex, traceCategories.ViewHierarchy);
|
||||
}
|
||||
|
||||
return parent._addViewToNativeVisualTree(child, baseIndex + insideIndex);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public _removeViewFromNativeVisualTree(child: View): void {
|
||||
if (traceEnabled()) {
|
||||
traceWrite("ProxyViewContainer._removeViewFromNativeVisualTree for a child " + child + " ViewContainer.parent: " + this.parent, traceCategories.ViewHierarchy);
|
||||
}
|
||||
super._removeViewFromNativeVisualTree(child);
|
||||
|
||||
const parent = this.parent;
|
||||
if (parent instanceof View) {
|
||||
return parent._removeViewFromNativeVisualTree(child);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Some layouts (e.g. GridLayout) need to get notified when adding and
|
||||
* removing children, so that they can update private measure data.
|
||||
*
|
||||
* We register our children with the parent to avoid breakage.
|
||||
*/
|
||||
public _registerLayoutChild(child: View) {
|
||||
const parent = this.parent;
|
||||
if (parent instanceof LayoutBase) {
|
||||
parent._registerLayoutChild(child);
|
||||
}
|
||||
}
|
||||
|
||||
public _unregisterLayoutChild(child: View) {
|
||||
const parent = this.parent;
|
||||
if (parent instanceof LayoutBase) {
|
||||
parent._unregisterLayoutChild(child);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Register/unregister existing children with the parent layout.
|
||||
*/
|
||||
public _parentChanged(oldParent: View): void {
|
||||
// call super in order to execute base logic like clear inherited properties, etc.
|
||||
super._parentChanged(oldParent);
|
||||
const addingToParent = this.parent && !oldParent;
|
||||
const newLayout = <LayoutBase>this.parent;
|
||||
const oldLayout = <LayoutBase>oldParent;
|
||||
|
||||
if (addingToParent && newLayout instanceof LayoutBase) {
|
||||
this.eachLayoutChild((child) => {
|
||||
newLayout._registerLayoutChild(child);
|
||||
|
||||
return true;
|
||||
});
|
||||
} else if (oldLayout instanceof LayoutBase) {
|
||||
this.eachLayoutChild((child) => {
|
||||
oldLayout._unregisterLayoutChild(child);
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user