diff --git a/UI/AtomicLayout/README.md b/UI/AtomicLayout/README.md new file mode 100644 index 0000000000000000000000000000000000000000..948ae597c692f1cb0affce6dbb71b358920fabae --- /dev/null +++ b/UI/AtomicLayout/README.md @@ -0,0 +1,23 @@ +# AtomicLayout + +### Introduction + +This sample illustrates style attributes related to layout effect adaptation, including the hiding feature, proportion feature, and fixed ratio. + +With the hiding feature, you can adjust the display priority of components in a container in the horizontal or vertical direction. + +With the proportion feature, you can adjust the proportion of each component in a container so that each of them is always arranged in a proportional space of the container. + +You can scale up or down a component with fixed ratio while retaining its aspect ratio. + +### Usage + +In this sample, there are three buttons on the home screen. You can click them to display the corresponding screen. + +On the feature display screen, the rectangle in light yellow is a container, and it accommodates three components: A, B, and C. You can click the buttons to change the size of the components and display them in different ways. + +### Constraints + +- The hiding and proportion features must be used in a flex layout that does not support cross-row display. +- This sample can only be run on mini-system devices. + diff --git a/UI/AtomicLayout/README_zh.md b/UI/AtomicLayout/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..fb0a13b04ddbb13a8d1a3c8d190581be3c81e2f9 --- /dev/null +++ b/UI/AtomicLayout/README_zh.md @@ -0,0 +1,23 @@ +# 原子布局 + +### 简介 + +本示例展示了布局效果自适应的相关样式属性,包括隐藏能力、占比能力和固定比例。 + +隐藏能力:可以调整组件内元素水平/垂直方向的显示优先级。 + +占比能力:可以调整指定元素始终在容器的某一比例空间中进行布局。 + +固定比例:可以以固定的比例调整组件的宽高尺寸。 + +### 使用说明 + +本示例主界面为三个按钮,点击后在新页面分别展示。 + +在能力展示页面中,浅黄色背景为父容器,A、B、C为其中三个子元素,点击按钮可改变子容器大小,子元素显示会随之改变。 + +### 约束与限制 + +- 隐藏能力与占比能力需在非折行的flex布局中使用。 +- 本示例支持在轻量系统使用。 + diff --git a/UI/AtomicLayout/build.gradle b/UI/AtomicLayout/build.gradle new file mode 100644 index 0000000000000000000000000000000000000000..ad33f7c014a76f9b635c1e497c19e278f2aef9da --- /dev/null +++ b/UI/AtomicLayout/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/AtomicLayout/entry/build.gradle b/UI/AtomicLayout/entry/build.gradle new file mode 100644 index 0000000000000000000000000000000000000000..88e1fd7d4aad2df8c0b60bc3fd818690ace968bf --- /dev/null +++ b/UI/AtomicLayout/entry/build.gradle @@ -0,0 +1,16 @@ +apply plugin: 'com.huawei.ohos.hap' +ohos { + compileSdkVersion 6 + defaultConfig { + compatibleSdkVersion 6 + } + buildTypes { + release { + proguardOpt { + proguardEnabled false + rulesFiles 'proguard-rules.pro' + } + } + } + supportSystem "standard" +} \ No newline at end of file diff --git a/UI/AtomicLayout/entry/src/main/config.json b/UI/AtomicLayout/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..bfffc253b1768d7f1117c3e705fc5adfc8567e44 --- /dev/null +++ b/UI/AtomicLayout/entry/src/main/config.json @@ -0,0 +1,61 @@ +{ + "app": { + "bundleName": "ohos.samples.atomiclayout", + "version": { + "code": 1000000, + "name": "1.0" + } + }, + "deviceConfig": {}, + "module": { + "package": "ohos.samples.atomiclayout", + "name": ".MyApplication", + "mainAbility": "ohos.samples.atomiclayout.MainAbility", + "deviceType": [ + "phone", + "tv", + "wearable" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": ".MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "$string:app_name", + "type": "page", + "launchType": "standard" + } + ], + "js": [ + { + "pages": [ + "pages/index/index", + "pages/hide/index", + "pages/percentage/index", + "pages/fixed/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/UI/AtomicLayout/entry/src/main/js/default/app.js b/UI/AtomicLayout/entry/src/main/js/default/app.js new file mode 100644 index 0000000000000000000000000000000000000000..8e47afff13e928a74fdcc01a108e4422404b9ac9 --- /dev/null +++ b/UI/AtomicLayout/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/AtomicLayout/entry/src/main/js/default/i18n/en-US.json b/UI/AtomicLayout/entry/src/main/js/default/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..ac2a096c9233bc155e36211509e7f897eae6ea2c --- /dev/null +++ b/UI/AtomicLayout/entry/src/main/js/default/i18n/en-US.json @@ -0,0 +1,13 @@ +{ + "strings": { + "hide_capabilities": "Hidden capabilities", + "percentage": "Proportion capability", + "fixed_scale": "Fixed scale", + + "displaystyle": "display", + "hidestyle": "hide", + + "refresh": "refresh", + "return": "reset" + } +} \ No newline at end of file diff --git a/UI/AtomicLayout/entry/src/main/js/default/i18n/zh-CN.json b/UI/AtomicLayout/entry/src/main/js/default/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..10e687f9dca70b61e7dfca8af599e5f69b5d5e5b --- /dev/null +++ b/UI/AtomicLayout/entry/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,13 @@ +{ + "strings": { + "hide_capabilities": "隐藏能力", + "percentage": "占比能力", + "fixed_scale": "固定比例", + + "displaystyle": "显示", + "hidestyle": "隐藏", + + "refresh": "刷新", + "return": "重置" + } +} \ No newline at end of file diff --git a/UI/AtomicLayout/entry/src/main/js/default/pages/fixed/index.css b/UI/AtomicLayout/entry/src/main/js/default/pages/fixed/index.css new file mode 100644 index 0000000000000000000000000000000000000000..917c89243b1494182262267f2b68b94f2fb80a23 --- /dev/null +++ b/UI/AtomicLayout/entry/src/main/js/default/pages/fixed/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 { + width: 100%; + height: 100%; + align-items: center; + flex-direction: column; + justify-content: center; +} + +.box { + display: flex; + align-items: center; + flex-direction: column; + background-color: bisque; +} +.btn { + width: 60%; + height: 50px; + font-size: 20px; + margin-top: 20px; + color: #ff00ff7f; +} +.red-box { + width: 150px; + height: 150px; + aspect-ratio: 1; + text-align: center; + background-color: #FF5733; +} \ No newline at end of file diff --git a/UI/AtomicLayout/entry/src/main/js/default/pages/fixed/index.hml b/UI/AtomicLayout/entry/src/main/js/default/pages/fixed/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..ca837c90fae3aec64bb0195a9b6e25fa7e80a18e --- /dev/null +++ b/UI/AtomicLayout/entry/src/main/js/default/pages/fixed/index.hml @@ -0,0 +1,22 @@ + + +
+
+ A +
+ + +
\ No newline at end of file diff --git a/UI/AtomicLayout/entry/src/main/js/default/pages/fixed/index.js b/UI/AtomicLayout/entry/src/main/js/default/pages/fixed/index.js new file mode 100644 index 0000000000000000000000000000000000000000..fb99408e0da9786f7391c7e8018f57677719f73a --- /dev/null +++ b/UI/AtomicLayout/entry/src/main/js/default/pages/fixed/index.js @@ -0,0 +1,30 @@ +/* + * 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{ + data: { + "height": "300px", + "width": "300px" + }, + + onClickReturn() { + this.height = "300px" + this.width = "300px" + }, + onClickRefresh() { + this.height = "100px" + this.width = "200px" + } +} \ No newline at end of file diff --git a/UI/AtomicLayout/entry/src/main/js/default/pages/hide/index.css b/UI/AtomicLayout/entry/src/main/js/default/pages/hide/index.css new file mode 100644 index 0000000000000000000000000000000000000000..f52d61b775f819dc152fd22ed09b851fd0849c56 --- /dev/null +++ b/UI/AtomicLayout/entry/src/main/js/default/pages/hide/index.css @@ -0,0 +1,56 @@ +/* + * 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 { + width: 100%; + height: 100%; + align-items: center; + flex-direction: column; + justify-content: center; +} +.box { + width: 100%; + align-items: center; + flex-direction: column; + background-color: bisque; +} +.btn { + width: 60%; + height: 50px; + font-size: 20px; + margin-top: 20px; + color: #ff00ff7f; +} +.aquamarine-box { + width: 50%; + height: 150px; + display-index: 3; + text-align: center; + background-color: #DAF7A6; +} +.yellow-box { + width: 50%; + height: 150px; + display-index: 2; + text-align: center; + background-color: #FFC300; +} +.red-box { + width: 50%; + height: 150px; + display-index: 1; + text-align: center; + background-color: #FF5733; +} \ No newline at end of file diff --git a/UI/AtomicLayout/entry/src/main/js/default/pages/hide/index.hml b/UI/AtomicLayout/entry/src/main/js/default/pages/hide/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..9bc84b19cc70102bfd4dd4a224df3d6d4e4ab0c6 --- /dev/null +++ b/UI/AtomicLayout/entry/src/main/js/default/pages/hide/index.hml @@ -0,0 +1,24 @@ + + +
+
+ A + B + C +
+ + +
\ No newline at end of file diff --git a/UI/AtomicLayout/entry/src/main/js/default/pages/hide/index.js b/UI/AtomicLayout/entry/src/main/js/default/pages/hide/index.js new file mode 100644 index 0000000000000000000000000000000000000000..42ea8ec7220978a5abdb1edc9354e737ede30967 --- /dev/null +++ b/UI/AtomicLayout/entry/src/main/js/default/pages/hide/index.js @@ -0,0 +1,27 @@ +/* + * 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{ + data: { + height:"200px", + }, + + onClickReturn() { + this.height = "200px" + }, + onClickRefresh() { + this.height = "600px" + } +} \ No newline at end of file diff --git a/UI/AtomicLayout/entry/src/main/js/default/pages/index/index.css b/UI/AtomicLayout/entry/src/main/js/default/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..917d3393f55176d4d30ef10f20450a04c48f057f --- /dev/null +++ b/UI/AtomicLayout/entry/src/main/js/default/pages/index/index.css @@ -0,0 +1,29 @@ +/* + * 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; + justify-content: center; + align-items: center; +} + +.btn { + width: 60%; + height: 50px; + font-size: 20px; + margin-top: 20px; + color: #ff00ff7f; +} + diff --git a/UI/AtomicLayout/entry/src/main/js/default/pages/index/index.hml b/UI/AtomicLayout/entry/src/main/js/default/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..784ee2d7b37fd0ed8b65ed86e246b4fbcca36c4f --- /dev/null +++ b/UI/AtomicLayout/entry/src/main/js/default/pages/index/index.hml @@ -0,0 +1,20 @@ + + +
+ + + +
\ No newline at end of file diff --git a/UI/AtomicLayout/entry/src/main/js/default/pages/index/index.js b/UI/AtomicLayout/entry/src/main/js/default/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..ef24408bd749c01803d429ba17b960e5eed0fa77 --- /dev/null +++ b/UI/AtomicLayout/entry/src/main/js/default/pages/index/index.js @@ -0,0 +1,37 @@ +/* + * 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: { + }, + onClickHidecapabilities() { + router.push({ + uri: "pages/hide/index" + }) + }, + + onClickPercentage() { + router.push({ + uri: "pages/percentage/index" + }) + }, + + onClickFixedscale() { + router.push({ + uri: "pages/fixed/index" + }) + } +} diff --git a/UI/AtomicLayout/entry/src/main/js/default/pages/percentage/index.css b/UI/AtomicLayout/entry/src/main/js/default/pages/percentage/index.css new file mode 100644 index 0000000000000000000000000000000000000000..ba53e8f9746f310702e7ca94f03e77813fc55a34 --- /dev/null +++ b/UI/AtomicLayout/entry/src/main/js/default/pages/percentage/index.css @@ -0,0 +1,56 @@ +/* + * 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 { + width: 100%; + height: 100%; + align-items: center; + justify-content: center; + flex-direction: column; +} +.box { + width: 100%; + align-items: center; + flex-direction: column; + background-color: bisque; +} +.btn { + width: 60%; + height: 50px; + font-size: 20px; + margin-top: 20px; + color: #ff00ff7f; +} +.aquamarine-box { + width: 50%; + height: 10%; + flex-weight: 1; + text-align: center; + background-color: #DAF7A6; +} +.yellow-box { + width: 50%; + height: 10%; + flex-weight: 2; + text-align: center; + background-color: #FFC300; +} +.red-box { + width: 50%; + height: 10%; + flex-weight: 2; + text-align: center; + background-color: #FF5733; +} \ No newline at end of file diff --git a/UI/AtomicLayout/entry/src/main/js/default/pages/percentage/index.hml b/UI/AtomicLayout/entry/src/main/js/default/pages/percentage/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..ac54669c2568bebac89af6a30277401d9fb3dd3b --- /dev/null +++ b/UI/AtomicLayout/entry/src/main/js/default/pages/percentage/index.hml @@ -0,0 +1,24 @@ + + +
+
+ A + B + C +
+ + +
\ No newline at end of file diff --git a/UI/AtomicLayout/entry/src/main/js/default/pages/percentage/index.js b/UI/AtomicLayout/entry/src/main/js/default/pages/percentage/index.js new file mode 100644 index 0000000000000000000000000000000000000000..51dea13a46634496abdb35fb12f8b5238656dfe6 --- /dev/null +++ b/UI/AtomicLayout/entry/src/main/js/default/pages/percentage/index.js @@ -0,0 +1,27 @@ +/* + * 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{ + data: { + height:"200px", + }, + + onClickReturn() { + this.height = "200px" + }, + onClickRefresh() { + this.height = "500px" + } +} \ No newline at end of file diff --git a/UI/AtomicLayout/entry/src/main/resources/base/element/string.json b/UI/AtomicLayout/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..823b52104ab106bbc27d9d243d7297dd1868beaf --- /dev/null +++ b/UI/AtomicLayout/entry/src/main/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "AtomicLayout" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + } + ] +} \ No newline at end of file diff --git a/UI/AtomicLayout/entry/src/main/resources/base/media/icon.png b/UI/AtomicLayout/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/UI/AtomicLayout/entry/src/main/resources/base/media/icon.png differ diff --git a/UI/AtomicLayout/screenshots/device/button.png b/UI/AtomicLayout/screenshots/device/button.png new file mode 100644 index 0000000000000000000000000000000000000000..0f97414cd62dc66b5e27458b9fbbf4123e4a231c Binary files /dev/null and b/UI/AtomicLayout/screenshots/device/button.png differ diff --git a/UI/AtomicLayout/screenshots/device/fixed.png b/UI/AtomicLayout/screenshots/device/fixed.png new file mode 100644 index 0000000000000000000000000000000000000000..1808e6430654af959d93b38ddc9c36cd6f60a536 Binary files /dev/null and b/UI/AtomicLayout/screenshots/device/fixed.png differ diff --git a/UI/AtomicLayout/screenshots/device/hide.png b/UI/AtomicLayout/screenshots/device/hide.png new file mode 100644 index 0000000000000000000000000000000000000000..7bd8a31f19cf6b9282e853b0dcd2cf4ce7b6345b Binary files /dev/null and b/UI/AtomicLayout/screenshots/device/hide.png differ diff --git a/UI/AtomicLayout/screenshots/device/percentage.png b/UI/AtomicLayout/screenshots/device/percentage.png new file mode 100644 index 0000000000000000000000000000000000000000..a429566c945fab249a8bde9ed0b5eb83d72579cd Binary files /dev/null and b/UI/AtomicLayout/screenshots/device/percentage.png differ diff --git a/UI/AtomicLayout/settings.gradle b/UI/AtomicLayout/settings.gradle new file mode 100644 index 0000000000000000000000000000000000000000..848717efd35171fb6854d82aca81b430f10f4cae --- /dev/null +++ b/UI/AtomicLayout/settings.gradle @@ -0,0 +1,16 @@ +/* + * 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. + */ + +include ':entry'