No Description

Listas.js 3.8KB

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