1/** 2 * Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development 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 ConfigData from '../utils/ConfigData'; 17import wifi from '@ohos.wifi'; 18 19/** 20 * WifiView Component of wifi test 21 */ 22 23const TAG = "[wifiView]" 24 25@Component 26export struct WifiView { 27 private wifi!: wifi.WifiScanInfo; 28 private securityString: Resource = $r('app.string.encryption') 29 @State isLock: boolean = true 30 31 aboutToAppear() { 32 console.log(TAG , `aboutToAppear ${ JSON.stringify(this.wifi) }`) 33 if ( this.wifi ) { 34 if ( this.wifi.securityType ) { 35 if ( this.wifi.securityType === 1 ) { 36 this.securityString = $r('app.string.open') 37 this.isLock = false 38 } else { 39 console.log(TAG , "this.wifi.securityType /= 0 && this.wifi.securityType /= 1") 40 } 41 } else { 42 console.log(TAG , "this.wifi.securityType is false") 43 } 44 } else { 45 console.log(TAG , "this.wifi is false") 46 } 47 } 48 49 build() { 50 Row() { 51 Column() { 52 if ( this.wifi ) { 53 if ( this.wifi.ssid ) { 54 Text(this.wifi.ssid) 55 .fontSize(20) 56 .width(ConfigData.WH_100_100) 57 } 58 } 59 Text(this.securityString) 60 .fontSize(18) 61 .fontColor(Color.Gray) 62 .width(ConfigData.WH_100_100) 63 } 64 .layoutWeight(1) 65 66 Stack({ alignContent : Alignment.BottomEnd }) { 67 Image($r('app.media.wifi')) 68 .height(30).width(30) 69 .objectFit(ImageFit.Contain) 70 if ( this.isLock ) { 71 Image($r('app.media.lock')) 72 .objectFit(ImageFit.Contain) 73 .width(15).height(15) 74 } 75 } 76 .width(40).height(40) 77 .margin({ right : 10 }) 78 } 79 .backgroundColor(Color.White) 80 .width(ConfigData.WH_100_100) 81 .padding(10) 82 } 83}