diff --git a/entry/src/main/ets/common/keyMenu.ets b/entry/src/main/ets/common/keyMenu.ets new file mode 100644 index 0000000000000000000000000000000000000000..9c7c0ba66725b71efa79aa5b955b1a86a176b828 --- /dev/null +++ b/entry/src/main/ets/common/keyMenu.ets @@ -0,0 +1,134 @@ +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 + + +//key键盘 +@Component +export struct keyMenu { + 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(() => { + 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: 'PY', menuType: $menuType }) + changeItem({ keyValue: 'PY', 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