diff --git a/ArkUI/entry/src/main/ets/pages/EnterProhibitedPromptPlanOne.ets b/ArkUI/entry/src/main/ets/pages/EnterProhibitedPromptPlanOne.ets new file mode 100644 index 0000000000000000000000000000000000000000..a2e26d3159b05b5c60c7d86d5279e257f0ccc618 --- /dev/null +++ b/ArkUI/entry/src/main/ets/pages/EnterProhibitedPromptPlanOne.ets @@ -0,0 +1,48 @@ +/* +* 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: TextInput、TextArea等组件如何禁止提示拍摄输入 +*/ + +// [Start enter_prohibited_prompt_plan_one] +@Entry +@Component +struct TextAreaExample { + @State text: string = 'TextArea editMenuOptions'; + + onCreateMenu(menuItems: Array) { + menuItems = menuItems.filter((item) => item.content !== '拍照输入'); // 也可以选择禁止全选等其他菜单选项 + return menuItems; + } + + build() { + Column() { + TextArea({ text: this.text }) + .width('95%') + .height(56) + .editMenuOptions({ + onCreateMenu: this.onCreateMenu, + onMenuItemClick: (menuItem: TextMenuItem, textRange: TextRange) => { + return false; // 返回为false,先执行自定义逻辑,再执行系统逻辑 + } + }) + .margin({ top: 100 }) + } + .width('90%') + .margin('5%') + } +} +// [End enter_prohibited_prompt_plan_one] \ No newline at end of file diff --git a/ArkUI/entry/src/main/ets/pages/EnterProhibitedPromptPlanTwo.ets b/ArkUI/entry/src/main/ets/pages/EnterProhibitedPromptPlanTwo.ets new file mode 100644 index 0000000000000000000000000000000000000000..895eba40a3f52ad17fdc068e98c2e31b31e2645d --- /dev/null +++ b/ArkUI/entry/src/main/ets/pages/EnterProhibitedPromptPlanTwo.ets @@ -0,0 +1,45 @@ +/* +* 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: TextInput、TextArea等组件如何禁止提示拍摄输入 +*/ + +// [Start enter_prohibited_prompt_plan_two] +@Entry +@Component +struct Index { + @State message: string = ''; + + build() { + Column() { + Text(`输入的内容:${this.message}`) + .margin({ + top: 100, + bottom: 30 + }) + TextInput({ placeholder: '请输入内容' }) + .borderRadius(0) + .onChange((value: string) => { + this.message = value; + }) + .selectionMenuHidden(true) + } + .width('100%') + .height('100%') + } +} + +// [End enter_prohibited_prompt_plan_two] \ No newline at end of file diff --git a/ArkUI/entry/src/main/ets/pages/TabsLazyLoading.ets b/ArkUI/entry/src/main/ets/pages/TabsLazyLoading.ets new file mode 100644 index 0000000000000000000000000000000000000000..0db3c3c54c86e59bdfc9c4e999abb619bc48ca2f --- /dev/null +++ b/ArkUI/entry/src/main/ets/pages/TabsLazyLoading.ets @@ -0,0 +1,127 @@ +/* +* 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组件懒加载的问题,应该怎么解决 +*/ + +// [Start tabs_lazy_loading] +class MyDataSource implements IDataSource { + private list: number[] = []; + + constructor(list: number[]) { + this.list = list; + } + + totalCount(): number { + return this.list.length; + } + + getData(index: number): number { + return this.list[index]; + } + + registerDataChangeListener(listener: DataChangeListener): void { + // ... + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + // ... + } +} + +@Entry +@Component +struct TabsSwiperExample { + @State fontColor: string = '#182431'; + @State selectedFontColor: string = '#007DFF'; + @State currentIndex: number = 0; + private list: number[] = []; + private tabsController: TabsController = new TabsController(); + private swiperController: SwiperController = new SwiperController(); + private swiperData: MyDataSource = new MyDataSource([]); + + aboutToAppear(): void { + for (let i = 0; i <= 9; i++) { + this.list.push(i); + } + this.swiperData = new MyDataSource(this.list); + } + + @Builder + tabBuilder(index: number, name: string) { + Column() { + Text(name) + .fontColor(this.currentIndex === index ? this.selectedFontColor : this.fontColor) + .fontSize(16) + .fontWeight(this.currentIndex === index ? 500 : 400) + .lineHeight(22) + .margin({ + top: 17, + bottom: 7 + }) + Divider() + .strokeWidth(2) + .color('#007DFF') + .opacity(this.currentIndex === index ? 1 : 0) + } + .width('20%') + } + + build() { + Column() { + Tabs({ barPosition: BarPosition.Start, controller: this.tabsController }) { + ForEach(this.list, (item: number) => { + TabContent().tabBar(this.tabBuilder(item, '页签' + this.list[item])) + }) + } + .onTabBarClick((index: number) => { + this.currentIndex = index; + this.swiperController.changeIndex(index, true); + }) + .barMode(BarMode.Scrollable) + .backgroundColor('#F1F3F5') + .height(56) + .width('100%') + + Swiper(this.swiperController) { + LazyForEach(this.swiperData, (item: string) => { + Text(item.toString()) + .onAppear(() => { + console.info('onAppear ' + item.toString()); + }) + .onDisAppear(() => { + console.info('onDisAppear ' + item.toString()); + }) + .width('100%') + .height('100%') + .backgroundColor(0xAFEEEE) + .textAlign(TextAlign.Center) + .fontSize(30) + }, (item: string) => item) + } + .loop(true) + .onChange((index: number) => { + this.currentIndex = index; + }) + .onAnimationStart((index: number, targetIndex: number, extraInfo: SwiperAnimationEvent) => { + this.currentIndex = targetIndex; + this.tabsController.changeIndex(targetIndex); + }) + } + } +} + +// [End tabs_lazy_loading] \ No newline at end of file