diff --git a/MobileApp/App.js b/MobileApp/App.js
index bd99b36..8f157e1 100644
--- a/MobileApp/App.js
+++ b/MobileApp/App.js
@@ -10,23 +10,45 @@ const events = Object.entries(data.events).map(([uid, event]) => ({...event, uid
export default class App extends React.Component {
render() {
+ const groupedEvents = groupEventsByName(events)
+ const sectionListEvents = adjustSectionListData(groupedEvents)
+
return (
-
+
);
}
}
+function groupEventsByName(events) {
+ return events.reduce((grouped, event) => {
+ const firstLetter = event.title[0].toUpperCase()
+
+ if (!grouped.get(firstLetter)) {
+ grouped.set(firstLetter, [])
+ }
+
+ grouped.get(firstLetter).push(event)
+
+ return grouped
+ }, new Map())
+}
+
+function adjustSectionListData(eventsMap) {
+ return Array.from(eventsMap, ([title, data]) => ({
+ title,
+ data
+ })).sort((sectionA, sectionB) => sectionA.title > sectionB.title ? 1 : -1)
+}
+
const styles = StyleSheet.create({
container: {
flex: 1,
- backgroundColor: '#fff',
- alignItems: 'center',
- justifyContent: 'center',
+ backgroundColor: '#fff'
},
image: {
width: '100%'
diff --git a/MobileApp/src/components/event-list.js b/MobileApp/src/components/event-list.js
index b15eaa1..a1800be 100644
--- a/MobileApp/src/components/event-list.js
+++ b/MobileApp/src/components/event-list.js
@@ -1,5 +1,5 @@
import React, { Component } from 'react'
-import {Text, ScrollView, StyleSheet} from 'react-native'
+import { View, Text, SectionList, StyleSheet} from 'react-native'
import Card from './common/card'
class EventList extends Component {
@@ -8,19 +8,47 @@ class EventList extends Component {
};
render() {
- return (
-
- {this.props.events.map(event =>
-
- {event.title}
-
- )}
-
- )
+ return (
+
+ {item.title}
+ {item.when}
+ {item.where}
+
+ )}
+ keyExtractor={(item, index) => item + index}
+ sections={this.props.events}
+ renderSectionHeader={({ section }) => {
+ // debugger
+ return (
+
+ {section.title}
+ {`Number of Events: ${section.data.length}`}
+
+ )
+ }}
+ />
}
}
const styles = StyleSheet.create({
+ header: {
+ display: 'flex',
+ flexDirection: 'row',
+ justifyContent: 'space-between',
+ backgroundColor: 'white',
+ padding: 10,
+ borderBottomColor: 'black',
+ borderBottomWidth: 2
+ },
+ title: {
+ fontWeight: 'bold',
+ backgroundColor: 'white'
+ },
+ count: {
+ fontWeight: 'bold',
+ backgroundColor: 'white'
+ }
})
export default EventList
\ No newline at end of file
diff --git a/MobileApp/src/components/event.js b/MobileApp/src/components/event.js
index ace1ea9..ebd27bf 100644
--- a/MobileApp/src/components/event.js
+++ b/MobileApp/src/components/event.js
@@ -1,20 +1,40 @@
import React, { Component } from 'react'
-import {View, Text, Image, StyleSheet} from 'react-native'
+import {View, Text, Image, StyleSheet, TouchableHighlight, Alert} from 'react-native'
class Event extends Component {
static propTypes = {
};
+
+ onPress = () => {
+ Alert.alert(
+ 'Warning!',
+ 'Are you sure you want to delete an event?',
+ [
+ {text: 'Yes'},
+ {text: 'No'}
+ ],
+ { cancelable: false }
+ )
+ }
render() {
const { event } = this.props
return (
- {event.title}
- {event.url}
- {event.where}
- {event.when}
+
+ {event.title}
+ {event.url}
+ {event.where}
+ {event.when}
+
+
+ Delete an event
+
)
}
@@ -22,15 +42,24 @@ class Event extends Component {
const styles = StyleSheet.create({
image: {
- width: 400,
+ width: '100%',
height: 200
},
title: {
fontSize: 30
},
container: {
- flex: 1,
- justifyContent: 'space-around',
+ borderColor: 'black',
+ borderWidth: 1,
+ borderStyle: 'solid'
+ },
+ desc: {
+ padding: 15
+ },
+ button: {
+ alignItems: 'center',
+ backgroundColor: '#DDDDDD',
+ padding: 10
}
})