No Description

ListInput.js 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. import React, { Component } from 'react';
  2. import { StyleSheet, TextInput, View, Alert, TouchableOpacity, Text } from 'react-native';
  3. export default class Lists extends Component {
  4. constructor(props) {
  5. // const {navigation,route}=props
  6. // const {uid} = route.params;
  7. super(props)
  8. this.state = {
  9. name_l: '',
  10. store: '',
  11. lid: '',
  12. uid: this.props.navigation.getParam('uid')
  13. }
  14. }
  15. insertList_Function = () => {
  16. fetch('https://ada.uprrp.edu/~laura.gonzalez19/4030/insert_l.php', {
  17. method: 'POST',
  18. headers: {
  19. 'Accept': 'application/json',
  20. 'Content-Type': 'application/json',
  21. },
  22. body: JSON.stringify({
  23. name_l: this.state.name_l,
  24. store: this.state.store,
  25. uid: this.state.uid,
  26. })
  27. }).then((response) => response.json())
  28. .then((responseJson) => {
  29. // Showing response message coming from server after inserting records.
  30. Alert.alert("Status",responseJson, [
  31. {
  32. text: 'Cancel',
  33. style: 'cancel'
  34. },
  35. { text: 'OK', onPress:() => this.props.navigation.navigate('Lists') }
  36. ],
  37. { cancelable: false }
  38. );
  39. });
  40. }
  41. render() {
  42. return (
  43. <View style={styles.MainContainer}>
  44. <Text style={{ fontSize: 25, color: "#3414B3", textAlign: 'center', marginBottom: 15 }}>List Form</Text>
  45. <TextInput
  46. placeholder="Name the list!"
  47. onChangeText={data => this.setState({ name_l: data })}
  48. underlineColorAndroid='transparent'
  49. style={styles.TextInputStyleClass}
  50. />
  51. <TextInput
  52. placeholder="Where are you using this list?"
  53. onChangeText={data => this.setState({ store: data })}
  54. underlineColorAndroid='transparent'
  55. style={styles.TextInputStyleClass}
  56. />
  57. <TouchableOpacity style={styles.button} onPress={this.insertList_Function} >
  58. <Text style={styles.text}>+</Text>
  59. </TouchableOpacity>
  60. <Text style={{ fontSize: 15, color: "#3414B3", textAlign: 'center', marginTop: 20, marginBottom: 15 }}>Start adding your lists </Text>
  61. </View>
  62. );
  63. }
  64. }
  65. const styles = StyleSheet.create({
  66. MainContainer: {
  67. justifyContent: 'center',
  68. alignItems: 'center',
  69. flex: 1,
  70. margin: 10
  71. },
  72. TextInputStyleClass: {
  73. textAlign: 'center',
  74. marginBottom: 7,
  75. height: 40,
  76. width: '80%',
  77. borderWidth: 1,
  78. borderColor: '#3414B3',
  79. borderRadius: 5,
  80. },
  81. button: {
  82. height:50,
  83. width: 50,
  84. paddingTop: 2,
  85. paddingBottom: 2,
  86. backgroundColor: '#3414B3',
  87. borderRadius: 100,
  88. marginTop: 20,
  89. alignItems: 'center'
  90. },
  91. text: {
  92. color: '#fff',
  93. fontSize: 35,
  94. textAlign: 'center',
  95. padding: 0
  96. }
  97. });