1/** 2 * Copyright (c) 2023 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 */ 15import LogUtils from '../utils/LogUtils' 16 17const TAG = "HeadComponent" 18 19/** 20 * head custom component 21 */ 22@Component 23export default struct HeadComponent { 24 @State isTouch: boolean = false; 25 26 build() { 27 Row() { 28 Stack({ alignContent: Alignment.Center }) { 29 Image($r('app.media.ic_back')) 30 .width(24) 31 .height(24) 32 .fillColor($r("sys.color.ohos_id_color_primary")) 33 } 34 .margin({ right: 16 }) 35 .backgroundColor(this.isTouch ? $r('app.color.color_E3E3E3_grey') : $r('app.color.color_00000000_transparent')) 36 .onClick(() => { 37 globalThis.settingsAbilityContext?.terminateSelf().then((data) => { 38 LogUtils.i(TAG, "terminateSelfCallBack"); 39 }); 40 }) 41 .onTouch((event: TouchEvent) => { 42 if (event.type === TouchType.Down) { 43 this.isTouch = true; 44 } 45 if (event.type === TouchType.Up) { 46 this.isTouch = false; 47 } 48 }); 49 50 Text($r('app.string.mobile_data')) 51 .fontSize(20) 52 .fontFamily('HarmonyHeiTi-Bold') 53 .fontWeight(FontWeight.Medium) 54 .fontColor($r('app.color.font_color_182431')) 55 .maxLines(1) 56 .textOverflow({ overflow: TextOverflow.Ellipsis }) 57 .textAlign(TextAlign.Start) 58 .margin({ top: 15, bottom: 15 }); 59 } 60 .width("100%") 61 .padding({ left: 12 }) 62 .height(56) 63 .alignItems(VerticalAlign.Center) 64 .align(Alignment.Start) 65 } 66}