feat: overhaul My Profile dialog

This commit is contained in:
Garrett Watson 2024-02-16 10:39:59 -05:00
parent 85a3d65d23
commit bcff2214aa
2 changed files with 160 additions and 94 deletions

View file

@ -46,23 +46,15 @@ class PersonalProfile {
bool get isPatreonSupporter =>
supporterMetadata.whereType<PatreonSupporter>().any((element) => element.isActiveSupporter);
static final List<AccountType> accountTypes = [
AccountType(label: "Standard Account", color: const Color(0xFF86888B)),
AccountType(label: "Patreon Supporter", color: const Color(0xFFFF7676)),
AccountType(label: "Resonite Mentor", color: const Color(0xFF59EB5C)),
AccountType(label: "Resonite Moderator", color: const Color(0xFF61D1FA)),
AccountType(label: "Resonite Team", color: const Color.fromARGB(255, 255, 230, 0)),
];
AccountType get accountType => tags.contains("team member")
? accountTypes[4]
? AccountType(label: "Resonite Team", color: const Color.fromARGB(255, 255, 230, 0))
: tags.contains("moderator")
? accountTypes[3]
? AccountType(label: "Resonite Moderator", color: const Color(0xFF61D1FA))
: tags.contains("mentor")
? accountTypes[2]
? AccountType(label: "Resonite Mentor", color: const Color(0xFF59EB5C))
: isPatreonSupporter
? accountTypes[1]
: accountTypes[0];
? AccountType(label: "Patreon Supporter", color: const Color(0xFFFF7676))
: AccountType(label: "Standard Account", color: const Color(0xFF86888B));
}
class AccountType {

View file

@ -33,21 +33,29 @@ class _MyProfileDialogState extends State<MyProfileDialog> {
@override
Widget build(BuildContext context) {
final tt = Theme.of(context).textTheme;
final textTheme = Theme.of(context).textTheme;
DateFormat dateFormat = DateFormat.yMd();
return Dialog(
clipBehavior: Clip.antiAlias,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
backgroundColor: const Color(0xFF11151D),
child: FutureBuilder(
future: _personalProfileFuture,
builder: (context, snapshot) {
if (snapshot.hasData) {
final profile = snapshot.data as PersonalProfile;
return Padding(
padding: const EdgeInsets.all(24),
padding: const EdgeInsets.only(bottom: 16),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
Container(
padding: const EdgeInsets.all(16),
decoration: const BoxDecoration(
color: Color(0x6611151D),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
@ -60,69 +68,118 @@ class _MyProfileDialogState extends State<MyProfileDialog> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(profile.username, style: tt.titleLarge),
Text(profile.username, style: textTheme.titleLarge),
Text(
profile.accountType.label,
style: tt.labelMedium?.copyWith(color: profile.accountType.color),
style: textTheme.labelMedium?.copyWith(color: profile.accountType.color),
),
],
)),
],
),
),
const SizedBox(
height: 16,
height: 12,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"User ID: ",
style: tt.labelLarge,
"Account Info",
style: textTheme.titleMedium,
),
Text(profile.id)
],
const SizedBox(
height: 8,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
ClipRRect(
borderRadius: BorderRadius.circular(8),
child: Container(
width: double.infinity,
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
color: const Color(0x6611151D),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Email: ",
style: tt.labelLarge,
"User ID",
style: textTheme.titleSmall,
),
Text(profile.email)
Text(profile.id,
style: textTheme.bodySmall?.copyWith(color: const Color(0xFFE1E1E0)))
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
const SizedBox(
height: 8,
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Patreon Supporter: ",
style: tt.labelLarge,
"Email",
style: textTheme.titleSmall,
),
Text(profile.isPatreonSupporter ? "Yes" : "No")
Text(profile.email,
style: textTheme.bodySmall?.copyWith(color: const Color(0xFFE1E1E0)))
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
const SizedBox(
height: 8,
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"2FA: ",
style: tt.labelLarge,
"Patreon Supporter",
style: textTheme.titleSmall,
),
Text(profile.twoFactor ? "Enabled" : "Disabled")
Text(profile.isPatreonSupporter ? "Yes" : "No",
style: textTheme.bodySmall?.copyWith(color: const Color(0xFFE1E1E0)))
],
),
const SizedBox(
height: 8,
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Two Factor Authentication",
style: textTheme.titleSmall,
),
Text(profile.twoFactor ? "Enabled" : "Disabled",
style: textTheme.bodySmall?.copyWith(color: const Color(0xFFE1E1E0)))
],
),
])),
),
],
),
),
if (profile.publicBanExpiration?.isAfter(DateTime.now()) ?? false)
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Ban Expiration: ",
style: tt.labelLarge,
style: textTheme.labelLarge,
),
Text(dateFormat.format(profile.publicBanExpiration!))
],
),
const SizedBox(
height: 12,
),
FutureBuilder(
future: _storageQuotaFuture,
builder: (context, snapshot) {
@ -132,9 +189,6 @@ class _MyProfileDialogState extends State<MyProfileDialog> {
maxBytes: storage?.fullQuotaBytes ?? 1,
);
}),
const SizedBox(
height: 12,
),
],
),
);
@ -179,28 +233,48 @@ class StorageIndicator extends StatelessWidget {
Widget build(BuildContext context) {
final value = usedBytes / maxBytes;
return Padding(
padding: const EdgeInsets.only(top: 16.0),
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text("Storage:", style: Theme.of(context).textTheme.titleMedium),
Text(// Displayed in GiB instead of GB for consistency with Resonite
"${(usedBytes * 9.3132257461548e-10).toStringAsFixed(2)}/${(maxBytes * 9.3132257461548e-10).toStringAsFixed(2)} GB"),
],
),
Text("Storage", style: Theme.of(context).textTheme.titleMedium),
const SizedBox(
height: 8,
),
ClipRRect(
borderRadius: BorderRadius.circular(8),
child: LinearProgressIndicator(
minHeight: 12,
color: value > 0.95 ? Theme.of(context).colorScheme.error : null,
child: Stack(children: [
LinearProgressIndicator(
value: value,
minHeight: 48,
color: value > 0.95 ? Theme.of(context).colorScheme.error : const Color(0xFF61D1FA),
backgroundColor: const Color(0xFF284C5D),
),
Container(
height: 48,
padding: const EdgeInsets.symmetric(horizontal: 12),
alignment: Alignment.center,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
"${(value * 100).toStringAsFixed(0)}%",
style: Theme.of(context).textTheme.titleMedium?.copyWith(fontWeight: FontWeight.bold),
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
// Displayed in GiB instead of GB for consistency with Resonite
Text(
"${(usedBytes * 9.3132257461548e-10).toStringAsFixed(2)} GB of ${(maxBytes * 9.3132257461548e-10).toStringAsFixed(2)} GB"),
Text("Storage Space Used",
style: Theme.of(context).textTheme.labelSmall?.copyWith(fontSize: 10)),
]),
],
)),
]),
)
],
),