1048147e0Sopenharmony_ci/** 2048147e0Sopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd. 3048147e0Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4048147e0Sopenharmony_ci * you may not use this file except in compliance with the License. 5048147e0Sopenharmony_ci * You may obtain a copy of the License at 6048147e0Sopenharmony_ci * 7048147e0Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8048147e0Sopenharmony_ci * 9048147e0Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10048147e0Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11048147e0Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12048147e0Sopenharmony_ci * See the License for the specific language governing permissions and 13048147e0Sopenharmony_ci * limitations under the License. 14048147e0Sopenharmony_ci */ 15048147e0Sopenharmony_ciimport TransmitMsgController from './transmitMsgController'; 16048147e0Sopenharmony_ciimport DeviceUtil from '../../utils/DeviceUtil'; 17048147e0Sopenharmony_ciimport router from '@system.router'; 18048147e0Sopenharmony_ciimport { TransmitMsgDialog } from '../../views/MmsDialogs'; 19048147e0Sopenharmony_ciimport WantUtil from '../../utils/WantUtil'; 20048147e0Sopenharmony_ci 21048147e0Sopenharmony_ci@Entry 22048147e0Sopenharmony_ci@Component 23048147e0Sopenharmony_ciexport default struct TransmitMsg { 24048147e0Sopenharmony_ci @State mTransmitMsgCtrl: TransmitMsgController = TransmitMsgController.getInstance(); 25048147e0Sopenharmony_ci @State gridColumns: number = DeviceUtil.isTablet() ? 12 : 4; 26048147e0Sopenharmony_ci @State gridSizeType: SizeType = DeviceUtil.isTablet() ? SizeType.LG : SizeType.SM; 27048147e0Sopenharmony_ci @State gridGutter: string = '24vp'; 28048147e0Sopenharmony_ci @State gridMargin: string = '24vp'; 29048147e0Sopenharmony_ci private dialogAlignment: DialogAlignment = DeviceUtil.isTablet() ? DialogAlignment.Center : DialogAlignment.Bottom; 30048147e0Sopenharmony_ci private dialogOffset: Offset = DeviceUtil.isTablet() ? { dx: 0, dy: 0 } : { dx: 0, dy: -12 }; 31048147e0Sopenharmony_ci delDialogController: CustomDialogController = new CustomDialogController({ 32048147e0Sopenharmony_ci builder: TransmitMsgDialog({ 33048147e0Sopenharmony_ci cancel: () => { 34048147e0Sopenharmony_ci 35048147e0Sopenharmony_ci }, 36048147e0Sopenharmony_ci confirm: () => { 37048147e0Sopenharmony_ci this.mTransmitMsgCtrl.transmit() 38048147e0Sopenharmony_ci }, 39048147e0Sopenharmony_ci msg: this.mTransmitMsgCtrl.dialogMsg, 40048147e0Sopenharmony_ci }), 41048147e0Sopenharmony_ci autoCancel: false, 42048147e0Sopenharmony_ci alignment: this.dialogAlignment, 43048147e0Sopenharmony_ci offset: this.dialogOffset, 44048147e0Sopenharmony_ci }); 45048147e0Sopenharmony_ci 46048147e0Sopenharmony_ci aboutToAppear() { 47048147e0Sopenharmony_ci this.mTransmitMsgCtrl.onInit(); 48048147e0Sopenharmony_ci this.mTransmitMsgCtrl.onShow(); 49048147e0Sopenharmony_ci } 50048147e0Sopenharmony_ci 51048147e0Sopenharmony_ci aboutToDisappear() { 52048147e0Sopenharmony_ci this.delDialogController = null; 53048147e0Sopenharmony_ci } 54048147e0Sopenharmony_ci 55048147e0Sopenharmony_ci onPageShow() { 56048147e0Sopenharmony_ci WantUtil.getWant(); 57048147e0Sopenharmony_ci if (this.mTransmitMsgCtrl.DialogShow) { 58048147e0Sopenharmony_ci this.delDialogController.open(); 59048147e0Sopenharmony_ci } 60048147e0Sopenharmony_ci } 61048147e0Sopenharmony_ci 62048147e0Sopenharmony_ci onPageHide() { 63048147e0Sopenharmony_ci } 64048147e0Sopenharmony_ci 65048147e0Sopenharmony_ci onBackPress() { 66048147e0Sopenharmony_ci } 67048147e0Sopenharmony_ci 68048147e0Sopenharmony_ci build() { 69048147e0Sopenharmony_ci GridContainer({ 70048147e0Sopenharmony_ci columns: this.gridColumns, 71048147e0Sopenharmony_ci sizeType: this.gridSizeType, 72048147e0Sopenharmony_ci gutter: this.gridGutter, 73048147e0Sopenharmony_ci margin: this.gridMargin 74048147e0Sopenharmony_ci }) { 75048147e0Sopenharmony_ci Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Start, alignItems: ItemAlign.Start }) { 76048147e0Sopenharmony_ci //Notification information 77048147e0Sopenharmony_ci Flex() { 78048147e0Sopenharmony_ci Row() { 79048147e0Sopenharmony_ci Image($rawfile('icon/ic_public_cancel.svg')) 80048147e0Sopenharmony_ci .width(24) 81048147e0Sopenharmony_ci .height(24) 82048147e0Sopenharmony_ci .onClick(() => { 83048147e0Sopenharmony_ci // Click Back to return to the unselected SMS state. 84048147e0Sopenharmony_ci router.back(); 85048147e0Sopenharmony_ci }) 86048147e0Sopenharmony_ci Text($r('app.string.transmitHeadText')) 87048147e0Sopenharmony_ci .margin({ left: 16 }) 88048147e0Sopenharmony_ci .fontSize(20) 89048147e0Sopenharmony_ci .fontColor($r('sys.color.ohos_id_color_text_primary')) 90048147e0Sopenharmony_ci .fontWeight(FontWeight.Bold) 91048147e0Sopenharmony_ci } 92048147e0Sopenharmony_ci .alignItems(VerticalAlign.Center) 93048147e0Sopenharmony_ci .width('100%') 94048147e0Sopenharmony_ci .height(56) 95048147e0Sopenharmony_ci } 96048147e0Sopenharmony_ci 97048147e0Sopenharmony_ci //Select Contact 98048147e0Sopenharmony_ci Flex() { 99048147e0Sopenharmony_ci Column() { 100048147e0Sopenharmony_ci Row() { 101048147e0Sopenharmony_ci Text($r('app.string.selectContacts')) 102048147e0Sopenharmony_ci .fontSize('16fp') 103048147e0Sopenharmony_ci .fontColor($r('sys.color.ohos_id_color_text_primary')) 104048147e0Sopenharmony_ci Blank() 105048147e0Sopenharmony_ci Image($rawfile('icon/ic_next.svg')) 106048147e0Sopenharmony_ci .width($r('app.float.settings_item_next_image_width')) 107048147e0Sopenharmony_ci .height($r('app.float.settings_item_next_image_height')) 108048147e0Sopenharmony_ci } 109048147e0Sopenharmony_ci .width('100%') 110048147e0Sopenharmony_ci .height('100%') 111048147e0Sopenharmony_ci .margin({ left: '4vp' }) 112048147e0Sopenharmony_ci } 113048147e0Sopenharmony_ci .layoutWeight(1) 114048147e0Sopenharmony_ci .height('100%') 115048147e0Sopenharmony_ci }.height('48vp') 116048147e0Sopenharmony_ci .width('100%') 117048147e0Sopenharmony_ci .onClick(() => { 118048147e0Sopenharmony_ci //Go to Select Contact 119048147e0Sopenharmony_ci this.mTransmitMsgCtrl.jumpToSelectContacts(); 120048147e0Sopenharmony_ci }) 121048147e0Sopenharmony_ci 122048147e0Sopenharmony_ci //recent 123048147e0Sopenharmony_ci Flex() { 124048147e0Sopenharmony_ci Row() { 125048147e0Sopenharmony_ci Text($r('app.string.recently')) 126048147e0Sopenharmony_ci .fontSize('16fp') 127048147e0Sopenharmony_ci .fontColor($r('sys.color.ohos_id_color_text_primary')) 128048147e0Sopenharmony_ci }.height('48vp') 129048147e0Sopenharmony_ci } 130048147e0Sopenharmony_ci 131048147e0Sopenharmony_ci List() { 132048147e0Sopenharmony_ci LazyForEach(this.mTransmitMsgCtrl.transmitMsgDataSource, (item, index) => { 133048147e0Sopenharmony_ci ListItem() { 134048147e0Sopenharmony_ci Row() { 135048147e0Sopenharmony_ci //avatar 136048147e0Sopenharmony_ci if (item.conversation.photoFirstName === '') { 137048147e0Sopenharmony_ci Image($rawfile('icon/ic_user_portrait.svg')) 138048147e0Sopenharmony_ci .objectFit(ImageFit.Fill) 139048147e0Sopenharmony_ci .width('40vp') 140048147e0Sopenharmony_ci .height('40vp') 141048147e0Sopenharmony_ci .clip(new Circle({ width: '40vp', height: '40vp' })) 142048147e0Sopenharmony_ci .backgroundColor(item.conversation.portraitColor) 143048147e0Sopenharmony_ci } else { 144048147e0Sopenharmony_ci Text(item.conversation.photoFirstName) 145048147e0Sopenharmony_ci .fontSize('30vp') 146048147e0Sopenharmony_ci .fontWeight(FontWeight.Bold) 147048147e0Sopenharmony_ci .fontColor(Color.White) 148048147e0Sopenharmony_ci .height('40vp') 149048147e0Sopenharmony_ci .width('40vp') 150048147e0Sopenharmony_ci .textAlign(TextAlign.Center) 151048147e0Sopenharmony_ci .clip(new Circle({ width: '40vp', height: '40vp' })) 152048147e0Sopenharmony_ci .backgroundColor(item.conversation.portraitColor) 153048147e0Sopenharmony_ci } 154048147e0Sopenharmony_ci Text(item.conversation.name !== '' ? item.conversation.name : item.conversation.telephone) 155048147e0Sopenharmony_ci .fontSize('16vp') 156048147e0Sopenharmony_ci .fontWeight(FontWeight.Bold) 157048147e0Sopenharmony_ci .margin({ left: 16 }) 158048147e0Sopenharmony_ci } 159048147e0Sopenharmony_ci .width('100%') 160048147e0Sopenharmony_ci .height(64) 161048147e0Sopenharmony_ci } 162048147e0Sopenharmony_ci .onClick(() => { 163048147e0Sopenharmony_ci this.mTransmitMsgCtrl.clickSendMessage(item) 164048147e0Sopenharmony_ci this.delDialogController.open(); 165048147e0Sopenharmony_ci }) 166048147e0Sopenharmony_ci }, item => item.conversation.threadId.toString()) 167048147e0Sopenharmony_ci } 168048147e0Sopenharmony_ci .divider({ 169048147e0Sopenharmony_ci strokeWidth: 1, 170048147e0Sopenharmony_ci startMargin: 56, 171048147e0Sopenharmony_ci endMargin: 0 172048147e0Sopenharmony_ci }) 173048147e0Sopenharmony_ci }.width('100%') 174048147e0Sopenharmony_ci .height('100%') 175048147e0Sopenharmony_ci .useSizeType({ 176048147e0Sopenharmony_ci xs: { span: 4, offset: 0 }, sm: { span: 4, offset: 0 }, 177048147e0Sopenharmony_ci md: { span: 12, offset: 0 }, lg: { span: 12, offset: 0 } 178048147e0Sopenharmony_ci }) 179048147e0Sopenharmony_ci } 180048147e0Sopenharmony_ci } 181048147e0Sopenharmony_ci}