diff --git a/entry/src/main/config.json b/entry/src/main/config.json index 33e946daff4dacfc891eeb3fff2ba8a7e9726db0..f4aa79a245d383e6aa5f2761113dc8ca31ed42cf 100644 --- a/entry/src/main/config.json +++ b/entry/src/main/config.json @@ -39,26 +39,6 @@ "label": "$string:app_name", "type": "page", "launchType": "standard" - }, - { - - "orientation": "portrait", - "icon": "$media:icon", - "name": "com.stx.xhb.customwaterview.JsForestAbility", - "description": "", - "type": "page" - } - ], - "js": [ - { - "pages": [ - "pages/index/index" - ], - "name": "default", - "window": { - "designWidth": 720, - "autoDesignWidth": false - } } ] } diff --git a/entry/src/main/java/com/stx/xhb/customwaterview/JsForestAbility.java b/entry/src/main/java/com/stx/xhb/customwaterview/JsForestAbility.java deleted file mode 100644 index e84668a98876d5e698a86813f81185a7eb6e9bd5..0000000000000000000000000000000000000000 --- a/entry/src/main/java/com/stx/xhb/customwaterview/JsForestAbility.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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. - */ - -package com.stx.xhb.customwaterview; - -import ohos.aafwk.content.Intent; -import ohos.ace.ability.AceAbility; - -/** - * JS版蚂蚁森林demo 容器页 - * - * @since 2021-06-08 - */ -public class JsForestAbility extends AceAbility { - @Override - public void onStart(Intent intent) { - super.onStart(intent); - } - - @Override - public void onStop() { - super.onStop(); - } -} diff --git a/entry/src/main/java/com/stx/xhb/customwaterview/MainAbility.java b/entry/src/main/java/com/stx/xhb/customwaterview/MainAbility.java index 4d7c947ed65fb137afa247229f3747defd93fd38..b93d398065301e6c54b8f90e90beb59ee093b73a 100644 --- a/entry/src/main/java/com/stx/xhb/customwaterview/MainAbility.java +++ b/entry/src/main/java/com/stx/xhb/customwaterview/MainAbility.java @@ -15,7 +15,7 @@ package com.stx.xhb.customwaterview; -import com.stx.xhb.customwaterview.slice.MainAbilitySlice; +import com.stx.xhb.customwaterview.slice.ForestAbilitySlice; import ohos.aafwk.ability.Ability; import ohos.aafwk.content.Intent; @@ -28,6 +28,6 @@ public class MainAbility extends Ability { @Override public void onStart(Intent intent) { super.onStart(intent); - super.setMainRoute(MainAbilitySlice.class.getName()); + super.setMainRoute(ForestAbilitySlice.class.getName()); } } diff --git a/entry/src/main/java/com/stx/xhb/customwaterview/slice/MainAbilitySlice.java b/entry/src/main/java/com/stx/xhb/customwaterview/slice/MainAbilitySlice.java deleted file mode 100644 index f293e46c891831a07bd579fa1e737405243ff206..0000000000000000000000000000000000000000 --- a/entry/src/main/java/com/stx/xhb/customwaterview/slice/MainAbilitySlice.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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. - */ - -package com.stx.xhb.customwaterview.slice; - -import com.stx.xhb.customwaterview.JsForestAbility; -import com.stx.xhb.customwaterview.ResourceTable; -import ohos.aafwk.ability.AbilitySlice; -import ohos.aafwk.content.Intent; -import ohos.aafwk.content.Operation; -import ohos.agp.components.Component; - -/** - * 入口页 - * - * @since 2021-06-08 - */ -public class MainAbilitySlice extends AbilitySlice { - @Override - public void onStart(Intent intent) { - super.onStart(intent); - super.setUIContent(ResourceTable.Layout_ability_main); - } - - @Override - public void onActive() { - super.onActive(); - findComponentById(ResourceTable.Id_btnJava).setClickedListener(new Component.ClickedListener() { - @Override - public void onClick(Component component) { - present(new ForestAbilitySlice(), new Intent()); - } - }); - findComponentById(ResourceTable.Id_btnJS).setClickedListener(new Component.ClickedListener() { - @Override - public void onClick(Component component) { - Intent intent = new Intent(); - Operation operation = new Intent.OperationBuilder() - .withBundleName(getBundleName()) - .withAbilityName(JsForestAbility.class.getName()) - .build(); - intent.setOperation(operation); - startAbility(intent); - } - }); - } -} diff --git a/entry/src/main/js/default/app.js b/entry/src/main/js/default/app.js deleted file mode 100644 index cd08a9b22f02851dd42e2c194100fa7bad092a1d..0000000000000000000000000000000000000000 --- a/entry/src/main/js/default/app.js +++ /dev/null @@ -1,23 +0,0 @@ -/* - * 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/entry/src/main/js/default/common/bg.jpg b/entry/src/main/js/default/common/bg.jpg deleted file mode 100644 index f73919aa8ce5acc2f25c824b71a5570b06b47f32..0000000000000000000000000000000000000000 Binary files a/entry/src/main/js/default/common/bg.jpg and /dev/null differ diff --git a/entry/src/main/js/default/common/component/waterflake/waterFlake.css b/entry/src/main/js/default/common/component/waterflake/waterFlake.css deleted file mode 100644 index bc404bea43b6c2176e89541d7816241e2914d428..0000000000000000000000000000000000000000 --- a/entry/src/main/js/default/common/component/waterflake/waterFlake.css +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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. - */ - -.main_contain { - width: 100%; - position: relative; -} - -.ball { - width: 100px; - height: 100px; - background-color: #c3f593; - background-size: 100%; - border-radius: 60px; - border: #69c78e; - border-bottom-style: solid; - border-width: 1px; - position: absolute; - text-align: center; -/* animation-name: Wave;*/ -/* animation-duration: 2s;*/ -/* animation-fill-mode: forwards;*/ -/* animation-iteration-count: infinite;*/ -} - -@keyframes Wave { - from { - transform: translateY(0px); - } - - to { - transform: translateY(10px); - } -} \ No newline at end of file diff --git a/entry/src/main/js/default/common/component/waterflake/waterFlake.hml b/entry/src/main/js/default/common/component/waterflake/waterFlake.hml deleted file mode 100644 index 0e4c7d4185e61f679d90a8bca8dc3bcaeedd5d84..0000000000000000000000000000000000000000 --- a/entry/src/main/js/default/common/component/waterflake/waterFlake.hml +++ /dev/null @@ -1,11 +0,0 @@ -
- {{ $item.content }} - -
diff --git a/entry/src/main/js/default/common/component/waterflake/waterFlake.js b/entry/src/main/js/default/common/component/waterflake/waterFlake.js deleted file mode 100644 index 63c0d0b750c7d0091189a372d1d6299cc511f5b5..0000000000000000000000000000000000000000 --- a/entry/src/main/js/default/common/component/waterflake/waterFlake.js +++ /dev/null @@ -1,222 +0,0 @@ -/* - * 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 { - props: { - //后台返回的小球信息 - ballList: { - default: [10, 11, 12, 13, 14], - }, - // 收集能量动画结束的X坐标 - collDestinationX: { - default: 0 - }, - // 收集能量动画结束的Y坐标 - collDestinationY: { - default: 600 - } - }, - data() { - return { - /** - * ballDataList的每个对象包括以下属性: - * content(小球显示的文本信息) - * x(横坐标)、 - * y(纵坐标)、 - */ - ballDataList: [], - collectionAnimation: null, - isCollect: false // 是否正在执行收集能量动画 - }; - }, - onInit() { - this.$watch('ballList', 'onBallListChange'); //注册数据变化监听 - }, - onReady() { - this.initData() - }, - initData() { - if (this.collectionAnimation != null) { - this.collectionAnimation.cancel() - } - setTimeout(() => { - let width = 720 //组件的款第 - let height = 600 //组件的高度 - // 生成小球的x坐标数组 - let xRandom = this.randomCommon(1, 8, this.ballList.length) - if (xRandom == null) { - return - } - let all_x = xRandom.map(item => { - return item * width * 0.10 - }); - //生成小球的y坐标数组 - let yRandom = this.randomCommon(1, 8, this.ballList.length); - if (yRandom == null) { - return - } - let all_y = yRandom.map(item => { - return item * height * 0.08 - }) - let dataList = [] - for (let index = 0; index < this.ballList.length; index++) { - dataList.push({ - content: this.ballList[index] + 'g', - x: all_x[index], - y: all_y[index] - }) - } - this.ballDataList = dataList; // 触发视图更新 - console.info('onReady ballDataList = ' + JSON.stringify(this.ballDataList)); - - this.playShakeAnimate() // 开始执行抖动动画 - }, 50) - }, - onBallClick(index, item) { - console.info('onBallClick index = ' + index); - console.info('onBallClick item = ' + JSON.stringify(item)); - if (this.isCollect || item.isCollected) { // 正在执行收集动画或者是已经被回收的 - return - } - this.$emit('ballClick', item); - let el = this.$element(`ball${index}`) - this.playCollectionAnimate(el, index) - }, - /** - * 执行收集的动画 - * @param el - * @param index - * @return - */ - playCollectionAnimate(el, index) { - if (this.isCollect) { // 正在执行收集动画则直接return - return - } - var options = { - duration: 1500, - easing: 'ease-in-out', - fill: 'forwards', - }; - let offsetX = this.collDestinationX - this.ballDataList[index].x - let offsetY = this.collDestinationY - this.ballDataList[index].y - var frames = [ - { - transform: { - translate: '0px 0px' - }, - opacity: 1 - }, - { - transform: { - translate: `${offsetX}px ${offsetY}px` - }, - opacity: 0 - } - ]; - let _t = this - _t.collectionAnimation = el.animate(frames, options); - _t.collectionAnimation.onfinish = function () { - console.info('onBallClick collection animation onFinish'); - _t.isCollect = false; - _t.ballDataList[index].isCollected = true - console.info('xwg1: ' + JSON.stringify(_t.ballDataList)); - }; - _t.collectionAnimation.oncancel = function () { - console.info('xwg1: collectionAnimation oncancel'); - _t.isCollect = false; - } - this.isCollect = true - _t.collectionAnimation.play() - }, - createShakeAnimate(el) { - if (el == undefined) { - return - } - var options = { - duration: 2000, - easing: 'friction', - fill: 'forwards', - iterations: "Infinity", - }; - var frames = [ - { - transform: { - translate: '0px 0px' - }, - offset: 0.0 - }, - { - transform: { - translate: '0px 20px' - }, - offset: 0.5 - }, - { - transform: { - translate: '0px 0px' - }, - offset: 1.0 - }, - - ]; - let animation = el.animate(frames, options); - return animation - }, - playShakeAnimate() { - setTimeout(() => { - console.info('xwg playShakeAnimate '); - for (var index = 0; index < this.ballDataList.length; index++) { - let el = this.$element(`ball${index}`) - let animate = this.createShakeAnimate(el) - animate.play() - } - }, 50) - }, - /** - * 随机指定范围内N个不重复的数 - * 最简单最基本的方法 - * - * @param min 指定范围最小值 - * @param max 指定范围最大值 - * @param n 随机数个数 - * @return 随机数列表 - */ - randomCommon(min, max, n) { - if (n > (max - min + 1) || max < min) { - return null; - } - let result = []; - let count = 0; - while (count < n) { - let num = parseInt((Math.random() * (max - min)) + min); - let flag = true; - for (let j = 0; j < n; j++) { - if (num == result[j]) { - flag = false; - break; - } - } - if (flag) { - result[count] = num; - count++; - } - } - return result; - }, - onBallListChange(newV) { // 外部数据发生变化 重新渲染组件 - console.log('onBallListChange newV = ' + JSON.stringify(newV)) - this.initData() - } -} diff --git a/entry/src/main/js/default/i18n/en-US.json b/entry/src/main/js/default/i18n/en-US.json deleted file mode 100644 index e63c70d978a3a53be988388c87182f81785e170c..0000000000000000000000000000000000000000 --- a/entry/src/main/js/default/i18n/en-US.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "strings": { - "hello": "Hello", - "world": "World" - } -} \ No newline at end of file diff --git a/entry/src/main/js/default/i18n/zh-CN.json b/entry/src/main/js/default/i18n/zh-CN.json deleted file mode 100644 index de6ee5748322f44942c1b003319d8e66c837675f..0000000000000000000000000000000000000000 --- a/entry/src/main/js/default/i18n/zh-CN.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "strings": { - "hello": "您好", - "world": "世界" - } -} \ No newline at end of file diff --git a/entry/src/main/js/default/pages/index/index.css b/entry/src/main/js/default/pages/index/index.css deleted file mode 100644 index 194a38add98aad85faf308f9516a9f5c61e698ea..0000000000000000000000000000000000000000 --- a/entry/src/main/js/default/pages/index/index.css +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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: flex-start; -} - -.title { - font-size: 100px; -} - -.forestContainer { - width: 100%; - height: 750px; - background-image: url("/common/bg.jpg"); - background-size: 100%; - background-repeat: no-repeat; -} \ No newline at end of file diff --git a/entry/src/main/js/default/pages/index/index.hml b/entry/src/main/js/default/pages/index/index.hml deleted file mode 100644 index 4e2a17392d008906690205880f0ae4d521c58eb8..0000000000000000000000000000000000000000 --- a/entry/src/main/js/default/pages/index/index.hml +++ /dev/null @@ -1,10 +0,0 @@ - -
-
- -
- - -
diff --git a/entry/src/main/js/default/pages/index/index.js b/entry/src/main/js/default/pages/index/index.js deleted file mode 100644 index 473974684c6d750648accefc11318ffedee578c3..0000000000000000000000000000000000000000 --- a/entry/src/main/js/default/pages/index/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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'; -export default { - data() { - return { - ballList: [] - } - }, - onInit() { - - this.ballList = this.genRandomArray(5); - }, - onBallClick(info) { - console.info('xwg parent onBallClick item = ' + JSON.stringify(info.detail)); - let content = info.detail.content - prompt.showToast({message:`点击了${content}`,duration:1500}) - }, - reset() { - console.info("xwg reset clicked ") - this.ballList = this.genRandomArray(6); - console.info("xwg reset ballList = " + JSON.stringify(this.ballList)) - }, - genRandomArray(count) { - let ballArray = [] - for (var index = 0; index < count; index++) { - let v = this.random(1, 60) - ballArray.push(parseInt(v)) - } - return ballArray - }, - random(min, max) { - return Math.floor(Math.random() * (max - min)) + min; - } -}