• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// @ts-nocheck
2/**
3 * Copyright (c) 2022 Huawei Device Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16import TransmitMsgController from "./transmitMsgController";
17import DeviceUtil from "../../utils/DeviceUtil";
18import router from "@system.router";
19import { TransmitMsgDialog } from "../../views/MmsDialogs";
20import WantUtil from "../../utils/WantUtil";
21
22@Entry
23@Component
24export default struct TransmitMsg {
25    @State mTransmitMsgCtrl: TransmitMsgController = TransmitMsgController.getInstance();
26    @State gridColumns: number = DeviceUtil.isTablet() ? 12 : 4;
27    @State gridSizeType: SizeType = DeviceUtil.isTablet() ? SizeType.LG : SizeType.SM;
28    @State gridGutter: string = "24vp";
29    @State gridMargin: string = "24vp";
30    private dialogAlignment: DialogAlignment = DeviceUtil.isTablet() ? DialogAlignment.Center : DialogAlignment.Bottom;
31    private dialogOffset: Offset = DeviceUtil.isTablet() ? { dx: 0, dy: 0 } : { dx: 0, dy: -12 };
32    delDialogController: CustomDialogController = new CustomDialogController({
33        builder: TransmitMsgDialog({
34            cancel: () => {
35
36            },
37            confirm: () => {
38                this.mTransmitMsgCtrl.transmit()
39            },
40            msg: this.mTransmitMsgCtrl.dialogMsg,
41        }),
42        autoCancel: false,
43        alignment: this.dialogAlignment,
44        offset: this.dialogOffset,
45        changeValue: (item) => {
46            this.mTransmitMsgCtrl.changeValue(item)
47        },
48        clickChecked: (isOn: boolean) => {
49            this.mConListCtrl.clickChecked(isOn)
50        }
51    });
52
53    aboutToAppear() {
54        this.mTransmitMsgCtrl.onInit();
55        this.mTransmitMsgCtrl.onShow();
56    }
57
58    aboutToDisappear() {
59    }
60
61    onPageShow() {
62        WantUtil.getWant();
63        if(this.mTransmitMsgCtrl.DialogShow){
64            this.delDialogController.open();
65        }
66    }
67
68    onPageHide() {
69    }
70
71    onBackPress() {
72    }
73
74    build() {
75        GridContainer({
76            columns: this.gridColumns,
77            sizeType: this.gridSizeType,
78            gutter: this.gridGutter,
79            margin: this.gridMargin
80        }) {
81            Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Start, alignItems: ItemAlign.Start }) {
82                //Notification information
83                Flex() {
84                    Row() {
85                        Image($rawfile("icon/ic_public_cancel.svg"))
86                            .width(24)
87                            .height(24)
88                            .onClick(() => {
89                                // Click Back to return to the unselected SMS state.
90                                router.back();
91                            })
92                        Text($r("app.string.transmitHeadText"))
93                            .margin({ left: 16 })
94                            .fontSize(20)
95                            .fontColor($r("sys.color.ohos_id_color_text_primary"))
96                            .fontWeight(FontWeight.Bold)
97                    }
98                    .alignItems(VerticalAlign.Center)
99                    .width("100%")
100                    .height(56)
101                }
102
103                //Select Contact
104                Flex(){
105                    Column(){
106                        Row() {
107                            Text($r("app.string.selectContracts"))
108                                .fontSize("16fp")
109                                .fontColor($r("sys.color.ohos_id_color_text_primary"))
110                            Blank()
111                                Image($rawfile("icon/ic_next.svg"))
112                                    .width($r("app.float.settings_item_next_image_width"))
113                                    .height($r("app.float.settings_item_next_image_height"))
114                        }
115                        .width("100%")
116                        .height("100%")
117                        .margin({ left: "4vp" })
118                    }
119                    .layoutWeight(1)
120                    .height("100%")
121                }.height("48vp")
122                .width("100%")
123                .onClick(() => {
124                    //Go to Select Contact
125                    this.mTransmitMsgCtrl.jumpToSelectContracts()
126                })
127
128                //recent
129                Flex() {
130                    Row() {
131                        Text($r("app.string.recently"))
132                            .fontSize("16fp")
133                            .fontColor($r("sys.color.ohos_id_color_text_primary"))
134                    }.height("48vp")
135                }
136                List() {
137                    LazyForEach(this.mTransmitMsgCtrl.transmitMsgDataSource, (item, index) => {
138                        ListItem() {
139                            Row() {
140                                //avatar
141                                if(item.conversation.photoFirstName === '') {
142                                    Image($rawfile("icon/ic_user_portrait.svg"))
143                                        .objectFit(ImageFit.Fill)
144                                        .width("40vp")
145                                        .height("40vp")
146                                        .clip(new Circle({ width: "40vp", height: "40vp" }))
147                                        .backgroundColor(item.conversation.portraitColor)
148                                } else {
149                                    Text(item.conversation.photoFirstName)
150                                        .fontSize("30vp")
151                                        .fontWeight(FontWeight.Bold)
152                                        .fontColor(Color.White)
153                                        .height("40vp")
154                                        .width("40vp")
155                                        .textAlign(TextAlign.Center)
156                                        .clip(new Circle({ width: "40vp", height: "40vp" }))
157                                        .backgroundColor(item.conversation.portraitColor)
158                                }
159                                Text(item.conversation.name !== '' ? item.conversation.name : item.conversation.telephone)
160                                    .fontSize("16vp")
161                                    .fontWeight(FontWeight.Bold)
162                                    .margin({ left: 16 })
163                            }
164                            .width("100%")
165                            .height(64)
166                        }
167                        .onClick( () => {
168                            this.mTransmitMsgCtrl.clickSendMessage(item)
169                            this.delDialogController.open();
170                        })
171                    }, item => item.conversation.threadId.toString())
172                }
173                .divider({
174                    strokeWidth: 1,
175                    startMargin: 56,
176                    endMargin: 0
177                })
178            }.width("100%")
179            .height("100%")
180            .useSizeType({
181                xs: { span: 4, offset: 0 }, sm: { span: 4, offset: 0 },
182                md: { span: 12, offset: 0 }, lg: { span: 12, offset: 0 }
183            })
184        }
185    }
186}