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 MmsPreferences from "../utils/MmsPreferences"; 16import common from "../data/commonData"; 17 18/** 19 * Custom multi-SimCard pop-up menu 20 */ 21@Component 22export struct MultiSimCardMenu { 23 @Prop slotId: number; 24 private spnOfSim1: string = MmsPreferences.getInstance().getSpnOfSim1(); 25 private spnOfSim2: string = MmsPreferences.getInstance().getTelephoneNumberOfSim2(); 26 private telephoneNumberOfSim1: string = MmsPreferences.getInstance().getTelephoneNumberOfSim1(); 27 private telephoneNumberOfSim2: string = MmsPreferences.getInstance().getTelephoneNumberOfSim2(); 28 29 @Builder PopupBuilder() { 30 Column() { 31 List() { 32 ListItem() { 33 Button({ type: ButtonType.Normal }) { 34 Column() { 35 Row() { 36 Image($rawfile('icon/icon_mms_sim_card_1.svg')) 37 .width(15) 38 .height(18) 39 Text(this.spnOfSim1) 40 .fontSize('16vp') 41 .fontWeight(FontWeight.Medium) 42 .fontColor($r("sys.color.ohos_id_color_text_primary")) 43 .padding({ left: 2 }) 44 } 45 Text(this.telephoneNumberOfSim1) 46 .padding({ left: 19, top: 2 }) 47 .fontSize('14vp') 48 .fontWeight(FontWeight.Regular) 49 .fontColor($r("sys.color.ohos_id_color_text_secondary")) 50 } 51 .justifyContent(FlexAlign.Center) 52 .alignItems(HorizontalAlign.Start) 53 .padding({ left: 16 }) 54 .width('100%') 55 } 56 .backgroundColor($r("sys.color.ohos_id_color_background_transparent")) 57 .width('100%') 58 .height('64vp') 59 .onClick(() => { 60 this.slotId = common.int.SIM_ONE; 61 MmsPreferences.getInstance().setValueToMap(common.string.KEY_OF_SELECTED_SLOTID, this.slotId); 62 }) 63 } 64 ListItem() { 65 Button({ type: ButtonType.Normal }) { 66 Column() { 67 Row() { 68 Image($rawfile('icon/icon_mms_sim_card_2.svg')) 69 .width(15) 70 .height(18) 71 Text(this.spnOfSim2) 72 .fontSize('16vp') 73 .fontWeight(FontWeight.Medium) 74 .fontColor($r("sys.color.ohos_id_color_text_primary")) 75 .padding({ left: 2 }) 76 } 77 Text(this.telephoneNumberOfSim2) 78 .padding({ left: 19, top: 2 }) 79 .fontSize('14vp') 80 .fontWeight(FontWeight.Regular) 81 .fontColor($r("sys.color.ohos_id_color_text_secondary")) 82 } 83 .justifyContent(FlexAlign.Center) 84 .alignItems(HorizontalAlign.Start) 85 .padding({ left: 16 }) 86 .width('100%') 87 } 88 .backgroundColor($r("sys.color.ohos_id_color_background_transparent")) 89 .width('100%') 90 .height('64vp') 91 .onClick(() => { 92 this.slotId = common.int.SIM_TWO; 93 MmsPreferences.getInstance().setValueToMap(common.string.KEY_OF_SELECTED_SLOTID, this.slotId); 94 }) 95 } 96 } 97 .listDirection(Axis.Vertical) 98 .divider({ 99 strokeWidth: 0.5, 100 color: $r("sys.color.ohos_id_color_list_separator"), 101 startMargin: 17, 102 endMargin: 17 103 }) 104 .edgeEffect(EdgeEffect.Spring) 105 .chainAnimation(false) 106 .width('170vp') 107 .height('136vp') 108 .borderRadius(16) 109 } 110 } 111 112 build() { 113 Row() { 114 Image(this.slotId == 0 ? $rawfile("icon/ic_message_card1.svg") : $rawfile("icon/ic_message_card2.svg")) 115 .width(24) 116 .height(24) 117 Image($rawfile("icon/ic_public_spinner.svg")) 118 .width(12) 119 .height(24) 120 } 121 .size({ width: 36, height: 24 }) 122 .bindMenu(this.PopupBuilder) 123 .onClick(() => { 124 this.spnOfSim1 = MmsPreferences.getInstance().getSpnOfSim1(); 125 this.spnOfSim2 = MmsPreferences.getInstance().getSpnOfSim2(); 126 this.telephoneNumberOfSim1 = MmsPreferences.getInstance().getTelephoneNumberOfSim1(); 127 this.telephoneNumberOfSim2 = MmsPreferences.getInstance().getTelephoneNumberOfSim2(); 128 }) 129 } 130}