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 16import common from '@ohos.app.ability.common'; 17 18@Component 19export default struct HeadComponent { 20 private headName: string | Resource = ''; 21 22 build() { 23 Row() { 24 Image($r('app.media.ic_back')) 25 .width($r('app.float.wh_value_24')) 26 .height($r('app.float.wh_value_24')) 27 .borderRadius($r('app.float.wh_value_15')) 28 .margin({ 29 left: $r('app.float.wh_value_36'), 30 right: $r('app.float.wh_value_16'), 31 }) 32 .backgroundColor($r('app.color.color_00000000_transparent')) 33 .visibility(Visibility.Visible) 34 .onClick(() => { 35 (getContext(this) as common.UIAbilityContext).terminateSelf(); 36 }) 37 Text(this.headName) 38 .height($r('app.float.wh_value_56')) 39 .fontColor($r('sys.color.ohos_id_color_text_primary')) 40 .fontSize($r('app.float.font_20')) 41 .fontWeight(FontWeight.Bold) 42 .textAlign(TextAlign.Start) 43 .maxLines(1) 44 .textOverflow({ overflow: TextOverflow.Ellipsis }) 45 } 46 .width('100%') 47 .height($r('app.float.wh_value_56')) 48 .alignItems(VerticalAlign.Center) 49 .align(Alignment.Start) 50 } 51}