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 */ 15 16/** 17 * @file: Header information display component 18 */ 19import LogUtils from '../utils/LogUtils'; 20import CallStateConst from '../constant/CallStateConst'; 21import Utils from '../utils/utils' 22import CallList from './CallList' 23import callStateConst from '../constant/CallStateConst'; 24import CallUtils from '../utils/CallUtils' 25 26const TAG = "MultiContactCard"; 27 28@Component 29export default struct MultiContactCard { 30 @State callStateText: string = ''; 31 @State dialing: string = '.'; 32 @Prop isShowKeyboard: boolean; 33 @Link callList: Array<any>; 34 @Link callData: any; 35 @StorageLink("TextInput") textInput: string = ''; 36 @StorageLink("TextInputValue") textInputValue: string = ''; 37 @StorageLink("CallTimeList") callTimeList: any = []; 38 @StorageLink("AccountNumber") accountNumber: string = ''; 39 @StorageLink("IsEmergencyPhoneNumber") isEmergencyPhoneNumber: boolean = false; 40 @StorageLink("hasSimCard1") hasSimCard1: boolean = false; 41 @StorageLink("hasSimCard2") hasSimCard2: boolean = false; 42 private mUtils: Utils; 43 private timer; 44 private emergency = $r('app.string.emergency'); 45 46 public aboutToAppear(): void { 47 LogUtils.i(TAG, "aboutToAppear"); 48 this.mUtils = Utils.getInstance(); 49 this.timer = setInterval(() => { 50 if (this.dialing === '...') { 51 this.dialing = ''; 52 } 53 this.dialing += '.'; 54 }, 500) 55 if (this.callData.callState === 3) { 56 clearInterval(this.timer) 57 } 58 59 if (this.callData.callState === 4 || this.callData.callState === 5) { 60 CallUtils.hasSimeCard(0); 61 CallUtils.hasSimeCard(1); 62 } 63 } 64 65 private isShowSim() { 66 return (this.callData.callState === CallStateConst.callStateObj.CALL_STATUS_WAITING 67 || this.callData.callState === CallStateConst.callStateObj.CALL_STATUS_INCOMING) && this.hasSimCard1 && this.hasSimCard2; 68 } 69 70 build() { 71 GridRow({ columns: { sm: 4, md: 8, lg: 12 }, gutter: 24 }) { 72 GridCol({ span: { sm: 4, md: 6, lg: 6 }, offset: { md: 1, lg: 3 } }) { 73 Column() { 74 if (!(this.isShowKeyboard && this.textInput.length != 0)) { 75 CallList({ 76 callList: $callList, 77 callData: $callData 78 }) 79 80 if (this.callData.callState === CallStateConst.callStateObj.CALL_STATUS_WAITING 81 || this.callData.callState === CallStateConst.callStateObj.CALL_STATUS_INCOMING) { 82 Column() { 83 if (!this.isShowKeyboard || this.isShowKeyboard && this.textInput.length === 0) { 84 Text(this.isEmergencyPhoneNumber ? this.emergency : this.callData.contactName ? this.callData.contactName : this.callData.accountNumber) 85 .fontSize(30) 86 .height(40) 87 .lineHeight(40) 88 .fontWeight(FontWeight.Medium) 89 .fontColor('#FFFFFF') 90 .margin({ bottom: 8 }) 91 92 Text((this.callData.contactName || this.isEmergencyPhoneNumber) ? this.callData.accountNumber : '') 93 .fontSize(14) 94 .height(19) 95 .lineHeight(19) 96 .fontColor('#FFFFFF') 97 .opacity(0.60) 98 .visibility((this.callData.contactName || this.isEmergencyPhoneNumber) && !this.isShowKeyboard ? Visibility.Visible : Visibility.None) 99 } 100 } 101 .margin({ top: 56 }) 102 103 if (this.isShowSim()) { 104 Image(this.callData.accountId == 1 ? $r("app.media.ic_public_phone_sim2") : $r("app.media.ic_public_phone_sim1")) 105 .margin({ right: 4 }) 106 .width(12) 107 .height(12) 108 .opacity(0.6) 109 } 110 } 111 112 113 } else if (this.isShowKeyboard && this.textInput.length != 0) { 114 Scroll() { 115 Text(this.textInputValue) 116 .height(40) 117 .fontSize(30) 118 .lineHeight(40) 119 .fontWeight(FontWeight.Medium) 120 .margin({ bottom: 8 }) 121 .fontColor('#FFFFFF') 122 .onTouch((event: TouchEvent) => { 123 if (event.type === TouchType.Move) { 124 this.textInputValue = this.textInput 125 } 126 }) 127 } 128 .scrollable(ScrollDirection.Horizontal) 129 .scrollBar(BarState.Off) 130 .width('100%') 131 } 132 } 133 } 134 } 135 .margin({ left: 24, right: 24 }) 136 } 137}