Skip to content

Commit

Permalink
fix: Overlap for long passwords with show/hide button and replaced sh…
Browse files Browse the repository at this point in the history
…ow/hide button text with show/hide icon
  • Loading branch information
KshitizSareen committed Jan 25, 2023
1 parent ff4e8a3 commit e38a6b3
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions src/common/PasswordInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,26 @@ import React, { useState, useCallback } from 'react';
import type { Node } from 'react';
import { View } from 'react-native';

import { Icon } from './Icons';
import Input from './Input';
import type { Props as InputProps } from './Input';
import { BRAND_COLOR, createStyleSheet } from '../styles';
import ZulipTextIntl from './ZulipTextIntl';
import Touchable from './Touchable';

const styles = createStyleSheet({
showPasswordButton: {
position: 'absolute',
right: 0,
top: 0,
bottom: 0,
justifyContent: 'center',
},
showPasswordButtonText: {
showPasswordButtonIcon: {
margin: 8,
color: BRAND_COLOR,
},
passwordTextInput: {
flex: 1,
},
passwordInputView: {
flexDirection: 'row',
},
});

// Prettier wants a ", >" here, which is silly.
Expand All @@ -44,10 +46,16 @@ export default function PasswordInput(props: Props): Node {
}, []);

return (
<View>
<Input {...props} secureTextEntry={isHidden} autoCorrect={false} autoCapitalize="none" />
<View style={styles.passwordInputView}>
<Input
{...props}
secureTextEntry={isHidden}
autoCorrect={false}
autoCapitalize="none"
style={styles.passwordTextInput}
/>
<Touchable style={styles.showPasswordButton} onPress={handleShow}>
<ZulipTextIntl style={styles.showPasswordButtonText} text={isHidden ? 'show' : 'hide'} />
<Icon name={isHidden ? 'eye-off' : 'eye'} size={24} style={styles.showPasswordButtonIcon} />
</Touchable>
</View>
);
Expand Down

0 comments on commit e38a6b3

Please sign in to comment.