Skip to content

Commit

Permalink
code review updates
Browse files Browse the repository at this point in the history
  • Loading branch information
smb2268 committed Nov 22, 2024
1 parent 614fe21 commit 26c07a8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
4 changes: 2 additions & 2 deletions app/src/atoms/SoftwareKeyboard/AlphanumericKeyboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useSelector } from 'react-redux'
import { getAppLanguage } from '/app/redux/config'
import {
alphanumericKeyboardLayout,
pinYinLayoutCandidates,
layoutCandidates,
customDisplay,
} from '../constants'
import type { KeyboardReactInterface } from 'react-simple-keyboard'
Expand Down Expand Up @@ -55,7 +55,7 @@ export function AlphanumericKeyboard({
layoutName={layoutName}
layout={alphanumericKeyboardLayout}
layoutCandidates={
appLanguage === 'zh-CN' ? pinYinLayoutCandidates : undefined
appLanguage != null ? layoutCandidates[appLanguage] : undefined
}
display={customDisplay}
mergeDisplay={true}
Expand Down
4 changes: 2 additions & 2 deletions app/src/atoms/SoftwareKeyboard/FullKeyboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useSelector } from 'react-redux'
import { getAppLanguage } from '/app/redux/config'
import {
customDisplay,
pinYinLayoutCandidates,
layoutCandidates,
fullKeyboardLayout,
} from '../constants'
import type { KeyboardReactInterface } from 'react-simple-keyboard'
Expand Down Expand Up @@ -64,7 +64,7 @@ export function FullKeyboard({
layoutName={layoutName}
layout={fullKeyboardLayout}
layoutCandidates={
appLanguage === 'zh-CN' ? pinYinLayoutCandidates : undefined
appLanguage != null ? layoutCandidates[appLanguage] : undefined
}
display={customDisplay}
mergeDisplay={true}
Expand Down
17 changes: 14 additions & 3 deletions app/src/atoms/SoftwareKeyboard/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import chineseLayout from 'simple-keyboard-layouts/build/layouts/chinese'

type LayoutCandidates =
| {
[key: string]: string
}
| undefined

export const customDisplay = {
'{numbers}': '123',
'{shift}': 'ABC',
Expand Down Expand Up @@ -72,6 +78,11 @@ export const numericalCustom = {
'{backspace}': 'del',
}

// @ts-expect-error layout candidates exists but is not on the type
// in the simple-keyboard-layouts package
export const pinYinLayoutCandidates = chineseLayout.layoutCandidates
export const layoutCandidates: {
[key: string]: LayoutCandidates
} = {
// @ts-expect-error layout candidates exists but is not on the type
// in the simple-keyboard-layouts package
'zh-CN': chineseLayout.layoutCandidates,
'en-US': undefined,
}

0 comments on commit 26c07a8

Please sign in to comment.