add results components

This commit is contained in:
Jake Howard 2016-09-18 12:01:28 +01:00
parent b4b2942438
commit 1c9612b3a3
Signed by: jake
GPG key ID: 57AFB45680EDD477
5 changed files with 73 additions and 4 deletions

View 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>
);
}

View file

@ -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,

View 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>
);
}

View file

@ -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;
}

View file

@ -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>
); );
} }