1c41cb6d2Sopenharmony_ci/** 2c41cb6d2Sopenharmony_ci * Copyright (c) 2021 Huawei Device Co., Ltd. 3c41cb6d2Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4c41cb6d2Sopenharmony_ci * you may not use this file except in compliance with the License. 5c41cb6d2Sopenharmony_ci * You may obtain a copy of the License at 6c41cb6d2Sopenharmony_ci * 7c41cb6d2Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8c41cb6d2Sopenharmony_ci * 9c41cb6d2Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10c41cb6d2Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11c41cb6d2Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12c41cb6d2Sopenharmony_ci * See the License for the specific language governing permissions and 13c41cb6d2Sopenharmony_ci * limitations under the License. 14c41cb6d2Sopenharmony_ci */ 15c41cb6d2Sopenharmony_ciimport ComponentConfig from './ComponentConfig'; 16c41cb6d2Sopenharmony_ci 17c41cb6d2Sopenharmony_ci/** 18c41cb6d2Sopenharmony_ci * item custom component 19c41cb6d2Sopenharmony_ci */ 20c41cb6d2Sopenharmony_ci@Component 21c41cb6d2Sopenharmony_ciexport default struct DoubleLineComponent { 22c41cb6d2Sopenharmony_ci @State settingIcon: string = ""; 23c41cb6d2Sopenharmony_ci @State settingTitle: string = ""; 24c41cb6d2Sopenharmony_ci @State settingSummary: string = ""; 25c41cb6d2Sopenharmony_ci @State settingValue: string = ""; 26c41cb6d2Sopenharmony_ci @State settingArrow: string = ''; 27c41cb6d2Sopenharmony_ci @State settingArrowStyle: string = ""; 28c41cb6d2Sopenharmony_ci @State settingUri: string = ""; 29c41cb6d2Sopenharmony_ci @State titleFontColor: Resource = $r('sys.color.ohos_id_color_text_primary'); 30c41cb6d2Sopenharmony_ci @State isTouched: boolean = false; 31c41cb6d2Sopenharmony_ci @State heights: Resource = $r('app.float.wh_value_72'); 32c41cb6d2Sopenharmony_ci @State image_wh: Resource = $r('app.float.wh_value_40'); 33c41cb6d2Sopenharmony_ci @State fontSize: Resource = $r('sys.float.ohos_id_text_size_body1'); 34c41cb6d2Sopenharmony_ci @State valueFontSize: Resource = $r('sys.float.ohos_id_text_size_body2'); 35c41cb6d2Sopenharmony_ci private isEnabled: boolean = true; 36c41cb6d2Sopenharmony_ci private onArrowClick?: () => void; 37c41cb6d2Sopenharmony_ci 38c41cb6d2Sopenharmony_ci build() { 39c41cb6d2Sopenharmony_ci Row() { 40c41cb6d2Sopenharmony_ci Row() { 41c41cb6d2Sopenharmony_ci Image(this.settingIcon) 42c41cb6d2Sopenharmony_ci .width(this.image_wh) 43c41cb6d2Sopenharmony_ci .height(this.image_wh) 44c41cb6d2Sopenharmony_ci .margin({ right: $r('app.float.wh_value_16') }) 45c41cb6d2Sopenharmony_ci .objectFit(ImageFit.Contain); 46c41cb6d2Sopenharmony_ci 47c41cb6d2Sopenharmony_ci Column() { 48c41cb6d2Sopenharmony_ci Text(this.settingTitle) 49c41cb6d2Sopenharmony_ci .fontColor(this.isEnabled ? this.titleFontColor : $r("sys.color.ohos_id_color_primary")) 50c41cb6d2Sopenharmony_ci .fontSize(this.fontSize) 51c41cb6d2Sopenharmony_ci .fontWeight(FontWeight.Medium) 52c41cb6d2Sopenharmony_ci .textAlign(TextAlign.Start) 53c41cb6d2Sopenharmony_ci .maxLines(ComponentConfig.MAX_LINES_3) 54c41cb6d2Sopenharmony_ci .textOverflow({ overflow: TextOverflow.Ellipsis }) 55c41cb6d2Sopenharmony_ci Row() { 56c41cb6d2Sopenharmony_ci Text($r('app.string.version')) 57c41cb6d2Sopenharmony_ci .fontColor($r('sys.color.ohos_id_color_mask_light')) 58c41cb6d2Sopenharmony_ci .fontSize(this.valueFontSize) 59c41cb6d2Sopenharmony_ci .textAlign(TextAlign.Start) 60c41cb6d2Sopenharmony_ci .fontWeight(FontWeight.Regular) 61c41cb6d2Sopenharmony_ci .maxLines(ComponentConfig.MAX_LINES_1) 62c41cb6d2Sopenharmony_ci .textOverflow({ overflow: TextOverflow.Ellipsis }) 63c41cb6d2Sopenharmony_ci .visibility('pages/applicationInfo' === this.settingUri ? Visibility.Visible : Visibility.None) 64c41cb6d2Sopenharmony_ci .margin({ top: $r('sys.float.ohos_id_text_margin_vertical') }) 65c41cb6d2Sopenharmony_ci Text(this.settingSummary) 66c41cb6d2Sopenharmony_ci .fontColor($r('sys.color.ohos_id_color_mask_light')) 67c41cb6d2Sopenharmony_ci .fontSize(this.valueFontSize) 68c41cb6d2Sopenharmony_ci .fontWeight(FontWeight.Regular) 69c41cb6d2Sopenharmony_ci .textAlign(TextAlign.Start) 70c41cb6d2Sopenharmony_ci .maxLines(ComponentConfig.MAX_LINES_1) 71c41cb6d2Sopenharmony_ci .textOverflow({ overflow: TextOverflow.Ellipsis }) 72c41cb6d2Sopenharmony_ci .visibility('pages/applicationInfo' === this.settingUri ? Visibility.Visible : Visibility.None) 73c41cb6d2Sopenharmony_ci .margin({ top: $r('sys.float.ohos_id_text_margin_vertical') }) 74c41cb6d2Sopenharmony_ci } 75c41cb6d2Sopenharmony_ci } 76c41cb6d2Sopenharmony_ci .alignItems(HorizontalAlign.Start); 77c41cb6d2Sopenharmony_ci } 78c41cb6d2Sopenharmony_ci .flexShrink(0) 79c41cb6d2Sopenharmony_ci .alignItems(VerticalAlign.Center) 80c41cb6d2Sopenharmony_ci .align(Alignment.Start) 81c41cb6d2Sopenharmony_ci 82c41cb6d2Sopenharmony_ci Blank() 83c41cb6d2Sopenharmony_ci 84c41cb6d2Sopenharmony_ci Row() { 85c41cb6d2Sopenharmony_ci Text(this.settingValue) 86c41cb6d2Sopenharmony_ci .fontSize(this.valueFontSize) 87c41cb6d2Sopenharmony_ci .fontColor($r('sys.color.ohos_fa_text_secondary')) 88c41cb6d2Sopenharmony_ci .fontWeight('sans-serif') 89c41cb6d2Sopenharmony_ci .height($r('app.float.wh_value_40')) 90c41cb6d2Sopenharmony_ci .margin({ left: $r('sys.float.ohos_id_elements_margin_horizontal_l') }) 91c41cb6d2Sopenharmony_ci .align(Alignment.End); 92c41cb6d2Sopenharmony_ci 93c41cb6d2Sopenharmony_ci Stack({ alignContent: Alignment.End }) { 94c41cb6d2Sopenharmony_ci Image(this.settingArrow) 95c41cb6d2Sopenharmony_ci .width(this.settingArrowStyle === '' ? $r('app.float.wh_value_12') : $r('app.float.wh_value_40')) 96c41cb6d2Sopenharmony_ci .height($r('app.float.wh_value_24')) 97c41cb6d2Sopenharmony_ci } 98c41cb6d2Sopenharmony_ci .width($r('app.float.wh_value_48')) 99c41cb6d2Sopenharmony_ci .height($r('app.float.wh_value_48')) 100c41cb6d2Sopenharmony_ci .margin({ left: $r('app.float.wh_value_4') }) 101c41cb6d2Sopenharmony_ci .visibility('' === this.settingArrow ? Visibility.None : Visibility.Visible) 102c41cb6d2Sopenharmony_ci .onClick(this.onArrowClick as ((event?: ClickEvent) => void)); 103c41cb6d2Sopenharmony_ci } 104c41cb6d2Sopenharmony_ci .align(Alignment.End); 105c41cb6d2Sopenharmony_ci } 106c41cb6d2Sopenharmony_ci .height(this.heights) 107c41cb6d2Sopenharmony_ci .width(ComponentConfig.WH_100_100) 108c41cb6d2Sopenharmony_ci .padding({ 109c41cb6d2Sopenharmony_ci left: $r('sys.float.ohos_id_card_margin_end'), 110c41cb6d2Sopenharmony_ci right: $r('sys.float.ohos_id_card_margin_end'), 111c41cb6d2Sopenharmony_ci top: $r('sys.float.ohos_id_elements_margin_vertical_m'), 112c41cb6d2Sopenharmony_ci bottom: $r('sys.float.ohos_id_elements_margin_vertical_m') 113c41cb6d2Sopenharmony_ci }) 114c41cb6d2Sopenharmony_ci .borderRadius($r("sys.float.ohos_id_corner_radius_default_l")) 115c41cb6d2Sopenharmony_ci .linearGradient((this.isEnabled && this.isTouched) ? { 116c41cb6d2Sopenharmony_ci angle: 90, 117c41cb6d2Sopenharmony_ci direction: GradientDirection.Right, 118c41cb6d2Sopenharmony_ci colors: [[$r("app.color.DCEAF9"), 0.0], [$r("app.color.FAFAFA"), 1.0]] 119c41cb6d2Sopenharmony_ci } : { 120c41cb6d2Sopenharmony_ci angle: 90, 121c41cb6d2Sopenharmony_ci direction: GradientDirection.Right, 122c41cb6d2Sopenharmony_ci colors: [[$r("sys.color.ohos_id_color_foreground_contrary"), 1], [$r("sys.color.ohos_id_color_foreground_contrary"), 1]] 123c41cb6d2Sopenharmony_ci }) 124c41cb6d2Sopenharmony_ci .alignItems(VerticalAlign.Center) 125c41cb6d2Sopenharmony_ci .onTouch((event?: TouchEvent) => { 126c41cb6d2Sopenharmony_ci if (event?.type === TouchType.Down) { 127c41cb6d2Sopenharmony_ci this.isTouched = true; 128c41cb6d2Sopenharmony_ci } 129c41cb6d2Sopenharmony_ci if (event?.type === TouchType.Up) { 130c41cb6d2Sopenharmony_ci this.isTouched = false; 131c41cb6d2Sopenharmony_ci } 132c41cb6d2Sopenharmony_ci }) 133c41cb6d2Sopenharmony_ci } 134c41cb6d2Sopenharmony_ci}