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 {
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"
}
}
@ -26,6 +26,6 @@ subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
tasks.register("clean", Delete) {
delete rootProject.buildDir
}

View File

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

View File

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

View File

@ -33,29 +33,32 @@ class Brain{
NonLinkedGamesJson = [];
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) {
bool foundLink = false;
for (var linkedGame in linkedGames) {
int gid = linkedGame["game_id"];
int id = int.parse(element['id']);
if(gid == id){
LinkedGamesJson.add(element);
foundLink = true;
break;
Hoarder.GamesJson.forEach((element) {
bool foundLink = false;
for (var linkedGame in linkedGames) {
int gid = linkedGame["game_id"];
int id = int.parse(element['id']);
if (gid == id) {
LinkedGamesJson.add(element);
foundLink = true;
break;
}
}
}
if(!foundLink){
NonLinkedGamesJson.add(element);
}
if (!foundLink) {
NonLinkedGamesJson.add(element);
}
});
});
Debug.Log("Linked games count : ${linkedGames.length}");
}catch(e){
NonLinkedGamesJson = Hoarder.GamesJson;
}
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:http/http.dart' as http;
import 'helpers.dart';
class Hoarder{
static List<dynamic> GamesJson = [];
@ -53,11 +55,18 @@ class Hoarder{
FetchChallenges();
}
static double currentEarnings = 0;
static Map<String, int> ThisSeasonCryptoEarnings = {};
static Future<void> FetchChallenges() async {
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) {
try {
Debug.Log("game_code : ${value['code']}, id: ${Brain.UserJson['id']}");
@ -69,14 +78,39 @@ class Hoarder{
}));
Debug.Log("Challenges response: " +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) {
Debug.LogError("Error while fetching challenges $e");
}
}
ThisSeasonCryptoEarnings = _ThisSeasonCryptoEarnings;
Challenges = _Challenges;
currentEarnings = _currentEarnings;
Debug.Log(ThisSeasonCryptoEarnings);
// 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 password= "";
try{
if(prefs.containsKey("googleLogin")){
if(prefs.getBool("googleLogin") ?? false){
}
}
username = prefs.getString("username")!;
password = prefs.getString("password")!;
}catch(e){
@ -110,6 +116,7 @@ class LoginManager {
Debug.LogResponse(Brain.UserJson);
prefs.setString("username", username);
prefs.setString("password", username);
prefs.setBool("googleLogin", true);
return 0;
}catch(e){
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:device_apps/device_apps.dart';
import 'package:external_app_launcher/external_app_launcher.dart';
import 'package:faucethub/Backend/DebugHelper.dart';
import 'package:faucethub/Backend/Dialogs.dart';
import 'package:faucethub/Backend/Encryptor.dart';
import 'package:faucethub/Backend/brains.dart';
import 'package:faucethub/Backend/hoarder.dart';
import 'package:faucethub/Backend/login_mgr.dart';
import 'package:faucethub/game_page.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:url_launcher/url_launcher.dart';
import 'Backend/helpers.dart';
class HomePage extends StatefulWidget {
@ -22,8 +22,9 @@ class HomePage extends StatefulWidget {
int selectedBotNavIndex = 0;
String daysLeft = "";
class _HomePageState extends State<HomePage> {
bool looping =false;
bool looping = false;
@override
void initState() {
// TODO: implement initState
@ -31,18 +32,17 @@ class _HomePageState extends State<HomePage> {
loop();
}
void loop() async{
looping=true;
void loop() async {
looping = true;
while(looping){
while (looping) {
await Hoarder.FetchChallenges();
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";
setState(() {
});
setState(() {});
await Future.delayed(const Duration(seconds: 30));
}
@ -53,7 +53,7 @@ class _HomePageState extends State<HomePage> {
// TODO: implement dispose
super.dispose();
looping=false;
looping = false;
}
Widget HomeWidget() {
@ -67,44 +67,116 @@ class _HomePageState extends State<HomePage> {
child: Text("Welcome ${Brain.DisplayName},",
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold)),
),
HomeCard(
child: Container(
padding: EdgeInsets.symmetric(vertical: 50),
child: Text(
"\$6.90",
style: TextStyle(fontSize: 50),
),
),
title: "Earnings"),
HomeCard(
title: "Seasonal Challenges - $daysLeft",
Card(
margin: EdgeInsets.all(12),
child: Container(
padding: EdgeInsets.all(10),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text("Earnings",
style: TextStyle(
fontSize: 20, fontWeight: FontWeight.bold)),
ListView.builder(
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: Hoarder.Challenges.length,
itemBuilder: (BuildContext context, int index) {
dynamic gameJson = Helpers.GetGameFromCode(Hoarder.Challenges[index][0]['game'] ?? 'spaceio');
return ChallengesList(gameName: gameJson['name'], coin: gameJson['coin'], challengesInfo: [
ListView.builder(
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: Hoarder.Challenges[index].length,
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']));
}
)
]);
}
)
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))
],
),
),
],
),
)
),
),
// 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(
title: "Seasonal Challenges $daysLeft",
child: Container(
child: Column(
children: [
(Hoarder.Challenges.length > 0)
? ListView.builder(
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: Hoarder.Challenges.length,
itemBuilder: (BuildContext context, int index) {
dynamic gameJson = Helpers.GetGameFromCode(
Hoarder.Challenges[index][0]['game'] ??
'spaceio');
return ChallengesList(
gameName: gameJson['name'],
coin: gameJson['coin'],
challengesInfo: [
ListView.builder(
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount:
Hoarder.Challenges[index].length,
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(
// title: "Featured Games",
// child: SizedBox(
// height: 110,
@ -143,30 +215,39 @@ 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(
color: Colors.black12,
child: Container(
padding: EdgeInsets.all(10),
child: Column(
children: [
Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisSize: MainAxisSize.max,children:[
Text(gameName, style:TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
Row(
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
mainAxisSize: MainAxisSize.max,
children: [
FaIcon(Helpers.GetIconForCrypto(coin)),
Text(" $coin"),
],
)
]),
SizedBox(height: 10,),
Text(gameName,
style:
TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
Row(
children: [
FaIcon(Helpers.GetIconForCrypto(coin)),
Text(" $coin"),
],
)
]),
SizedBox(
height: 10,
),
Container(
padding: const EdgeInsets.all(8.0),
child: Column(
children: challengesInfo,
),
),
],
),
),
@ -174,31 +255,52 @@ class _HomePageState extends State<HomePage> {
}
Widget ChallengeProgress(String title, int total, int current, int reward,
{String prefix = ""}){
{String prefix = ""}) {
return Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
mainAxisSize: MainAxisSize.max,
children: [
Text(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,),
Row(
children: [
Expanded(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,),
]
),
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
mainAxisSize: MainAxisSize.max,
children: [
Text(
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,
),
Row(
children: [
Expanded(
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,
),
]),
);
}
@ -211,6 +313,11 @@ class _HomePageState extends State<HomePage> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
alignment: Alignment.center,
padding: EdgeInsets.fromLTRB(0, 0, 0, 20),
child: Text("FH ID : ${Brain.UserJson['id']}"),
),
Text(
"Linked",
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
@ -226,17 +333,30 @@ class _HomePageState extends State<HomePage> {
itemBuilder: (BuildContext context, int index) {
// Debug.Log(Hoarder.LinkedGamesJson[index]);
return InkWell(
onTap: () {
showLinkGameDialog(context, Brain.LinkedGamesJson[index]);
onTap: () async {
// 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(
leading: ClipRRect(
borderRadius: BorderRadius.circular(12),
child: Image.network(Brain.LinkedGamesJson[index]['icon'],
width: 50, height: 50),
child: Image.network(
Brain.LinkedGamesJson[index]['icon'],
width: 50,
height: 50),
),
title: Text(Brain.LinkedGamesJson[index]['name']),
subtitle: Text(Brain.LinkedGamesJson[index]['description']),
subtitle:
Text(Brain.LinkedGamesJson[index]['description']),
trailing: Row(
mainAxisSize: MainAxisSize.min,
children: [
@ -248,7 +368,7 @@ class _HomePageState extends State<HomePage> {
SizedBox(
width: 2,
),
Text("0.00004000"),
// Text("0.00004000"),
],
),
),
@ -271,30 +391,49 @@ class _HomePageState extends State<HomePage> {
itemCount: Brain.NonLinkedGamesJson.length,
itemBuilder: (BuildContext context, int index) {
// Debug.Log(Hoarder.NonLinkedGamesJson[index]);
String code = Brain.NonLinkedGamesJson[index]['code'];
return InkWell(
onTap: () async{
onTap: () async {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => GamePage(code)),
);
// showLinkGameDialog(context, Brain.NonLinkedGamesJson[index]);
try {
///checks if the app is installed on your mobile device
bool isInstalled = await DeviceApps.isAppInstalled('si.modula.android.instantheartrate');
if (isInstalled) {
DeviceApps.openApp("si.modula.android.instantheartrate");
} else {
///if the app is not installed it lunches google play store so you can install it from there
launch("market://details?id=" +"si.modula.android.instantheartrate");
}
} catch (e) {
print(e);
}
// try {
// ///checks if the app is installed on your mobile device
// String id = Brain.NonLinkedGamesJson[index]['link'];
// Debug.Log(id);
// bool isInstalled = await DeviceApps.isAppInstalled(id);
// if (isInstalled) {
// DeviceApps.openApp(id);
// } else {
// ///if the app is not installed it lunches google play store so you can install it from there
// // launchUrl(Uri(path: "market://details?id=" +Brain.NonLinkedGamesJson[index]['link']),mode: LaunchMode.externalApplication,);
// // 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(
leading: ClipRRect(
borderRadius: BorderRadius.circular(12),
child: Image.network(Brain.NonLinkedGamesJson[index]['icon'],
width: 50, height: 50),
child: Image.network(
Brain.NonLinkedGamesJson[index]['icon'],
width: 50,
height: 50),
),
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,76 +447,111 @@ class _HomePageState extends State<HomePage> {
final ScrollController scrollController = ScrollController();
return Container(
padding: EdgeInsets.all(10),
child:
Container( child: Column(children: [
HomeCard(child: Container(
child: ListTile(
leading: FaIcon(FontAwesomeIcons.solidCircleUser,size: 60,),
child: Container(
child: Column(
children: [
HomeCard(
child: Container(
child: ListTile(
leading: FaIcon(
FontAwesomeIcons.solidCircleUser,
size: 60,
),
title: Text(Brain.Username),
subtitle: Text("Total Earnings : \$42.69"),
trailing: IconButton(icon: Icon(Icons.settings), onPressed: () { selectedBotNavIndex=3;setState(() {
}); },),
)
), title: "Your Account", showMore: false),
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,
children: [
TabBar(
tabs:[Tab(text: "Currency",),Tab(text: "Games",)]
trailing: IconButton(
icon: Icon(Icons.settings),
onPressed: () {
selectedBotNavIndex = 3;
setState(() {});
},
),
Container(
padding: EdgeInsets.all(10),
//Add this to give height
constraints: BoxConstraints.expand(height: 250),
child: TabBarView(children: [
Container(
child: Column(
)),
title: "Your Account",
showMore: false),
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,
children: [
TabBar(tabs: [
Tab(
text: "Currency",
),
Tab(
text: "Games",
)
]),
Container(
padding: EdgeInsets.all(10),
//Add this to give height
constraints: BoxConstraints.expand(height: 250),
child: TabBarView(children: [
Container(
child: Column(
children: [
CurrencyListItem("BTC", "0.0004000 = \$1.20"),
CurrencyListItem("ETH", "0.0004000 = \$0.50"),
CurrencyListItem("XRP", "0.0004000 = \$0.20"),
CurrencyListItem("DOGE", "0.0004000 = \$0.020")
],
)
),
Container(
child: Column(
)),
Container(
child: Column(
children: [
GameListItem(Hoarder.GamesJson[0], "0.0004000 = \$1.20"),
GameListItem(Hoarder.GamesJson[1], "0.0004000 = \$1.20"),
GameListItem(Hoarder.GamesJson[2], "0.0004000 = \$1.20"),
GameListItem(
Hoarder.GamesJson[0], "0.0004000 = \$1.20"),
GameListItem(
Hoarder.GamesJson[1], "0.0004000 = \$1.20"),
GameListItem(
Hoarder.GamesJson[2], "0.0004000 = \$1.20"),
],
)
),
]),
),
],
))
],)));
)),
]),
),
],
))
],
)));
}
Widget SettingsWidget() {
final ScrollController scrollController = ScrollController();
return Container(
padding: EdgeInsets.symmetric(vertical: 20,horizontal: 10),
child:
SingleChildScrollView(physics: ScrollPhysics(), child: Column(children: [
Text("Settings", style: TextStyle(fontSize: 25,fontWeight: FontWeight.bold),),
SizedBox(height: 20,),
ListTile()
],)));
padding: EdgeInsets.symmetric(vertical: 20, horizontal: 10),
child: SingleChildScrollView(
physics: ScrollPhysics(),
child: Column(
children: [
Text(
"Settings",
style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold),
),
SizedBox(
height: 20,
),
ListTile()
],
)));
}
@override
@ -433,10 +607,12 @@ class _HomePageState extends State<HomePage> {
style: TextStyle(
fontSize: 17, fontWeight: FontWeight.bold),
),
(showMore) ? InkWell(
child: Icon(Icons.arrow_right_alt),
onTap: () {},
) : Container()
(showMore)
? InkWell(
child: Icon(Icons.arrow_right_alt),
onTap: () {},
)
: Container()
],
),
),
@ -444,23 +620,49 @@ class _HomePageState extends State<HomePage> {
]))));
}
Widget CurrencyListItem(String currencyName, String value){
return Container(padding: EdgeInsets.all(5),
child: Row(mainAxisSize: MainAxisSize.max,mainAxisAlignment: MainAxisAlignment.spaceBetween,
Widget CurrencyListItem(String currencyName, String value) {
return Container(
padding: EdgeInsets.all(5),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
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)
],),
],
),
);
}
Widget GameListItem(dynamic Game, String value){
return Container(padding: EdgeInsets.all(5),
child: Row(mainAxisSize: MainAxisSize.max,mainAxisAlignment: MainAxisAlignment.spaceBetween,
Widget GameListItem(dynamic Game, String value) {
return Container(
padding: EdgeInsets.all(5),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
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)
],),
],
),
);
}
@ -468,43 +670,54 @@ class _HomePageState extends State<HomePage> {
selectedBotNavIndex = value;
setState(() {});
}
TextEditingController manualLinkInput = TextEditingController();
void showLinkGameDialog(BuildContext context, dynamic Game) {
Debug.Log("Showing custom dialog");
showDialog(
context: context,
builder: (BuildContext context){
return AlertDialog(
title: Text("Link game - ${Game['name']}"),
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text("Enter user id in-game to Link this game to the Faucet Hub"),
TextField(controller: manualLinkInput,
decoration: InputDecoration(
hintText: 'User ID'
))
],
),
actions: [
TextButton(child:Text("Link"), onPressed: (){
String input = manualLinkInput.text;
manualLinkInput.clear();
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text("Link game - ${Game['name']}"),
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(
"Enter user id in-game to Link this game to the Faucet Hub"),
TextField(
controller: manualLinkInput,
decoration: InputDecoration(hintText: 'User ID'))
],
),
actions: [
TextButton(
child: Text("Link"),
onPressed: () {
String input = manualLinkInput.text;
manualLinkInput.clear();
if(input.length< 2){
Dialogs.showAlertDialog(context, "Failed", "Invalid User ID");
return;
}
int userId = Encryptor.stringToInt(input);
if(userId < 0){ return;}
if (input.length < 2) {
Dialogs.showAlertDialog(
context, "Failed", "Invalid User ID");
return;
}
int userId = Encryptor.stringToInt(input);
if (userId < 0) {
return;
}
print("Init link to id $userId");
},),
TextButton(child:Text("Cancel"), onPressed: (){ manualLinkInput.clear(); Navigator.of(context).pop(); },)
]
);
}
);
print("Init link to id $userId");
},
),
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:google_sign_in/google_sign_in.dart';
import 'package:provider/provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
class LoginPage extends StatefulWidget {
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(){
return Container(
padding: EdgeInsets.symmetric(vertical: 20, horizontal: 50),

View File

@ -13,10 +13,10 @@ packages:
dependency: transitive
description:
name: async
sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0
sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
url: "https://pub.dev"
source: hosted
version: "2.10.0"
version: "2.11.0"
boolean_selector:
dependency: transitive
description:
@ -29,10 +29,10 @@ packages:
dependency: transitive
description:
name: characters
sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c
sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605"
url: "https://pub.dev"
source: hosted
version: "1.2.1"
version: "1.3.0"
clock:
dependency: transitive
description:
@ -45,10 +45,10 @@ packages:
dependency: transitive
description:
name: collection
sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0
sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c"
url: "https://pub.dev"
source: hosted
version: "1.17.0"
version: "1.17.1"
crypto_font_icons:
dependency: "direct main"
description:
@ -65,14 +65,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.0.5"
device_apps:
external_app_launcher:
dependency: "direct main"
description:
name: device_apps
sha256: e84dc74d55749993fd671148cc0bd53096e1be0c268fc364285511b1d8a4c19b
name: external_app_launcher
sha256: fb55cddd706c62ede11056750d5e018ef379820e09739e967873211dd537d833
url: "https://pub.dev"
source: hosted
version: "2.2.0"
version: "3.1.0"
fake_async:
dependency: transitive
description:
@ -252,10 +252,10 @@ packages:
dependency: transitive
description:
name: js
sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7"
sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
url: "https://pub.dev"
source: hosted
version: "0.6.5"
version: "0.6.7"
lints:
dependency: transitive
description:
@ -268,10 +268,10 @@ packages:
dependency: transitive
description:
name: matcher
sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72"
sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb"
url: "https://pub.dev"
source: hosted
version: "0.12.13"
version: "0.12.15"
material_color_utilities:
dependency: transitive
description:
@ -284,10 +284,10 @@ packages:
dependency: transitive
description:
name: meta
sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42"
sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3"
url: "https://pub.dev"
source: hosted
version: "1.8.0"
version: "1.9.1"
nested:
dependency: transitive
description:
@ -300,10 +300,10 @@ packages:
dependency: transitive
description:
name: path
sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
url: "https://pub.dev"
source: hosted
version: "1.8.2"
version: "1.8.3"
path_provider_linux:
dependency: transitive
description:
@ -489,10 +489,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206
sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb
url: "https://pub.dev"
source: hosted
version: "0.4.16"
version: "0.5.1"
typed_data:
dependency: transitive
description:
@ -501,70 +501,6 @@ packages:
url: "https://pub.dev"
source: hosted
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:
dependency: transitive
description:
@ -590,5 +526,5 @@ packages:
source: hosted
version: "0.2.0+3"
sdks:
dart: ">=2.18.0 <3.0.0"
flutter: ">=3.3.0"
dart: ">=3.0.0-0 <4.0.0"
flutter: ">=3.0.0"

View File

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