• 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  private dailHDImg = [$r("app.media.ic_contact_call_1_hd_dial"), $r("app.media.ic_contact_call_2_hd_dial")]
29
30  dialClick(slot: number) {
31    this.mPresenter.callBtnClick = true;
32    if (this.tele_number.length > 0) {
33      this.mPresenter.dialing(this.mPresenter.all_number, {
34        accountId: slot,
35      });
36      AppStorage.SetOrCreate("tele_number", '');
37      this.mPresenter.all_number = '';
38    }
39    this.mPresenter.callBtnClick = false;
40  }
41
42  build() {
43    Row() {
44      ForEach(this.simNames, (item, index) => {
45        //DailButton for voLte
46        Row() {
47          Image(this.voLteRegStates[index] ? this.dailHDImg[index] : this.dailImg[index])
48            .width("18vp")
49            .height("18vp")
50            .onError((event => {
51              HiLog.e(TAG, "Sim:" + index + " Image onError" + JSON.stringify(event))
52            }))
53
54          Text(this.simNames[index])
55            .fontColor($r("sys.color.ohos_id_color_primary_contrary"))
56            .fontSize("16fp")
57            .maxLines(1)
58            .textOverflow({ overflow: TextOverflow.Ellipsis })
59        }
60        .justifyContent(FlexAlign.Center)
61        .alignItems(VerticalAlign.Center)
62        .width('100vp')
63        .height("48vp")
64        .backgroundColor($r('sys.color.ohos_id_color_connected'))
65        .onClick(() => {
66          this.dialClick(index);
67        })
68        .borderRadius('24vp')
69      })
70    }.width('100%')
71    .alignItems(VerticalAlign.Center)
72    .justifyContent(FlexAlign.SpaceBetween)
73  }
74}