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/** 17 * @file: bottom button component 18 */ 19 20import CallServiceProxy from '../../model/CallServiceProxy'; 21import LogUtils from '../utils/LogUtils'; 22import DefaultCallData from '../struct/TypeUtils'; 23import CallListStruct from '../struct/CallListStruct' 24 25const TAG = 'BottomBtn'; 26 27@Component 28export default struct BottomBtn { 29 onItemClick: Function = null; 30 @Link callData: DefaultCallData; 31 @Link callList: Array<CallListStruct>; 32 @Link hangup: boolean; 33 private mCallServiceProxy: CallServiceProxy; 34 private imageList; 35 36 public aboutToAppear() { 37 LogUtils.i(TAG, 'aboutToAppear :'); 38 this.getImageList(); 39 this.mCallServiceProxy = CallServiceProxy.getInstance(); 40 } 41 42 /** 43 * get Image List 44 */ 45 private getImageList() { 46 this.imageList = [ 47 { 48 type: 'keyboard', 49 img: $r('app.media.ic_public_DTFS') 50 }, 51 { 52 type: 'hangUP', 53 img: $r('app.media.ic_public_ring_off') 54 }, 55 { 56 type: 'speakerphone', 57 img: $r('app.media.ic_public_sound_louder') 58 }, 59 ] 60 } 61 62 /** 63 * this method is to call the hangup interface 64 */ 65 onHangUp() { 66 this.mCallServiceProxy.hangUpCall(this.callData.callId); 67 if (this.callList.length === 1) { 68 this.hangup = true; 69 globalThis.calluiAbilityContext?.terminateSelf().then((data) => { 70 LogUtils.i(TAG, 'onHangUp terminateSelfCallBack'); 71 }); 72 } 73 LogUtils.i(TAG, 'onHangUp this.callData.callId : ' + this.callData.callId); 74 } 75 76 /** 77 * Image size 78 */ 79 imgSizes(type) { 80 if (type == 'keyboard') { 81 return 30; 82 } 83 if (type == 'speakerphone') { 84 return 30; 85 } 86 if (type == 'hangUP') { 87 return 56; 88 } 89 } 90 91 /** 92 * Button Event 93 */ 94 onImgClick(type) { 95 if (type == 'keyboard') { 96 this.onItemClick(); 97 } 98 if (type == 'hangUP') { 99 this.onHangUp(); 100 } 101 if (type == 'speakerphone') { 102 this.onSpeakerButtonClicked(); 103 } 104 } 105 106 onSpeakerButtonClicked() { 107 } 108 build() { 109 GridRow({ columns: { sm: 4, md: 8, lg: 12 }, gutter: 24 }) { 110 GridCol({ span: { sm: 4, md: 6, lg: 6 }, offset: { md: 1, lg: 3 } }) { 111 Grid() { 112 ForEach(this.imageList, (item,) => { 113 GridItem() { 114 Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { 115 Image(item.img) 116 .width(this.imgSizes(item.type)) 117 .height(this.imgSizes(item.type)) 118 } 119 .width(56) 120 .height(56) 121 .onClick(() => { 122 this.onImgClick(item.type) 123 }) 124 } 125 }) 126 } 127 .columnsGap(24) 128 .height(56) 129 .columnsTemplate('1fr 1fr 1fr') 130 .rowsTemplate('1fr') 131 } 132 } 133 .margin({ left: 24, right: 24 }) 134 } 135} 136