diff --git a/UI/Toolbar/README_zh.md b/UI/Toolbar/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..f1cc4e95477229d094bc14fed7ad83e3508ba79d --- /dev/null +++ b/UI/Toolbar/README_zh.md @@ -0,0 +1,13 @@ +# 工具栏 + +### 简介 + +工具栏放在界面底部,可展示针对当前界面的各种操作,子组件表示工具栏上的一个操作选项,必须为其设置图片与文字。本示例使用工具栏实现了对小说阅读界面的模拟。 + +### 使用说明 + +本示例主界面为列表目录,点击列表条目,跳转到对应章节内容,点击内容可呼出工具栏,可通过工具栏中的操作选项来更改页面属性或章节跳转。 + +### 约束与限制 + +本示例仅支持在标准系统上使用。 \ No newline at end of file diff --git a/UI/Toolbar/build.gradle b/UI/Toolbar/build.gradle new file mode 100644 index 0000000000000000000000000000000000000000..ad33f7c014a76f9b635c1e497c19e278f2aef9da --- /dev/null +++ b/UI/Toolbar/build.gradle @@ -0,0 +1,36 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +apply plugin: 'com.huawei.ohos.app' + +ohos { + compileSdkVersion 6 + defaultConfig { + compatibleSdkVersion 6 + } +} + +buildscript { + repositories { + maven { + url 'https://repo.huaweicloud.com/repository/maven/' + } + maven { + url 'https://developer.huawei.com/repo/' + } + jcenter() + } + dependencies { + classpath 'com.huawei.ohos:hap:2.4.4.3-RC' + } +} + +allprojects { + repositories { + maven { + url 'https://repo.huaweicloud.com/repository/maven/' + } + maven { + url 'https://developer.huawei.com/repo/' + } + jcenter() + } +} \ No newline at end of file diff --git a/UI/Toolbar/entry/build.gradle b/UI/Toolbar/entry/build.gradle new file mode 100644 index 0000000000000000000000000000000000000000..6b6a606b1b3e2af76d27a6fa8ad069e92ddbed68 --- /dev/null +++ b/UI/Toolbar/entry/build.gradle @@ -0,0 +1,17 @@ +apply plugin: 'com.huawei.ohos.hap' + +ohos { + compileSdkVersion 6 + defaultConfig { + compatibleSdkVersion 6 + } + buildTypes { + release { + proguardOpt { + proguardEnabled false + rulesFiles 'proguard-rules.pro' + } + } + } + supportSystem "standard" +} diff --git a/UI/Toolbar/entry/src/main/config.json b/UI/Toolbar/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..a256150b8b83ec3332a4e0d043076d1bc144e63b --- /dev/null +++ b/UI/Toolbar/entry/src/main/config.json @@ -0,0 +1,57 @@ +{ + "app": { + "bundleName": "ohos.samples.toolbar", + "version": { + "code": 1000000, + "name": "1.0.0" + } + }, + "deviceConfig": {}, + "module": { + "package": "ohos.samples.toolbar", + "name": ".MainAbility", + "mainAbility": "ohos.samples.toolbar.MainAbility", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "ohos.samples.toolbar.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "$string:app_name", + "type": "page", + "launchType": "standard" + } + ], + "js": [ + { + "pages": [ + "pages/index/index", + "pages/toolbar/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": true + } + } + ] + } +} \ No newline at end of file diff --git a/UI/Toolbar/entry/src/main/js/default/app.js b/UI/Toolbar/entry/src/main/js/default/app.js new file mode 100644 index 0000000000000000000000000000000000000000..8e47afff13e928a74fdcc01a108e4422404b9ac9 --- /dev/null +++ b/UI/Toolbar/entry/src/main/js/default/app.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default { + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + } +}; diff --git a/UI/Toolbar/entry/src/main/js/default/common/images/bright.png b/UI/Toolbar/entry/src/main/js/default/common/images/bright.png new file mode 100644 index 0000000000000000000000000000000000000000..b72177f2fa256f5171e7cbec0b8aad40dcf68c5f Binary files /dev/null and b/UI/Toolbar/entry/src/main/js/default/common/images/bright.png differ diff --git a/UI/Toolbar/entry/src/main/js/default/common/images/dark.png b/UI/Toolbar/entry/src/main/js/default/common/images/dark.png new file mode 100644 index 0000000000000000000000000000000000000000..1a8e4d4cebb9b1161df2d596de5c1d9f1b036947 Binary files /dev/null and b/UI/Toolbar/entry/src/main/js/default/common/images/dark.png differ diff --git a/UI/Toolbar/entry/src/main/js/default/common/images/directory.png b/UI/Toolbar/entry/src/main/js/default/common/images/directory.png new file mode 100644 index 0000000000000000000000000000000000000000..c730b81668b073ce2560c042d85aa81e624f75dd Binary files /dev/null and b/UI/Toolbar/entry/src/main/js/default/common/images/directory.png differ diff --git a/UI/Toolbar/entry/src/main/js/default/common/images/next.png b/UI/Toolbar/entry/src/main/js/default/common/images/next.png new file mode 100644 index 0000000000000000000000000000000000000000..bfebc6fc5d445371169d555b6c8bfaafcbbac078 Binary files /dev/null and b/UI/Toolbar/entry/src/main/js/default/common/images/next.png differ diff --git a/UI/Toolbar/entry/src/main/js/default/common/images/previous.png b/UI/Toolbar/entry/src/main/js/default/common/images/previous.png new file mode 100644 index 0000000000000000000000000000000000000000..352237ef60beb4aadffaceb73280f8d790b7f9c4 Binary files /dev/null and b/UI/Toolbar/entry/src/main/js/default/common/images/previous.png differ diff --git a/UI/Toolbar/entry/src/main/js/default/i18n/en-US.json b/UI/Toolbar/entry/src/main/js/default/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..d5f2f0c547a3de0c0ed73a166d4d827e5e6bba94 --- /dev/null +++ b/UI/Toolbar/entry/src/main/js/default/i18n/en-US.json @@ -0,0 +1,14 @@ +{ + "strings": { + "directory": "directory", + "the": "The ", + "chapter": " chapter", + "context": "context", + "previous": "previous", + "next": "next", + "bright": "bright", + "dark": "dark", + "first": "The current chapter is the final chapter", + "last": "The current chapter is the first chapter" + } +} \ No newline at end of file diff --git a/UI/Toolbar/entry/src/main/js/default/i18n/zh-CN.json b/UI/Toolbar/entry/src/main/js/default/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..e72e8927eee26425ae0b452825a10736c89a9e55 --- /dev/null +++ b/UI/Toolbar/entry/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,14 @@ +{ + "strings": { + "directory": "目录", + "the": "第", + "chapter": "章", + "context": "内容", + "previous": "上一章", + "next": "下一章", + "bright": "亮色", + "dark": "暗色", + "first": "当前章节为第一章", + "last": "当前章节为最后一章" + } +} \ No newline at end of file diff --git a/UI/Toolbar/entry/src/main/js/default/pages/index/index.css b/UI/Toolbar/entry/src/main/js/default/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..a2d7d625d246c571bd7f10bd08c821af4813fc26 --- /dev/null +++ b/UI/Toolbar/entry/src/main/js/default/pages/index/index.css @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +.container { + flex-direction: column; + align-items: center; + background-color: #ABDAFF; +} + +.title { + margin-top: 20px; + margin-bottom: 20px; + font-size: 30px; +} + +.item { + height: 60px; + background-color: #FAFAFA; + margin-top: 2px; +} + +.list { + flex-direction: column; + justify-content: center; + align-items: center +} + +.text { + margin-left: 10px; + font-size: 24px; +} \ No newline at end of file diff --git a/UI/Toolbar/entry/src/main/js/default/pages/index/index.hml b/UI/Toolbar/entry/src/main/js/default/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..ccbb76d77a5a029f7cbbc35aae43e3f4507c592b --- /dev/null +++ b/UI/Toolbar/entry/src/main/js/default/pages/index/index.hml @@ -0,0 +1,24 @@ + + +
+ {{ $t('strings.directory') }} + + + {{ $item.title }} + + +
\ No newline at end of file diff --git a/UI/Toolbar/entry/src/main/js/default/pages/index/index.js b/UI/Toolbar/entry/src/main/js/default/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..a56b76f41035415e89a5c8a2f7421c623a6f90d9 --- /dev/null +++ b/UI/Toolbar/entry/src/main/js/default/pages/index/index.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import router from '@system.router'; + +export default { + data: { + list: [] + }, + onInit() { + for (var i = 1; i <= 15; i++) { + var item = { + uri: "pages/toolbar/index", + title: this.$t('strings.the') + i + this.$t('strings.chapter'), + id: i + } + this.list.push(item); + } + }, + jumpPage(id, uri) { + var cardId = this.$element(id).attr.id + router.push({ + uri: uri, + params: { + ref: cardId + } + }); + } +} diff --git a/UI/Toolbar/entry/src/main/js/default/pages/toolbar/index.css b/UI/Toolbar/entry/src/main/js/default/pages/toolbar/index.css new file mode 100644 index 0000000000000000000000000000000000000000..f17a967cab145a8bd2fbdb2ac8c1d38c511b1829 --- /dev/null +++ b/UI/Toolbar/entry/src/main/js/default/pages/toolbar/index.css @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +.container { + flex-direction: column; + align-items: center; + justify-content: center; +} + +.list { + height: 85%; + width: 100%; + flex-direction: column; + align-items: center; + justify-content: center; +} + +.title { + position: absolute; + top: 15px; + left: 10px; + font-size: 30px; +} + +.text { + font-size: 24px; +} + +.toolbar { + width: 100%; + position: absolute; + bottom: 0px; + opacity: 0.6; +} + diff --git a/UI/Toolbar/entry/src/main/js/default/pages/toolbar/index.hml b/UI/Toolbar/entry/src/main/js/default/pages/toolbar/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..9fea164462acf0d71f54080660d960f3fc8f93d5 --- /dev/null +++ b/UI/Toolbar/entry/src/main/js/default/pages/toolbar/index.hml @@ -0,0 +1,31 @@ + + +
+ {{ title }} +
+ {{ $t('strings.context') }} +
+ + + + + + + + + +
\ No newline at end of file diff --git a/UI/Toolbar/entry/src/main/js/default/pages/toolbar/index.js b/UI/Toolbar/entry/src/main/js/default/pages/toolbar/index.js new file mode 100644 index 0000000000000000000000000000000000000000..e54562a5c6e3e7679b96863cd03a2c35837c118f --- /dev/null +++ b/UI/Toolbar/entry/src/main/js/default/pages/toolbar/index.js @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import prompt from '@system.prompt'; +import router from '@system.router' + +export default { + data: { + containerBackground: "white", + listBackground: "white", + hidden: "hidden", + title: "", + num: 0, + isState: true, + isHidden: false + }, + onInit() { + this.num = this.ref + this.flash(this.num) + }, + flash(id) { + this.title = this.$t('strings.the') + JSON.stringify(id) + this.$t('strings.chapter') + }, + show() { + if (this.isHidden) { + this.hidden = "hidden" + this.isHidden = false + } else { + this.hidden = "visible" + this.isHidden = true + } + }, + jumpBack() { + router.push({ + uri: "pages/index/index" + }) + }, + black() { + if (this.isState) { + this.isState = false + this.containerBackground = "#999999" + this.listBackground = "#999999" + } else { + this.isState = true + this.containerBackground = "white" + this.listBackground = "white" + } + }, + change(choose) { + if (this.num == 1 && choose == "previous") { + prompt.showToast({ + message: this.$t('strings.first') + }) + } else if (choose == "previous") { + this.flash(--this.num) + } else if (this.num == 15 && choose == "next") { + prompt.showToast({ + message: this.$t('strings.last') + }) + } else if (choose == "next") { + this.flash(++this.num) + } + } +} \ No newline at end of file diff --git a/UI/Toolbar/entry/src/main/resources/base/element/string.json b/UI/Toolbar/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..a4898df1c20d9896e4cc7f9d8e5bab9c5577eb59 --- /dev/null +++ b/UI/Toolbar/entry/src/main/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "Toolbar" + }, + { + "name": "mainability_description", + "value": "JS_Empty Ability" + } + ] +} \ No newline at end of file diff --git a/UI/Toolbar/entry/src/main/resources/base/media/icon.png b/UI/Toolbar/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/UI/Toolbar/entry/src/main/resources/base/media/icon.png differ diff --git a/UI/Toolbar/entry/src/main/resources/en/element/string.json b/UI/Toolbar/entry/src/main/resources/en/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..66e02a40851f577356389edbf6f98ecb728d5d6b --- /dev/null +++ b/UI/Toolbar/entry/src/main/resources/en/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "Toobar" + }, + { + "name": "mainability_description", + "value": "JS_Empty Ability" + } + ] +} \ No newline at end of file diff --git a/UI/Toolbar/entry/src/main/resources/zh/element/string.json b/UI/Toolbar/entry/src/main/resources/zh/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..94f68c95752d5982bdacd719329b26d486a04240 --- /dev/null +++ b/UI/Toolbar/entry/src/main/resources/zh/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "工具栏" + }, + { + "name": "mainability_description", + "value": "JS_Empty Ability" + } + ] +} \ No newline at end of file diff --git a/UI/Toolbar/screenshots/device/bright.png b/UI/Toolbar/screenshots/device/bright.png new file mode 100644 index 0000000000000000000000000000000000000000..8fdae3863332908c87b4ab1d66cd83a05724e630 Binary files /dev/null and b/UI/Toolbar/screenshots/device/bright.png differ diff --git a/UI/Toolbar/screenshots/device/dark.png b/UI/Toolbar/screenshots/device/dark.png new file mode 100644 index 0000000000000000000000000000000000000000..404dc8cf72087f8419758c62762c359eb16f1ca8 Binary files /dev/null and b/UI/Toolbar/screenshots/device/dark.png differ diff --git a/UI/Toolbar/screenshots/device/directory.png b/UI/Toolbar/screenshots/device/directory.png new file mode 100644 index 0000000000000000000000000000000000000000..41c988081fdb8ff76dcaa8fe36b4709b4de8daa0 Binary files /dev/null and b/UI/Toolbar/screenshots/device/directory.png differ diff --git a/UI/Toolbar/screenshots/device/toolbar.png b/UI/Toolbar/screenshots/device/toolbar.png new file mode 100644 index 0000000000000000000000000000000000000000..490a41a9eae8e765f2c7646dbad1b56a62159f10 Binary files /dev/null and b/UI/Toolbar/screenshots/device/toolbar.png differ diff --git a/UI/Toolbar/settings.gradle b/UI/Toolbar/settings.gradle new file mode 100644 index 0000000000000000000000000000000000000000..4773db73233a570c2d0c01a22e75321acfbf7a07 --- /dev/null +++ b/UI/Toolbar/settings.gradle @@ -0,0 +1 @@ +include ':entry'