No Description

Productos.js 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. import { StatusBar } from 'expo-status-bar';
  2. import { useEffect, useState } from 'react';
  3. import React from 'react';
  4. import { StyleSheet, Text, View, Image, ImageBackground, Button, TouchableOpacity, Platform, Alert, FlatList} from 'react-native';
  5. import { ScrollView } from 'react-native-gesture-handler';
  6. TouchableOpacity.defaultProps = { activeOpacity: 0.8 };
  7. export default function Listas ({ navigation }) {
  8. const [data, setData] = useState([]);
  9. useEffect(() => {
  10. fetch('https://ada.uprrp.edu/~victor.hernandez17/groceryPolice/viewListProducts.php', {
  11. method: 'POST',
  12. mode: 'no-cors',
  13. headers: {
  14. Accept: 'application/json',
  15. 'Content-Type': 'application/json'
  16. },
  17. body: JSON.stringify({
  18. lid: navigation.getParam('lid')
  19. })
  20. })
  21. .then((response) => response.json())
  22. .then((json) => {
  23. setData(json);
  24. console.log(json);
  25. })
  26. .catch((error) => {
  27. console.error(error);
  28. });
  29. }, []);
  30. return (
  31. <View style = {styles.container} >
  32. <View style = {styles.pageTitleView}>
  33. <Text style = {styles.pageTitleText}>{ navigation.getParam('name_l') } </Text>
  34. <Text style = {styles.location}>{ navigation.getParam('store') } </Text>
  35. </View>
  36. <View style = {styles.contents}>
  37. <ScrollView style = {styles.scrollView}>
  38. <FlatList
  39. data={data}
  40. keyExtractor={(list) => list.id}
  41. renderItem={({ item }) => (
  42. <TouchableOpacity style={styles.listCards}>
  43. <Text key={item.lid} style={styles.listText}>{item.name_p}</Text>
  44. </TouchableOpacity>
  45. )}
  46. />
  47. </ScrollView>
  48. </View>
  49. <View style = {styles.contentsPlus}>
  50. <TouchableOpacity style={styles.plusButton} onPress={() => navigation.navigate('NewProduct', { lid:navigation.getParam('lid')})}>
  51. <Text style={styles.plusText}>+</Text>
  52. </TouchableOpacity>
  53. </View>
  54. </View>
  55. );
  56. };
  57. // navigation.getParam('lid')
  58. // STYLING
  59. const styles = StyleSheet.create({
  60. container: {
  61. flex: 1,
  62. backgroundColor: '#F2F2F2',
  63. },
  64. pageTitleView: {
  65. flex: 1,
  66. alignContent: 'flex-end',
  67. justifyContent: 'flex-end'
  68. },
  69. contents: {
  70. flex: 2,
  71. },
  72. contentsPlus: {
  73. flex: 1,
  74. justifyContent: 'center',
  75. alignContent: 'center',
  76. alignItems: 'center'
  77. },
  78. pageTitleText: {
  79. color: '#888',
  80. fontSize: 35,
  81. paddingLeft: 10,
  82. paddingBottom: -10,
  83. fontFamily: 'Avenir'
  84. },
  85. location: {
  86. color: 'rgb(32,56,100)',
  87. fontSize: 25,
  88. paddingLeft: 15,
  89. paddingBottom: 30,
  90. fontFamily: 'Avenir'
  91. },
  92. listCards: {
  93. flexDirection: 'row',
  94. alignContent: 'flex-start',
  95. justifyContent: 'flex-start',
  96. alignItems: 'center',
  97. backgroundColor: 'rgb(32,56,100)',
  98. width: '99%',
  99. borderRadius: 10,
  100. paddingVertical: 20,
  101. paddingHorizontal: 10,
  102. marginBottom: 10,
  103. shadowColor: 'rgba(0,0,0,.5)',
  104. shadowOffset: { width: 2, height: 2},
  105. shadowOpacity: 0.3,
  106. },
  107. listText: {
  108. color: 'white',
  109. fontSize: 20,
  110. fontFamily: 'Avenir'
  111. },
  112. plusButton: {
  113. flexDirection: 'row',
  114. alignContent: 'flex-start',
  115. justifyContent: 'flex-start',
  116. alignItems: 'center',
  117. justifyContent: 'center',
  118. backgroundColor: 'rgb(32,56,100)',
  119. width: 90,
  120. height: 90,
  121. borderRadius: 45,
  122. marginBottom: 50,
  123. shadowColor: 'rgba(0,0,0,.5)',
  124. shadowOffset: { width: 2, height: 2},
  125. shadowOpacity: 0.3,
  126. },
  127. plusText: {
  128. color: '#F2F2F2',
  129. fontSize: 60,
  130. fontWeight: '600',
  131. fontFamily: 'Avenir'
  132. },
  133. appButtonText: {
  134. fontSize: 17,
  135. color: "#fff",
  136. alignSelf: "center",
  137. },
  138. bContainer: {
  139. padding: 50,
  140. paddingTop: -20,
  141. flex: 2,
  142. width: '100%',
  143. justifyContent: "space-evenly",
  144. },
  145. scrollView: {
  146. backgroundColor: 'transparent',
  147. marginHorizontal: 20,
  148. },
  149. });