diff --git a/common/AirQuality/README_zh.md b/common/AirQuality/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..f91adb7c1759b9bed79f4d63477815859a0ef528 --- /dev/null +++ b/common/AirQuality/README_zh.md @@ -0,0 +1,16 @@ +# 空气质量 + +### 简介 + +本示例使用JS实现了一个简单空气质量应用,使用折行显示能力显示空气质量信息,使用柱形图展示历史记录。 + +### 使用说明 + +- 点击桌面应用图标,启动应用; +- 在首页展示空气质量信息,左右滑动可以切换城市; +- 点击历史记录可以跳转到历史记录页面,此界面用柱形图展示历史记录; + +### 约束与限制 + +- 本示例支持在标准系统上运行。 + diff --git a/common/AirQuality/build.gradle b/common/AirQuality/build.gradle new file mode 100644 index 0000000000000000000000000000000000000000..46b60f671636e773ed178e73685210c630acf439 --- /dev/null +++ b/common/AirQuality/build.gradle @@ -0,0 +1,33 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +apply plugin: 'com.huawei.ohos.app' + +//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510 +ohos { + compileSdkVersion 7 + supportSystem "standard" +} + +buildscript { + repositories { + maven { + url 'https://repo.huaweicloud.com/repository/maven/' + } + maven { + url 'https://developer.huawei.com/repo/' + } + } + dependencies { + classpath 'com.huawei.ohos:hap:3.0.3.2' + } +} + +allprojects { + repositories { + maven { + url 'https://repo.huaweicloud.com/repository/maven/' + } + maven { + url 'https://developer.huawei.com/repo/' + } + } +} diff --git a/common/AirQuality/entry/build.gradle b/common/AirQuality/entry/build.gradle new file mode 100644 index 0000000000000000000000000000000000000000..4186492febe943de4f349ab0adfbb168d763274a --- /dev/null +++ b/common/AirQuality/entry/build.gradle @@ -0,0 +1,17 @@ +apply plugin: 'com.huawei.ohos.hap' +//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510 +ohos { + compileSdkVersion 7 + defaultConfig { + compatibleSdkVersion 6 + } + buildTypes { + release { + proguardOpt { + proguardEnabled false + rulesFiles 'proguard-rules.pro' + } + } + } +} + diff --git a/common/AirQuality/entry/src/main/config.json b/common/AirQuality/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..946975608fee4bc9af6fdfb8a84698c58c5edad0 --- /dev/null +++ b/common/AirQuality/entry/src/main/config.json @@ -0,0 +1,62 @@ +{ + "app": { + "bundleName": "ohos.samples.airquality", + "vendor": "samples", + "version": { + "code": 1000000, + "name": "1.0.0" + } + }, + "deviceConfig": {}, + "module": { + "package": "ohos.samples.airquality", + "name": ".MyApplication", + "mainAbility": ".default", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "name": ".default", + "srcPath": "default", + "srcLanguage": "js", + "icon": "$media:icon", + "description": "$string:mainability_description", + "formsEnabled": false, + "label": "$string:app_name", + "type": "page", + "launchType": "standard" + } + ], + "js": [ + { + "pages": [ + "pages/index/index", + "pages/second/second" + ], + "name": ".default", + "window": { + "designWidth": 720, + "autoDesignWidth": true + } + } + ] + } +} \ No newline at end of file diff --git a/common/AirQuality/entry/src/main/js/default/app.js b/common/AirQuality/entry/src/main/js/default/app.js new file mode 100644 index 0000000000000000000000000000000000000000..50449ecbed6d3b8099f6f9a1fb66e29bbe2177f0 --- /dev/null +++ b/common/AirQuality/entry/src/main/js/default/app.js @@ -0,0 +1,22 @@ +/* + * 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("Application onCreate"); + }, + onDestroy() { + console.info("Application onDestroy"); + } +}; diff --git a/common/AirQuality/entry/src/main/js/default/common/ic_back.png b/common/AirQuality/entry/src/main/js/default/common/ic_back.png new file mode 100644 index 0000000000000000000000000000000000000000..4a269a11a6eca005d2eabb957992297446c858db Binary files /dev/null and b/common/AirQuality/entry/src/main/js/default/common/ic_back.png differ diff --git a/common/AirQuality/entry/src/main/js/default/i18n/en-US.json b/common/AirQuality/entry/src/main/js/default/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..9eb7314a8f13aa1a24e7422ca82c736a9f259f32 --- /dev/null +++ b/common/AirQuality/entry/src/main/js/default/i18n/en-US.json @@ -0,0 +1,10 @@ +{ + "strings": { + "title": "AirQuality", + "history": "History record", + "update_time": "Update time: 10: 38", + "source_info": "Information source: tianqi.com" + }, + "Files": { + } +} \ No newline at end of file diff --git a/common/AirQuality/entry/src/main/js/default/i18n/zh-CN.json b/common/AirQuality/entry/src/main/js/default/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..c7321ad12ddf019fa26037565302e8314f179609 --- /dev/null +++ b/common/AirQuality/entry/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,10 @@ +{ + "strings": { + "title": "空气质量", + "history": "历史记录", + "update_time": "更新时间: 10: 38", + "source_info": "信息来源: tianqi.com" + }, + "Files": { + } +} \ No newline at end of file diff --git a/common/AirQuality/entry/src/main/js/default/pages/index/index.css b/common/AirQuality/entry/src/main/js/default/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..c385c66236178f1ea8ea5799247e64e543cd6af3 --- /dev/null +++ b/common/AirQuality/entry/src/main/js/default/pages/index/index.css @@ -0,0 +1,188 @@ +/* + * 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. + */ +.aqi-value { + text-align: center; + font-size: 40px; + color: #000000; + width: 100%; + height: 25%; +} + +.list { + width: 100%; + height: 100%; +} + +.list-item { + flex-direction: column; + align-items: center; + justify-content: center; +} + +.aqi { + text-align: center; + color: #a2c4a2; + margin-top: 10%; + font-size: 30px; + width: 100%; + height: 30%; +} + +.airquality { + text-align: center; + width: 100%; + height: 25%; + font-size: 30px; +} + +.image { + top: 285px; + left: 274px; + width: 32px; + height: 32px; +} + +.location-text { + text-align: center; + color: #000000; + width: 100%; + height: 50px; + font-size: 35px; +} +.progress-div { + width: 320px; + height: 220px; + flex-direction: column; +} +.progress { + width: 100%; + height: 100%; +} + +.container { + flex-direction: column; + height: 100%; + width: 100%; +} + +.circle-progress { + start-angle: 198deg; + total-angle: 320deg; + stroke-width: 20px; + width: 100%; + height: 100%; + top:5px; +} + +.mask-layer { + width: 100%; + height: 100%; + top:10px; + flex-direction: column; +} + +.detail { + width: 350px; + height: 280px; + flex-direction: column; + justify-content: center; + align-items: center; +} + +.text-wrapper { + width: 100%; + height: 16%; +} + +.gas-name { + width: 50%; + text-align: left; + margin-left: 30%; +} + +.gas-value { + width: 50%; + text-align: right; + margin-right: 30%; +} + +.btn { + width: 50%; + height: 50px; + border-radius: 55px; + background-color: #1a1a1a; + color: #1085CE; +} + +.footer { + width: 100%; + height: 120px; + flex-direction: column; + align-items: center; + margin-top: 10px; +} + +.header { + width: 100%; + height: 80px; +} + +.back { + width: 36px; + height: 36px; + margin-top: 20px; + margin-left: 21px; + color: #e6e6e6; +} + +.title { + width: 296px; + height: 40px; + margin-top: 20px; + margin-left: 21px; + color: #e6e6e6; +} + +.swiper { + height: 700px; + width: 100%; +} + +.page { + width: 100%; + height: 100%; + flex-direction: row; + flex-wrap:wrap; + align-items: center; + justify-content: center; +} + +.update-time { + width: 100%; + color: #A9A9A9; + text-align: center; +} + +.info-source { + width: 100%; + color: #A9A9A9; + text-align: center; +} + +.circle-div { + width: 12px; + height: 12px; + border-radius: 6px; +} \ No newline at end of file diff --git a/common/AirQuality/entry/src/main/js/default/pages/index/index.hml b/common/AirQuality/entry/src/main/js/default/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..02620f661ce31eeafdcaf573f079a7f1913eafc5 --- /dev/null +++ b/common/AirQuality/entry/src/main/js/default/pages/index/index.hml @@ -0,0 +1,120 @@ + +
+
+ + {{ $t('strings.title') }} +
+ + + +
+
+ + {{ airData[0].location }} + + + + +
+ AQI + {{ airData[0].detailData }} + {{ airData[0].airQuality }} + +
+
+
+
+
+ CO + 100 +
+
+ NO2 + 90 +
+
+ PM10 + 120 +
+
+ PM2.5 + 40 +
+
+ SO2 + 150 +
+
+
+ +
+ +
+
+
+ + {{ airData[1].location }} + + + + +
+ AQI + {{ airData[1].detailData }} + {{ airData[1].airQuality }} + +
+
+
+
+
+ CO + 100 +
+
+ NO2 + 90 +
+
+ PM10 + 120 +
+
+ PM2.5 + 40 +
+
+ SO2 + 150 +
+
+ + +
+
+
+
+
diff --git a/common/AirQuality/entry/src/main/js/default/pages/index/index.js b/common/AirQuality/entry/src/main/js/default/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..f18ece7f111c6219806b7c86a4b054029224f8d0 --- /dev/null +++ b/common/AirQuality/entry/src/main/js/default/pages/index/index.js @@ -0,0 +1,98 @@ +/* + * 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'; +import app from '@system.app'; + +export default { + data: { + textColor1: '#00ff00', + textColor2: '#00ff00', + bgColor1: '#669966', + bgColor2: '#669966', + swiperPage: 0, + percent1: 40, + percent2: 90, + iconcheckedBR: '6px', + iconcheckedColor: '#ffffff', + iconUncheckedColor: '#262626', + src1: '/common/cloud_green.png', + src2: '/common/cloud_green.png', + airData: [{ + location: '东莞', + airQuality: '良', + detailData: 40 + }, { + location: '深圳', + airQuality: '差', + detailData: 90 + }] + }, + onInit() { + if (this.airData[0].detailData > 100) { + this.src1 = '/common/cloud_red.png'; + this.textColor1 = '#ff0000'; + this.bgColor1 = '#9d7462'; + } else if (this.airData[0].detailData > 50 ) { + this.src1 = '/common/cloud_yellow.png'; + this.textColor1 = '#ecf19a'; + this.bgColor1 = '#9d9d62'; + } + if (this.airData[1].detailData > 100) { + this.src2 = '/common/cloud_red.png'; + this.textColor2 = '#ff0000'; + this.bgColor2 = '#9d9d62'; + } else if (50 < this.airData[1].detailData) { + this.src2 = '/common/cloud_yellow.png' + this.textColor2 = '#ecf19a'; + this.bgColor2 = '#9d9d62'; + } + if (this.selectedCityIndex) { + this.swiperPage = this.selectedCityIntex + if (this.swiperPage == 0) { + this.iconcheckedBR = '#ffffff'; + this.iconUncheckedColor = '#262626'; + } else { + this.iconcheckedColor = '#262626'; + this.iconUncheckedColor = '#ffffff'; + } + } + }, + openDetail() { + router.replace({ + uri: 'pages/second/second', + params: { + selectedCityIndex: this.swiperPage + } + }); + }, + exitApp() { + console.log('start exit'); + app.terminate(); + console.log('end exit') + }, + swiperChange(e) { + this.swiperPage = e.index; + if (e.index == 0) { + this.iconcheckedColor = '#ffffff'; + this.iconUncheckedColor = '#262626'; + } else { + this.iconcheckedColor = '#262626'; + this.iconUncheckedColor = '#ffffff'; + } + } +} + + + diff --git a/common/AirQuality/entry/src/main/js/default/pages/second/second.css b/common/AirQuality/entry/src/main/js/default/pages/second/second.css new file mode 100644 index 0000000000000000000000000000000000000000..289345c63a6700777fed0fff7843cdaeb68d3fdd --- /dev/null +++ b/common/AirQuality/entry/src/main/js/default/pages/second/second.css @@ -0,0 +1,116 @@ +/* + * 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. + */ +.location { + text-align: center; + color: #000000; + width: 100%; + height: 100%; + font-size: 40px; +} + +.container { + height: 100%; + width: 100%; + flex-direction: column; +} + +.header { + width: 100%; + height: 60px; + align-items: center; +} + +.back { + width: 36px; + height: 36px; + margin-left: 39px; +} + +.title { + width: 296px; + height: 40px; + margin-left: 21px; + color: #e6e6e6; +} + +.chart-list { + width: 100%; + height: 900px; +} + +.list-item-title { + width: 100%; + height: 80px; +} + +.list-item-chart { + width: 100%; + height: 250px; +} + +.chart-wrapper { + width: 47%; + height: 256px; + flex-direction: column; +} + +.chart-wrapper1 { + width: 60%; + height: 256px; + flex-direction: column; +} + +.gas-name { + width: 100%; + height: 35px; + text-align: left; +} + +.chart { + width: 100%; + height: 155px; + margin-top: 10px; + justify-content: flex-start; + align-items: flex-end; +} + +.chart-item { + width: 24px; + margin-left: 18px; + border-radius: 3px; +} + +.white-line { + width: 100%; + height: 2px; + background-color: #ffffff; + margin-top: 22px; +} + +.week { + width: 100%; + height: 40px; + margin-top: 6px; + border-color: #ffffff; + border-radius: 2px; +} + +.day { + width: 26px; + height: 40px; + font-size: 10px; + margin-left: 16px; + text-align: center; +} \ No newline at end of file diff --git a/common/AirQuality/entry/src/main/js/default/pages/second/second.hml b/common/AirQuality/entry/src/main/js/default/pages/second/second.hml new file mode 100644 index 0000000000000000000000000000000000000000..6d0e315e60afacd54fd7e5fa0f0636bfe19cda2d --- /dev/null +++ b/common/AirQuality/entry/src/main/js/default/pages/second/second.hml @@ -0,0 +1,147 @@ + +
+
+ + {{ $t('strings.title') }} +
+ + + {{ location }} + + +
+
+ CO +
+
+
+
+
+
+
+
+
+
+
+ MON + TUE + WED + THU + FRI + SAT + SUN +
+
+
+ SO2 +
+
+
+
+
+
+
+
+
+
+
+ MON + TUE + WED + THU + FRI + SAT + SUN +
+
+
+
+ +
+
+ PM10 +
+
+
+
+
+
+
+
+
+
+
+ MON + TUE + WED + THU + FRI + SAT + SUN +
+
+
+ PM2.5 +
+
+
+
+
+
+
+
+
+
+
+ MON + TUE + WED + THU + FRI + SAT + SUN +
+
+
+
+ +
+
+ NO2 +
+
+
+
+
+
+
+
+
+
+
+ MON + TUE + WED + THU + FRI + SAT + SUN +
+
+
+
+
+
diff --git a/common/AirQuality/entry/src/main/js/default/pages/second/second.js b/common/AirQuality/entry/src/main/js/default/pages/second/second.js new file mode 100644 index 0000000000000000000000000000000000000000..1912cea0dc4e66fef86a4a25703202f3dcd109b9 --- /dev/null +++ b/common/AirQuality/entry/src/main/js/default/pages/second/second.js @@ -0,0 +1,36 @@ +/* + * 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: { + location: '' + }, + onInit() { + if (this.selectedCityIndex === 0) { + this.location = '东莞'; + } else { + this.location = '深圳'; + } + }, + backMain() { + router.replace({ + uri: 'pages/index/index', + params: { + selectedCityIndex: this.selectedCityIndex + } + }); + } +} diff --git a/common/AirQuality/entry/src/main/resources/base/element/string.json b/common/AirQuality/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..277fb5384b78a798de55ddce8182f058dfece991 --- /dev/null +++ b/common/AirQuality/entry/src/main/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "AirQuality" + }, + { + "name": "mainability_description", + "value": "JS_Empty Ability" + } + ] +} \ No newline at end of file diff --git a/common/AirQuality/entry/src/main/resources/base/media/icon.png b/common/AirQuality/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..1f1899c2d46e2de8a01588efa3168b79cfd173d5 Binary files /dev/null and b/common/AirQuality/entry/src/main/resources/base/media/icon.png differ diff --git a/common/AirQuality/settings.gradle b/common/AirQuality/settings.gradle new file mode 100644 index 0000000000000000000000000000000000000000..4773db73233a570c2d0c01a22e75321acfbf7a07 --- /dev/null +++ b/common/AirQuality/settings.gradle @@ -0,0 +1 @@ +include ':entry' diff --git a/common/DistributeCalc/entry/src/main/js/default/pages/index/index.hml b/common/DistributeCalc/entry/src/main/js/default/pages/index/index.hml index d932563366c3610d17bfbd6226c678d7fc6037e8..19e1120750b9efed5bbf2946fe80eadb2882839f 100644 --- a/common/DistributeCalc/entry/src/main/js/default/pages/index/index.hml +++ b/common/DistributeCalc/entry/src/main/js/default/pages/index/index.hml @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. --> -
+