-
Notifications
You must be signed in to change notification settings - Fork 56
/
Copy pathmain-page.ts
62 lines (52 loc) · 1.64 KB
/
main-page.ts
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import {
Application,
Color,
Device,
EventData,
isAndroid,
Label,
Page
} from '@nativescript/core';
import { CheckBox } from '@nstudio/nativescript-checkbox';
import { DataItem, HelloWorldModel } from './main-view-model';
let page: Page;
let model: HelloWorldModel;
// Event handler for Page "loaded" event attached in main-page.xml
export function onNavigatedTo(args: EventData) {
// Get the event sender
page = args.object as Page;
model = new HelloWorldModel();
page.bindingContext = model;
// Not related to checkboxes
if (isAndroid && Device.sdkVersion >= '21') {
const window = Application.android.startActivity.getWindow();
window.setStatusBarColor(new Color('#3f3f3f').android);
}
}
export function disabledTapTestCheck() {
const tapTestCheck = page.getViewById('tapTestCheck') as CheckBox;
tapTestCheck.isEnabled = !tapTestCheck.isEnabled;
}
export function onToggleTest(args) {
console.log('toggle tap');
const toggleTest = page.getViewById('toggleTest') as CheckBox;
toggleTest.toggle();
}
export function onCustomCheckStateChange(args) {
console.log('toggle enabled state tap');
const toggleTest = page.getViewById('toggleTest') as CheckBox;
toggleTest.isEnabled = !toggleTest.isEnabled;
}
export function onTapTest(args) {
console.log('tap event test');
const box = args.object as CheckBox;
model.updateMessage(box.checked);
}
export function onRepeaterItemTap(args: any) {
const label = <Label>page.getViewById('modelDumpLabel');
const data = new Array<DataItem>();
for (let i = 0; i < model.data.length; i++) {
data.push(model.data.getItem(i));
}
label.text = JSON.stringify(data);
}