MCPcopy Create free account
hub / github.com/ICBNetwork/web3-Wallet / KeypadComponent

Function KeypadComponent

app/components/Base/Keypad/index.js:7–204  ·  view source on GitHub ↗
({
  onChange,
  value,
  currency,
  decimals,
  style,
  digitButtonStyle,
  digitTextStyle,
  periodButtonStyle,
  periodTextStyle,
  deleteButtonStyle,
  deleteIcon,
})

Source from the content-addressed store, hash-verified

5import useCurrency from './useCurrency';
6import { ViewPropTypes } from 'react-native';
7function KeypadComponent({
8 onChange,
9 value,
10 currency,
11 decimals,
12 style,
13 digitButtonStyle,
14 digitTextStyle,
15 periodButtonStyle,
16 periodTextStyle,
17 deleteButtonStyle,
18 deleteIcon,
19}) {
20 const { handler, decimalSeparator } = useCurrency(currency, decimals);
21 const handleKeypadPress = useCallback(
22 (pressedKey) => {
23 const newValue = handler(value, pressedKey);
24 let valueAsNumber = 0;
25 try {
26 valueAsNumber = Number(newValue.replace(decimalSeparator, '.'));
27 } catch (error) {
28 console.error(error);
29 }
30 onChange({ value: newValue, valueAsNumber, pressedKey });
31 },
32 [decimalSeparator, handler, onChange, value],
33 );
34 const handleKeypadPress1 = useCallback(
35 () => handleKeypadPress(KEYS.DIGIT_1),
36 [handleKeypadPress],
37 );
38 const handleKeypadPress2 = useCallback(
39 () => handleKeypadPress(KEYS.DIGIT_2),
40 [handleKeypadPress],
41 );
42 const handleKeypadPress3 = useCallback(
43 () => handleKeypadPress(KEYS.DIGIT_3),
44 [handleKeypadPress],
45 );
46 const handleKeypadPress4 = useCallback(
47 () => handleKeypadPress(KEYS.DIGIT_4),
48 [handleKeypadPress],
49 );
50 const handleKeypadPress5 = useCallback(
51 () => handleKeypadPress(KEYS.DIGIT_5),
52 [handleKeypadPress],
53 );
54 const handleKeypadPress6 = useCallback(
55 () => handleKeypadPress(KEYS.DIGIT_6),
56 [handleKeypadPress],
57 );
58 const handleKeypadPress7 = useCallback(
59 () => handleKeypadPress(KEYS.DIGIT_7),
60 [handleKeypadPress],
61 );
62 const handleKeypadPress8 = useCallback(
63 () => handleKeypadPress(KEYS.DIGIT_8),
64 [handleKeypadPress],

Callers

nothing calls this directly

Calls 2

useCurrencyFunction · 0.85
errorMethod · 0.45

Tested by

no test coverage detected