From 0ac56951f5b1e870919b5752f9ffd0f4fb9e827e Mon Sep 17 00:00:00 2001 From: liuhanxiong Date: Tue, 10 Oct 2023 10:06:02 +0000 Subject: [PATCH] hap panel test Signed-off-by: liuhanxiong Change-Id: Iddeef7df0925aeffad39e18f79366f0933531924 --- .../ets/extensionability/UserAuthAbility.ts | 3 +- entry/src/main/ets/pages/PanelExample.ets | 49 +++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 entry/src/main/ets/pages/PanelExample.ets diff --git a/entry/src/main/ets/extensionability/UserAuthAbility.ts b/entry/src/main/ets/extensionability/UserAuthAbility.ts index e274be4..13f470a 100644 --- a/entry/src/main/ets/extensionability/UserAuthAbility.ts +++ b/entry/src/main/ets/extensionability/UserAuthAbility.ts @@ -47,7 +47,8 @@ export default class UserAuthAbility extends UserAuthExtensionAbility { LogUtils.info(TAG, 'UserAuthExtensionAbility onSessionCreate'); AppStorage.setOrCreate("wantParams", want?.parameters?.useriamCmdData); AppStorage.setOrCreate("session", session); - (session as UIExtensionContentSession)?.loadContent('pages/Index'); + // (session as UIExtensionContentSession)?.loadContent('pages/Index'); + (session as UIExtensionContentSession)?.loadContent('pages/PanelExample'); try { if ((AppStorage.get("wantParams") as WantParams)?.windowModeType === 'DIALOG_BOX') { (session as UIExtensionContentSession)?.setWindowBackgroundColor(MASK_THIN_COLOR); diff --git a/entry/src/main/ets/pages/PanelExample.ets b/entry/src/main/ets/pages/PanelExample.ets new file mode 100644 index 0000000..44c61a2 --- /dev/null +++ b/entry/src/main/ets/pages/PanelExample.ets @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2023 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. + */ + +@Entry +@Component +struct PanelExample { + @State show: boolean = true + + build() { + Column() { + Text('2021-09-30 Today Calendar: 1.afternoon......Click for details') + .width('90%') + .height(50) + .borderRadius(10) + .backgroundColor(0xFFFFFF) + .padding({ left: 20 }) + .onClick(() => { + this.show = !this.show + }) + Panel(this.show) { // 展示日程 + Column() { + Text('Today Calendar') + Divider() + Text('1. afternoon 4:00 The project meeting') + } + } + .type(PanelType.Foldable) + .mode(PanelMode.Half) + .dragBar(true) // 默认开启 + .halfHeight(500) // 默认一半 + .showCloseIcon(true) // 显示关闭图标 + .onChange((width: number, height: number, mode: PanelMode) => { + console.info(`width:${width},height:${height},mode:${mode}`) + }) + }.width('100%').height('100%').backgroundColor(0xDCDCDC).padding({ top: 5 }) + } +} \ No newline at end of file -- Gitee