add types of react-native-qrcode

This commit is contained in:
york yao
2017-12-29 20:32:28 +08:00
parent b3fad80228
commit 6e8155c0c6
4 changed files with 92 additions and 0 deletions

16
types/react-native-qrcode/index.d.ts vendored Normal file
View File

@@ -0,0 +1,16 @@
// Type definitions for react-native-qrcode 0.2
// Project: https://github.com/cssivision/react-native-qrcode
// Definitions by: York Yao <https://github.com/plantain-00>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
import * as React from 'react';
export default class QRCode extends React.Component<QRCodeProperties> { }
export interface QRCodeProperties {
value?: string;
size?: number;
bgColor?: string;
fgColor?: string;
}

View File

@@ -0,0 +1,50 @@
import * as React from 'react';
import QRCode from 'react-native-qrcode';
import {
AppRegistry,
StyleSheet,
View,
TextInput
} from 'react-native';
class HelloWorld extends React.Component {
state = {
text: 'http://facebook.github.io/react-native/',
};
render() {
return (
<View style={styles.container}>
<TextInput
style={styles.input}
onChangeText={(text) => this.setState({ text })}
value={this.state.text}
/>
<QRCode
value={this.state.text}
size={200}
bgColor='purple'
fgColor='white' />
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: 'white',
alignItems: 'center',
justifyContent: 'center'
},
input: {
height: 40,
borderColor: 'gray',
borderWidth: 1,
margin: 10,
borderRadius: 5,
padding: 5,
}
});

View File

@@ -0,0 +1,25 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"jsx": "react"
},
"files": [
"index.d.ts",
"react-native-qrcode-tests.tsx"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }