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 { WidthPercent } from '../../common/util/ConfigData'; 18import { AlertDialog, CustomContentDialog } from '@ohos.arkui.advanced.Dialog'; 19import { BusinessError } from '@ohos.base'; 20import CmShowSysCredPresenter from '../../presenter/CmShowSysCredPresenter'; 21 22const TAG: string = 'CredSystemDetailPage: '; 23 24export class CredSystemDetailParam { 25 public presenter: CmShowSysCredPresenter; 26 27 constructor(presenter: CmShowSysCredPresenter) { 28 this.presenter = presenter; 29 } 30} 31 32@Component 33export struct CredSystemDetailPage { 34 private presenter: CmShowSysCredPresenter = CmShowSysCredPresenter.getInstance(); 35 36 private stack?: NavPathStack; 37 38 @State private bottomRectHeight: Length = $r('sys.float.padding_level8'); 39 40 deleteWarnDialog: CustomDialogController = new CustomDialogController({ 41 builder: AlertDialog({ 42 primaryTitle: $r('app.string.warning_title'), 43 content: $r('app.string.warning_message'), 44 primaryButton: { 45 value: $r('app.string.cancelAuthApp'), 46 buttonStyle: ButtonStyleMode.TEXTUAL, 47 action: () => { 48 } 49 }, 50 secondaryButton: { 51 value: $r('app.string.deleteAllCredDelete'), 52 buttonStyle: ButtonStyleMode.TEXTUAL, 53 action: () => { 54 this.presenter.deleteSystemCred(this.presenter.credInfo.keyUri); 55 this.presenter.updateSystemCredList(); 56 this.stack?.pop(); 57 }, 58 role: ButtonRole.ERROR 59 } 60 }), 61 }) 62 63 build() { 64 NavDestination() { 65 Stack({ alignContent: Alignment.Bottom }) { 66 Column() { 67 HeadComponent({ headName: $r('app.string.evidenceDetails'), isStartBySheet: true, onBackClicked: () => { 68 this.stack?.pop(); 69 } }) 70 .margin({ 71 left: $r('app.float.wh_value_12'), 72 top: 8 73 }) 74 75 Scroll() { 76 this.buildContent() 77 } 78 .align(Alignment.Top) 79 .scrollable(ScrollDirection.Vertical) 80 .scrollBar(BarState.Auto) 81 .edgeEffect(EdgeEffect.Spring) 82 .width(WidthPercent.WH_100_100) 83 .layoutWeight(1) 84 } 85 .width(WidthPercent.WH_100_100) 86 .height(WidthPercent.WH_100_100) 87 .padding({ 88 bottom: this.bottomRectHeight 89 }) 90 91 Column() { 92 Button($r('app.string.warning_title')) 93 .onClick(() => { 94 this.deleteWarnDialog.open(); 95 }) 96 .role(ButtonRole.ERROR) 97 .buttonStyle(ButtonStyleMode.NORMAL) 98 .margin({ 99 top: $r('app.float.distance_16'), 100 bottom: $r('app.float.distance_24') 101 }) 102 .width(WidthPercent.WH_100_100) 103 }.onAreaChange((oldArea: Area, newArea: Area) => { 104 this.bottomRectHeight = newArea.height as number; 105 }) 106 .padding({ 107 left: 16, right: 16 108 }) 109 } 110 } 111 .hideTitleBar(true) 112 .width(WidthPercent.WH_100_100) 113 .height(WidthPercent.WH_100_100) 114 .backgroundColor($r('sys.color.background_secondary')) 115 .onReady((ctx: NavDestinationContext) => { 116 this.stack = ctx.pathStack; 117 try { 118 this.presenter = (ctx.pathInfo.param as CredSystemDetailParam).presenter; 119 } catch (err) { 120 let error = err as BusinessError; 121 console.error(TAG + 'Get presenter failed: ' + error?.code + ', message: ' + error?.message); 122 } 123 }) 124 } 125 126 @Builder 127 private buildContent() { 128 Column() { 129 Text(this.presenter.credInfo.alias) 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 left: $r('app.float.wh_value_24'), 135 right: $r('app.float.wh_value_24') 136 }) 137 .alignSelf(ItemAlign.Start) 138 139 Text($r('app.string.entryContains')) 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 .margin({ 144 top: $r('app.float.wh_value_24'), 145 left: $r('app.float.wh_value_24'), 146 right: $r('app.float.wh_value_24') 147 }) 148 .alignSelf(ItemAlign.Start) 149 150 Text($r('app.string.keyNum', String(this.presenter.credInfo.keyNum))) 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 .margin({ 155 left: $r('app.float.wh_value_10'), 156 right: $r('app.float.wh_value_10') 157 }) 158 .opacity($r('app.float.opacity_100_60')) 159 .alignSelf(ItemAlign.Start) 160 161 Text($r('app.string.userCerNum', String(this.presenter.credInfo.certNum))) 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 .margin({ 166 left: $r('app.float.wh_value_10'), 167 right: $r('app.float.wh_value_10') 168 }) 169 .opacity($r('app.float.opacity_100_60')) 170 .alignSelf(ItemAlign.Start) 171 } 172 .width(WidthPercent.WH_100_100) 173 .alignItems(HorizontalAlign.Start) 174 } 175}