feat: replace mail protocol with smolmail and rebuild the UI
This commit is contained in:
parent
cb24b68069
commit
e94e4158cc
93 changed files with 6387 additions and 3479 deletions
|
|
@ -1,34 +1,32 @@
|
|||
import "package:flutter_riverpod/flutter_riverpod.dart";
|
||||
import "package:flutter/material.dart";
|
||||
|
||||
import "package:flash_mail/data/providers/providers.dart";
|
||||
import "package:flash_mail/presentation/widgets/drawer/user_profile.dart";
|
||||
import "package:flash_mail/presentation/widgets/drawer/drawer_list.dart";
|
||||
import "package:flash_mail/presentation/widgets/drawer/user_quota.dart";
|
||||
import "package:smol_mail/data/providers/providers.dart";
|
||||
import "package:smol_mail/smol/proto.dart";
|
||||
import "package:smol_mail/presentation/widgets/drawer/identity_header.dart";
|
||||
import "package:smol_mail/presentation/widgets/drawer/drawer_list.dart";
|
||||
import "package:smol_mail/presentation/theme/app_colors.dart";
|
||||
|
||||
class AppDrawer extends ConsumerWidget {
|
||||
const AppDrawer({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final account = ref.read(accountProvider);
|
||||
final identity = ref.watch(identityProvider);
|
||||
final account = ref.watch(accountProvider);
|
||||
final address = account?.short ?? "";
|
||||
final fp = identity == null ? "" : fingerprint(identity.publicKey);
|
||||
|
||||
return Drawer(
|
||||
backgroundColor: const Color.fromRGBO(22, 39, 56, 1),
|
||||
backgroundColor: Theme.of(context).extension<AppColors>()!.cardFill,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(top: 90),
|
||||
padding: const EdgeInsets.only(top: 60),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
UserProfile(
|
||||
email: account.user!.email,
|
||||
password: account.user!.password,
|
||||
),
|
||||
IdentityHeader(address: address, fingerprint: fp),
|
||||
const SizedBox(height: 50),
|
||||
const DrawerList(),
|
||||
UserQuota(
|
||||
value: account.user!.used / account.user!.quota,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -1,24 +1,19 @@
|
|||
import "package:flutter/material.dart";
|
||||
import "package:flutter_riverpod/flutter_riverpod.dart";
|
||||
import "package:auto_route/auto_route.dart";
|
||||
|
||||
import "package:flash_mail/data/providers/providers.dart";
|
||||
import "package:flash_mail/shared/configs/flash_mail_icons.dart";
|
||||
import "package:flash_mail/presentation/widgets/drawer/drawer_list_tile.dart";
|
||||
import "package:smol_mail/data/providers/providers.dart";
|
||||
import "package:smol_mail/presentation/routes/app_router.gr.dart";
|
||||
import "package:auto_route/auto_route.dart";
|
||||
import "package:smol_mail/shared/configs/flash_mail_icons.dart";
|
||||
import "package:smol_mail/presentation/widgets/drawer/drawer_list_tile.dart";
|
||||
|
||||
class DrawerList extends ConsumerWidget {
|
||||
const DrawerList({super.key});
|
||||
|
||||
Future<void> signOut(BuildContext context, WidgetRef ref) async {
|
||||
Navigator.of(context).pop();
|
||||
await ref.read(accountProvider.notifier).logout();
|
||||
if (context.mounted) {
|
||||
AutoRouter.of(context).replaceNamed("/");
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final unread = ref.watch(unreadProvider);
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(left: 25),
|
||||
child: Column(
|
||||
|
|
@ -26,16 +21,40 @@ class DrawerList extends ConsumerWidget {
|
|||
DrawerListTile(
|
||||
color: Theme.of(context).primaryColor,
|
||||
icon: FlashMailIcons.inbox,
|
||||
title: "Inbox",
|
||||
onTap: () => Navigator.of(context).pop(),
|
||||
title: "Inbox${unread > 0 ? " ($unread)" : ""}",
|
||||
onTap: () {
|
||||
ref.read(folderProvider.notifier).select("inbox");
|
||||
ref.read(revisionProvider.notifier).bump();
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
Consumer(
|
||||
builder: (context, ref, _) => DrawerListTile(
|
||||
color: Theme.of(context).colorScheme.error,
|
||||
icon: FlashMailIcons.sign_out,
|
||||
title: "Sign out",
|
||||
onTap: () => signOut(context, ref),
|
||||
),
|
||||
DrawerListTile(
|
||||
color: Theme.of(context).primaryColor,
|
||||
icon: Icons.outgoing_mail,
|
||||
title: "Sent",
|
||||
onTap: () {
|
||||
ref.read(folderProvider.notifier).select("sent");
|
||||
ref.read(revisionProvider.notifier).bump();
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
DrawerListTile(
|
||||
color: Theme.of(context).primaryColor,
|
||||
icon: Icons.contacts,
|
||||
title: "Contacts",
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
AutoRouter.of(context).push(ContactsRoute());
|
||||
},
|
||||
),
|
||||
DrawerListTile(
|
||||
color: Theme.of(context).primaryColor,
|
||||
icon: Icons.settings,
|
||||
title: "Settings",
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
AutoRouter.of(context).push(SettingsRoute());
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
import "package:flutter/material.dart";
|
||||
|
||||
import "package:smol_mail/presentation/theme/app_colors.dart";
|
||||
|
||||
class DrawerListTile extends StatelessWidget {
|
||||
final Color color;
|
||||
final IconData icon;
|
||||
|
|
@ -16,10 +18,11 @@ class DrawerListTile extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final appColors = Theme.of(context).extension<AppColors>()!;
|
||||
return Theme(
|
||||
data: Theme.of(context).copyWith(
|
||||
splashColor: const Color.fromRGBO(40, 70, 100, 1),
|
||||
highlightColor: const Color.fromRGBO(22, 39, 56, 1),
|
||||
splashColor: appColors.highlight,
|
||||
highlightColor: appColors.cardFill,
|
||||
),
|
||||
child: ListTile(
|
||||
onTap: onTap,
|
||||
|
|
|
|||
64
lib/presentation/widgets/drawer/identity_header.dart
Normal file
64
lib/presentation/widgets/drawer/identity_header.dart
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
import "package:flutter/material.dart";
|
||||
|
||||
import "package:smol_mail/shared/utils/format.dart";
|
||||
|
||||
/// Identity summary in the drawer: the address is what gets shared, the
|
||||
/// fingerprint is what gets verified.
|
||||
class IdentityHeader extends StatelessWidget {
|
||||
final String address;
|
||||
final String fingerprint;
|
||||
|
||||
const IdentityHeader({
|
||||
super.key,
|
||||
required this.address,
|
||||
required this.fingerprint,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: <Widget>[
|
||||
CircleAvatar(
|
||||
backgroundColor: Theme.of(context).primaryColor,
|
||||
radius: 35,
|
||||
child: Text(
|
||||
address.isEmpty ? "?" : address[0].toUpperCase(),
|
||||
style:
|
||||
Theme.of(context).textTheme.bodyLarge!.copyWith(fontSize: 30),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
InkWell(
|
||||
onTap: () => copyText(context, address),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Text(
|
||||
address.isEmpty ? "(not registered)" : address,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w900,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
InkWell(
|
||||
onTap: () => copyText(context, fingerprint),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Text(
|
||||
"fp: $fingerprint",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
import "package:flutter/material.dart";
|
||||
import "package:flash/flash.dart";
|
||||
|
||||
class ToastMessage extends StatelessWidget {
|
||||
final FlashController controller;
|
||||
final IconData icon;
|
||||
final String text;
|
||||
|
||||
const ToastMessage({
|
||||
super.key,
|
||||
required this.controller,
|
||||
required this.icon,
|
||||
required this.text,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Flash(
|
||||
position: FlashPosition.bottom,
|
||||
controller: controller,
|
||||
child: AlertDialog(
|
||||
alignment: Alignment.bottomCenter,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
backgroundColor: const Color.fromRGBO(217, 217, 217, 1),
|
||||
content: Row(
|
||||
children: [
|
||||
Icon(
|
||||
icon,
|
||||
color: Colors.black,
|
||||
),
|
||||
const SizedBox(width: 20),
|
||||
Text(
|
||||
text,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodySmall!
|
||||
.copyWith(color: Colors.black),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
import "package:flutter/material.dart";
|
||||
import "package:flutter/services.dart";
|
||||
import "package:flash/flash.dart";
|
||||
|
||||
import "package:flash_mail/presentation/widgets/drawer/toast_message.dart";
|
||||
|
||||
class UserProfile extends StatelessWidget {
|
||||
final String email;
|
||||
final String password;
|
||||
|
||||
const UserProfile({
|
||||
super.key,
|
||||
required this.email,
|
||||
required this.password,
|
||||
});
|
||||
|
||||
Future<void> copyClipboard(BuildContext context, String text) async {
|
||||
await Clipboard.setData(ClipboardData(text: text));
|
||||
if (context.mounted) {
|
||||
showFlash(
|
||||
context: context,
|
||||
duration: const Duration(seconds: 2),
|
||||
builder: (context, controller) => ToastMessage(
|
||||
controller: controller,
|
||||
icon: Icons.check,
|
||||
text: "Copied to Clipboard!",
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: <Widget>[
|
||||
CircleAvatar(
|
||||
backgroundColor: Theme.of(context).primaryColor,
|
||||
radius: 35,
|
||||
child: Text(
|
||||
email[0].toUpperCase(),
|
||||
style:
|
||||
Theme.of(context).textTheme.bodyLarge!.copyWith(fontSize: 30),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
InkWell(
|
||||
onTap: () => copyClipboard(context, email),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Text(
|
||||
email,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w900,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
InkWell(
|
||||
onTap: () => copyClipboard(context, password),
|
||||
child: Text(
|
||||
"password: $password",
|
||||
style: const TextStyle(
|
||||
color: Color.fromRGBO(127, 133, 141, 1),
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w900,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,71 +0,0 @@
|
|||
import "package:flutter/material.dart";
|
||||
import "package:url_launcher/url_launcher.dart";
|
||||
|
||||
import "package:flash_mail/shared/configs/flash_mail_icons.dart";
|
||||
|
||||
class UserQuota extends StatelessWidget {
|
||||
final String _url = "https://mail.tm/";
|
||||
|
||||
final double value;
|
||||
|
||||
const UserQuota({super.key, required this.value});
|
||||
|
||||
Future<void> openUrl(Uri url) async {
|
||||
if (await canLaunchUrl(url)) {
|
||||
launchUrl(url);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(bottom: 30, left: 40, right: 40),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Quota",
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).primaryColor,
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
LinearProgressIndicator(
|
||||
backgroundColor: const Color.fromRGBO(85, 97, 112, 1),
|
||||
color: Theme.of(context).primaryColor,
|
||||
value: value,
|
||||
minHeight: 10,
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
),
|
||||
const SizedBox(height: 25),
|
||||
InkWell(
|
||||
onTap: () => openUrl(Uri.parse(_url)),
|
||||
highlightColor: Colors.transparent,
|
||||
splashColor: Colors.transparent,
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
"Powered By Mail.tm",
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).primaryColor,
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Icon(
|
||||
FlashMailIcons.redirect,
|
||||
color: Theme.of(context).primaryColor,
|
||||
size: 16,
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue