From a8f5135dead84c804acbea04e5df35281d1533a3 Mon Sep 17 00:00:00 2001 From: x-zyu Date: Thu, 13 Oct 2022 12:00:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=AD=E6=96=87=E9=94=AE=E7=9B=98=E6=8C=89?= =?UTF-8?q?=E9=94=AE=E6=98=BE=E7=A4=BA=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/common/keyItem.ets | 58 +++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 entry/src/main/ets/common/keyItem.ets diff --git a/entry/src/main/ets/common/keyItem.ets b/entry/src/main/ets/common/keyItem.ets new file mode 100644 index 0000000..caa452f --- /dev/null +++ b/entry/src/main/ets/common/keyItem.ets @@ -0,0 +1,58 @@ +import { keySourceListType} from '../model/keyboardKeyData' +import { InputHandler } from '../model/InputHandler' +import styleConfiguration from '../common/styleConfiguration' + + +let inputStyle: any = styleConfiguration.getInputStyle() +let basicButtonWidth : string +let basicButtonHeight : string + + +//无大小写的按键组件 +@Component +export struct keyItem { + private keyValue: keySourceListType + private color: string + + @Styles pressedStyles() { + .backgroundColor("#AEB3BD") + } + + @Styles normalStyles() { + .backgroundColor("#ffffff") + } + + aboutToAppear() : void{ + + var dHeight = AppStorage.Get("dHeight") + if (dHeight == 1280) { + basicButtonWidth = inputStyle.basicButtonWidth_1280; + basicButtonHeight = inputStyle.basicButtonHeight_1280; + } + else{ + basicButtonWidth = inputStyle.basicButtonWidth; + basicButtonHeight = inputStyle.basicButtonHeight; + } + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(this.keyValue.content) + .fontSize(inputStyle.en_fontSize) + .fontColor('black') + } + .backgroundColor('#fff') + .borderRadius(4) + .width(basicButtonWidth) + .height(basicButtonHeight) + .shadow({ radius: 1, color: '#76787c', offsetY: 3 }) + .padding({ top: '5%', bottom: '5%' }) + .onClick(() => { + console.info('may-->111122233444:eeee') + InputHandler.getInstance().insertText(this.keyValue.content); + }) + .stateStyles({ + normal: this.normalStyles, pressed: this.pressedStyles + }) + } +} \ No newline at end of file -- Gitee