• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 */
15
16import DialerPresenter from '../../presenter/dialer/DialerPresenter';
17import { HiLog } from "../../../../../../common"
18
19const TAG = "MutiDialerButtonView";
20
21@Component
22export struct MutiDialerButtonView {
23  @Link mPresenter: DialerPresenter;
24  @StorageLink("tele_number") tele_number: string = "";
25  @StorageLink("spnList") simNames: Array<string | Resource> = ["", ""];
26  @StorageLink("voLteRegStates") voLteRegStates: boolean[] = [false, false];
27  private dailImg = [$r("app.media.ic_public_phone1_filled"), $r("app.media.ic_public_phone2_filled")]
28
29  dialClick(slot: number) {
30    this.mPresenter.callBtnClick = true;
31    if (this.tele_number.length > 0) {
32      this.mPresenter.dialing(this.mPresenter.all_number, {
33        accountId: slot,
34      });
35      AppStorage.SetOrCreate("tele_number", '');
36      this.mPresenter.all_number = '';
37    }
38    this.mPresenter.callBtnClick = false;
39  }
40
41  build() {
42    Row() {
43      ForEach(this.simNames, (item, index) => {
44        //DailButton for voLte
45        Row() {
46          Column() {
47            Image(this.dailImg[index])
48              .width(this.voLteRegStates[index] ? "14vp" : "18vp")
49              .height(this.voLteRegStates[index] ? "14vp" : "18vp")
50              .onError((event => {
51                HiLog.e(TAG, "Sim:" + index + " Image onError" + JSON.stringify(event))
52              }))
53            Image($r('app.media.ic_dail_button_volte'))
54              .onError((event => {
55                HiLog.e(TAG, "ic_dail_button_volte Image onError" + JSON.stringify(event))
56              }))
57              .height('10vp')
58              .width('16vp')
59              .visibility(this.voLteRegStates[index] ? Visibility.Visible : Visibility.None)
60          }.width("18vp")
61          .justifyContent(FlexAlign.Center)
62          .alignItems(HorizontalAlign.Center)
63
64          Text(this.simNames[index])
65            .fontColor($r("sys.color.ohos_id_color_primary_contrary"))
66            .fontSize("16fp")
67            .maxLines(1)
68            .textOverflow({ overflow: TextOverflow.Ellipsis })
69        }
70        .justifyContent(FlexAlign.Center)
71        .alignItems(VerticalAlign.Center)
72        .width('100vp')
73        .height("48vp")
74        .backgroundColor($r('sys.color.ohos_id_color_connected'))
75        .onClick(() => {
76          this.dialClick(index);
77        })
78        .borderRadius('24vp')
79      })
80    }.width('100%')
81    .alignItems(VerticalAlign.Center)
82    .justifyContent(FlexAlign.SpaceBetween)
83  }
84}