mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
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:
14
apps/custom-root-view/app.ts
Normal file
14
apps/custom-root-view/app.ts
Normal 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();
|
||||
15
apps/custom-root-view/list-view.xml
Normal file
15
apps/custom-root-view/list-view.xml
Normal 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>
|
||||
29
apps/custom-root-view/main-page.css
Normal file
29
apps/custom-root-view/main-page.css
Normal 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;
|
||||
}
|
||||
17
apps/custom-root-view/main-page.xml
Normal file
17
apps/custom-root-view/main-page.xml
Normal 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>
|
||||
4
apps/custom-root-view/package.json
Normal file
4
apps/custom-root-view/package.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "custom-root-viewcustom-root-view",
|
||||
"main": "app.js"
|
||||
}
|
||||
Reference in New Issue
Block a user