add results components
This commit is contained in:
parent
b4b2942438
commit
1c9612b3a3
5 changed files with 73 additions and 4 deletions
27
src/components/BlankResults.tsx
Normal file
27
src/components/BlankResults.tsx
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
import React, { Component }from 'react';
|
||||||
|
|
||||||
|
import {
|
||||||
|
Text,
|
||||||
|
View,
|
||||||
|
StyleSheet
|
||||||
|
} from 'react-native';
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
container: {
|
||||||
|
flex: 1,
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center'
|
||||||
|
} as React.ViewStyle,
|
||||||
|
});
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export default function BlankResults(props : Props) {
|
||||||
|
return (
|
||||||
|
<View style={styles.container}>
|
||||||
|
<Text>Something</Text>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
}
|
|
@ -3,7 +3,6 @@ import React, { Component }from 'react';
|
||||||
import { TextInput, View, StyleSheet } from 'react-native';
|
import { TextInput, View, StyleSheet } from 'react-native';
|
||||||
import { BRAND_PRIMARY } from '../settings/styles';
|
import { BRAND_PRIMARY } from '../settings/styles';
|
||||||
|
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
inputBorder: {
|
inputBorder: {
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
|
|
32
src/components/Results.tsx
Normal file
32
src/components/Results.tsx
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
import React, { Component }from 'react';
|
||||||
|
import zxcvbn from 'zxcvbn';
|
||||||
|
import {
|
||||||
|
Text,
|
||||||
|
View,
|
||||||
|
StyleSheet
|
||||||
|
} from 'react-native';
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
container: {
|
||||||
|
flex: 1,
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center'
|
||||||
|
} as React.ViewStyle,
|
||||||
|
});
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
value: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface State {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function Result(props : Props) {
|
||||||
|
const resultData = zxcvbn(props.value);
|
||||||
|
return (
|
||||||
|
<View style={styles.container}>
|
||||||
|
<Text>{resultData.score}</Text>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
}
|
|
@ -4,3 +4,8 @@ declare module "react-native-vector-icons/FontAwesome" {
|
||||||
var noTypeInfoYet: any; // any var name here really
|
var noTypeInfoYet: any; // any var name here really
|
||||||
export = noTypeInfoYet;
|
export = noTypeInfoYet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
declare module "zxcvbn" {
|
||||||
|
var noTypeInfoYet: any; // any var name here really
|
||||||
|
export = noTypeInfoYet;
|
||||||
|
}
|
||||||
|
|
|
@ -5,11 +5,14 @@ import {
|
||||||
View
|
View
|
||||||
} from 'react-native';
|
} from 'react-native';
|
||||||
import Input from '../components/Input';
|
import Input from '../components/Input';
|
||||||
|
import Results from '../components/Results';
|
||||||
|
import BlankResults from '../components/BlankResults';
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
alignItems: 'stretch',
|
alignItems: 'stretch',
|
||||||
|
justifyContent: 'center',
|
||||||
backgroundColor: '#FFF',
|
backgroundColor: '#FFF',
|
||||||
} as React.ViewStyle,
|
} as React.ViewStyle,
|
||||||
|
|
||||||
|
@ -39,12 +42,15 @@ export default class App extends Component<any, State> {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
const results = this.state.text ? (
|
||||||
|
<Results value={this.state.text} />
|
||||||
|
) : (
|
||||||
|
<BlankResults />
|
||||||
|
);
|
||||||
return (
|
return (
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
<Input onSubmit={this.handleSubmit} value={this.state.text} />
|
<Input onSubmit={this.handleSubmit} value={this.state.text} />
|
||||||
<Text style={styles.text}>
|
{ results }
|
||||||
Welcome to React Native!
|
|
||||||
</Text>
|
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue