From 00bbfd4aada69654d294e0a9b82f7c925973425e Mon Sep 17 00:00:00 2001 From: liugang9704 <2745340733@qq.com> Date: Tue, 23 Sep 2025 11:16:10 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9EFAQ=E5=90=8C=E6=BA=90?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ets/pages/CompatibleCrownExampleOne.ets | 53 +++++++ .../ets/pages/CompatibleCrownExampleThree.ets | 72 ++++++++++ .../ets/pages/CompatibleCrownExampleTwo.ets | 54 ++++++++ .../pages/SwiperLoadsMassiveAmountsOfData.ets | 35 +++++ .../main/ets/pages/TabsLinkageAbnormal.ets | 129 ++++++++++++++++++ 5 files changed, 343 insertions(+) create mode 100644 ArkUI/entry/src/main/ets/pages/CompatibleCrownExampleOne.ets create mode 100644 ArkUI/entry/src/main/ets/pages/CompatibleCrownExampleThree.ets create mode 100644 ArkUI/entry/src/main/ets/pages/CompatibleCrownExampleTwo.ets create mode 100644 ArkUI/entry/src/main/ets/pages/SwiperLoadsMassiveAmountsOfData.ets create mode 100644 ArkUI/entry/src/main/ets/pages/TabsLinkageAbnormal.ets diff --git a/ArkUI/entry/src/main/ets/pages/CompatibleCrownExampleOne.ets b/ArkUI/entry/src/main/ets/pages/CompatibleCrownExampleOne.ets new file mode 100644 index 0000000..9178362 --- /dev/null +++ b/ArkUI/entry/src/main/ets/pages/CompatibleCrownExampleOne.ets @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2024 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. +*/ + +/* +* FAQ: arcSwiper如何适配表冠 +*/ + +// [Start compatible_crown_example_one] +@Entry +@Component +struct Index { + private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; + + build() { + Column() { + List({ space: 20, initialIndex: 0 }) { + ForEach(this.arr, (item: number) => { + ListItem() { + Button('' + item) + .width('100%') + .height(100) + .fontSize(16) + } + .onClick(() => { + }) + }, (item: string) => item) + } + .focusable(true) + .defaultFocus(true) + .focusOnTouch(true) // After the list component is focused, it can respond to the sliding control of the rotating crown + .width('90%') + .height('100%') + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5 }) + } +} + +// [End compatible_crown_example_one] \ No newline at end of file diff --git a/ArkUI/entry/src/main/ets/pages/CompatibleCrownExampleThree.ets b/ArkUI/entry/src/main/ets/pages/CompatibleCrownExampleThree.ets new file mode 100644 index 0000000..ac92286 --- /dev/null +++ b/ArkUI/entry/src/main/ets/pages/CompatibleCrownExampleThree.ets @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 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. +*/ + +/* +* FAQ: arcSwiper如何适配表冠 +*/ + +// [Start compatible_crown_example_three] +@Entry +@Component +struct Index { + private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; + @State isLoading: boolean = true; + + onPageShow(): void { + setTimeout(() => { + this.isLoading = false; + }, 3000) + } + + build() { + Column() { + if (this.isLoading) { + Text('数据加载中') + } else { + List({ space: 20, initialIndex: 0 }) { + ForEach(this.arr, (item: number) => { + ListItem() { + Button('' + item) + .width('100%') + .height(100) + .fontSize(16) + } + .onClick(() => { + }) + }, (item: string) => item) + } + .onAppear(() => { + try { + this.getUIContext().getFocusController().requestFocus('test'); + } catch (error) { + console.error('requestFocus failed code is ' + error.code + 'message is ' + error.message); + } + }) + .id('test') + .focusable(true) + .defaultFocus(true) + .focusOnTouch(true) // After the list component is focused, it can respond to the sliding control of the rotating crown + .width('90%') + .height('100%') + } + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5 }) + } +} + +// [End compatible_crown_example_three] \ No newline at end of file diff --git a/ArkUI/entry/src/main/ets/pages/CompatibleCrownExampleTwo.ets b/ArkUI/entry/src/main/ets/pages/CompatibleCrownExampleTwo.ets new file mode 100644 index 0000000..bd3e6fc --- /dev/null +++ b/ArkUI/entry/src/main/ets/pages/CompatibleCrownExampleTwo.ets @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2024 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. +*/ + +/* +* FAQ: arcSwiper如何适配表冠 +*/ + +// [Start compatible_crown_example_two] +@Entry +@Component +struct CityList { + @State message: string = 'onDigitalCrown'; + + build() { + Column() { + Row() { + Stack() { + Text(this.message) + .fontSize(20) + .fontColor(Color.White) + .backgroundColor('#262626') + .textAlign(TextAlign.Center) + .focusable(true) + .focusOnTouch(true) + .defaultFocus(true) + .borderWidth(2) + .width(223) + .height(223) + .borderRadius(110) + .onDigitalCrown((event: CrownEvent) => { + event.stopPropagation(); + this.message = 'CrownEvent\n\n' + JSON.stringify(event); + console.debug('action:%d, angularVelocity:%f,degree:%f,timestamp:%f', event.action, event.angularVelocity, + event.degree, event.timestamp); + }) + } + } + } + } +} + +// [End compatible_crown_example_two] \ No newline at end of file diff --git a/ArkUI/entry/src/main/ets/pages/SwiperLoadsMassiveAmountsOfData.ets b/ArkUI/entry/src/main/ets/pages/SwiperLoadsMassiveAmountsOfData.ets new file mode 100644 index 0000000..83d70e9 --- /dev/null +++ b/ArkUI/entry/src/main/ets/pages/SwiperLoadsMassiveAmountsOfData.ets @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2024 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. +*/ + +/* +* FAQ:Swiper如何高效加载海量数据场景示例 +*/ + +// [Start swiper_loads_massive_amounts_of_data] +@Entry +@Component +struct Index { + private swiperController: SwiperController = new SwiperController(); + + build() { + Column() { + Swiper(this.swiperController) { + // NormalMarketView() + } + } + } +} + +// [End swiper_loads_massive_amounts_of_data] \ No newline at end of file diff --git a/ArkUI/entry/src/main/ets/pages/TabsLinkageAbnormal.ets b/ArkUI/entry/src/main/ets/pages/TabsLinkageAbnormal.ets new file mode 100644 index 0000000..69ee369 --- /dev/null +++ b/ArkUI/entry/src/main/ets/pages/TabsLinkageAbnormal.ets @@ -0,0 +1,129 @@ +/* +* Copyright (c) 2024 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. +*/ + +/* +* FAQ:Tabs组件子组件包含if节点,if条件变更后,tabBar页签联动异常,有没有解决方案 +*/ + +// [Start tabs_linkage_abnormal] +@Entry +@Component +struct Index { + private currentIndex: number = 0; + private controller: TabsController = new TabsController(); + @State change: boolean = true; + + @Builder + tabBuilder(index: number, name: string) { + RelativeContainer() { + Text(name) + .fontColor(this.currentIndex === index ? '#007DFF' : '#182431') + .fontSize(16) + .fontWeight(this.currentIndex === index ? 500 : 400) + .height('auto') + .padding({ + left: 8, + right: 8, + top: 6, + bottom: 6 + }) + .id('textTitle') + .alignRules({ + middle: { anchor: '__container__', align: HorizontalAlign.Center }, + center: { anchor: '__container__', align: VerticalAlign.Center } + }) + Divider() + .strokeWidth(1) + .color('#C3C3C3') + .width(100) + .alignRules({ bottom: { anchor: '__container__', align: VerticalAlign.Bottom } }) + Divider() + .strokeWidth(2) + .color('#007DFF') + .opacity(this.currentIndex === index ? 1 : 0) + .width(100) + .alignRules({ bottom: { anchor: '__container__', align: VerticalAlign.Bottom } }) + } + .width(100) + .backgroundColor('#F0F1F3') + } + + build() { + RelativeContainer() { + Tabs({ barPosition: BarPosition.Start, index: this.currentIndex, controller: this.controller }) { + TabContent() { + Text('Page One') + } + .tabBar(this.tabBuilder(0, 'Page One')) + .backgroundColor('#ffa2051d') + + TabContent() { + Text('Page Two, Click on Page Three to show or hide') + .onClick(() => { + this.change = !this.change; + }) + } + .tabBar(this.tabBuilder(1, 'Page Two')) + .backgroundColor('#ffefd005') + + if (this.change) { + TabContent() { + Text('Page Three') + } + .tabBar(this.tabBuilder(2, 'Page Three')) + .backgroundColor('#ff061ef8') + + TabContent() { + Text('Page Four') + } + .tabBar(this.tabBuilder(3, 'Page Four')) + .backgroundColor('#ff039105') + + TabContent() { + Text('Page Five') + } + .tabBar(this.tabBuilder(4, 'Page Five')) + .backgroundColor('#ff02e7c4') + } + // When the page is hidden, it is necessary to ensure that the first parameter Index of the TabContent page is continuous + else { + TabContent() { + Text('Page Four') + } + .tabBar(this.tabBuilder(2, 'Page Four')) + .backgroundColor('#ff039105') + + TabContent() { + Text('Page Five') + } + .tabBar(this.tabBuilder(3, 'Page Five')) + .backgroundColor('#ff02e7c4') + } + } + .barMode(BarMode.Scrollable) + .barBackgroundColor('#fff3f3f3') + .onChange((index) => { + this.currentIndex = index; + }) + .animationDuration(400) + .scrollable(true) + .vertical(false) + .width('100%') + .fadingEdge(false) + } + } +} + +// [End tabs_linkage_abnormal] \ No newline at end of file -- Gitee