-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathtab-folder-events.js
63 lines (47 loc) · 1.82 KB
/
tab-folder-events.js
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
63
const {Tab, TabFolder, TextView, ui, AlertDialog, Button} = require('tabris');
const IMAGE_PATH = 'https://raw.githubusercontent.com/eclipsesource/tabris-js/master/snippets/resources/';
// Create a swipe enabled tab folder with 3 tabs
// Create a push button that counts up on selection
let tabFolder = new TabFolder({
left: 0, top: 0, right: 0, bottom: 0,
paging: true // enables swiping. To still be able to open the developer console in iOS, swipe from the bottom right.
}).appendTo(ui.contentView);
createTab('Cart', IMAGE_PATH + 'cart.png', IMAGE_PATH + 'cart-filled.png');
createTab('Pay', IMAGE_PATH + 'card.png', IMAGE_PATH + 'card-filled.png');
createTab('Statistic', IMAGE_PATH + 'chart.png', IMAGE_PATH + 'chart-filled.png');
createTab('Statistic', IMAGE_PATH + 'chart.png', IMAGE_PATH + 'chart-filled.png');
// example of doing 3 tings in an event and outside of new declaration
tabFolder.on('selectionChanged', ({value: tab}) =>
{
new AlertDialog({
message: '© 2018 Mr. M. - Free to use',
buttons: {ok: 'OK'}
}).open(); // end AlertDialog
// do some other things
console.log('hello world');
console.log(tab.title);
}
); // end selectionChaned event
function createTab(title, image, seletedImage) {
let tab = new Tab({
title: title, // converted to upper-case on Android
image: {src: image, scale: 2},
selectedImage: {src: seletedImage, scale: 2}
}).appendTo(tabFolder);
new TextView({
centerX: 0, centerY: 0,
text: 'Content of Tab ' + title
})
new Button({
centerX: 0, centerY: 0,
text: 'TAP ME'
}).on('select', () => tabFolder.selection = tab)
.appendTo(tab);
}
let count = 0;
new Button({
left: 10, top: 10,
text: 'Button',
image: IMAGE_PATH + 'cart.png'
}).on('select', ({target}) => target.text = 'Pressed ' + (++count) + ' times')
.appendTo(ui.contentView);