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 } 53 54 onPageShow() { 55 WantUtil.getWant(); 56 if(this.mTransmitMsgCtrl.DialogShow){ 57 this.delDialogController.open(); 58 } 59 } 60 61 onPageHide() { 62 } 63 64 onBackPress() { 65 } 66 67 build() { 68 GridContainer({ 69 columns: this.gridColumns, 70 sizeType: this.gridSizeType, 71 gutter: this.gridGutter, 72 margin: this.gridMargin 73 }) { 74 Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Start, alignItems: ItemAlign.Start }) { 75 //Notification information 76 Flex() { 77 Row() { 78 Image($rawfile("icon/ic_public_cancel.svg")) 79 .width(24) 80 .height(24) 81 .onClick(() => { 82 // Click Back to return to the unselected SMS state. 83 router.back(); 84 }) 85 Text($r("app.string.transmitHeadText")) 86 .margin({ left: 16 }) 87 .fontSize(20) 88 .fontColor($r("sys.color.ohos_id_color_text_primary")) 89 .fontWeight(FontWeight.Bold) 90 } 91 .alignItems(VerticalAlign.Center) 92 .width("100%") 93 .height(56) 94 } 95 96 //Select Contact 97 Flex(){ 98 Column(){ 99 Row() { 100 Text($r("app.string.selectContacts")) 101 .fontSize("16fp") 102 .fontColor($r("sys.color.ohos_id_color_text_primary")) 103 Blank() 104 Image($rawfile("icon/ic_next.svg")) 105 .width($r("app.float.settings_item_next_image_width")) 106 .height($r("app.float.settings_item_next_image_height")) 107 } 108 .width("100%") 109 .height("100%") 110 .margin({ left: "4vp" }) 111 } 112 .layoutWeight(1) 113 .height("100%") 114 }.height("48vp") 115 .width("100%") 116 .onClick(() => { 117 //Go to Select Contact 118 this.mTransmitMsgCtrl.jumpToSelectContacts(); 119 }) 120 121 //recent 122 Flex() { 123 Row() { 124 Text($r("app.string.recently")) 125 .fontSize("16fp") 126 .fontColor($r("sys.color.ohos_id_color_text_primary")) 127 }.height("48vp") 128 } 129 List() { 130 LazyForEach(this.mTransmitMsgCtrl.transmitMsgDataSource, (item, index) => { 131 ListItem() { 132 Row() { 133 //avatar 134 if(item.conversation.photoFirstName === '') { 135 Image($rawfile("icon/ic_user_portrait.svg")) 136 .objectFit(ImageFit.Fill) 137 .width("40vp") 138 .height("40vp") 139 .clip(new Circle({ width: "40vp", height: "40vp" })) 140 .backgroundColor(item.conversation.portraitColor) 141 } else { 142 Text(item.conversation.photoFirstName) 143 .fontSize("30vp") 144 .fontWeight(FontWeight.Bold) 145 .fontColor(Color.White) 146 .height("40vp") 147 .width("40vp") 148 .textAlign(TextAlign.Center) 149 .clip(new Circle({ width: "40vp", height: "40vp" })) 150 .backgroundColor(item.conversation.portraitColor) 151 } 152 Text(item.conversation.name !== '' ? item.conversation.name : item.conversation.telephone) 153 .fontSize("16vp") 154 .fontWeight(FontWeight.Bold) 155 .margin({ left: 16 }) 156 } 157 .width("100%") 158 .height(64) 159 } 160 .onClick( () => { 161 this.mTransmitMsgCtrl.clickSendMessage(item) 162 this.delDialogController.open(); 163 }) 164 }, item => item.conversation.threadId.toString()) 165 } 166 .divider({ 167 strokeWidth: 1, 168 startMargin: 56, 169 endMargin: 0 170 }) 171 }.width("100%") 172 .height("100%") 173 .useSizeType({ 174 xs: { span: 4, offset: 0 }, sm: { span: 4, offset: 0 }, 175 md: { span: 12, offset: 0 }, lg: { span: 12, offset: 0 } 176 }) 177 } 178 } 179}