Advertisement
Guest User

Untitled

a guest
Feb 1st, 2018
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 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. <Image
  67. style={{width: 50, height: 50}}
  68. source={logo}
  69. />
  70. </View>
  71. <View style={styles.container}>
  72. <Form
  73. ref={c => this._form = c}
  74. type={User}
  75. //options={options}
  76. />
  77. <Button
  78. title="LOGIN"
  79. onPress={this.handleSubmit}
  80. />
  81. </View>
  82. );
  83. }
  84. }
  85.  
  86. const styles = StyleSheet.create({
  87. container: {
  88. justifyContent: 'center',
  89. marginTop: 50,
  90. padding: 20,
  91. backgroundColor: '#ffffff',
  92. },
  93. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement