@zeppos/zeus-cli 1.3.7 → 1.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/post-command.js +1 -1
- package/package.json +2 -2
- package/private-modules/zeppos-app-utils/dist/config/project.js +1 -1
- package/private-modules/zeppos-app-utils/dist/modules/fetchDevices.js +3 -1
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/todo-list/.prettierrc.js +6 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/todo-list/app-side/index.js +45 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/todo-list/app.js +25 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/todo-list/app.json +64 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/todo-list/assets/gts/icon.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/todo-list/page/home/index.page.js +155 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/todo-list/page/home/index.page.json +1 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/todo-list/page/home/index.style.js +92 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/todo-list/page/i18n/en-US.po +9 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/todo-list/secondary-widget/index.js +160 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/todo-list/setting/i18n/en-US.po +5 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/todo-list/setting/index.js +143 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/todo-list/shared/data.js +67 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/todo-list/shared/defer.js +35 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/todo-list/shared/device-polyfill.js +6 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/todo-list/shared/es6-promise.js +1178 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/todo-list/shared/event.js +42 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/todo-list/shared/message-side.js +1190 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/todo-list/shared/message.js +1196 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/todo-list/utils/constants.js +1 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/todo-list/utils/index.js +38 -0
- package/private-modules/zeppos-app-utils/package.json +1 -1
package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/todo-list/setting/index.js
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { gettext } from 'i18n'
|
|
2
|
+
import { DEFAULT_TODO_LIST } from './../utils/constants'
|
|
3
|
+
AppSettingsPage({
|
|
4
|
+
state: {
|
|
5
|
+
todoList: [],
|
|
6
|
+
props: {}
|
|
7
|
+
},
|
|
8
|
+
addTodoList(val) {
|
|
9
|
+
this.state.todoList = [...this.state.todoList, val]
|
|
10
|
+
this.setItem()
|
|
11
|
+
},
|
|
12
|
+
editTodoList(val, index) {
|
|
13
|
+
this.state.todoList[index] = val
|
|
14
|
+
this.setItem()
|
|
15
|
+
},
|
|
16
|
+
deleteTodoList(index) {
|
|
17
|
+
this.state.todoList = this.state.todoList.filter((_, ind) => {
|
|
18
|
+
return ind !== index
|
|
19
|
+
})
|
|
20
|
+
this.setItem()
|
|
21
|
+
},
|
|
22
|
+
setItem() {
|
|
23
|
+
const newString = JSON.stringify(this.state.todoList)
|
|
24
|
+
this.state.props.settingsStorage.setItem('todoList', newString)
|
|
25
|
+
},
|
|
26
|
+
setState(props) {
|
|
27
|
+
this.state.props = props
|
|
28
|
+
if (props.settingsStorage.getItem('todoList')) {
|
|
29
|
+
this.state.todoList = JSON.parse(props.settingsStorage.getItem('todoList'))
|
|
30
|
+
} else {
|
|
31
|
+
this.state.todoList = [...DEFAULT_TODO_LIST]
|
|
32
|
+
}
|
|
33
|
+
console.log('todoList: ', this.state.todoList)
|
|
34
|
+
},
|
|
35
|
+
build(props) {
|
|
36
|
+
this.setState(props)
|
|
37
|
+
const contentItems = []
|
|
38
|
+
const addBTN = View(
|
|
39
|
+
{
|
|
40
|
+
style: {
|
|
41
|
+
fontSize: '12px',
|
|
42
|
+
lineHeight: '30px',
|
|
43
|
+
borderRadius: '30px',
|
|
44
|
+
background: '#409EFF',
|
|
45
|
+
color: 'white',
|
|
46
|
+
textAlign: 'center',
|
|
47
|
+
padding: '0 15px',
|
|
48
|
+
width: '30%'
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
[
|
|
52
|
+
TextInput({
|
|
53
|
+
label: gettext('addTodo'),
|
|
54
|
+
onChange: (val) => {
|
|
55
|
+
this.addTodoList(val)
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
]
|
|
59
|
+
)
|
|
60
|
+
this.state.todoList.forEach((item, index) => {
|
|
61
|
+
contentItems.push(
|
|
62
|
+
View(
|
|
63
|
+
{
|
|
64
|
+
style: {
|
|
65
|
+
borderBottom: '1px solid #eaeaea',
|
|
66
|
+
padding: '6px 0',
|
|
67
|
+
marginBottom: '6px',
|
|
68
|
+
display: 'flex',
|
|
69
|
+
flexDirection: 'row'
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
[
|
|
73
|
+
View(
|
|
74
|
+
{
|
|
75
|
+
style: {
|
|
76
|
+
flex: 1,
|
|
77
|
+
display: 'flex',
|
|
78
|
+
flexDirection: 'row',
|
|
79
|
+
justfyContent: 'center',
|
|
80
|
+
alignItems: 'center'
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
[
|
|
84
|
+
TextInput({
|
|
85
|
+
label: '',
|
|
86
|
+
bold: true,
|
|
87
|
+
value: item,
|
|
88
|
+
subStyle: {
|
|
89
|
+
color: '#333',
|
|
90
|
+
fontSize: '14px'
|
|
91
|
+
},
|
|
92
|
+
maxLength: 200,
|
|
93
|
+
onChange: (val) => {
|
|
94
|
+
if (val.length > 0 && val.length <= 200) {
|
|
95
|
+
this.editTodoList(val, index)
|
|
96
|
+
} else {
|
|
97
|
+
console.log("todoList can't be empty or too long!")
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
})
|
|
101
|
+
]
|
|
102
|
+
),
|
|
103
|
+
Button({
|
|
104
|
+
label: gettext('delete'),
|
|
105
|
+
style: {
|
|
106
|
+
fontSize: '12px',
|
|
107
|
+
borderRadius: '30px',
|
|
108
|
+
background: '#D85E33',
|
|
109
|
+
color: 'white'
|
|
110
|
+
},
|
|
111
|
+
onClick: () => {
|
|
112
|
+
this.deleteTodoList(index)
|
|
113
|
+
}
|
|
114
|
+
})
|
|
115
|
+
]
|
|
116
|
+
)
|
|
117
|
+
)
|
|
118
|
+
})
|
|
119
|
+
return View(
|
|
120
|
+
{
|
|
121
|
+
style: {
|
|
122
|
+
padding: '12px 20px'
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
[
|
|
126
|
+
addBTN,
|
|
127
|
+
contentItems.length > 0 &&
|
|
128
|
+
View(
|
|
129
|
+
{
|
|
130
|
+
style: {
|
|
131
|
+
marginTop: '12px',
|
|
132
|
+
padding: '10px',
|
|
133
|
+
border: '1px solid #eaeaea',
|
|
134
|
+
borderRadius: '6px',
|
|
135
|
+
backgroundColor: 'white'
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
[...contentItems]
|
|
139
|
+
)
|
|
140
|
+
]
|
|
141
|
+
)
|
|
142
|
+
}
|
|
143
|
+
})
|
package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/todo-list/shared/data.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export function json2buf(json) {
|
|
2
|
+
return str2buf(json2str(json))
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export function json2bin(json) {
|
|
6
|
+
return str2bin(json2str(json))
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function len(binOrBuf) {
|
|
10
|
+
return binOrBuf.byteLength
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function buf2json(buf) {
|
|
14
|
+
return str2json(buf2str(buf))
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function str2json(str) {
|
|
18
|
+
return JSON.parse(str)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function json2str(json) {
|
|
22
|
+
return JSON.stringify(json)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function str2buf(str) {
|
|
26
|
+
return Buffer.from(str, 'utf-8')
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function buf2str(buf) {
|
|
30
|
+
return buf.toString('utf-8')
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function bin2buf(bin) {
|
|
34
|
+
return Buffer.from(bin)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function buf2bin(buf) {
|
|
38
|
+
return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function buf2hex(buf) {
|
|
42
|
+
return buf.toString('hex')
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function bin2hex(bin) {
|
|
46
|
+
return buf2hex(bin2buf(bin))
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function bin2json(bin) {
|
|
50
|
+
return buf2json(bin2buf(bin))
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function bin2str(bin) {
|
|
54
|
+
return buf2str(bin2buf(bin))
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function str2bin(str) {
|
|
58
|
+
return buf2bin(str2buf(str))
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function allocOfBin(size = 0) {
|
|
62
|
+
return Buffer.alloc(size).buffer
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function allocOfBuf(size = 0) {
|
|
66
|
+
return Buffer.alloc(size)
|
|
67
|
+
}
|
package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/todo-list/shared/defer.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export function Deferred() {
|
|
2
|
+
const defer = {}
|
|
3
|
+
|
|
4
|
+
defer.promise = new Promise(function (resolve, reject) {
|
|
5
|
+
defer.resolve = resolve
|
|
6
|
+
defer.reject = reject
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
return defer
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function delay(ms) {
|
|
13
|
+
const defer = Deferred()
|
|
14
|
+
|
|
15
|
+
setTimeout(defer.resolve, ms)
|
|
16
|
+
|
|
17
|
+
return defer.promise
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function timeout(ms, cb) {
|
|
21
|
+
const defer = Deferred()
|
|
22
|
+
ms = ms || 1000
|
|
23
|
+
|
|
24
|
+
const wait = setTimeout(() => {
|
|
25
|
+
clearTimeout(wait)
|
|
26
|
+
|
|
27
|
+
if (cb) {
|
|
28
|
+
cb && cb(defer.resolve, defer.reject)
|
|
29
|
+
} else {
|
|
30
|
+
defer.reject('Timed out in ' + ms + 'ms.')
|
|
31
|
+
}
|
|
32
|
+
}, ms)
|
|
33
|
+
|
|
34
|
+
return defer.promise
|
|
35
|
+
}
|