games = response.body.toString().split("");
- List featuredGames = Settings["featured_games"].toString().split(',');
- games.forEach((game) {
- dynamic Json = jsonDecode(game);
- String id = Json['id'];
- GamesJson.add(Json);
- print(Json);
-
- if(featuredGames.contains(id)){
- FeaturedGames.add(Json);
- }
- });
-
- Debug.Log("Total games ${GamesJson.length} and ${FeaturedGames.length} featured");
- } catch (e) {
- Debug.LogError("Error while loading games : $e");
- }
-
- FetchChallenges();
- }
-
- static Future FetchChallenges() async {
- var response = null;
-
- Challenges = [];
- for (var value in Brain.LinkedGamesJson) {
- try {
- Debug.Log("game_code : ${value['code']}, id: ${Brain.UserJson['id']}");
- response = (await http.post(
- Uri.parse('${Brain.API_ENDPOINT}get_challenges.php'),
- body: {
- "game_code": value['code'],
- "id": Brain.UserJson['id']
- }));
- Debug.Log("Challenges response: " +response.body.toString());
- List newChallenges = jsonDecode(response.body.toString());
- Challenges.add(newChallenges);
- } catch (e) {
- Debug.LogError("Error while fetching challenges $e");
- }
- }
-
- // Debug.Log(Challenges);
- Debug.Log("Challenge, " + (Hoarder.Challenges[0][0]['game']));
-
- }
-
- static Future GetGameProgress() async{
- // try {
- // var response = (await http.post(Uri.parse('${Brain.API_ENDPOINT}get_settings.php')));
- //
- // Debug.LogResponse(response.body.toString());
- // // Settings= jsonDecode(response.body.toString());
- // List jsonList = jsonDecode(response.body.toString());
- // jsonList.forEach((jsonItem) {
- // Settings[jsonItem['id']] = jsonItem['value'];
- // });
- //
- // } catch (e) {
- // Debug.LogError("Error while loading settings : $e");
- // }
- //
- // try {
- // var response = (await http.post(Uri.parse('${Brain.API_ENDPOINT}get_games.php')));
- //
- // Debug.LogResponse(response.body.toString());
- // GamesJson=[];
- // FeaturedGames = [];
- // List games = response.body.toString().split("");
- // List featuredGames = Settings["featured_games"].toString().split(',');
- // games.forEach((game) {
- // dynamic Json = jsonDecode(game);
- // String id = Json['id'];
- // GamesJson.add(Json);
- //
- // if(featuredGames.contains(id)){
- // FeaturedGames.add(Json);
- // }
- // });
- //
- // Debug.Log("Total games ${GamesJson.length} and ${FeaturedGames.length} featured");
- // } catch (e) {
- // Debug.LogError("Error while loading games : $e");
- // }
- }
+import 'dart:convert';
+
+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 GamesJson = [];
+
+ static List> Challenges= [];
+ static Map Settings = {};
+ static List FeaturedGames = [];
+
+ static Future GrabInitData() async{
+ try {
+ var response = (await http.post(Uri.parse('${Brain.API_ENDPOINT}get_settings.php')));
+
+ Debug.LogResponse(response.body.toString());
+ // Settings= jsonDecode(response.body.toString());
+ List jsonList = jsonDecode(response.body.toString());
+ jsonList.forEach((jsonItem) {
+ Settings[jsonItem['id']] = jsonItem['value'];
+ });
+
+ } catch (e) {
+ Debug.LogError("Error while loading settings : $e");
+ }
+
+ try {
+ var response = (await http.post(Uri.parse('${Brain.API_ENDPOINT}get_games.php')));
+
+ Debug.LogResponse(response.body.toString());
+ GamesJson=[];
+ FeaturedGames = [];
+ List games = response.body.toString().split("");
+ List featuredGames = Settings["featured_games"].toString().split(',');
+ games.forEach((game) {
+ dynamic Json = jsonDecode(game);
+ String id = Json['id'];
+ GamesJson.add(Json);
+ print(Json);
+
+ if(featuredGames.contains(id)){
+ FeaturedGames.add(Json);
+ }
+ });
+
+ Debug.Log("Total games ${GamesJson.length} and ${FeaturedGames.length} featured");
+ } catch (e) {
+ Debug.LogError("Error while loading games : $e");
+ }
+
+ FetchChallenges();
+ }
+ static double currentEarnings = 0;
+ static Map ThisSeasonCryptoEarnings = {};
+ static Future FetchChallenges() async {
+ var response = null;
+
+ List> _Challenges = [];
+ double _currentEarnings = 0;
+ Map _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']}");
+ response = (await http.post(
+ Uri.parse('${Brain.API_ENDPOINT}get_challenges.php'),
+ body: {
+ "game_code": value['code'],
+ "id": Brain.UserJson['id']
+ }));
+ Debug.Log("Challenges response: " +response.body.toString());
+ List newChallenges = jsonDecode(response.body.toString());
+
+ 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']));
+
+ }
+
+ static Future GetGameProgress() async{
+ // try {
+ // var response = (await http.post(Uri.parse('${Brain.API_ENDPOINT}get_settings.php')));
+ //
+ // Debug.LogResponse(response.body.toString());
+ // // Settings= jsonDecode(response.body.toString());
+ // List jsonList = jsonDecode(response.body.toString());
+ // jsonList.forEach((jsonItem) {
+ // Settings[jsonItem['id']] = jsonItem['value'];
+ // });
+ //
+ // } catch (e) {
+ // Debug.LogError("Error while loading settings : $e");
+ // }
+ //
+ // try {
+ // var response = (await http.post(Uri.parse('${Brain.API_ENDPOINT}get_games.php')));
+ //
+ // Debug.LogResponse(response.body.toString());
+ // GamesJson=[];
+ // FeaturedGames = [];
+ // List games = response.body.toString().split("| ");
+ // List featuredGames = Settings["featured_games"].toString().split(',');
+ // games.forEach((game) {
+ // dynamic Json = jsonDecode(game);
+ // String id = Json['id'];
+ // GamesJson.add(Json);
+ //
+ // if(featuredGames.contains(id)){
+ // FeaturedGames.add(Json);
+ // }
+ // });
+ //
+ // Debug.Log("Total games ${GamesJson.length} and ${FeaturedGames.length} featured");
+ // } catch (e) {
+ // Debug.LogError("Error while loading games : $e");
+ // }
+ }
}
\ No newline at end of file
diff --git a/lib/Backend/login_mgr.dart b/lib/Backend/login_mgr.dart
index 71bafd1..4323c7f 100644
--- a/lib/Backend/login_mgr.dart
+++ b/lib/Backend/login_mgr.dart
@@ -1,123 +1,130 @@
-import 'dart:convert';
-
-import 'package:faucethub/Backend/DebugHelper.dart';
-import 'package:faucethub/Backend/brains.dart';
-import 'package:flutter/cupertino.dart';
-import 'package:http/http.dart' as http;
-import 'package:shared_preferences/shared_preferences.dart';
-
-final GlobalKey navigatorKey = new GlobalKey();
-
-class LoginManager {
-
- static Future AutoLogin() async{
- final prefs = await SharedPreferences.getInstance();
- String username = "";
- String password= "";
- try{
- username = prefs.getString("username")!;
- password = prefs.getString("password")!;
- }catch(e){
-
- }
-
- if(username.length > 3 && password.length >5){
- return await Login(username, password);
- }
-
- return 1;
- }
-
- static Future Register (String username, String password) async{
- Debug.Log("Starting registration");
- final prefs = await SharedPreferences.getInstance();
-
- var loginResponse = null;
- try {
- loginResponse = (await http.post(
- Uri.parse('${Brain.API_ENDPOINT}register.php'),
- body: {
- "username": username,
- "password": password
- }));
- // Debug.Log("Reg response: " + loginResponse.body.toString());
-
-
- if (loginResponse.body.toLowerCase() == "0") {
- prefs.setString("username", username);
- prefs.setString("password", password);
-
- return 0;
-
- }else{
- return 5;
- }
- } catch (e) {
- Debug.LogError("Error while login $e");
- }
-
- return 1;
- }
-
- static Future Login (String username, String password) async{
- Debug.Log("Logging in");
- final prefs = await SharedPreferences.getInstance();
-
- var loginResponse = null;
- try {
- loginResponse = (await http.post(
- Uri.parse('${Brain.API_ENDPOINT}login.php'),
- body: {
- "username": username,
- "password": password
- }));
- Debug.LogError(loginResponse.body.toString());
-
- try{
- Brain.UserJson = jsonDecode(loginResponse.body.toString());
- Brain.InitUserData();
- Debug.LogResponse(Brain.UserJson);
- prefs.setString("username", username);
- prefs.setString("password", password);
- return 0;
- }catch(e){
- return 5;
- }
- } catch (e) {
- Debug.LogError("Error while login $e");
- }
-
- return 1;
- }
-
- static Future GoogleLogin (String email) async{
- Debug.Log("Logging in");
- final prefs = await SharedPreferences.getInstance();
-
- var loginResponse = null;
- try {
- var username = email + "#0";
- loginResponse = (await http.post(
- Uri.parse('${Brain.API_ENDPOINT}google_login.php'),
- body: {
- "username": username
- }));
- Debug.LogError(loginResponse.body.toString());
-
- try{
- Brain.UserJson = jsonDecode(loginResponse.body.toString());
- Brain.InitUserData();
- Debug.LogResponse(Brain.UserJson);
- prefs.setString("username", username);
- prefs.setString("password", username);
- return 0;
- }catch(e){
- return 5;
- }
- } catch (e) {
- Debug.LogError("Error while login $e");
- }
-
- return 1;
- }
-}
+import 'dart:convert';
+
+import 'package:faucethub/Backend/DebugHelper.dart';
+import 'package:faucethub/Backend/brains.dart';
+import 'package:flutter/cupertino.dart';
+import 'package:http/http.dart' as http;
+import 'package:shared_preferences/shared_preferences.dart';
+
+final GlobalKey navigatorKey = new GlobalKey();
+
+class LoginManager {
+
+ static Future AutoLogin() async{
+ final prefs = await SharedPreferences.getInstance();
+ String username = "";
+ String password= "";
+ try{
+ if(prefs.containsKey("googleLogin")){
+ if(prefs.getBool("googleLogin") ?? false){
+
+ }
+ }
+
+ username = prefs.getString("username")!;
+ password = prefs.getString("password")!;
+ }catch(e){
+
+ }
+
+ if(username.length > 3 && password.length >5){
+ return await Login(username, password);
+ }
+
+ return 1;
+ }
+
+ static Future Register (String username, String password) async{
+ Debug.Log("Starting registration");
+ final prefs = await SharedPreferences.getInstance();
+
+ var loginResponse = null;
+ try {
+ loginResponse = (await http.post(
+ Uri.parse('${Brain.API_ENDPOINT}register.php'),
+ body: {
+ "username": username,
+ "password": password
+ }));
+ // Debug.Log("Reg response: " + loginResponse.body.toString());
+
+
+ if (loginResponse.body.toLowerCase() == "0") {
+ prefs.setString("username", username);
+ prefs.setString("password", password);
+
+ return 0;
+
+ }else{
+ return 5;
+ }
+ } catch (e) {
+ Debug.LogError("Error while login $e");
+ }
+
+ return 1;
+ }
+
+ static Future Login (String username, String password) async{
+ Debug.Log("Logging in");
+ final prefs = await SharedPreferences.getInstance();
+
+ var loginResponse = null;
+ try {
+ loginResponse = (await http.post(
+ Uri.parse('${Brain.API_ENDPOINT}login.php'),
+ body: {
+ "username": username,
+ "password": password
+ }));
+ Debug.LogError(loginResponse.body.toString());
+
+ try{
+ Brain.UserJson = jsonDecode(loginResponse.body.toString());
+ Brain.InitUserData();
+ Debug.LogResponse(Brain.UserJson);
+ prefs.setString("username", username);
+ prefs.setString("password", password);
+ return 0;
+ }catch(e){
+ return 5;
+ }
+ } catch (e) {
+ Debug.LogError("Error while login $e");
+ }
+
+ return 1;
+ }
+
+ static Future GoogleLogin (String email) async{
+ Debug.Log("Logging in");
+ final prefs = await SharedPreferences.getInstance();
+
+ var loginResponse = null;
+ try {
+ var username = email + "#0";
+ loginResponse = (await http.post(
+ Uri.parse('${Brain.API_ENDPOINT}google_login.php'),
+ body: {
+ "username": username
+ }));
+ Debug.LogError(loginResponse.body.toString());
+
+ try{
+ Brain.UserJson = jsonDecode(loginResponse.body.toString());
+ Brain.InitUserData();
+ Debug.LogResponse(Brain.UserJson);
+ prefs.setString("username", username);
+ prefs.setString("password", username);
+ prefs.setBool("googleLogin", true);
+ return 0;
+ }catch(e){
+ return 5;
+ }
+ } catch (e) {
+ Debug.LogError("Error while login $e");
+ }
+
+ return 1;
+ }
+}
diff --git a/lib/game_page.dart b/lib/game_page.dart
new file mode 100644
index 0000000..97e1bf4
--- /dev/null
+++ b/lib/game_page.dart
@@ -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 createState() => _GamePageState();
+}
+
+class _GamePageState extends State {
+ @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!")
+ ],
+ ),
+
+ ],
+ ),
+ ),
+ ));
+ }
+}
diff --git a/lib/home.dart b/lib/home.dart
index 7416f4a..1a7b5f8 100644
--- a/lib/home.dart
+++ b/lib/home.dart
@@ -1,510 +1,723 @@
-// 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: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: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 {
- const HomePage({Key? key}) : super(key: key);
-
- @override
- State createState() => _HomePageState();
-}
-
-int selectedBotNavIndex = 0;
-String daysLeft = "";
-class _HomePageState extends State {
- bool looping =false;
- @override
- void initState() {
- // TODO: implement initState
- super.initState();
- loop();
- }
-
- void loop() async{
- looping=true;
-
- while(looping){
- await Hoarder.FetchChallenges();
- DateTime now = DateTime.now();
- DateTime nextMonth = DateTime(now.year,now.month);
-
- daysLeft = "${nextMonth.difference(now).inDays} Days Remaining";
- setState(() {
-
- });
-
- await Future.delayed(const Duration(seconds: 30));
- }
- }
-
- @override
- void dispose() {
- // TODO: implement dispose
- super.dispose();
-
- looping=false;
- }
-
- Widget HomeWidget() {
- final ScrollController _firstController = ScrollController();
- return SingleChildScrollView(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.stretch,
- children: [
- Container(
- padding: EdgeInsets.all(20),
- 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",
- child: Container(
- child: Column(
- children: [
-
- 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']));
- }
- )
- ]);
- }
- )
- ],
- ),
- )
- ),
- // HomeCard(
- // title: "Featured Games",
- // child: SizedBox(
- // height: 110,
- // child: Scrollbar(
- // thumbVisibility: true,
- // controller: _firstController,
- // child: ListView.builder(
- // scrollDirection: Axis.horizontal,
- // controller: _firstController,
- // itemCount: Hoarder.FeaturedGames.length,
- // itemBuilder: (BuildContext context, int index) {
- // Debug.Log(Hoarder.FeaturedGames[index]);
- // return InkWell(
- // onTap: () {},
- // child: Card(
- // child: ClipRRect(
- // borderRadius: BorderRadius.circular(12),
- // child: Image.network(
- // Hoarder.FeaturedGames[index]['icon'],
- // width: 100,
- // height: 100),
- // ),
- // ),
- // );
- // }),
- // ),
- // ),
- // ),
- // HomeCard(
- // child: SizedBox(
- // height: 250,
- // ),
- // title: "Top Players"),
- ],
- ),
- );
- }
-
- Widget ChallengesList({required String gameName, required String coin, required List 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(
- children: [
- FaIcon(Helpers.GetIconForCrypto(coin)),
- Text(" $coin"),
- ],
- )
- ]),
- SizedBox(height: 10,),
- Container(
- padding: const EdgeInsets.all(8.0),
- child: Column(
- children: challengesInfo,
- ),
- ),
-
- ],
- ),
- ),
- );
- }
-
- Widget ChallengeProgress(String title, int total, int current, int reward,
- {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,),
-
- ]
- ),
- );
- }
-
- Widget GamesWidget() {
- final ScrollController scrollController = ScrollController();
- return Container(
- padding: EdgeInsets.fromLTRB(20, 20, 0, 20),
- child: SingleChildScrollView(
- physics: ScrollPhysics(),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text(
- "Linked",
- style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
- ),
- SizedBox(
- height: 5,
- ),
- ListView.builder(
- physics: NeverScrollableScrollPhysics(),
- shrinkWrap: true,
- controller: scrollController,
- itemCount: Brain.LinkedGamesJson.length,
- itemBuilder: (BuildContext context, int index) {
- // Debug.Log(Hoarder.LinkedGamesJson[index]);
- return InkWell(
- onTap: () {
- showLinkGameDialog(context, Brain.LinkedGamesJson[index]);
- },
- child: ListTile(
- leading: ClipRRect(
- borderRadius: BorderRadius.circular(12),
- child: Image.network(Brain.LinkedGamesJson[index]['icon'],
- width: 50, height: 50),
- ),
- title: Text(Brain.LinkedGamesJson[index]['name']),
- subtitle: Text(Brain.LinkedGamesJson[index]['description']),
- trailing: Row(
- mainAxisSize: MainAxisSize.min,
- children: [
- Icon(
- Helpers.GetIconForCrypto(
- Brain.LinkedGamesJson[index]['coin']),
- size: 17,
- ),
- SizedBox(
- width: 2,
- ),
- Text("0.00004000"),
- ],
- ),
- ),
- );
- }),
- SizedBox(
- height: 20,
- ),
- Text(
- "Not Linked",
- style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
- ),
- SizedBox(
- height: 5,
- ),
- ListView.builder(
- physics: NeverScrollableScrollPhysics(),
- shrinkWrap: true,
- controller: scrollController,
- itemCount: Brain.NonLinkedGamesJson.length,
- itemBuilder: (BuildContext context, int index) {
- // Debug.Log(Hoarder.NonLinkedGamesJson[index]);
- return InkWell(
- onTap: () async{
- // 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);
- }
- },
- child: ListTile(
- leading: ClipRRect(
- borderRadius: BorderRadius.circular(12),
- child: Image.network(Brain.NonLinkedGamesJson[index]['icon'],
- width: 50, height: 50),
- ),
- title: Text(Brain.NonLinkedGamesJson[index]['name']),
- subtitle: Text(Brain.NonLinkedGamesJson[index]['description']),
- ),
- );
- })
- ],
- ),
- ),
- );
- }
-
- Widget WalletWidget() {
- 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,),
- 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",)]
- ),
-
- 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(
- 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"),
-
- ],
- )
- ),
- ]),
- ),
-
- ],
- ))
- ],)));
- }
-
- 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()
- ],)));
- }
-
- @override
- Widget build(BuildContext context) {
- List bodyOptions = [
- HomeWidget(),
- GamesWidget(),
- WalletWidget(),
- SettingsWidget()
- ];
-
- return SafeArea(
- child: Scaffold(
- // appBar: AppBar(title: Text('Faucet Hub'),),
-
- body: bodyOptions.elementAt(selectedBotNavIndex),
- bottomNavigationBar: BottomNavigationBar(
- enableFeedback: true,
- selectedItemColor: Colors.green,
- unselectedItemColor: Colors.grey,
- elevation: 20,
- items: const [
- BottomNavigationBarItem(icon: Icon(Icons.home), label: "Home"),
- BottomNavigationBarItem(
- icon: Icon(Icons.videogame_asset), label: "Games"),
- BottomNavigationBarItem(
- icon: Icon(Icons.account_balance_wallet), label: "Wallet"),
- BottomNavigationBarItem(
- icon: Icon(Icons.settings), label: "Settings"),
- ],
- currentIndex: selectedBotNavIndex,
- onTap: onBotNavTapped,
- )),
- );
- }
-
- static Widget HomeCard(
- {bool showMore = false, required Widget child, required String title}) {
- return Padding(
- padding: const EdgeInsets.all(8.0),
- child: Card(
- child: Container(
- padding: EdgeInsets.symmetric(horizontal: 5, vertical: 10),
- child: Column(children: [
- Padding(
- padding: const EdgeInsets.fromLTRB(8, 0, 8, 8),
- child: Row(
- mainAxisSize: MainAxisSize.max,
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Text(
- title,
- style: TextStyle(
- fontSize: 17, fontWeight: FontWeight.bold),
- ),
- (showMore) ? InkWell(
- child: Icon(Icons.arrow_right_alt),
- onTap: () {},
- ) : Container()
- ],
- ),
- ),
- child
- ]))));
- }
-
- 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)],),
- Text(value)
- ],),
- );
- }
-
- 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'])],),
- Text(value)
- ],),
- );
- }
-
- void onBotNavTapped(int value) {
- 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();
-
- 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(); },)
- ]
- );
- }
- );
- }
-}
+// import 'package:crypto_font_icons/crypto_font_icons.dart';
+import 'package:crypto_font_icons/crypto_font_icons.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 'Backend/helpers.dart';
+
+class HomePage extends StatefulWidget {
+ const HomePage({Key? key}) : super(key: key);
+
+ @override
+ State createState() => _HomePageState();
+}
+
+int selectedBotNavIndex = 0;
+String daysLeft = "";
+
+class _HomePageState extends State {
+ bool looping = false;
+ @override
+ void initState() {
+ // TODO: implement initState
+ super.initState();
+ loop();
+ }
+
+ void loop() async {
+ looping = true;
+
+ while (looping) {
+ await Hoarder.FetchChallenges();
+
+ DateTime now = DateTime.now();
+ DateTime nextMonth = DateTime(now.year, now.month);
+
+ daysLeft = "${nextMonth.difference(now).inDays} Days Remaining";
+ setState(() {});
+
+ await Future.delayed(const Duration(seconds: 30));
+ }
+ }
+
+ @override
+ void dispose() {
+ // TODO: implement dispose
+ super.dispose();
+
+ looping = false;
+ }
+
+ Widget HomeWidget() {
+ final ScrollController _firstController = ScrollController();
+ return SingleChildScrollView(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ Container(
+ padding: EdgeInsets.all(20),
+ child: Text("Welcome ${Brain.DisplayName},",
+ style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold)),
+ ),
+ 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)),
+
+ 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,
+ // child: Scrollbar(
+ // thumbVisibility: true,
+ // controller: _firstController,
+ // child: ListView.builder(
+ // scrollDirection: Axis.horizontal,
+ // controller: _firstController,
+ // itemCount: Hoarder.FeaturedGames.length,
+ // itemBuilder: (BuildContext context, int index) {
+ // Debug.Log(Hoarder.FeaturedGames[index]);
+ // return InkWell(
+ // onTap: () {},
+ // child: Card(
+ // child: ClipRRect(
+ // borderRadius: BorderRadius.circular(12),
+ // child: Image.network(
+ // Hoarder.FeaturedGames[index]['icon'],
+ // width: 100,
+ // height: 100),
+ // ),
+ // ),
+ // );
+ // }),
+ // ),
+ // ),
+ // ),
+ // HomeCard(
+ // child: SizedBox(
+ // height: 250,
+ // ),
+ // title: "Top Players"),
+ ],
+ ),
+ );
+ }
+
+ Widget ChallengesList(
+ {required String gameName,
+ required String coin,
+ required List 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(
+ children: [
+ FaIcon(Helpers.GetIconForCrypto(coin)),
+ Text(" $coin"),
+ ],
+ )
+ ]),
+ SizedBox(
+ height: 10,
+ ),
+ Container(
+ padding: const EdgeInsets.all(8.0),
+ child: Column(
+ children: challengesInfo,
+ ),
+ ),
+ ],
+ ),
+ ),
+ );
+ }
+
+ Widget ChallengeProgress(String title, int total, int current, int reward,
+ {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,
+ ),
+ ]),
+ );
+ }
+
+ Widget GamesWidget() {
+ final ScrollController scrollController = ScrollController();
+ return Container(
+ padding: EdgeInsets.fromLTRB(20, 20, 0, 20),
+ child: SingleChildScrollView(
+ physics: ScrollPhysics(),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ 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),
+ ),
+ SizedBox(
+ height: 5,
+ ),
+ ListView.builder(
+ physics: NeverScrollableScrollPhysics(),
+ shrinkWrap: true,
+ controller: scrollController,
+ itemCount: Brain.LinkedGamesJson.length,
+ itemBuilder: (BuildContext context, int index) {
+ // Debug.Log(Hoarder.LinkedGamesJson[index]);
+ return InkWell(
+ 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),
+ ),
+ title: Text(Brain.LinkedGamesJson[index]['name']),
+ subtitle:
+ Text(Brain.LinkedGamesJson[index]['description']),
+ trailing: Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Icon(
+ Helpers.GetIconForCrypto(
+ Brain.LinkedGamesJson[index]['coin']),
+ size: 17,
+ ),
+ SizedBox(
+ width: 2,
+ ),
+ // Text("0.00004000"),
+ ],
+ ),
+ ),
+ );
+ }),
+ SizedBox(
+ height: 20,
+ ),
+ Text(
+ "Not Linked",
+ style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
+ ),
+ SizedBox(
+ height: 5,
+ ),
+ ListView.builder(
+ physics: NeverScrollableScrollPhysics(),
+ shrinkWrap: true,
+ controller: scrollController,
+ itemCount: Brain.NonLinkedGamesJson.length,
+ itemBuilder: (BuildContext context, int index) {
+ // Debug.Log(Hoarder.NonLinkedGamesJson[index]);
+ String code = Brain.NonLinkedGamesJson[index]['code'];
+ return InkWell(
+ 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
+ // 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),
+ ),
+ title: Text(Brain.NonLinkedGamesJson[index]['name']),
+ subtitle:
+ Text(Brain.NonLinkedGamesJson[index]['description']),
+ trailing: Icon(
+ Helpers.GetIconForCrypto(
+ Brain.NonLinkedGamesJson[index]['coin']),
+ size: 17,
+ ),
+ ),
+ );
+ })
+ ],
+ ),
+ ),
+ );
+ }
+
+ Widget WalletWidget() {
+ 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,
+ ),
+ 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",
+ )
+ ]),
+ 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(
+ 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"),
+ ],
+ )),
+ ]),
+ ),
+ ],
+ ))
+ ],
+ )));
+ }
+
+ 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()
+ ],
+ )));
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ List bodyOptions = [
+ HomeWidget(),
+ GamesWidget(),
+ WalletWidget(),
+ SettingsWidget()
+ ];
+
+ return SafeArea(
+ child: Scaffold(
+ // appBar: AppBar(title: Text('Faucet Hub'),),
+
+ body: bodyOptions.elementAt(selectedBotNavIndex),
+ bottomNavigationBar: BottomNavigationBar(
+ enableFeedback: true,
+ selectedItemColor: Colors.green,
+ unselectedItemColor: Colors.grey,
+ elevation: 20,
+ items: const [
+ BottomNavigationBarItem(icon: Icon(Icons.home), label: "Home"),
+ BottomNavigationBarItem(
+ icon: Icon(Icons.videogame_asset), label: "Games"),
+ BottomNavigationBarItem(
+ icon: Icon(Icons.account_balance_wallet), label: "Wallet"),
+ BottomNavigationBarItem(
+ icon: Icon(Icons.settings), label: "Settings"),
+ ],
+ currentIndex: selectedBotNavIndex,
+ onTap: onBotNavTapped,
+ )),
+ );
+ }
+
+ static Widget HomeCard(
+ {bool showMore = false, required Widget child, required String title}) {
+ return Padding(
+ padding: const EdgeInsets.all(8.0),
+ child: Card(
+ child: Container(
+ padding: EdgeInsets.symmetric(horizontal: 5, vertical: 10),
+ child: Column(children: [
+ Padding(
+ padding: const EdgeInsets.fromLTRB(8, 0, 8, 8),
+ child: Row(
+ mainAxisSize: MainAxisSize.max,
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ Text(
+ title,
+ style: TextStyle(
+ fontSize: 17, fontWeight: FontWeight.bold),
+ ),
+ (showMore)
+ ? InkWell(
+ child: Icon(Icons.arrow_right_alt),
+ onTap: () {},
+ )
+ : Container()
+ ],
+ ),
+ ),
+ child
+ ]))));
+ }
+
+ 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)
+ ],
+ ),
+ Text(value)
+ ],
+ ),
+ );
+ }
+
+ 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'])
+ ],
+ ),
+ Text(value)
+ ],
+ ),
+ );
+ }
+
+ void onBotNavTapped(int value) {
+ 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();
+
+ 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();
+ },
+ )
+ ]);
+ });
+ }
+}
diff --git a/lib/login.dart b/lib/login.dart
index 5d1bafc..0513623 100644
--- a/lib/login.dart
+++ b/lib/login.dart
@@ -1,274 +1,295 @@
-import 'package:faucethub/Backend/DebugHelper.dart';
-import 'package:faucethub/Backend/Dialogs.dart';
-import 'package:faucethub/Backend/login_mgr.dart';
-
-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';
-
-class LoginPage extends StatefulWidget {
- const LoginPage({Key? key}) : super(key: key);
-
- @override
- State createState() => _LoginPageState();
-}
-
-
-class _LoginPageState extends State {
- TextEditingController usernameTxtController = TextEditingController();
- TextEditingController passwordTxtController = TextEditingController();
-
- bool isLogin = true;
-
-
- @override
- Widget build(BuildContext context) => ChangeNotifierProvider(
- create:(context)=>GoogleSignInProvider(),
- builder: (context, snapshot) {
- return Scaffold(
- body: Container(
- alignment: Alignment.center,
- child: Card(
- child: (isLogin) ? LoginCard() : RegisterCard(),
- ),
- ),
- );
- }
- );
-
-
- Widget LoginCard(){
- return Container(
- padding: EdgeInsets.symmetric(vertical: 20, horizontal: 50),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- Text("Welcome!",style: TextStyle(fontSize: 25),), SizedBox(height: 10,),
-
- Text("Login to continue"),
- Row(
- mainAxisSize: MainAxisSize.max,
- children: [
- Container(child: Icon(Icons.person)),
- Expanded(child: TextField(controller: usernameTxtController,decoration: const InputDecoration(
- labelText: 'Username',
- ))),
- ],
- ),
- SizedBox(height: 10,),
- Row(
- mainAxisSize: MainAxisSize.max,
- children: [
- Container(child: Icon(Icons.key)),
- Expanded(child: TextField(controller: passwordTxtController,obscureText: true,
- decoration: const InputDecoration(
- labelText: 'Password',
- ),)),
- ],
- ),
- MaterialButton(onPressed: (){
- if(usernameTxtController.value.text.length < 3){
- Dialogs.showAlertDialog(context, "Invalid", "Username entered is invalid, It must be longer than 3 letters");
- return;
- }
- if(passwordTxtController.value.text.length < 5){
- Dialogs.showAlertDialog(context, "Invalid", "Password entered is invalid, It must be longer than 5 letters");
- return;
- }
- Login();
- setState(() {
-
- });
- },child: Text("Login"),
- color: Colors.green,
- ),
- MaterialButton(onPressed: (){
- isLogin=false;
- setState(() {
-
- });
- },child: Text("Don't have an account? Register"),
- color: Colors.grey,
- ),
- SizedBox(height: 50,),
-
- MaterialButton(onPressed: (){
- SignWithGoogle();
- setState(() {
-
- });
- },child: Text("Continue with Google"),
- color: Colors.blueAccent,
- )
- ],
- )
- );
- }
- Widget RegisterCard(){
- return Container(
- padding: EdgeInsets.symmetric(vertical: 20, horizontal: 50),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- Text("Welcome!",style: TextStyle(fontSize: 25),), SizedBox(height: 10,),
- Text("Create a new Account"),
- Row(
- mainAxisAlignment: MainAxisAlignment.start,
- mainAxisSize: MainAxisSize.max,
- children: [
- Container(child: Icon(Icons.person)),
- Expanded(child: TextField(controller: usernameTxtController,decoration: const InputDecoration(
- labelText: 'Username',
- ))),
- ],
- ),
- SizedBox(height: 10,),
- Row(
- mainAxisSize: MainAxisSize.max,
- children: [
- Container(child: Icon(Icons.key)),
- Expanded(child: TextField(controller: passwordTxtController,obscureText: true,
- decoration: const InputDecoration(
- labelText: 'Password',
- ),)),
- ],
- ),
- MaterialButton(onPressed: (){
- if(usernameTxtController.value.text.length < 3){
- Dialogs.showAlertDialog(context, "Invalid", "Username entered is invalid, It must be longer than 3 letters");
- return;
- }
- if(passwordTxtController.value.text.length < 5){
- Dialogs.showAlertDialog(context, "Invalid", "Password entered is invalid, It must be longer than 5 letters");
- return;
- }
- Register();
-
- setState(() {
-
- });
- },child: Text("Register"),
- color: Colors.green,
- ),
- MaterialButton(onPressed: (){
- isLogin=true;
- setState(() {
-
- });
- },child: Text("Has an account? Login Here"),
- color: Colors.grey,
- ),
- SizedBox(height: 50,),
-
- MaterialButton(onPressed: (){
- SignWithGoogle();
- setState(() {
-
- });
- },child: Text("Continue with Google"),
- color: Colors.blueAccent,
- )
- ],
- )
- );
- }
-
- Future SignWithGoogle() async {
- GoogleSignIn _googleSignIn = GoogleSignIn(
- scopes: [
- 'email',
- 'https://www.googleapis.com/auth/contacts.readonly',
- ],
- );
-
- try {
- GoogleSignInAccount? account = await _googleSignIn.signIn();
-
- print(account?.email);
-
- int registerResult = await LoginManager.GoogleLogin(account!.email);
- Dialogs.hide();
-
- if(registerResult == 0){
- // Dialogs.showAlertDialog(context, "Success", "Login done, congrats!");
- Navigator.of(context).pushReplacementNamed('/home');
- }else if(registerResult == 1){
- Dialogs.showAlertDialog(context, "Failed", "Servers are unreachable. Please check internet connection and try again.");
- }else if(registerResult == 5){
- Dialogs.showAlertDialog(context, "Failed", "Couldn't Login with this google account");
- }
-
-
- } catch (error) {
- print(error);
- print("google sign in failed");
- }
-
- }
-
- void Register({String? email = null}) async{
-
- Debug.Log("Register clicked");
- Dialogs.waiting();
- int registerResult = 0;
- if(email == null) {
- Debug.Log("Continuing with native login");
- Debug.Log(usernameTxtController.value.text + " : " + passwordTxtController.value.text);
- registerResult = await LoginManager.Register(
- usernameTxtController.value.text, passwordTxtController.value.text);
- }else{
- registerResult = await LoginManager.Register(email!, email!);
- }
-
- Dialogs.hide();
-
- if(registerResult == 0){
- // Dialogs.showAlertDialog(context, "Success", "Registration done, congrats!");
- Login();
- }else if(registerResult == 1){
- Dialogs.showAlertDialog(context, "Failed", "Servers are unreachable. Please check internet connection and try again.");
- }else if(registerResult == 5){
- Dialogs.showAlertDialog(context, "Failed", "Username already exists.");
- }
-
- }
-
- void Login() async{
-
- Debug.Log("Login clicked");
- Dialogs.waiting();
-
- int registerResult = await LoginManager.Login(usernameTxtController.value.text, passwordTxtController.value.text);
- Dialogs.hide();
-
- if(registerResult == 0){
- // Dialogs.showAlertDialog(context, "Success", "Login done, congrats!");
- Navigator.of(context).pushReplacementNamed('/home');
- }else if(registerResult == 1){
- Dialogs.showAlertDialog(context, "Failed", "Servers are unreachable. Please check internet connection and try again.");
- }else if(registerResult == 5){
- Dialogs.showAlertDialog(context, "Failed", "Username or password is incorrect.");
- }
-
- }
-
-
- void GoogleLogin() async{
- Debug.Log("Google Login clicked");
- Dialogs.waiting();
-
- int registerResult = await LoginManager.Login(usernameTxtController.value.text, passwordTxtController.value.text);
- Dialogs.hide();
-
- if(registerResult == 0){
- // Dialogs.showAlertDialog(context, "Success", "Login done, congrats!");
- Navigator.of(context).pushReplacementNamed('/home');
- }else if(registerResult == 1){
- Dialogs.showAlertDialog(context, "Failed", "Servers are unreachable. Please check internet connection and try again.");
- }else if(registerResult == 5){
- Dialogs.showAlertDialog(context, "Failed", "Username or password is incorrect.");
- }
- }
-
-}
+import 'package:faucethub/Backend/DebugHelper.dart';
+import 'package:faucethub/Backend/Dialogs.dart';
+import 'package:faucethub/Backend/login_mgr.dart';
+
+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);
+
+ @override
+ State createState() => _LoginPageState();
+}
+
+
+class _LoginPageState extends State {
+ TextEditingController usernameTxtController = TextEditingController();
+ TextEditingController passwordTxtController = TextEditingController();
+
+ bool isLogin = true;
+
+
+ @override
+ Widget build(BuildContext context) => ChangeNotifierProvider(
+ create:(context)=>GoogleSignInProvider(),
+ builder: (context, snapshot) {
+ return Scaffold(
+ body: Container(
+ alignment: Alignment.center,
+ child: Card(
+ child: (isLogin) ? LoginCard() : RegisterCard(),
+ ),
+ ),
+ );
+ }
+ );
+
+
+ @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),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Text("Welcome!",style: TextStyle(fontSize: 25),), SizedBox(height: 10,),
+
+ Text("Login to continue"),
+ Row(
+ mainAxisSize: MainAxisSize.max,
+ children: [
+ Container(child: Icon(Icons.person)),
+ Expanded(child: TextField(controller: usernameTxtController,decoration: const InputDecoration(
+ labelText: 'Username',
+ ))),
+ ],
+ ),
+ SizedBox(height: 10,),
+ Row(
+ mainAxisSize: MainAxisSize.max,
+ children: [
+ Container(child: Icon(Icons.key)),
+ Expanded(child: TextField(controller: passwordTxtController,obscureText: true,
+ decoration: const InputDecoration(
+ labelText: 'Password',
+ ),)),
+ ],
+ ),
+ MaterialButton(onPressed: (){
+ if(usernameTxtController.value.text.length < 3){
+ Dialogs.showAlertDialog(context, "Invalid", "Username entered is invalid, It must be longer than 3 letters");
+ return;
+ }
+ if(passwordTxtController.value.text.length < 5){
+ Dialogs.showAlertDialog(context, "Invalid", "Password entered is invalid, It must be longer than 5 letters");
+ return;
+ }
+ Login();
+ setState(() {
+
+ });
+ },child: Text("Login"),
+ color: Colors.green,
+ ),
+ MaterialButton(onPressed: (){
+ isLogin=false;
+ setState(() {
+
+ });
+ },child: Text("Don't have an account? Register"),
+ color: Colors.grey,
+ ),
+ SizedBox(height: 50,),
+
+ MaterialButton(onPressed: (){
+ SignWithGoogle();
+ setState(() {
+
+ });
+ },child: Text("Continue with Google"),
+ color: Colors.blueAccent,
+ )
+ ],
+ )
+ );
+ }
+ Widget RegisterCard(){
+ return Container(
+ padding: EdgeInsets.symmetric(vertical: 20, horizontal: 50),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Text("Welcome!",style: TextStyle(fontSize: 25),), SizedBox(height: 10,),
+ Text("Create a new Account"),
+ Row(
+ mainAxisAlignment: MainAxisAlignment.start,
+ mainAxisSize: MainAxisSize.max,
+ children: [
+ Container(child: Icon(Icons.person)),
+ Expanded(child: TextField(controller: usernameTxtController,decoration: const InputDecoration(
+ labelText: 'Username',
+ ))),
+ ],
+ ),
+ SizedBox(height: 10,),
+ Row(
+ mainAxisSize: MainAxisSize.max,
+ children: [
+ Container(child: Icon(Icons.key)),
+ Expanded(child: TextField(controller: passwordTxtController,obscureText: true,
+ decoration: const InputDecoration(
+ labelText: 'Password',
+ ),)),
+ ],
+ ),
+ MaterialButton(onPressed: (){
+ if(usernameTxtController.value.text.length < 3){
+ Dialogs.showAlertDialog(context, "Invalid", "Username entered is invalid, It must be longer than 3 letters");
+ return;
+ }
+ if(passwordTxtController.value.text.length < 5){
+ Dialogs.showAlertDialog(context, "Invalid", "Password entered is invalid, It must be longer than 5 letters");
+ return;
+ }
+ Register();
+
+ setState(() {
+
+ });
+ },child: Text("Register"),
+ color: Colors.green,
+ ),
+ MaterialButton(onPressed: (){
+ isLogin=true;
+ setState(() {
+
+ });
+ },child: Text("Has an account? Login Here"),
+ color: Colors.grey,
+ ),
+ SizedBox(height: 50,),
+
+ MaterialButton(onPressed: (){
+ SignWithGoogle();
+ setState(() {
+
+ });
+ },child: Text("Continue with Google"),
+ color: Colors.blueAccent,
+ )
+ ],
+ )
+ );
+ }
+
+ Future SignWithGoogle() async {
+ GoogleSignIn _googleSignIn = GoogleSignIn(
+ scopes: [
+ 'email',
+ 'https://www.googleapis.com/auth/contacts.readonly',
+ ],
+ );
+
+ try {
+ GoogleSignInAccount? account = await _googleSignIn.signIn();
+
+ print(account?.email);
+
+ int registerResult = await LoginManager.GoogleLogin(account!.email);
+ Dialogs.hide();
+
+ if(registerResult == 0){
+ // Dialogs.showAlertDialog(context, "Success", "Login done, congrats!");
+ Navigator.of(context).pushReplacementNamed('/home');
+ }else if(registerResult == 1){
+ Dialogs.showAlertDialog(context, "Failed", "Servers are unreachable. Please check internet connection and try again.");
+ }else if(registerResult == 5){
+ Dialogs.showAlertDialog(context, "Failed", "Couldn't Login with this google account");
+ }
+
+
+ } catch (error) {
+ print(error);
+ print("google sign in failed");
+ }
+
+ }
+
+ void Register({String? email = null}) async{
+
+ Debug.Log("Register clicked");
+ Dialogs.waiting();
+ int registerResult = 0;
+ if(email == null) {
+ Debug.Log("Continuing with native login");
+ Debug.Log(usernameTxtController.value.text + " : " + passwordTxtController.value.text);
+ registerResult = await LoginManager.Register(
+ usernameTxtController.value.text, passwordTxtController.value.text);
+ }else{
+ registerResult = await LoginManager.Register(email!, email!);
+ }
+
+ Dialogs.hide();
+
+ if(registerResult == 0){
+ // Dialogs.showAlertDialog(context, "Success", "Registration done, congrats!");
+ Login();
+ }else if(registerResult == 1){
+ Dialogs.showAlertDialog(context, "Failed", "Servers are unreachable. Please check internet connection and try again.");
+ }else if(registerResult == 5){
+ Dialogs.showAlertDialog(context, "Failed", "Username already exists.");
+ }
+
+ }
+
+ void Login() async{
+
+ Debug.Log("Login clicked");
+ Dialogs.waiting();
+
+ int registerResult = await LoginManager.Login(usernameTxtController.value.text, passwordTxtController.value.text);
+ Dialogs.hide();
+
+ if(registerResult == 0){
+ // Dialogs.showAlertDialog(context, "Success", "Login done, congrats!");
+ Navigator.of(context).pushReplacementNamed('/home');
+ }else if(registerResult == 1){
+ Dialogs.showAlertDialog(context, "Failed", "Servers are unreachable. Please check internet connection and try again.");
+ }else if(registerResult == 5){
+ Dialogs.showAlertDialog(context, "Failed", "Username or password is incorrect.");
+ }
+
+ }
+
+
+ void GoogleLogin() async{
+ Debug.Log("Google Login clicked");
+ Dialogs.waiting();
+
+ int registerResult = await LoginManager.Login(usernameTxtController.value.text, passwordTxtController.value.text);
+ Dialogs.hide();
+
+ if(registerResult == 0){
+ // Dialogs.showAlertDialog(context, "Success", "Login done, congrats!");
+ Navigator.of(context).pushReplacementNamed('/home');
+ }else if(registerResult == 1){
+ Dialogs.showAlertDialog(context, "Failed", "Servers are unreachable. Please check internet connection and try again.");
+ }else if(registerResult == 5){
+ Dialogs.showAlertDialog(context, "Failed", "Username or password is incorrect.");
+ }
+ }
+
+}
diff --git a/lib/main.dart b/lib/main.dart
index 1a77caf..8dc13da 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -1,36 +1,36 @@
-import 'package:faucethub/Backend/hoarder.dart';
-import 'package:faucethub/Backend/login_mgr.dart';
-
-import 'package:faucethub/home.dart';
-import 'package:faucethub/login.dart';
-import 'package:faucethub/splash.dart';
-import 'package:flutter/material.dart';
-
-void main() {
- Hoarder.GrabInitData();
- runApp(const MyApp());
-}
-
-class MyApp extends StatelessWidget {
- const MyApp({Key? key}) : super(key: key);
-
- // This widget is the root of your application.
- @override
- Widget build(BuildContext context) {
- return MaterialApp(
- title: 'Faucet Hub',
- navigatorKey: navigatorKey,
- theme: ThemeData(
- primarySwatch: Colors.blue,
- brightness: Brightness.dark,
- ),
- initialRoute: '/splash',
- routes: {
- '/login': (context)=> LoginPage(),
- '/splash': (context)=> SplashScreen(),
- '/home': (context)=> HomePage(),
-
- },
- );
- }
-}
+import 'package:faucethub/Backend/hoarder.dart';
+import 'package:faucethub/Backend/login_mgr.dart';
+
+import 'package:faucethub/home.dart';
+import 'package:faucethub/login.dart';
+import 'package:faucethub/splash.dart';
+import 'package:flutter/material.dart';
+
+void main() {
+ Hoarder.GrabInitData();
+ runApp(const MyApp());
+}
+
+class MyApp extends StatelessWidget {
+ const MyApp({Key? key}) : super(key: key);
+
+ // This widget is the root of your application.
+ @override
+ Widget build(BuildContext context) {
+ return MaterialApp(
+ title: 'Faucet Hub',
+ navigatorKey: navigatorKey,
+ theme: ThemeData(
+ primarySwatch: Colors.blue,
+ brightness: Brightness.dark,
+ ),
+ initialRoute: '/splash',
+ routes: {
+ '/login': (context)=> LoginPage(),
+ '/splash': (context)=> SplashScreen(),
+ '/home': (context)=> HomePage(),
+
+ },
+ );
+ }
+}
diff --git a/lib/splash.dart b/lib/splash.dart
index b256815..3d31f11 100644
--- a/lib/splash.dart
+++ b/lib/splash.dart
@@ -1,44 +1,44 @@
-import 'package:faucethub/Backend/hoarder.dart';
-import 'package:faucethub/Backend/login_mgr.dart';
-import 'package:flutter/material.dart';
-import 'package:flutter_spinkit/flutter_spinkit.dart';
-
-
-class SplashScreen extends StatefulWidget {
- const SplashScreen({Key? key}) : super(key: key);
-
- @override
- State createState() => _SplashScreenState();
-}
-
-class _SplashScreenState extends State {
-
- @override
- void initState() {
- // TODO: implement initState
- super.initState();
-
- init();
- }
-
- void init () async{
- await Hoarder.GrabInitData();
-
- int result = await LoginManager.AutoLogin();
- if(result == 0){
- Navigator.of(context).pushReplacementNamed('/home');
- }else{
- Navigator.of(context).pushReplacementNamed('/login');
- }
- }
-
- @override
- Widget build(BuildContext context) {
- return SafeArea(
- child: Scaffold(
- // backgroundColor: Colors.black,
- body: Container(child: SpinKitRipple(color: Colors.blue,size: 150,),alignment: Alignment.center,),
- ),
- );
- }
-}
+import 'package:faucethub/Backend/hoarder.dart';
+import 'package:faucethub/Backend/login_mgr.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter_spinkit/flutter_spinkit.dart';
+
+
+class SplashScreen extends StatefulWidget {
+ const SplashScreen({Key? key}) : super(key: key);
+
+ @override
+ State createState() => _SplashScreenState();
+}
+
+class _SplashScreenState extends State {
+
+ @override
+ void initState() {
+ // TODO: implement initState
+ super.initState();
+
+ init();
+ }
+
+ void init () async{
+ await Hoarder.GrabInitData();
+
+ int result = await LoginManager.AutoLogin();
+ if(result == 0){
+ Navigator.of(context).pushReplacementNamed('/home');
+ }else{
+ Navigator.of(context).pushReplacementNamed('/login');
+ }
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ return SafeArea(
+ child: Scaffold(
+ // backgroundColor: Colors.black,
+ body: Container(child: SpinKitRipple(color: Colors.blue,size: 150,),alignment: Alignment.center,),
+ ),
+ );
+ }
+}
diff --git a/pubspec.lock b/pubspec.lock
index fd3452e..ec1589f 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -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"
diff --git a/pubspec.yaml b/pubspec.yaml
index 1d707fb..7cee9d1 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,78 +1,78 @@
-name: faucethub
-description: A new Flutter project.
-
-publish_to: 'none' # Remove this line if you wish to publish to pub.dev
-
-version: 1.0.0+1
-
-environment:
- sdk: ">=2.16.2 <3.0.0"
-
-
-dependencies:
- flutter:
- sdk: flutter
- google_sign_in: ^5.4.4
- firebase_auth: ^4.2.5
- provider: ^6.0.5
- http: ^0.13.5
- shared_preferences: ^2.0.17
- flutter_spinkit: ^5.1.0
- 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
-
- # The following adds the Cupertino Icons font to your application.
- # Use with the CupertinoIcons class for iOS style icons.
- cupertino_icons: ^1.0.2
-
-dev_dependencies:
- flutter_test:
- sdk: flutter
-
-
- flutter_lints: ^1.0.0
-
-# For information on the generic Dart part of this file, see the
-# following page: https://dart.dev/tools/pub/pubspec
-
-# The following section is specific to Flutter.
-flutter:
-
- # The following line ensures that the Material Icons font is
- # included with your application, so that you can use the icons in
- # the material Icons class.
- uses-material-design: true
-
- # To add assets to your application, add an assets section, like this:
- # assets:
- # - images/a_dot_burr.jpeg
- # - images/a_dot_ham.jpeg
-
- # An image asset can refer to one or more resolution-specific "variants", see
- # https://flutter.dev/assets-and-images/#resolution-aware.
-
- # For details regarding adding assets from package dependencies, see
- # https://flutter.dev/assets-and-images/#from-packages
-
- # To add custom fonts to your application, add a fonts section here,
- # in this "flutter" section. Each entry in this list should have a
- # "family" key with the font family name, and a "fonts" key with a
- # list giving the asset and other descriptors for the font. For
- # example:
- # fonts:
- # - family: Schyler
- # fonts:
- # - asset: fonts/Schyler-Regular.ttf
- # - asset: fonts/Schyler-Italic.ttf
- # style: italic
- # - family: Trajan Pro
- # fonts:
- # - asset: fonts/TrajanPro.ttf
- # - asset: fonts/TrajanPro_Bold.ttf
- # weight: 700
- #
- # For details regarding fonts from package dependencies,
- # see https://flutter.dev/custom-fonts/#from-packages
+name: faucethub
+description: A new Flutter project.
+
+publish_to: 'none' # Remove this line if you wish to publish to pub.dev
+
+version: 1.0.0+1
+
+environment:
+ sdk: ">=2.16.2 <3.0.0"
+
+
+dependencies:
+ flutter:
+ sdk: flutter
+ google_sign_in: ^5.4.4
+ firebase_auth: ^4.2.5
+ provider: ^6.0.5
+ http: ^0.13.5
+ shared_preferences: ^2.0.17
+ flutter_spinkit: ^5.1.0
+ font_awesome_flutter: ^10.3.0
+ crypto_font_icons: ^1.0.1
+ syncfusion_flutter_charts: ^20.4.49
+ 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.
+ cupertino_icons: ^1.0.2
+
+dev_dependencies:
+ flutter_test:
+ sdk: flutter
+
+
+ flutter_lints: ^1.0.0
+
+# For information on the generic Dart part of this file, see the
+# following page: https://dart.dev/tools/pub/pubspec
+
+# The following section is specific to Flutter.
+flutter:
+
+ # The following line ensures that the Material Icons font is
+ # included with your application, so that you can use the icons in
+ # the material Icons class.
+ uses-material-design: true
+
+ # To add assets to your application, add an assets section, like this:
+ # assets:
+ # - images/a_dot_burr.jpeg
+ # - images/a_dot_ham.jpeg
+
+ # An image asset can refer to one or more resolution-specific "variants", see
+ # https://flutter.dev/assets-and-images/#resolution-aware.
+
+ # For details regarding adding assets from package dependencies, see
+ # https://flutter.dev/assets-and-images/#from-packages
+
+ # To add custom fonts to your application, add a fonts section here,
+ # in this "flutter" section. Each entry in this list should have a
+ # "family" key with the font family name, and a "fonts" key with a
+ # list giving the asset and other descriptors for the font. For
+ # example:
+ # fonts:
+ # - family: Schyler
+ # fonts:
+ # - asset: fonts/Schyler-Regular.ttf
+ # - asset: fonts/Schyler-Italic.ttf
+ # style: italic
+ # - family: Trajan Pro
+ # fonts:
+ # - asset: fonts/TrajanPro.ttf
+ # - asset: fonts/TrajanPro_Bold.ttf
+ # weight: 700
+ #
+ # For details regarding fonts from package dependencies,
+ # see https://flutter.dev/custom-fonts/#from-packages
diff --git a/test/widget_test.dart b/test/widget_test.dart
index ff3543c..876db5a 100644
--- a/test/widget_test.dart
+++ b/test/widget_test.dart
@@ -1,30 +1,30 @@
-// This is a basic Flutter widget test.
-//
-// To perform an interaction with a widget in your test, use the WidgetTester
-// utility that Flutter provides. For example, you can send tap and scroll
-// gestures. You can also use WidgetTester to find child widgets in the widget
-// tree, read text, and verify that the values of widget properties are correct.
-
-import 'package:flutter/material.dart';
-import 'package:flutter_test/flutter_test.dart';
-
-import 'package:faucethub/main.dart';
-
-void main() {
- testWidgets('Counter increments smoke test', (WidgetTester tester) async {
- // Build our app and trigger a frame.
- await tester.pumpWidget(const MyApp());
-
- // Verify that our counter starts at 0.
- expect(find.text('0'), findsOneWidget);
- expect(find.text('1'), findsNothing);
-
- // Tap the '+' icon and trigger a frame.
- await tester.tap(find.byIcon(Icons.add));
- await tester.pump();
-
- // Verify that our counter has incremented.
- expect(find.text('0'), findsNothing);
- expect(find.text('1'), findsOneWidget);
- });
-}
+// This is a basic Flutter widget test.
+//
+// To perform an interaction with a widget in your test, use the WidgetTester
+// utility that Flutter provides. For example, you can send tap and scroll
+// gestures. You can also use WidgetTester to find child widgets in the widget
+// tree, read text, and verify that the values of widget properties are correct.
+
+import 'package:flutter/material.dart';
+import 'package:flutter_test/flutter_test.dart';
+
+import 'package:faucethub/main.dart';
+
+void main() {
+ testWidgets('Counter increments smoke test', (WidgetTester tester) async {
+ // Build our app and trigger a frame.
+ await tester.pumpWidget(const MyApp());
+
+ // Verify that our counter starts at 0.
+ expect(find.text('0'), findsOneWidget);
+ expect(find.text('1'), findsNothing);
+
+ // Tap the '+' icon and trigger a frame.
+ await tester.tap(find.byIcon(Icons.add));
+ await tester.pump();
+
+ // Verify that our counter has incremented.
+ expect(find.text('0'), findsNothing);
+ expect(find.text('1'), findsOneWidget);
+ });
+}
diff --git a/web/index.html b/web/index.html
index 25277ea..407b10f 100644
--- a/web/index.html
+++ b/web/index.html
@@ -1,104 +1,104 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- faucethub
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ faucethub
+
+
+
+
+
+
+
diff --git a/web/manifest.json b/web/manifest.json
index 25d9100..547e93c 100644
--- a/web/manifest.json
+++ b/web/manifest.json
@@ -1,35 +1,35 @@
-{
- "name": "faucethub",
- "short_name": "faucethub",
- "start_url": ".",
- "display": "standalone",
- "background_color": "#0175C2",
- "theme_color": "#0175C2",
- "description": "A new Flutter project.",
- "orientation": "portrait-primary",
- "prefer_related_applications": false,
- "icons": [
- {
- "src": "icons/Icon-192.png",
- "sizes": "192x192",
- "type": "image/png"
- },
- {
- "src": "icons/Icon-512.png",
- "sizes": "512x512",
- "type": "image/png"
- },
- {
- "src": "icons/Icon-maskable-192.png",
- "sizes": "192x192",
- "type": "image/png",
- "purpose": "maskable"
- },
- {
- "src": "icons/Icon-maskable-512.png",
- "sizes": "512x512",
- "type": "image/png",
- "purpose": "maskable"
- }
- ]
-}
+{
+ "name": "faucethub",
+ "short_name": "faucethub",
+ "start_url": ".",
+ "display": "standalone",
+ "background_color": "#0175C2",
+ "theme_color": "#0175C2",
+ "description": "A new Flutter project.",
+ "orientation": "portrait-primary",
+ "prefer_related_applications": false,
+ "icons": [
+ {
+ "src": "icons/Icon-192.png",
+ "sizes": "192x192",
+ "type": "image/png"
+ },
+ {
+ "src": "icons/Icon-512.png",
+ "sizes": "512x512",
+ "type": "image/png"
+ },
+ {
+ "src": "icons/Icon-maskable-192.png",
+ "sizes": "192x192",
+ "type": "image/png",
+ "purpose": "maskable"
+ },
+ {
+ "src": "icons/Icon-maskable-512.png",
+ "sizes": "512x512",
+ "type": "image/png",
+ "purpose": "maskable"
+ }
+ ]
+}
| | | |