18779efd5Sopenharmony_ci/**
28779efd5Sopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd.
38779efd5Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
48779efd5Sopenharmony_ci * you may not use this file except in compliance with the License.
58779efd5Sopenharmony_ci * You may obtain a copy of the License at
68779efd5Sopenharmony_ci *
78779efd5Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
88779efd5Sopenharmony_ci *
98779efd5Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
108779efd5Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
118779efd5Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
128779efd5Sopenharmony_ci * See the License for the specific language governing permissions and
138779efd5Sopenharmony_ci * limitations under the License.
148779efd5Sopenharmony_ci */
158779efd5Sopenharmony_ci
168779efd5Sopenharmony_ciimport DialerPresenter from '../../presenter/dialer/DialerPresenter';
178779efd5Sopenharmony_ciimport { HiLog } from '../../../../../../common'
188779efd5Sopenharmony_ci
198779efd5Sopenharmony_ciconst TAG = 'MutiDialerButtonView';
208779efd5Sopenharmony_ci
218779efd5Sopenharmony_ci@Component
228779efd5Sopenharmony_ciexport struct MutiDialerButtonView {
238779efd5Sopenharmony_ci  @Link mPresenter: DialerPresenter;
248779efd5Sopenharmony_ci  @StorageLink('tele_number') tele_number: string = '';
258779efd5Sopenharmony_ci  @StorageLink('spnList') simNames: Array<string | Resource> = ['', ''];
268779efd5Sopenharmony_ci  @StorageLink('voLteRegStates') voLteRegStates: boolean[] = [false, false];
278779efd5Sopenharmony_ci  private dailImg = [$r('app.media.ic_public_phone1_filled'), $r('app.media.ic_public_phone2_filled')]
288779efd5Sopenharmony_ci  private dailHDImg = [$r('app.media.ic_contact_call_1_hd_dial'), $r('app.media.ic_contact_call_2_hd_dial')]
298779efd5Sopenharmony_ci
308779efd5Sopenharmony_ci  dialClick(slot: number) {
318779efd5Sopenharmony_ci    this.mPresenter.callBtnClick = true;
328779efd5Sopenharmony_ci    if (this.tele_number.length > 0) {
338779efd5Sopenharmony_ci      this.mPresenter.dialing(this.mPresenter.all_number, {
348779efd5Sopenharmony_ci        accountId: slot,
358779efd5Sopenharmony_ci      });
368779efd5Sopenharmony_ci      AppStorage.SetOrCreate('tele_number', '');
378779efd5Sopenharmony_ci      this.mPresenter.all_number = '';
388779efd5Sopenharmony_ci    }
398779efd5Sopenharmony_ci    this.mPresenter.callBtnClick = false;
408779efd5Sopenharmony_ci  }
418779efd5Sopenharmony_ci
428779efd5Sopenharmony_ci  build() {
438779efd5Sopenharmony_ci    Row() {
448779efd5Sopenharmony_ci      ForEach(this.simNames, (item, index) => {
458779efd5Sopenharmony_ci        //DailButton for voLte
468779efd5Sopenharmony_ci        Row() {
478779efd5Sopenharmony_ci          Image(this.voLteRegStates[index] ? this.dailHDImg[index] : this.dailImg[index])
488779efd5Sopenharmony_ci            .width('18vp')
498779efd5Sopenharmony_ci            .height('18vp')
508779efd5Sopenharmony_ci            .onError((event => {
518779efd5Sopenharmony_ci              HiLog.e(TAG, 'Sim:' + index + ' Image onError' + JSON.stringify(event))
528779efd5Sopenharmony_ci            }))
538779efd5Sopenharmony_ci
548779efd5Sopenharmony_ci          Text(this.simNames[index])
558779efd5Sopenharmony_ci            .fontColor($r('sys.color.ohos_id_color_primary_contrary'))
568779efd5Sopenharmony_ci            .fontSize('16fp')
578779efd5Sopenharmony_ci            .maxLines(1)
588779efd5Sopenharmony_ci            .textOverflow({ overflow: TextOverflow.Ellipsis })
598779efd5Sopenharmony_ci        }
608779efd5Sopenharmony_ci        .justifyContent(FlexAlign.Center)
618779efd5Sopenharmony_ci        .alignItems(VerticalAlign.Center)
628779efd5Sopenharmony_ci        .width('100vp')
638779efd5Sopenharmony_ci        .height('48vp')
648779efd5Sopenharmony_ci        .backgroundColor($r('sys.color.ohos_id_color_connected'))
658779efd5Sopenharmony_ci        .onClick(() => {
668779efd5Sopenharmony_ci          this.dialClick(index);
678779efd5Sopenharmony_ci        })
688779efd5Sopenharmony_ci        .borderRadius('24vp')
698779efd5Sopenharmony_ci      })
708779efd5Sopenharmony_ci    }.width('100%')
718779efd5Sopenharmony_ci    .alignItems(VerticalAlign.Center)
728779efd5Sopenharmony_ci    .justifyContent(FlexAlign.SpaceBetween)
738779efd5Sopenharmony_ci  }
748779efd5Sopenharmony_ci}