Added an option to change the rootView.

Fixed crash where activity was incorrectly using existing initialized frame.
Fixed TabView to use _nativeView instead of Frame.
This commit is contained in:
Hristo Hristov
2016-02-05 15:09:02 +02:00
parent c865728001
commit e709485bb6
14 changed files with 415 additions and 289 deletions

View File

@@ -0,0 +1,14 @@
import app = require("application");
import {Frame} from "ui/frame";
import {TabView} from "ui/tab-view";
import * as builder from "ui/builder";
app.on("launch", function (args) {
var tabView = <TabView>builder.load((__dirname + "/main-page.xml"));
args.root = tabView;
var frame = <Frame>tabView.items[0].view;
var basePath = "list-view";
frame.navigate(basePath);
});
app.start();

View File

@@ -0,0 +1,15 @@
<Page xmlns="http://schemas.nativescript.org/tns.xsd" loaded="pageLoaded"
codeFile="~/cuteness.io/main-page.js">
<ListView items="{{ redditItems }}" isScrolling="{{ isScrolling }}" itemTap="listViewItemTap" loadMoreItems="listViewLoadMoreItems">
<ListView.itemTemplate>
<!-- Binding in template property of an component will use the bindingContext provided by the component. -->
<GridLayout columns="auto, *, auto" rows="auto, 25">
<Image src="{{ thumbnailImage }}" class="thumbnail" rowSpan="2"/>
<Label text="{{ title || 'Downloading...' }}" textWrap="true" class="title" col="1" colSpan="2" minHeight="50" />
<Label text="{{ author ? 'by ' + author : '' }}" class="author" col="1" row="1" />
<Label text="{{ num_comments ? num_comments + ' comments' : '' }}" class="comments" col="2" row="1" />
</GridLayout>
<!-- End of tempplate. -->
</ListView.itemTemplate>
</ListView>
</Page>

View File

@@ -0,0 +1,29 @@
.title {
font-size: 20;
margin: 3;
}
.author {
font-size: 14;
horizontal-align: left;
vertical-align: bottom;
margin: 3;
}
.comments {
color: #10C2B0;
font-size: 14;
vertical-align: bottom;
margin: 3;
}
.thumbnail {
width: 72;
height: 72;
margin: 3;
vertical-align: top;
}
TabView {
background-color: white;
}

View File

@@ -0,0 +1,17 @@
<TabView xmlns="http://schemas.nativescript.org/tns.xsd">
<TabView.items>
<TabViewItem title="List">
<TabViewItem.view>
<Frame />
</TabViewItem.view>
</TabViewItem>
<TabViewItem title="About">
<TabViewItem.view>
<StackLayout>
<Image margin="10" src="~/res/telerik-logo.png" />
<Label margin="10" textWrap="true" text="{{ aboutText }}" />
</StackLayout>
</TabViewItem.view>
</TabViewItem>
</TabView.items>
</TabView>

View File

@@ -0,0 +1,4 @@
{
"name": "custom-root-viewcustom-root-view",
"main": "app.js"
}