1c41cb6d2Sopenharmony_ci/**
2c41cb6d2Sopenharmony_ci * Copyright (c) 2021 Huawei Device Co., Ltd.
3c41cb6d2Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4c41cb6d2Sopenharmony_ci * you may not use this file except in compliance with the License.
5c41cb6d2Sopenharmony_ci * You may obtain a copy of the License at
6c41cb6d2Sopenharmony_ci *
7c41cb6d2Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8c41cb6d2Sopenharmony_ci *
9c41cb6d2Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10c41cb6d2Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11c41cb6d2Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12c41cb6d2Sopenharmony_ci * See the License for the specific language governing permissions and
13c41cb6d2Sopenharmony_ci * limitations under the License.
14c41cb6d2Sopenharmony_ci */
15c41cb6d2Sopenharmony_ciimport ComponentConfig from './ComponentConfig';
16c41cb6d2Sopenharmony_ciimport InputMethod from '@ohos.inputMethod';
17c41cb6d2Sopenharmony_ci
18c41cb6d2Sopenharmony_ci/**
19c41cb6d2Sopenharmony_ci * TextInput component
20c41cb6d2Sopenharmony_ci */
21c41cb6d2Sopenharmony_ci@Component
22c41cb6d2Sopenharmony_ciexport default struct textInputComponent {
23c41cb6d2Sopenharmony_ci  private hintText: string= '';
24c41cb6d2Sopenharmony_ci  private contextText: string= '';
25c41cb6d2Sopenharmony_ci
26c41cb6d2Sopenharmony_ci  build() {
27c41cb6d2Sopenharmony_ci    TextInput({ placeholder: this.hintText, text: this.contextText })
28c41cb6d2Sopenharmony_ci      .placeholderColor(Color.Blue)
29c41cb6d2Sopenharmony_ci      .placeholderFont({ size: ConfigData.font_20, weight: 2, family: "sans-serif", style: FontStyle.Normal })
30c41cb6d2Sopenharmony_ci      .caretColor(Color.Blue)
31c41cb6d2Sopenharmony_ci      .height($r('app.float.wh_value_70'))
32c41cb6d2Sopenharmony_ci      .backgroundColor(Color.White)
33c41cb6d2Sopenharmony_ci      .type(InputType.Password)
34c41cb6d2Sopenharmony_ci      .width(ComponentConfig.WH_100_100)
35c41cb6d2Sopenharmony_ci      .margin({ left: $r('app.float.wh_value_15'), right: $r('app.float.wh_value_15') })
36c41cb6d2Sopenharmony_ci      .onChange((value: string) => {
37c41cb6d2Sopenharmony_ci        this.contextText = value;
38c41cb6d2Sopenharmony_ci      })
39c41cb6d2Sopenharmony_ci      .onSubmit((enterKey) => {
40c41cb6d2Sopenharmony_ci        InputMethod.getInputMethodController().stopInput().then((ret) => {
41c41cb6d2Sopenharmony_ci          LogUtil.debug(`${ConfigData.TAG}, enterType: ${enterKey}, stopInput: ${ret}`);
42c41cb6d2Sopenharmony_ci        });
43c41cb6d2Sopenharmony_ci      });
44c41cb6d2Sopenharmony_ci  }
45c41cb6d2Sopenharmony_ci}