| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- import StyleConstants from '../constants/StyleConstants'
- export class BackgroundPageModifier implements AttributeModifier<CommonAttribute> {
- isNeedImage: boolean
- isNeedPaddingTop: boolean
- isNeedPaddingBottom: boolean
- constructor(isNeedImage: boolean, isNeedPaddingTop: boolean = true, isNeedPaddingBottom: boolean = true) {
- this.isNeedImage = isNeedImage
- this.isNeedPaddingTop = isNeedPaddingTop
- this.isNeedPaddingBottom = isNeedPaddingBottom
- }
- applyNormalAttribute(instance: CommonAttribute): void {
- if (this.isNeedImage) {
- instance
- .height(StyleConstants.FULL_PARENT)
- .width(StyleConstants.FULL_PARENT)
- .backgroundColor($r("app.color.theme_bg_color"))
- // .backgroundImage($r("app.media.bgPage"))
- .backgroundImageSize({ width: '100%', height: '100%' })//backgroundImageSize((ImageSize.Cover))
- .backgroundImagePosition(Alignment.Center)
- .padding({
- top: this.isNeedPaddingTop ? StyleConstants.TOP_HEIGHT : 0,
- bottom: this.isNeedPaddingBottom ? StyleConstants.BOTTOM_HEIGHT : 0,
- left: 10,
- right: 10
- })
- } else {
- instance
- .height(StyleConstants.FULL_PARENT)
- .width(StyleConstants.FULL_PARENT)
- .backgroundColor($r("app.color.theme_bg_color"))
- .padding({
- top: this.isNeedPaddingTop ? StyleConstants.TOP_HEIGHT : 0,
- bottom: this.isNeedPaddingBottom ? StyleConstants.BOTTOM_HEIGHT : 0,
- left: 10,
- right: 10
- })
- }
- }
- }
|