2020-04-23 16:08:50 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { View } from 'react-native';
|
|
|
|
import _ from 'lodash';
|
|
|
|
|
|
|
|
import styles from './styles';
|
2020-04-23 20:11:17 +00:00
|
|
|
import { themes } from '../../../constants/colors';
|
2020-04-23 16:08:50 +00:00
|
|
|
|
|
|
|
const SIZE_EMPTY = 8;
|
|
|
|
const SIZE_FULL = 12;
|
|
|
|
|
2020-04-23 16:38:27 +00:00
|
|
|
const Dots = ({
|
|
|
|
passcode,
|
2020-04-23 16:08:50 +00:00
|
|
|
showError,
|
|
|
|
changeScreen,
|
|
|
|
attemptFailed,
|
2020-04-23 16:38:27 +00:00
|
|
|
theme,
|
|
|
|
length
|
2020-04-23 16:08:50 +00:00
|
|
|
}) => (
|
2020-04-23 16:38:27 +00:00
|
|
|
<View style={[styles.topViewCirclePasscode]}>
|
|
|
|
{_.range(length).map((val) => {
|
|
|
|
const lengthSup = ((passcode.length >= val + 1 && !changeScreen) || showError) && !attemptFailed;
|
2020-04-23 16:08:50 +00:00
|
|
|
const opacity = lengthSup ? 1 : 0.5;
|
|
|
|
const height = lengthSup ? SIZE_FULL : SIZE_EMPTY;
|
|
|
|
const width = lengthSup ? SIZE_FULL : SIZE_EMPTY;
|
|
|
|
let color = '';
|
|
|
|
if (showError) {
|
|
|
|
color = themes[theme].dangerColor;
|
2020-04-23 16:38:27 +00:00
|
|
|
} else if (lengthSup && passcode.length > 0) {
|
2020-04-23 16:08:50 +00:00
|
|
|
color = themes[theme].titleText;
|
|
|
|
} else {
|
|
|
|
color = themes[theme].bodyText;
|
|
|
|
}
|
|
|
|
const borderRadius = lengthSup
|
|
|
|
? SIZE_FULL / 2
|
|
|
|
: SIZE_EMPTY / 2;
|
|
|
|
const marginRight = lengthSup
|
|
|
|
? 10 - (SIZE_FULL - SIZE_EMPTY) / 2
|
|
|
|
: 10;
|
|
|
|
const marginLeft = lengthSup
|
|
|
|
? 10 - (SIZE_FULL - SIZE_EMPTY) / 2
|
|
|
|
: 10;
|
|
|
|
return (
|
|
|
|
<View style={styles.viewCircles}>
|
|
|
|
<View
|
|
|
|
style={[{
|
|
|
|
opacity,
|
|
|
|
height,
|
|
|
|
width,
|
|
|
|
borderRadius,
|
|
|
|
backgroundColor: color,
|
|
|
|
marginRight,
|
|
|
|
marginLeft
|
|
|
|
}]}
|
|
|
|
/>
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
})}
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
|
2020-04-23 16:38:27 +00:00
|
|
|
export default Dots;
|