1/** 2 * Copyright (c) 2021 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 */ 15import ComponentConfig from './ComponentConfig'; 16import InputMethod from '@ohos.inputMethod'; 17 18/** 19 * TextInput component 20 */ 21@Component 22export default struct textInputComponent { 23 private hintText: string= ''; 24 private contextText: string= ''; 25 26 build() { 27 TextInput({ placeholder: this.hintText, text: this.contextText }) 28 .placeholderColor(Color.Blue) 29 .placeholderFont({ size: ConfigData.font_20, weight: 2, family: "sans-serif", style: FontStyle.Normal }) 30 .caretColor(Color.Blue) 31 .height($r('app.float.wh_value_70')) 32 .backgroundColor(Color.White) 33 .type(InputType.Password) 34 .width(ComponentConfig.WH_100_100) 35 .margin({ left: $r('app.float.wh_value_15'), right: $r('app.float.wh_value_15') }) 36 .onChange((value: string) => { 37 this.contextText = value; 38 }) 39 .onSubmit((enterKey) => { 40 InputMethod.getInputMethodController().stopInput().then((ret) => { 41 LogUtil.debug(`${ConfigData.TAG}, enterType: ${enterKey}, stopInput: ${ret}`); 42 }); 43 }); 44 } 45}