Skip to content

Commit

Permalink
Pokedex with Flutter
Browse files Browse the repository at this point in the history
  • Loading branch information
imayush-chauhan committed Nov 20, 2021
1 parent 389431c commit 7c70111
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 54 deletions.
1 change: 1 addition & 0 deletions lib/data/data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:firebase_auth/firebase_auth.dart';
class Data {

static Map poke = {};
static List poke2 = [];
static List<String> fav = [];
static bool isGen = false;
static bool isGenPoke = false;
Expand Down
2 changes: 1 addition & 1 deletion lib/pokemon/help.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class _HelpState extends State<Help> {
socialMedias(String s) async{
fireStore.then((value) async {
FirebaseFirestore.instance.
collection("data").doc("1")
collection("data").doc("2")
.get().then((result){
if(result.get(s) == ""){
snackBar("We don't have $s account try Instagram");
Expand Down
16 changes: 14 additions & 2 deletions lib/pokemon/infoScreen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class _InfoScreenState extends State<InfoScreen> {
int max = 20;
bool isType = false;
String click = "";
int total = 0;

Future<bool> onWillPop() async {
return (await set()) ?? false;
Expand Down Expand Up @@ -109,11 +110,23 @@ class _InfoScreenState extends State<InfoScreen> {
mainColor = Colors.grey.shade200;
thickColor = Colors.grey.shade400;
}
totalPoints();
Future.delayed(Duration(milliseconds: 800), () {
calculator();
});
}

totalPoints(){
setState(() {
total = Data.poke["pokemon"][widget.inx]["special_defense"] +
Data.poke["pokemon"][widget.inx]["special_attack"] +
Data.poke["pokemon"][widget.inx]["speed"] +
Data.poke["pokemon"][widget.inx]["hp"] +
Data.poke["pokemon"][widget.inx]["attack"] +
Data.poke["pokemon"][widget.inx]["defense"];
});
}

calculator() {
setState(() {
max = Data.poke["pokemon"][widget.inx]["special_defense"];
Expand Down Expand Up @@ -1098,8 +1111,7 @@ class _InfoScreenState extends State<InfoScreen> {
color: Colors.black.withOpacity(
0.6),
),),
Text(Data.poke["pokemon"][widget
.inx]["total"].toString(),
Text(total.toString(),
style: TextStyle(
fontSize: 17,
fontWeight: FontWeight.w600,
Expand Down
6 changes: 4 additions & 2 deletions lib/pokemon/introduction screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class _IntroScreenState extends State<IntroScreen> {
final FirebaseAuth _auth = FirebaseAuth.instance;

bool onPress = false;
bool loading = false;

void signInAnonymously() {
_auth.signInAnonymously().then((result) {
Expand All @@ -33,7 +34,7 @@ class _IntroScreenState extends State<IntroScreen> {
return Scaffold(
backgroundColor: Colors.white,
body: Center(
child: Column(
child: loading == false ? Column(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expand Down Expand Up @@ -95,6 +96,7 @@ class _IntroScreenState extends State<IntroScreen> {
Future.delayed(Duration(milliseconds: 350), () {
setState(() {
onPress = false;
loading = true;
signInAnonymously();
});

Expand Down Expand Up @@ -124,7 +126,7 @@ class _IntroScreenState extends State<IntroScreen> {
height: MediaQuery.of(context).size.height*0.1,
),
],
),
) : CircularProgressIndicator(),
),
);
}
Expand Down
103 changes: 54 additions & 49 deletions lib/pokemon/pokemon.dart
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class _PokemonState extends State<Pokemon> with SingleTickerProviderStateMixin {

final fireStore = Firebase.initializeApp();
String url = "";

getData() {
fireStore.then((value) async {
FirebaseFirestore.instance
Expand All @@ -123,22 +123,27 @@ class _PokemonState extends State<Pokemon> with SingleTickerProviderStateMixin {
.get()
.then((value) {
setState(() {
url = value.get("url");
Data.poke = value.get("newData");
// url = value.get("url");
// url2 = value.get("url2");
});
}).whenComplete(() {
getUsersData();
});
// .whenComplete(() {
// getUsersData();
// }).whenComplete(() {
// getUsersData2();
// })
});
}

getUsersData() async {
var response =
await http.get(
Uri.parse(url));
setState(() {
Data.poke = jsonDecode(response.body);
});
}
// getUsersData() async {
// var response =
// await http.get(
// Uri.parse(url));
// setState(() {
// Data.poke = jsonDecode(response.body);
// });
// }

iconAnimation() {
if (isCollapsed == false) {
Expand Down Expand Up @@ -969,43 +974,43 @@ class _PokemonState extends State<Pokemon> with SingleTickerProviderStateMixin {
),
),
),
// GestureDetector(
// onTap: () {
// FirebaseAuth.instance.signOut();
// },
// child: Container(
// height: 55,
// width: MediaQuery
// .of(context)
// .size
// .width * 0.6,
// alignment: Alignment.centerLeft,
// color: Colors.white,
// child: Row(
// mainAxisAlignment: MainAxisAlignment.start,
// crossAxisAlignment: CrossAxisAlignment.center,
// children: [
// Padding(
// padding: const EdgeInsets.only(left: 20),
// child: Icon(Icons.logout),
// // child: Icon(Icons.hel,
// // color: Colors.black.withOpacity(0.9),
// // size: 20,
// // ),
// ),
// Padding(
// padding: const EdgeInsets.only(left: 15),
// child: Text("Logout",
// style: GoogleFonts.roboto(
// fontSize: 20,
// fontWeight: FontWeight.w600,
// color: Colors.black.withOpacity(0.9),
// )),
// ),
// ],
// ),
// ),
// ),
GestureDetector(
onTap: () {
FirebaseAuth.instance.signOut();
},
child: Container(
height: 55,
width: MediaQuery
.of(context)
.size
.width * 0.6,
alignment: Alignment.centerLeft,
color: Colors.white,
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.only(left: 20),
child: Icon(Icons.logout),
// child: Icon(Icons.hel,
// color: Colors.black.withOpacity(0.9),
// size: 20,
// ),
),
Padding(
padding: const EdgeInsets.only(left: 15),
child: Text("Logout",
style: GoogleFonts.roboto(
fontSize: 20,
fontWeight: FontWeight.w600,
color: Colors.black.withOpacity(0.9),
)),
),
],
),
),
),
],
),
),
Expand Down

0 comments on commit 7c70111

Please sign in to comment.