256 Star 409 Fork 2.7K

OpenHarmony / arkui_ace_engine

 / 详情

监听横竖屏,当横竖屏状态变化时,自定义弹窗的alignment一直不变

已拒绝
任务
创建于  
2022-06-09 09:32

【模块名_概率】简要描述:
监听横竖屏,当横竖屏状态变化时,自定义弹窗的alignment一直不变
【环境信息】:

网络环境
现网
硬件开发板型号
软件版本信息或tag节点
3.0.1.900 (API8)
测试环境
其他
【预置条件】:
DevEco Studio 3.0 Beta3
Build Version: 3.0.1.900, built on March 31, 2022
Runtime version: 11.0.13+7-b1751.21 amd64
VM: Dynamic Code Evolution 64-Bit Server VM by JetBrains s.r.o.
Windows 10 10.0
GC: G1 Young Generation, G1 Old Generation
Memory: 1536M
Cores: 8

【测试步骤】:
1.竖屏时观察弹窗位置,横屏时观察弹窗位置。
import mediaquery from '@ohos.mediaquery'
let portraitFunc = null
@CustomDialog
struct CustomDialogExample {
controller: CustomDialogController
cancel: () => void
confirm: () => void

build() {
Column() {
Text('Software uninstall').width('70%').fontSize(20).margin({ top: 10, bottom: 10 })
Image($r('app.media.icon')).width(80).height(80)
Text('Whether to uninstall a software?').fontSize(16).margin({ bottom: 10 })
Flex({ justifyContent: FlexAlign.SpaceAround }) {
Button('cancel')
.onClick(() => {
this.controller.close()
this.cancel()
}).backgroundColor(0xffffff).fontColor(Color.Black)
Button('confirm')
.onClick(() => {
this.controller.close()
this.confirm()
}).backgroundColor(0xffffff).fontColor(Color.Red)
}.margin({ bottom: 10 })
}
}
}

@entry
@citizenl

struct CustomDialogUser {

@后蜗牛 aligns:DialogAlignment=DialogAlignment.Bottom
@后蜗牛 font:string="30px"
@后蜗牛 txt:string='点击试试'

listener = mediaquery.matchMediaSync('(orientation: landscape)');

onPortrait(mediaQueryResult) {
if (mediaQueryResult.matches) {
this.aligns=DialogAlignment.Center //横屏
this.font='30px'
this.txt="不试"
} else {
this.aligns=DialogAlignment.Bottom //竖屏
this.font='100px'
}
}

dialogController: CustomDialogController = new CustomDialogController({
builder: CustomDialogExample({ cancel: this.onCancel, confirm: this.onAccept }),
cancel: this.existApp,
autoCancel: true,
alignment: this.aligns
})

onCancel() {
console.info('Callback when the first button is clicked')
}

onAccept() {
console.info('Callback when the second button is clicked')
}

existApp() {
console.info('Click the callback in the blank area')
}

aboutToAppear() {
portraitFunc = this.onPortrait.bind(this) //bind current js instance
this.listener.on('change', portraitFunc)
}

build() {
Column() {
Button(this.txt).fontSize(this.font).onClick(() => {
this.dialogController.open()
}).backgroundColor(0x317aff)
Text(this.font)
Text(this.aligns.toString())
}.width('100%').margin({ top: 5 })
}
}
【预期结果】:
竖屏时,弹窗在底部;横屏时,弹窗在中间
【实际结果】:
竖屏时,弹窗在中间;横屏时,弹窗在中间
【恢复手段】:

【出现概率】:问题出现次数/实际测试次数
5/5

评论 (1)

关明月 创建了缺陷
luoying_ace 任务状态待办的 修改为已确认
关明月 修改了描述
关明月 任务类型缺陷 修改为任务
关明月 任务状态已确认 修改为待办的
关明月 任务状态待办的 修改为进行中
展开全部操作日志

该问题与该场景类似,需要统一考虑
输入图片说明

yangfan229 添加了
 
Good_First_Issue
标签
关明月 任务状态进行中 修改为已拒绝

登录 后才可以发表评论

状态
负责人
项目
里程碑
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
开始日期   -   截止日期
-
置顶选项
优先级
预计工期 (小时)
参与者(2)
1
https://gitee.com/openharmony/arkui_ace_engine.git
git@gitee.com:openharmony/arkui_ace_engine.git
openharmony
arkui_ace_engine
arkui_ace_engine

搜索帮助