@zeppos/zeus-cli 1.6.5 → 1.6.6
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/modules/create.js +3 -0
- package/package.json +2 -2
- package/private-modules/zeppos-app-utils/dist/modules/create/index.js +3 -2
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/calories/_package.json +17 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/calories/app.js +27 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/calories/app.json +52 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/calories/assets/gt.r/consume.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/calories/assets/gt.r/food/beer.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/calories/assets/gt.r/food/cake.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/calories/assets/gt.r/food/chocolate.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/calories/assets/gt.r/food/coffee.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/calories/assets/gt.r/food/cookies.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/calories/assets/gt.r/food/ham.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/calories/assets/gt.r/food/hamburger.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/calories/assets/gt.r/food/ice cream.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/calories/assets/gt.r/food/pizza.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/calories/assets/gt.r/food/sausage.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/calories/assets/gt.r/icon.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/calories/assets/gt.r/multiply.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/calories/assets/gt.r/selected.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/calories/assets/gt.r/unselected.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/calories/assets/gt.s/consume.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/calories/assets/gt.s/food/beer.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/calories/assets/gt.s/food/cake.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/calories/assets/gt.s/food/chocolate.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/calories/assets/gt.s/food/coffee.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/calories/assets/gt.s/food/cookies.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/calories/assets/gt.s/food/ham.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/calories/assets/gt.s/food/hamburger.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/calories/assets/gt.s/food/ice cream.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/calories/assets/gt.s/food/pizza.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/calories/assets/gt.s/food/sausage.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/calories/assets/gt.s/icon.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/calories/assets/gt.s/multiply.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/calories/assets/gt.s/selected.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/calories/assets/gt.s/unselected.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/calories/global.d.ts +1 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/calories/jsconfig.json +9 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/calories/page/gt/food-list.js +107 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/calories/page/gt/food-list.r.layout.js +48 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/calories/page/gt/food-list.s.layout.js +33 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/calories/page/gt/index.js +127 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/calories/page/gt/index.r.layout.js +110 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/calories/page/gt/index.s.layout.js +98 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/calories/page/i18n/en-US.po +42 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/calories/page/i18n/zh-CN.po +42 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/calories/utils/constants.js +62 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/calories/utils/storage.js +40 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/empty/_package.json +14 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/empty/app-side/i18n/en-US.po +2 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/empty/app-side/index.js +13 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/empty/app.js +10 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/empty/app.json +60 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/empty/assets/default.b/icon.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/empty/assets/default.r/icon.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/empty/assets/default.s/icon.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/empty/global.d.ts +1 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/empty/jsconfig.json +9 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/empty/page/i18n/en-US.po +2 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/empty/page/index.b.layout.js +6 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/empty/page/index.js +7 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/empty/page/index.r.layout.js +6 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/empty/page/index.s.layout.js +6 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/empty/setting/i18n/en-US.po +2 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/empty/setting/index.js +7 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/fetch-api/_package.json +17 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/fetch-api/app-side/i18n/en-US.po +2 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/fetch-api/app-side/index.js +56 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/fetch-api/app.js +14 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/fetch-api/app.json +51 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/fetch-api/assets/common.r/icon.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/fetch-api/assets/common.s/icon.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/fetch-api/global.d.ts +1 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/fetch-api/jsconfig.json +9 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/fetch-api/page/i18n/en-US.po +2 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/fetch-api/page/index.js +45 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/fetch-api/page/index.r.layout.js +32 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/fetch-api/page/index.s.layout.js +32 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/fetch-api/utils/config/constants.js +2 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/fetch-api/utils/config/device.js +2 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/hello-world/_package.json +17 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/hello-world/app.js +10 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/hello-world/app.json +51 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/hello-world/assets/gt.r/icon.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/hello-world/assets/gt.r/image/logo.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/hello-world/assets/gt.s/icon.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/hello-world/assets/gt.s/image/logo.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/hello-world/global.d.ts +1 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/hello-world/jsconfig.json +9 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/hello-world/page/gt/home/index.page.js +17 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/hello-world/page/gt/home/index.page.r.layout.js +19 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/hello-world/page/gt/home/index.page.s.layout.js +19 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/hello-world/page/i18n/en-US.po +2 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/hello-world/page/i18n/zh-CN.po +2 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/hello-world/utils/index.js +3 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/showcase/_package.json +17 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/showcase/app.js +16 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/showcase/app.json +71 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/showcase/assets/default.b/icon.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/showcase/assets/default.r/icon.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/showcase/assets/default.r/images/icons/ic_moon.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/showcase/assets/default.s/icon.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/showcase/global.d.ts +1 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/showcase/jsconfig.json +9 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/showcase/page/TC/TC_01/index.js +205 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/showcase/page/TC/TC_01/index.r.layout.js +106 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/showcase/page/TC/TC_02/index.js +88 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/showcase/page/TC/TC_02/index.r.layout.js +74 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/showcase/page/TC/TC_03/index.js +98 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/showcase/page/TC/TC_03/index.r.layout.js +80 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/showcase/page/i18n/en-US.po +2 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/showcase/page/index.js +53 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/showcase/page/index.r.layout.js +75 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/todo-list/.prettierrc.js +6 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/todo-list/_package.json +17 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/todo-list/app-side/index.js +47 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/todo-list/app.js +17 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/todo-list/app.json +55 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/todo-list/assets/gt.r/add.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/todo-list/assets/gt.r/delete.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/todo-list/assets/gt.r/icon.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/todo-list/assets/gt.s/add.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/todo-list/assets/gt.s/delete.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/todo-list/assets/gt.s/icon.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/todo-list/global.d.ts +1 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/todo-list/jsconfig.json +9 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/todo-list/page/home/index.page.js +177 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/todo-list/page/home/index.page.r.layout.js +112 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/todo-list/page/home/index.page.s.layout.js +112 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/todo-list/page/i18n/en-US.po +21 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/todo-list/setting/i18n/en-US.po +5 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/todo-list/setting/index.js +143 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/todo-list/utils/constants.js +3 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/todo-list/utils/fs.js +34 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/todo-list/utils/index.js +38 -0
- package/private-modules/zeppos-app-utils/package.json +1 -1
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"configVersion": "v3",
|
|
3
|
+
"app": {
|
|
4
|
+
"appType": "app",
|
|
5
|
+
"version": {
|
|
6
|
+
"code": 1,
|
|
7
|
+
"name": "1.0.0"
|
|
8
|
+
},
|
|
9
|
+
"appId": 20001,
|
|
10
|
+
"appName": "Todo List",
|
|
11
|
+
"icon": "icon.png",
|
|
12
|
+
"vender": "zepp",
|
|
13
|
+
"description": "todo list application"
|
|
14
|
+
},
|
|
15
|
+
"runtime": {
|
|
16
|
+
"apiVersion": {
|
|
17
|
+
"compatible": "4.0",
|
|
18
|
+
"target": "4.0",
|
|
19
|
+
"minVersion": "4.0"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"targets": {
|
|
23
|
+
"gt": {
|
|
24
|
+
"module": {
|
|
25
|
+
"page": {
|
|
26
|
+
"pages": ["page/home/index.page"]
|
|
27
|
+
},
|
|
28
|
+
"app-side": {
|
|
29
|
+
"path": "app-side/index"
|
|
30
|
+
},
|
|
31
|
+
"setting": {
|
|
32
|
+
"path": "setting/index"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"platforms": [
|
|
36
|
+
{
|
|
37
|
+
"st": "r",
|
|
38
|
+
"dw": 480
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"st": "s",
|
|
42
|
+
"dw": 390
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"permissions": ["data:os.device.info", "device:os.local_storage"],
|
|
48
|
+
"i18n": {
|
|
49
|
+
"en-US": {
|
|
50
|
+
"name": "Todo List"
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"defaultLanguage": "en-US",
|
|
54
|
+
"debug": false
|
|
55
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference path="node_modules/@zeppos/device-types/dist/index.d.ts" />
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import * as hmUI from '@zos/ui'
|
|
2
|
+
import { getText } from '@zos/i18n'
|
|
3
|
+
import { getDeviceInfo, SCREEN_SHAPE_SQUARE } from '@zos/device'
|
|
4
|
+
import { log as Logger } from '@zos/utils'
|
|
5
|
+
|
|
6
|
+
import { BasePage } from '@zeppos/zml/base-page'
|
|
7
|
+
import {
|
|
8
|
+
TITLE_TEXT_STYLE,
|
|
9
|
+
TIPS_TEXT_STYLE,
|
|
10
|
+
SCROLL_LIST,
|
|
11
|
+
ADD_BUTTON
|
|
12
|
+
} from 'zosLoader:./index.page.[pf].layout.js'
|
|
13
|
+
import { readFileSync, writeFileSync } from './../../utils/fs'
|
|
14
|
+
import { getScrollListDataConfig } from './../../utils/index'
|
|
15
|
+
|
|
16
|
+
const logger = Logger.getLogger('todo-list-page')
|
|
17
|
+
|
|
18
|
+
Page(
|
|
19
|
+
BasePage({
|
|
20
|
+
state: {
|
|
21
|
+
scrollList: null,
|
|
22
|
+
tipText: null,
|
|
23
|
+
refreshText: null,
|
|
24
|
+
addButton: null,
|
|
25
|
+
dataList: readFileSync()
|
|
26
|
+
},
|
|
27
|
+
onInit() {
|
|
28
|
+
logger.debug('page onInit invoked')
|
|
29
|
+
this.getTodoList()
|
|
30
|
+
},
|
|
31
|
+
build() {
|
|
32
|
+
logger.debug('page build invoked')
|
|
33
|
+
|
|
34
|
+
if (getDeviceInfo().screenShape !== SCREEN_SHAPE_SQUARE) {
|
|
35
|
+
this.state.title = hmUI.createWidget(hmUI.widget.TEXT, {
|
|
36
|
+
...TITLE_TEXT_STYLE
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
this.state.addButton = hmUI.createWidget(hmUI.widget.BUTTON, {
|
|
41
|
+
...ADD_BUTTON,
|
|
42
|
+
click_func: () => {
|
|
43
|
+
this.addRandomTodoItem()
|
|
44
|
+
}
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
this.createAndUpdateList(false)
|
|
48
|
+
},
|
|
49
|
+
onDestroy() {
|
|
50
|
+
logger.debug('page onDestroy invoked')
|
|
51
|
+
writeFileSync(this.state.dataList, false)
|
|
52
|
+
},
|
|
53
|
+
onCall(req) {
|
|
54
|
+
const dataList = req.result.map((i) => ({ name: i, img_src: 'delete.png' }))
|
|
55
|
+
logger.log('call dataList', dataList)
|
|
56
|
+
this.refreshAndUpdate(dataList)
|
|
57
|
+
},
|
|
58
|
+
getTodoList() {
|
|
59
|
+
this.request({
|
|
60
|
+
method: 'GET_TODO_LIST'
|
|
61
|
+
})
|
|
62
|
+
.then(({ result }) => {
|
|
63
|
+
this.state.dataList = result.map((d) => ({ name: d, img_src: 'delete.png' }))
|
|
64
|
+
this.createAndUpdateList()
|
|
65
|
+
})
|
|
66
|
+
.catch((res) => {
|
|
67
|
+
this.createAndUpdateList()
|
|
68
|
+
})
|
|
69
|
+
},
|
|
70
|
+
addRandomTodoItem() {
|
|
71
|
+
this.request({
|
|
72
|
+
method: 'ADD'
|
|
73
|
+
})
|
|
74
|
+
.then(({ result }) => {
|
|
75
|
+
this.state.dataList = result.map((d) => ({ name: d, img_src: 'delete.png' }))
|
|
76
|
+
this.createAndUpdateList()
|
|
77
|
+
hmUI.showToast({
|
|
78
|
+
text: getText('addSuccess')
|
|
79
|
+
})
|
|
80
|
+
})
|
|
81
|
+
.catch((res) => {
|
|
82
|
+
hmUI.showToast({
|
|
83
|
+
text: getText('addFailure')
|
|
84
|
+
})
|
|
85
|
+
})
|
|
86
|
+
},
|
|
87
|
+
deleteTodoItem(index) {
|
|
88
|
+
this.request({
|
|
89
|
+
method: 'DELETE',
|
|
90
|
+
params: { index }
|
|
91
|
+
})
|
|
92
|
+
.then(({ result }) => {
|
|
93
|
+
this.state.scrollList.setProperty(hmUI.prop.DELETE_ITEM, { index: index })
|
|
94
|
+
this.state.dataList.splice(index, 1)
|
|
95
|
+
hmUI.showToast({
|
|
96
|
+
text: getText('deleteSuccess')
|
|
97
|
+
})
|
|
98
|
+
})
|
|
99
|
+
.catch((res) => {
|
|
100
|
+
hmUI.showToast({
|
|
101
|
+
text: getText('deleteFailure')
|
|
102
|
+
})
|
|
103
|
+
})
|
|
104
|
+
},
|
|
105
|
+
changeUI(showEmpty) {
|
|
106
|
+
const { dataList } = this.state
|
|
107
|
+
|
|
108
|
+
if (showEmpty) {
|
|
109
|
+
if (dataList.length === 0) {
|
|
110
|
+
!this.state.tipText &&
|
|
111
|
+
(this.state.tipText = hmUI.createWidget(hmUI.widget.TEXT, {
|
|
112
|
+
...TIPS_TEXT_STYLE
|
|
113
|
+
}))
|
|
114
|
+
}
|
|
115
|
+
const isTip = dataList.length === 0
|
|
116
|
+
|
|
117
|
+
this.state.refreshText && this.state.refreshText.setProperty(hmUI.prop.VISIBLE, false)
|
|
118
|
+
this.state.tipText && this.state.tipText.setProperty(hmUI.prop.VISIBLE, isTip)
|
|
119
|
+
this.state.scrollList && this.state.scrollList.setProperty(hmUI.prop.VISIBLE, !isTip)
|
|
120
|
+
} else {
|
|
121
|
+
// 占位刷新
|
|
122
|
+
!this.state.refreshText &&
|
|
123
|
+
(this.state.refreshText = hmUI.createWidget(hmUI.widget.TEXT, {
|
|
124
|
+
...TIPS_TEXT_STYLE,
|
|
125
|
+
text: ' '
|
|
126
|
+
}))
|
|
127
|
+
|
|
128
|
+
this.state.tipText && this.state.tipText.setProperty(hmUI.prop.VISIBLE, false)
|
|
129
|
+
this.state.refreshText.setProperty(hmUI.prop.VISIBLE, true)
|
|
130
|
+
this.state.scrollList && this.state.scrollList.setProperty(hmUI.prop.VISIBLE, false)
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
createAndUpdateList(showEmpty = true) {
|
|
134
|
+
const _scrollListItemClick = (list, index, key) => {
|
|
135
|
+
if (key === 'img_src') {
|
|
136
|
+
this.deleteTodoItem(index)
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
const { scrollList, dataList } = this.state
|
|
140
|
+
this.changeUI(showEmpty)
|
|
141
|
+
const dataTypeConfig = getScrollListDataConfig(
|
|
142
|
+
dataList.length === 0 ? -1 : 0,
|
|
143
|
+
dataList.length
|
|
144
|
+
)
|
|
145
|
+
if (scrollList) {
|
|
146
|
+
scrollList.setProperty(hmUI.prop.UPDATE_DATA, {
|
|
147
|
+
data_array: dataList,
|
|
148
|
+
data_count: dataList.length,
|
|
149
|
+
data_type_config: [{ start: 0, end: dataList.length, type_id: 2 }],
|
|
150
|
+
data_type_config_count: dataTypeConfig.length,
|
|
151
|
+
on_page: 1
|
|
152
|
+
})
|
|
153
|
+
} else {
|
|
154
|
+
this.state.scrollList = hmUI.createWidget(hmUI.widget.SCROLL_LIST, {
|
|
155
|
+
...(SCROLL_LIST || {}),
|
|
156
|
+
data_array: dataList,
|
|
157
|
+
data_count: dataList.length,
|
|
158
|
+
data_type_config: dataTypeConfig,
|
|
159
|
+
data_type_config_count: dataTypeConfig.length,
|
|
160
|
+
item_enable_horizon_drag: true,
|
|
161
|
+
item_drag_max_distance: -120,
|
|
162
|
+
on_page: 1,
|
|
163
|
+
item_click_func: _scrollListItemClick
|
|
164
|
+
})
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
refreshAndUpdate(dataList = []) {
|
|
168
|
+
this.state.dataList = []
|
|
169
|
+
this.createAndUpdateList(false)
|
|
170
|
+
|
|
171
|
+
setTimeout(() => {
|
|
172
|
+
this.state.dataList = dataList
|
|
173
|
+
this.createAndUpdateList()
|
|
174
|
+
}, 20)
|
|
175
|
+
}
|
|
176
|
+
})
|
|
177
|
+
)
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import * as hmUI from '@zos/ui'
|
|
2
|
+
import { getText } from '@zos/i18n'
|
|
3
|
+
import { getDeviceInfo } from '@zos/device'
|
|
4
|
+
import { px } from '@zos/utils'
|
|
5
|
+
|
|
6
|
+
export const { width: DEVICE_WIDTH, height: DEVICE_HEIGHT } = getDeviceInfo()
|
|
7
|
+
|
|
8
|
+
export const TITLE_TEXT_STYLE = {
|
|
9
|
+
text: getText('todoList'),
|
|
10
|
+
x: px(42),
|
|
11
|
+
y: px(65),
|
|
12
|
+
w: DEVICE_WIDTH - px(42 * 2),
|
|
13
|
+
h: px(50),
|
|
14
|
+
color: 0xffffff,
|
|
15
|
+
text_size: 36,
|
|
16
|
+
align_h: hmUI.align.CENTER_H,
|
|
17
|
+
text_style: hmUI.text_style.WRAP
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const ADD_BUTTON = {
|
|
21
|
+
x: Math.floor((DEVICE_WIDTH - px(88)) / 2),
|
|
22
|
+
y: DEVICE_HEIGHT - px(100),
|
|
23
|
+
w: px(88),
|
|
24
|
+
h: px(88),
|
|
25
|
+
normal_src: 'add.png',
|
|
26
|
+
press_src: 'add.png'
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const TIPS_TEXT_STYLE = {
|
|
30
|
+
text: getText('noData'),
|
|
31
|
+
x: px(15),
|
|
32
|
+
y: px(120),
|
|
33
|
+
w: DEVICE_WIDTH - px(15 * 2),
|
|
34
|
+
h: DEVICE_HEIGHT - px(120),
|
|
35
|
+
color: 0xffffff,
|
|
36
|
+
text_size: px(32),
|
|
37
|
+
align_h: hmUI.align.CENTER_H,
|
|
38
|
+
align_v: hmUI.align.CENTER_V,
|
|
39
|
+
text_style: hmUI.text_style.WRAP
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const SCROLL_LIST = {
|
|
43
|
+
item_height: px(120),
|
|
44
|
+
item_space: px(10),
|
|
45
|
+
item_config: [
|
|
46
|
+
{
|
|
47
|
+
type_id: 1,
|
|
48
|
+
item_bg_color: 0x333333,
|
|
49
|
+
item_bg_radius: px(25),
|
|
50
|
+
text_view: [
|
|
51
|
+
{
|
|
52
|
+
x: px(80),
|
|
53
|
+
y: px(0),
|
|
54
|
+
w: px(360),
|
|
55
|
+
h: px(120),
|
|
56
|
+
key: 'name',
|
|
57
|
+
color: 0xffff00,
|
|
58
|
+
text_size: px(36),
|
|
59
|
+
align_h: hmUI.align.LEFT
|
|
60
|
+
}
|
|
61
|
+
],
|
|
62
|
+
text_view_count: 1,
|
|
63
|
+
image_view: [
|
|
64
|
+
{
|
|
65
|
+
x: DEVICE_WIDTH - px(30),
|
|
66
|
+
y: px(16),
|
|
67
|
+
w: px(88),
|
|
68
|
+
h: px(88),
|
|
69
|
+
key: 'img_src',
|
|
70
|
+
action: true
|
|
71
|
+
}
|
|
72
|
+
],
|
|
73
|
+
image_view_count: 1,
|
|
74
|
+
item_height: px(120)
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
type_id: 2,
|
|
78
|
+
item_bg_color: 0x333333,
|
|
79
|
+
item_bg_radius: px(25),
|
|
80
|
+
text_view: [
|
|
81
|
+
{
|
|
82
|
+
x: px(80),
|
|
83
|
+
y: px(0),
|
|
84
|
+
w: px(360),
|
|
85
|
+
h: px(120),
|
|
86
|
+
key: 'name',
|
|
87
|
+
color: 0xff0000,
|
|
88
|
+
text_size: px(36),
|
|
89
|
+
align_h: hmUI.align.LEFT
|
|
90
|
+
}
|
|
91
|
+
],
|
|
92
|
+
text_view_count: 1,
|
|
93
|
+
image_view: [
|
|
94
|
+
{
|
|
95
|
+
x: DEVICE_WIDTH - px(30),
|
|
96
|
+
y: px(16),
|
|
97
|
+
w: px(88),
|
|
98
|
+
h: px(88),
|
|
99
|
+
key: 'img_src',
|
|
100
|
+
action: true
|
|
101
|
+
}
|
|
102
|
+
],
|
|
103
|
+
image_view_count: 1,
|
|
104
|
+
item_height: px(120)
|
|
105
|
+
}
|
|
106
|
+
],
|
|
107
|
+
item_config_count: 2,
|
|
108
|
+
x: px(30),
|
|
109
|
+
y: px(120),
|
|
110
|
+
h: px(250),
|
|
111
|
+
w: DEVICE_WIDTH - px(30) * 2
|
|
112
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import * as hmUI from '@zos/ui'
|
|
2
|
+
import { getText } from '@zos/i18n'
|
|
3
|
+
import { getDeviceInfo } from '@zos/device'
|
|
4
|
+
import { px } from '@zos/utils'
|
|
5
|
+
|
|
6
|
+
export const { width: DEVICE_WIDTH, height: DEVICE_HEIGHT } = getDeviceInfo()
|
|
7
|
+
|
|
8
|
+
export const TITLE_TEXT_STYLE = {
|
|
9
|
+
text: getText('todoList'),
|
|
10
|
+
x: px(42),
|
|
11
|
+
y: px(65),
|
|
12
|
+
w: DEVICE_WIDTH - px(42 * 2),
|
|
13
|
+
h: px(50),
|
|
14
|
+
color: 0xffffff,
|
|
15
|
+
text_size: 36,
|
|
16
|
+
align_h: hmUI.align.CENTER_H,
|
|
17
|
+
text_style: hmUI.text_style.WRAP
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const ADD_BUTTON = {
|
|
21
|
+
x: Math.floor((DEVICE_WIDTH - px(88)) / 2),
|
|
22
|
+
y: DEVICE_HEIGHT - px(100),
|
|
23
|
+
w: px(88),
|
|
24
|
+
h: px(88),
|
|
25
|
+
normal_src: 'add.png',
|
|
26
|
+
press_src: 'add.png'
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const TIPS_TEXT_STYLE = {
|
|
30
|
+
text: getText('noData'),
|
|
31
|
+
x: px(15),
|
|
32
|
+
y: px(120),
|
|
33
|
+
w: DEVICE_WIDTH - px(15 * 2),
|
|
34
|
+
h: DEVICE_HEIGHT - px(120),
|
|
35
|
+
color: 0xffffff,
|
|
36
|
+
text_size: px(32),
|
|
37
|
+
align_h: hmUI.align.CENTER_H,
|
|
38
|
+
align_v: hmUI.align.CENTER_V,
|
|
39
|
+
text_style: hmUI.text_style.WRAP
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const SCROLL_LIST = {
|
|
43
|
+
item_height: px(120),
|
|
44
|
+
item_space: px(10),
|
|
45
|
+
item_config: [
|
|
46
|
+
{
|
|
47
|
+
type_id: 1,
|
|
48
|
+
item_bg_color: 0x333333,
|
|
49
|
+
item_bg_radius: px(25),
|
|
50
|
+
text_view: [
|
|
51
|
+
{
|
|
52
|
+
x: px(80),
|
|
53
|
+
y: px(0),
|
|
54
|
+
w: px(360),
|
|
55
|
+
h: px(120),
|
|
56
|
+
key: 'name',
|
|
57
|
+
color: 0xffff00,
|
|
58
|
+
text_size: px(36),
|
|
59
|
+
align_h: hmUI.align.LEFT
|
|
60
|
+
}
|
|
61
|
+
],
|
|
62
|
+
text_view_count: 1,
|
|
63
|
+
image_view: [
|
|
64
|
+
{
|
|
65
|
+
x: DEVICE_WIDTH - px(10),
|
|
66
|
+
y: px(16),
|
|
67
|
+
w: px(88),
|
|
68
|
+
h: px(88),
|
|
69
|
+
key: 'img_src',
|
|
70
|
+
action: true
|
|
71
|
+
}
|
|
72
|
+
],
|
|
73
|
+
image_view_count: 1,
|
|
74
|
+
item_height: px(120)
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
type_id: 2,
|
|
78
|
+
item_bg_color: 0x333333,
|
|
79
|
+
item_bg_radius: px(25),
|
|
80
|
+
text_view: [
|
|
81
|
+
{
|
|
82
|
+
x: px(80),
|
|
83
|
+
y: px(0),
|
|
84
|
+
w: px(360),
|
|
85
|
+
h: px(120),
|
|
86
|
+
key: 'name',
|
|
87
|
+
color: 0xff0000,
|
|
88
|
+
text_size: px(36),
|
|
89
|
+
align_h: hmUI.align.LEFT
|
|
90
|
+
}
|
|
91
|
+
],
|
|
92
|
+
text_view_count: 1,
|
|
93
|
+
image_view: [
|
|
94
|
+
{
|
|
95
|
+
x: DEVICE_WIDTH - px(10),
|
|
96
|
+
y: px(16),
|
|
97
|
+
w: px(88),
|
|
98
|
+
h: px(88),
|
|
99
|
+
key: 'img_src',
|
|
100
|
+
action: true
|
|
101
|
+
}
|
|
102
|
+
],
|
|
103
|
+
image_view_count: 1,
|
|
104
|
+
item_height: px(120)
|
|
105
|
+
}
|
|
106
|
+
],
|
|
107
|
+
item_config_count: 2,
|
|
108
|
+
x: px(10),
|
|
109
|
+
y: px(80),
|
|
110
|
+
h: px(250),
|
|
111
|
+
w: DEVICE_WIDTH - px(10) * 2
|
|
112
|
+
}
|
package/private-modules/zeppos-app-utils/dist/public/template/os4.0/app/todo-list/page/i18n/en-US.po
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
|
|
2
|
+
msgid "todoList"
|
|
3
|
+
msgstr "todo List"
|
|
4
|
+
|
|
5
|
+
msgid "noData"
|
|
6
|
+
msgstr "No data, please add it on the phone"
|
|
7
|
+
|
|
8
|
+
msgid "add"
|
|
9
|
+
msgstr "Add"
|
|
10
|
+
|
|
11
|
+
msgid "deleteSuccess"
|
|
12
|
+
msgstr "successfully deleted"
|
|
13
|
+
|
|
14
|
+
msgid "deleteFailure"
|
|
15
|
+
msgstr "Delete failed, check the network"
|
|
16
|
+
|
|
17
|
+
msgid "addSuccess"
|
|
18
|
+
msgstr "Added successfully"
|
|
19
|
+
|
|
20
|
+
msgid "addFailure"
|
|
21
|
+
msgstr "Failed to add, check the network"
|
package/private-modules/zeppos-app-utils/dist/public/template/os4.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
|
+
})
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { statSync, writeFileSync as writeFile, readFileSync as readFile } from '@zos/fs'
|
|
2
|
+
|
|
3
|
+
import { TODO_FILE_NAME } from './constants'
|
|
4
|
+
|
|
5
|
+
export function readFileSync() {
|
|
6
|
+
const fStat = statSync({
|
|
7
|
+
path: this.fileName
|
|
8
|
+
})
|
|
9
|
+
if (fStat) {
|
|
10
|
+
const resData = readFile({
|
|
11
|
+
path: TODO_FILE_NAME,
|
|
12
|
+
options: {
|
|
13
|
+
encoding: 'utf8'
|
|
14
|
+
}
|
|
15
|
+
})
|
|
16
|
+
return !resData ? [] : JSON.parse(resData)
|
|
17
|
+
} else {
|
|
18
|
+
return []
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function writeFileSync(data, merge = true) {
|
|
23
|
+
let params = data
|
|
24
|
+
if (merge) {
|
|
25
|
+
params = [...readFile(), ...data]
|
|
26
|
+
}
|
|
27
|
+
writeFile({
|
|
28
|
+
path: TODO_FILE_NAME,
|
|
29
|
+
data: JSON.stringify(params),
|
|
30
|
+
options: {
|
|
31
|
+
encoding: 'utf8'
|
|
32
|
+
}
|
|
33
|
+
})
|
|
34
|
+
}
|