Skip to content

Commit

Permalink
removed edit avatar
Browse files Browse the repository at this point in the history
  • Loading branch information
KhalafA committed May 5, 2019
1 parent 55fa086 commit 3836783
Show file tree
Hide file tree
Showing 10 changed files with 106 additions and 63 deletions.
7 changes: 0 additions & 7 deletions lib/config/route_handlers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import 'package:pro/pages/deathmatch_tab/deathmatch_quiz.dart';
import 'package:pro/pages/multiplayer_tab/game_creation.dart';
import 'package:pro/pages/multiplayer_tab/game_lobby.dart';

import 'package:pro/pages/edit_avatar_page.dart';

import 'package:pro/data/constants.dart' as constants;

var rootHandler = new Handler(
Expand Down Expand Up @@ -81,8 +79,3 @@ var multiplayerGameHandler = new Handler(
return GameLobby(gameID : gameID, owner: owner);
});

var editAvatarHandler = new Handler(
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
return EditAvatarPage();
});

1 change: 0 additions & 1 deletion lib/config/routes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,5 @@ class Routes {
router.define(score, handler: scoreHandler);
router.define(createNewGame, handler: createNewGameHandler);
router.define(multiplayerGame, handler: multiplayerGameHandler);
router.define(editAvatar, handler: editAvatarHandler);
}
}
3 changes: 0 additions & 3 deletions lib/data/database.dart
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ class Database {
}

// Update Game
// TODO: update game
Future<void> updateGame(String gameID, Game updatedGame) async {
DocumentReference documentReference = Firestore.instance.collection(constants.gamesCollection).document(gameID);
currentGame = updatedGame;
Expand All @@ -229,7 +228,6 @@ class Database {
List<DocumentSnapshot> d = querySnapshot.documents;

List<Game> games = [];
print(d.length.toString() + "------");

for(DocumentSnapshot snapshot in d){

Expand Down Expand Up @@ -264,7 +262,6 @@ class Database {

return true;
}else {
//TODO: Game is no longer open.
return false;
}
}
Expand Down
19 changes: 0 additions & 19 deletions lib/pages/edit_avatar_page.dart

This file was deleted.

38 changes: 32 additions & 6 deletions lib/pages/multiplayer_tab/game_lobby.dart
Original file line number Diff line number Diff line change
Expand Up @@ -442,8 +442,6 @@ class _GameLobbyState extends State<GameLobby> {

}



Future<bool> _onWillPop() {
if(!gameStarted){
if(widget.owner == "true"){
Expand All @@ -460,14 +458,42 @@ class _GameLobbyState extends State<GameLobby> {

Navigator.pop(context);
}else {
_showPromt();
}
}

//TODO: warn user that they are about to leave the game
Navigator.pop(context);
}
_showPromt(){
return showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text("You're about to leave the game, are you sure?"),
content: Text("t"),
actions: <Widget>[
new FlatButton(
child: new Text('CANCEL'),
onPressed: () {
Navigator.of(context).pop();
},
),
new FlatButton(
child: new Text('ACCEPT'),
onPressed: () {
//TODO: updateDatabase -> Let winner know he won.
Navigator.of(context).pop();
_goBack();
},
)
],
);
});
}


_goBack(){
Navigator.pop(context);
}


}


23 changes: 10 additions & 13 deletions lib/pages/multiplayer_tab/game_quiz.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ class _GameQuizState extends State<GameQuiz> {
bool isCreator = false;
int timeLeft;

String statusMessage;
bool gameHasStarted = false;
bool gameHasEnded = false;

@override
void initState() {
Expand Down Expand Up @@ -75,16 +76,15 @@ class _GameQuizState extends State<GameQuiz> {
);
}

bool gameHasStarted = false;

Widget questionList(){
return Container(
child: Stack(
children: <Widget>[
quiz(),
(!gameHasEnded) ? quiz() : Container(),

(!gameHasStarted) ? blur() : Container(),
(!gameHasStarted) ? startScreen() : Container()
(!gameHasStarted || gameHasEnded) ? blur() : Container(),
(!gameHasStarted) ? startScreen() : Container(),
(gameHasEnded) ? endScreen() : Container()
],
),
);
Expand Down Expand Up @@ -124,13 +124,8 @@ Widget quiz() {
if(snap.data[constants.gameCurrentRound] <= 5){
return placeholder(snap.data[constants.gameCurrentRound]);
}else {
return Container(
child: Text("Game Has ended"), //TODO: Score for each player
);
gameHasEnded = true;
}



},
);
}
Expand Down Expand Up @@ -380,7 +375,9 @@ Widget quiz() {




Widget endScreen(){
return Container();
}



Expand Down
70 changes: 63 additions & 7 deletions lib/pages/multiplayer_tab/multiplayer_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:pro/model/user.dart';
import 'package:pro/model/game.dart';

import 'package:pro/widgets/custom_widgets.dart' as customWidget;
import 'package:fluttertoast/fluttertoast.dart';

class MultiplayerPage extends StatefulWidget {
final int index;
Expand All @@ -16,7 +17,9 @@ class MultiplayerPage extends StatefulWidget {

class _MultiplayerPageState extends State<MultiplayerPage> {

TextEditingController controller = new TextEditingController();
TextEditingController searchInputController = TextEditingController();
TextEditingController passwordFieldControler = TextEditingController();

String filter;

User user;
Expand All @@ -30,9 +33,9 @@ class _MultiplayerPageState extends State<MultiplayerPage> {
void initState() {
super.initState();

controller.addListener(() {
searchInputController.addListener(() {
setState(() {
filter = controller.text;
filter = searchInputController.text;
});
});
print("starting multiplayer page");
Expand Down Expand Up @@ -95,7 +98,7 @@ class _MultiplayerPageState extends State<MultiplayerPage> {
child: Padding(
padding: EdgeInsets.only(left:30.0,top:5.0),
child: TextField(
controller: controller,
controller: searchInputController,
cursorColor: Color(0xFF2c304d),
style: TextStyle(fontSize: 16.0, color: Color(0xFF2c304d), fontWeight: FontWeight.w300),
decoration: InputDecoration(
Expand Down Expand Up @@ -154,18 +157,71 @@ class _MultiplayerPageState extends State<MultiplayerPage> {
);
}

Future joinGame(int index) async{
joinGame(int index){
if(games[index].password != null){
//TODO: popup with that lets type in passwords
print("Game ${games[index].creatorName} has password");
passwordAlertDialog(index);
}else {

Database().joinGame(games[index])
.then((onValue) => onValue ?
Navigator.pushNamed(context, '/multiplayerGame?gameID=${games[index].gameID}&owner=false') : print("game is closed"));
Navigator.pushNamed(context, '/multiplayerGame?gameID=${games[index].gameID}&owner=false') : toast("The game is no longer avaliable"));
}

}

passwordAlertDialog(int index){
return showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text('Password:'),
content: TextField(
keyboardType: TextInputType.number,
controller: passwordFieldControler,

decoration: InputDecoration(hintText: "Enter password here"),
),
actions: <Widget>[
new FlatButton(
child: new Text('Join game'),
onPressed: () {

if(passwordFieldControler.text == games[index].password){
passwordFieldControler.text = '';
Navigator.of(context).pop();
doSomething(index);
}else {
toast("Incorrect Password");
}

},
)
],
);
});
}

doSomething(int index){
Database().joinGame(games[index])
.then((onValue) => onValue ?
Navigator.pushNamed(context, '/multiplayerGame?gameID=${games[index].gameID}&owner=false') : toast("The game is no longer avaliable"));
}

toast(String string){
Fluttertoast.showToast(
msg: string,
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.CENTER,
timeInSecForIos: 1,
backgroundColor: Colors.white70,
textColor: Colors.black,
fontSize: 16.0
);
}



Widget joinCard(bool isPasswordLocked){
return Column(
children: <Widget>[
Expand Down
1 change: 0 additions & 1 deletion lib/pages/onBoarding/animation/page_reveal.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class CircleRevealClipper extends CustomClipper<Rect>{

@override
bool shouldReclip(CustomClipper<Rect> oldClipper) {
// TODO: implement shouldReclip
return true;
}

Expand Down
6 changes: 0 additions & 6 deletions lib/pages/settings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,6 @@ class _SettingsPageState extends State<SettingsPage> {
onPressed: _signOut,
),
),
Container(
child: RaisedButton(
child: Text("Edit Avatar"),
onPressed:() => Navigator.of(context).pushNamed('/editAvatar'),
),
),
new FutureBuilder<FirebaseUser>(
future: FirebaseAuth.instance.currentUser(),
builder: (BuildContext context,
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ dependencies:
shared_preferences:
fluro: "^1.3.7"
html_unescape: 1.0.1+2
fluttertoast: ^3.0.4


dev_dependencies:
Expand Down

0 comments on commit 3836783

Please sign in to comment.