From f9342889f7e5e24da7b83b86d16acd77c3b7a654 Mon Sep 17 00:00:00 2001 From: sudashao Date: Thu, 13 Oct 2022 10:53:23 +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/chineseKeyMenu.ets | 137 +++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 entry/src/main/ets/common/chineseKeyMenu.ets diff --git a/entry/src/main/ets/common/chineseKeyMenu.ets b/entry/src/main/ets/common/chineseKeyMenu.ets new file mode 100644 index 0000000..faad68d --- /dev/null +++ b/entry/src/main/ets/common/chineseKeyMenu.ets @@ -0,0 +1,137 @@ +// @ts-nocheck +import {keySourceListType} from '../model/keyboardKeyData' +import { keyItemNumber } from './keyItemNumber' +import { deleteItem } from './deleteItem' +import { keyItemGray } from './keyItemGray' +import { keyItem } from './keyItem' +import { spaceItem } from './spaceItem' +import { changeItem } from './changeItem' +import { returnItem } from './returnItem' +import styleConfiguration from '../common/styleConfiguration' + + +let inputStyle: any = styleConfiguration.getInputStyle() +let basicButtonHeight : string +let switchButtonWidth : string +let returnButtonWidthType_2 : string +let spaceButtonWidth_2 : string + + +//chinesekey键盘 +@Component +export struct chineseKeyMenu { + private keyList: keySourceListType[] + @State public upper: number= 0 + @Link menuType: number + + @Styles pressedStyles() { + .backgroundColor("#868b95") + } + + @Styles normalStyles() { + .backgroundColor("#a8abb7") + } + + aboutToAppear() : void{ + + var dHeight = AppStorage.Get("dHeight") + if (dHeight == 1280) { + + basicButtonHeight = inputStyle.basicButtonHeight_1280; + switchButtonWidth = inputStyle.switchButtonWidth_1280; + returnButtonWidthType_2 = inputStyle.returnButtonWidthType_1280_2; + spaceButtonWidth_2 = inputStyle.spaceButtonWidth_1280_2; + } + else{ + basicButtonHeight = inputStyle.basicButtonHeight; + switchButtonWidth = inputStyle.switchButtonWidth; + returnButtonWidthType_2 = inputStyle.returnButtonWidthType_2; + spaceButtonWidth_2 = inputStyle.spaceButtonWidth_2; + + } + + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center }) { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { + ForEach(this.keyList.slice(0, 10), (item: keySourceListType) => { + keyItemNumber({ keyValue: item, upper: $upper }) + }, (item: keySourceListType) => item.content) + } + .width('100%') + .height(basicButtonHeight) + .margin({ top: inputStyle.paddingTop }) + + Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { + Stack() { + }.width('4%').height(0) + + ForEach(this.keyList.slice(10, 19), (item: keySourceListType) => { + keyItemNumber({ keyValue: item, upper: $upper }) + }, (item: keySourceListType) => item.content) + Stack() { + }.width('4%').height(0) + } + .width('100%') + .height(basicButtonHeight) + .margin({ top: inputStyle.paddingTop }) + + Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { + Stack() { + Image($rawfile(this.upper === 1 ? 'shift light.svg' : this.upper === 2 ? 'shift light long.svg' : 'shift.svg')) + .width(inputStyle.featurePicSize) + .height(inputStyle.featurePicSize) + } + .backgroundColor('#a8abb7') + .borderRadius(4) + .onClick(() => { + console.log('may-->7') + if (this.upper === 0) { + this.upper = 1 + } else if (this.upper === 1) { + this.upper = 2 + } else if (this.upper === 2) { + this.upper = 0 + } + }) + .height(basicButtonHeight) + .width(switchButtonWidth) /////mxg + .shadow({ radius: 1, color: '#76787c', offsetY: 3 }) + .stateStyles({ + normal: this.normalStyles, pressed: this.pressedStyles + }) + + + ForEach(this.keyList.slice(19), (item: keySourceListType) => { + keyItemNumber({ keyValue: item, upper: $upper }) + }, (item: keySourceListType) => item.content) + deleteItem() + } + .width('100%')///mxg + .height(basicButtonHeight) + .margin({ top: inputStyle.paddingTop }) + + Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { + keyItemGray({ keyValue: '?123', menuType: $menuType }) + keyItem({ keyValue: { content: ',', title: ',', upperContent: ',' }, color: '#a8abb7' }) + spaceItem({ spaceWith: spaceButtonWidth_2 }) + + keyItem({ keyValue: { content: '。', title: '。', upperContent: '。' }, color: '#a8abb7' }) + // keyItemGray({ keyValue: 'ABC', menuType: $menuType }) + changeItem({ keyValue: 'ABC', menuType: $menuType }) + returnItem({ returnWidth: returnButtonWidthType_2 }) + } + .width('100%') + .height(basicButtonHeight) + .margin({ top: inputStyle.paddingTop }) + + } + .width('100%') + .height('100%') + .padding({ + left: inputStyle.paddingLeftRight, + right: inputStyle.paddingLeftRight + }) + } +} \ No newline at end of file -- Gitee