FaucetHub/lib/game_page.dart

98 lines
3.8 KiB
Dart

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