Skip to content

Commit

Permalink
Literature store (#145)
Browse files Browse the repository at this point in the history
* cleanup before store implementation

* add artifact details

* layout for the store

* get items on purchase logic
  • Loading branch information
aquibbaig authored Aug 19, 2020
1 parent 0b180a0 commit 243496c
Show file tree
Hide file tree
Showing 14 changed files with 537 additions and 35 deletions.
24 changes: 24 additions & 0 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,14 @@ PODS:
- Flutter
- shared_preferences_web (0.0.1):
- Flutter
- url_launcher (0.0.1):
- Flutter
- url_launcher_linux (0.0.1):
- Flutter
- url_launcher_macos (0.0.1):
- Flutter
- url_launcher_web (0.0.1):
- Flutter

DEPENDENCIES:
- Firebase/Analytics
Expand All @@ -416,6 +424,10 @@ DEPENDENCIES:
- shared_preferences (from `.symlinks/plugins/shared_preferences/ios`)
- shared_preferences_macos (from `.symlinks/plugins/shared_preferences_macos/ios`)
- shared_preferences_web (from `.symlinks/plugins/shared_preferences_web/ios`)
- url_launcher (from `.symlinks/plugins/url_launcher/ios`)
- url_launcher_linux (from `.symlinks/plugins/url_launcher_linux/ios`)
- url_launcher_macos (from `.symlinks/plugins/url_launcher_macos/ios`)
- url_launcher_web (from `.symlinks/plugins/url_launcher_web/ios`)

SPEC REPOS:
trunk:
Expand Down Expand Up @@ -475,6 +487,14 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/shared_preferences_macos/ios"
shared_preferences_web:
:path: ".symlinks/plugins/shared_preferences_web/ios"
url_launcher:
:path: ".symlinks/plugins/url_launcher/ios"
url_launcher_linux:
:path: ".symlinks/plugins/url_launcher_linux/ios"
url_launcher_macos:
:path: ".symlinks/plugins/url_launcher_macos/ios"
url_launcher_web:
:path: ".symlinks/plugins/url_launcher_web/ios"

SPEC CHECKSUMS:
abseil: 6c8eb7892aefa08d929b39f9bb108e5367e3228f
Expand Down Expand Up @@ -517,6 +537,10 @@ SPEC CHECKSUMS:
shared_preferences: 430726339841afefe5142b9c1f50cb6bd7793e01
shared_preferences_macos: f3f29b71ccbb56bf40c9dd6396c9acf15e214087
shared_preferences_web: 141cce0c3ed1a1c5bf2a0e44f52d31eeb66e5ea9
url_launcher: 6fef411d543ceb26efce54b05a0a40bfd74cbbef
url_launcher_linux: ac237cb7a8058736e4aae38bdbcc748a4b394cc0
url_launcher_macos: fd7894421cd39320dce5f292fc99ea9270b2a313
url_launcher_web: e5527357f037c87560776e36436bf2b0288b965c

PODFILE CHECKSUM: 37a32c4517040e393e2d4d1be49ee7c809fa9dc9

Expand Down
13 changes: 12 additions & 1 deletion lib/components/appbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:literature/provider/playerlistprovider.dart';
import 'package:literature/screens/howtoplay.dart';
import 'package:literature/screens/landingpage.dart';
import 'package:literature/screens/profile.dart';
import 'package:literature/store/store.dart';
import 'package:literature/utils/game_communication.dart';
import 'package:literature/components/credits.dart';
import 'package:provider/provider.dart';
Expand Down Expand Up @@ -328,11 +329,21 @@ class _GlobalAppBarState extends State<GlobalAppBar> {
// ),
// ],
actions: <Widget>[
IconButton(
icon: Icon(Icons.shopping_cart),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => Store())
);
},
color: Color(0xFF303f9f),
),
GestureDetector(
child: Padding(
padding: EdgeInsets.all(10.0),
child: CircleAvatar(
radius: width * 0.05,
radius: 15.0,
backgroundColor: (user == null) ? Color(0xFF6ad1ff) : null,
backgroundImage: (user != null)
? NetworkImage(user.photoUrl, scale: 1.0)
Expand Down
19 changes: 14 additions & 5 deletions lib/components/card_deck.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import 'package:flutter/material.dart';
import 'package:literature/models/playing_cards.dart';
import 'package:enum_to_string/enum_to_string.dart';
import 'package:literature/provider/playerlistprovider.dart';
import 'package:provider/provider.dart';
import 'package:literature/store/card-designs/prime.dart';

// ignore: must_be_immutable
class CardDeck extends StatefulWidget {
CardDeck({
Key key,
Expand Down Expand Up @@ -31,16 +35,21 @@ class _CardDeckState extends State<CardDeck> {
void dispose() {
super.dispose();
}

// Widget _rowCardsView() {
// return _largeCardsDeck();
// }

@override
Widget build(BuildContext context) {
return new Center(child: _buildCardDeck());
final playerProvider = Provider.of<PlayerList>(context, listen: false);
var selectedCardDesign = playerProvider.getCardDesignDetails(playerProvider.currPlayer);
switch(selectedCardDesign) {
case "prime":
return new PrimeCardDesign(cards: widget.cards);
default:
return new Center(child: _buildCardDeck());
break;
}
}

// Default card design that we have.
// Returns a string representing
// the shorthand of a card suit.
String _cardTypeToString(String type) {
Expand Down
15 changes: 11 additions & 4 deletions lib/models/player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,16 @@ class Player extends ChangeNotifier {
bool teamLeader;
// Team identifier
String teamIdentifier;
//name from firebase
// name from firebase
String loginName;
//photo url
// photo url
String photoUrl;
// selected card design
String selectedCardDesign;
// selected theme.
String selectedTheme;
// purchased store content.
List<String> purchasedStoreContent;

// Constructor
Player({
Expand All @@ -25,7 +31,8 @@ class Player extends ChangeNotifier {
this.teamIdentifier,
this.teamLeader = false,
this.loginName,
this.photoUrl
this.photoUrl,
this.selectedCardDesign = "default",
this.selectedTheme = "default"
});

}
12 changes: 12 additions & 0 deletions lib/provider/playerlistprovider.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:collection';
import 'dart:convert';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/foundation.dart';
import 'package:literature/models/player.dart';
Expand Down Expand Up @@ -38,4 +39,15 @@ class PlayerList extends ChangeNotifier {
void addFirebaseUser(FirebaseUser u) {
user = u;
}

String getCardDesignDetails (Player pl) {
Player p = _list.firstWhere((element) => pl.name == element.name);
return p.selectedCardDesign;
}

void setCardDesignDetails (Player pl, String name) {
Player p = _list.firstWhere((element) => pl.name == element.name);
p.selectedCardDesign = name;
return;
}
}
43 changes: 22 additions & 21 deletions lib/screens/creategame.dart
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ class _CreateGame extends State<CreateGame> with AfterLayoutMixin<CreateGame> {
..show();
}

void showJoinDialog(BuildContext context) {
showDialog(
Future showJoinDialog(BuildContext context) {
return showDialog(
child: new Dialog(
backgroundColor: Colors.white,
shape: RoundedRectangleBorder(
Expand All @@ -264,32 +264,33 @@ class _CreateGame extends State<CreateGame> with AfterLayoutMixin<CreateGame> {
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Center(
Padding(
padding: EdgeInsets.fromLTRB(0, 30, 0, 0),
child: new Text(
"Join Room",
textAlign: TextAlign.center,
textAlign: TextAlign.left,
style: TextStyle(
color: Colors.blueAccent,
color: Colors.black,
fontFamily: 'B612',
fontSize: MediaQuery.of(context).size.width * 0.075,
fontSize: MediaQuery.of(context).size.width * 0.045,
),
),
),
new TextField(
controller: joinRoomIdTextController,
keyboardType: TextInputType.text,
decoration: new InputDecoration(
hintText: 'Enter Room ID...',
contentPadding: EdgeInsets.fromLTRB(
MediaQuery.of(context).size.width * 0.01,
MediaQuery.of(context).size.height * 0.01,
MediaQuery.of(context).size.width * 0.01,
MediaQuery.of(context).size.height * 0.01),
border: new OutlineInputBorder(
borderRadius: new BorderRadius.circular(
MediaQuery.of(context).size.height * 0.03),
Container(
width: 200,
child: new TextField(
controller: joinRoomIdTextController,
keyboardType: TextInputType.text,
decoration: new InputDecoration(
hintText: ' Enter Room ID',
contentPadding: EdgeInsets.fromLTRB(
MediaQuery.of(context).size.width * 0.01,
MediaQuery.of(context).size.height * 0.01,
MediaQuery.of(context).size.width * 0.01,
MediaQuery.of(context).size.height * 0.01),
border: new OutlineInputBorder(),
prefixIcon: const Icon(Icons.person),
),
icon: const Icon(Icons.person),
),
),
Row(
Expand All @@ -303,7 +304,7 @@ class _CreateGame extends State<CreateGame> with AfterLayoutMixin<CreateGame> {
},
child: Text(
'Close',
style: TextStyle(color: Colors.black),
style: TextStyle(color: Colors.blue),
)),
FlatButton(
onPressed: () {
Expand Down
1 change: 0 additions & 1 deletion lib/screens/gamescreen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,6 @@ class _GameScreenState extends State<GameScreen> with WidgetsBindingObserver {

@override
Widget build(BuildContext context) {
print(MediaQuery.of(context).size.height);
return new SafeArea(
bottom: false,
top: false,
Expand Down
27 changes: 27 additions & 0 deletions lib/store/artifacts.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const store = [
{
"diamond": [
"card_design:prime",
"card_design:pixels",
"arena_design:nightscape",
"game_mat:castle",
"game_mat:sanctuary"
],
},
{"gold": [
"card_design:piper",
"card_design:azure",
"arena_design:infinitesnake",
"arena_design:flowerpot"
],},
{"silver": [
"game_mat:lava",
"game_mat:cloudbursts",
"card_design:flake"
],},
{"bronze": [
"card_design:default",
"arena_design:dashedlines",
"arena_design:doublepipes"
]},
];
17 changes: 17 additions & 0 deletions lib/store/card-designs/prime.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import 'package:flutter/material.dart';
import 'package:literature/models/playing_cards.dart';

// ignore: must_be_immutable
class PrimeCardDesign extends StatelessWidget {
PrimeCardDesign({
this.cards
});

List<PlayingCard> cards;


@override
Widget build(BuildContext context) {
return new Text("Prime");
}
}
18 changes: 18 additions & 0 deletions lib/store/rarity.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
var rarity = [
{
"tier": "diamond",
"rarity": 5
},
{
"tier": "gold",
"rarity": 15
},
{
"tier": "silver",
"rarity": 20
},
{
"tier": "bronze",
"rarity": 60
},
];
Loading

0 comments on commit 243496c

Please sign in to comment.