1/** 2 * Copyright (c) 2024-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 HeadComponent from '../../common/component/headComponent'; 17import { NavEntryKey } from '../../common/NavEntryKey'; 18import { WidthPercent } from '../../common/util/ConfigData'; 19import CmShowSysCaPresenter from '../../presenter/CmShowSysCaPresenter'; 20import { 21 DialogDateComponent, 22 DialogFingerPrintComponent, 23 DialogIssuerComponent, 24 DialogSubjectComponent 25} from '../trustedCa'; 26import { SheetParam } from './SheetParam'; 27 28@Component 29export struct CaSystemDetailPage { 30 @State mShowSysCaPresenter: CmShowSysCaPresenter = CmShowSysCaPresenter.getInstance(); 31 32 private stack?: NavPathStack; 33 34 @State headRectHeight: number = 64; 35 @State headRectHeightReal: number = 0; 36 @Prop sheetParam: SheetParam; 37 private scroller: Scroller = new Scroller(); 38 @State scrollerHeight: number = 0; 39 40 build() { 41 NavDestination() { 42 Stack({ alignContent: Alignment.Top }) { 43 Column() { 44 HeadComponent({ headName: $r('app.string.CustomDialogExample_firText'), isStartBySheet: true, onBackClicked: () => { 45 this.stack?.pop(); 46 } }) 47 .margin({ 48 left: $r('app.float.wh_value_12'), 49 top: 8 50 }) 51 }.zIndex(1) 52 .onAreaChange((oldArea, newArea) => { 53 this.headRectHeight = newArea.height as number; 54 this.headRectHeightReal = newArea.height as number; 55 }) 56 57 Stack({ alignContent: Alignment.TopEnd }) { 58 Scroll(this.scroller) { 59 this.buildContent() 60 } 61 .padding({ 62 left: 16, right: 16, 63 bottom: $r('app.float.wh_value_24') 64 }) 65 .align(Alignment.Top) 66 .scrollable(ScrollDirection.Vertical) 67 .edgeEffect(EdgeEffect.Spring) 68 .scrollBar(BarState.Off) 69 .width(WidthPercent.WH_100_100) 70 .height(WidthPercent.WH_AUTO) 71 .constraintSize({ 72 minHeight: this.getScrollMinHeight() 73 }).onAreaChange((oldArea, newArea) => { 74 this.scrollerHeight = newArea.height as number; 75 }) 76 77 Column() { 78 ScrollBar({ 79 scroller: this.scroller, 80 direction: ScrollBarDirection.Vertical, 81 state: BarState.Auto 82 }).margin({ 83 bottom: $r('app.float.wh_value_24') 84 }) 85 }.height(this.scrollerHeight) 86 }.padding({ 87 top: this.headRectHeight 88 }) 89 } 90 } 91 .hideTitleBar(true) 92 .width(WidthPercent.WH_100_100) 93 .height(this.sheetParam?.lastSheetPage === NavEntryKey.CA_SYSTEM_DETAIL_ENTRY ? 94 WidthPercent.WH_AUTO : this.sheetParam?.sheetMinHeight) 95 .backgroundColor($r('sys.color.background_secondary')) 96 .onReady((ctx: NavDestinationContext) => { 97 this.stack = ctx.pathStack; 98 }) 99 } 100 101 getScrollMinHeight() { 102 if (this.sheetParam === undefined || this.headRectHeightReal === 0 || 103 this.sheetParam.sheetMinHeight < this.headRectHeightReal) { 104 return 0; 105 } 106 return this.sheetParam.sheetMinHeight - this.headRectHeightReal; 107 } 108 109 @Builder 110 private buildContent() { 111 Column() { 112 Text(this.mShowSysCaPresenter.certInfo.certAlias) 113 .fontSize($r('sys.float.ohos_id_text_size_body1')) 114 .fontColor($r('sys.color.ohos_id_color_text_primary')) 115 .fontWeight(FontWeight.Medium) 116 .margin({ 117 top: $r('app.float.wh_value_8'), 118 bottom: $r('app.float.wh_value_24') 119 }) 120 .alignSelf(ItemAlign.Start) 121 122 Text($r('app.string.CustomDialogExample_firListItem_text')) 123 .fontSize($r('sys.float.ohos_id_text_size_body1')) 124 .fontColor($r('sys.color.ohos_id_color_text_primary')) 125 .fontWeight(FontWeight.Medium) 126 127 DialogSubjectComponent({ map: this.mShowSysCaPresenter.certInfo.subjectNameMap }) 128 129 Text($r('app.string.CustomDialogExample_secListItem_text')) 130 .fontSize($r('sys.float.ohos_id_text_size_body1')) 131 .fontColor($r('sys.color.ohos_id_color_text_primary')) 132 .fontWeight(FontWeight.Medium) 133 .margin({ 134 top: $r('app.float.wh_value_24') 135 }) 136 137 DialogIssuerComponent({ map: this.mShowSysCaPresenter.certInfo.issuerNameMap }) 138 139 Text($r('app.string.CustomDialogExample_thdListItem_text')) 140 .fontSize($r('sys.float.ohos_id_text_size_body1')) 141 .fontColor($r('sys.color.ohos_id_color_text_primary')) 142 .fontWeight(FontWeight.Medium) 143 .margin({ 144 top: $r('app.float.wh_value_24') 145 }) 146 147 DialogDateComponent({ map: this.mShowSysCaPresenter.certInfo.dateMap }) 148 149 Text($r('app.string.CustomDialogExample_fouListItem_text')) 150 .fontSize($r('sys.float.ohos_id_text_size_body1')) 151 .fontColor($r('sys.color.ohos_id_color_text_primary')) 152 .fontWeight(FontWeight.Medium) 153 .margin({ 154 top: $r('app.float.wh_value_24') 155 }) 156 157 DialogFingerPrintComponent({ fingerprintSha256: this.mShowSysCaPresenter.certInfo.fingerprintSha256 }) 158 } 159 .alignItems(HorizontalAlign.Start) 160 .width(WidthPercent.WH_100_100) 161 } 162}