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