• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/**
2 * Copyright (c) 2022-2024 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 { WidthPercent, ConfigValue } from '../common/util/ConfigData';
17import HeadComponent from '../common/component/headComponent';
18import CmShowAppCredPresenter from '../presenter/CmShowAppCredPresenter';
19import CMFaPresenter from '../presenter/CmFaPresenter';
20import { GlobalContext } from '../common/GlobalContext';
21import { CredentialAbstractVo } from '../model/CertManagerVo/CredentialAbstractVo';
22import { AppAuthorVo } from '../model/CertManagerVo/AppAuthorVo';
23import router from '@ohos.router';
24import { CustomContentDialog } from '@ohos.arkui.advanced.Dialog';
25import CmShowSysCredPresenter from '../presenter/CmShowSysCredPresenter';
26import { NavEntryKey } from '../common/NavEntryKey';
27import { CredSystemDetailParam } from './picker/CredSystemDetailPage';
28import { CredUserDetailParam } from './picker/CredUserDetailPage';
29
30const COPIES_NUM: number = 12;
31
32@Component
33export struct DialogComponent {
34  @Link uidItem: CmShowAppCredPresenter;
35  private appName: string = '';
36  private appImage: string = '';
37  private indexNum: number = 0;
38
39  onChanged?: () => void;
40
41  build() {
42    Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
43      Row() {
44        Image(this.appImage)
45          .width($r('app.float.credentials_app_image_wh'))
46          .height($r('app.float.credentials_app_image_hg'))
47
48        Text(this.appName)
49          .fontSize($r('sys.float.ohos_id_text_size_body2'))
50          .fontColor($r('sys.color.ohos_id_color_text_primary'))
51          .fontWeight(FontWeight.Medium)
52          .margin({ left: $r('app.float.credentials_app_name_margin') })
53      }
54      .alignItems(VerticalAlign.Center)
55
56      Toggle({ type: ToggleType.Switch, isOn: true })
57        .width($r('app.float.credentials_app_Toggle_wh'))
58        .height($r('app.float.credentials_app_Toggle_hg'))
59        .selectedColor($r('app.color.credentials_app_Toggle_selectColor'))
60        .onChange((isOn: boolean) => {
61          this.uidItem.appInfoList[this.indexNum].status = isOn;
62          if (!isOn) {
63            this.onChanged?.();
64          }
65        })
66        .margin({ right: $r('app.float.wh_value_16') })
67
68    }.height($r('app.float.wh_value_72'))
69  }
70}
71
72@Component
73export struct componentPublic {
74  private alias: string = '';
75  private keyUri: string = '';
76  @Link mShowAppCaPresenter: CmShowAppCredPresenter;
77  @State authorInfo: CmShowAppCredPresenter = CmShowAppCredPresenter.getInstance();
78  private authorScroller: Scroller = new Scroller();
79  @State isHoverBackgroundColor: ResourceColor = '';
80  @Styles pressedStyles(): void {
81    .backgroundColor($r('sys.color.ohos_id_color_click_effect'))
82  }
83  @Styles normalStyles(): void {
84    .backgroundColor(this.isHoverBackgroundColor)
85  }
86
87  onItemClicked?: () => void;
88
89  getAuthorizedAppList(): void {
90    this.authorInfo.getAuthorizedAppList(this.mShowAppCaPresenter.credInfo.keyUri);
91  }
92
93  deleteWarnDialog: CustomDialogController = new CustomDialogController({
94    builder: CustomContentDialog({
95      contentBuilder: () => {
96        this.deleteWarnContent();
97      },
98      contentAreaPadding: { right: $r('app.float.wh_value_0') },
99      buttons: [
100        {
101          value: $r('app.string.cancelAuthApp'),
102          buttonStyle: ButtonStyleMode.TEXTUAL,
103          action: () => {
104            this.appDialogController?.close();
105          }
106        },
107        {
108          value: $r('app.string.deleteAllCredDelete'),
109          buttonStyle: ButtonStyleMode.TEXTUAL,
110          action: () => {
111            this.mShowAppCaPresenter.deleteAppCred(this.mShowAppCaPresenter.credInfo.keyUri);
112            this.deleteWarnDialog?.close();
113          },
114          role: ButtonRole.ERROR
115        }
116      ]
117    }),
118  })
119
120  appDialogController: CustomDialogController = new CustomDialogController({
121    builder: CustomContentDialog({
122      contentBuilder: () => {
123        this.appControllerContent();
124      },
125      contentAreaPadding: { right: $r('app.float.wh_value_0') },
126      buttons: [
127        {
128          value: $r('app.string.cancelAuthApp'),
129          buttonStyle: ButtonStyleMode.TEXTUAL,
130          action: () => {
131            this.appDialogController?.close();
132          }
133        },
134        {
135          value: $r('app.string.finishAuthApp'),
136          buttonStyle: ButtonStyleMode.TEXTUAL,
137          action: () => {
138            this.authorInfo.removeGrantedAppList(this.authorInfo.credInfo.keyUri).then(() => {
139              this.appDialogController?.close();
140            })
141          }
142        }
143      ]
144    }),
145  })
146
147  credDetailsDialog: CustomDialogController = new CustomDialogController({
148    builder: CustomContentDialog({
149      contentBuilder: () => {
150        this.credDetailContent();
151      },
152      contentAreaPadding: { right: $r('app.float.wh_value_0') },
153      buttons: [
154        {
155          value: $r('app.string.publicDetailsCancel'),
156          buttonStyle: ButtonStyleMode.TEXTUAL,
157          action: () => {
158            this.credDetailsDialog?.close();
159          }
160        },
161        {
162          value: $r('app.string.publicDetailsDelete'),
163          buttonStyle: ButtonStyleMode.TEXTUAL,
164          action: () => {
165            this.onShowDeleteWarnDialog();
166          },
167          role: ButtonRole.ERROR
168        }
169      ]
170    }),
171  })
172
173  @Builder
174  appControllerContent(): void {
175    Column() {
176      Text($r('app.string.managerAuthApp'))
177        .height($r('app.float.wh_value_56'))
178        .fontSize($r('sys.float.ohos_id_text_size_dialog_tittle'))
179        .fontColor($r('sys.color.ohos_id_color_text_primary'))
180        .fontWeight(FontWeight.Medium)
181        .margin({
182          left: $r('app.float.wh_value_24'),
183          right: $r('app.float.wh_value_24')
184        })
185        .alignSelf(ItemAlign.Start)
186
187      if (this.authorInfo.appInfoList.length > ConfigValue.APP_AUTH_MAX_LENGTH) {
188        Stack({ alignContent: Alignment.End }) {
189          Scroll(this.authorScroller) {
190            List() {
191              ForEach(this.authorInfo.appInfoList, (item: AppAuthorVo, index) => {
192                ListItem() {
193                  DialogComponent({ appImage: item.appImage, appName: item.appName,
194                    indexNum: index, uidItem: $authorInfo })
195                }
196              })
197            }
198            .scrollBar(BarState.Off)
199            .divider({
200              strokeWidth: $r('app.float.Evidence_strokeWidth'),
201              color: $r('sys.color.ohos_id_color_list_separator')
202            })
203            .visibility(this.authorInfo.appInfoList.length > 0 ? Visibility.Visible : Visibility.None)
204          }
205          .scrollBar(BarState.Off)
206          .margin({
207            left: $r('app.float.wh_value_24'),
208            right: $r('app.float.wh_value_24')
209          })
210
211          ScrollBar({ scroller: this.authorScroller, direction: ScrollBarDirection.Vertical,
212            state: BarState.Auto }) {
213            Text()
214              .width($r('app.float.wh_value_3'))
215              .height($r('app.float.wh_value_50'))
216              .borderRadius($r('app.float.wh_value_10'))
217              .backgroundColor($r('sys.color.ohos_id_color_foreground'))
218              .opacity($r('app.float.text_opacity_0_4'))
219          }
220          .width($r('app.float.wh_value_3'))
221          .margin({
222            right: $r('app.float.wh_value_3')
223          })
224        }
225        .height(WidthPercent.WH_50_100)
226      } else {
227        List() {
228          ForEach(this.mShowAppCaPresenter.appInfoList, (item: AppAuthorVo, index) => {
229            ListItem() {
230              DialogComponent({ appImage: item.appImage, appName: item.appName,
231                indexNum: index, uidItem: $authorInfo })
232            }
233          })
234        }
235        .scrollBar(BarState.Off)
236        .margin({
237          left: $r('app.float.wh_value_24'),
238          right: $r('app.float.wh_value_24')
239        })
240        .divider({
241          strokeWidth: $r('app.float.Evidence_strokeWidth'),
242          color: $r('sys.color.ohos_id_color_list_separator')
243        })
244        .visibility(this.authorInfo.appInfoList.length > 0 ? Visibility.Visible : Visibility.None)
245      }
246    }
247    .width(WidthPercent.WH_100_100)
248    .borderRadius($r('app.float.user_list_divider_borderRadius_value'))
249    .backgroundColor($r('sys.color.ohos_id_color_dialog_bg'))
250  }
251
252  @Builder
253  credDetailContent(): void {
254    Column() {
255      Text($r('app.string.evidenceDetails'))
256        .height($r('app.float.wh_value_56'))
257        .fontSize($r('sys.float.ohos_id_text_size_dialog_tittle'))
258        .fontColor($r('sys.color.ohos_id_color_text_primary'))
259        .fontWeight(FontWeight.Medium)
260        .margin({
261          left: $r('app.float.wh_value_24'),
262          right: $r('app.float.wh_value_24')
263        })
264        .alignSelf(ItemAlign.Start)
265
266      Text(this.mShowAppCaPresenter.credInfo.alias)
267        .fontSize($r('sys.float.ohos_id_text_size_body1'))
268        .fontColor($r('sys.color.ohos_id_color_text_primary'))
269        .fontWeight(FontWeight.Medium)
270        .margin({
271          left: $r('app.float.wh_value_24'),
272          right: $r('app.float.wh_value_24')
273        })
274        .alignSelf(ItemAlign.Start)
275
276      Text($r('app.string.entryContains'))
277        .fontSize($r('sys.float.ohos_id_text_size_body2'))
278        .fontColor($r('sys.color.ohos_id_color_text_primary'))
279        .fontWeight(FontWeight.Regular)
280        .margin({
281          top: $r('app.float.wh_value_24'),
282          left: $r('app.float.wh_value_24'),
283          right: $r('app.float.wh_value_24')
284        })
285        .alignSelf(ItemAlign.Start)
286
287      Text($r('app.string.keyNum', String(this.mShowAppCaPresenter.credInfo.keyNum)))
288        .fontSize($r('sys.float.ohos_id_text_size_body2'))
289        .fontColor($r('sys.color.ohos_id_color_text_primary'))
290        .fontWeight(FontWeight.Regular)
291        .margin({
292          left: $r('app.float.wh_value_10'),
293          right: $r('app.float.wh_value_10')
294        })
295        .opacity($r('app.float.opacity_100_60'))
296        .alignSelf(ItemAlign.Start)
297
298      Text($r('app.string.userCerNum', String(this.mShowAppCaPresenter.credInfo.certNum)))
299        .fontSize($r('sys.float.ohos_id_text_size_body2'))
300        .fontColor($r('sys.color.ohos_id_color_text_primary'))
301        .fontWeight(FontWeight.Regular)
302        .margin({
303          left: $r('app.float.wh_value_10'),
304          right: $r('app.float.wh_value_10')
305        })
306        .opacity($r('app.float.opacity_100_60'))
307        .alignSelf(ItemAlign.Start)
308
309      Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
310        Column() {
311          Text($r('app.string.managerAuthApp'))
312            .fontSize($r('sys.float.ohos_id_text_size_body1'))
313            .fontColor($r('sys.color.ohos_id_color_text_primary'))
314            .fontWeight(FontWeight.Medium)
315        }
316
317        Row() {
318          Image($r('app.media.ic_settings_arrow'))
319            .width($r('app.float.managerAuthApp_image_wh'))
320            .height($r('app.float.managerAuthApp_image_hg'))
321            .fillColor($r('sys.color.ohos_id_color_primary'))
322            .opacity($r('app.float.managerAuthApp_image_opacity'))
323        }
324      }
325      .onClick(() => {
326        this.onShowAuthMngChange();
327      })
328      .margin({
329        top: $r('app.float.wh_value_12'),
330        left: $r('app.float.wh_value_24'),
331        right: $r('app.float.wh_value_24')
332      })
333      .height('48vp')
334    }
335    .width(WidthPercent.WH_100_100)
336    .borderRadius($r('app.float.user_list_divider_borderRadius_value'))
337    .backgroundColor($r('sys.color.ohos_id_color_dialog_bg'))
338  }
339
340  @Builder
341  deleteWarnContent(): void {
342    Column() {
343      Text($r('app.string.warning_title'))
344        .height($r('app.float.wh_value_56'))
345        .fontSize($r('sys.float.ohos_id_text_size_dialog_tittle'))
346        .fontColor($r('sys.color.ohos_id_color_text_primary'))
347        .fontWeight(FontWeight.Medium)
348        .margin({
349          left: $r('app.float.wh_value_24'),
350          right: $r('app.float.wh_value_24')
351        })
352        .alignSelf(ItemAlign.Start)
353
354      Text($r('app.string.warning_message'))
355        .fontSize($r('sys.float.ohos_id_text_size_body1'))
356        .fontWeight(FontWeight.Regular)
357        .fontColor($r('sys.color.ohos_id_color_primary'))
358        .margin({
359          top: $r('app.float.wh_value_16'),
360          left: $r('app.float.wh_value_24'),
361          right: $r('app.float.wh_value_24')
362        })
363        .alignSelf(ItemAlign.Start)
364    }
365    .width(WidthPercent.WH_100_100)
366    .borderRadius($r('app.float.user_list_divider_borderRadius_value'))
367    .backgroundColor($r('sys.color.ohos_id_color_dialog_bg'))
368  }
369
370  onShowAuthMngChange() {
371    this.credDetailsDialog?.close();
372    this.appDialogController.open();
373  }
374
375  onShowDeleteWarnDialog() {
376    this.credDetailsDialog?.close();
377    this.deleteWarnDialog.open();
378  }
379
380  build() {
381    Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
382      Column() {
383        Text(this.alias)
384          .fontSize($r('sys.float.ohos_id_text_size_body1'))
385          .fontColor($r('sys.color.ohos_id_color_text_primary'))
386          .fontWeight(FontWeight.Medium)
387      }
388
389      Row() {
390        Image($r('app.media.ic_settings_arrow'))
391          .width($r('app.float.publicList_image_wh'))
392          .height($r('app.float.publicList_image_hg'))
393      }
394    }
395    .height($r('app.float.wh_value_48'))
396    .hoverEffect(HoverEffect.Highlight)
397    .onHover((isHover?: boolean) => {
398      this.isHoverBackgroundColor = isHover ? $r('sys.color.ohos_id_color_hover') : ''
399    })
400    .backgroundColor(this.isHoverBackgroundColor)
401    .stateStyles({
402      pressed: this.pressedStyles,
403      normal: this.normalStyles
404    })
405    .padding({
406      left: $r('app.float.wh_value_8'),
407      right: $r('app.float.wh_value_8')
408    })
409    .borderRadius($r('app.float.wh_value_20'))
410    .onClick(() => {
411      this.mShowAppCaPresenter.getAppCred(this.keyUri, () => {
412        this.getAuthorizedAppList();
413        if (this.onItemClicked !== undefined) {
414          this.onItemClicked();
415        } else {
416          this.credDetailsDialog.open();
417        }
418      });
419    })
420  }
421}
422
423@Component
424export struct componentSystem {
425  private alias: string = '';
426  private keyUri: string = '';
427  @State mSystemCredPresenter: CmShowSysCredPresenter = CmShowSysCredPresenter.getInstance();
428  @State isHoverBackgroundColor: ResourceColor = '';
429  @Link systemCredPresenter: CmShowSysCredPresenter;
430  @Styles pressedStyles(): void {
431    .backgroundColor($r('sys.color.ohos_id_color_click_effect'))
432  }
433  @Styles normalStyles(): void {
434    .backgroundColor(this.isHoverBackgroundColor)
435  }
436
437  onItemClicked?: () => void;
438
439  sysCredDetailsDialog: CustomDialogController = new CustomDialogController({
440    builder: CustomContentDialog({
441      contentBuilder: () => {
442        this.sysCredDetailContent();
443      },
444      contentAreaPadding: { right: $r('app.float.wh_value_0') },
445      buttons: [
446        {
447          value: $r('app.string.publicDetailsCancel'),
448          buttonStyle: ButtonStyleMode.TEXTUAL,
449          action: () => {
450            this.sysCredDetailsDialog?.close();
451          }
452        },
453        {
454          value: $r('app.string.publicDetailsDelete'),
455          buttonStyle: ButtonStyleMode.TEXTUAL,
456          action: () => {
457            this.sysCredDetailsDialog?.close();
458            this.deleteWarnDialog.open();
459          },
460          role: ButtonRole.ERROR
461        }
462      ]
463    }),
464  })
465
466  deleteWarnDialog: CustomDialogController = new CustomDialogController({
467    builder: CustomContentDialog({
468      contentBuilder: () => {
469        this.deleteWarnContent();
470      },
471      contentAreaPadding: { right: $r('app.float.wh_value_0') },
472      buttons: [
473        {
474          value: $r('app.string.cancelAuthApp'),
475          buttonStyle: ButtonStyleMode.TEXTUAL,
476          action: () => {
477            this.sysCredDetailsDialog?.close();
478          }
479        },
480        {
481          value: $r('app.string.deleteAllCredDelete'),
482          buttonStyle: ButtonStyleMode.TEXTUAL,
483          action: () => {
484            this.mSystemCredPresenter.deleteSystemCred(this.mSystemCredPresenter.credInfo.keyUri);
485            this.deleteWarnDialog?.close();
486            this.systemCredPresenter.updateSystemCredList();
487          },
488          role: ButtonRole.ERROR
489        }
490      ]
491    }),
492  })
493
494  @Builder
495  sysCredDetailContent(): void {
496    Column() {
497      Text($r('app.string.evidenceDetails'))
498        .height($r('app.float.wh_value_56'))
499        .fontSize($r('sys.float.ohos_id_text_size_dialog_tittle'))
500        .fontColor($r('sys.color.ohos_id_color_text_primary'))
501        .fontWeight(FontWeight.Medium)
502        .margin({
503          left: $r('app.float.wh_value_24'),
504          right: $r('app.float.wh_value_24')
505        })
506        .alignSelf(ItemAlign.Start)
507
508      Text(this.systemCredPresenter.credInfo.alias)
509        .fontSize($r('sys.float.ohos_id_text_size_body1'))
510        .fontColor($r('sys.color.ohos_id_color_text_primary'))
511        .fontWeight(FontWeight.Medium)
512        .margin({
513          left: $r('app.float.wh_value_24'),
514          right: $r('app.float.wh_value_24')
515        })
516        .alignSelf(ItemAlign.Start)
517
518      Text($r('app.string.entryContains'))
519        .fontSize($r('sys.float.ohos_id_text_size_body2'))
520        .fontColor($r('sys.color.ohos_id_color_text_primary'))
521        .fontWeight(FontWeight.Regular)
522        .margin({
523          top: $r('app.float.wh_value_24'),
524          left: $r('app.float.wh_value_24'),
525          right: $r('app.float.wh_value_24')
526        })
527        .alignSelf(ItemAlign.Start)
528
529      Text($r('app.string.keyNum', String(this.systemCredPresenter.credInfo.keyNum)))
530        .fontSize($r('sys.float.ohos_id_text_size_body2'))
531        .fontColor($r('sys.color.ohos_id_color_text_primary'))
532        .fontWeight(FontWeight.Regular)
533        .margin({
534          left: $r('app.float.wh_value_10'),
535          right: $r('app.float.wh_value_10')
536        })
537        .opacity($r('app.float.opacity_100_60'))
538        .alignSelf(ItemAlign.Start)
539
540      Text($r('app.string.userCerNum', String(this.systemCredPresenter.credInfo.certNum)))
541        .fontSize($r('sys.float.ohos_id_text_size_body2'))
542        .fontColor($r('sys.color.ohos_id_color_text_primary'))
543        .fontWeight(FontWeight.Regular)
544        .margin({
545          left: $r('app.float.wh_value_10'),
546          right: $r('app.float.wh_value_10')
547        })
548        .opacity($r('app.float.opacity_100_60'))
549        .alignSelf(ItemAlign.Start)
550    }
551    .width(WidthPercent.WH_100_100)
552    .borderRadius($r('app.float.user_list_divider_borderRadius_value'))
553    .backgroundColor($r('sys.color.ohos_id_color_dialog_bg'))
554  }
555
556  @Builder
557  deleteWarnContent(): void {
558    Column() {
559      Text($r('app.string.warning_title'))
560        .height($r('app.float.wh_value_56'))
561        .fontSize($r('sys.float.ohos_id_text_size_dialog_tittle'))
562        .fontColor($r('sys.color.ohos_id_color_text_primary'))
563        .fontWeight(FontWeight.Medium)
564        .margin({
565          left: $r('app.float.wh_value_24'),
566          right: $r('app.float.wh_value_24')
567        })
568        .alignSelf(ItemAlign.Start)
569
570      Text($r('app.string.warning_message'))
571        .fontSize($r('sys.float.ohos_id_text_size_body1'))
572        .fontWeight(FontWeight.Regular)
573        .fontColor($r('sys.color.ohos_id_color_primary'))
574        .margin({
575          top: $r('app.float.wh_value_16'),
576          left: $r('app.float.wh_value_24'),
577          right: $r('app.float.wh_value_24')
578        })
579        .alignSelf(ItemAlign.Start)
580    }
581    .width(WidthPercent.WH_100_100)
582    .borderRadius($r('app.float.user_list_divider_borderRadius_value'))
583    .backgroundColor($r('sys.color.ohos_id_color_dialog_bg'))
584  }
585
586  build() {
587    Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
588      Column() {
589        Text(this.alias)
590          .fontSize($r('sys.float.ohos_id_text_size_body1'))
591          .fontColor($r('sys.color.ohos_id_color_text_primary'))
592          .fontWeight(FontWeight.Medium)
593      }
594
595      Row() {
596        Image($r('app.media.ic_settings_arrow'))
597          .width($r('app.float.publicList_image_wh'))
598          .height($r('app.float.publicList_image_hg'))
599      }
600    }
601    .height($r('app.float.wh_value_48'))
602    .hoverEffect(HoverEffect.Highlight)
603    .onHover((isHover?: boolean) => {
604      this.isHoverBackgroundColor = isHover ? $r('sys.color.ohos_id_color_hover') : ''
605    })
606    .backgroundColor(this.isHoverBackgroundColor)
607    .stateStyles({
608      pressed: this.pressedStyles,
609      normal: this.normalStyles
610    })
611    .padding({
612      left: $r('app.float.wh_value_8'),
613      right: $r('app.float.wh_value_8')
614    })
615    .borderRadius($r('app.float.wh_value_20'))
616    .onClick(() => {
617      this.mSystemCredPresenter.getSystemCred(this.keyUri, () => {
618        if (this.onItemClicked !== undefined) {
619          this.onItemClicked();
620        } else {
621          this.sysCredDetailsDialog.open();
622        }
623      });
624    })
625  }
626
627}
628
629@Entry
630@Component
631export struct evidenceList {
632  @State mShowAppCaPresenter: CmShowAppCredPresenter = CmShowAppCredPresenter.getInstance();
633  @State mShowSysCredPresenter: CmShowSysCredPresenter = CmShowSysCredPresenter.getInstance();
634  @State mFaPresenter: CMFaPresenter = CMFaPresenter.getInstance();
635  private publicScroller: Scroller = new Scroller();
636  private systemScroller: Scroller = new Scroller();
637  @State currentIndex: number = 0;
638  @State fontColor: Resource = $r('app.color.evidenceList_TabBuilder_fontColor_182431');
639  @State selectedFontColor: Resource = $r('app.color.font_color_007DFF');
640  private controller: TabsController = new TabsController();
641  @State animationDurationNum: number = 400;
642
643  isStartBySheetFirst: boolean = false;
644  isStartBySheet: boolean = false;
645  selected?: (path: string, param?: Object) => void;
646
647  @Builder
648  TabBuilder(index: number) {
649    Column() {
650      Text(index == 0 ? $r('app.string.system') : $r('app.string.user'))
651        .fontColor(this.currentIndex === index ? this.selectedFontColor : this.fontColor)
652        .fontSize($r('app.float.TrustedEvidence_TabBuilder_Text_fontSize_value'))
653        .fontWeight(this.currentIndex === index ? FontWeight.Medium : FontWeight.Regular)
654        .alignSelf(ItemAlign.Center)
655        .margin({
656          top: $r('app.float.TrustedEvidence_TabBuilder_Text_padding_top_value')
657        })
658      if (this.currentIndex === index) {
659        Divider()
660          .width($r('app.float.TrustedEvidence_TabBuilder_Divider_width_value'))
661          .margin({ top: $r('app.float.TrustedEvidence_TabBuilder_Divider_padding_top_value') })
662          .color(this.selectedFontColor)
663          .alignSelf(ItemAlign.Center)
664      }
665    }
666    .width(WidthPercent.WH_100_100)
667  }
668
669  aboutToAppear() {
670    this.mShowAppCaPresenter.updateAppCredListCallback(() => {
671      console.info('get AppCredList first');
672    })
673    this.mShowSysCredPresenter.updateSystemCredListCallback(() => {
674      console.info('get systemCredList start');
675    })
676  }
677
678  onPageShow() {
679    let uri = GlobalContext.getContext().getAbilityWant().uri;
680    GlobalContext.getContext().clearAbilityWantUri();
681
682    if (uri === 'certInstall') {
683      router.pushUrl({
684        url: 'pages/certInstallFromStorage'
685      })
686    } else if (uri === 'requestAuthorize') {
687      this.mFaPresenter.startRequestAuth(GlobalContext.getContext().getAbilityWant().parameters?.appUid as string);
688    } else {
689      console.error('The want type is not supported.');
690    }
691  }
692
693  build() {
694    Column() {
695      GridRow({
696        columns: COPIES_NUM,
697        gutter: vp2px(1) === 2 ? $r('app.float.wh_value_12') : $r('app.float.wh_value_0')
698      }) {
699        GridCol({ span: { xs: COPIES_NUM, sm: COPIES_NUM, md: COPIES_NUM, lg: COPIES_NUM },
700          offset: { xs: 0, sm: 0, md: 0, lg: 0 } }) {
701          Row() {
702            Column() {
703              HeadComponent({ headName: $r('app.string.userEvidence'), isStartBySheet: this.isStartBySheet,
704                icBackIsVisibility: !this.isStartBySheetFirst,
705                onBackClicked: () => {
706                  this.selected?.(NavEntryKey.POP);
707                }})
708                .margin({
709                  left: $r('app.float.wh_value_16'),
710                  top: this.isStartBySheet ? 8 : 0
711                })
712
713              Column() {
714                Tabs({barPosition: BarPosition.Start, index: 0, controller: this.controller}) {
715                  TabContent() {
716                    Stack({alignContent: Alignment.End}) {
717                      Scroll(this.systemScroller) {
718                        List() {
719                          ForEach(this.mShowSysCredPresenter.credList, (item: CredentialAbstractVo) => {
720                            ListItem() {
721                              componentSystem({
722                                alias: item.alias,
723                                keyUri: item.keyUri,
724                                systemCredPresenter: $mShowSysCredPresenter,
725                                onItemClicked: this.isStartBySheet ? () => {
726                                  this.selected?.(NavEntryKey.CRED_SYSTEM_DETAIL_ENTRY,
727                                    new CredSystemDetailParam(this.mShowSysCredPresenter));
728                                } : undefined
729                              })
730                            }
731                          }, (item:CredentialAbstractVo) => JSON.stringify(item))
732                        }
733                        .backgroundColor($r('sys.color.ohos_id_color_list_card_bg'))
734                        .borderRadius($r('sys.float.padding_level10'))
735                        .scrollBar(BarState.Off)
736                        .padding({
737                          right: $r('app.float.wh_value_4'),
738                          left: $r('app.float.wh_value_4'),
739                          top: $r('app.float.wh_value_4'),
740                          bottom: $r('app.float.wh_value_4')
741                        })
742                        .divider({
743                          strokeWidth: $r('app.float.user_list_divider_strokeWidth_value'),
744                          color: $r('sys.color.ohos_id_color_list_separator'),
745                          endMargin: $r('app.float.wh_value_3')
746                        })
747                        .visibility(this.mShowSysCredPresenter.credList.length > 0
748                          ? Visibility.Visible : Visibility.None)
749                      }
750                      .position({ y: $r('app.float.wh_value_0') })
751                      .scrollable(ScrollDirection.Vertical)
752                      .scrollBar(BarState.Off)
753                      .width(WidthPercent.WH_100_100)
754                      .height(WidthPercent.WH_100_100)
755                      .align(Alignment.Top)
756                      .edgeEffect(EdgeEffect.Spring)
757                      .padding({
758                        left: $r('app.float.wh_value_12'),
759                        right: $r('app.float.wh_value_12'),
760                        bottom: $r('app.float.wh_value_24')
761                      })
762                    }
763                    .width(WidthPercent.WH_100_100)
764                  }
765                  .tabBar(this.TabBuilder(0))
766
767                  TabContent() {
768                    Stack({ alignContent: Alignment.End }) {
769                      Scroll(this.publicScroller) {
770                        List() {
771                          ForEach(this.mShowAppCaPresenter.credList, (item: CredentialAbstractVo) => {
772                            ListItem() {
773                              componentPublic({
774                                alias: item.alias,
775                                keyUri: item.keyUri,
776                                mShowAppCaPresenter: $mShowAppCaPresenter,
777                                onItemClicked: this.isStartBySheet ? () => {
778                                  this.selected?.(NavEntryKey.CRED_USER_DETAIL_ENTRY,
779                                    new CredUserDetailParam(this.mShowAppCaPresenter));
780                                } : undefined
781                              })
782                            }
783                          }, (item: CredentialAbstractVo) => JSON.stringify(item))
784                        }
785                        .backgroundColor($r('sys.color.ohos_id_color_list_card_bg'))
786                        .borderRadius($r('sys.float.padding_level10'))
787                        .scrollBar(BarState.Off)
788                        .padding({
789                          right: $r('app.float.wh_value_4'),
790                          left: $r('app.float.wh_value_4'),
791                          top: $r('app.float.wh_value_4'),
792                          bottom: $r('app.float.wh_value_4')
793                        })
794                        .divider({
795                          strokeWidth: $r('app.float.user_list_divider_strokeWidth_value'),
796                          color: $r('sys.color.ohos_id_color_list_separator'),
797                          endMargin: $r('app.float.wh_value_3')
798                        })
799                        .visibility(this.mShowAppCaPresenter.credList.length > 0 ? Visibility.Visible : Visibility.None)
800                      }
801                      .position({ y: $r('app.float.wh_value_0') })
802                      .width(WidthPercent.WH_100_100)
803                      .height(WidthPercent.WH_100_100)
804                      .align(Alignment.Top)
805                      .edgeEffect(EdgeEffect.Spring)
806                      .scrollable(ScrollDirection.Vertical)
807                      .scrollBar(BarState.Off)
808                      .padding({
809                        left: $r('app.float.wh_value_12'),
810                        right: $r('app.float.wh_value_12'),
811                        bottom: $r('app.float.wh_value_24')
812                      })
813                    }
814                    .width(WidthPercent.WH_100_100)
815                    .backgroundColor($r('sys.color.ohos_id_color_sub_background'))
816                  }
817                  .tabBar(this.TabBuilder(1))
818                }
819                .vertical(false)
820                .scrollable(true)
821                .barMode(BarMode.Fixed)
822                .barWidth($r('app.float.tabs_barWidth_value'))
823                .barHeight($r('app.float.tabs_barHeight_value'))
824                .animationDuration(this.animationDurationNum)
825                .width(WidthPercent.WH_100_100)
826                .backgroundColor($r('sys.color.ohos_id_color_sub_background'))
827                .onChange((index: number) => {
828                  this.currentIndex = index;
829                });
830              }
831              .height(WidthPercent.WH_94_100)
832              .width(WidthPercent.WH_100_100)
833            }
834            .backgroundColor($r('sys.color.ohos_id_color_sub_background'))
835            .width(WidthPercent.WH_100_100)
836            .height(WidthPercent.WH_100_100)
837          }
838          .width(WidthPercent.WH_100_100)
839          .height(WidthPercent.WH_100_100);
840        }
841        .margin(vp2px(1) === 2 ? $r('app.float.item_common_horizontal_margin') : $r('app.float.wh_value_0'))
842      }
843      .width(WidthPercent.WH_100_100)
844      .height(WidthPercent.WH_100_100);
845    }
846    .backgroundColor($r('sys.color.ohos_id_color_sub_background'))
847    .width(WidthPercent.WH_100_100)
848    .height(WidthPercent.WH_100_100);
849  }
850}
851