Skip to content
This repository was archived by the owner on Jul 7, 2024. It is now read-only.

Commit

Permalink
Reduce technical debt
Browse files Browse the repository at this point in the history
  • Loading branch information
JohanRochet authored and JohanRochet committed May 23, 2024
1 parent dad1593 commit 5feeba5
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 29 deletions.
17 changes: 13 additions & 4 deletions apps/app/components/BaseKeyboard/BaseKeyboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,34 @@ export default function BaseKeyboard({ onPress }: BaseKeyboardProps) {
const keyWidth = width / 11;
const keyMargin = keyWidth / 20;

const baseKeys = new Map<string, string | JSX.Element>([
['Backspace', <Ionicons name='backspace' size={keyWidth / 5} />],
const baseKeys = new Map<string, string | React.JSX.Element>([
[
'Backspace',
<Ionicons name='backspace' size={keyWidth / 5} key='backspace' />,
],
[
'Keyboard',
<MaterialCommunityIcons
name='keyboard-outline'
size={keyWidth / 6}
key='keyboard'
/>,
],
['\n', <AntDesign name='enter' size={keyWidth / 6} />],
['\n', <AntDesign name='enter' size={keyWidth / 6} key='enter' />],
[
'\t',
<MaterialCommunityIcons name='keyboard-tab' size={keyWidth / 6} />,
<MaterialCommunityIcons
name='keyboard-tab'
size={keyWidth / 6}
key='tab'
/>,
],
[
'Maj',
<MaterialCommunityIcons
name='apple-keyboard-shift'
size={keyWidth / 6}
key='maj'
/>,
],
]);
Expand Down
78 changes: 57 additions & 21 deletions apps/app/components/BaseKeyboard/keys.ts
Original file line number Diff line number Diff line change
@@ -1,145 +1,181 @@
export const numKeysFrom0To4 = new Map<string, string | JSX.Element>([
export const numKeysFrom0To4 = new Map<string, string | React.JSX.Element>([
['0', '0'],
['1', '1'],
['2', '2'],
['3', '3'],
['4', '4'],
]);
export const numKeysFrom5To9 = new Map<string, string | JSX.Element>([
export const numKeysFrom5To9 = new Map<string, string | React.JSX.Element>([
['5', '5'],
['6', '6'],
['7', '7'],
['8', '8'],
['9', '9'],
]);
export const lowerLettersKeysFromAtoE = new Map<string, string | JSX.Element>([
export const lowerLettersKeysFromAtoE = new Map<
string,
string | React.JSX.Element
>([
['a', 'a'],
['b', 'b'],
['c', 'c'],
['d', 'd'],
['e', 'e'],
]);
export const lowerLettersKeysFromFtoJ = new Map<string, string | JSX.Element>([
export const lowerLettersKeysFromFtoJ = new Map<
string,
string | React.JSX.Element
>([
['f', 'f'],
['g', 'g'],
['h', 'h'],
['i', 'i'],
['j', 'j'],
]);
export const lowerLettersKeysFromKtoO = new Map<string, string | JSX.Element>([
export const lowerLettersKeysFromKtoO = new Map<
string,
string | React.JSX.Element
>([
['k', 'k'],
['l', 'l'],
['m', 'm'],
['n', 'n'],
['o', 'o'],
]);
export const lowerLettersKeysFromPtoT = new Map<string, string | JSX.Element>([
export const lowerLettersKeysFromPtoT = new Map<
string,
string | React.JSX.Element
>([
['p', 'p'],
['q', 'q'],
['r', 'r'],
['s', 's'],
['t', 't'],
]);
export const lowerLettersKeysFromUtoY = new Map<string, string | JSX.Element>([
export const lowerLettersKeysFromUtoY = new Map<
string,
string | React.JSX.Element
>([
['u', 'u'],
['v', 'v'],
['w', 'w'],
['x', 'x'],
['y', 'y'],
]);
export const lowerLettersKeysFromZToDot = new Map<string, string | JSX.Element>([
export const lowerLettersKeysFromZToDot = new Map<
string,
string | React.JSX.Element
>([
['z', 'z'],
['.', '.'],
[',', ','],
[';', ';'],
[':', ':'],
]);
export const upperLettersKeysFromAtoE = new Map<string, string | JSX.Element>([
export const upperLettersKeysFromAtoE = new Map<
string,
string | React.JSX.Element
>([
['A', 'A'],
['B', 'B'],
['C', 'C'],
['D', 'D'],
['E', 'E'],
]);
export const upperLettersKeysFromFtoJ = new Map<string, string | JSX.Element>([
export const upperLettersKeysFromFtoJ = new Map<
string,
string | React.JSX.Element
>([
['F', 'F'],
['G', 'G'],
['H', 'H'],
['I', 'I'],
['J', 'J'],
]);
export const upperLettersKeysFromKtoO = new Map<string, string | JSX.Element>([
export const upperLettersKeysFromKtoO = new Map<
string,
string | React.JSX.Element
>([
['K', 'K'],
['L', 'L'],
['M', 'M'],
['N', 'N'],
['O', 'O'],
]);
export const upperLettersKeysFromPtoT = new Map<string, string | JSX.Element>([
export const upperLettersKeysFromPtoT = new Map<
string,
string | React.JSX.Element
>([
['P', 'P'],
['Q', 'Q'],
['R', 'R'],
['S', 'S'],
['T', 'T'],
]);
export const upperLettersKeysFromUtoY = new Map<string, string | JSX.Element>([
export const upperLettersKeysFromUtoY = new Map<
string,
string | React.JSX.Element
>([
['U', 'U'],
['V', 'V'],
['W', 'W'],
['X', 'X'],
['Y', 'Y'],
]);
export const upperLettersKeysFromZToDot = new Map<string, string | JSX.Element>([
export const upperLettersKeysFromZToDot = new Map<
string,
string | React.JSX.Element
>([
['Z', 'Z'],
['.', '.'],
[',', ','],
[';', ';'],
[':', ':'],
]);
export const specialKeys1 = new Map<string, string | JSX.Element>([
export const specialKeys1 = new Map<string, string | React.JSX.Element>([
['\\', '\\'],
['&', '&'],
['}', '}'],
['|', '|'],
['{', '{'],
]);
export const specialKeys2 = new Map<string, string | JSX.Element>([
export const specialKeys2 = new Map<string, string | React.JSX.Element>([
['_', '_'],
['?', '?'],
[']', ']'],
['!', '!'],
['[', '['],
]);
export const specialKeys3 = new Map<string, string | JSX.Element>([
export const specialKeys3 = new Map<string, string | React.JSX.Element>([
['%', '%'],
['>', '>'],
[')', ')'],
['<', '<'],
['(', '('],
]);
export const specialKeys4 = new Map<string, string | JSX.Element>([
export const specialKeys4 = new Map<string, string | React.JSX.Element>([
['=', '='],
['+', '+'],
['*', '*'],
['-', '-'],
['/', '/'],
]);
export const specialKeys5 = new Map<string, string | JSX.Element>([
export const specialKeys5 = new Map<string, string | React.JSX.Element>([
['"', '"'],
['#', '#'],
['@', '@'],
['$', '$'],

['`', '`'],
]);
export const specialKeys6 = new Map<string, string | JSX.Element>([
export const specialKeys6 = new Map<string, string | React.JSX.Element>([
['^', '^'],
['§', '§'],
['°', '°'],
['µ', 'µ'],
['~', '~'],
]);
export const specialKeys7 = new Map<string, string | JSX.Element>([
export const specialKeys7 = new Map<string, string | React.JSX.Element>([
["'", "'"],
['é ', 'é'],
['è', 'è'],
Expand Down
2 changes: 1 addition & 1 deletion apps/app/components/CodeKeyboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default function CodeKeyboard({
}, [isVisble]);

const generateKeyboard = (
keys: Map<string, string | JSX.Element>,
keys: Map<string, string | React.JSX.Element>,
onPress: (key: string) => void,
selectAfterTen: boolean = false
) => {
Expand Down
2 changes: 1 addition & 1 deletion apps/app/components/GestureKey.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
import { runOnJS, useSharedValue } from 'react-native-reanimated';

type GestureKeyProps = {
keys: Map<string, string | JSX.Element>;
keys: Map<string, string | React.JSX.Element>;
onPress: (key: string) => void;
keyWidth: number;
keyMargin: number;
Expand Down
3 changes: 2 additions & 1 deletion apps/app/components/Key.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from 'react';
import { TouchableOpacity, Text } from 'react-native';

type KeyProps = {
keyPressed: string;
value: string | JSX.Element;
value: string | React.JSX.Element;
onPress: (key: string) => void;
keyHeight: number;
keyMargin: number;
Expand Down
3 changes: 2 additions & 1 deletion apps/app/utils/workspace/Workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ export default class Workspace {
async openFile(file: string) {
if (this.__openedFiles.has(file)) {
console.info(`File ${file} is already opened in the workspace`);
return (this.currentFile = file);
this.currentFile = file;
return this.currentFile;
}
const { content } = await this.trpcClient.projects.getFile.query({
path: file,
Expand Down

0 comments on commit 5feeba5

Please sign in to comment.