Challenges + Estimated Earnings

This commit is contained in:
Sewmina Dilshan 2023-05-24 17:14:54 +05:30
parent 4a17d7f8b0
commit cb8d1bb74c
87 changed files with 5197 additions and 4877 deletions

View File

@ -6,7 +6,7 @@ buildscript {
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:4.1.0' classpath 'com.android.tools.build:gradle:7.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
} }
} }
@ -26,6 +26,6 @@ subprojects {
project.evaluationDependsOn(':app') project.evaluationDependsOn(':app')
} }
task clean(type: Delete) { tasks.register("clean", Delete) {
delete rootProject.buildDir delete rootProject.buildDir
} }

View File

@ -1,3 +1,3 @@
org.gradle.jvmargs=-Xmx1536M org.gradle.jvmargs=-XX:MaxHeapSize=256m -Xmx1536M
android.useAndroidX=true android.useAndroidX=true
android.enableJetifier=true android.enableJetifier=true

View File

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip

View File

@ -5,10 +5,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: async name: async
sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0 sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.10.0" version: "2.11.0"
boolean_selector: boolean_selector:
dependency: transitive dependency: transitive
description: description:
@ -21,10 +21,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: characters name: characters
sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.2.1" version: "1.3.0"
clock: clock:
dependency: transitive dependency: transitive
description: description:
@ -37,10 +37,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: collection name: collection
sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0 sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.17.0" version: "1.17.1"
cupertino_icons: cupertino_icons:
dependency: "direct main" dependency: "direct main"
description: description:
@ -79,10 +79,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: js name: js
sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7" sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.6.5" version: "0.6.7"
lints: lints:
dependency: transitive dependency: transitive
description: description:
@ -95,10 +95,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: matcher name: matcher
sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72" sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.12.13" version: "0.12.15"
material_color_utilities: material_color_utilities:
dependency: transitive dependency: transitive
description: description:
@ -111,18 +111,18 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: meta name: meta
sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42" sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.8.0" version: "1.9.1"
path: path:
dependency: transitive dependency: transitive
description: description:
name: path name: path
sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.8.2" version: "1.8.3"
sky_engine: sky_engine:
dependency: transitive dependency: transitive
description: flutter description: flutter
@ -172,10 +172,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: test_api name: test_api
sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206 sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.4.16" version: "0.5.1"
vector_math: vector_math:
dependency: transitive dependency: transitive
description: description:
@ -185,4 +185,4 @@ packages:
source: hosted source: hosted
version: "2.1.4" version: "2.1.4"
sdks: sdks:
dart: ">=2.19.1 <3.0.0" dart: ">=3.0.0-0 <4.0.0"

View File

@ -33,8 +33,9 @@ class Brain{
NonLinkedGamesJson = []; NonLinkedGamesJson = [];
Debug.Log("Going to filter linked games from ${Hoarder.GamesJson.length} games\nmy linked game ids : ${UserJson['linkedGames']}"); Debug.Log("Going to filter linked games from ${Hoarder.GamesJson.length} games\nmy linked game ids : ${UserJson['linkedGames']}");
try {
List<Map<String, dynamic>> linkedGames = jsonDecode(UserJson['linkedGames']).cast<Map<String, dynamic>>(); List<Map<String, dynamic>> linkedGames = jsonDecode(
UserJson['linkedGames']).cast<Map<String, dynamic>>();
Hoarder.GamesJson.forEach((element) { Hoarder.GamesJson.forEach((element) {
bool foundLink = false; bool foundLink = false;
@ -51,11 +52,13 @@ class Brain{
if (!foundLink) { if (!foundLink) {
NonLinkedGamesJson.add(element); NonLinkedGamesJson.add(element);
} }
}); });
Debug.Log("Linked games count : ${linkedGames.length}");
Debug.Log("Linked games count : ${linkedGames.length}");
}catch(e){
NonLinkedGamesJson = Hoarder.GamesJson;
}
Hoarder.FetchChallenges(); Hoarder.FetchChallenges();
} }

View File

@ -45,4 +45,13 @@ class Helpers{
} }
} }
} }
static dynamic GetGameFromID(int id){
for (var value in Hoarder.GamesJson) {
Debug.Log(value);
if(id == value['id']){
return value;
}
}
}
} }

View File

@ -4,6 +4,8 @@ import 'package:faucethub/Backend/DebugHelper.dart';
import 'package:faucethub/Backend/brains.dart'; import 'package:faucethub/Backend/brains.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'helpers.dart';
class Hoarder{ class Hoarder{
static List<dynamic> GamesJson = []; static List<dynamic> GamesJson = [];
@ -53,11 +55,18 @@ class Hoarder{
FetchChallenges(); FetchChallenges();
} }
static double currentEarnings = 0;
static Map<String, int> ThisSeasonCryptoEarnings = {};
static Future<void> FetchChallenges() async { static Future<void> FetchChallenges() async {
var response = null; var response = null;
Challenges = []; List<List<dynamic>> _Challenges = [];
double _currentEarnings = 0;
Map<String,int> _ThisSeasonCryptoEarnings = {};
var cryptoValuesResponse = await http.get(Uri.parse('http://vps.playpoolstudios.com:2009/'));
dynamic cryptoValues = jsonDecode(cryptoValuesResponse.body.toString());
Debug.Log(cryptoValues);
for (var value in Brain.LinkedGamesJson) { for (var value in Brain.LinkedGamesJson) {
try { try {
Debug.Log("game_code : ${value['code']}, id: ${Brain.UserJson['id']}"); Debug.Log("game_code : ${value['code']}, id: ${Brain.UserJson['id']}");
@ -69,14 +78,39 @@ class Hoarder{
})); }));
Debug.Log("Challenges response: " +response.body.toString()); Debug.Log("Challenges response: " +response.body.toString());
List<dynamic> newChallenges = jsonDecode(response.body.toString()); List<dynamic> newChallenges = jsonDecode(response.body.toString());
Challenges.add(newChallenges);
dynamic GameJson = Helpers.GetGameFromCode(value['code']);
newChallenges.forEach((challengeJson) {
int total = int.parse(challengeJson['total']);
int current = int.parse(challengeJson['current']);
int reward = int.parse(challengeJson['reward']);
double rewardInDollars = double.parse(cryptoValues[GameJson['coin']]) * (0.00000001) * reward;
Debug.Log("Reward is $reward ~ \$$rewardInDollars");
if(total <= current){
_currentEarnings+= rewardInDollars;
// Debug.Log(_ThisSeasonCryptoEarnings[GameJson['coin']]);
_ThisSeasonCryptoEarnings.update(GameJson['coin'], (value) => value + reward, ifAbsent: ()=> reward);
// Debug.Log(_ThisSeasonCryptoEarnings[GameJson['coin']]);
}
});
_Challenges.add(newChallenges);
} catch (e) { } catch (e) {
Debug.LogError("Error while fetching challenges $e"); Debug.LogError("Error while fetching challenges $e");
} }
} }
ThisSeasonCryptoEarnings = _ThisSeasonCryptoEarnings;
Challenges = _Challenges;
currentEarnings = _currentEarnings;
Debug.Log(ThisSeasonCryptoEarnings);
// Debug.Log(Challenges); // Debug.Log(Challenges);
Debug.Log("Challenge, " + (Hoarder.Challenges[0][0]['game'])); // Debug.Log("Challenge, " + (Hoarder.Challenges[0][0]['game']));
} }

View File

@ -15,6 +15,12 @@ class LoginManager {
String username = ""; String username = "";
String password= ""; String password= "";
try{ try{
if(prefs.containsKey("googleLogin")){
if(prefs.getBool("googleLogin") ?? false){
}
}
username = prefs.getString("username")!; username = prefs.getString("username")!;
password = prefs.getString("password")!; password = prefs.getString("password")!;
}catch(e){ }catch(e){
@ -110,6 +116,7 @@ class LoginManager {
Debug.LogResponse(Brain.UserJson); Debug.LogResponse(Brain.UserJson);
prefs.setString("username", username); prefs.setString("username", username);
prefs.setString("password", username); prefs.setString("password", username);
prefs.setBool("googleLogin", true);
return 0; return 0;
}catch(e){ }catch(e){
return 5; return 5;

97
lib/game_page.dart Normal file
View File

@ -0,0 +1,97 @@
import 'package:external_app_launcher/external_app_launcher.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'Backend/DebugHelper.dart';
import 'Backend/brains.dart';
import 'Backend/helpers.dart';
class GamePage extends StatefulWidget {
const GamePage(this.id,{Key? key}) : super(key: key);
final String id;
@override
State<GamePage> createState() => _GamePageState();
}
class _GamePageState extends State<GamePage> {
@override
Widget build(BuildContext context) {
dynamic GameJson = Helpers.GetGameFromCode(widget.id);
Debug.Log("game for id : ${widget.id} -> $GameJson");
bool linked = Brain.LinkedGamesJson.contains(GameJson);
return SafeArea(child: Scaffold(
body: Container(
padding: EdgeInsets.all(15),
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
mainAxisSize: MainAxisSize.max,
children: [
InkWell(child: Icon(Icons.arrow_back,size: 40), onTap: (){Navigator.pop(context);},),
Column(
children: [
Text("${GameJson['name']}",style: TextStyle(fontSize: 25),),
Text((linked) ? "Linked" : "How to Link and EARN",style: TextStyle(fontSize: 12))
],
),
FaIcon(Helpers.GetIconForCrypto(GameJson['coin'])),
],
),
),
SizedBox(height: 50,),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
ClipRRect(
borderRadius: BorderRadius.circular(12),
child: Image.network(GameJson['icon'],
width: 100, height: 100),
),
Column(
children: [
Row(
children: [
// FaIcon(Helpers.GetIconForCrypto(GameJson['coin'])),
// SizedBox(width: 10,),
Text(GameJson['description'], style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold)),
],
),
SizedBox(height: 10,),
MaterialButton(onPressed: () async{
await LaunchApp.openApp(
androidPackageName: GameJson['link'],
// openStore: false
);
}, child: Row(
children: [
FaIcon(FontAwesomeIcons.googlePlay),
SizedBox(width: 15,),
Text("View on Playstore"),
],
),color: Colors.green,),
],
)
],
),
SizedBox(height: 50,),
(linked) ? Container(child: Text("This game is already linked to this FH account.\n\nYour Earnings from game will be accounted to this FH account"),) :Column(
children: [
Text("Your FH ID"),
Text(Brain.UserJson['id'], style: TextStyle(fontSize: 50, fontWeight: FontWeight.bold)),
SizedBox(height: 30,),
Text("Install this game from playstore and login with the same google account to Link the game to this FaucetHub Automatically.\n\nTo Link manually, Navigate to 'Link to FH' in game settings, Then Enter ${Brain.UserJson['id']} As FH ID.\n\n\n Then enjoy your earnings from playing this game!")
],
),
],
),
),
));
}
}

View File

@ -1,16 +1,16 @@
// import 'package:crypto_font_icons/crypto_font_icons.dart'; // import 'package:crypto_font_icons/crypto_font_icons.dart';
import 'package:crypto_font_icons/crypto_font_icons.dart'; import 'package:crypto_font_icons/crypto_font_icons.dart';
import 'package:device_apps/device_apps.dart'; import 'package:external_app_launcher/external_app_launcher.dart';
import 'package:faucethub/Backend/DebugHelper.dart'; import 'package:faucethub/Backend/DebugHelper.dart';
import 'package:faucethub/Backend/Dialogs.dart'; import 'package:faucethub/Backend/Dialogs.dart';
import 'package:faucethub/Backend/Encryptor.dart'; import 'package:faucethub/Backend/Encryptor.dart';
import 'package:faucethub/Backend/brains.dart'; import 'package:faucethub/Backend/brains.dart';
import 'package:faucethub/Backend/hoarder.dart'; import 'package:faucethub/Backend/hoarder.dart';
import 'package:faucethub/Backend/login_mgr.dart'; import 'package:faucethub/Backend/login_mgr.dart';
import 'package:faucethub/game_page.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:url_launcher/url_launcher.dart';
import 'Backend/helpers.dart'; import 'Backend/helpers.dart';
class HomePage extends StatefulWidget { class HomePage extends StatefulWidget {
@ -22,6 +22,7 @@ class HomePage extends StatefulWidget {
int selectedBotNavIndex = 0; int selectedBotNavIndex = 0;
String daysLeft = ""; String daysLeft = "";
class _HomePageState extends State<HomePage> { class _HomePageState extends State<HomePage> {
bool looping = false; bool looping = false;
@override @override
@ -36,13 +37,12 @@ class _HomePageState extends State<HomePage> {
while (looping) { while (looping) {
await Hoarder.FetchChallenges(); await Hoarder.FetchChallenges();
DateTime now = DateTime.now(); DateTime now = DateTime.now();
DateTime nextMonth = DateTime(now.year, now.month); DateTime nextMonth = DateTime(now.year, now.month);
daysLeft = "${nextMonth.difference(now).inDays} Days Remaining"; daysLeft = "${nextMonth.difference(now).inDays} Days Remaining";
setState(() { setState(() {});
});
await Future.delayed(const Duration(seconds: 30)); await Future.delayed(const Duration(seconds: 30));
} }
@ -67,43 +67,115 @@ class _HomePageState extends State<HomePage> {
child: Text("Welcome ${Brain.DisplayName},", child: Text("Welcome ${Brain.DisplayName},",
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold)), style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold)),
), ),
HomeCard( Card(
margin: EdgeInsets.all(12),
child: Container( child: Container(
padding: EdgeInsets.symmetric(vertical: 50), padding: EdgeInsets.all(10),
child: Text( child: Column(
"\$6.90", children: [
style: TextStyle(fontSize: 50), Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text("Earnings",
style: TextStyle(
fontSize: 20, fontWeight: FontWeight.bold)),
InkWell(child: Icon(Icons.arrow_forward_outlined,size:25), onTap: (){
selectedBotNavIndex=2;
setState(() {
});
},)
],
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
SizedBox(height: 20,),
Text("Previously Earned",
style: TextStyle(
fontSize: 25, fontWeight: FontWeight.bold)),
Text('\$0', style: TextStyle(fontSize: 20)),
SizedBox(height: 20,),
Text("This Seasons",
style: TextStyle(
fontSize: 25, fontWeight: FontWeight.bold)),
Text('~ \$${Hoarder.currentEarnings.toStringAsFixed(2)}', style: TextStyle(fontSize: 18))
],
), ),
), ),
title: "Earnings"), ],
),
),
),
// HomeCard(
// child: Container(
// padding: EdgeInsets.symmetric(vertical: 50),
// child: Column(
// mainAxisSize: MainAxisSize.max,
// mainAxisAlignment: MainAxisAlignment.spaceAround,
// children: [
// Text("Previously earned", style:TextStyle(fontSize: 25, fontWeight: FontWeight.bold)),
// Text('\$6.9'),
// Text("This Seasons'",style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold)),
// Text('\$2.3')
// ],
// )
// // child: Text(
// // "\$6.90",
// // style: TextStyle(fontSize: 50),
// // ),
// ),
// title: "Earnings"),
HomeCard( HomeCard(
title: "Seasonal Challenges - $daysLeft", title: "Seasonal Challenges $daysLeft",
child: Container( child: Container(
child: Column( child: Column(
children: [ children: [
(Hoarder.Challenges.length > 0)
ListView.builder( ? ListView.builder(
physics: NeverScrollableScrollPhysics(), physics: NeverScrollableScrollPhysics(),
shrinkWrap: true, shrinkWrap: true,
itemCount: Hoarder.Challenges.length, itemCount: Hoarder.Challenges.length,
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
dynamic gameJson = Helpers.GetGameFromCode(Hoarder.Challenges[index][0]['game'] ?? 'spaceio'); dynamic gameJson = Helpers.GetGameFromCode(
return ChallengesList(gameName: gameJson['name'], coin: gameJson['coin'], challengesInfo: [ Hoarder.Challenges[index][0]['game'] ??
'spaceio');
return ChallengesList(
gameName: gameJson['name'],
coin: gameJson['coin'],
challengesInfo: [
ListView.builder( ListView.builder(
physics: NeverScrollableScrollPhysics(), physics: NeverScrollableScrollPhysics(),
shrinkWrap: true, shrinkWrap: true,
itemCount: Hoarder.Challenges[index].length, itemCount:
itemBuilder: (BuildContext context, int index2) { Hoarder.Challenges[index].length,
return ChallengeProgress(Hoarder.Challenges[index][index2]['name'], int.parse(Hoarder.Challenges[index][index2]['total']), int.parse(Hoarder.Challenges[index][index2]['current']), int.parse(Hoarder.Challenges[index][index2]['reward'])); itemBuilder:
} (BuildContext context, int index2) {
) return ChallengeProgress(
Hoarder.Challenges[index][index2]
['name'],
int.parse(
Hoarder.Challenges[index]
[index2]['total']),
int.parse(
Hoarder.Challenges[index]
[index2]['current']),
int.parse(
Hoarder.Challenges[index]
[index2]['reward']));
})
]); ]);
} })
) : Container(
padding: EdgeInsets.all(30),
child: Text("Not linked to any games"))
], ],
), ),
) )),
),
// HomeCard( // HomeCard(
// title: "Featured Games", // title: "Featured Games",
// child: SizedBox( // child: SizedBox(
@ -143,15 +215,23 @@ class _HomePageState extends State<HomePage> {
); );
} }
Widget ChallengesList({required String gameName, required String coin, required List<Widget> challengesInfo}){ Widget ChallengesList(
{required String gameName,
required String coin,
required List<Widget> challengesInfo}) {
return Card( return Card(
color: Colors.black12, color: Colors.black12,
child: Container( child: Container(
padding: EdgeInsets.all(10), padding: EdgeInsets.all(10),
child: Column( child: Column(
children: [ children: [
Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisSize: MainAxisSize.max,children:[ Row(
Text(gameName, style:TextStyle(fontSize: 18, fontWeight: FontWeight.bold)), mainAxisAlignment: MainAxisAlignment.spaceBetween,
mainAxisSize: MainAxisSize.max,
children: [
Text(gameName,
style:
TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
Row( Row(
children: [ children: [
FaIcon(Helpers.GetIconForCrypto(coin)), FaIcon(Helpers.GetIconForCrypto(coin)),
@ -159,14 +239,15 @@ class _HomePageState extends State<HomePage> {
], ],
) )
]), ]),
SizedBox(height: 10,), SizedBox(
height: 10,
),
Container( Container(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: Column( child: Column(
children: challengesInfo, children: challengesInfo,
), ),
), ),
], ],
), ),
), ),
@ -184,21 +265,42 @@ class _HomePageState extends State<HomePage> {
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
mainAxisSize: MainAxisSize.max, mainAxisSize: MainAxisSize.max,
children: [ children: [
Text(title, textAlign: TextAlign.left,), Text(
Text("$reward Sats",style: TextStyle(fontWeight: FontWeight.bold,color: (total <= current) ? Colors.green : Colors.grey,fontSize: 15)) title,
textAlign: TextAlign.left,
),
Text("$reward Sats",
style: TextStyle(
fontWeight: FontWeight.bold,
color: (total <= current) ? Colors.green : Colors.grey,
fontSize: 15))
], ],
), ),
const SizedBox(height: 5,), const SizedBox(
height: 5,
),
Row( Row(
children: [ children: [
Expanded(child: LinearProgressIndicator(value: current/total, color: Colors.green,)), Expanded(
SizedBox(width:60,child: Text("$current / $total $prefix",textAlign: TextAlign.end,style:TextStyle(fontSize: 12,color: (total <= current) ? Colors.green : Colors.white))) child: LinearProgressIndicator(
value: current / total,
color: Colors.green,
)),
SizedBox(
width: 60,
child: Text("$current / $total $prefix",
textAlign: TextAlign.end,
style: TextStyle(
fontSize: 12,
color: (total <= current)
? Colors.green
: Colors.white)))
], ],
), ),
const SizedBox(height: 12,), const SizedBox(
height: 12,
]
), ),
]),
); );
} }
@ -211,6 +313,11 @@ class _HomePageState extends State<HomePage> {
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Container(
alignment: Alignment.center,
padding: EdgeInsets.fromLTRB(0, 0, 0, 20),
child: Text("FH ID : ${Brain.UserJson['id']}"),
),
Text( Text(
"Linked", "Linked",
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold), style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
@ -226,17 +333,30 @@ class _HomePageState extends State<HomePage> {
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
// Debug.Log(Hoarder.LinkedGamesJson[index]); // Debug.Log(Hoarder.LinkedGamesJson[index]);
return InkWell( return InkWell(
onTap: () { onTap: () async {
showLinkGameDialog(context, Brain.LinkedGamesJson[index]); // showLinkGameDialog(context, Brain.LinkedGamesJson[index]);
// await LaunchApp.openApp(
// androidPackageName: Brain.LinkedGamesJson[index]['link'],
// // openStore: false
// );
String code = Brain.LinkedGamesJson[index]['code'];
Navigator.push(
context,
MaterialPageRoute(builder: (context) => GamePage(code)),
);
}, },
child: ListTile( child: ListTile(
leading: ClipRRect( leading: ClipRRect(
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(12),
child: Image.network(Brain.LinkedGamesJson[index]['icon'], child: Image.network(
width: 50, height: 50), Brain.LinkedGamesJson[index]['icon'],
width: 50,
height: 50),
), ),
title: Text(Brain.LinkedGamesJson[index]['name']), title: Text(Brain.LinkedGamesJson[index]['name']),
subtitle: Text(Brain.LinkedGamesJson[index]['description']), subtitle:
Text(Brain.LinkedGamesJson[index]['description']),
trailing: Row( trailing: Row(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
@ -248,7 +368,7 @@ class _HomePageState extends State<HomePage> {
SizedBox( SizedBox(
width: 2, width: 2,
), ),
Text("0.00004000"), // Text("0.00004000"),
], ],
), ),
), ),
@ -271,30 +391,49 @@ class _HomePageState extends State<HomePage> {
itemCount: Brain.NonLinkedGamesJson.length, itemCount: Brain.NonLinkedGamesJson.length,
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
// Debug.Log(Hoarder.NonLinkedGamesJson[index]); // Debug.Log(Hoarder.NonLinkedGamesJson[index]);
String code = Brain.NonLinkedGamesJson[index]['code'];
return InkWell( return InkWell(
onTap: () async { onTap: () async {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => GamePage(code)),
);
// showLinkGameDialog(context, Brain.NonLinkedGamesJson[index]); // showLinkGameDialog(context, Brain.NonLinkedGamesJson[index]);
try { // try {
///checks if the app is installed on your mobile device // ///checks if the app is installed on your mobile device
bool isInstalled = await DeviceApps.isAppInstalled('si.modula.android.instantheartrate'); // String id = Brain.NonLinkedGamesJson[index]['link'];
if (isInstalled) { // Debug.Log(id);
DeviceApps.openApp("si.modula.android.instantheartrate"); // bool isInstalled = await DeviceApps.isAppInstalled(id);
} else { // if (isInstalled) {
///if the app is not installed it lunches google play store so you can install it from there // DeviceApps.openApp(id);
launch("market://details?id=" +"si.modula.android.instantheartrate"); // } else {
} // ///if the app is not installed it lunches google play store so you can install it from there
} catch (e) { // // launchUrl(Uri(path: "market://details?id=" +Brain.NonLinkedGamesJson[index]['link']),mode: LaunchMode.externalApplication,);
print(e); // // try{launch("market://details?id=" +Brain.NonLinkedGamesJson[index]['link']);}catch(e){
} // launch("https://play.google.com/store/apps/details?id=$id");
// // }
// }
// } catch (e) {
// print(e);
// }
}, },
child: ListTile( child: ListTile(
leading: ClipRRect( leading: ClipRRect(
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(12),
child: Image.network(Brain.NonLinkedGamesJson[index]['icon'], child: Image.network(
width: 50, height: 50), Brain.NonLinkedGamesJson[index]['icon'],
width: 50,
height: 50),
), ),
title: Text(Brain.NonLinkedGamesJson[index]['name']), title: Text(Brain.NonLinkedGamesJson[index]['name']),
subtitle: Text(Brain.NonLinkedGamesJson[index]['description']), subtitle:
Text(Brain.NonLinkedGamesJson[index]['description']),
trailing: Icon(
Helpers.GetIconForCrypto(
Brain.NonLinkedGamesJson[index]['coin']),
size: 17,
),
), ),
); );
}) })
@ -308,31 +447,60 @@ class _HomePageState extends State<HomePage> {
final ScrollController scrollController = ScrollController(); final ScrollController scrollController = ScrollController();
return Container( return Container(
padding: EdgeInsets.all(10), padding: EdgeInsets.all(10),
child: child: Container(
Container( child: Column(children: [ child: Column(
HomeCard(child: Container( children: [
HomeCard(
child: Container(
child: ListTile( child: ListTile(
leading: FaIcon(FontAwesomeIcons.solidCircleUser,size: 60,), leading: FaIcon(
FontAwesomeIcons.solidCircleUser,
size: 60,
),
title: Text(Brain.Username), title: Text(Brain.Username),
subtitle: Text("Total Earnings : \$42.69"), subtitle: Text("Total Earnings : \$42.69"),
trailing: IconButton(icon: Icon(Icons.settings), onPressed: () { selectedBotNavIndex=3;setState(() { trailing: IconButton(
icon: Icon(Icons.settings),
}); },), onPressed: () {
) selectedBotNavIndex = 3;
), title: "Your Account", showMore: false), setState(() {});
Row(mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.max,children: [ },
Expanded(child: MaterialButton(onPressed: (){}, child: Text("Withdraw"),color: Colors.green, )) ),
],), )),
SizedBox(height: 30,), title: "Your Account",
Text("Sort by",style: TextStyle(fontSize: 12),), showMore: false),
DefaultTabController(length: 2, child: Column( Row(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
children: [
Expanded(
child: MaterialButton(
onPressed: () {},
child: Text("Withdraw"),
color: Colors.green,
))
],
),
SizedBox(
height: 30,
),
Text(
"Sort by",
style: TextStyle(fontSize: 12),
),
DefaultTabController(
length: 2,
child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
TabBar(tabs: [
TabBar( Tab(
tabs:[Tab(text: "Currency",),Tab(text: "Games",)] text: "Currency",
), ),
Tab(
text: "Games",
)
]),
Container( Container(
padding: EdgeInsets.all(10), padding: EdgeInsets.all(10),
//Add this to give height //Add this to give height
@ -340,44 +508,50 @@ class _HomePageState extends State<HomePage> {
child: TabBarView(children: [ child: TabBarView(children: [
Container( Container(
child: Column( child: Column(
children: [ children: [
CurrencyListItem("BTC", "0.0004000 = \$1.20"), CurrencyListItem("BTC", "0.0004000 = \$1.20"),
CurrencyListItem("ETH", "0.0004000 = \$0.50"), CurrencyListItem("ETH", "0.0004000 = \$0.50"),
CurrencyListItem("XRP", "0.0004000 = \$0.20"), CurrencyListItem("XRP", "0.0004000 = \$0.20"),
CurrencyListItem("DOGE", "0.0004000 = \$0.020") CurrencyListItem("DOGE", "0.0004000 = \$0.020")
], ],
) )),
),
Container( Container(
child: Column( child: Column(
children: [ children: [
GameListItem(Hoarder.GamesJson[0], "0.0004000 = \$1.20"), GameListItem(
GameListItem(Hoarder.GamesJson[1], "0.0004000 = \$1.20"), Hoarder.GamesJson[0], "0.0004000 = \$1.20"),
GameListItem(Hoarder.GamesJson[2], "0.0004000 = \$1.20"), GameListItem(
Hoarder.GamesJson[1], "0.0004000 = \$1.20"),
GameListItem(
Hoarder.GamesJson[2], "0.0004000 = \$1.20"),
], ],
) )),
),
]), ]),
), ),
], ],
)) ))
],))); ],
)));
} }
Widget SettingsWidget() { Widget SettingsWidget() {
final ScrollController scrollController = ScrollController(); final ScrollController scrollController = ScrollController();
return Container( return Container(
padding: EdgeInsets.symmetric(vertical: 20, horizontal: 10), padding: EdgeInsets.symmetric(vertical: 20, horizontal: 10),
child: child: SingleChildScrollView(
SingleChildScrollView(physics: ScrollPhysics(), child: Column(children: [ physics: ScrollPhysics(),
Text("Settings", style: TextStyle(fontSize: 25,fontWeight: FontWeight.bold),), child: Column(
SizedBox(height: 20,), children: [
Text(
"Settings",
style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold),
),
SizedBox(
height: 20,
),
ListTile() ListTile()
],))); ],
)));
} }
@override @override
@ -433,10 +607,12 @@ class _HomePageState extends State<HomePage> {
style: TextStyle( style: TextStyle(
fontSize: 17, fontWeight: FontWeight.bold), fontSize: 17, fontWeight: FontWeight.bold),
), ),
(showMore) ? InkWell( (showMore)
? InkWell(
child: Icon(Icons.arrow_right_alt), child: Icon(Icons.arrow_right_alt),
onTap: () {}, onTap: () {},
) : Container() )
: Container()
], ],
), ),
), ),
@ -445,22 +621,48 @@ class _HomePageState extends State<HomePage> {
} }
Widget CurrencyListItem(String currencyName, String value) { Widget CurrencyListItem(String currencyName, String value) {
return Container(padding: EdgeInsets.all(5), return Container(
child: Row(mainAxisSize: MainAxisSize.max,mainAxisAlignment: MainAxisAlignment.spaceBetween, padding: EdgeInsets.all(5),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Row(mainAxisSize: MainAxisSize.min, children: [Icon(Helpers.GetIconForCrypto(currencyName)),SizedBox(width: 10,), Text(currencyName)],), Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Helpers.GetIconForCrypto(currencyName)),
SizedBox(
width: 10,
),
Text(currencyName)
],
),
Text(value) Text(value)
],), ],
),
); );
} }
Widget GameListItem(dynamic Game, String value) { Widget GameListItem(dynamic Game, String value) {
return Container(padding: EdgeInsets.all(5), return Container(
child: Row(mainAxisSize: MainAxisSize.max,mainAxisAlignment: MainAxisAlignment.spaceBetween, padding: EdgeInsets.all(5),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Row(mainAxisSize: MainAxisSize.min, children: [ Icon(Helpers.GetIconForCrypto(Game['coin'])),SizedBox(width: 10,), Text(Game['name'])],), Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Helpers.GetIconForCrypto(Game['coin'])),
SizedBox(
width: 10,
),
Text(Game['name'])
],
),
Text(value) Text(value)
],), ],
),
); );
} }
@ -468,6 +670,7 @@ class _HomePageState extends State<HomePage> {
selectedBotNavIndex = value; selectedBotNavIndex = value;
setState(() {}); setState(() {});
} }
TextEditingController manualLinkInput = TextEditingController(); TextEditingController manualLinkInput = TextEditingController();
void showLinkGameDialog(BuildContext context, dynamic Game) { void showLinkGameDialog(BuildContext context, dynamic Game) {
Debug.Log("Showing custom dialog"); Debug.Log("Showing custom dialog");
@ -480,31 +683,41 @@ class _HomePageState extends State<HomePage> {
content: Column( content: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
Text("Enter user id in-game to Link this game to the Faucet Hub"), Text(
TextField(controller: manualLinkInput, "Enter user id in-game to Link this game to the Faucet Hub"),
decoration: InputDecoration( TextField(
hintText: 'User ID' controller: manualLinkInput,
)) decoration: InputDecoration(hintText: 'User ID'))
], ],
), ),
actions: [ actions: [
TextButton(child:Text("Link"), onPressed: (){ TextButton(
child: Text("Link"),
onPressed: () {
String input = manualLinkInput.text; String input = manualLinkInput.text;
manualLinkInput.clear(); manualLinkInput.clear();
if (input.length < 2) { if (input.length < 2) {
Dialogs.showAlertDialog(context, "Failed", "Invalid User ID"); Dialogs.showAlertDialog(
context, "Failed", "Invalid User ID");
return; return;
} }
int userId = Encryptor.stringToInt(input); int userId = Encryptor.stringToInt(input);
if(userId < 0){ return;} if (userId < 0) {
return;
}
print("Init link to id $userId"); print("Init link to id $userId");
},), },
TextButton(child:Text("Cancel"), onPressed: (){ manualLinkInput.clear(); Navigator.of(context).pop(); },) ),
] TextButton(
); child: Text("Cancel"),
} onPressed: () {
); manualLinkInput.clear();
Navigator.of(context).pop();
},
)
]);
});
} }
} }

View File

@ -6,6 +6,7 @@ import 'package:faucethub/Backend/googleSignIn.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:google_sign_in/google_sign_in.dart'; import 'package:google_sign_in/google_sign_in.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
class LoginPage extends StatefulWidget { class LoginPage extends StatefulWidget {
const LoginPage({Key? key}) : super(key: key); const LoginPage({Key? key}) : super(key: key);
@ -38,6 +39,26 @@ class _LoginPageState extends State<LoginPage> {
); );
@override
void initState() {
// TODO: implement initState
super.initState();
autoLogin();
}
void autoLogin() async{
final prefs = await SharedPreferences.getInstance();
try{
if(prefs.getBool("googleLogin") ?? false){
SignWithGoogle();
}
}catch(e){
}
}
Widget LoginCard(){ Widget LoginCard(){
return Container( return Container(
padding: EdgeInsets.symmetric(vertical: 20, horizontal: 50), padding: EdgeInsets.symmetric(vertical: 20, horizontal: 50),

View File

@ -13,10 +13,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: async name: async
sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0 sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.10.0" version: "2.11.0"
boolean_selector: boolean_selector:
dependency: transitive dependency: transitive
description: description:
@ -29,10 +29,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: characters name: characters
sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.2.1" version: "1.3.0"
clock: clock:
dependency: transitive dependency: transitive
description: description:
@ -45,10 +45,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: collection name: collection
sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0 sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.17.0" version: "1.17.1"
crypto_font_icons: crypto_font_icons:
dependency: "direct main" dependency: "direct main"
description: description:
@ -65,14 +65,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.0.5" version: "1.0.5"
device_apps: external_app_launcher:
dependency: "direct main" dependency: "direct main"
description: description:
name: device_apps name: external_app_launcher
sha256: e84dc74d55749993fd671148cc0bd53096e1be0c268fc364285511b1d8a4c19b sha256: fb55cddd706c62ede11056750d5e018ef379820e09739e967873211dd537d833
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.2.0" version: "3.1.0"
fake_async: fake_async:
dependency: transitive dependency: transitive
description: description:
@ -252,10 +252,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: js name: js
sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7" sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.6.5" version: "0.6.7"
lints: lints:
dependency: transitive dependency: transitive
description: description:
@ -268,10 +268,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: matcher name: matcher
sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72" sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.12.13" version: "0.12.15"
material_color_utilities: material_color_utilities:
dependency: transitive dependency: transitive
description: description:
@ -284,10 +284,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: meta name: meta
sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42" sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.8.0" version: "1.9.1"
nested: nested:
dependency: transitive dependency: transitive
description: description:
@ -300,10 +300,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: path name: path
sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.8.2" version: "1.8.3"
path_provider_linux: path_provider_linux:
dependency: transitive dependency: transitive
description: description:
@ -489,10 +489,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: test_api name: test_api
sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206 sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.4.16" version: "0.5.1"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description:
@ -501,70 +501,6 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.3.0" version: "1.3.0"
url_launcher:
dependency: "direct main"
description:
name: url_launcher
sha256: eb1e00ab44303d50dd487aab67ebc575456c146c6af44422f9c13889984c00f3
url: "https://pub.dev"
source: hosted
version: "6.1.11"
url_launcher_android:
dependency: transitive
description:
name: url_launcher_android
sha256: "1a5848f598acc5b7d8f7c18b8cb834ab667e59a13edc3c93e9d09cf38cc6bc87"
url: "https://pub.dev"
source: hosted
version: "6.0.34"
url_launcher_ios:
dependency: transitive
description:
name: url_launcher_ios
sha256: "9af7ea73259886b92199f9e42c116072f05ff9bea2dcb339ab935dfc957392c2"
url: "https://pub.dev"
source: hosted
version: "6.1.4"
url_launcher_linux:
dependency: transitive
description:
name: url_launcher_linux
sha256: "207f4ddda99b95b4d4868320a352d374b0b7e05eefad95a4a26f57da413443f5"
url: "https://pub.dev"
source: hosted
version: "3.0.5"
url_launcher_macos:
dependency: transitive
description:
name: url_launcher_macos
sha256: "91ee3e75ea9dadf38036200c5d3743518f4a5eb77a8d13fda1ee5764373f185e"
url: "https://pub.dev"
source: hosted
version: "3.0.5"
url_launcher_platform_interface:
dependency: transitive
description:
name: url_launcher_platform_interface
sha256: "6c9ca697a5ae218ce56cece69d46128169a58aa8653c1b01d26fcd4aad8c4370"
url: "https://pub.dev"
source: hosted
version: "2.1.2"
url_launcher_web:
dependency: transitive
description:
name: url_launcher_web
sha256: "81fe91b6c4f84f222d186a9d23c73157dc4c8e1c71489c4d08be1ad3b228f1aa"
url: "https://pub.dev"
source: hosted
version: "2.0.16"
url_launcher_windows:
dependency: transitive
description:
name: url_launcher_windows
sha256: "254708f17f7c20a9c8c471f67d86d76d4a3f9c1591aad1e15292008aceb82771"
url: "https://pub.dev"
source: hosted
version: "3.0.6"
vector_math: vector_math:
dependency: transitive dependency: transitive
description: description:
@ -590,5 +526,5 @@ packages:
source: hosted source: hosted
version: "0.2.0+3" version: "0.2.0+3"
sdks: sdks:
dart: ">=2.18.0 <3.0.0" dart: ">=3.0.0-0 <4.0.0"
flutter: ">=3.3.0" flutter: ">=3.0.0"

View File

@ -21,8 +21,8 @@ dependencies:
font_awesome_flutter: ^10.3.0 font_awesome_flutter: ^10.3.0
crypto_font_icons: ^1.0.1 crypto_font_icons: ^1.0.1
syncfusion_flutter_charts: ^20.4.49 syncfusion_flutter_charts: ^20.4.49
url_launcher: ^6.1.11 external_app_launcher: ^3.1.0
device_apps: ^2.1.1
# The following adds the Cupertino Icons font to your application. # The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons. # Use with the CupertinoIcons class for iOS style icons.