• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2024 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 InputStyle KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import inputMethod from '@ohos.inputMethod';
17import Log from '../model/Log';
18import { BusinessError } from '@ohos.base';
19
20const TAG: string = 'PrivatePreview->';
21
22@Entry
23@Component
24struct PrivatePreview {
25  @State message: string = 'Hello World';
26  @State accountText: string = '';
27  @State preViewText: string = '';
28  @StorageLink('isTextPreviewSupported') isTextPreviewSupported: boolean = true;
29  controllerPrivate: TextInputController = new TextInputController();
30  controllerPreview: TextInputController = new TextInputController();
31
32  aboutToAppear() {
33    this.addLog(`private preview aboutToAppear begin!`);
34    inputMethod.getSetting().showOptionalInputMethods().then((data: boolean) => {
35      console.log('onPageShow Succeeded in showing optionalInputMethods.');
36    }).catch((err: BusinessError) => {
37      console.error(`onPageShow Failed to showOptionalInputMethods: ${JSON.stringify(err)}`);
38    })
39  }
40
41  onPageShow() {
42    this.addLog(`private command onPageShow!`);
43  }
44
45  addLog(message: string): void {
46    Log.showInfo(TAG, `kikaInput-new: ${message}`);
47  }
48
49  build() {
50    Column() {
51      Text($r('app.string.Preview_Text'))
52        .width('100%')
53        .height(56)
54        .fontFamily('HarmonyHeiTi-Medium')
55        .fontSize('16fp')
56        .fontColor('#182431')
57        .lineHeight(22)
58        .fontWeight(500)
59
60      TextInput({
61        text: this.preViewText,
62        placeholder: $r('app.string.Preview_tip'),
63        controller: this.controllerPreview
64      })
65        .placeholderFont({ size: 16, weight: 400 })
66        .width('100%')
67        .height(56)
68        .margin(10)
69        .fontSize(16)
70        .fontColor('#182431')
71        .backgroundColor('#FFFFFF')
72        .border({ width: 1, color: Color.Gray, radius: 18 })
73        .maxLength(50)
74        .onChange((value: string) => {
75          this.addLog('preViewText onChange.');
76        })
77        .onSubmit(() => {
78          this.addLog('preViewText onSubmit.');
79        })
80    }
81    .width('100%')
82    .padding(20)
83  }
84}