-
Notifications
You must be signed in to change notification settings - Fork 0
/
Libraries.js
47 lines (36 loc) · 1.29 KB
/
Libraries.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import React, {Component} from 'react';
import {ScrollView} from 'react-native';
import Locations from './Locations';
import { firebase } from '@react-native-firebase/firestore';
export default class Libraries extends Component{
constructor(props) {
super(props);
this.prepareLibraryData = this.prepareLibraryData.bind(this);
this.state = {};
}
async prepareLibraryData() {
try {
const firebaseLibraryData = await firebase.firestore()
.collection('Libraries')
.get()
let libraryData = []
firebaseLibraryData.docs.forEach((d,i)=> {
if(Object.keys(d._data).length > 0) {
let loc = d._data
loc.longitude = loc.longitude > 0 ? -loc.longitude : loc.longitude
libraryData.push({"name": loc.name, "latitude": loc.latitude, "longitude": loc.longitude, "occupancy": "Low", "type": "Cafe", "image": loc.picture})
}
});
return libraryData
} catch (e) {
console.log(e);
}
}
render() {
return(
<ScrollView contentContainerStyle={{flexGrow: 1, justifyContent: "center"}}>
<Locations heading = {"Find your study spot"} prepareData = {this.prepareLibraryData} iconImage = {"https://image.flaticon.com/icons/png/512/130/130304.png"} />
</ScrollView>
);
}
}