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