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