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 */ 15import TransmitMsgController from './transmitMsgController'; 16import DeviceUtil from '../../utils/DeviceUtil'; 17import router from '@system.router'; 18import { TransmitMsgDialog } from '../../views/MmsDialogs'; 19import WantUtil from '../../utils/WantUtil'; 20 21@Entry 22@Component 23export default struct TransmitMsg { 24 @State mTransmitMsgCtrl: TransmitMsgController = TransmitMsgController.getInstance(); 25 @State gridColumns: number = DeviceUtil.isTablet() ? 12 : 4; 26 @State gridSizeType: SizeType = DeviceUtil.isTablet() ? SizeType.LG : SizeType.SM; 27 @State gridGutter: string = '24vp'; 28 @State gridMargin: string = '24vp'; 29 private dialogAlignment: DialogAlignment = DeviceUtil.isTablet() ? DialogAlignment.Center : DialogAlignment.Bottom; 30 private dialogOffset: Offset = DeviceUtil.isTablet() ? { dx: 0, dy: 0 } : { dx: 0, dy: -12 }; 31 delDialogController: CustomDialogController = new CustomDialogController({ 32 builder: TransmitMsgDialog({ 33 cancel: () => { 34 35 }, 36 confirm: () => { 37 this.mTransmitMsgCtrl.transmit() 38 }, 39 msg: this.mTransmitMsgCtrl.dialogMsg, 40 }), 41 autoCancel: false, 42 alignment: this.dialogAlignment, 43 offset: this.dialogOffset, 44 }); 45 46 aboutToAppear() { 47 this.mTransmitMsgCtrl.onInit(); 48 this.mTransmitMsgCtrl.onShow(); 49 } 50 51 aboutToDisappear() { 52 this.delDialogController = null; 53 } 54 55 onPageShow() { 56 WantUtil.getWant(); 57 if (this.mTransmitMsgCtrl.DialogShow) { 58 this.delDialogController.open(); 59 } 60 } 61 62 onPageHide() { 63 } 64 65 onBackPress() { 66 } 67 68 build() { 69 GridContainer({ 70 columns: this.gridColumns, 71 sizeType: this.gridSizeType, 72 gutter: this.gridGutter, 73 margin: this.gridMargin 74 }) { 75 Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Start, alignItems: ItemAlign.Start }) { 76 //Notification information 77 Flex() { 78 Row() { 79 Image($rawfile('icon/ic_public_cancel.svg')) 80 .width(24) 81 .height(24) 82 .onClick(() => { 83 // Click Back to return to the unselected SMS state. 84 router.back(); 85 }) 86 Text($r('app.string.transmitHeadText')) 87 .margin({ left: 16 }) 88 .fontSize(20) 89 .fontColor($r('sys.color.ohos_id_color_text_primary')) 90 .fontWeight(FontWeight.Bold) 91 } 92 .alignItems(VerticalAlign.Center) 93 .width('100%') 94 .height(56) 95 } 96 97 //Select Contact 98 Flex() { 99 Column() { 100 Row() { 101 Text($r('app.string.selectContacts')) 102 .fontSize('16fp') 103 .fontColor($r('sys.color.ohos_id_color_text_primary')) 104 Blank() 105 Image($rawfile('icon/ic_next.svg')) 106 .width($r('app.float.settings_item_next_image_width')) 107 .height($r('app.float.settings_item_next_image_height')) 108 } 109 .width('100%') 110 .height('100%') 111 .margin({ left: '4vp' }) 112 } 113 .layoutWeight(1) 114 .height('100%') 115 }.height('48vp') 116 .width('100%') 117 .onClick(() => { 118 //Go to Select Contact 119 this.mTransmitMsgCtrl.jumpToSelectContacts(); 120 }) 121 122 //recent 123 Flex() { 124 Row() { 125 Text($r('app.string.recently')) 126 .fontSize('16fp') 127 .fontColor($r('sys.color.ohos_id_color_text_primary')) 128 }.height('48vp') 129 } 130 131 List() { 132 LazyForEach(this.mTransmitMsgCtrl.transmitMsgDataSource, (item, index) => { 133 ListItem() { 134 Row() { 135 //avatar 136 if (item.conversation.photoFirstName === '') { 137 Image($rawfile('icon/ic_user_portrait.svg')) 138 .objectFit(ImageFit.Fill) 139 .width('40vp') 140 .height('40vp') 141 .clip(new Circle({ width: '40vp', height: '40vp' })) 142 .backgroundColor(item.conversation.portraitColor) 143 } else { 144 Text(item.conversation.photoFirstName) 145 .fontSize('30vp') 146 .fontWeight(FontWeight.Bold) 147 .fontColor(Color.White) 148 .height('40vp') 149 .width('40vp') 150 .textAlign(TextAlign.Center) 151 .clip(new Circle({ width: '40vp', height: '40vp' })) 152 .backgroundColor(item.conversation.portraitColor) 153 } 154 Text(item.conversation.name !== '' ? item.conversation.name : item.conversation.telephone) 155 .fontSize('16vp') 156 .fontWeight(FontWeight.Bold) 157 .margin({ left: 16 }) 158 } 159 .width('100%') 160 .height(64) 161 } 162 .onClick(() => { 163 this.mTransmitMsgCtrl.clickSendMessage(item) 164 this.delDialogController.open(); 165 }) 166 }, item => item.conversation.threadId.toString()) 167 } 168 .divider({ 169 strokeWidth: 1, 170 startMargin: 56, 171 endMargin: 0 172 }) 173 }.width('100%') 174 .height('100%') 175 .useSizeType({ 176 xs: { span: 4, offset: 0 }, sm: { span: 4, offset: 0 }, 177 md: { span: 12, offset: 0 }, lg: { span: 12, offset: 0 } 178 }) 179 } 180 } 181}