|
1 | 1 | /* @flow strict-local */
|
2 | 2 | import React, { useState, useCallback } from 'react';
|
3 | 3 | import type { Node } from 'react';
|
4 |
| -import { View } from 'react-native'; |
| 4 | +import { View, Pressable } from 'react-native'; |
5 | 5 |
|
6 | 6 | import { Icon } from './Icons';
|
7 | 7 | import Input from './Input';
|
8 | 8 | import type { Props as InputProps } from './Input';
|
9 |
| -import { BRAND_COLOR, createStyleSheet } from '../styles'; |
10 |
| -import Touchable from './Touchable'; |
| 9 | +import { BRAND_COLOR, HIGHLIGHT_COLOR, createStyleSheet } from '../styles'; |
11 | 10 |
|
12 | 11 | const styles = createStyleSheet({
|
13 | 12 | showPasswordButton: {
|
14 | 13 | marginLeft: 8,
|
15 | 14 | },
|
16 |
| - showPasswordButtonIcon: { |
17 |
| - // 24 (icon size) + 12 + 12 = 48px min touch target: |
18 |
| - // https://material.io/design/usability/accessibility.html#layout-and-typography |
19 |
| - margin: 12, |
20 |
| - color: BRAND_COLOR, |
21 |
| - }, |
22 | 15 | passwordTextInput: {
|
23 | 16 | flex: 1,
|
24 | 17 | },
|
@@ -57,9 +50,21 @@ export default function PasswordInput(props: Props): Node {
|
57 | 50 | autoCapitalize="none"
|
58 | 51 | style={styles.passwordTextInput}
|
59 | 52 | />
|
60 |
| - <Touchable style={styles.showPasswordButton} onPress={handleShow}> |
61 |
| - <Icon name={isHidden ? 'eye-off' : 'eye'} size={24} style={styles.showPasswordButtonIcon} /> |
62 |
| - </Touchable> |
| 53 | + <Pressable |
| 54 | + // 24 (icon size) + 12 + 12 = 48px min touch target: |
| 55 | + // https://material.io/design/usability/accessibility.html#layout-and-typography |
| 56 | + hitSlop={12} |
| 57 | + style={styles.showPasswordButton} |
| 58 | + onPress={handleShow} |
| 59 | + > |
| 60 | + {({ pressed }) => ( |
| 61 | + <Icon |
| 62 | + color={pressed ? HIGHLIGHT_COLOR : BRAND_COLOR} |
| 63 | + name={isHidden ? 'eye-off' : 'eye'} |
| 64 | + size={24} |
| 65 | + /> |
| 66 | + )} |
| 67 | + </Pressable> |
63 | 68 | </View>
|
64 | 69 | );
|
65 | 70 | }
|
0 commit comments