Skip to content

Commit 6de033f

Browse files
committed
Update to the new renderer API.
- Kill the ViewNode class. - Return View instances from renderer. - Add a ViewContainer view (based on ContentView) that attaches children directly to its parent and keeps track of insert positions. - Update the ng-sample app - Broke the complex properties hack. We'll have to support components such as TabView with custom components/directives.
1 parent 0d31ea8 commit 6de033f

File tree

7 files changed

+440
-624
lines changed

7 files changed

+440
-624
lines changed

ng-sample/app/renderer-test.ts

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,19 @@ export class TemplatedComponent {
1111
selector: 'renderer-test',
1212
directives: [TemplatedComponent],
1313
template: `
14-
<TabView>
15-
<TabView.items>
16-
<TabViewItem title="First Tab">
17-
<TabViewItem.view>
18-
<StackLayout orientation='vertical'>
19-
<templated-component></templated-component>
20-
<Label [class.valid]="isValid" [class.invalid]="!isValid" text='Name' fontSize='20' verticalAlignment='center' padding='20'></Label>
21-
<TextField #name text='John' fontSize='20' padding='20'></TextField>
22-
<Button [text]='buttonText' (tap)='onSave($event, name.text, $el)'></Button>
23-
<Button text='Toggle details' (tap)='onToggleDetails()'></Button>
24-
<TextView *ngIf='showDetails' [text]='detailsText'></TextView>
25-
<Label text='==============================' fontSize='20'></Label>
26-
<StackLayout #more *ngIf='showDetails' orientation='vertical'>
27-
<TextField *ngFor='#detailLine of detailLines' [text]='detailLine'></TextField>
28-
</StackLayout>
29-
<Label text='==============================' fontSize='20'></Label>
14+
<StackLayout orientation='vertical'>
15+
<templated-component *ngIf='showDetails'></templated-component>
16+
<Label [class.valid]="isValid" [class.invalid]="!isValid" text='Name' fontSize='20' verticalAlignment='center' padding='20'></Label>
17+
<TextField #name text='John' fontSize='20' padding='20'></TextField>
18+
<Button [text]='buttonText' (tap)='onSave($event, name.text, $el)'></Button>
19+
<Button text='Toggle details' (tap)='onToggleDetails()'></Button>
20+
<TextView *ngIf='showDetails' [text]='detailsText'></TextView>
21+
<Label text='==============================' fontSize='20'></Label>
22+
<StackLayout #more *ngIf='showDetails' orientation='vertical'>
23+
<TextField *ngFor='#detailLine of detailLines' [text]='detailLine'></TextField>
3024
</StackLayout>
31-
</TabViewItem.view>
32-
</TabViewItem>
33-
<TabViewItem title="Second Tab">
34-
<TabViewItem.view>
35-
<Label text="Completely different tab!"></Label>
36-
</TabViewItem.view>
37-
</TabViewItem>
38-
</TabView.items>
39-
</TabView>
25+
<Label text='==============================' fontSize='20'></Label>
26+
</StackLayout>
4027
`,
4128
})
4229
export class RendererTest {

ng-sample/app/title.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
<Switch></Switch>
12
<Label text="Hello, external templates"></Label>

src/nativescript-angular/application.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import {platform, ComponentRef, PLATFORM_DIRECTIVES, PLATFORM_PIPES} from 'angul
1313
import {bind, provide, Provider} from 'angular2/src/core/di';
1414
import {DOM} from 'angular2/src/platform/dom/dom_adapter';
1515

16-
import {Renderer} from 'angular2/src/core/render/api';
17-
import {NativeScriptRenderer} from './renderer';
16+
import {RootRenderer, Renderer} from 'angular2/src/core/render/api';
17+
import {NativeScriptRootRenderer, NativeScriptRenderer} from './renderer';
1818
import {NativeScriptDomAdapter} from './dom_adapter';
1919
import {XHR} from 'angular2/src/compiler/xhr';
2020
import {FileSystemXHR} from './xhr';
@@ -34,6 +34,8 @@ export function nativeScriptBootstrap(appComponentType: any,
3434
NativeScriptDomAdapter.makeCurrent();
3535

3636
let nativeScriptProviders: ProviderArray = [
37+
NativeScriptRootRenderer,
38+
provide(RootRenderer, {useClass: NativeScriptRootRenderer}),
3739
NativeScriptRenderer,
3840
provide(Renderer, {useClass: NativeScriptRenderer}),
3941
provide(XHR, {useClass: FileSystemXHR}),

0 commit comments

Comments
 (0)