forked from NativeScript/NativeScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain-page.ts
More file actions
33 lines (27 loc) · 1.29 KB
/
main-page.ts
File metadata and controls
33 lines (27 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import {EventData as ObservableEventData} from "tns-core-modules/data/observable";
import {Page} from "tns-core-modules/ui/page";
import {ItemEventData as ListViewItemEventData} from "tns-core-modules/ui/list-view";
import {topmost as topmostFrame} from "tns-core-modules/ui/frame";
import {AppViewModel} from "./reddit-app-view-model";
var appViewModel = new AppViewModel();
// Event handler for Page "loaded" event attached in main-page.xml
export function pageLoaded(args: ObservableEventData) {
// Get the event sender
var page = <Page>args.object;
page.bindingContext = appViewModel;
// Enable platform specific feature (in this case Android page caching)
if (topmostFrame().android) {
topmostFrame().android.cachePagesOnNavigate = true;
}
}
export function listViewItemTap(args: ListViewItemEventData) {
// Navigate to the details page with context set to the data item for specified index
topmostFrame().navigate({
moduleName: "cuteness.io/details-page",
bindingContext: appViewModel.redditItems.getItem(args.index)
});
}
export function listViewLoadMoreItems(args: ObservableEventData) {
// Increase model items length with model items loadSize property value
//appViewModel.redditItems.length += appViewModel.redditItems.loadSize;
}