Starting bug hunting

This commit is contained in:
Sewmina Dilshan 2023-06-30 15:16:14 +05:30
parent 476afe153a
commit f337e72476
4 changed files with 116 additions and 90 deletions

View File

@ -165,7 +165,13 @@ class DataManager{
Map<String, int> _ThisSeasonCryptoEarnings = {}; Map<String, int> _ThisSeasonCryptoEarnings = {};
Map<String, int> _ThisSeasonGamesEarnings = {}; Map<String, int> _ThisSeasonGamesEarnings = {};
earningsObj.forEach((key, earnings) { earningsObj.forEach((key, _earnings) {
int earnings;
try{
earnings = _earnings;
}catch(e){
earnings = int.parse(_earnings);
}
Debug.Log("$key : $earnings"); Debug.Log("$key : $earnings");
dynamic gameData = Helpers.GetGameFromCode(key); dynamic gameData = Helpers.GetGameFromCode(key);
_ThisSeasonCryptoEarnings.update(gameData['coin'], (value) => earnings, ifAbsent: ()=> earnings); _ThisSeasonCryptoEarnings.update(gameData['coin'], (value) => earnings, ifAbsent: ()=> earnings);

View File

@ -3,6 +3,10 @@ import 'package:fhub/backend/DataManager.dart';
import 'package:fhub/backend/DebugHelper.dart'; import 'package:fhub/backend/DebugHelper.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
extension NumExtensions on num {
bool get isInt => (this % 1) == 0;
}
class Helpers{ class Helpers{
static IconData GetIconForCrypto(String val){ static IconData GetIconForCrypto(String val){

View File

@ -51,6 +51,7 @@ class _HomeState extends State<Home> {
child: CustomBody( child: CustomBody(
context: context, context: context,
onAnimEnd: () { onAnimEnd: () {
// kickstartAnimations();
setState(() {}); setState(() {});
}, },
bottomNav: [ bottomNav: [

View File

@ -109,17 +109,23 @@ class _MyHomePageState extends State<MyHomePage> {
), ),
), ),
const SizedBox(height: 100), const SizedBox(height: 100),
NeonButton( GlassButton(onTap: (){setState(() {
onPressed: () { counter=1;
setState(() { });}, child: Padding(
counter = 1; padding: const EdgeInsets.all(8.0),
}); child: Row(mainAxisAlignment:MainAxisAlignment.spaceBetween,children: [Container(width: 30,),Text("Get Started",style: TextStyle(fontSize: 20)), Icon(Icons.arrow_circle_right_outlined,size: 30,)],),
}, ), width: 250, height : 50,color: Colors.lightBlueAccent),
text: "Get Started", // NeonButton(
trailing: const Icon( // onPressed: () {
Icons.arrow_circle_right_outlined, // setState(() {
size: 30, // counter = 1;
)), // });
// },
// text: "Get Started",
// trailing: const Icon(
// Icons.arrow_circle_right_outlined,
// size: 30,
// )),
const SizedBox(height: 120), const SizedBox(height: 120),
], ],
@ -135,97 +141,106 @@ class _MyHomePageState extends State<MyHomePage> {
return Header(child: loginLoading ? const Center(child: Text("Loading...")) : Column(mainAxisSize: MainAxisSize.max, return Header(child: loginLoading ? const Center(child: Text("Loading...")) : Column(mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Text("Let's Get you ${isLogin ? "Logged-In" : "Registered"}!", Padding(
style: TextStyle(fontSize: 20)), padding: const EdgeInsets.symmetric(horizontal: 30),
const SizedBox(height: 30,), child: GlassCard(
Row(mainAxisAlignment: MainAxisAlignment.center, child: Padding(
children: [ padding: const EdgeInsets.all(15.0),
Icon(Icons.person), SizedBox(width: 15,), child: Column(children:[
Text("Let's Get you ${isLogin ? "Logged-In" : "Registered"}!",
style: TextStyle(fontSize: 20)),
const SizedBox(height: 30,),
Row(mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(Icons.person), SizedBox(width: 15,),
SizedBox(width: 250, SizedBox(width: 250,
child: TextField(controller: usernameController, child: TextField(controller: usernameController,
decoration: InputDecoration(hintText: "Username"),),) decoration: InputDecoration(hintText: "Username"),),)
],), ],),
Row(mainAxisAlignment: MainAxisAlignment.center, Row(mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Icon(Icons.key), Icon(Icons.key),
SizedBox(width: 15,), SizedBox(width: 15,),
SizedBox(width: 250, SizedBox(width: 250,
child: TextField(controller:passwordController,obscureText: true, child: TextField(controller:passwordController,obscureText: true,
decoration: InputDecoration(hintText: "Password"),),) decoration: InputDecoration(hintText: "Password"),),)
],), ],),
const SizedBox(height: 20,), const SizedBox(height: 20,),
NeonButton(height: 40, GlassButton(height: 40,
width: 200, width: 200,
onPressed: () async{ onTap: () async{
if(usernameController.text.length < 3){ if(usernameController.text.length < 3){
Dialogs.showAlertDialog(context, "Invalid Input", "Username must be longer than 3 characters"); Dialogs.showAlertDialog(context, "Invalid Input", "Username must be longer than 3 characters");
return; return;
} }
if(passwordController.text.length < 3){ if(passwordController.text.length < 3){
Dialogs.showAlertDialog(context, "Invalid Input", "Password must be longer than 3 characters"); Dialogs.showAlertDialog(context, "Invalid Input", "Password must be longer than 3 characters");
return; return;
} }
if(passwordController.text.contains(" ") || usernameController.text.contains(" ")){ if(passwordController.text.contains(" ") || usernameController.text.contains(" ")){
Dialogs.showAlertDialog(context, "Invalid Input", "Neither the username nor password can contain spaces"); Dialogs.showAlertDialog(context, "Invalid Input", "Neither the username nor password can contain spaces");
return; return;
} }
setState(() { setState(() {
loginLoading = true; loginLoading = true;
}); });
if(isLogin){ if(isLogin){
int loginResult = await LoginManager.Login(usernameController.text, passwordController.text); int loginResult = await LoginManager.Login(usernameController.text, passwordController.text);
if(loginResult == 0){ if(loginResult == 0){
loadHome(); loadHome();
}else if(loginResult == 5){ }else if(loginResult == 5){
Dialogs.showAlertDialog(context, "Login Failed", "Incorrect username or password"); Dialogs.showAlertDialog(context, "Login Failed", "Incorrect username or password");
}else{ }else{
Dialogs.showAlertDialog(context, "Login Failed", "Error code : $loginResult"); Dialogs.showAlertDialog(context, "Login Failed", "Error code : $loginResult");
} }
}else{ }else{
int regResult = await LoginManager.Register(usernameController.text, passwordController.text); int regResult = await LoginManager.Register(usernameController.text, passwordController.text);
if(regResult == 0){ if(regResult == 0){
loadHome(); await DataManager.GetGamesProgress();
}else if(regResult == 5){ loadHome();
Dialogs.showAlertDialog(context, "Register Failed", "Username Already exists, Please try again with a different username"); }else if(regResult == 5){
}else{ Dialogs.showAlertDialog(context, "Register Failed", "Username Already exists, Please try again with a different username");
Dialogs.showAlertDialog(context, "Register Failed", "Error code : $regResult"); }else{
} Dialogs.showAlertDialog(context, "Register Failed", "Error code : $regResult");
} }
setState(() { }
loginLoading = false; setState(() {
}); loginLoading = false;
}, });
text: isLogin ? "Login" : "Register"), },
const SizedBox(height: 10,), child: isLogin ? Text("Login",style: TextStyle(fontSize: 18)) : Text("Register",style: TextStyle(fontSize: 18))),
InkWell( const SizedBox(height: 10,),
child: Text(isLogin InkWell(
? "Don't have an account? Register here" child: Text(isLogin
: "Already have an Account? Login here", ? "Don't have an account? Register here"
style: TextStyle(color: Colors.blue)), onTap: () { : "Already have an Account? Login here",
setState(() { style: TextStyle(color: Colors.blue)), onTap: () {
isLogin = !isLogin; setState(() {
}); isLogin = !isLogin;
},), });
},),]),
),
),
),
const Padding( const Padding(
padding: EdgeInsets.all(25.0), padding: EdgeInsets.all(25.0),
child: Center(child: Text("OR")), child: Center(child: Text("OR")),
), ),
Row( Row(
mainAxisAlignment: MainAxisAlignment.center, children: [ mainAxisAlignment: MainAxisAlignment.center, children: [
NeonButton(onPressed: () { GlassButton(onTap: () {
// Dialogs.showAlertDialog(context, "Test", "This is a test message"); // Dialogs.showAlertDialog(context, "Test", "This is a test message");
SignWithGoogle(); SignWithGoogle();
}, },
text: "Sign with Google", child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween,children: [Icon(Icons.g_mobiledata_rounded,size: 40), Text("Sign with Google",style:TextStyle(fontSize: 18)),Container()],),
colors: [Colors.green, Colors.teal], height: 50,
fontSize: 18, width: 250,
height: 45, color: Colors.greenAccent
heading: Icon(Icons.g_mobiledata, size: 40,)) )])
],)
])); ]));
} }