1/* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16@Entry 17@Component 18struct GridRowSample4 { 19 @State gridMargin: number = 0 20 21 build() { 22 Column() { 23 Row().width('100%').height(30) 24 25 GridRow() { 26 GridCol({ span: { sm: 12, md: 12, lg: 12 } }) { 27 Row() { 28 Text('padding') 29 .fontSize(24) 30 .fontWeight(FontWeight.Medium) 31 } 32 .width('100%') 33 .height('100%') 34 .alignItems(VerticalAlign.Center) 35 .justifyContent(FlexAlign.Center) 36 .backgroundColor('#19000000') 37 } 38 } 39 .height(50) 40 .borderWidth(2) 41 .borderColor('#F1CCB8') 42 .padding({ left: this.gridMargin, right: this.gridMargin }) 43 .onBreakpointChange((currentBreakpoint: string) => { 44 if (currentBreakpoint === 'lg' || currentBreakpoint === 'md') { 45 this.gridMargin = 24 46 } else { 47 this.gridMargin = 12 48 } 49 }) 50 51 Row().width('100%').height(30) 52 53 GridRow() { 54 GridCol({ span: { sm: 12, md: 12, lg: 12 } }) { 55 Row() { 56 Text('margin') 57 .fontSize(24) 58 .fontWeight(FontWeight.Medium) 59 } 60 .width('100%') 61 .height('100%') 62 .alignItems(VerticalAlign.Center) 63 .justifyContent(FlexAlign.Center) 64 .backgroundColor('#19000000') 65 } 66 } 67 .height(50) 68 .borderWidth(2) 69 .borderColor('#F1CCB8') 70 .margin({ left: this.gridMargin, right: this.gridMargin }) 71 } 72 } 73}