Skip to content

Commit

Permalink
Enhanced Comunity Page (#19)
Browse files Browse the repository at this point in the history
* implements #18
* Increments version
* Changed event state inicator colour

The schedule state indicator is now green when a schedule is finished this is to prevent a colour clash of red and green.
  • Loading branch information
REDACTED-REDACTED authored Aug 4, 2018
1 parent 467c0f7 commit fe95e37
Show file tree
Hide file tree
Showing 9 changed files with 248 additions and 8 deletions.
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.danielmilnes.cyberdiscovery"
minSdkVersion 16
targetSdkVersion 27
versionCode 6
versionName "1.3"
versionCode 7
versionName "1.3.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

Expand Down
Binary file added assets/images/contributors.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions lib/comunity_data.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import 'package:cached_network_image/cached_network_image.dart';

class ComunityData {
final String _title;
final String _subtitle;
final String _link;
final CachedNetworkImageProvider _imageProvider;
ComunityData(this._title, this._subtitle, this._link, this._imageProvider);

get title => _title;
get subtitle => _subtitle;
get link => _link;
get imageProvider => _imageProvider;
}
90 changes: 90 additions & 0 deletions lib/pages/comunity_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import 'package:flutter/material.dart';
import 'dart:async';

import 'package:firebase_database/firebase_database.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:cyber_discovery/comunity_data.dart';

import 'package:cyber_discovery/widgets/contributers.dart';
import 'package:cyber_discovery/widgets/comunity.dart';
import 'package:cyber_discovery/widgets/error_message.dart';

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

Future<List<ComunityData>> getComunityData(FirebaseDatabase db, BuildContext context) async {
DataSnapshot snapshot = await db.reference().child("Comunity").once();
dynamic data = snapshot.value;
int count = data["count"];
var configuration = createLocalImageConfiguration(context);

List<ComunityData> comunityData = [];
for (int i = 0; i<count; i++) {
dynamic rawComunityData = data[i.toString()];
ComunityData comunity = new ComunityData(
rawComunityData["title"],
rawComunityData["subtitle"],
rawComunityData["link"],
new CachedNetworkImageProvider(rawComunityData["qrLink"])..resolve(configuration)
);
comunityData.add(comunity);
}
return comunityData;
}


@override
Widget build(BuildContext context) {
/*List<Widget> comunitys = [
new Text("Comunity", style: Theme.of(context).textTheme.headline.apply(color: Colors.white)),
new Text("Over the course of Cyber Discovery a large comunity has formed. Originating from the discord server several comunity projects were undertaken showing the strength of the comunity, this app is one of them. Some others and other pillars of the comunity are listed below.", style: Theme.of(context).textTheme.body1.apply(color: Colors.white)),
new Divider(),
new Comunity(
"Discord",
"Come and Lurk",
"https://discord.gg/Kf8n5rT",
"assets/images/discord_qr.png"
),
new Comunity(
"The App",
"Leave a 5 star review xxx",
"https://play.google.com/store/apps/details?id=com.danielmilnes.cyberdiscovery",
"assets/images/playstore_qr.png"
),
new Comunity(
"Challenge Master", "A shit webiste I made", "https://challenge-master.firebaseapp.com/", "assets/images/discord_qr.png")
];*/

return new Padding(
padding: new EdgeInsets.all(5.0),
child: new FutureBuilder(
future: getComunityData(_db, context),
builder: (BuildContext context, AsyncSnapshot<List<ComunityData>> 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(
child: new CircularProgressIndicator(),
);
case (ConnectionState.done):
//Got Data
List<Widget> comunities = [new Contributors()];
for(ComunityData data in snapshot.data) {
comunities.add(new Comunity(data));
}
return new ListView(children: comunities);
default:
return new ErrorMessage("Welp Something Went Wrong", "Check your connection to the internet");
}
}
)



);
}
}
10 changes: 6 additions & 4 deletions lib/pages/home_page.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import 'package:flutter/material.dart';

import 'package:url_launcher/url_launcher.dart';

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

Expand All @@ -11,6 +9,7 @@ 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/pages/comunity_page.dart';
import 'package:cyber_discovery/widgets/error_message.dart';

class HomePage extends StatefulWidget {
Expand Down Expand Up @@ -39,6 +38,8 @@ class _HomePageState extends State<HomePage> {
return new BlogPage();
case 3:
return new SchedulePage(db);
case 4:
return new ComunityPage(db);
default:
return new ErrorMessage("Welp Something Went Wrong", "Unknown Cause");
}
Expand Down Expand Up @@ -81,9 +82,10 @@ class _HomePageState extends State<HomePage> {
Navigator.pop(context);
});
}),
new ListItem(Icons.people, "Discord", (){setState(
new ListItem(Icons.people, "Comunity", (){setState(
(){
launch("https://discord.gg/Kf8n5rT");
_pageId = 4;
Navigator.pop(context);
});
}),
],
Expand Down
62 changes: 62 additions & 0 deletions lib/widgets/comunity.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import 'package:flutter/material.dart';

import 'package:url_launcher/url_launcher.dart';
import 'package:cyber_discovery/comunity_data.dart';

class Comunity extends StatelessWidget {
final ComunityData _data;
Comunity(this._data);

@override
Widget build(BuildContext context) {
return new Padding(
padding: new EdgeInsets.symmetric(vertical: 10.0),
child: new Row(
children: <Widget>[
new SizedBox(
child: new Image(image: _data.imageProvider),
width: 130.0,
height: 130.0,
),
new Flexible(
fit: FlexFit.tight,
child: new Card(
child: new SizedBox(
height: 130.0,
child: new Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
new Padding(
padding: new EdgeInsets.symmetric(vertical: 10.0),
child: new Text(_data.title, style: Theme.of(context).textTheme.headline, textAlign: TextAlign.center,),
),
new Padding(
padding: new EdgeInsets.only(bottom: 5.0),
child: new Text(_data.subtitle, style: Theme.of(context).textTheme.subhead, textAlign: TextAlign.center,),
),
new Flexible(
child: new Container(),
fit: FlexFit.tight,
),
new Padding(
padding: new EdgeInsets.symmetric(vertical: 5.0),
child: new RaisedButton(
color: Theme.of(context).primaryColor,
textColor: Colors.white,
shape: new RoundedRectangleBorder(borderRadius: new BorderRadius.circular(30.0)),
child: new Text("Click Here or Scan the QR Code"),
onPressed: (){
launch(_data.link);
},
),
)
],
),
)
),
)
],
)
);
}
}
72 changes: 72 additions & 0 deletions lib/widgets/contributers.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import 'package:flutter/material.dart';

import 'package:url_launcher/url_launcher.dart';

class Contributors extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Padding(
padding: new EdgeInsets.symmetric(vertical: 10.0),
child: new Card(
child: new Padding(
padding: new EdgeInsets.all(5.0),
child: new Column(
children: <Widget>[
new Image.asset("assets/images/contributors.png"),
new Text("Contributors", style: Theme.of(context).textTheme.headline),
new Padding(
padding: new EdgeInsets.symmetric(vertical: 5.0),
child: new Text("This app is the result of some amazing people from the comunity why not give them a follow and show your appreciation."),
),
new GestureDetector(
child: new Padding(
padding: new EdgeInsets.symmetric(vertical: 5.0),
child: new Text("@BenTechy66 - Building the IOS version without paying a cent", style: new TextStyle(color: Colors.lightBlue)),
),
onTap: (){
launch("https://twitter.com/BenTechy66");
},
),
new GestureDetector(
child: new Padding(
padding: new EdgeInsets.symmetric(vertical: 5.0),
child: new Text("@thebeanogamer - Financial support and marketing", style: new TextStyle(color: Colors.lightBlue)),
),
onTap: (){
launch("https://twitter.com/thebeanogamer");
},
),
new GestureDetector(
child: new Padding(
padding: new EdgeInsets.symmetric(vertical: 5.0),
child: new Text("@dwouca - Curing my dislexia and the website", style: new TextStyle(color: Colors.lightBlue)),
),
onTap: (){
launch("https://twitter.com/dwouca");
},
),
new GestureDetector(
child: new Padding(
padding: new EdgeInsets.symmetric(vertical: 5.0),
child: new Text("@OwlNamedSeymour - Everything else", style: new TextStyle(color: Colors.lightBlue)),
),
onTap: (){
launch("https://twitter.com/OwlNamedSeymour");
},
),
new GestureDetector(
child: new Padding(
padding: new EdgeInsets.symmetric(vertical: 5.0),
child: new Text("@BritMonk3y - Graphic Design", style: new TextStyle(color: Colors.lightBlue)),
),
onTap: (){
launch("https://twitter.com/BritMonk3y");
},
),
],
),
),
)
);
}
}
2 changes: 1 addition & 1 deletion lib/widgets/schedule_tab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ScheduleTab extends StatelessWidget {
return new ScheduleState(state, active);
}else {
state = "Finished";
active = false;
active = true;
return new ScheduleState(state, active);
}
}
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ flutter:
- assets/images/drawer_head.png
- assets/images/unreleased.png
- assets/images/error_image.png

- assets/images/contributors.png
# Fonts
fonts:
- family: Dosis
Expand Down

0 comments on commit fe95e37

Please sign in to comment.