Skip to content

Commit

Permalink
Allows for passed events (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
REDACTED-REDACTED authored Jun 19, 2018
1 parent 78b63e3 commit ba84537
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 34 deletions.
14 changes: 7 additions & 7 deletions lib/pages/event_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class EventPage extends StatelessWidget {
dynamic data = snapshot.value;
int count = data["count"];
var configuration = createLocalImageConfiguration(context);
List<EventData> eventData = [];

List<EventData> eventData = [];
for (int i = 0; i<count; i++) {
dynamic rawEventData = data[i.toString()];
EventData event = new EventData(
Expand All @@ -28,6 +28,7 @@ class EventPage extends StatelessWidget {
);
eventData.add(event);
}
eventData.sort((a, b) => a.timestamp.compareTo(b.timestamp));
return eventData;
}

Expand All @@ -36,7 +37,6 @@ class EventPage extends StatelessWidget {
return new FutureBuilder(
future: getEventData(_db, context),
builder: (BuildContext context, AsyncSnapshot<List<EventData>> snapshot) {

switch (snapshot.connectionState) {
case ConnectionState.waiting:
return new Center(
Expand All @@ -46,15 +46,15 @@ class EventPage extends StatelessWidget {
//Got Data
List<Widget> events = [];
for(EventData data in snapshot.data) {
events.add(
new EventCard(data)
);
if (new DateTime.fromMillisecondsSinceEpoch(data.timestamp).isAfter(new DateTime.now())) {
events.add(
new EventCard(data)
);
}
}

return new ListView(
children: events,
);

default:
//TODO
//Image should be here
Expand Down
49 changes: 22 additions & 27 deletions lib/widgets/event_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,28 @@ class EventCard extends StatelessWidget {

@override
Widget build(BuildContext context) {
DateTime eventTime = new DateTime.fromMicrosecondsSinceEpoch(_eventData.timestamp);
if (!eventTime.isAfter(new DateTime.now())) {
return new Padding(
padding: new EdgeInsets.symmetric(vertical: 15.0, horizontal: 5.0),
child: new Card(
color: Colors.white,
child: new Column(
children: <Widget>[
new Container(
color: new Color.fromRGBO(9, 24, 35, 1.0),
child: new Image(image: _eventData.imageProvider),
),
new Padding(
padding: new EdgeInsets.only(top: 15.0),
child: new Text(_eventData.name, style: Theme.of(context).textTheme.title),
),
new Padding(
padding: new EdgeInsets.symmetric(vertical: 5.0),
child: new Text(_eventData.description, style: Theme.of(context).textTheme.caption),
),
new Countdown(_eventData.timestamp),
],
),
return new Padding(
padding: new EdgeInsets.symmetric(vertical: 15.0, horizontal: 5.0),
child: new Card(
color: Colors.white,
child: new Column(
children: <Widget>[
new Container(
color: new Color.fromRGBO(9, 24, 35, 1.0),
child: new Image(image: _eventData.imageProvider),
),
new Padding(
padding: new EdgeInsets.only(top: 15.0),
child: new Text(_eventData.name, style: Theme.of(context).textTheme.title),
),
new Padding(
padding: new EdgeInsets.symmetric(vertical: 5.0),
child: new Text(_eventData.description, style: Theme.of(context).textTheme.caption),
),
new Countdown(_eventData.timestamp),
],
),
);
}else {
return new Padding(padding: new EdgeInsets.all(0.0),);
}
),
);
}
}

0 comments on commit ba84537

Please sign in to comment.