340 lines
12 KiB
Dart
340 lines
12 KiB
Dart
// import 'package:crypto_font_icons/crypto_font_icons.dart';
|
|
import 'package:crypto_font_icons/crypto_font_icons.dart';
|
|
import 'package:faucethub/Backend/DebugHelper.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 'Backend/helpers.dart';
|
|
|
|
class HomePage extends StatefulWidget {
|
|
const HomePage({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<HomePage> createState() => _HomePageState();
|
|
}
|
|
|
|
int selectedBotNavIndex = 0;
|
|
|
|
class _HomePageState extends State<HomePage> {
|
|
|
|
@override
|
|
void initState() {
|
|
// TODO: implement initState
|
|
super.initState();
|
|
|
|
}
|
|
|
|
Widget HomeWidget() {
|
|
final ScrollController _firstController = ScrollController();
|
|
return SingleChildScrollView(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
Container(
|
|
padding: EdgeInsets.all(20),
|
|
child: Text("Welcome ${Brain.UserJson['name']},",
|
|
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: "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 GamesWidget() {
|
|
final ScrollController scrollController = ScrollController();
|
|
return Container(
|
|
padding: EdgeInsets.fromLTRB(20, 20, 0, 20),
|
|
child: SingleChildScrollView(
|
|
physics: ScrollPhysics(),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: <Widget>[
|
|
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: () {},
|
|
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: () {},
|
|
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.UserJson['name']),
|
|
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<Widget> 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>[
|
|
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(() {});
|
|
}
|
|
}
|