1/* 2 * Copyright (c) 2022-2023 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 window from '@ohos.window'; 17 18import BackComponent from '../component/backComponent'; 19import Log from '../utils/log'; 20import EntryViewController from '../controller/entryViewController'; 21import CommonController from '../controller/commonController'; 22 23@Entry 24@Component 25struct Index { 26 private readonly TAG: string = 'Index'; 27 @State resultString: string = ''; 28 @StorageLink('SYSTEM_STATUS_BAR_HEIGHT') SYSTEM_STATUS_BAR_HEIGHT: number = 0; 29 @StorageLink('SYSTEM_NAVIGATION_BAR_HEIGHT') SYSTEM_NAVIGATION_BAR_HEIGHT: number = 0; 30 31 build() { 32 Column() { 33 BackComponent({ prevTag: this.TAG }) 34 Text('临时认证界面') 35 .fontColor($r('sys.color.ohos_id_color_text_primary')) 36 .fontSize($r('sys.float.ohos_id_text_size_headline7')) 37 .fontWeight(FontWeight.Bold) 38 Text('请将锁屏密码设置为123456后,点击认证按钮') 39 .fontColor($r('sys.color.ohos_id_color_text_primary')) 40 .fontSize($r('sys.float.ohos_id_text_size_sub_title1')) 41 .fontWeight(FontWeight.Medium) 42 .margin({ 43 top: '12', 44 bottom: '24' 45 }) 46 Button({ type: ButtonType.Capsule, stateEffect: true }) { 47 Text('认证') 48 .fontColor($r('sys.color.ohos_id_color_foreground_contrary')) 49 .fontSize($r('sys.float.ohos_id_text_size_button1')) 50 .fontWeight(FontWeight.Medium) 51 } 52 .backgroundColor($r('sys.color.ohos_id_color_activated')) 53 .onClick(()=>{ 54 EntryViewController.doPINAuth() 55 .catch(()=>{this.resultString = '认证失败,请将锁屏密码设置为123456后重试'}) 56 }) 57 .width('30%') 58 Text(this.resultString) 59 .fontColor($r('sys.color.ohos_id_color_text_primary')) 60 .fontSize($r('sys.float.ohos_id_text_size_sub_title1')) 61 .fontWeight(FontWeight.Medium) 62 } 63 .alignItems(HorizontalAlign.Center) 64 .width('100%') 65 .height('100%') 66 .backgroundColor($r('sys.color.ohos_id_color_sub_background')) 67 .onAreaChange((_, newArea) => { 68 try { 69 window.on('systemBarTintChange', (data) => { 70 if (data !== null && data !== undefined) { 71 Log.info(this.TAG, 'receive system bar tint change: ' + JSON.stringify(data)); 72 for (let i = 0; i < data.regionTint.length; i++) { 73 let regionData = data.regionTint[i] 74 if (regionData.region) { 75 if (regionData.type === window.WindowType.TYPE_STATUS_BAR) { 76 this.SYSTEM_STATUS_BAR_HEIGHT = px2vp(regionData.region.height) 77 Log.info(this.TAG, 'set status bar height ' + regionData.region.height) 78 continue 79 } 80 if (regionData.type === window.WindowType.TYPE_NAVIGATION_BAR) { 81 this.SYSTEM_NAVIGATION_BAR_HEIGHT = px2vp(regionData.region.height) 82 Log.info(this.TAG, 'set navigation ba r height ' + this.SYSTEM_NAVIGATION_BAR_HEIGHT) 83 continue 84 } 85 } 86 } 87 } 88 }); 89 } catch (exception) { 90 Log.error(this.TAG, 'Failed to register systemBarTintChange' + JSON.stringify(exception)) 91 } 92 Log.info(this.TAG, 'new display area :' + JSON.stringify(newArea)) 93 CommonController.setDisplaySize(Number(newArea.width), Number(newArea.height)) 94 Log.info(this.TAG, 'total area w: ' + newArea.width + ' h: ' + newArea.height) 95 }) 96 } 97 98 onBackPress(): boolean { 99 Log.info(this.TAG, 'onBackPress+'); 100 CommonController.routeBack(); 101 Log.info(this.TAG, 'onBackPress-'); 102 return true; 103 } 104}