Skip to content

Commit

Permalink
Adds V0.3 Features (#7)
Browse files Browse the repository at this point in the history
* Incremented Version Code

* fixes #4

Fixes #4 the home widget had to be put into a seperate class otherwise exceptions were raised.

* fixes #6

Sounds are now locally cached for 7 days

* Added schedule to drawer and frame for page

* Setup schedule tabs

* Initial schedule features added

* Improved error handling

* Fixes blank screen if no events

* Fixed blank screen when no schedules

* Added clarification to schedule state

* Aligned Text and Icons in drawer

* Converted all timestamps to utc

* Fixed state checking logic

* Finalised schedule closes #5

* Changed App Colour to match primary

* Allow for text overflow
  • Loading branch information
REDACTED-REDACTED authored Jun 23, 2018
1 parent 62481d1 commit aa230c2
Show file tree
Hide file tree
Showing 22 changed files with 518 additions and 63 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Source code for the cyber discovry app. You should be able to build it from sou
## Features

* The app has countdowns to all forthcoming events in the cyber discovery calender.
* The app has a schedule for certain activities duraning a events showing when they start, finish and how much of the activity that has happened.
* The app has a soundboard with some of our favorite clips from vc and agent j.
* The app has the latest articles from the [Cyber Discovery Medium](https://medium.com/cyber-discovery) embeded for easy access.

Expand Down
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ android {
applicationId "com.example.cyberdiscovery"
minSdkVersion 16
targetSdkVersion 27
versionCode 2
versionName "1.1"
versionCode 3
versionName "1.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

Expand Down
Binary file added assets/images/error_image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/unreleased.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions lib/activity_data.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
class ActivityData {
final String _name;
final String _description;
final int _startTimestamp;
final int _endTimestamp;

ActivityData(
this._name,
this._description,
this._startTimestamp,
this._endTimestamp
);

get name => _name;
get description => _description;
get startTimestamp => _startTimestamp;
get endTimestamp => _endTimestamp;
}
42 changes: 3 additions & 39 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ import 'package:firebase_database/firebase_database.dart';
import 'package:firebase_analytics/firebase_analytics.dart';
import 'package:firebase_messaging/firebase_messaging.dart';

import 'package:cyber_discovery/pages/event_page.dart';
import 'package:cyber_discovery/pages/soundboard_page.dart';
import 'package:cyber_discovery/pages/blog_page.dart';
import 'package:cyber_discovery/widgets/drawer_header.dart';
import 'package:cyber_discovery/widgets/list_item.dart';
import 'package:cyber_discovery/pages/home_page.dart';

Future<void> main() async {
final FirebaseApp app = await FirebaseApp.configure(
Expand Down Expand Up @@ -42,24 +38,10 @@ CyberDiscoveryApp(this._app);
class _CyberDiscoveryAppState extends State<CyberDiscoveryApp> {
final FirebaseApp _app;
_CyberDiscoveryAppState(this._app);
int _pageId = 0;

static FirebaseAnalytics analytics = new FirebaseAnalytics();
final FirebaseMessaging firebaseMessaging = new FirebaseMessaging();

Widget getActivePage(id, db) {
switch(id) {
case 0:
return new EventPage(db);
case 1:
return new SoundBoardPage(db, analytics);
case 2:
return new BlogPage();
default:
return new Text("ERROR");
}
}

@override
void initState() {
super.initState();
Expand All @@ -74,31 +56,13 @@ class _CyberDiscoveryAppState extends State<CyberDiscoveryApp> {

return MaterialApp(
title: "Cyber Discovery",
color: new Color.fromRGBO(13, 35, 50, 1.0),
color: Colors.deepPurple[500],
theme: new ThemeData(
primaryColor: Colors.deepPurple[500],
accentColor: new Color.fromRGBO(62, 174, 211, 1.0),
fontFamily: "Dosis",
),
home: new Scaffold(
appBar: new AppBar(
title: new Text("Cyber Discovery"),
),
drawer: new Drawer(
child: new Container(
color: Colors.deepPurple[500],
child: new ListView(
children: <Widget>[
new DrawerHead(),
new ListItem(Icons.access_time, "Events", (){setState((){_pageId = 0;});}),
new ListItem(Icons.notifications, "Soundboard", (){setState((){_pageId = 1;});}),
new ListItem(Icons.library_books, "Blog", (){setState((){_pageId = 2;});}),
],
),
),
),
body: getActivePage(_pageId, db),
backgroundColor: new Color.fromRGBO(9, 24, 35, 1.0)),
home: new HomePage(db, analytics),
);
}
}
9 changes: 8 additions & 1 deletion lib/pages/blog_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ import 'dart:async';

import 'package:cyber_discovery/widgets/blog_card.dart';
import 'package:cyber_discovery/blog_data.dart';
import 'package:cyber_discovery/widgets/error_message.dart';

class BlogPage extends StatelessWidget {

Future<String> getRSSData() async {
String rssFeed = "https://medium.com/feed/@CyberDiscUK";
String data = await http.read(rssFeed);
//TODO implement https://pub.dartlang.org/packages/petitparser

int start = 0;
int end = 0;
while (true) {
Expand All @@ -38,6 +40,11 @@ class BlogPage extends StatelessWidget {
return FutureBuilder(
future: getRSSData(),
builder: (BuildContext context, AsyncSnapshot<String> snapshot){

if (snapshot.hasError) {
return new ErrorMessage("Welp Something Went Wrong", "Check your connection to the internet");
}

switch(snapshot.connectionState) {
case ConnectionState.waiting:
return new Center(
Expand All @@ -55,7 +62,7 @@ class BlogPage extends StatelessWidget {
children: articles,
);
default:
return new Text("ERROR");
return new ErrorMessage("Welp Something Went Wrong", "Check your connection to the internet");
}
},
);
Expand Down
21 changes: 14 additions & 7 deletions lib/pages/event_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:cached_network_image/cached_network_image.dart';

import 'package:cyber_discovery/widgets/event_card.dart';
import 'package:cyber_discovery/event_data.dart';
import 'package:cyber_discovery/widgets/error_message.dart';

class EventPage extends StatelessWidget {
final FirebaseDatabase _db;
Expand Down Expand Up @@ -37,6 +38,10 @@ class EventPage extends StatelessWidget {
return new FutureBuilder(
future: getEventData(_db, context),
builder: (BuildContext context, AsyncSnapshot<List<EventData>> snapshot) {
if (snapshot.hasError) {
return new ErrorMessage("Welp Something Went Wrong", "Check your connection to the internet");
}

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

if (events.length > 0) {
return new ListView(
children: events,
);
}
return new ErrorMessage("There are currently no listed events", "Who forgot to put the events in the database?");
default:
//TODO
//Image should be here
return new Text("ERROR");
return new ErrorMessage("Welp Something Went Wrong", "Check your connection to the internet");
}
},
);
Expand Down
90 changes: 90 additions & 0 deletions lib/pages/home_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import 'package:flutter/material.dart';

import 'package:firebase_database/firebase_database.dart';
import 'package:firebase_analytics/firebase_analytics.dart';

import 'package:cyber_discovery/widgets/drawer_header.dart';
import 'package:cyber_discovery/widgets/list_item.dart';
import 'package:cyber_discovery/pages/event_page.dart';
import 'package:cyber_discovery/pages/schedule_page.dart';
import 'package:cyber_discovery/pages/soundboard_page.dart';
import 'package:cyber_discovery/pages/blog_page.dart';
import 'package:cyber_discovery/widgets/error_message.dart';

class HomePage extends StatefulWidget {
final FirebaseDatabase _db;
final FirebaseAnalytics _analytics;
HomePage(this._db, this._analytics);

@override
_HomePageState createState() => _HomePageState(_db, _analytics);
}

class _HomePageState extends State<HomePage> {
final FirebaseDatabase db;
final FirebaseAnalytics analytics;
_HomePageState(this.db, this.analytics);

int _pageId = 0;

Widget getActivePage(id, db) {
switch(id) {
case 0:
return new EventPage(db);
case 1:
return new SoundBoardPage(db, analytics);
case 2:
return new BlogPage();
case 3:
return new SchedulePage(db);
default:
return new ErrorMessage("Welp Something Went Wrong", "Unknown Cause");
}
}

@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text("Cyber Discovery"),
),
drawer: new Drawer(
child: new Container(
color: Colors.deepPurple[500],
child: new ListView(
children: <Widget>[
new DrawerHead(),
new ListItem(Icons.access_time, "Events", (){setState(
(){
_pageId = 0;
Navigator.pop(context);
});
}),
new ListItem(Icons.calendar_today, "Schedule", (){setState(
(){
_pageId = 3;
Navigator.pop(context);
}
);}
),
new ListItem(Icons.notifications, "Soundboard", (){setState(
(){
_pageId = 1;
Navigator.pop(context);
});
}),
new ListItem(Icons.library_books, "Blog", (){setState(
(){
_pageId = 2;
Navigator.pop(context);
});
}),
],
),
),
),
body: getActivePage(_pageId, db),
backgroundColor: new Color.fromRGBO(9, 24, 35, 1.0)
);
}
}
61 changes: 61 additions & 0 deletions lib/pages/schedule_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import 'package:flutter/material.dart';
import 'dart:async';

import 'package:firebase_database/firebase_database.dart';

import 'package:cyber_discovery/widgets/schedule_tab.dart';
import 'package:cyber_discovery/widgets/error_message.dart';

class SchedulePage extends StatelessWidget {
final FirebaseDatabase _db;
SchedulePage(this._db);

Future<DataSnapshot> getTabData() {
return _db.reference().child("Schedule").child("Tabs").once();
}

@override
Widget build(BuildContext context) {
return new FutureBuilder<DataSnapshot>(
future: getTabData(),
builder: (BuildContext context, AsyncSnapshot<DataSnapshot> snapshot){
switch(snapshot.connectionState) {
case ConnectionState.waiting:
return new Center(
child: new CircularProgressIndicator(),
);
case ConnectionState.done:
//Load Tabs
var data = snapshot.data.value;
int i = 0;
int count = data["count"];
List<Widget> tabs = [];
List<Widget> tabPages = [];
for(i; i < count; i++) {
tabs.add(new Tab(text: data[i.toString()]));
tabPages.add(new ScheduleTab(_db, data[i.toString()]));
}

if (tabs.length > 0) {
return new DefaultTabController(
length: i+1,
child: new Scaffold(
backgroundColor: new Color.fromRGBO(13, 35, 50, 1.0),
appBar: new TabBar(
tabs: tabs,
indicatorColor: Theme.of(context).primaryColor,
),
body: new TabBarView(
children: tabPages,
),
),
);
}
return new ErrorMessage("There are currently no listed schedules", "Who forgot to put the schedules in the database?");
default:
return new ErrorMessage("Welp Something Went Wrong", "Check your connection to the internet");
}
},
);
}
}
5 changes: 2 additions & 3 deletions lib/pages/soundboard_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:firebase_analytics/firebase_analytics.dart';
import 'package:audioplayer/audioplayer.dart';

import 'package:cyber_discovery/widgets/sound_tab.dart';
import 'package:cyber_discovery/widgets/error_message.dart';

class SoundBoardPage extends StatelessWidget {
final FirebaseDatabase _db;
Expand Down Expand Up @@ -61,9 +62,7 @@ class SoundBoardPage extends StatelessWidget {
)
);
default:
//TODO
//Internet Error Picture Maybe?
return new Text("ERROR");
return new ErrorMessage("Welp Something Went Wrong", "Check your connection to the internet");
}
},
);
Expand Down
9 changes: 9 additions & 0 deletions lib/schedule_state.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class ScheduleState {
final String _state;
final bool _active;

ScheduleState(this._state, this._active);

get state => _state;
get active => _active;
}
Loading

0 comments on commit aa230c2

Please sign in to comment.