Skip to content
This repository has been archived by the owner on Aug 24, 2021. It is now read-only.

Commit

Permalink
game page added
Browse files Browse the repository at this point in the history
  • Loading branch information
gigabite-pro committed Jun 22, 2021
1 parent d19c01f commit 7cbaf60
Show file tree
Hide file tree
Showing 12 changed files with 413 additions and 5 deletions.
Binary file added assets/Dice-1.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/Dice-2.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/Dice-3.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/Dice-4.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/Dice-5.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/Dice-6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:bharat_mystery/screens/homepage.dart';
import 'package:bharat_mystery/screens/mainGame.dart';
import 'package:bharat_mystery/screens/selectMonument.dart';
import 'package:bharat_mystery/screens/theme_provider.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -43,7 +44,8 @@ class MyApp extends StatelessWidget {
'/register-page': (_) => RegisterPage(),
'/home-page': (_) => HomePage(),
'/forgot-password-page': (_) => ForgotPage(),
'/select-monument': (_) => SelectMonument()
'/select-monument': (_) => SelectMonument(),
'/main-game': (_) => MainGame(),
});
},
),
Expand Down
199 changes: 199 additions & 0 deletions lib/screens/game.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
import 'package:flutter/services.dart';
import 'package:bharat_mystery/screens/mainGame.dart';
import 'package:flutter/material.dart';

class Game extends StatefulWidget {
const Game({Key pagekey, this.title}) : super(key: pagekey);
final String title;

@override
_GameState createState() => _GameState();
}

class _GameState extends State<Game> with AutomaticKeepAliveClientMixin {
Future<bool> _onWillPop() {
return showDialog(
context: context,
builder: (context) => AlertDialog(
title: Text('Are you sure?'),
content: Text('Do you want to exit the app?'),
actions: <Widget>[
TextButton(
onPressed: () => Navigator.of(context).pop(false),
child: Text('No'),
),
TextButton(
onPressed: () => SystemNavigator.pop(),
child: Text('Yes'),
),
],
),
) ??
false;
}

@override
Widget build(BuildContext context) {
super.build(context);
//exit app on back pressed
return WillPopScope(onWillPop: _onWillPop, child: GameContent());
}

@override
// TODO: implement wantKeepAlive
bool get wantKeepAlive => true;
}

class GameContent extends StatefulWidget {
@override
_GameContentState createState() => _GameContentState();
}

class _GameContentState extends State<GameContent> {
String _player1Name, _player2Name;
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
List players = [];

@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Theme.of(context).focusColor,
body: SingleChildScrollView(
child: Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
decoration: BoxDecoration(
color: Theme.of(context).accentColor,
),
child: Stack(
children: <Widget>[
Padding(
padding: const EdgeInsets.fromLTRB(10.0, 200.0, 10.0, 20.0),
child: Column(
children: <Widget>[
Text(
"Player Info",
style: TextStyle(
color: Theme.of(context).highlightColor,
fontFamily: 'LexendDeca',
fontSize: 25.0,
fontWeight: FontWeight.bold,
),
),
SizedBox(
height: 30.0,
),
Form(
key: _formKey,
child: Column(
children: <Widget>[
//textfield player1
TextFormField(
autocorrect: false,
autofocus: false,
validator: (input) {
if (input.isEmpty) {
return "Please provide Player's Name";
}
return null;
},
style: TextStyle(color: Colors.black),
decoration: InputDecoration(
hintText: "Player 1 Name",
hintStyle: TextStyle(color: Colors.grey),
border: OutlineInputBorder(
borderSide:
BorderSide(color: Colors.grey[50]),
borderRadius: BorderRadius.circular(30.0),
),
fillColor: Colors.white,
filled: true,
contentPadding: EdgeInsets.all(20.0)),
onSaved: (input) => _player1Name = input,
keyboardType: TextInputType.emailAddress,
),
SizedBox(
height: 20.0,
),

//textfield player1
TextFormField(
autocorrect: false,
autofocus: false,
validator: (input) {
if (input.isEmpty) {
return "Please provide Player's Name";
}
return null;
},
style: TextStyle(color: Colors.black),
decoration: InputDecoration(
hintText: "Player 2 Name",
hintStyle: TextStyle(color: Colors.grey),
border: OutlineInputBorder(
borderSide:
BorderSide(color: Colors.grey[50]),
borderRadius: BorderRadius.circular(30.0),
),
fillColor: Colors.white,
filled: true,
contentPadding: EdgeInsets.all(20.0)),
onSaved: (input) => _player2Name = input,
keyboardType: TextInputType.emailAddress,
),
SizedBox(
height: 20.0,
),

MaterialButton(
onPressed: addUser,
height: 50.0,
padding: EdgeInsets.symmetric(horizontal: 40.0),
shape: StadiumBorder(),
child: Text(
"Start Game",
style: TextStyle(
fontFamily: 'LexendDeca',
fontSize: 16.0,
color: Theme.of(context).cardColor),
),
color: Theme.of(context).highlightColor,
),
],
),
),
],
),
),
Positioned(
bottom: 0,
child: Container(
width: MediaQuery.of(context).size.width,
height: 20.0,
color: Theme.of(context).focusColor,
),
),
],
),
),
),
);
}

void addUser() {
final formState = _formKey.currentState;
if (formState.validate()) {
formState.save();
players.add(_player1Name);
players.add(_player2Name);

Navigator.push(
context,
MaterialPageRoute(
builder: (context) => MainGame(
players: players,
),
));
}
}
}
7 changes: 7 additions & 0 deletions lib/screens/homepage.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:bharat_mystery/screens/profile.dart';
import 'package:bharat_mystery/screens/selectMonument.dart';
import 'package:bharat_mystery/screens/theme_provider.dart';
import 'package:bharat_mystery/screens/game.dart';
import 'package:flutter/material.dart';
import 'package:curved_navigation_bar/curved_navigation_bar.dart';
import 'package:provider/provider.dart';
Expand All @@ -14,6 +15,7 @@ class _HomePageState extends State<HomePage> {
PageController _pageController = PageController();
List<Widget> _screens = [
SelectMonument(),
Game(),
Profile(),
];

Expand Down Expand Up @@ -48,6 +50,11 @@ class _HomePageState extends State<HomePage> {
size: 20.0,
color: Theme.of(context).highlightColor,
),
Icon(
Icons.gamepad,
size: 20.0,
color: Theme.of(context).highlightColor,
),
Icon(
Icons.settings,
size: 20.0,
Expand Down
Loading

0 comments on commit 7cbaf60

Please sign in to comment.