From f55523cfd1989241b1003de70562109793b7be5f Mon Sep 17 00:00:00 2001 From: snowxqshi Date: Thu, 13 Oct 2022 14:10:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=97=E6=AF=8D=E6=8C=89=E9=92=AE=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F=EF=BC=8C=E5=8C=BA=E5=88=86=E5=A4=A7=E5=B0=8F=E5=86=99?= =?UTF-8?q?=E5=8F=8A=E4=BA=8B=E4=BB=B6=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/common/keyItemNumber.ets | 81 +++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 entry/src/main/ets/common/keyItemNumber.ets diff --git a/entry/src/main/ets/common/keyItemNumber.ets b/entry/src/main/ets/common/keyItemNumber.ets new file mode 100644 index 0000000..76a4dc8 --- /dev/null +++ b/entry/src/main/ets/common/keyItemNumber.ets @@ -0,0 +1,81 @@ +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 keyItemNumber { + private keyValue: keySourceListType + @Link upper: number + @State isChinese: boolean = AppStorage.Get("isChinese") + + @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.SpaceAround }) { + Text(this.keyValue.title) + .fontSize(inputStyle.litterNumberFontSize) + .fontColor(0x606060) + .fontWeight(FontWeight.Lighter) + if (this.upper === 0) { + Text(this.keyValue.content) + .fontSize(inputStyle.en_fontSize) + .fontColor('#000') + .fontWeight(FontWeight.Regular) + } else { + Text(this.keyValue.upperContent) + .fontSize(inputStyle.en_fontSize) + .fontColor('#000') + .fontWeight(FontWeight.Regular) + } + } + .backgroundColor('#ffffff') + .borderRadius(4) + .padding({ top: '5%', bottom: '5%' }) + .onClick(() => { + if (this.upper === 0) { + console.info('may-->111122233444:cccc') + InputHandler.getInstance().insertText(this.keyValue.content,this.isChinese); + } else { + console.info('may-->111122233444:dddd') + if (this.upper === 1) { + this.upper = 0 + } + InputHandler.getInstance().insertText(this.keyValue.upperContent,this.isChinese); + } + }) + .width(basicButtonWidth) + .height(basicButtonHeight) + .shadow({ radius: 1, color: '#76787c', offsetY: 3 }) + .stateStyles({ + normal: this.normalStyles, pressed: this.pressedStyles + }) + } +} \ No newline at end of file -- Gitee