This commit is contained in:
Sewmina Dilshan 2023-07-02 16:39:53 +05:30
parent f337e72476
commit 9bba037c66
3 changed files with 44 additions and 26 deletions

View File

@ -17,6 +17,18 @@ class DataManager{
static dynamic UserJson; static dynamic UserJson;
static dynamic cryptoRates;
static double currentEarnings =0;
static Map<String, int> GamesEarnings = {};
static Map<String, int> CryptoEarnings = {};
static void Reset(){
UserJson = LinkedGamesJson = NonLinkedGamesJson = Challenges = [];
currentEarnings = 0;
GamesEarnings = CryptoEarnings = {};
}
static Future<bool> Init() async{ static Future<bool> Init() async{
bool isSettingsDone = await GetSettings(); bool isSettingsDone = await GetSettings();
bool isGamesDone = await GetGames(); bool isGamesDone = await GetGames();
@ -43,9 +55,12 @@ class DataManager{
} }
static void FilterLinkedGames(){ static void FilterLinkedGames(){
Debug.Log("err044 : $UserJson");
LinkedGamesJson = []; LinkedGamesJson = [];
NonLinkedGamesJson = []; NonLinkedGamesJson = [];
if(UserJson['linkedGames'].toString().length < 3){ if (UserJson['linkedGames']
.toString()
.length < 3) {
NonLinkedGamesJson = AllGames; NonLinkedGamesJson = AllGames;
return; return;
} }
@ -68,6 +83,7 @@ class DataManager{
NonLinkedGamesJson.add(element); NonLinkedGamesJson.add(element);
} }
}); });
} }
static Future<bool> GetSettings() async{ static Future<bool> GetSettings() async{
@ -143,10 +159,7 @@ class DataManager{
Challenges = _Challenges; Challenges = _Challenges;
return true; return true;
} }
static dynamic cryptoRates;
static double currentEarnings =0;
static Map<String, int> GamesEarnings = {};
static Map<String, int> CryptoEarnings = {};
static void CalculateEarnings() async{ static void CalculateEarnings() async{
@ -215,4 +228,6 @@ class DataManager{
Debug.LogError(e); Debug.LogError(e);
} }
} }
} }

View File

@ -525,6 +525,7 @@ class _HomeState extends State<Home> {
Navigator.of(context).pushAndRemoveUntil(MaterialPageRoute(builder: (context) => Navigator.of(context).pushAndRemoveUntil(MaterialPageRoute(builder: (context) =>
MyHomePage()), (Route<dynamic> route) => false); MyHomePage()), (Route<dynamic> route) => false);
DataManager.Reset();
}, },
child: GlassCard(child: Padding( child: GlassCard(child: Padding(
padding: const EdgeInsets.all(15.0), padding: const EdgeInsets.all(15.0),

View File

@ -200,7 +200,9 @@ class _MyHomePageState extends State<MyHomePage> {
int regResult = await LoginManager.Register(usernameController.text, passwordController.text); int regResult = await LoginManager.Register(usernameController.text, passwordController.text);
if(regResult == 0){ if(regResult == 0){
await LoginManager.AutoLogin();
await DataManager.GetGamesProgress(); await DataManager.GetGamesProgress();
loadHome(); loadHome();
}else if(regResult == 5){ }else if(regResult == 5){
Dialogs.showAlertDialog(context, "Register Failed", "Username Already exists, Please try again with a different username"); Dialogs.showAlertDialog(context, "Register Failed", "Username Already exists, Please try again with a different username");