From d10694cf1dd337c25c151cb340a4756b2ed99145 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=BF=9E=E6=BC=AA?= Date: Tue, 15 Apr 2025 22:19:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=8A=E5=B1=8F=E5=B5=8C=E5=85=A5=E5=BC=8F?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E9=80=82=E9=85=8D=E6=97=A0=E9=9A=9C=E7=A2=8D?= =?UTF-8?q?=E9=98=85=E8=AF=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 连漪 --- customappbar/interfaces/custom_app_bar.js | 32 ++++++++++++++++++----- customappbar/source/custom_app_bar.ets | 25 +++++++++++------- 2 files changed, 40 insertions(+), 17 deletions(-) diff --git a/customappbar/interfaces/custom_app_bar.js b/customappbar/interfaces/custom_app_bar.js index 2cdc46f..474c802 100644 --- a/customappbar/interfaces/custom_app_bar.js +++ b/customappbar/interfaces/custom_app_bar.js @@ -71,6 +71,7 @@ const EVENT_NAME_CUSTOM_APP_BAR_CREATE_SERVICE_PANEL = 'arkui_custom_app_bar_cre const ARKUI_APP_BAR_SERVICE_PANEL = 'arkui_app_bar_service_panel'; const ARKUI_APP_BAR_CLOSE = 'arkui_app_bar_close'; const ARKUI_APP_BAR_PROVIDE_SERVICE = 'arkui_app_bar_provide_service'; +const ARKUI_APP_BAR_MAXIMIZE = 'arkui_app_bar_maximize'; /** * 适配不同颜色模式集合 @@ -138,6 +139,7 @@ export class CustomAppBar extends ViewPU { this.__breakPoint = new ObservedPropertySimplePU(BreakPointsType.NONE, this, 'breakPoint'); this.__serviceMenuRead = new ObservedPropertySimplePU(this.getStringByResourceToken(ARKUI_APP_BAR_SERVICE_PANEL), this, 'serviceMenuRead'); this.__closeRead = new ObservedPropertySimplePU(this.getStringByResourceToken(ARKUI_APP_BAR_CLOSE), this, 'closeRead'); + this.__maximizeRead = new ObservedPropertySimplePU(this.getStringByResourceToken(ARKUI_APP_BAR_MAXIMIZE), this, 'maximizeRead'); this.__provideService = new ObservedPropertySimplePU('', this, 'provideService'); this.__labelName = new ObservedPropertySimplePU('', this, 'labelName'); this.isHalfToFullScreen = false; @@ -246,6 +248,9 @@ export class CustomAppBar extends ViewPU { if (params.closeRead !== undefined) { this.closeRead = params.closeRead; } + if (params.maximizeRead !== undefined) { + this.maximizeRead = params.maximizeRead; + } if (params.provideService !== undefined) { this.provideService = params.provideService; } @@ -319,6 +324,7 @@ export class CustomAppBar extends ViewPU { this.__breakPoint.purgeDependencyOnElmtId(rmElmtId); this.__serviceMenuRead.purgeDependencyOnElmtId(rmElmtId); this.__closeRead.purgeDependencyOnElmtId(rmElmtId); + this.__maximizeRead.purgeDependencyOnElmtId(rmElmtId); this.__provideService.purgeDependencyOnElmtId(rmElmtId); this.__labelName.purgeDependencyOnElmtId(rmElmtId); } @@ -353,6 +359,7 @@ export class CustomAppBar extends ViewPU { this.__breakPoint.aboutToBeDeleted(); this.__serviceMenuRead.aboutToBeDeleted(); this.__closeRead.aboutToBeDeleted(); + this.__maximizeRead.aboutToBeDeleted(); this.__provideService.aboutToBeDeleted(); this.__labelName.aboutToBeDeleted(); SubscriberManager.Get().delete(this.id__()); @@ -538,6 +545,12 @@ export class CustomAppBar extends ViewPU { set closeRead(newValue) { this.__closeRead.set(newValue); } + get maximizeRead() { + return this.__maximizeRead.get(); + } + set maximizeRead(newValue) { + this.__maximizeRead.set(newValue); + } get provideService() { return this.__provideService.get(); } @@ -561,6 +574,7 @@ export class CustomAppBar extends ViewPU { this.containerHeight = '100%'; this.containerWidth = '100%'; } + this.updateStringByResource(); this.getDeviceRadiusConfig(); } aboutToDisappear() { @@ -638,6 +652,14 @@ export class CustomAppBar extends ViewPU { } return ''; } + updateStringByResource() { + if (this.isHalfScreen) { + this.provideService = this.getStringByResourceToken(ARKUI_APP_BAR_PROVIDE_SERVICE); + this.maximizeRead = this.getStringByResourceToken(ARKUI_APP_BAR_MAXIMIZE); + } + this.closeRead = this.getStringByResourceToken(ARKUI_APP_BAR_CLOSE); + this.serviceMenuRead = this.getStringByResourceToken(ARKUI_APP_BAR_SERVICE_PANEL); + } /** * atomicservice侧的事件变化回调 * @param eventName 事件名称 @@ -677,7 +699,7 @@ export class CustomAppBar extends ViewPU { } this.bundleName = splitArray[0]; this.labelName = splitArray[1]; - this.provideService = this.getStringByResourceToken(ARKUI_APP_BAR_PROVIDE_SERVICE); + this.updateStringByResource(); } else if (eventName === ARKUI_APP_BAR_SCREEN) { this.isHalfScreen = this.parseBoolean(param); @@ -879,9 +901,6 @@ export class CustomAppBar extends ViewPU { Button.width(BUTTON_SIZE); Button.height(VIEW_HEIGHT); Button.accessibilityText(this.serviceMenuRead); - Button.onAccessibilityHover(() => { - this.serviceMenuRead = this.getStringByResourceToken(ARKUI_APP_BAR_SERVICE_PANEL); - }); Gesture.create(GesturePriority.Low); TapGesture.create(); TapGesture.onAction(() => { @@ -918,9 +937,6 @@ export class CustomAppBar extends ViewPU { Button.width(BUTTON_SIZE); Button.height(VIEW_HEIGHT); Button.accessibilityText(this.closeRead); - Button.onAccessibilityHover(() => { - this.closeRead = this.getStringByResourceToken(ARKUI_APP_BAR_CLOSE); - }); Gesture.create(GesturePriority.Low); TapGesture.create(); TapGesture.onAction(() => { @@ -1053,6 +1069,7 @@ export class CustomAppBar extends ViewPU { Button.onClick(() => { this.expendContainerAnimation(); }); + Button.accessibilityText(this.maximizeRead); }, Button); this.observeComponentCreation2((elmtId, isInitialRender) => { SymbolGlyph.create({ 'id': -1, 'type': 40000, params: ['sys.symbol.arrow_up_left_and_arrow_down_right'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }); @@ -1072,6 +1089,7 @@ export class CustomAppBar extends ViewPU { Button.onClick(() => { this.closeContainerAnimation(); }); + Button.accessibilityText(this.closeRead); }, Button); this.observeComponentCreation2((elmtId, isInitialRender) => { SymbolGlyph.create({ 'id': -1, 'type': 40000, params: ['sys.symbol.xmark'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }); diff --git a/customappbar/source/custom_app_bar.ets b/customappbar/source/custom_app_bar.ets index 0add41d..ea498f7 100644 --- a/customappbar/source/custom_app_bar.ets +++ b/customappbar/source/custom_app_bar.ets @@ -68,6 +68,7 @@ const EVENT_NAME_CUSTOM_APP_BAR_MENU_CLICK = 'arkui_custom_app_bar_menu_click'; const EVENT_NAME_CUSTOM_APP_BAR_CLOSE_CLICK = 'arkui_custom_app_bar_close_click'; const EVENT_NAME_CUSTOM_APP_BAR_DID_BUILD = 'arkui_custom_app_bar_did_build'; const EVENT_NAME_CUSTOM_APP_BAR_CREATE_SERVICE_PANEL = 'arkui_custom_app_bar_create_service_panel'; +const ARKUI_APP_BAR_MAXIMIZE: string = 'arkui_app_bar_maximize'; /** * 适配不同颜色模式集合 @@ -150,6 +151,7 @@ export struct CustomAppBar { @State @Watch('onBreakPointChange') breakPoint: BreakPointsType = BreakPointsType.NONE; @State serviceMenuRead: string = this.getStringByResourceToken(ARKUI_APP_BAR_SERVICE_PANEL); @State closeRead: string = this.getStringByResourceToken(ARKUI_APP_BAR_CLOSE); + @State maximizeRead: string = this.getStringByResourceToken(ARKUI_APP_BAR_MAXIMIZE); @State provideService: string = ''; private isHalfToFullScreen: boolean = false; private isDark: boolean = true; @@ -168,12 +170,12 @@ export struct CustomAppBar { if (this.isHalfScreen) { this.contentBgColor = Color.Transparent; this.titleHeight = EYELASH_HEIGHT + 2 * TITLE_MARGIN_TOP + this.statusBarHeight; - this.provideService = this.getStringByResourceToken(ARKUI_APP_BAR_PROVIDE_SERVICE); this.halfScreenShowAnimation(); } else { this.containerHeight = '100%'; this.containerWidth = '100%'; } + this.updateStringByResource(); this.getDeviceRadiusConfig(); } @@ -257,6 +259,15 @@ export struct CustomAppBar { return ''; } + updateStringByResource(): void { + if (this.isHalfScreen) { + this.provideService = this.getStringByResourceToken(ARKUI_APP_BAR_PROVIDE_SERVICE); + this.maximizeRead = this.getStringByResourceToken(ARKUI_APP_BAR_MAXIMIZE); + } + this.closeRead = this.getStringByResourceToken(ARKUI_APP_BAR_CLOSE); + this.serviceMenuRead = this.getStringByResourceToken(ARKUI_APP_BAR_SERVICE_PANEL); + } + /** * atomicservice侧的事件变化回调 * @param eventName 事件名称 @@ -293,8 +304,7 @@ export struct CustomAppBar { } this.bundleName = splitArray[0]; this.labelName = splitArray[1]; - this.provideService = this.getStringByResourceToken(ARKUI_APP_BAR_PROVIDE_SERVICE); - + this.updateStringByResource(); } else if (eventName === ARKUI_APP_BAR_SCREEN) { this.isHalfScreen = this.parseBoolean(param); this.initBreakPointListener(); @@ -477,9 +487,6 @@ export struct CustomAppBar { .width(BUTTON_SIZE) .height(VIEW_HEIGHT) .accessibilityText(this.serviceMenuRead) - .onAccessibilityHover(() => { - this.serviceMenuRead = this.getStringByResourceToken(ARKUI_APP_BAR_SERVICE_PANEL); - }) .gesture(TapGesture().onAction(() => { this.onMenuButtonClick(); })) @@ -508,9 +515,6 @@ export struct CustomAppBar { .width(BUTTON_SIZE) .height(VIEW_HEIGHT) .accessibilityText(this.closeRead) - .onAccessibilityHover(() => { - this.closeRead = this.getStringByResourceToken(ARKUI_APP_BAR_CLOSE); - }) .gesture(TapGesture().onAction(() => { this.closeContainerAnimation(); })) @@ -611,7 +615,7 @@ export struct CustomAppBar { .onClick(() => { this.expendContainerAnimation(); }) - + .accessibilityText(this.maximizeRead) Button({ type: ButtonType.Circle }) { SymbolGlyph($r('sys.symbol.xmark')) .fontSize(BUTTON_IMAGE_SIZE) @@ -627,6 +631,7 @@ export struct CustomAppBar { .onClick(() => { this.closeContainerAnimation(); }) + .accessibilityText(this.closeRead) } .geometryTransition('menubar') .justifyContent(FlexAlign.End) -- Gitee