217 lines
7.5 KiB
Dart
217 lines
7.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:mhunt_launcher/Shared/Helpers.dart';
|
|
import 'package:mhunt_launcher/Shared/TextStyles.dart';
|
|
import 'package:mhunt_launcher/login.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
import 'package:toastification/toastification.dart';
|
|
import 'package:url_launcher/url_launcher_string.dart';
|
|
|
|
import '../../../Backend/Backend.dart';
|
|
import '../../../Shared/Dialogs.dart';
|
|
import '../../CustomWidgets.dart';
|
|
import 'BuyDialog.dart';
|
|
|
|
Widget AccountPage(BuildContext context, Function onUpdate) {
|
|
return Padding(
|
|
padding: const EdgeInsets.all(25.0),
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Column(
|
|
children: [
|
|
Row(
|
|
children: [
|
|
Text("Hello, ${Backend.displayName}",
|
|
style: TextStyle(fontSize: 30)),
|
|
],
|
|
),
|
|
SizedBox(
|
|
height: 100,
|
|
),
|
|
GlassCard(
|
|
child: Container(
|
|
padding: const EdgeInsets.all(12.0),
|
|
margin: const EdgeInsets.symmetric(horizontal: 50),
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
InkWell(
|
|
onTap: (){
|
|
launchUrlString('https://explorer.solana.com/address/${Backend.pubKey}?cluster=devnet');
|
|
},
|
|
child: Column(
|
|
children: [
|
|
Text("Solana Wallet Address", style: TextStyles.title2BTextStyle,),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Text(Backend.pubKey),
|
|
InkWell(
|
|
onTap: ()async {
|
|
await Clipboard.setData(ClipboardData(text: Backend.pubKey));
|
|
toastification.show(
|
|
context: context, // optional if you use ToastificationWrapper
|
|
title: Text('Wallet address copied to clipboard'),
|
|
autoCloseDuration: const Duration(seconds: 2),
|
|
style: ToastificationStyle.simple,
|
|
);
|
|
},
|
|
child: Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 10),
|
|
child: Icon(Icons.copy),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
SizedBox(width: 50,),
|
|
Row(
|
|
children: [
|
|
Column(
|
|
children: [
|
|
Text("SOL Balance", style: TextStyles.title2BTextStyle,),
|
|
|
|
Text('${Helpers.trimTrailingZeros(Backend.SolBalance / Helpers.LAMPORTS_PER_SOL).toString()} SOL')
|
|
],
|
|
),
|
|
InkWell(
|
|
onTap: ()async{
|
|
await Backend.GetWalletBalance();
|
|
onUpdate();
|
|
},
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: Icon(Icons.refresh),
|
|
),
|
|
)
|
|
],
|
|
)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 20,
|
|
),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Column(
|
|
children: [
|
|
Text(
|
|
"Vault Credits",
|
|
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15),
|
|
),
|
|
Row(
|
|
children: [
|
|
Image.asset(
|
|
'images/vault.png',
|
|
width: 40,
|
|
height: 40,
|
|
),
|
|
Text(
|
|
Backend.vault.php.toString(),
|
|
style: TextStyle(fontSize: 50),
|
|
),
|
|
],
|
|
)
|
|
],
|
|
),
|
|
SizedBox(
|
|
width: 60,
|
|
),
|
|
Column(
|
|
children: [
|
|
Text(
|
|
"Tickets",
|
|
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15),
|
|
),
|
|
InkWell(
|
|
onTap: (){
|
|
launchUrlString('https://explorer.solana.com/address/${Backend.ticketsATA}?cluster=devnet');
|
|
},
|
|
child: Row(
|
|
children: [
|
|
Icon(
|
|
Icons.airplane_ticket_rounded,
|
|
color: Colors.amber,
|
|
size: 35,
|
|
),
|
|
Text(
|
|
Backend.TicketsBalance.toString(),
|
|
style: TextStyle(fontSize: 50),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
GlassButton(
|
|
onTap: (){OnPurchaseClicked(context);}, child: Text("Buy Tickets"), width: 100)
|
|
],
|
|
),
|
|
],
|
|
),
|
|
SizedBox(
|
|
height: 50,
|
|
),
|
|
GlassButton(
|
|
onTap: () {
|
|
launchUrlString(Helpers.DASHBOARD_URL);
|
|
},
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Text("Open Dashboard"),
|
|
SizedBox(
|
|
width: 10,
|
|
),
|
|
Icon(Icons.open_in_new, color: Colors.grey)
|
|
],
|
|
),
|
|
width: 250,
|
|
height: 50),
|
|
|
|
],
|
|
|
|
),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Container(),
|
|
GlassButton(
|
|
color: Colors.red,
|
|
onTap: ()async {
|
|
var prefs = await SharedPreferences.getInstance();
|
|
prefs.clear();
|
|
|
|
Navigator.of(context).pushReplacement(MaterialPageRoute(builder: (context) => LoginPage()));
|
|
},
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Text("Logout"),
|
|
SizedBox(
|
|
width: 10,
|
|
),
|
|
Icon(Icons.logout, color: Colors.grey)
|
|
],
|
|
),
|
|
width: 150,
|
|
height: 50),
|
|
],
|
|
)
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
|
|
void OnPurchaseClicked(BuildContext context){
|
|
Navigator.of(context).restorablePush(buyTicketsDialogBuilder);
|
|
}
|
|
|
|
|
|
|