Advertisement
Guest User

Untitled

a guest
Feb 1st, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. import React, { Component } from 'react';
  2. import {AppRegistry, View, StyleSheet, Button, Image, Text } from 'react-native';
  3.  
  4. import t from 'tcomb-form-native'; // 0.6.9
  5.  
  6. var logo = require('./assets/download.jpg')
  7.  
  8.  
  9. const Form = t.form.Form;
  10.  
  11. const User = t.struct({
  12. //email: t.String,
  13. username: t.String,
  14. password: t.String,
  15. //terms: t.Boolean
  16. });
  17.  
  18. const formStyles = {
  19. ...Form.stylesheet,
  20. formGroup: {
  21. normal: {
  22. marginBottom: 10
  23. },
  24. },
  25. controlLabel: {
  26. normal: {
  27. color: 'blue',
  28. fontSize: 18,
  29. marginBottom: 7,
  30. fontWeight: '600'
  31. },
  32. // the style applied when a validation error occours
  33. error: {
  34. color: 'red',
  35. fontSize: 18,
  36. marginBottom: 7,
  37. fontWeight: '600'
  38. }
  39. }
  40. }
  41. //
  42. // const options = {
  43. // fields: {
  44. // email: {
  45. // error: 'Without an email address how are you going to reset your password when you forget it?'
  46. // },
  47. // password: {
  48. // error: 'Choose something you use on a dozen other sites or something you won\'t remember'
  49. // },
  50. // terms: {
  51. // label: 'Agree to Terms',
  52. // },
  53. // },
  54. // stylesheet: formStyles,
  55. // };
  56.  
  57. export default class App extends Component {
  58. handleSubmit = () => {
  59. const value = this._form.getValue();
  60. console.log('value: ', value);
  61. }
  62.  
  63. render() {
  64. return (
  65. <View>
  66.  
  67. <View>
  68. <Image
  69. style={{width: 50, height: 50}}
  70. source={require('/assets/download.jpg')}
  71. />
  72. </View>
  73.  
  74.  
  75. <View style={styles.container}>
  76.  
  77. <Form
  78. ref={c => this._form = c}
  79. type={User}
  80. //options={options}
  81. />
  82. <Button
  83. title="LOGIN"
  84. onPress={this.handleSubmit}
  85. />
  86. </View>
  87. </View>
  88. );
  89. }
  90. }
  91.  
  92. const styles = StyleSheet.create({
  93. container: {
  94. justifyContent: 'center',
  95. marginTop: 50,
  96. padding: 20,
  97. backgroundColor: '#ffffff',
  98. },
  99. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement