mhunt_launcher/lib/Widgets/Home/AccountsPage/AccountsPage.dart
2024-10-29 00:12:00 +05:30

168 lines
5.3 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:toastification/toastification.dart';
import 'package:url_launcher/url_launcher_string.dart';
import '../../../Backend/Backend.dart';
import '../../CustomWidgets.dart';
import 'BuyDialog.dart';
Widget AccountPage(BuildContext context, Function onUpdate) {
return Padding(
padding: const EdgeInsets.all(25.0),
child: 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: [
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),
),
Row(
children: [
Icon(
Icons.airplane_ticket_rounded,
color: Colors.amber,
size: 35,
),
Text(
Backend.TicketsBalance.toString(),
style: TextStyle(fontSize: 50),
),
],
),
GlassButton(
onTap: () {
Navigator.of(context).restorablePush(buyTicketsDialogBuilder);
}, 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)
],
),
);
}