Glass
This commit is contained in:
@@ -20,10 +20,22 @@ class DataManager{
|
||||
static Future<bool> Init() async{
|
||||
bool isSettingsDone = await GetSettings();
|
||||
bool isGamesDone = await GetGames();
|
||||
|
||||
CalculateEarnings();
|
||||
StartGrabbing();
|
||||
return isSettingsDone && isGamesDone;
|
||||
}
|
||||
|
||||
static void StartGrabbing() async{
|
||||
while(true){
|
||||
await Future.delayed(const Duration(minutes: 1));
|
||||
|
||||
await GetSettings();
|
||||
await GetGames();
|
||||
await GetChallenges();
|
||||
CalculateEarnings();
|
||||
}
|
||||
}
|
||||
|
||||
static Future<void> GetGamesProgress() async{
|
||||
FilterLinkedGames();
|
||||
await GetChallenges();
|
||||
@@ -33,7 +45,10 @@ class DataManager{
|
||||
static void FilterLinkedGames(){
|
||||
LinkedGamesJson = [];
|
||||
NonLinkedGamesJson = [];
|
||||
|
||||
if(UserJson['linkedGames'].toString().length < 3){
|
||||
NonLinkedGamesJson = AllGames;
|
||||
return;
|
||||
}
|
||||
List<Map<String, dynamic>> linkedGames = jsonDecode(
|
||||
UserJson['linkedGames']).cast<Map<String, dynamic>>();
|
||||
|
||||
@@ -128,4 +143,70 @@ class DataManager{
|
||||
Challenges = _Challenges;
|
||||
return true;
|
||||
}
|
||||
static dynamic cryptoRates;
|
||||
static double currentEarnings =0;
|
||||
static Map<String, int> GamesEarnings = {};
|
||||
static Map<String, int> CryptoEarnings = {};
|
||||
|
||||
|
||||
static void CalculateEarnings() async{
|
||||
Debug.Log("Going to calculate earnings from games");
|
||||
while(UserJson == null){
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
}
|
||||
try{
|
||||
if(UserJson == null){Debug.LogError("User json is null, Abort calculating earnings");return;}
|
||||
Map<String, dynamic> earningsObj = jsonDecode(UserJson['earnings']);
|
||||
var cryptoValuesResponse = await http.get(Uri.parse('http://vps.playpoolstudios.com:2009/'));
|
||||
dynamic cryptoValues = jsonDecode(cryptoValuesResponse.body.toString());
|
||||
cryptoRates = cryptoValues;
|
||||
Debug.Log(cryptoValues);
|
||||
currentEarnings=0;
|
||||
Map<String, int> _ThisSeasonCryptoEarnings = {};
|
||||
Map<String, int> _ThisSeasonGamesEarnings = {};
|
||||
|
||||
earningsObj.forEach((key, earnings) {
|
||||
Debug.Log("$key : $earnings");
|
||||
dynamic gameData = Helpers.GetGameFromCode(key);
|
||||
_ThisSeasonCryptoEarnings.update(gameData['coin'], (value) => earnings, ifAbsent: ()=> earnings);
|
||||
_ThisSeasonGamesEarnings.update(key, (value) => earnings, ifAbsent: ()=> earnings);
|
||||
|
||||
double rewardInDollars = double.parse(cryptoValues[gameData['coin']]) * (0.00000001) * earnings;
|
||||
Debug.Log(rewardInDollars);
|
||||
currentEarnings += rewardInDollars;
|
||||
});
|
||||
currentEarnings = currentEarnings;
|
||||
CryptoEarnings = _ThisSeasonCryptoEarnings;
|
||||
GamesEarnings = _ThisSeasonGamesEarnings;
|
||||
Debug.Log(_ThisSeasonCryptoEarnings);
|
||||
|
||||
// return true;
|
||||
}catch(e){
|
||||
Debug.LogError("Error at calculating earnings from games $e");
|
||||
|
||||
// return false;
|
||||
}
|
||||
}
|
||||
|
||||
static Future<void> ClaimChallenge(dynamic challengeData) async{
|
||||
Map<String,String> body = <String, String>{
|
||||
"game_code": challengeData['game'],
|
||||
"id": UserJson['id'],
|
||||
"challenge_id" : challengeData['id']
|
||||
};
|
||||
var response = (await http.post(
|
||||
Uri.parse('${API_ENDPOINT}claim_challenge.php'),
|
||||
body: body));
|
||||
Debug.Log("Challenges response: " +response.body.toString());
|
||||
try{
|
||||
dynamic newEarnings = jsonDecode(response.body.toString());
|
||||
UserJson['earnings'] = response.body.toString();
|
||||
await GetChallenges();
|
||||
CalculateEarnings();
|
||||
}catch(e){
|
||||
Debug.LogError("Error claiming challenge : ${challengeData}");
|
||||
Debug.LogError(body);
|
||||
Debug.LogError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -60,17 +60,17 @@ class Helpers{
|
||||
}
|
||||
}
|
||||
|
||||
// static double CryptoToDollars({required double amount, required String Crypto}){
|
||||
// if(Hoarder.cryptoRates==null){Debug.Log("Crypto rates haven't been updated yet"); return 0;}
|
||||
// Debug.Log(Hoarder.cryptoRates);
|
||||
// if(Hoarder.cryptoRates[Crypto] == null){
|
||||
// Debug.Log("$Crypto not found in ${Hoarder.cryptoRates}");
|
||||
// return 0;
|
||||
// }
|
||||
// return amount * double.parse(Hoarder.cryptoRates[Crypto]);
|
||||
// }
|
||||
//
|
||||
// static double SatsToCoin(int sats){
|
||||
// return sats.toDouble() * 0.00000001;
|
||||
// }
|
||||
static double CryptoToDollars({required double amount, required String Crypto}){
|
||||
if(DataManager.cryptoRates==null){Debug.Log("Crypto rates haven't been updated yet"); return 0;}
|
||||
Debug.Log(DataManager.cryptoRates);
|
||||
if(DataManager.cryptoRates[Crypto] == null){
|
||||
Debug.Log("$Crypto not found in ${DataManager.cryptoRates}");
|
||||
return 0;
|
||||
}
|
||||
return amount * double.parse(DataManager.cryptoRates[Crypto]);
|
||||
}
|
||||
|
||||
static double SatsToCoin(int sats){
|
||||
return sats.toDouble() * 0.00000001;
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ class LoginManager {
|
||||
try{
|
||||
if(prefs.containsKey("googleLogin")){
|
||||
if(prefs.getBool("googleLogin") ?? false){
|
||||
|
||||
return await GoogleLogin(prefs.getString("username")!.replaceAll("#0", ""));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
108
lib/gameInfo.dart
Normal file
108
lib/gameInfo.dart
Normal file
@@ -0,0 +1,108 @@
|
||||
import 'package:external_app_launcher/external_app_launcher.dart';
|
||||
import 'package:fhub/backend/DataManager.dart';
|
||||
import 'package:fhub/backend/helpers.dart';
|
||||
import 'package:fhub/src/CustomWidgets.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class GameInfoPage extends StatefulWidget {
|
||||
const GameInfoPage({Key? key, required this.gameJson}) : super(key: key);
|
||||
final dynamic gameJson;
|
||||
@override
|
||||
State<GameInfoPage> createState() => _GameInfoPageState();
|
||||
}
|
||||
|
||||
class _GameInfoPageState extends State<GameInfoPage> {
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
super.initState();
|
||||
kickstartAnimations();
|
||||
}
|
||||
|
||||
void kickstartAnimations() async {
|
||||
await Future.delayed(const Duration(milliseconds: 500));
|
||||
|
||||
setState(() {
|
||||
op1 = 0.5;
|
||||
op2 = 0.5;
|
||||
op3 = 0.5;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
bool linked = DataManager.LinkedGamesJson.contains(widget.gameJson);
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.black,
|
||||
body: CustomBody(child: SafeArea(child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
InkWell(child: Container(margin:EdgeInsets.all(10), child: Icon(Icons.keyboard_arrow_left,size: 50)), onTap: (){Navigator.of(context).pop();},),
|
||||
GradientText(
|
||||
text: widget.gameJson['name'],
|
||||
gradient: LinearGradient(colors: [
|
||||
Colors.white.withOpacity(0.6),
|
||||
Colors.white.withOpacity(0.5),
|
||||
Colors.white.withOpacity(0.2)
|
||||
]),
|
||||
style: TextStyle(fontSize: 33, fontWeight: FontWeight.bold),
|
||||
),
|
||||
Container(width: 40,)
|
||||
],
|
||||
),
|
||||
SizedBox(height: 50,),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
Container(
|
||||
width: 120,
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
child: Image.network(widget.gameJson['icon']))),
|
||||
Column(
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
Text("Earn"),
|
||||
Text("${widget.gameJson['coin']}", style: TextStyle(fontSize: 25,fontWeight: FontWeight.bold),),
|
||||
],
|
||||
),SizedBox(height: 10,), Icon(Helpers.GetIconForCrypto(widget.gameJson['coin']),size: 50)
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
SizedBox(height: 50,),
|
||||
GlassButton(onTap: ()async{
|
||||
await LaunchApp.openApp(
|
||||
androidPackageName: widget.gameJson['link'],
|
||||
// openStore: false
|
||||
);
|
||||
}, child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
Icon(Icons.g_mobiledata_rounded,size: 40),
|
||||
Text("Open on Playstore"),
|
||||
],
|
||||
), width: 200,height: 50),
|
||||
SizedBox(height: 35,),
|
||||
Text(widget.gameJson['description'],textAlign: TextAlign.center),
|
||||
SizedBox(height: 20,),
|
||||
(linked) ? Container(child: Text("\nThis game is already linked to this FH account.\n\nYour Earnings from game will be accounted to this FH account",textAlign: TextAlign.center,),) :Column(
|
||||
children: [
|
||||
Text("Your FH ID"),
|
||||
Text(DataManager.UserJson['id'], style: TextStyle(fontSize: 50, fontWeight: FontWeight.bold)),
|
||||
SizedBox(height: 20,),
|
||||
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 '${DataManager.UserJson['id']}' As FH ID.\n\n Then enjoy your earnings from playing this game!",textAlign: TextAlign.center)
|
||||
],
|
||||
),
|
||||
],),
|
||||
),
|
||||
)), context: context, onAnimEnd: (){setState(() {});}),
|
||||
);
|
||||
}
|
||||
}
|
||||
613
lib/home.dart
613
lib/home.dart
@@ -1,6 +1,16 @@
|
||||
import 'package:animated_text_kit/animated_text_kit.dart';
|
||||
import 'package:fhub/backend/DataManager.dart';
|
||||
import 'package:fhub/backend/DebugHelper.dart';
|
||||
import 'package:fhub/backend/Dialogs.dart';
|
||||
import 'package:fhub/gameInfo.dart';
|
||||
import 'package:fhub/src/CustomWidgets.dart';
|
||||
import 'package:fhub/welcome.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter_spinkit/flutter_spinkit.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import 'backend/helpers.dart';
|
||||
|
||||
class Home extends StatefulWidget {
|
||||
const Home({Key? key}) : super(key: key);
|
||||
@@ -54,6 +64,15 @@ class _HomeState extends State<Home> {
|
||||
});
|
||||
},
|
||||
),
|
||||
BottomNavBarItem(
|
||||
icon: Icons.gamepad_outlined,
|
||||
active: selectedPageId == 3,
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
TitleText = "Games";
|
||||
selectedPageId = 3;
|
||||
});
|
||||
}),
|
||||
BottomNavBarItem(
|
||||
icon: Icons.wallet,
|
||||
active: selectedPageId == 1,
|
||||
@@ -73,23 +92,587 @@ class _HomeState extends State<Home> {
|
||||
});
|
||||
}),
|
||||
],
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(children: [
|
||||
Center(
|
||||
child:
|
||||
AnimatedSwitcher(
|
||||
duration: Duration(milliseconds: 300),
|
||||
transitionBuilder:
|
||||
(Widget child, Animation<double> animation) {
|
||||
return FadeTransition(child: child,opacity: Tween<double>(begin: 0, end: 1).animate(animation));
|
||||
},
|
||||
child:
|
||||
GradientText(key: ValueKey<String>(TitleText),text: TitleText,gradient: LinearGradient(colors: [Colors.deepPurpleAccent, Colors.purple,Colors.purpleAccent]),style: TextStyle(fontSize: 45,fontWeight: FontWeight.bold),),
|
||||
))
|
||||
]),
|
||||
child: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(children: [
|
||||
Center(
|
||||
child: AnimatedSwitcher(
|
||||
duration: Duration(milliseconds: 300),
|
||||
transitionBuilder: (Widget child, Animation<double> animation) {
|
||||
return FadeTransition(
|
||||
child: child,
|
||||
opacity:
|
||||
Tween<double>(begin: 0, end: 1).animate(animation));
|
||||
},
|
||||
child: GradientText(
|
||||
key: ValueKey<String>(TitleText),
|
||||
text: TitleText,
|
||||
gradient: LinearGradient(colors: [
|
||||
Colors.white.withOpacity(0.6),
|
||||
Colors.white.withOpacity(0.5),
|
||||
Colors.white.withOpacity(0.2)
|
||||
]),
|
||||
style: TextStyle(fontSize: 45, fontWeight: FontWeight.bold),
|
||||
),
|
||||
)),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 20),
|
||||
child: GetCurrentBody(),
|
||||
)
|
||||
]),
|
||||
),
|
||||
),
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
Widget GetCurrentBody() {
|
||||
switch (selectedPageId) {
|
||||
case 1:
|
||||
return wallet();
|
||||
case 3:
|
||||
return games();
|
||||
case 2:
|
||||
return settings();
|
||||
default:
|
||||
return home();
|
||||
}
|
||||
}
|
||||
|
||||
double screenHeight = 0;
|
||||
double screenWidth = 0;
|
||||
Widget home() {
|
||||
screenHeight = MediaQuery.of(context).size.height;
|
||||
screenWidth = MediaQuery.of(context).size.width;
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
InkWell(
|
||||
onTap: () {
|
||||
selectedPageId = 1;
|
||||
setState(() {});
|
||||
},
|
||||
child: TotalEarningsCard()),
|
||||
SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
GlassCard(
|
||||
child: Container(
|
||||
width: screenWidth * 0.9,
|
||||
padding: EdgeInsets.all(20),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
Text("Challenges"),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
(DataManager.Challenges.length > 0)
|
||||
? ListView.builder(
|
||||
physics: NeverScrollableScrollPhysics(),
|
||||
shrinkWrap: true,
|
||||
itemCount: DataManager.Challenges.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
dynamic gameJson = Helpers.GetGameFromCode(
|
||||
DataManager.Challenges[index][0]['game'] ??
|
||||
'spaceio');
|
||||
|
||||
return ChallengeList(
|
||||
gameName: gameJson['name'],
|
||||
coin: gameJson['coin'],
|
||||
challengesInfo: [
|
||||
ListView.builder(
|
||||
physics: NeverScrollableScrollPhysics(),
|
||||
shrinkWrap: true,
|
||||
itemCount:
|
||||
DataManager.Challenges[index].length,
|
||||
itemBuilder:
|
||||
(BuildContext context, int index2) {
|
||||
return ChallengeProgress(DataManager
|
||||
.Challenges[index][index2]);
|
||||
},
|
||||
)
|
||||
]);
|
||||
},
|
||||
)
|
||||
: Column(
|
||||
children: [
|
||||
Text(
|
||||
"\nComplete Challenges in Games and\n EARN CRYPTO!\n\nLink a Game to receive Challenges!",
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
GlassButton(
|
||||
color: Colors.lightBlueAccent,
|
||||
onTap: () {
|
||||
setState(() {
|
||||
selectedPageId = 3;
|
||||
});
|
||||
},
|
||||
child: Text(
|
||||
"Get Started!",
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 17),
|
||||
),
|
||||
width: 200,
|
||||
height: 40)
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget games() {
|
||||
return Column(
|
||||
children: [
|
||||
Align(alignment: Alignment.topLeft, child: Text("Linked Games")),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
(DataManager.LinkedGamesJson.length > 0)
|
||||
? GridView.builder(
|
||||
shrinkWrap: true,
|
||||
itemCount: DataManager.LinkedGamesJson.length,
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 2,
|
||||
crossAxisSpacing: 10.0,
|
||||
mainAxisSpacing: 10.0),
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return GameCard(
|
||||
list: DataManager.LinkedGamesJson, index: index);
|
||||
},
|
||||
)
|
||||
: GlassCard(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(15.0),
|
||||
child: Text(
|
||||
"Install a game from the list below and Link it to FaucetHub(FH) to Start Earning!",style: TextStyle(color: Colors.blue.withGreen(150).withRed(100)),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
)),
|
||||
SizedBox(
|
||||
height: 25,
|
||||
),
|
||||
Align(alignment: Alignment.topLeft, child: Text("Non-Linked Games")),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
GridView.builder(
|
||||
shrinkWrap: true,
|
||||
itemCount: DataManager.NonLinkedGamesJson.length,
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 2, crossAxisSpacing: 10.0, mainAxisSpacing: 10.0),
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return GameCard(list: DataManager.NonLinkedGamesJson, index: index);
|
||||
},
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget GameCard({required int index, required List<dynamic> list}) {
|
||||
return GlassCard(
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
Navigator.of(context).push(MaterialPageRoute(
|
||||
builder: (BuildContext context) =>
|
||||
GameInfoPage(gameJson: list[index])));
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(12),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
list[index]['name'],
|
||||
style: TextStyle(fontSize: 16),
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
Container(
|
||||
width: 50,
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
child: Image.network(list[index]['icon']))),
|
||||
Icon(Helpers.GetIconForCrypto(list[index]['coin']))
|
||||
],
|
||||
),
|
||||
Text(list[index]['description'], style: TextStyle(fontSize: 13)),
|
||||
],
|
||||
),
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
Widget TotalEarningsCard() {
|
||||
return GlassCard(
|
||||
child: Container(
|
||||
// height: screenHeight * 0.18,
|
||||
width: screenWidth * 0.9,
|
||||
padding: EdgeInsets.all(20),
|
||||
child: Column(
|
||||
children: [
|
||||
Text("Total Earnings"),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Text('~ \$${DataManager.currentEarnings.toStringAsFixed(2)} ',
|
||||
style: TextStyle(fontSize: 50)),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
ScrollController scrollController = ScrollController();
|
||||
bool sortByGames = true;
|
||||
Widget wallet() {
|
||||
return Column(
|
||||
children: [
|
||||
TotalEarningsCard(),
|
||||
(DataManager.currentEarnings <=0) ? Container() : Column(children: [
|
||||
SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text("Sort earnings by "),
|
||||
SizedBox(
|
||||
width: 20,
|
||||
),
|
||||
GlassCard(
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(vertical: 8.0, horizontal: 15),
|
||||
child: Row(
|
||||
children: [
|
||||
InkWell(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
sortByGames = true;
|
||||
});
|
||||
},
|
||||
child: GlassCard(
|
||||
highlighted: sortByGames,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(
|
||||
vertical: 8, horizontal: 20),
|
||||
child: Text("Games"),
|
||||
))),
|
||||
SizedBox(
|
||||
width: 5,
|
||||
),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
sortByGames = false;
|
||||
});
|
||||
},
|
||||
child: GlassCard(
|
||||
highlighted: !sortByGames,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(
|
||||
vertical: 8, horizontal: 20),
|
||||
child: Text("Earnings"),
|
||||
))),
|
||||
],
|
||||
),
|
||||
))
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
GlassCard(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
children: [
|
||||
sortByGames
|
||||
? ListView.builder(
|
||||
shrinkWrap: true,
|
||||
controller: scrollController,
|
||||
itemCount: DataManager.GamesEarnings.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
String gameName =
|
||||
DataManager.GamesEarnings.keys.elementAt(index);
|
||||
dynamic GameJson = Helpers.GetGameFromCode(gameName);
|
||||
if (GameJson == null) {
|
||||
Debug.LogError(
|
||||
("Error getting game json from ${gameName}. returned:\n$GameJson"));
|
||||
return GlassCard(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(16),
|
||||
child: Text(
|
||||
"Error",
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
));
|
||||
}
|
||||
double amount = Helpers.SatsToCoin(DataManager
|
||||
.GamesEarnings.values
|
||||
.elementAt(index));
|
||||
|
||||
return WalletGameListItem(GameJson, amount);
|
||||
})
|
||||
: ListView.builder(
|
||||
shrinkWrap: true,
|
||||
controller: scrollController,
|
||||
itemCount: DataManager.CryptoEarnings.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return WalletCurrencyListItem(
|
||||
DataManager.CryptoEarnings.keys.elementAt(index));
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
))
|
||||
])
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget WalletGameListItem(dynamic GameJson, double amount) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(3.0),
|
||||
child: GlassCard(
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
children: [SizedBox(width: 100, child: Text(GameJson['name']))],
|
||||
),
|
||||
Text(
|
||||
"~\$${Helpers.CryptoToDollars(amount: amount, Crypto: GameJson['coin']).toStringAsFixed(2)}"),
|
||||
Row(
|
||||
children: [
|
||||
Text("${amount.toStringAsFixed(8)}"),
|
||||
SizedBox(
|
||||
width: 5,
|
||||
),
|
||||
Icon(Helpers.GetIconForCrypto(GameJson['coin']))
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
Widget WalletCurrencyListItem(String coin) {
|
||||
double amount = Helpers.SatsToCoin(DataManager.CryptoEarnings[coin] ?? 0);
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(3.0),
|
||||
child: GlassCard(
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
children: [SizedBox(width: 100, child: Text(coin))],
|
||||
),
|
||||
Text(
|
||||
"~\$${Helpers.CryptoToDollars(amount: amount, Crypto: coin).toStringAsFixed(2)}"),
|
||||
Row(
|
||||
children: [
|
||||
Text("${amount.toStringAsFixed(8)}"),
|
||||
SizedBox(
|
||||
width: 5,
|
||||
),
|
||||
Icon(Helpers.GetIconForCrypto(coin))
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
)),
|
||||
);
|
||||
}
|
||||
TextEditingController TxtCoinbaseAddress = TextEditingController();
|
||||
Widget settings() {
|
||||
TxtCoinbaseAddress.text = "sewmina7@gmail.com";
|
||||
return Column(
|
||||
children: [
|
||||
GlassCard(child: Padding(padding: EdgeInsets.all(15), child: Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text("Coinbase Address"),
|
||||
InkWell(onTap: (){Dialogs.showAlertDialog(context, "Coinbase Address", "Withdrawals will be accounted to this address");},child: Icon(Icons.help))
|
||||
],
|
||||
),
|
||||
TextField(controller: TxtCoinbaseAddress,)
|
||||
],
|
||||
),)),
|
||||
SizedBox(height: 10,),
|
||||
InkWell(
|
||||
onTap: ()async{
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
prefs.clear();
|
||||
|
||||
Navigator.of(context).pushAndRemoveUntil(MaterialPageRoute(builder: (context) =>
|
||||
MyHomePage()), (Route<dynamic> route) => false);
|
||||
},
|
||||
child: GlassCard(child: Padding(
|
||||
padding: const EdgeInsets.all(15.0),
|
||||
child: Row(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Icon(Icons.logout),
|
||||
SizedBox(width: 10,),
|
||||
Text("Signout"),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
)),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget ChallengeList(
|
||||
{required String gameName,
|
||||
required String coin,
|
||||
required List<Widget> challengesInfo}) {
|
||||
return GlassCard(
|
||||
child: Container(
|
||||
width: screenWidth * 0.8,
|
||||
padding: EdgeInsets.all(15),
|
||||
child: Column(children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(gameName, style: TextStyle(fontSize: 16)),
|
||||
Row(
|
||||
children: [Icon(Helpers.GetIconForCrypto(coin)), Text(" $coin")],
|
||||
)
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Column(
|
||||
children: challengesInfo,
|
||||
)
|
||||
]),
|
||||
));
|
||||
}
|
||||
|
||||
Widget ChallengeProgress(dynamic ChallengeData) {
|
||||
int value = int.parse(ChallengeData['current'].toString());
|
||||
int max = int.parse(ChallengeData['total'].toString());
|
||||
String reward = ChallengeData['reward'];
|
||||
bool isDone = value >= max;
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 2.0, vertical: 5),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Icon(Icons.diamond),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(ChallengeData['name'], style: TextStyle(fontSize: 13)),
|
||||
isDone
|
||||
? SizedBox(
|
||||
width: 80,
|
||||
child: Text(
|
||||
"$reward Sats",
|
||||
style:
|
||||
TextStyle(fontSize: 15, color: Colors.greenAccent),
|
||||
textAlign: TextAlign.end,
|
||||
))
|
||||
: GlassProgressBar(
|
||||
width: screenWidth * 0.4, value: value / max)
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
!isDone
|
||||
? Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 80,
|
||||
child: Text(
|
||||
"$reward Sats",
|
||||
style: TextStyle(
|
||||
fontSize: 15, color: Colors.greenAccent),
|
||||
textAlign: TextAlign.end,
|
||||
)),
|
||||
SizedBox(
|
||||
width: 80,
|
||||
child: Text(
|
||||
"$value/$max",
|
||||
style: TextStyle(fontSize: 12),
|
||||
textAlign: TextAlign.end,
|
||||
)),
|
||||
],
|
||||
)
|
||||
: Container(
|
||||
padding: EdgeInsets.fromLTRB(10, 5, 0, 0),
|
||||
child: GlassButton(
|
||||
onTap: () async {
|
||||
Debug.Log("Button");
|
||||
setState(() {});
|
||||
|
||||
showDialog(
|
||||
context: context!,
|
||||
barrierDismissible: false,
|
||||
routeSettings:
|
||||
const RouteSettings(name: "Progress"),
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
// backgroundColor: Colors.deepPurpleAccent,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius:
|
||||
BorderRadius.circular(30)),
|
||||
title: Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
SpinKitDualRing(
|
||||
color: Colors.deepPurpleAccent),
|
||||
Expanded(
|
||||
child: Text(
|
||||
"Loading",
|
||||
textAlign: TextAlign.center,
|
||||
)),
|
||||
],
|
||||
),
|
||||
);
|
||||
});
|
||||
await DataManager.ClaimChallenge(ChallengeData);
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
Navigator.of(context).pop();
|
||||
|
||||
setState(() {});
|
||||
},
|
||||
child: Text("Claim"),
|
||||
width: 80,
|
||||
color: Colors.greenAccent),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
|
||||
|
||||
import 'dart:math';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
double op1 = 0;
|
||||
double op2 = 0;
|
||||
double op3 = 0;
|
||||
Widget CustomBody({required Widget child,required BuildContext context, required Function() onAnimEnd, List<BottomNavBarItem>? bottomNav}) {
|
||||
Widget CustomBody(
|
||||
{required Widget child,
|
||||
required BuildContext context,
|
||||
required Function() onAnimEnd,
|
||||
List<BottomNavBarItem>? bottomNav}) {
|
||||
Duration opDuration = const Duration(milliseconds: 1500);
|
||||
var random = new Random();
|
||||
|
||||
|
||||
final screenHeight = MediaQuery.of(context).size.height;
|
||||
final screenWidth = MediaQuery.of(context).size.width;
|
||||
|
||||
@@ -35,7 +37,7 @@ Widget CustomBody({required Widget child,required BuildContext context, required
|
||||
shape: BoxShape.circle,
|
||||
gradient: RadialGradient(
|
||||
colors: [
|
||||
Colors.blue.withOpacity(0.3 + (op1/3)),
|
||||
Colors.blue.withOpacity(0.3 + (op1 / 3)),
|
||||
Colors.blue.withOpacity(op1),
|
||||
Colors.deepPurpleAccent.withOpacity(op1)
|
||||
],
|
||||
@@ -43,8 +45,8 @@ Widget CustomBody({required Widget child,required BuildContext context, required
|
||||
),
|
||||
child: BackdropFilter(
|
||||
filter: ImageFilter.blur(sigmaX: 200, sigmaY: 200),
|
||||
child: Container(
|
||||
height: 200, width: 200, color: Colors.transparent),
|
||||
child:
|
||||
Container(height: 200, width: 200, color: Colors.transparent),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -55,8 +57,9 @@ Widget CustomBody({required Widget child,required BuildContext context, required
|
||||
duration: opDuration,
|
||||
onEnd: () {
|
||||
// setState(() {
|
||||
op2 = (random.nextDouble() / 2) + 0.5;
|
||||
log(op2); onAnimEnd();
|
||||
op2 = (random.nextDouble() / 2) + 0.5;
|
||||
log(op2);
|
||||
onAnimEnd();
|
||||
|
||||
// });
|
||||
},
|
||||
@@ -74,8 +77,8 @@ Widget CustomBody({required Widget child,required BuildContext context, required
|
||||
),
|
||||
child: BackdropFilter(
|
||||
filter: ImageFilter.blur(sigmaX: 200, sigmaY: 200),
|
||||
child: Container(
|
||||
height: 200, width: 200, color: Colors.transparent),
|
||||
child:
|
||||
Container(height: 200, width: 200, color: Colors.transparent),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -86,8 +89,9 @@ Widget CustomBody({required Widget child,required BuildContext context, required
|
||||
duration: opDuration,
|
||||
onEnd: () {
|
||||
// setState(() {
|
||||
op3 = (random.nextDouble() / 2) + 0.5;
|
||||
log(op3); onAnimEnd();
|
||||
op3 = (random.nextDouble() / 2) + 0.5;
|
||||
log(op3);
|
||||
onAnimEnd();
|
||||
|
||||
// });
|
||||
},
|
||||
@@ -105,46 +109,56 @@ Widget CustomBody({required Widget child,required BuildContext context, required
|
||||
),
|
||||
child: BackdropFilter(
|
||||
filter: ImageFilter.blur(sigmaX: 200, sigmaY: 200),
|
||||
child: Container(
|
||||
height: 200, width: 200, color: Colors.transparent),
|
||||
child:
|
||||
Container(height: 200, width: 200, color: Colors.transparent),
|
||||
),
|
||||
),
|
||||
),
|
||||
(bottomNav != null) ? Positioned(
|
||||
bottom: 20,
|
||||
right: screenWidth * 0.15,
|
||||
child: Container(
|
||||
width: screenWidth * 0.7,
|
||||
height: 70,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black,
|
||||
borderRadius: BorderRadius.circular(50),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black26, offset: Offset.fromDirection(1, 2))
|
||||
]),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: bottomNav,
|
||||
)),
|
||||
) : Container(),
|
||||
AnimatedContainer(duration: opDuration,child: child)
|
||||
Container(
|
||||
margin: const EdgeInsets.fromLTRB(0,0,0,50),
|
||||
child: AnimatedContainer(duration: opDuration, child: child),
|
||||
),
|
||||
(bottomNav != null)
|
||||
? Positioned(
|
||||
bottom: 20,
|
||||
right: screenWidth * 0.15,
|
||||
child: Container(
|
||||
width: screenWidth * 0.7,
|
||||
height: 70,
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [
|
||||
Colors.white.withOpacity(0.12),
|
||||
Colors.white.withOpacity(0.05)
|
||||
]
|
||||
),
|
||||
borderRadius: BorderRadius.circular(50),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black26,
|
||||
offset: Offset.fromDirection(1, 2))
|
||||
]),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: bottomNav,
|
||||
)),
|
||||
)
|
||||
: Container(),
|
||||
]));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Widget NeonButton(
|
||||
{required void Function() onPressed,
|
||||
required String text,
|
||||
double width = 250,
|
||||
double height = 50,
|
||||
double fontSize = 20,
|
||||
List<Color>? colors,
|
||||
Widget? trailing,
|
||||
Widget? heading}) {
|
||||
if(colors == null){
|
||||
required String text,
|
||||
double width = 250,
|
||||
double height = 50,
|
||||
double fontSize = 20,
|
||||
List<Color>? colors,
|
||||
Widget? trailing,
|
||||
Widget? heading}) {
|
||||
if (colors == null) {
|
||||
colors = [Colors.blue, Colors.deepPurple];
|
||||
}
|
||||
return Padding(
|
||||
@@ -191,8 +205,65 @@ Widget NeonButton(
|
||||
);
|
||||
}
|
||||
|
||||
Widget GlassButton({Color color = Colors.white,double height = 30,required Function() onTap, required Widget child, required double width}){
|
||||
return InkWell(
|
||||
onTap: onTap,
|
||||
child: Container(width: width,height: height, decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
gradient: LinearGradient(begin: Alignment.topLeft, end: Alignment.bottomCenter, colors: [color.withOpacity(0.3), color.withOpacity(0.1)]),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black26,
|
||||
offset: Offset.fromDirection(1, 2))
|
||||
],
|
||||
),
|
||||
child: Align(alignment: Alignment.center,child: child),),
|
||||
);
|
||||
}
|
||||
|
||||
Widget GlassCard({bool highlighted = false,required Widget child}) {
|
||||
return Container(
|
||||
// padding: EdgeInsets.all(30),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [
|
||||
Colors.white.withOpacity(highlighted ? 0.4 : 0.12),
|
||||
Colors.white.withOpacity(highlighted? 0.15:0.05),
|
||||
]),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black26,
|
||||
offset: Offset.fromDirection(1, 2))
|
||||
],
|
||||
|
||||
),
|
||||
child: child);
|
||||
}
|
||||
|
||||
Widget GlassProgressBar({double height = 10, required double width, required double value}){
|
||||
return Stack(
|
||||
children: [
|
||||
Container(width: width,height: height,decoration: BoxDecoration(
|
||||
gradient: LinearGradient(begin: Alignment.centerLeft, end: Alignment.centerRight, colors: [Colors.white.withOpacity(0.3), Colors.white.withOpacity(0.1)]),borderRadius: BorderRadius.circular(10)
|
||||
),),
|
||||
Container(width: width * value ,height: height,decoration: BoxDecoration(
|
||||
gradient: LinearGradient(begin: Alignment.centerLeft, end: Alignment.centerRight, colors: [Colors.white.withOpacity(0.6), Colors.white.withOpacity(0.4)]),borderRadius: BorderRadius.circular(10)
|
||||
),)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
class BottomNavBarItem extends StatelessWidget {
|
||||
BottomNavBarItem({required this.active,required IconData this.icon, String? this.text, required Function() this.onPressed,});
|
||||
BottomNavBarItem({
|
||||
required this.active,
|
||||
required IconData this.icon,
|
||||
String? this.text,
|
||||
required Function() this.onPressed,
|
||||
});
|
||||
IconData icon;
|
||||
String? text;
|
||||
Function() onPressed;
|
||||
@@ -201,7 +272,7 @@ class BottomNavBarItem extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
// TODO: implement build
|
||||
return InkWell(
|
||||
onTap: (){
|
||||
onTap: () {
|
||||
onPressed();
|
||||
},
|
||||
child: Container(
|
||||
@@ -210,8 +281,12 @@ class BottomNavBarItem extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
AnimatedSize(duration: const Duration(milliseconds: 300),child: Icon(icon,size:active ? 45 : 25, color: active ? Colors.deepPurpleAccent : Colors.blue)),
|
||||
(text!=null) ? Text(text!) : Container()
|
||||
AnimatedSize(
|
||||
duration: const Duration(milliseconds: 300),
|
||||
child: Icon(icon,
|
||||
size: active ? 45 : 25,
|
||||
color: active ? Colors.blueAccent : Colors.white.withOpacity(0.8))),
|
||||
(text != null) ? Text(text!) : Container()
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -220,11 +295,12 @@ class BottomNavBarItem extends StatelessWidget {
|
||||
}
|
||||
|
||||
class GradientText extends StatelessWidget {
|
||||
const GradientText(
|
||||
{super.key, required this.text,
|
||||
required this.gradient,
|
||||
this.style,
|
||||
});
|
||||
const GradientText({
|
||||
super.key,
|
||||
required this.text,
|
||||
required this.gradient,
|
||||
this.style,
|
||||
});
|
||||
|
||||
final String text;
|
||||
final TextStyle? style;
|
||||
@@ -240,4 +316,4 @@ class GradientText extends StatelessWidget {
|
||||
child: Text(text, style: style),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,6 +81,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.5"
|
||||
external_app_launcher:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: external_app_launcher
|
||||
sha256: fb55cddd706c62ede11056750d5e018ef379820e09739e967873211dd537d833
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.1.0"
|
||||
fake_async:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@@ -39,6 +39,7 @@ dependencies:
|
||||
firebase_auth: ^4.2.5
|
||||
animated_text_kit: ^4.2.2
|
||||
cupertino_icons: ^1.0.2
|
||||
external_app_launcher: ^3.1.0
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
||||
Reference in New Issue
Block a user