-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathsplash-screen.js
96 lines (78 loc) · 2.47 KB
/
splash-screen.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
const { ActivityIndicator, Canvas, Button, ui, device, app } = require('tabris')
ui.contentView.background = '#3f51b5'
// Create the activity indicator centered in the page
let activityIndicator = new ActivityIndicator({ left: 0, centerY: 0 }).appendTo(
ui.contentView
)
ui.statusBar.background = '#f00'
ui.statusBar.displayMode = 'default'
// ui.statusBar.height = 40 // no work it's read only
// https://tabrisjs.com/mrmccormack/apps/// Create reload button
let reloadButton = new Button({ left: 0, top: 90, text: 'Run Task' })
.on('select', () => executeLongRunningTask())
.appendTo(ui.contentView)
function executeLongRunningTask () {
// Toggle visibility of elements
activityIndicator.visible = true
reloadButton.visible = true
setTimeout(
() => {
// Async action is done
activityIndicator.visible = false
reloadButton.visible = true
},
2500
)
}
executeLongRunningTask()
// Draw shapes on a canvas using HTML5 Canvas API
let canvas = new Canvas({ left: 10, top: 10, right: 10, bottom: 10 })
.on('resize', ({ target: canvas, width, height }) => {
let scaleFactor = device.scaleFactor
let ctx = canvas.getContext(
'2d',
width * scaleFactor,
height * scaleFactor
)
ctx.scale(scaleFactor, scaleFactor)
ctx.strokeStyle = 'rgb(78, 154, 217)'
ctx.lineWidth = 10
ctx.moveTo(20, 20)
// ctx.lineTo(width - 40, height - 40);
ctx.stroke()
// draw image
ctx.putImageData(createImageData(80, 40), 100, 100)
})
.appendTo(ui.contentView)
let count = 0
let btnMain = new Button({ left: 10, top: 10, text: 'Button', visible: false })
.on('select', ({ target }) => target.text = 'Pressed ' + ++count + ' times')
.appendTo(ui.contentView)
new Button({ centerX: 0, centerY: 0, text: 'Press me!' })
.on('select', ({ target }) => {
target.text = 'Please wait...'
setTimeout(sayThanks, 2000, target)
app.reload()
})
.appendTo(ui.contentView)
function sayThanks (widget) {
widget.text = 'Thank you!'
canvas.visible = false
btnMain.visible = true
}
function createImageData (width, height) {
let array = []
for (let y = 0; y < height; y++) {
for (let x = 0; x < width; x++) {
let alpha = x % 20 > y % 20 ? 255 : 0
array.push(200, 0, 0, alpha)
}
}
return new ImageData(new Uint8ClampedArray(array), width, height)
}
setTimeout(sayThanks1, 2000)
function sayThanks1 () {
ui.contentView.background = 'initial'
canvas.visible = false
btnMain.visible = true
}