@a16n/web-sim 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -2
- package/bin/cli.ts +255 -0
- package/bin/web-sim.js +39 -0
- package/overrides/@backpackapp-io/react-native-toast/overrides.ts +15 -0
- package/overrides/@react-native-firebase/app/overrides.ts +34 -0
- package/overrides/@tiktok-for-business/react-native-sdk/NativeTiktokSdk.ts +29 -0
- package/overrides/@tiktok-for-business/react-native-sdk/overrides.ts +9 -0
- package/overrides/expo-application/ExpoApplication.ts +81 -0
- package/overrides/expo-application/overrides.ts +16 -0
- package/overrides/expo-background-task/ExpoBackgroundTaskModule.ts +30 -0
- package/overrides/expo-background-task/overrides.ts +9 -0
- package/overrides/expo-constants/ExponentConstants.ts +66 -0
- package/overrides/expo-constants/overrides.ts +9 -0
- package/overrides/expo-device/ExpoDevice.ts +104 -0
- package/overrides/expo-device/overrides.ts +9 -0
- package/overrides/expo-glass-effect/GlassContainer.tsx +9 -0
- package/overrides/expo-glass-effect/GlassView.tsx +95 -0
- package/overrides/expo-glass-effect/availability.ts +14 -0
- package/overrides/expo-glass-effect/overrides.ts +14 -0
- package/overrides/expo-haptics/Haptics.ts +67 -0
- package/overrides/expo-haptics/overrides.ts +5 -0
- package/overrides/expo-mail-composer/ExpoMailComposer.ts +40 -0
- package/overrides/expo-mail-composer/overrides.ts +9 -0
- package/overrides/expo-mesh-gradient/MeshGradientView.tsx +44 -0
- package/overrides/expo-mesh-gradient/overrides.ts +9 -0
- package/overrides/expo-modules-core/overrides.ts +12 -0
- package/overrides/expo-navigation-bar/ExpoNavigationBar.ts +29 -0
- package/overrides/expo-navigation-bar/NavigationBar.ts +43 -0
- package/overrides/expo-navigation-bar/overrides.ts +12 -0
- package/overrides/expo-router/NativeStackView.tsx +74 -0
- package/overrides/expo-router/NativeTabsView.tsx +263 -0
- package/overrides/expo-router/SafeAreaProvider.ts +6 -0
- package/overrides/expo-router/overrides.ts +23 -0
- package/overrides/expo-router/statusBarRequests.ts +51 -0
- package/overrides/expo-screen-orientation/ExpoScreenOrientation.ts +173 -0
- package/overrides/expo-screen-orientation/overrides.ts +21 -0
- package/overrides/expo-sharing/SharingNativeModule.ts +21 -0
- package/overrides/expo-sharing/overrides.ts +9 -0
- package/overrides/expo-sms/ExpoSMS.ts +24 -0
- package/overrides/expo-sms/overrides.ts +9 -0
- package/overrides/expo-splash-screen/SplashScreen.ts +25 -0
- package/overrides/expo-splash-screen/overrides.ts +5 -0
- package/overrides/expo-status-bar/StatusBar.tsx +44 -0
- package/overrides/expo-status-bar/overrides.ts +5 -0
- package/overrides/expo-store-review/ExpoStoreReview.ts +18 -0
- package/overrides/expo-store-review/overrides.ts +9 -0
- package/overrides/expo-symbols/SymbolView.tsx +192 -0
- package/overrides/expo-symbols/overrides.ts +9 -0
- package/overrides/expo-system-ui/ExpoSystemUI.ts +34 -0
- package/overrides/expo-system-ui/overrides.ts +9 -0
- package/overrides/expo-task-manager/ExpoTaskManager.ts +39 -0
- package/overrides/expo-task-manager/overrides.ts +9 -0
- package/overrides/expo-tracking-transparency/ExpoTrackingTransparency.ts +30 -0
- package/overrides/expo-tracking-transparency/overrides.ts +11 -0
- package/overrides/expo-video/ExpoVideo.ts +16 -0
- package/overrides/expo-video/overrides.ts +9 -0
- package/overrides/lottie-react-native/LottieView.tsx +87 -0
- package/overrides/lottie-react-native/overrides.ts +9 -0
- package/overrides/react-native-pager-view/PagerViewNativeComponent.tsx +254 -0
- package/overrides/react-native-pager-view/overrides.ts +9 -0
- package/overrides/react-native-reanimated/overrides.ts +28 -0
- package/overrides/react-native-safe-area-context/NativeSafeAreaProvider.tsx +40 -0
- package/overrides/react-native-safe-area-context/overrides.ts +12 -0
- package/overrides/react-native-share/NativeRNShare.ts +22 -0
- package/overrides/react-native-share/overrides.ts +12 -0
- package/overrides/react-native-share/platform.ts +14 -0
- package/overrides/react-native-turbo-image/TurboImage.tsx +101 -0
- package/overrides/react-native-turbo-image/overrides.ts +9 -0
- package/overrides/react-native-web/RefreshControl.tsx +57 -0
- package/overrides/react-native-web/overrides.ts +153 -0
- package/overrides/react-native-web/useElementLayout.ts +140 -0
- package/package.json +78 -4
- package/plugins/battery/overrides/expo-battery/ExpoBattery.ts +57 -0
- package/plugins/battery/overrides/expo-battery/overrides.ts +9 -0
- package/plugins/battery/plugin.ts +8 -0
- package/plugins/battery/shell.tsx +56 -0
- package/plugins/battery/state.ts +11 -0
- package/plugins/biometrics/overrides/expo-local-authentication/ExpoLocalAuthentication.ts +90 -0
- package/plugins/biometrics/overrides/expo-local-authentication/overrides.ts +11 -0
- package/plugins/biometrics/plugin.ts +8 -0
- package/plugins/biometrics/shell.tsx +88 -0
- package/plugins/biometrics/state.ts +41 -0
- package/plugins/brightness/app.ts +5 -0
- package/plugins/brightness/overrides/expo-brightness/Brightness.ts +98 -0
- package/plugins/brightness/overrides/expo-brightness/overrides.ts +10 -0
- package/plugins/brightness/plugin.ts +9 -0
- package/plugins/brightness/shell.tsx +55 -0
- package/plugins/brightness/state.ts +19 -0
- package/plugins/calendar/calendar.ts +299 -0
- package/plugins/calendar/overrides/expo-calendar/ExpoCalendar.ts +358 -0
- package/plugins/calendar/overrides/expo-calendar/LegacyExpoCalendar.ts +163 -0
- package/plugins/calendar/overrides/expo-calendar/overrides.ts +14 -0
- package/plugins/calendar/plugin.ts +8 -0
- package/plugins/calendar/shell.tsx +123 -0
- package/plugins/camera/overrides/expo-camera/ExpoCamera.tsx +269 -0
- package/plugins/camera/overrides/expo-camera/ExpoCameraManager.ts +56 -0
- package/plugins/camera/overrides/expo-camera/overrides.ts +12 -0
- package/plugins/camera/plugin.ts +9 -0
- package/plugins/camera/shell.tsx +107 -0
- package/plugins/camera/state.ts +61 -0
- package/plugins/clipboard/overrides/expo-clipboard/ExpoClipboard.ts +138 -0
- package/plugins/clipboard/overrides/expo-clipboard/overrides.ts +9 -0
- package/plugins/clipboard/plugin.ts +8 -0
- package/plugins/clipboard/shell.tsx +122 -0
- package/plugins/clipboard/state.ts +93 -0
- package/plugins/clock/app.ts +25 -0
- package/plugins/clock/plugin.ts +8 -0
- package/plugins/clock/shell.tsx +225 -0
- package/plugins/clock/state.ts +12 -0
- package/plugins/contacts/contacts.ts +125 -0
- package/plugins/contacts/overrides/expo-contacts/ExpoContacts.ts +153 -0
- package/plugins/contacts/overrides/expo-contacts/ExpoContactsNext.ts +232 -0
- package/plugins/contacts/overrides/expo-contacts/overrides.ts +12 -0
- package/plugins/contacts/plugin.ts +8 -0
- package/plugins/contacts/shell.tsx +109 -0
- package/plugins/home-indicator/app.ts +5 -0
- package/plugins/home-indicator/plugin.ts +9 -0
- package/plugins/home-indicator/requests.ts +48 -0
- package/plugins/home-indicator/shell.tsx +68 -0
- package/plugins/home-indicator/state.ts +31 -0
- package/plugins/keep-awake/app.ts +5 -0
- package/plugins/keep-awake/overrides/expo-keep-awake/ExpoKeepAwake.ts +27 -0
- package/plugins/keep-awake/overrides/expo-keep-awake/overrides.ts +9 -0
- package/plugins/keep-awake/plugin.ts +9 -0
- package/plugins/keep-awake/shell.tsx +80 -0
- package/plugins/keep-awake/state.ts +12 -0
- package/plugins/keyboard/Keyboard.tsx +354 -0
- package/plugins/keyboard/app.ts +90 -0
- package/plugins/keyboard/controller.ts +384 -0
- package/plugins/keyboard/fields.ts +244 -0
- package/plugins/keyboard/icons.tsx +283 -0
- package/plugins/keyboard/keyboard.css +362 -0
- package/plugins/keyboard/layouts/android.ts +175 -0
- package/plugins/keyboard/layouts/index.ts +10 -0
- package/plugins/keyboard/layouts/ios.ts +219 -0
- package/plugins/keyboard/layouts/types.ts +80 -0
- package/plugins/keyboard/overrides/react-native-keyboard-controller/KeyboardController.tsx +470 -0
- package/plugins/keyboard/overrides/react-native-keyboard-controller/overrides.ts +9 -0
- package/plugins/keyboard/plugin.ts +13 -0
- package/plugins/keyboard/shell.tsx +133 -0
- package/plugins/keyboard/state.ts +92 -0
- package/plugins/keyboard/suggestions.ts +63 -0
- package/plugins/keyboard/taps.ts +77 -0
- package/plugins/keyboard/typing.ts +112 -0
- package/plugins/locale/app.ts +232 -0
- package/plugins/locale/locale.ts +143 -0
- package/plugins/locale/overrides/expo-localization/ExpoLocalization.ts +41 -0
- package/plugins/locale/overrides/expo-localization/overrides.ts +9 -0
- package/plugins/locale/plugin.ts +9 -0
- package/plugins/locale/shell.tsx +147 -0
- package/plugins/locale/state.ts +36 -0
- package/plugins/location/geo.ts +56 -0
- package/plugins/location/overrides/expo-location/ExpoLocation.ts +235 -0
- package/plugins/location/overrides/expo-location/overrides.ts +11 -0
- package/plugins/location/places.ts +38 -0
- package/plugins/location/plugin.ts +8 -0
- package/plugins/location/shell.tsx +188 -0
- package/plugins/location/state.ts +51 -0
- package/plugins/motion/overrides/expo-sensors/DeviceSensor.ts +169 -0
- package/plugins/motion/overrides/expo-sensors/ExponentPedometer.ts +54 -0
- package/plugins/motion/overrides/expo-sensors/overrides.ts +14 -0
- package/plugins/motion/plugin.ts +8 -0
- package/plugins/motion/sensors.ts +116 -0
- package/plugins/motion/shell.tsx +136 -0
- package/plugins/motion/state.ts +46 -0
- package/plugins/network/app.ts +400 -0
- package/plugins/network/overrides/expo-network/ExpoNetwork.ts +51 -0
- package/plugins/network/overrides/expo-network/overrides.ts +9 -0
- package/plugins/network/plugin.ts +8 -0
- package/plugins/network/shell.tsx +67 -0
- package/plugins/network/state.ts +29 -0
- package/plugins/notifications/center.ts +255 -0
- package/plugins/notifications/content.ts +36 -0
- package/plugins/notifications/overrides/expo-notifications/NotificationsModule.ts +175 -0
- package/plugins/notifications/overrides/expo-notifications/channels.ts +108 -0
- package/plugins/notifications/overrides/expo-notifications/getDevicePushTokenAsync.ts +19 -0
- package/plugins/notifications/overrides/expo-notifications/getExpoPushTokenAsync.ts +16 -0
- package/plugins/notifications/overrides/expo-notifications/overrides.ts +36 -0
- package/plugins/notifications/plugin.ts +8 -0
- package/plugins/notifications/shell.tsx +192 -0
- package/plugins/notifications/state.ts +56 -0
- package/plugins/notifications/tokens.ts +47 -0
- package/plugins/notifications/trigger.ts +107 -0
- package/plugins/permissions/plugin.ts +6 -0
- package/plugins/permissions/shell.tsx +50 -0
- package/plugins/permissions/state.ts +38 -0
- package/plugins/photos/appLibrary.ts +114 -0
- package/plugins/photos/library.ts +322 -0
- package/plugins/photos/overrides/expo-image-picker/ExponentImagePicker.ts +153 -0
- package/plugins/photos/overrides/expo-image-picker/overrides.ts +13 -0
- package/plugins/photos/overrides/expo-media-library/ExpoMediaLibrary.ts +235 -0
- package/plugins/photos/overrides/expo-media-library/NativeMediaLibraryModule.ts +318 -0
- package/plugins/photos/overrides/expo-media-library/overrides.ts +19 -0
- package/plugins/photos/plugin.ts +8 -0
- package/plugins/photos/samples.ts +367 -0
- package/plugins/photos/shell.tsx +164 -0
- package/plugins/photos/state.ts +88 -0
- package/plugins/storage/files.ts +351 -0
- package/plugins/storage/overrides/expo-file-system/ExpoFileSystem.ts +770 -0
- package/plugins/storage/overrides/expo-file-system/ExponentFileSystem.ts +196 -0
- package/plugins/storage/overrides/expo-file-system/overrides.ts +13 -0
- package/plugins/storage/overrides/expo-secure-store/ExpoSecureStore.ts +75 -0
- package/plugins/storage/overrides/expo-secure-store/overrides.ts +9 -0
- package/plugins/storage/plugin.ts +8 -0
- package/plugins/storage/reset.ts +136 -0
- package/plugins/storage/secure.ts +71 -0
- package/plugins/storage/shell.tsx +365 -0
- package/plugins/storage/state.ts +13 -0
- package/src/client/app/appDocument.ts +113 -0
- package/src/client/app/appFocus.ts +97 -0
- package/src/client/app/console.ts +118 -0
- package/src/client/app/fonts.ts +59 -0
- package/src/client/app/main.tsx +99 -0
- package/src/client/app/routeContext.ts +45 -0
- package/src/client/app/touch.ts +640 -0
- package/src/client/entry.ts +20 -0
- package/src/client/modules.d.ts +8 -0
- package/src/client/react-native/app.ts +57 -0
- package/src/client/react-native/deep.ts +13 -0
- package/src/client/react-native/keyboard.tsx +192 -0
- package/src/client/react-native/library.ts +256 -0
- package/src/client/shell/Cookies.tsx +95 -0
- package/src/client/shell/LogDrawer.tsx +415 -0
- package/src/client/shell/PhotoPicker.tsx +174 -0
- package/src/client/shell/PluginOverlays.tsx +42 -0
- package/src/client/shell/PluginPanels.tsx +82 -0
- package/src/client/shell/ResetApp.tsx +87 -0
- package/src/client/shell/Resizer.tsx +99 -0
- package/src/client/shell/Shell.tsx +531 -0
- package/src/client/shell/SystemBars.tsx +376 -0
- package/src/client/shell/SystemCamera.tsx +181 -0
- package/src/client/shell/SystemOverlay.tsx +422 -0
- package/src/client/shell/SystemSheets.tsx +462 -0
- package/src/client/shell/backdrop.ts +229 -0
- package/src/client/shell/control.ts +91 -0
- package/src/client/shell/events.ts +226 -0
- package/src/client/shell/geometry.ts +68 -0
- package/src/client/shell/host.ts +492 -0
- package/src/client/shell/icons.tsx +34 -0
- package/src/client/shell/logFeed.ts +102 -0
- package/src/client/shell/main.tsx +22 -0
- package/src/client/shell/permissionCopy.ts +169 -0
- package/src/client/shell/plugins.ts +266 -0
- package/src/client/shell/popout.ts +185 -0
- package/src/client/shell/popover.ts +27 -0
- package/src/client/shell/shell.css +878 -0
- package/src/client/shell/statusTime.ts +31 -0
- package/src/client/shell/tooltips.ts +104 -0
- package/src/client/virtual.d.ts +21 -0
- package/src/devices/catalog.ts +223 -0
- package/src/devices/types.ts +83 -0
- package/src/node/appInfo.ts +186 -0
- package/src/node/appSource.ts +138 -0
- package/src/node/config.ts +180 -0
- package/src/node/control.ts +144 -0
- package/src/node/doctor.ts +199 -0
- package/src/node/events/cli.ts +206 -0
- package/src/node/events/shared.ts +238 -0
- package/src/node/events/store.ts +266 -0
- package/src/node/index.ts +5 -0
- package/src/node/overrides/define.ts +56 -0
- package/src/node/overrides/packages.ts +136 -0
- package/src/node/overrides/platformPatch.ts +56 -0
- package/src/node/overrides/plugin.ts +166 -0
- package/src/node/overrides/registry.ts +258 -0
- package/src/node/paths.ts +18 -0
- package/src/node/platform.ts +171 -0
- package/src/node/plugins.ts +98 -0
- package/src/node/proxy.ts +421 -0
- package/src/node/server.ts +253 -0
- package/src/plugin/index.ts +33 -0
- package/src/plugin/types.ts +127 -0
- package/src/plugin/ui.tsx +562 -0
- package/src/runtime/clock.ts +112 -0
- package/src/runtime/draw.ts +196 -0
- package/src/runtime/index.ts +513 -0
- package/src/runtime/media.ts +379 -0
- package/src/runtime/records.ts +76 -0
- package/src/runtime/timezone.ts +81 -0
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import type { Layer } from '../state.ts'
|
|
2
|
+
import { isNumberPad, type KeyAction, type KeyboardLayout, type KeySpec, type KeyTone, type LayoutInput, NUMBER_PAD_SUB_LABELS } from './types.ts'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Gboard with Material 3 keys, as on a Pixel: a strip for suggestions and the toolbar over four rows of rounded keys,
|
|
6
|
+
* an optional number row, and the navigation bar's height under them.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const DIGITS = '1234567890'
|
|
10
|
+
const NUMBERS_ROW_2 = '@#$_&-+()/'
|
|
11
|
+
const NUMBERS_ROW_3 = '*"\':;!?'
|
|
12
|
+
const SYMBOLS_ROW_1 = '~`|•√π÷×¶∆'
|
|
13
|
+
const SYMBOLS_ROW_2 = '£¢€¥^°={}\\'
|
|
14
|
+
const SYMBOLS_ROW_3 = '%©®™✓[]'
|
|
15
|
+
|
|
16
|
+
type Rows = { keyHeight: number; pitch: number; numberRowHeight: number; numberRowPitch: number; strip: number; top: number; bottom: number; side: number; gap: number; radius: number }
|
|
17
|
+
|
|
18
|
+
function rows(input: LayoutInput): Rows {
|
|
19
|
+
const landscape = input.orientation === 'landscape'
|
|
20
|
+
const bottom = input.navigationHeight + (landscape ? 4 : 8)
|
|
21
|
+
return landscape
|
|
22
|
+
? { keyHeight: 34, pitch: 40, numberRowHeight: 30, numberRowPitch: 34, strip: 38, top: 2, bottom, side: Math.max(input.insets.left, input.insets.right) + 6, gap: 6, radius: 8 }
|
|
23
|
+
: { keyHeight: 46, pitch: 56, numberRowHeight: 38, numberRowPitch: 46, strip: 46, top: 4, bottom, side: 4, gap: 6, radius: 10 }
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function androidLayout(input: LayoutInput): KeyboardLayout {
|
|
27
|
+
if (isNumberPad(input.keyboardType)) {
|
|
28
|
+
return numberPad(input)
|
|
29
|
+
}
|
|
30
|
+
const base = rows(input)
|
|
31
|
+
const area = input.width - 2 * base.side
|
|
32
|
+
const pitch = (area + base.gap) / 10
|
|
33
|
+
const keyWidth = pitch - base.gap
|
|
34
|
+
const numberRow = input.numberRow && input.layer === 'letters'
|
|
35
|
+
const rowsHeight = (input.numberRow ? base.numberRowPitch : 0) + 3 * base.pitch + base.keyHeight
|
|
36
|
+
const height = base.strip + base.top + rowsHeight + base.bottom
|
|
37
|
+
// With the number row on, the other layers' four rows grow to keep the keyboard's height.
|
|
38
|
+
const grow = input.numberRow && !numberRow ? rowsHeight / (3 * base.pitch + base.keyHeight) : 1
|
|
39
|
+
const r = { ...base, keyHeight: base.keyHeight * grow, pitch: base.pitch * grow }
|
|
40
|
+
const rowY = (row: number) => height - r.bottom - r.keyHeight - (3 - row) * r.pitch
|
|
41
|
+
const x0 = r.side
|
|
42
|
+
const key = (id: string, action: KeyAction, x: number, row: number, width: number, tone: KeyTone, label?: string): KeySpec => ({
|
|
43
|
+
id,
|
|
44
|
+
action,
|
|
45
|
+
x,
|
|
46
|
+
y: rowY(row),
|
|
47
|
+
width,
|
|
48
|
+
height: r.keyHeight,
|
|
49
|
+
radius: r.radius,
|
|
50
|
+
tone,
|
|
51
|
+
popup: action.kind === 'letter' || (action.kind === 'char' && tone === 'character'),
|
|
52
|
+
label,
|
|
53
|
+
})
|
|
54
|
+
const row = (chars: string, row: number, startX: number, letters: boolean, hints?: string) =>
|
|
55
|
+
[...chars].map((char, index) => ({
|
|
56
|
+
...key(letters ? `letter:${char}` : `char:${char}`, letters ? { kind: 'letter', char } : { kind: 'char', char }, startX + index * pitch, row, keyWidth, 'character', letters ? undefined : char),
|
|
57
|
+
hint: hints?.[index],
|
|
58
|
+
}))
|
|
59
|
+
const wide = 1.5 * pitch - r.gap
|
|
60
|
+
const thirdRow = (chars: string, left: KeySpec, letters: boolean): KeySpec[] => {
|
|
61
|
+
const span = area - 2 * (wide + r.gap)
|
|
62
|
+
const width = (span - (chars.length - 1) * r.gap) / chars.length
|
|
63
|
+
return [
|
|
64
|
+
left,
|
|
65
|
+
...[...chars].map((char, index) =>
|
|
66
|
+
key(letters ? `letter:${char}` : `char:${char}`, letters ? { kind: 'letter', char } : { kind: 'char', char }, x0 + wide + r.gap + index * (width + r.gap), 2, width, 'character', letters ? undefined : char),
|
|
67
|
+
),
|
|
68
|
+
key('delete', { kind: 'delete' }, x0 + area - wide, 2, wide, 'function'),
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
const bottomRow = (layer: Layer, layerLabel: string): KeySpec[] => {
|
|
72
|
+
const second: [string, KeyAction, string] =
|
|
73
|
+
input.keyboardType === 'email' && input.layer === 'letters'
|
|
74
|
+
? ['char:@', { kind: 'char', char: '@' }, '@']
|
|
75
|
+
: input.keyboardType === 'url' && input.layer === 'letters'
|
|
76
|
+
? ['char:/', { kind: 'char', char: '/' }, '/']
|
|
77
|
+
: ['char:,', { kind: 'char', char: ',' }, ',']
|
|
78
|
+
let x = x0
|
|
79
|
+
const keys: KeySpec[] = []
|
|
80
|
+
const add = (id: string, action: KeyAction, width: number, tone: KeyTone, label?: string) => {
|
|
81
|
+
keys.push({ ...key(id, action, x, 3, width, tone, label), popup: false })
|
|
82
|
+
x += width + r.gap
|
|
83
|
+
}
|
|
84
|
+
add(`layer:${layer}`, { kind: 'layer', layer }, wide, 'function', layerLabel)
|
|
85
|
+
add(second[0], second[1], keyWidth, 'function', second[2])
|
|
86
|
+
add('emoji', { kind: 'emoji' }, keyWidth, 'function')
|
|
87
|
+
add('space', { kind: 'space' }, 4 * pitch - r.gap, 'character')
|
|
88
|
+
add('char:.', { kind: 'char', char: '.' }, keyWidth, 'function', '.')
|
|
89
|
+
add('return', { kind: 'return' }, wide, 'accent')
|
|
90
|
+
return keys
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
let keys: KeySpec[]
|
|
94
|
+
switch (input.layer) {
|
|
95
|
+
case 'letters':
|
|
96
|
+
keys = [
|
|
97
|
+
...row('qwertyuiop', 0, x0, true, input.numberRow ? undefined : DIGITS),
|
|
98
|
+
...row('asdfghjkl', 1, x0 + pitch / 2, true),
|
|
99
|
+
...thirdRow('zxcvbnm', key('shift', { kind: 'shift' }, x0, 2, wide, 'function'), true),
|
|
100
|
+
...bottomRow('numbers', '?123'),
|
|
101
|
+
]
|
|
102
|
+
if (numberRow) {
|
|
103
|
+
const y = r.strip + r.top
|
|
104
|
+
keys.push(
|
|
105
|
+
...[...DIGITS].map((char, index) => ({
|
|
106
|
+
...key(`char:${char}`, { kind: 'char', char }, x0 + index * pitch, 0, keyWidth, 'character', char),
|
|
107
|
+
y,
|
|
108
|
+
height: r.numberRowHeight,
|
|
109
|
+
})),
|
|
110
|
+
)
|
|
111
|
+
}
|
|
112
|
+
break
|
|
113
|
+
case 'numbers':
|
|
114
|
+
keys = [
|
|
115
|
+
...row(DIGITS, 0, x0, false),
|
|
116
|
+
...row(NUMBERS_ROW_2, 1, x0, false),
|
|
117
|
+
...thirdRow(NUMBERS_ROW_3, key('layer:symbols', { kind: 'layer', layer: 'symbols' }, x0, 2, wide, 'function', '=\\<'), false),
|
|
118
|
+
...bottomRow('letters', 'ABC'),
|
|
119
|
+
]
|
|
120
|
+
break
|
|
121
|
+
case 'symbols':
|
|
122
|
+
keys = [
|
|
123
|
+
...row(SYMBOLS_ROW_1, 0, x0, false),
|
|
124
|
+
...row(SYMBOLS_ROW_2, 1, x0, false),
|
|
125
|
+
...thirdRow(SYMBOLS_ROW_3, key('layer:numbers', { kind: 'layer', layer: 'numbers' }, x0, 2, wide, 'function', '?123'), false),
|
|
126
|
+
...bottomRow('letters', 'ABC'),
|
|
127
|
+
]
|
|
128
|
+
break
|
|
129
|
+
}
|
|
130
|
+
return {
|
|
131
|
+
platform: 'android',
|
|
132
|
+
width: input.width,
|
|
133
|
+
height,
|
|
134
|
+
keys,
|
|
135
|
+
strip: { y: 0, height: r.strip, x: r.side, width: area },
|
|
136
|
+
numberPad: false,
|
|
137
|
+
scale: r.keyHeight / 46,
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** Gboard's number pad: three columns of digits and a column of space, delete and return. */
|
|
142
|
+
function numberPad(input: LayoutInput): KeyboardLayout {
|
|
143
|
+
const r = rows(input)
|
|
144
|
+
const height = r.top + 8 + 3 * r.pitch + r.keyHeight + r.bottom
|
|
145
|
+
const area = input.width - 2 * r.side
|
|
146
|
+
const gap = r.gap
|
|
147
|
+
const functionWidth = area * 0.2
|
|
148
|
+
const digitWidth = (area - functionWidth - 3 * gap) / 3
|
|
149
|
+
const key = (id: string, action: KeyAction, column: number, row: number, tone: KeyTone, label?: string): KeySpec => ({
|
|
150
|
+
id,
|
|
151
|
+
action,
|
|
152
|
+
x: r.side + column * (digitWidth + gap),
|
|
153
|
+
y: height - r.bottom - r.keyHeight - (3 - row) * r.pitch,
|
|
154
|
+
width: column === 3 ? functionWidth : digitWidth,
|
|
155
|
+
height: r.keyHeight,
|
|
156
|
+
radius: r.radius,
|
|
157
|
+
tone,
|
|
158
|
+
popup: false,
|
|
159
|
+
label,
|
|
160
|
+
subLabel: input.keyboardType === 'phone' && label !== undefined ? NUMBER_PAD_SUB_LABELS[label] : undefined,
|
|
161
|
+
})
|
|
162
|
+
const digits = [...'123456789'].map((digit, index) => key(`char:${digit}`, { kind: 'char', char: digit }, index % 3, Math.floor(index / 3), 'character', digit))
|
|
163
|
+
const phone = input.keyboardType === 'phone'
|
|
164
|
+
const keys = [
|
|
165
|
+
...digits,
|
|
166
|
+
key(phone ? 'char:*' : 'char:,', { kind: 'char', char: phone ? '*' : ',' }, 0, 3, 'function', phone ? '*' : ','),
|
|
167
|
+
key('char:0', { kind: 'char', char: '0' }, 1, 3, 'character', '0'),
|
|
168
|
+
key(phone ? 'char:#' : 'char:.', { kind: 'char', char: phone ? '#' : '.' }, 2, 3, 'function', phone ? '#' : '.'),
|
|
169
|
+
key(phone ? 'char:+' : 'char:-', { kind: 'char', char: phone ? '+' : '-' }, 3, 0, 'function', phone ? '+' : '-'),
|
|
170
|
+
key('space', { kind: 'space' }, 3, 1, 'function'),
|
|
171
|
+
key('delete', { kind: 'delete' }, 3, 2, 'function'),
|
|
172
|
+
key('return', { kind: 'return' }, 3, 3, 'accent'),
|
|
173
|
+
]
|
|
174
|
+
return { platform: 'android', width: input.width, height, keys, strip: null, numberPad: true, scale: r.keyHeight / 46 }
|
|
175
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { androidLayout } from './android.ts'
|
|
2
|
+
import { iosLayout } from './ios.ts'
|
|
3
|
+
import type { KeyboardLayout, LayoutInput } from './types.ts'
|
|
4
|
+
|
|
5
|
+
export type { KeyAction, KeyboardLayout, KeySpec, LayoutInput, StripSpec } from './types.ts'
|
|
6
|
+
export { isNumberPad } from './types.ts'
|
|
7
|
+
|
|
8
|
+
export function buildLayout(input: LayoutInput): KeyboardLayout {
|
|
9
|
+
return input.platform === 'ios' ? iosLayout(input) : androidLayout(input)
|
|
10
|
+
}
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import type { KeyboardType, Layer } from '../state.ts'
|
|
2
|
+
import { isNumberPad, type KeyAction, type KeyboardLayout, type KeySpec, type LayoutInput, NUMBER_PAD_SUB_LABELS } from './types.ts'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The iOS 26 keyboard. Measured on an iPhone 17 Pro in portrait (402 points wide); other widths scale across, and
|
|
6
|
+
* landscape and home-button phones have their own rows, as iOS draws them.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const NUMBERS_ROW_1 = '1234567890'
|
|
10
|
+
const NUMBERS_ROW_2 = '-/:;()$&@"'
|
|
11
|
+
const SYMBOLS_ROW_1 = '[]{}#%^*+='
|
|
12
|
+
const SYMBOLS_ROW_2 = '_\\|~<>£€¥•'
|
|
13
|
+
const PUNCTUATION_ROW = ".,?!'"
|
|
14
|
+
|
|
15
|
+
/** Points from the bottom of the keyboard and from the top of the keys, per kind of phone and orientation. */
|
|
16
|
+
type Rows = {
|
|
17
|
+
keyHeight: number
|
|
18
|
+
pitch: number
|
|
19
|
+
/** Under the bottom row: room for the emoji and dictation keys and the home indicator. */
|
|
20
|
+
bottom: number
|
|
21
|
+
/** Over the top row, when there is no suggestion strip. */
|
|
22
|
+
top: number
|
|
23
|
+
strip: number
|
|
24
|
+
/** The keys' left edge; they span the screen less this on both sides. */
|
|
25
|
+
side: number
|
|
26
|
+
gap: number
|
|
27
|
+
/** Where the emoji and dictation keys go: under the keys, in the side margins, or in the bottom row. */
|
|
28
|
+
accessories: 'below' | 'sides' | 'row'
|
|
29
|
+
radius: number
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function rows(input: LayoutInput): Rows {
|
|
33
|
+
const landscape = input.orientation === 'landscape'
|
|
34
|
+
const scale = input.width / 402
|
|
35
|
+
if (input.homeButton) {
|
|
36
|
+
return landscape
|
|
37
|
+
? { keyHeight: 32, pitch: 39, bottom: 3, top: 9, strip: 38, side: 3, gap: 6, accessories: 'row', radius: 6 }
|
|
38
|
+
: { keyHeight: 42, pitch: 54, bottom: 3, top: 9, strip: 44, side: 3, gap: 6, accessories: 'row', radius: 8.5 }
|
|
39
|
+
}
|
|
40
|
+
if (landscape) {
|
|
41
|
+
const side = Math.max(input.insets.left, input.insets.right)
|
|
42
|
+
return { keyHeight: 32, pitch: 38, bottom: input.insets.bottom + 4, top: 6, strip: 36, side, gap: 6, accessories: 'sides', radius: 7 }
|
|
43
|
+
}
|
|
44
|
+
return { keyHeight: 43, pitch: 54, bottom: 71, top: 25.33, strip: 27, side: 6.67 * scale, gap: 6, accessories: 'below', radius: 8.5 }
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function iosLayout(input: LayoutInput): KeyboardLayout {
|
|
48
|
+
if (isNumberPad(input.keyboardType)) {
|
|
49
|
+
return numberPad(input)
|
|
50
|
+
}
|
|
51
|
+
const r = rows(input)
|
|
52
|
+
const area = input.width - 2 * r.side
|
|
53
|
+
const keyWidth = (area - 9 * r.gap) / 10
|
|
54
|
+
const pitch = keyWidth + r.gap
|
|
55
|
+
const showStrip = input.suggestions
|
|
56
|
+
const height = r.bottom + r.keyHeight + 3 * r.pitch + r.top + (showStrip ? r.strip : 0)
|
|
57
|
+
// Rows counted from the top: 0 is the top row.
|
|
58
|
+
const rowY = (row: number) => height - r.bottom - r.keyHeight - (3 - row) * r.pitch
|
|
59
|
+
const key = (id: string, action: KeyAction, x: number, row: number, width: number, label?: string): KeySpec => ({
|
|
60
|
+
id,
|
|
61
|
+
action,
|
|
62
|
+
x,
|
|
63
|
+
y: rowY(row),
|
|
64
|
+
width,
|
|
65
|
+
height: r.keyHeight,
|
|
66
|
+
radius: r.radius,
|
|
67
|
+
tone: action.kind === 'letter' || action.kind === 'char' || action.kind === 'space' ? 'character' : 'function',
|
|
68
|
+
popup: action.kind === 'letter' || action.kind === 'char',
|
|
69
|
+
label,
|
|
70
|
+
})
|
|
71
|
+
const x0 = r.side
|
|
72
|
+
const modifierWidth = 1.5 * pitch - 2.3 * r.gap
|
|
73
|
+
const thirdRowX = x0 + 1.5 * pitch
|
|
74
|
+
const deleteX = x0 + area - modifierWidth
|
|
75
|
+
|
|
76
|
+
const letterRow = (letters: string, startX: number, row: number) =>
|
|
77
|
+
[...letters].map((char, index) => key(`letter:${char}`, { kind: 'letter', char }, startX + index * pitch, row, keyWidth))
|
|
78
|
+
const characterRow = (chars: string, row: number) =>
|
|
79
|
+
[...chars].map((char, index) => key(`char:${char}`, { kind: 'char', char }, x0 + index * pitch, row, keyWidth, char))
|
|
80
|
+
|
|
81
|
+
const punctuationRow = (layer: Layer, label: string): KeySpec[] => {
|
|
82
|
+
const span = 7 * keyWidth + 6 * r.gap
|
|
83
|
+
const count = PUNCTUATION_ROW.length
|
|
84
|
+
const width = (span - (count - 1) * r.gap) / count
|
|
85
|
+
return [
|
|
86
|
+
key(`layer:${layer}`, { kind: 'layer', layer }, x0, 2, modifierWidth, label),
|
|
87
|
+
...[...PUNCTUATION_ROW].map((char, index) => key(`char:${char}`, { kind: 'char', char }, thirdRowX + index * (width + r.gap), 2, width, char)),
|
|
88
|
+
key('delete', { kind: 'delete' }, deleteX, 2, modifierWidth),
|
|
89
|
+
]
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const bottomRow = (type: KeyboardType, layer: Layer, layerLabel: string): KeySpec[] => {
|
|
93
|
+
const inRow = r.accessories === 'row'
|
|
94
|
+
const side = area * (inRow ? 0.238 : 0.2382)
|
|
95
|
+
const small = area * 0.1125
|
|
96
|
+
const symbol = area * 0.1114
|
|
97
|
+
const extras: [string, KeyAction, string][] =
|
|
98
|
+
type === 'email'
|
|
99
|
+
? [
|
|
100
|
+
['char:@', { kind: 'char', char: '@' }, '@'],
|
|
101
|
+
['char:.', { kind: 'char', char: '.' }, '.'],
|
|
102
|
+
]
|
|
103
|
+
: type === 'url'
|
|
104
|
+
? [
|
|
105
|
+
['char:/', { kind: 'char', char: '/' }, '/'],
|
|
106
|
+
['char:.', { kind: 'char', char: '.' }, '.'],
|
|
107
|
+
]
|
|
108
|
+
: []
|
|
109
|
+
const layerWidth = inRow ? small : side
|
|
110
|
+
const leading: KeySpec[] = [key(`layer:${layer}`, { kind: 'layer', layer }, x0, 3, layerWidth, layerLabel)]
|
|
111
|
+
let x = x0 + layerWidth + r.gap
|
|
112
|
+
if (inRow) {
|
|
113
|
+
leading.push(key('emoji', { kind: 'emoji' }, x, 3, small))
|
|
114
|
+
x += small + r.gap
|
|
115
|
+
}
|
|
116
|
+
const returnX = x0 + area - side
|
|
117
|
+
const spaceWidth = returnX - r.gap - x - extras.length * (symbol + r.gap)
|
|
118
|
+
const keys = [...leading, key('space', { kind: 'space' }, x, 3, spaceWidth)]
|
|
119
|
+
x += spaceWidth + r.gap
|
|
120
|
+
for (const [id, action, label] of extras) {
|
|
121
|
+
keys.push({ ...key(id, action, x, 3, symbol, label), popup: false })
|
|
122
|
+
x += symbol + r.gap
|
|
123
|
+
}
|
|
124
|
+
keys.push(key('return', { kind: 'return' }, returnX, 3, side))
|
|
125
|
+
return keys
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const accessories = (): KeySpec[] => {
|
|
129
|
+
if (r.accessories === 'row') {
|
|
130
|
+
return []
|
|
131
|
+
}
|
|
132
|
+
const size = 34
|
|
133
|
+
const centerY = r.accessories === 'below' ? height - 40 : rowY(3) + r.keyHeight / 2
|
|
134
|
+
const centers = r.accessories === 'below' ? [42.5 * (input.width / 402), input.width - 43 * (input.width / 402)] : [r.side / 2, input.width - r.side / 2]
|
|
135
|
+
const accessory = (id: string, action: KeyAction, centerX: number): KeySpec => ({
|
|
136
|
+
id,
|
|
137
|
+
action,
|
|
138
|
+
x: centerX - size / 2,
|
|
139
|
+
y: centerY - size / 2,
|
|
140
|
+
width: size,
|
|
141
|
+
height: size,
|
|
142
|
+
radius: size / 2,
|
|
143
|
+
tone: 'bare',
|
|
144
|
+
popup: false,
|
|
145
|
+
})
|
|
146
|
+
return [accessory('emoji', { kind: 'emoji' }, centers[0]), accessory('dictation', { kind: 'dictation' }, centers[1])]
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
let keys: KeySpec[]
|
|
150
|
+
switch (input.layer) {
|
|
151
|
+
case 'letters':
|
|
152
|
+
keys = [
|
|
153
|
+
...letterRow('qwertyuiop', x0, 0),
|
|
154
|
+
...letterRow('asdfghjkl', x0 + pitch / 2, 1),
|
|
155
|
+
key('shift', { kind: 'shift' }, x0, 2, modifierWidth),
|
|
156
|
+
...letterRow('zxcvbnm', thirdRowX, 2),
|
|
157
|
+
key('delete', { kind: 'delete' }, deleteX, 2, modifierWidth),
|
|
158
|
+
...bottomRow(input.keyboardType, 'numbers', '123'),
|
|
159
|
+
]
|
|
160
|
+
break
|
|
161
|
+
case 'numbers':
|
|
162
|
+
keys = [...characterRow(NUMBERS_ROW_1, 0), ...characterRow(NUMBERS_ROW_2, 1), ...punctuationRow('symbols', '#+='), ...bottomRow('default', 'letters', 'ABC')]
|
|
163
|
+
break
|
|
164
|
+
case 'symbols':
|
|
165
|
+
keys = [...characterRow(SYMBOLS_ROW_1, 0), ...characterRow(SYMBOLS_ROW_2, 1), ...punctuationRow('numbers', '123'), ...bottomRow('default', 'letters', 'ABC')]
|
|
166
|
+
break
|
|
167
|
+
}
|
|
168
|
+
keys.push(...accessories())
|
|
169
|
+
for (const k of keys) {
|
|
170
|
+
if (k.action.kind === 'return') {
|
|
171
|
+
k.tone = 'function'
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return {
|
|
175
|
+
platform: 'ios',
|
|
176
|
+
width: input.width,
|
|
177
|
+
height,
|
|
178
|
+
keys,
|
|
179
|
+
strip: showStrip ? { y: 0, height: r.top + r.strip, x: r.side, width: area } : null,
|
|
180
|
+
numberPad: false,
|
|
181
|
+
scale: r.keyHeight / 43,
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function numberPad(input: LayoutInput): KeyboardLayout {
|
|
186
|
+
const landscape = input.orientation === 'landscape'
|
|
187
|
+
const pad = input.homeButton
|
|
188
|
+
? landscape
|
|
189
|
+
? { keyHeight: 34, pitch: 39, bottom: 3, top: 6, side: 3, gap: 6, radius: 6 }
|
|
190
|
+
: { keyHeight: 46, pitch: 52, bottom: 3, top: 11, side: 5, gap: 6.67, radius: 10 }
|
|
191
|
+
: landscape
|
|
192
|
+
? { keyHeight: 34, pitch: 40, bottom: input.insets.bottom + 4, top: 6, side: Math.max(input.insets.left, input.insets.right), gap: 6.67, radius: 8 }
|
|
193
|
+
: { keyHeight: 48, pitch: 54, bottom: 68, top: 24.33, side: 5 * (input.width / 402), gap: 6.67, radius: 10 }
|
|
194
|
+
const height = pad.bottom + pad.keyHeight + 3 * pad.pitch + pad.top
|
|
195
|
+
const width = (input.width - 2 * pad.side - 2 * pad.gap) / 3
|
|
196
|
+
const key = (id: string, action: KeyAction, column: number, row: number, bare: boolean, label?: string): KeySpec => ({
|
|
197
|
+
id,
|
|
198
|
+
action,
|
|
199
|
+
x: pad.side + column * (width + pad.gap),
|
|
200
|
+
y: height - pad.bottom - pad.keyHeight - (3 - row) * pad.pitch,
|
|
201
|
+
width,
|
|
202
|
+
height: pad.keyHeight,
|
|
203
|
+
radius: pad.radius,
|
|
204
|
+
tone: bare ? 'bare' : 'character',
|
|
205
|
+
popup: false,
|
|
206
|
+
label,
|
|
207
|
+
subLabel: label === undefined ? undefined : NUMBER_PAD_SUB_LABELS[label],
|
|
208
|
+
})
|
|
209
|
+
const digits = [...'123456789'].map((digit, index) => key(`char:${digit}`, { kind: 'char', char: digit }, index % 3, Math.floor(index / 3), false, digit))
|
|
210
|
+
const keys = [...digits, key('char:0', { kind: 'char', char: '0' }, 1, 3, false, '0')]
|
|
211
|
+
if (input.keyboardType === 'decimal') {
|
|
212
|
+
keys.push(key('char:.', { kind: 'char', char: '.' }, 0, 3, true, '.'))
|
|
213
|
+
}
|
|
214
|
+
if (input.keyboardType === 'phone') {
|
|
215
|
+
keys.push(key('char:+', { kind: 'char', char: '+' }, 0, 3, true, '+*#'))
|
|
216
|
+
}
|
|
217
|
+
keys.push(key('delete', { kind: 'delete' }, 2, 3, true))
|
|
218
|
+
return { platform: 'ios', width: input.width, height, keys, strip: null, numberPad: true, scale: pad.keyHeight / 48 }
|
|
219
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { Insets, Orientation, Platform } from 'web-sim/shell'
|
|
2
|
+
import type { KeyboardType, Layer } from '../state.ts'
|
|
3
|
+
|
|
4
|
+
export type KeyAction =
|
|
5
|
+
| { kind: 'letter'; char: string }
|
|
6
|
+
| { kind: 'char'; char: string }
|
|
7
|
+
| { kind: 'space' }
|
|
8
|
+
| { kind: 'delete' }
|
|
9
|
+
| { kind: 'return' }
|
|
10
|
+
| { kind: 'shift' }
|
|
11
|
+
| { kind: 'layer'; layer: Layer }
|
|
12
|
+
| { kind: 'emoji' }
|
|
13
|
+
| { kind: 'dictation' }
|
|
14
|
+
|
|
15
|
+
/** How a key is painted: a character key, a modifier, the accented return key, or a bare icon on the panel. */
|
|
16
|
+
export type KeyTone = 'character' | 'function' | 'accent' | 'bare'
|
|
17
|
+
|
|
18
|
+
/** One key, in points from the keyboard's top-left corner. */
|
|
19
|
+
export type KeySpec = {
|
|
20
|
+
id: string
|
|
21
|
+
action: KeyAction
|
|
22
|
+
x: number
|
|
23
|
+
y: number
|
|
24
|
+
width: number
|
|
25
|
+
height: number
|
|
26
|
+
radius: number
|
|
27
|
+
tone: KeyTone
|
|
28
|
+
/** Shows the pressed character above the key. */
|
|
29
|
+
popup: boolean
|
|
30
|
+
label?: string
|
|
31
|
+
/** The letters under a number pad's digit. */
|
|
32
|
+
subLabel?: string
|
|
33
|
+
/** Gboard's small digit in a top-row key's corner. */
|
|
34
|
+
hint?: string
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** The strip over the keys: suggestions, or on Android the toolbar when there are none. */
|
|
38
|
+
export type StripSpec = { y: number; height: number; x: number; width: number }
|
|
39
|
+
|
|
40
|
+
export type KeyboardLayout = {
|
|
41
|
+
platform: Platform
|
|
42
|
+
width: number
|
|
43
|
+
height: number
|
|
44
|
+
keys: KeySpec[]
|
|
45
|
+
strip: StripSpec | null
|
|
46
|
+
numberPad: boolean
|
|
47
|
+
/** Font sizes scale with the keys in landscape. */
|
|
48
|
+
scale: number
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** What a layout is built from: the screen, the field, and the keyboard's settings. */
|
|
52
|
+
export type LayoutInput = {
|
|
53
|
+
platform: Platform
|
|
54
|
+
width: number
|
|
55
|
+
orientation: Orientation
|
|
56
|
+
insets: Insets
|
|
57
|
+
/** A device with a home button has no room under the keys. */
|
|
58
|
+
homeButton: boolean
|
|
59
|
+
/** Android's navigation bar height under the keys. */
|
|
60
|
+
navigationHeight: number
|
|
61
|
+
keyboardType: KeyboardType
|
|
62
|
+
layer: Layer
|
|
63
|
+
suggestions: boolean
|
|
64
|
+
numberRow: boolean
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function isNumberPad(type: KeyboardType): boolean {
|
|
68
|
+
return type === 'decimal' || type === 'number' || type === 'phone'
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export const NUMBER_PAD_SUB_LABELS: Record<string, string> = {
|
|
72
|
+
'2': 'ABC',
|
|
73
|
+
'3': 'DEF',
|
|
74
|
+
'4': 'GHI',
|
|
75
|
+
'5': 'JKL',
|
|
76
|
+
'6': 'MNO',
|
|
77
|
+
'7': 'PQRS',
|
|
78
|
+
'8': 'TUV',
|
|
79
|
+
'9': 'WXYZ',
|
|
80
|
+
}
|