Advertisement
Guest User

Untitled

a guest
Jul 24th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.64 KB | None | 0 0
  1. Here is a one of the Two Tabs
  2.  
  3.  
  4.  
  5. import React, { Component } from "react";
  6. import {
  7. View,
  8. Text,
  9. StyleSheet,
  10. Dimensions,
  11. FlatList,
  12. ScrollView,
  13. TouchableOpacity
  14. } from "react-native";
  15. import firebase from "react-native-firebase";
  16. import Icon from "react-native-vector-icons/Ionicons";
  17.  
  18. const { width } = Dimensions.get("window");
  19.  
  20. export default class AcceptedOrders extends Component {
  21. constructor(props) {
  22. super(props);
  23. this.state = {
  24. currentUser: null
  25. };
  26. }
  27. componentDidMount() {
  28. const currentUser = firebase.auth().currentUser.uid;
  29. this.setState({ currentUser });
  30. const Orders = firebase.database().ref(`AcceptedOrders/${currentUser}`);
  31. Orders.on("value", snapshot => {
  32. let orders = [];
  33. snapshot.forEach(childSnapshot => {
  34. if (childSnapshot.val().statusInfo == "Accepted") {
  35. orders.push({
  36. gKey: childSnapshot.key,
  37. id: childSnapshot.val().id,
  38. nameOfProblem: childSnapshot.val().nameOfProblem,
  39. description: childSnapshot.val().description,
  40. date: childSnapshot.val().date,
  41. time: childSnapshot.val().time,
  42. Price: childSnapshot.val().Price,
  43. statusInfo: childSnapshot.val().statusInfo,
  44. region: childSnapshot.val().region
  45. });
  46. this.setState({ orders });
  47. }
  48. });
  49. });
  50. }
  51.  
  52. _listEmptyComponent = () => {
  53. return (
  54. <View style={styles.container}>
  55. <Text style={{ alignSelf: "center" }}>
  56. {" "}
  57. No Orders Found :( try Later!
  58. </Text>
  59. </View>
  60. );
  61. };
  62. render() {
  63. return (
  64. <View style={styles.container}>
  65. <FlatList
  66. data={this.state.orders}
  67. key={Math.random() * 1000}
  68. contentContainerStyle={{ flexGrow: 1 }}
  69. ListEmptyComponent={this._listEmptyComponent()}
  70. extraData={this.state}
  71. renderItem={({ item }) => {
  72. return (
  73. <ScrollView scrollEnabled={true} style={{ marginTop: 20 }}>
  74. <TouchableOpacity
  75. onPress={() =>
  76. this.props.navigation.navigate("OrderDetails", {
  77. title: item.nameOfProblem,
  78. description: item.description,
  79. date: item.date,
  80. time: item.time,
  81. status: item.statusInfo,
  82. gKey: item.gKey,
  83. price: item.Price,
  84. // location: item.location
  85. region: item.region
  86. })
  87. }
  88. >
  89. <View style={styles.listCard}>
  90. <View
  91. style={{
  92. justifyContent: "flex-start",
  93. alignItems: "baseline"
  94. }}
  95. >
  96. <View
  97. style={{
  98. flexDirection: "row",
  99. alignItems: "center"
  100. }}
  101. >
  102. <Icon
  103. name="ios-build"
  104. size={25}
  105. color="#4d8dd6"
  106. style={{ margin: 5 }}
  107. />
  108. <Text style={{ color: "#1567d3" }}>
  109. {" "}
  110. <Text style={{ color: "#828282" }}>Title:</Text>{" "}
  111. {item.nameOfProblem}
  112. </Text>
  113. </View>
  114. {/* <View style={{
  115. flexDirection: "row",
  116. alignItems: "center"
  117. }}>
  118. <Icon name="md-clipboard" size={25} color='#4d8dd6' style={{ margin: 5 }} />
  119.  
  120. <Text numberOfLines={1} ellipsizeMode='tail' style={{ color: "#1567d3", paddingEnd: 10 }}>
  121. <Text style={{ color: "#828282" }}> Description:</Text> {item.description}
  122. </Text>
  123. </View> */}
  124. <View
  125. style={{
  126. flexDirection: "row",
  127. alignItems: "center",
  128. flexWrap: "wrap",
  129. paddingEnd: 50,
  130. marginVertical: 10
  131. }}
  132. >
  133. <Icon
  134. name="md-clipboard"
  135. size={25}
  136. color="#4d8dd6"
  137. style={{ margin: 5 }}
  138. />
  139. <Text style={{ color: "#828282" }}> Description:</Text>
  140. <Text
  141. numberOfLines={3}
  142. ellipsizeMode="tail"
  143. style={{ width: "100%", color: "#1567d3", left: 40 }}
  144. >
  145. {item.description}
  146. </Text>
  147. </View>
  148. <View
  149. style={{
  150. flexDirection: "row",
  151. alignItems: "center"
  152. }}
  153. >
  154. <Icon
  155. name="ios-calendar"
  156. size={25}
  157. color="#4d8dd6"
  158. style={{ margin: 5 }}
  159. />
  160. <Text style={{ color: "#1567d3" }}>
  161. <Text style={{ color: "#828282" }}> Date:</Text>{" "}
  162. {item.date}
  163. <Text style={{ color: "#828282" }}> Time:</Text>{" "}
  164. {item.time}
  165. </Text>
  166. </View>
  167. <View
  168. style={{
  169. flexDirection: "row",
  170. alignItems: "center"
  171. }}
  172. >
  173. <Icon
  174. name="ios-cash"
  175. size={25}
  176. color="#4d8dd6"
  177. style={{ margin: 5 }}
  178. />
  179. <Text style={{ color: "#1567d3" }}>
  180. {" "}
  181. <Text style={{ color: "#828282" }}> Price:</Text>{" "}
  182. {item.Price}$
  183. </Text>
  184. </View>
  185. <View
  186. style={{
  187. flexDirection: "row",
  188. alignItems: "center"
  189. }}
  190. >
  191. <Icon
  192. name="ios-alert"
  193. size={25}
  194. color="#4d8dd6"
  195. style={{ margin: 5 }}
  196. />
  197. <Text style={{ color: "#1567d3" }}>
  198. {" "}
  199. <Text style={{ color: "#828282" }}>
  200. {" "}
  201. Status:
  202. </Text>{" "}
  203. {item.statusInfo}
  204. </Text>
  205. </View>
  206. </View>
  207. <TouchableOpacity
  208. style={{
  209. width: width - 50,
  210. borderRadius: 5,
  211. height: 45,
  212. marginVertical: 10,
  213. alignSelf: "center",
  214. backgroundColor: "#35b5ce",
  215. alignItems: "center",
  216. justifyContent: "center"
  217. }}
  218. onPress={() =>
  219. this.props.navigation.navigate("OrderDetails", {
  220. title: item.nameOfProblem,
  221. description: item.description,
  222. date: item.date,
  223. time: item.time,
  224. status: item.statusInfo,
  225. gKey: item.gKey,
  226. price: item.Price,
  227. // location: item.location
  228. region: item.region
  229. })
  230. }
  231. >
  232. <Text style={{ color: "#fff", fontSize: 18 }}>Open</Text>
  233. </TouchableOpacity>
  234. </View>
  235. </TouchableOpacity>
  236. </ScrollView>
  237. );
  238. }}
  239. keyExtractor={(item, index) => index.toString()}
  240. />
  241. </View>
  242. );
  243. }
  244. }
  245. const styles = StyleSheet.create({
  246. container: {
  247. flex: 1,
  248. alignSelf: "center"
  249. },
  250. listCard: {
  251. flex: 1,
  252. padding: 15,
  253. borderRadius: 5,
  254. width: width - 20,
  255. alignItems: "flex-start",
  256. justifyContent: "flex-start",
  257. backgroundColor: "#eee"
  258. },
  259. btnContainer: {
  260. width: width - 50,
  261. flexDirection: "row",
  262. justifyContent: "space-around",
  263. margin: 10,
  264. marginBottom: 0
  265. },
  266. btnAccept: {
  267. backgroundColor: "#5ed81c",
  268. width: 170,
  269. justifyContent: "center",
  270. alignItems: "center",
  271. borderColor: "#5ed81c",
  272. borderWidth: 1,
  273. margin: 10,
  274. padding: 10
  275. },
  276. btnReject: {
  277. width: 100,
  278. justifyContent: "center",
  279. borderColor: "#333",
  280. borderWidth: 1,
  281. margin: 10,
  282. padding: 10,
  283. alignItems: "center"
  284. }
  285. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement