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 { SheetParam } from '../../common/util/SheetParam'; 21 22@Component 23export struct DialogSubjectComponent { 24 private map?: Map<string, string>; 25 private subjectNameCN: string = ''; 26 private subjectNameO: string = ''; 27 private subjectNameOU: string = ''; 28 private serial: string = ''; 29 30 aboutToAppear() { 31 if (this.map != null) { 32 let subjectNameCN = this.map.get('常用名称:'); 33 if (subjectNameCN !== undefined) { 34 this.subjectNameCN = subjectNameCN; 35 } 36 37 let subjectNameO = this.map.get('组织:'); 38 if (subjectNameO !== undefined) { 39 this.subjectNameO = subjectNameO; 40 } 41 42 let subjectNameOU = this.map.get('组织单位:'); 43 if (subjectNameOU !== undefined) { 44 this.subjectNameOU = subjectNameOU; 45 } 46 47 let serial = this.map.get('序列号:'); 48 if (serial !== undefined) { 49 this.serial = serial; 50 } 51 } 52 } 53 54 build() { 55 Column() { 56 Text($r('app.string.DialogSubjectComponent_firText')) 57 .fontSize($r('sys.float.ohos_id_text_size_body2')) 58 .fontColor($r('sys.color.ohos_id_color_text_primary')) 59 .fontWeight(FontWeight.Regular) 60 .margin({ 61 top: $r('app.float.sys_elements_margin_vertical_l') 62 }) 63 Text(this.subjectNameCN) 64 .fontSize($r('sys.float.ohos_id_text_size_body2')) 65 .fontColor($r('sys.color.ohos_id_color_text_primary')) 66 .fontWeight(FontWeight.Regular) 67 Text($r('app.string.DialogSubjectComponent_secText')) 68 .fontSize($r('sys.float.ohos_id_text_size_body2')) 69 .fontColor($r('sys.color.ohos_id_color_text_primary')) 70 .fontWeight(FontWeight.Regular) 71 .margin({ 72 top: $r('app.float.sys_elements_margin_vertical_m') 73 }) 74 Text(this.subjectNameO) 75 .fontSize($r('sys.float.ohos_id_text_size_body2')) 76 .fontColor($r('sys.color.ohos_id_color_text_primary')) 77 .fontWeight(FontWeight.Regular) 78 Text($r('app.string.DialogSubjectComponent_thdText')) 79 .fontSize($r('sys.float.ohos_id_text_size_body2')) 80 .fontColor($r('sys.color.ohos_id_color_text_primary')) 81 .fontWeight(FontWeight.Regular) 82 .margin({ 83 top: $r('app.float.sys_elements_margin_vertical_m') 84 }) 85 Text(this.subjectNameOU) 86 .fontSize($r('sys.float.ohos_id_text_size_body2')) 87 .fontColor($r('sys.color.ohos_id_color_text_primary')) 88 .fontWeight(FontWeight.Regular) 89 Text($r('app.string.DialogSubjectComponent_fouText')) 90 .fontSize($r('sys.float.ohos_id_text_size_body2')) 91 .fontColor($r('sys.color.ohos_id_color_text_primary')) 92 .fontWeight(FontWeight.Regular) 93 .margin({ 94 top: $r('app.float.sys_elements_margin_vertical_m') 95 }) 96 Text(this.serial) 97 .fontSize($r('sys.float.ohos_id_text_size_body2')) 98 .fontColor($r('sys.color.ohos_id_color_text_primary')) 99 .fontWeight(FontWeight.Regular) 100 }.alignItems(HorizontalAlign.Start); 101 } 102} 103 104@Component 105export struct DialogIssuerComponent { 106 private map?: Map<string, string>; 107 private issuerNameCN: string = ''; 108 private issuerNameO: string = ''; 109 private issuerNameOU: string = ''; 110 111 aboutToAppear() { 112 if (this.map != null) { 113 let issuerNameCN = this.map.get('常用名称:'); 114 if (issuerNameCN !== undefined) { 115 this.issuerNameCN = issuerNameCN; 116 } 117 118 let issuerNameO = this.map.get('组织:'); 119 if (issuerNameO !== undefined) { 120 this.issuerNameO = issuerNameO; 121 } 122 123 let issuerNameOU = this.map.get('组织单位:'); 124 if (issuerNameOU !== undefined) { 125 this.issuerNameOU = issuerNameOU; 126 } 127 } 128 } 129 130 build() { 131 Column() { 132 Text($r('app.string.DialogSubjectComponent_firText')) 133 .fontSize($r('sys.float.ohos_id_text_size_body2')) 134 .fontColor($r('sys.color.ohos_id_color_text_primary')) 135 .fontWeight(FontWeight.Regular) 136 .margin({ 137 top: $r('app.float.sys_elements_margin_vertical_l') 138 }) 139 Text(this.issuerNameCN) 140 .fontSize($r('sys.float.ohos_id_text_size_body2')) 141 .fontColor($r('sys.color.ohos_id_color_text_primary')) 142 .fontWeight(FontWeight.Regular) 143 Text($r('app.string.DialogSubjectComponent_secText')) 144 .fontSize($r('sys.float.ohos_id_text_size_body2')) 145 .fontColor($r('sys.color.ohos_id_color_text_primary')) 146 .fontWeight(FontWeight.Regular) 147 .margin({ 148 top: $r('app.float.sys_elements_margin_vertical_m') 149 }) 150 Text(this.issuerNameO) 151 .fontSize($r('sys.float.ohos_id_text_size_body2')) 152 .fontColor($r('sys.color.ohos_id_color_text_primary')) 153 .fontWeight(FontWeight.Regular) 154 Text($r('app.string.DialogSubjectComponent_thdText')) 155 .fontSize($r('sys.float.ohos_id_text_size_body2')) 156 .fontColor($r('sys.color.ohos_id_color_text_primary')) 157 .fontWeight(FontWeight.Regular) 158 .margin({ 159 top: $r('app.float.sys_elements_margin_vertical_m') 160 }) 161 Text(this.issuerNameOU) 162 .fontSize($r('sys.float.ohos_id_text_size_body2')) 163 .fontColor($r('sys.color.ohos_id_color_text_primary')) 164 .fontWeight(FontWeight.Regular) 165 }.alignItems(HorizontalAlign.Start); 166 } 167} 168 169@Component 170export struct DialogDateComponent { 171 private map?: Map<string, string>; 172 private notBefore: string = ''; 173 private notAfter: string = ''; 174 175 aboutToAppear() { 176 if (this.map != null) { 177 let notBefore = this.map.get('颁发时间:'); 178 if (notBefore != undefined) { 179 this.notBefore = notBefore; 180 } 181 182 let notAfter = this.map.get('有效期至:'); 183 if (notAfter != undefined) { 184 this.notAfter = notAfter; 185 } 186 } 187 } 188 189 build() { 190 Column() { 191 Text($r('app.string.DialogSubjectComponent_fifText')) 192 .fontSize($r('sys.float.ohos_id_text_size_body2')) 193 .fontColor($r('sys.color.ohos_id_color_text_primary')) 194 .fontWeight(FontWeight.Regular) 195 .margin({ 196 top: $r('app.float.sys_elements_margin_vertical_l') 197 }) 198 Text(this.notBefore) 199 .fontSize($r('sys.float.ohos_id_text_size_body2')) 200 .fontColor($r('sys.color.ohos_id_color_text_primary')) 201 .fontWeight(FontWeight.Regular) 202 Text($r('app.string.DialogSubjectComponent_sixText')) 203 .fontSize($r('sys.float.ohos_id_text_size_body2')) 204 .fontColor($r('sys.color.ohos_id_color_text_primary')) 205 .fontWeight(FontWeight.Regular) 206 .margin({ 207 top: $r('app.float.sys_elements_margin_vertical_m') 208 }) 209 Text(this.notAfter) 210 .fontSize($r('sys.float.ohos_id_text_size_body2')) 211 .fontColor($r('sys.color.ohos_id_color_text_primary')) 212 .fontWeight(FontWeight.Regular) 213 }.alignItems(HorizontalAlign.Start); 214 } 215} 216 217@Component 218export struct DialogFingerPrintComponent { 219 private fingerprintSha256: string = ''; 220 221 build() { 222 Column() { 223 Text($r('app.string.CustomDialogExample_FingerPrint_text')) 224 .fontSize($r('sys.float.ohos_id_text_size_body2')) 225 .fontColor($r('sys.color.ohos_id_color_text_primary')) 226 .fontWeight(FontWeight.Regular) 227 .margin({ 228 top: $r('app.float.sys_elements_margin_vertical_l') 229 }) 230 Text(this.fingerprintSha256) 231 .fontSize($r('sys.float.ohos_id_text_size_body2')) 232 .fontColor($r('sys.color.ohos_id_color_text_primary')) 233 .fontWeight(FontWeight.Regular) 234 .margin({ 235 right: $r('app.float.wh_value_24') 236 }) 237 }.alignItems(HorizontalAlign.Start); 238 } 239} 240 241@Component 242export struct CaSystemDetailPage { 243 @State mShowSysCaPresenter: CmShowSysCaPresenter = CmShowSysCaPresenter.getInstance(); 244 245 private stack?: NavPathStack; 246 247 @State headRectHeight: number = 64; 248 @State headRectHeightReal: number = 0; 249 @Prop sheetParam: SheetParam; 250 private scroller: Scroller = new Scroller(); 251 @State scrollerHeight: number = 0; 252 253 build() { 254 NavDestination() { 255 Stack({ alignContent: Alignment.Top }) { 256 Column() { 257 HeadComponent({ headName: $r('app.string.CustomDialogExample_firText'), isStartBySheet: true, onBackClicked: () => { 258 this.stack?.pop(); 259 } }) 260 .margin({ 261 left: $r('app.float.wh_value_12'), 262 top: 8 263 }) 264 }.zIndex(1) 265 .onAreaChange((oldArea, newArea) => { 266 this.headRectHeight = newArea.height as number; 267 this.headRectHeightReal = newArea.height as number; 268 }) 269 270 Stack({ alignContent: Alignment.TopEnd }) { 271 Scroll(this.scroller) { 272 this.buildContent() 273 } 274 .padding({ 275 left: 16, right: 16, 276 bottom: $r('app.float.wh_value_24') 277 }) 278 .align(Alignment.Top) 279 .scrollable(ScrollDirection.Vertical) 280 .edgeEffect(EdgeEffect.Spring) 281 .scrollBar(BarState.Off) 282 .width(WidthPercent.WH_100_100) 283 .height(WidthPercent.WH_AUTO) 284 .constraintSize({ 285 minHeight: this.getScrollMinHeight() 286 }).onAreaChange((oldArea, newArea) => { 287 this.scrollerHeight = newArea.height as number; 288 }) 289 290 Column() { 291 ScrollBar({ 292 scroller: this.scroller, 293 direction: ScrollBarDirection.Vertical, 294 state: BarState.Auto 295 }).margin({ 296 bottom: $r('app.float.wh_value_24') 297 }) 298 }.height(this.scrollerHeight) 299 }.padding({ 300 top: this.headRectHeight 301 }) 302 } 303 } 304 .hideTitleBar(true) 305 .width(WidthPercent.WH_100_100) 306 .height(this.sheetParam?.lastSheetPage === NavEntryKey.CA_SYSTEM_DETAIL_ENTRY ? 307 WidthPercent.WH_AUTO : this.sheetParam?.sheetMinHeight) 308 .backgroundColor($r('sys.color.background_secondary')) 309 .onReady((ctx: NavDestinationContext) => { 310 this.stack = ctx.pathStack; 311 }) 312 } 313 314 getScrollMinHeight() { 315 if (this.sheetParam === undefined || this.headRectHeightReal === 0 || 316 this.sheetParam.sheetMinHeight < this.headRectHeightReal) { 317 return 0; 318 } 319 return this.sheetParam.sheetMinHeight - this.headRectHeightReal; 320 } 321 322 @Builder 323 private buildContent() { 324 Column() { 325 Text(this.mShowSysCaPresenter.certInfo.certAlias) 326 .fontSize($r('sys.float.ohos_id_text_size_body1')) 327 .fontColor($r('sys.color.ohos_id_color_text_primary')) 328 .fontWeight(FontWeight.Medium) 329 .margin({ 330 top: $r('app.float.wh_value_8'), 331 bottom: $r('app.float.wh_value_24') 332 }) 333 .alignSelf(ItemAlign.Start) 334 335 Text($r('app.string.CustomDialogExample_firListItem_text')) 336 .fontSize($r('sys.float.ohos_id_text_size_body1')) 337 .fontColor($r('sys.color.ohos_id_color_text_primary')) 338 .fontWeight(FontWeight.Medium) 339 340 DialogSubjectComponent({ map: this.mShowSysCaPresenter.certInfo.subjectNameMap }) 341 342 Text($r('app.string.CustomDialogExample_secListItem_text')) 343 .fontSize($r('sys.float.ohos_id_text_size_body1')) 344 .fontColor($r('sys.color.ohos_id_color_text_primary')) 345 .fontWeight(FontWeight.Medium) 346 .margin({ 347 top: $r('app.float.wh_value_24') 348 }) 349 350 DialogIssuerComponent({ map: this.mShowSysCaPresenter.certInfo.issuerNameMap }) 351 352 Text($r('app.string.CustomDialogExample_thdListItem_text')) 353 .fontSize($r('sys.float.ohos_id_text_size_body1')) 354 .fontColor($r('sys.color.ohos_id_color_text_primary')) 355 .fontWeight(FontWeight.Medium) 356 .margin({ 357 top: $r('app.float.wh_value_24') 358 }) 359 360 DialogDateComponent({ map: this.mShowSysCaPresenter.certInfo.dateMap }) 361 362 Text($r('app.string.CustomDialogExample_fouListItem_text')) 363 .fontSize($r('sys.float.ohos_id_text_size_body1')) 364 .fontColor($r('sys.color.ohos_id_color_text_primary')) 365 .fontWeight(FontWeight.Medium) 366 .margin({ 367 top: $r('app.float.wh_value_24') 368 }) 369 370 DialogFingerPrintComponent({ fingerprintSha256: this.mShowSysCaPresenter.certInfo.fingerprintSha256 }) 371 } 372 .alignItems(HorizontalAlign.Start) 373 .width(WidthPercent.WH_100_100) 374 } 375}