1/* 2 * Copyright (c) 2024 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 router from '@ohos.router'; 17import image from '@ohos.multimedia.image'; 18import Logger from '../../../util/Logger'; 19import testNapi, { testNapiValue } from 'libentry.so'; 20import { TitleBar } from '../../../common/TitleBar' 21import hilog from '@ohos.hilog'; 22 23const TAG: string = 'napi_create_int32'; 24 25@Entry 26@Component 27struct napiCreateInt32 { 28 private btnFontColor: Resource = $r('app.color.white'); 29 private pixelMapFormat: image.PixelMapFormat = 3; 30 @State isSetInstance: Boolean = false; 31 @State imagePixelMap: PixelMap | undefined = undefined; 32 @State textcont: Resource = $r('app.string.napi_create_int32_description'); 33 @State testcont: string = ' // 测试 N-API napi_create_int32 \n' 34 + ' const myData = testNapi.testNapiCreateInt32(); \n' 35 + ' // 使用获取的自定义数据 \n' 36 + ' console.log(myData); // 输出自定义数据 \n'; 37 38 controller: TextAreaController = new TextAreaController() 39 40 build() { 41 Column() { 42 // 标题 43 TitleBar({ title: $r('app.string.napi_create_int32') }) 44 45 Column() { 46 Column() { 47 TextArea({ 48 text: this.textcont, 49 placeholder: '', 50 }) 51 .placeholderFont({ size: 16, weight: 400 }) 52 .width('90%') 53 .margin(10) 54 .fontSize(16) 55 .fontColor($r('app.color.sub_title_color')) 56 .backgroundColor($r('app.color.white')) 57 .enabled(false) 58 59 TextArea({ 60 text: this.testcont, 61 placeholder: '', 62 }) 63 .placeholderFont({ size: 16, weight: 400 }) 64 .width('90%') 65 .margin(10) 66 .fontSize(16) 67 .fontColor($r('app.color.textarea_font_color')) 68 .backgroundColor($r('app.color.textarea_background_color')) 69 .enabled(false) 70 } 71 .width('100%') 72 .alignItems(HorizontalAlign.Center) 73 .justifyContent(FlexAlign.Start) 74 75 Row() { 76 77 Button($r('app.string.napi_create_int32'), { type: ButtonType.Capsule }) 78 .backgroundColor(Color.Blue) 79 .width('80%') 80 .height(48) 81 .fontSize(16) 82 .fontWeight(500) 83 .fontColor(this.btnFontColor) 84 .margin({ left: 24 }) 85 .id('napi_create_int32') 86 .onClick(() => { 87 let ret = testNapi.testNapiCreateInt32(3); 88 console.info("ret = " + ret) 89 this.testcont = this.testcont.replace('log(myData)', 'log(## '+ret+' ##)'); 90 }) 91 } 92 .width('100%') 93 .height(48) 94 .alignItems(VerticalAlign.Center) 95 .justifyContent(FlexAlign.SpaceBetween) 96 } 97 .width('100%') 98 } 99 .height('100%') 100 .width('100%') 101 .backgroundColor($r('app.color.background_shallow_grey')) 102 } 103}