From d0364a257ef182942e9aaea5bd50aaa8aa29f776 Mon Sep 17 00:00:00 2001 From: gong-qingzhong Date: Wed, 12 Oct 2022 18:26:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=B8=AD=E8=8B=B1=E6=96=87?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E6=8C=89=E9=92=AE=E5=8F=8A=E7=82=B9=E5=87=BB?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/.gitignore | 3 + .idea/applications_inputmethod.iml | 9 +++ .idea/misc.xml | 6 ++ .idea/modules.xml | 8 +++ .idea/vcs.xml | 6 ++ entry/src/main/ets/common/changeItem.ets | 74 ++++++++++++++++++++++++ 6 files changed, 106 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/applications_inputmethod.iml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 entry/src/main/ets/common/changeItem.ets diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/applications_inputmethod.iml b/.idea/applications_inputmethod.iml new file mode 100644 index 0000000..d6ebd48 --- /dev/null +++ b/.idea/applications_inputmethod.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..639900d --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..227b524 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/entry/src/main/ets/common/changeItem.ets b/entry/src/main/ets/common/changeItem.ets new file mode 100644 index 0000000..74dc32b --- /dev/null +++ b/entry/src/main/ets/common/changeItem.ets @@ -0,0 +1,74 @@ +// @ts-nocheck +import styleConfiguration from '../common/styleConfiguration' + + +let inputStyle: any = styleConfiguration.getInputStyle() +let basicButtonHeight : string +let switchButtonWidth : string + + + +// 中英文切换 +@Component +export struct changeItem { + + private keyValue: string + @Link menuType: number + @State isChinese: boolean = AppStorage.Get("isChinese") + + @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; + } + else{ + basicButtonHeight = inputStyle.basicButtonHeight; + switchButtonWidth = inputStyle.switchButtonWidth; + } + + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + if (this.isChinese) { + Row() { + Text("中").fontSize(inputStyle.switchNumberFontSize_g).fontColor('black') + Text("/英").fontSize(inputStyle.switchNumberFontSize).fontColor('black') + } + } else { + Row() { + Text("中/").fontSize(inputStyle.switchNumberFontSize).fontColor('black') + Text("英").fontSize(inputStyle.switchNumberFontSize_g).fontColor('black') + } + } + } + .backgroundColor('#a8abb7') + .borderRadius(6) + .height(basicButtonHeight) + .width(switchButtonWidth)//mxg inputStyle.switchButtonWidth + .shadow({ radius: 1, color: '#76787c', offsetY: 3 }) + .stateStyles({ + normal: this.normalStyles, pressed: this.pressedStyles + }) + + .onClick(() => { + if (this.keyValue === 'PY') { + this.menuType = 3 // 拼音 + AppStorage.SetOrCreate('isChinese',true) + }else { + this.menuType = 0 //英文 + AppStorage.SetOrCreate('isChinese',false) + } + }) + } +} \ No newline at end of file -- Gitee