Skip to content

Commit f53ceaf

Browse files
committed
chore: cleanup
1 parent 418f22a commit f53ceaf

File tree

7 files changed

+43
-41
lines changed

7 files changed

+43
-41
lines changed

e2e/animation-examples/app/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class LaunchAnimation extends GridLayout implements AppLaunchView {
8585
})
8686
.then(() => {
8787
// done with animation, can safely remove to reveal bootstrapped app
88-
(<any>this).removeChild(this.animatedContainer);
88+
this.removeChild(this.animatedContainer);
8989
this.animatedContainer = null;
9090
this.circle = null;
9191
if (this.resolve) {

e2e/animation-examples/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"compilerOptions": {
33
"module": "ESNext",
44
"target": "es2015",
5+
"moduleResolution": "node",
56
"experimentalDecorators": true,
67
"emitDecoratorMetadata": true,
78
"noEmitHelpers": true,

e2e/tests-app-ng/app/main/main-page-router-outlet.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,6 @@ export class MainComponent {
5858

5959
@Component({
6060
selector: "navigation-main",
61-
template: `<page-router-outlet></page-router-outlet>`
61+
template: `<GridLayout><page-router-outlet></page-router-outlet></GridLayout>`
6262
})
6363
export class NavigationMainPageRouterComponent { }

nativescript-angular/app-host-view.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,18 @@ export class AppHostView extends ContentView {
4242
}
4343
}
4444
}
45+
46+
export class AppHostLaunchAnimationView extends GridLayout {
47+
constructor(backgroundColor: Color) {
48+
super();
49+
this.backgroundColor = backgroundColor;
50+
}
51+
52+
get ngAppRoot(): View {
53+
return this;
54+
}
55+
56+
set ngAppRoot(value: View) {
57+
// ignored
58+
}
59+
}

nativescript-angular/element-registry.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import { View, LayoutBase, Page, Frame, AbsoluteLayout, ActivityIndicator, BottomNavigation, Button, ContentView, DatePicker, DockLayout, GridLayout, HtmlView, Image, Label, ListPicker, ListView, Placeholder, Progress, ProxyViewContainer, Repeater, ScrollView, SearchBar, SegmentedBar, SegmentedBarItem, Slider, StackLayout, FlexboxLayout, Switch, TabView, TabStrip, TabStripItem, TabContentItem, Tabs, TextField, TextView, TimePicker, WebView, WrapLayout, FormattedString, Span } from '@nativescript/core';
22

3+
export interface ViewClass {
4+
new (): View;
5+
}
36
export interface ViewExtensions {
47
meta: ViewClassMeta;
58
nodeType: number;
@@ -13,10 +16,6 @@ export interface ViewExtensions {
1316

1417
export type NgView = View & ViewExtensions;
1518

16-
export interface ViewClass {
17-
new (): View;
18-
}
19-
2019
export abstract class InvisibleNode extends View implements NgView {
2120
meta: { skipAddToDom: boolean };
2221
nodeType: number;
@@ -87,20 +86,20 @@ export function isInvisibleNode(view: any): view is InvisibleNode {
8786
return view instanceof InvisibleNode;
8887
}
8988

90-
export type ViewResolver = () => ViewClass;
89+
export type ViewResolver = () => any;
9190

9291
const elementMap = new Map<string, { resolver: ViewResolver; meta?: ViewClassMeta }>();
9392
const camelCaseSplit = /([a-z0-9])([A-Z])/g;
9493
const defaultViewMeta: ViewClassMeta = { skipAddToDom: false };
9594

9695
export function registerElement(elementName: string, resolver: ViewResolver, meta?: ViewClassMeta): void {
97-
const entry = { resolver: resolver, meta: meta };
96+
const entry = { resolver, meta };
9897
elementMap.set(elementName, entry);
9998
elementMap.set(elementName.toLowerCase(), entry);
10099
elementMap.set(elementName.replace(camelCaseSplit, '$1-$2').toLowerCase(), entry);
101100
}
102101

103-
export function getViewClass(elementName: string): ViewClass {
102+
export function getViewClass(elementName: string): any {
104103
const entry = elementMap.get(elementName) || elementMap.get(elementName.toLowerCase());
105104
if (!entry) {
106105
throw new TypeError(`No known component for element ${elementName}.`);

nativescript-angular/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@nativescript/angular",
3-
"version": "10.0.0-rc.6",
3+
"version": "10.0.0-rc.7",
44
"description": "An Angular renderer that lets you build mobile apps with NativeScript.",
55
"homepage": "https://www.nativescript.org/",
66
"bugs": "https://github.com/NativeScript/nativescript-angular/issues",

nativescript-angular/platform-common.ts

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { DOCUMENT } from '@angular/common';
77

88
import { NativeScriptDebug } from './trace';
99
import { defaultPageFactoryProvider, setRootPage, PageFactory, PAGE_FACTORY, getRootPage } from './platform-providers';
10-
import { AppHostView } from './app-host-view';
10+
import { AppHostView, AppHostLaunchAnimationView } from './app-host-view';
1111

1212
export const onBeforeLivesync = new EventEmitter<NgModuleRef<any>>();
1313
export const onAfterLivesync = new EventEmitter<{
@@ -161,7 +161,6 @@ export class NativeScriptPlatformRef extends PlatformRef {
161161
@profile
162162
private bootstrapNativeScriptApp() {
163163
let rootContent: View;
164-
let launchView: AppLaunchView;
165164

166165
if (NativeScriptDebug.isLogEnabled()) {
167166
NativeScriptDebug.bootstrapLog('NativeScriptPlatform bootstrap started.');
@@ -172,12 +171,13 @@ export class NativeScriptPlatformRef extends PlatformRef {
172171
}
173172

174173
let tempAppHostView: AppHostView;
175-
let usingCustomLaunchView = false;
174+
let animatedHostView: AppHostLaunchAnimationView;
176175
if (this.appOptions && this.appOptions.launchView) {
177-
launchView = this.appOptions.launchView;
178-
usingCustomLaunchView = true;
179-
rootContent = launchView;
180-
setRootPage(<any>rootContent);
176+
animatedHostView = new AppHostLaunchAnimationView(new Color(this.appOptions && this.appOptions.backgroundColor ? this.appOptions.backgroundColor : '#fff'));
177+
this.appOptions.launchView.style.zIndex = 1000;
178+
animatedHostView.addChild(this.appOptions.launchView);
179+
rootContent = animatedHostView.ngAppRoot;
180+
setRootPage(<any>animatedHostView);
181181
} else {
182182
// Create a temp page for root of the renderer
183183
tempAppHostView = new AppHostView(new Color(this.appOptions && this.appOptions.backgroundColor ? this.appOptions.backgroundColor : '#fff'));
@@ -193,20 +193,11 @@ export class NativeScriptPlatformRef extends PlatformRef {
193193
NativeScriptDebug.bootstrapLog(`Angular bootstrap bootstrap done. uptime: ${profilingUptime()}`);
194194
}
195195

196-
if (launchView && launchView.cleanup) {
197-
// cleanup any custom launch views
198-
launchView.cleanup().then(() => {
199-
// swap launchView with actual booted view
200-
// todo: experiment in Angular 11 with a setup like this
201-
// Application.resetRootView({
202-
// create: () => {
203-
// // const { page, frame } = this.createFrameAndPage(false);
204-
// // frame._addView(launchView.getChildAt(0));
205-
// const rootView = launchView.getChildAt(0);
206-
// // launchView.parent._removeView(launchView);
207-
// return rootView;//launchView.getChildAt(0);//page;
208-
// },
209-
// });
196+
if (this.appOptions.launchView && this.appOptions.launchView.cleanup) {
197+
this.appOptions.launchView.cleanup().then(() => {
198+
// cleanup any custom launch views
199+
animatedHostView.removeChild(this.appOptions.launchView);
200+
this.appOptions.launchView = null;
210201
});
211202
} else {
212203
rootContent = tempAppHostView.content;
@@ -236,19 +227,15 @@ export class NativeScriptPlatformRef extends PlatformRef {
236227
}
237228
};
238229

239-
if (usingCustomLaunchView) {
240-
// Since custom LaunchView could engage with animations, Launch Angular app on next tick
230+
if (this.appOptions && this.appOptions.launchView && this.appOptions.launchView.startAnimation) {
231+
// start animations on next tick (after initial boot)
241232
setTimeout(() => {
242-
if (this.appOptions.launchView.startAnimation) {
243-
// ensure launch animation is executed after launchView added to view stack
244-
this.appOptions.launchView.startAnimation();
245-
}
246-
bootstrap();
233+
// ensure launch animation is executed after launchView added to view stack
234+
this.appOptions.launchView.startAnimation();
247235
});
248-
} else {
249-
bootstrap();
250236
}
251-
if (!bootstrapPromiseCompleted && !usingCustomLaunchView) {
237+
bootstrap();
238+
if (!bootstrapPromiseCompleted) {
252239
const errorMessage = "Bootstrap promise didn't resolve";
253240
if (NativeScriptDebug.isLogEnabled()) {
254241
NativeScriptDebug.bootstrapLogError(errorMessage);

0 commit comments

Comments
 (0)