横竖屏的样式适配

Signed-off-by: Mst <mashitao2@huawei.com>
This commit is contained in:
Mst 2022-05-23 21:41:48 +08:00
parent 8328d12344
commit 43332b048c
6 changed files with 63 additions and 25 deletions

View File

@ -43,7 +43,7 @@ export default struct CustomPSD {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.End }) {
Text(this.mViewModel.prompt)
.fontSize($r('app.float.custompsd_prompt_fontsize'))
.fontWeight(deviceInfo.deviceType === 'tablet' ? FontWeight.Bold : 'Medium')
.fontWeight(FontWeight.Medium)
.fontColor(Color.White)
.margin({ bottom: $r('app.float.custompsd_prompt_margin_bottom') })
.textAlign(TextAlign.Center)
@ -53,23 +53,23 @@ export default struct CustomPSD {
Stack({ alignContent: Alignment.Center }) {
Text()
.width(deviceInfo.deviceType === 'tablet' ? Constants.FULL_CONTAINER_WIDTH : 288)
.height(deviceInfo.deviceType === 'tablet' ? Constants.FULL_CONTAINER_HEIGHT : 36)
.width(Constants.FULL_CONTAINER_WIDTH)
.height(Constants.FULL_CONTAINER_HEIGHT)
.backgroundColor(Color.Gray)
.borderRadius($r('app.float.custompsd_input_radius'))
.opacity(deviceInfo.deviceType === 'tablet' ? 1 : 0.2)
.opacity($r("app.float.custompsd_text_opacity"))
List({ space: Constants.DIGITALPSD_IC_DIAMETER }) {
ForEach(this.passwordArr, (item) => {
ListItem() {
Image($r("app.media.ic_solid_dot"))
.width(deviceInfo.deviceType === 'tablet' ? Constants.DIGITALPSD_IC_DIAMETER : 9)
.height(deviceInfo.deviceType === 'tablet' ? Constants.DIGITALPSD_IC_DIAMETER : 9)
.width($r("app.float.custompsd_digitalpsd_ic_diameter"))
.height($r("app.float.custompsd_digitalpsd_ic_diameter"))
}
})
}
.listDirection(Axis.Horizontal)
.height(deviceInfo.deviceType === 'tablet' ? Constants.DIGITALPSD_IC_DIAMETER : 9)
.height($r("app.float.custompsd_digitalpsd_ic_diameter"))
}
.width($r('app.float.custompsd_input_width'))
.height($r('app.float.custompsd_input_height'))
@ -79,7 +79,7 @@ export default struct CustomPSD {
stateEffect: true
})
.width($r('app.float.custompsd_input_width'))
.height(deviceInfo.deviceType === 'tablet' ? $r('app.float.custompsd_input_height') : 40)
.height($r("app.float.custompsd_button_height"))
.enabled(this.passwordArr.length > 1)
.opacity(deviceInfo.deviceType === 'tablet' ? 1 : (this.passwordArr.length > 1 ? 1 : 0.4))
.onClick(() => {
@ -88,7 +88,7 @@ export default struct CustomPSD {
Log.showInfo(TAG, `onClick callback promptText:${JSON.stringify(this.mViewModel.prompt)}`)
});
})
.margin({ top: deviceInfo.deviceType === 'tablet' ? $r('sys.float.ohos_id_elements_margin_vertical_l') : 16 })
.margin({ top: $r('sys.float.ohos_id_elements_margin_vertical_l')})
}
.width(Constants.FULL_CONTAINER_WIDTH)
.height($r('app.float.custompsd_input_area_height'))

View File

@ -17,7 +17,6 @@ import Log from '../../../../../../../../../common/src/main/ets/default/Log'
import Constants from '../../common/constants'
import NumkeyBoard from './numkeyBoard'
import ViewModel from '../../vm/digitalPSDViewModel'
import deviceInfo from '@ohos.deviceInfo';
const TAG = 'ScreenLock-DigitalPSD'
@ -43,7 +42,7 @@ export default struct DigitalPSD {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.End }) {
Text(this.mViewModel.prompt)
.fontSize($r('app.float.digitalpsd_prompt_fontsize'))
.fontWeight(deviceInfo.deviceType === 'tablet' ? FontWeight.Bold : "Medium")
.fontWeight(FontWeight.Medium)
.fontColor(Color.White)
.margin({ bottom: $r('app.float.digitalpsd_prompt_margin_bottom') })
.textAlign(TextAlign.Center)
@ -55,8 +54,8 @@ export default struct DigitalPSD {
ForEach(this.passwdMaskArr, (item) => {
GridItem() {
Image(item)
.width(deviceInfo.deviceType === 'tablet' ? Constants.DIGITALPSD_IC_DIAMETER : 12)
.height(deviceInfo.deviceType === 'tablet' ? Constants.DIGITALPSD_IC_DIAMETER : 12)
.width(Constants.DIGITALPSD_IC_DIAMETER)
.height(Constants.DIGITALPSD_IC_DIAMETER)
}
})
}

View File

@ -51,37 +51,35 @@ export default struct NumkeyBoard {
item.value == Constants.DEL_PWD) {
Text(item.row1)
.fontSize($r('app.float.digitalpsd_prompt_fontsize'))
.fontWeight(deviceInfo.deviceType === 'tablet' ? FontWeight.Bold : 'Medium')
.fontWeight(FontWeight.Medium)
.fontColor(Color.White)
.textAlign(TextAlign.Center)
.width(Constants.FULL_CONTAINER_WIDTH)
.lineHeight(deviceInfo.deviceType === 'tablet' ? Constants.FULL_CONTAINER_HEIGHT : 21)
.padding(0)
.margin(0)
} else {
Text(item.row1)
.fontSize($r('app.float.digitalpsd_row1_fontsize'))
.fontWeight(deviceInfo.deviceType === 'tablet' ? FontWeight.Bold : 'Medium')
.fontWeight(FontWeight.Medium)
.fontColor(Color.White)
.textAlign(TextAlign.Center)
.width(Constants.FULL_CONTAINER_WIDTH)
.lineHeight(deviceInfo.deviceType === 'tablet' ? Constants.FULL_CONTAINER_HEIGHT : 38)
.padding(0)
.margin(0)
}
if (!!item.row2) {
Text(item.row2)
.fontSize($r('app.float.digitalpsd_row2_fontsize'))
.fontWeight(deviceInfo.deviceType === 'tablet' ? FontWeight.Bold : 'Regular')
.fontWeight(FontWeight.Regular)
.fontColor(Color.White)
.opacity(deviceInfo.deviceType === 'tablet' ? 1 : 0.6)
.opacity($r("app.float.numkeyBoard_text_opacity"))
.textAlign(TextAlign.Center)
.width(Constants.FULL_CONTAINER_WIDTH)
.padding(0)
.margin(0)
}
}
.width(deviceInfo.deviceType === 'tablet' ? Constants.FULL_CONTAINER_WIDTH : 98.75)
.width(Constants.FULL_CONTAINER_WIDTH)
.height($r('app.float.digitalpsd_row_height'))
}
@ -116,9 +114,9 @@ export default struct NumkeyBoard {
}
.columnsTemplate('1fr 1fr 1fr')
.rowsTemplate('1fr 1fr 1fr 1fr')
.rowsGap(deviceInfo.deviceType === 'tablet' ? 0 : 22)
.width(deviceInfo.deviceType === 'tablet' ? Constants.FULL_CONTAINER_WIDTH : 312)
.height(deviceInfo.deviceType === 'tablet' ? Constants.FULL_CONTAINER_HEIGHT : 288)
.rowsGap($r("app.float.numkeyBoard_rowsGap"))
.width(Constants.FULL_CONTAINER_WIDTH)
.height(Constants.FULL_CONTAINER_HEIGHT)
}
.width(Constants.FULL_CONTAINER_WIDTH)
.height(Constants.FULL_CONTAINER_HEIGHT)

View File

@ -179,6 +179,27 @@
{
"name": "custompsd_key_area_margin_bottom",
"value": "64"
},
{
"name": "custompsd_text_opacity",
"value": "1"
},
{
"name": "custompsd_digitalpsd_ic_diameter",
"value": "12vp"
},
{
"name": "custompsd_button_height",
"value": "36vp"
},
{
"name": "numkeyBoard_text_opacity",
"value": "1"
},
{
"name": "numkeyBoard_rowsGap",
"value": "0"
}
]
}

View File

@ -90,7 +90,7 @@
},
{
"name": "digitalpsd_row_height",
"value": "48vp"
"value": "52vp"
},
{
"name": "digitalpsd_key_area_height",
@ -179,6 +179,26 @@
{
"name": "custompsd_key_area_margin_bottom",
"value": "52vp"
},
{
"name": "custompsd_text_opacity",
"value": "0.2"
},
{
"name": "custompsd_digitalpsd_ic_diameter",
"value": "9vp"
},
{
"name": "custompsd_button_height",
"value": "40vp"
},
{
"name": "numkeyBoard_text_opacity",
"value": "0.6"
},
{
"name": "numkeyBoard_rowsGap",
"value": "22vp"
}
]
}

View File

@ -28,7 +28,7 @@ export default class Constants {
static LOCKICON_AREA_WIDTH = '15%'
static DATETIME_AREA_WIDTH = '20%'
static PASSWORD_AREA_WIDTH = '95%'
static PASSWORD_AREA_WIDTH = '312vp'
static STATUS_ABOUT_TO_APPEAR = 1
static STATUS_ABOUT_TO_DISAPPEAR = 2