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 wifi from '@ohos.wifi'
17import ConfigData from '../utils/ConfigData';
18/**
19 * PswDialog page of WiFi test
20 */
21
22@CustomDialog
23export struct PswDialog {
24  private scanInfo!: wifi.WifiScanInfo
25  private psw: string = ''
26  private controller: CustomDialogController
27  private action!: (scanInfo: wifi.WifiScanInfo , psw: string) => void
28
29  build() {
30    Column() {
31      Text(this.scanInfo.ssid)
32        .fontSize(20)
33        .width(ConfigData.WH_95_100)
34      TextInput({ placeholder : '请输入密码' })
35        .type(InputType.Password)
36        .placeholderColor(Color.Gray)
37        .fontSize(19)
38        .margin({ top : 15 })
39        .width(ConfigData.WH_95_100)
40        .onChange((value: string) => {
41          this.psw = value
42        })
43      Row() {
44        Button() {
45          Text($r('app.string.cancel'))
46            .fontColor(Color.Red)
47            .fontSize(17)
48        }
49        .layoutWeight(7)
50        .backgroundColor(Color.White)
51        .margin(5)
52        .onClick(() => {
53          this.controller.close()
54        })
55
56        Text()
57          .width(1).height(35)
58          .backgroundColor('#8F8F8F')
59        Button() {
60          Text($r('app.string.sure'))
61            .fontColor(Color.Blue)
62            .fontSize(17)
63        }
64        .layoutWeight(7)
65        .backgroundColor(Color.White)
66        .margin(5)
67        .onClick(() => {
68          this.controller.close()
69          this.action(this.scanInfo , this.psw)
70        })
71      }
72      .width(ConfigData.WH_100_100)
73      .margin({ top : ConfigData.WH_3_100 })
74    }
75    .padding(15)
76  }
77}
78
79