• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2025 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
16@CustomDialog
17@Component
18export struct ScanDialog {
19  @Link textValueOfInterval: string;
20  @Link inputValueOfInterval: string;
21  @Link textValueOfManufactureId: string;
22  @Link inputValueOfManufactureId: string;
23  @Link textValueOfDeviceName: string;
24  @Link inputValueOfDeviceName: string;
25  @Link textValueOfDeviceId: string;
26  @Link inputValueOfDeviceId: string;
27  controller?: CustomDialogController
28  cancel: () => void = () => {
29  }
30  confirm: () => void = () => {
31  }
32
33  build() {
34    Column() {
35      Text('set scan filtering parameters').fontSize(20).margin({ top: 10, bottom: 10 });
36      Row() {
37        Text('interval')
38          .width('30%')
39          .margin(5)
40        TextInput({ placeholder: 'default is 0', text: this.textValueOfInterval })
41          .height(40)
42          .width('65%')
43          .onChange((value: string) => {
44            this.textValueOfInterval = value;
45          })
46
47      }
48
49      Row() {
50        Text('manufactureId')
51          .width('30%')
52          .margin(5)
53        TextInput({ placeholder: 'default is 4567', text: this.textValueOfManufactureId })
54          .height(40)
55          .width('65%')
56          .onChange((value: string) => {
57            this.textValueOfManufactureId = value;
58          })
59      }
60
61      Row() {
62        Text('deviceName')
63          .width('30%')
64          .margin(5)
65        TextInput({ placeholder: 'default is \'\'', text: this.textValueOfDeviceName })
66          .height(40)
67          .width('65%')
68          .onChange((value: string) => {
69            this.textValueOfDeviceName = value;
70          })
71      }
72
73      Row() {
74        Text('deviceId')
75          .width('30%')
76          .margin(5)
77        TextInput({ placeholder: 'default is \'\'', text: this.textValueOfDeviceId })
78          .height(40)
79          .width('65%')
80          .onChange((value: string) => {
81            this.textValueOfDeviceId = value;
82          })
83      }
84
85      Flex({ justifyContent: FlexAlign.SpaceAround }) {
86        Button('cancel')
87          .onClick(() => {
88            if (this.controller != undefined) {
89              this.controller.close();
90              this.cancel();
91            }
92          }).backgroundColor(0xffffff).fontColor(Color.Black)
93
94        Button('clean up')
95          .onClick(() => {
96            this.textValueOfInterval = '';
97            this.inputValueOfInterval = '0';
98            this.textValueOfManufactureId = '';
99            this.inputValueOfManufactureId = '4567';
100            this.textValueOfDeviceName = '';
101            this.inputValueOfDeviceName = '';
102            this.textValueOfDeviceId = '';
103            this.inputValueOfDeviceId = '';
104          }).backgroundColor(0xffffff).fontColor(Color.Red)
105
106        Button('confirm')
107          .onClick(() => {
108            if (this.controller != undefined) {
109              this.inputValueOfInterval = this.textValueOfInterval;
110              this.inputValueOfManufactureId = this.textValueOfManufactureId;
111              this.inputValueOfDeviceName = this.textValueOfDeviceName;
112              this.inputValueOfDeviceId = this.textValueOfDeviceId;
113              this.controller.close();
114              this.confirm();
115            }
116          }).backgroundColor(0xffffff).fontColor(Color.Red)
117      }.margin({ bottom: 10 })
118    }.borderRadius(10)
119  }
120}