WIP: folders actions #5
@ -18,9 +18,11 @@ import 'dart:js' as js;
|
|||||||
class ApiService {
|
class ApiService {
|
||||||
static String ip = "";
|
static String ip = "";
|
||||||
static String port = "";
|
static String port = "";
|
||||||
static List<AttachmentResponse> threadAttachments = [];
|
static List<AttachmentResponse> threadAttachments =
|
||||||
|
[]; //holds attachments of the thread
|
||||||
static String currFolder = "";
|
static String currFolder = "";
|
||||||
static List<String> currThread = [];
|
static List<String> currThread = []; //holds the email ids of the thread
|
||||||
|
static String currThreadID = ""; //picked an email it prints the threadID
|
||||||
|
|
||||||
Future<List<GetThreadResponse>> fetchEmailsFromFolder(
|
Future<List<GetThreadResponse>> fetchEmailsFromFolder(
|
||||||
String folder, int pagenitaion) async {
|
String folder, int pagenitaion) async {
|
||||||
@ -31,7 +33,6 @@ class ApiService {
|
|||||||
'offset': pagenitaion.toString(),
|
'offset': pagenitaion.toString(),
|
||||||
});
|
});
|
||||||
var response = await http.get(url);
|
var response = await http.get(url);
|
||||||
// print(response);
|
|
||||||
List<GetThreadResponse> allEmails = [];
|
List<GetThreadResponse> allEmails = [];
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
@ -122,8 +123,8 @@ class ApiService {
|
|||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
content += response.body;
|
content += response.body;
|
||||||
try {
|
try {
|
||||||
List<AttachmentInfo> attachments = await getAttachmentsInfo(
|
List<AttachmentInfo> attachments =
|
||||||
emailFolder, id);
|
await getAttachmentsInfo(emailFolder, id);
|
||||||
for (var attachment in attachments) {
|
for (var attachment in attachments) {
|
||||||
//TODO: for each attachment creaate at the bottom a widget for each individual one
|
//TODO: for each attachment creaate at the bottom a widget for each individual one
|
||||||
threadAttachments
|
threadAttachments
|
||||||
@ -143,10 +144,71 @@ class ApiService {
|
|||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
// void _addMailBox async(BuildContext context){
|
Future<List<SerializableMessage>> threadsInSerializable(
|
||||||
// //add email folder
|
String thread_id) async {
|
||||||
// showDialog(context: context, builder: builder)
|
// grab all of the emails in thread anyways, for the future it'll come in handy
|
||||||
// }
|
var url = Uri.http('$ip:$port', 'get_thread_messages', {'id': thread_id});
|
||||||
|
try {
|
||||||
|
var response = await http.get(url);
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
List json = jsonDecode(response.body);
|
||||||
|
List<SerializableMessage> serializableMessages = [];
|
||||||
|
for (var mail in json) {
|
||||||
|
serializableMessages.add(SerializableMessage.fromJson(mail));
|
||||||
|
}
|
||||||
|
return serializableMessages;
|
||||||
|
} else {
|
||||||
|
print(
|
||||||
|
"failed get request with status code ${response.statusCode}, and body ${response.body}");
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
print("caught in threadInSerializable method error: $e");
|
||||||
|
}
|
||||||
|
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<bool> moveEmail(
|
||||||
|
//only moves the first email of the thread //or perhaps should do the last
|
||||||
|
String fromFolder,
|
||||||
|
String thread_id,
|
||||||
|
String toFolder) async {
|
||||||
|
var url = Uri.http('$ip:$port', 'move_email');
|
||||||
|
|
||||||
|
List<SerializableMessage> mailsInSerializable =
|
||||||
|
await this.threadsInSerializable(thread_id);
|
||||||
|
|
||||||
|
if (mailsInSerializable.isEmpty) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
SerializableMessage firstMail = mailsInSerializable[0];
|
||||||
|
|
||||||
|
Map<String, String> requestBody = {
|
||||||
|
'from': fromFolder,
|
||||||
|
'uid': firstMail.uid.toString(),
|
||||||
|
'to': toFolder,
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
var response = await http.post(
|
||||||
|
url,
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
body: jsonEncode(requestBody),
|
||||||
|
);
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
print('response body ${response.body}');
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
print('error ${response.statusCode} ${response.body}');
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
print("failed trying to post move_email, with error: $e");
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
Future<List<String>> fetchFolders() async {
|
Future<List<String>> fetchFolders() async {
|
||||||
try {
|
try {
|
||||||
@ -182,6 +244,31 @@ class ApiService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> renameFolder(String oldFolder, String newFolder) async {
|
||||||
|
var url = Uri.http('$ip:$port', 'rename_folder');
|
||||||
|
Map<String, String> requestBody = {
|
||||||
|
'old_name': oldFolder,
|
||||||
|
'new_name': newFolder,
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
var response = await http.post(
|
||||||
|
url,
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
body: jsonEncode(requestBody),
|
||||||
|
);
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
print('response body: ${response.body}');
|
||||||
|
} else {
|
||||||
|
print('Error: ${response.statusCode}, response body: ${response.body}');
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
print('error making post req: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> deleteFolder(String folderName) async {
|
Future<void> deleteFolder(String folderName) async {
|
||||||
var url = Uri.http('$ip:$port', 'delete_folder');
|
var url = Uri.http('$ip:$port', 'delete_folder');
|
||||||
|
|
||||||
@ -206,13 +293,6 @@ class ApiService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> logIn(String json) async {
|
Future<bool> logIn(String json) async {
|
||||||
// var url = Uri.https('')
|
|
||||||
// try{
|
|
||||||
// String response = await http.post(
|
|
||||||
// url
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -251,7 +331,6 @@ class ApiService {
|
|||||||
var response = await http.get(url);
|
var response = await http.get(url);
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
var result = response.body;
|
var result = response.body;
|
||||||
// print(result);
|
|
||||||
Map<String, dynamic> attachmentData = json.decode(result);
|
Map<String, dynamic> attachmentData = json.decode(result);
|
||||||
AttachmentResponse data = AttachmentResponse.fromJson(attachmentData);
|
AttachmentResponse data = AttachmentResponse.fromJson(attachmentData);
|
||||||
print("data $data");
|
print("data $data");
|
||||||
@ -268,7 +347,6 @@ class ApiService {
|
|||||||
//leads to problems as for a) the html is added one right after the other in one iframe, b)
|
//leads to problems as for a) the html is added one right after the other in one iframe, b)
|
||||||
// if it was multiple iframes then the scrolling to jump would not work as expected
|
// if it was multiple iframes then the scrolling to jump would not work as expected
|
||||||
|
|
||||||
|
|
||||||
print("marker called");
|
print("marker called");
|
||||||
// JavaScript code embedded as a string
|
// JavaScript code embedded as a string
|
||||||
String jsCode = '''
|
String jsCode = '''
|
||||||
@ -379,7 +457,7 @@ class _EmailViewState extends State<EmailView> {
|
|||||||
String currentContent = widget.emailContent;
|
String currentContent = widget.emailContent;
|
||||||
viewTypeId = "iframe-${DateTime.now().millisecondsSinceEpoch}";
|
viewTypeId = "iframe-${DateTime.now().millisecondsSinceEpoch}";
|
||||||
_registerViewFactory(currentContent);
|
_registerViewFactory(currentContent);
|
||||||
_markerPositionsFuture = ApiService().getMarkerPosition();
|
_markerPositionsFuture = ApiService().getMarkerPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
void _registerViewFactory(String currentContent) {
|
void _registerViewFactory(String currentContent) {
|
||||||
@ -403,7 +481,8 @@ class _EmailViewState extends State<EmailView> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
// print(currentContent);
|
// print("thread id ${widget.id}");
|
||||||
|
ApiService.currThreadID = widget.id;
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text(widget.name),
|
title: Text(widget.name),
|
||||||
|
280
lib/email.dart
280
lib/email.dart
@ -1,136 +1,144 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'api_service.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
import 'structs.dart';
|
import 'api_service.dart';
|
||||||
|
import 'structs.dart';
|
||||||
class EmailListScreen extends StatelessWidget {
|
|
||||||
final List<GetThreadResponse> emails;
|
class EmailListScreen extends StatelessWidget {
|
||||||
final Future<String> Function(List<String>, String) getEmailContent;
|
final List<GetThreadResponse> emails;
|
||||||
final String folder;
|
final Future<String> Function(List<String>, String) getEmailContent;
|
||||||
|
final String folder;
|
||||||
|
|
||||||
EmailListScreen({required this.emails, required this.getEmailContent, required this.folder});
|
EmailListScreen(
|
||||||
//fix the email list
|
{required this.emails,
|
||||||
@override
|
required this.getEmailContent,
|
||||||
Widget build(BuildContext context) {
|
required this.folder});
|
||||||
return Scaffold(
|
//fix the email list
|
||||||
body: ListView.separated(
|
@override
|
||||||
itemCount: emails.length,
|
Widget build(BuildContext context) {
|
||||||
itemBuilder: (context, index) {
|
return Scaffold(
|
||||||
final email = emails[index];
|
body: ListView.separated(
|
||||||
return ListTile(
|
itemCount: emails.length,
|
||||||
title: Text(email.from_name,
|
itemBuilder: (context, index) {
|
||||||
style: TextStyle(fontWeight: FontWeight.bold)),
|
final email = emails[index];
|
||||||
subtitle: Column(
|
return ListTile(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
title: Text(email.from_name,
|
||||||
children: [Text(email.subject)],
|
style: TextStyle(fontWeight: FontWeight.bold)),
|
||||||
),
|
subtitle: Column(
|
||||||
trailing: Text(email.date.toString()),
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
onTap: () async {
|
children: [Text(email.subject)],
|
||||||
String emailContent = await getEmailContent(email.messages, folder);
|
),
|
||||||
Navigator.push(
|
trailing: Text(email.date.toString()),
|
||||||
context,
|
onTap: () async {
|
||||||
MaterialPageRoute(
|
String emailContent =
|
||||||
builder: (context) => EmailView(
|
await getEmailContent(email.messages, folder);
|
||||||
emailContent: emailContent,
|
Navigator.push(
|
||||||
from: email.from_address,
|
context,
|
||||||
name: email.from_name,
|
MaterialPageRoute(
|
||||||
to: email.to.toString(),
|
builder: (context) => EmailView(
|
||||||
subject: email.subject,
|
emailContent: emailContent,
|
||||||
date: email.date.toString(),
|
from: email.from_address,
|
||||||
id: email.id.toString(),
|
name: email.from_name,
|
||||||
),
|
to: email.to.toString(),
|
||||||
),
|
subject: email.subject,
|
||||||
);
|
date: email.date.toString(),
|
||||||
},
|
id: email.id.toString(), //i think this is thread id?
|
||||||
);
|
),
|
||||||
},
|
),
|
||||||
separatorBuilder: (context, index) => Divider(),
|
);
|
||||||
),
|
},
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
}
|
separatorBuilder: (context, index) => Divider(),
|
||||||
|
),
|
||||||
// ignore: must_be_immutable
|
);
|
||||||
class EmailPage extends StatefulWidget {
|
}
|
||||||
EmailPage({Key? key}) : super(key: key);
|
}
|
||||||
String selectedFolder = "INBOX"; //starter
|
|
||||||
int offset = 0;
|
// ignore: must_be_immutable
|
||||||
int page = 1;
|
class EmailPage extends StatefulWidget {
|
||||||
|
EmailPage({Key? key}) : super(key: key);
|
||||||
@override
|
String selectedFolder = "INBOX"; //starter
|
||||||
EmailPageState createState() => EmailPageState();
|
int offset = 0;
|
||||||
}
|
int page = 1;
|
||||||
|
|
||||||
class EmailPageState extends State<EmailPage> {
|
@override
|
||||||
final ApiService apiService = ApiService();
|
EmailPageState createState() => EmailPageState();
|
||||||
List<GetThreadResponse> emails = [];
|
}
|
||||||
int page = 1;
|
|
||||||
bool isBackDisabled = false;
|
class EmailPageState extends State<EmailPage> {
|
||||||
|
final ApiService apiService = ApiService();
|
||||||
@override
|
List<GetThreadResponse> emails = [];
|
||||||
void initState() {
|
ValueNotifier<int> currentPageNotifier = ValueNotifier<int>(1);
|
||||||
super.initState();
|
int page = 1;
|
||||||
widget.page = page;
|
bool isBackDisabled = false;
|
||||||
isBackDisabled = true;
|
|
||||||
}
|
@override
|
||||||
|
void initState() {
|
||||||
void updateSelectedFolder(String folder) {
|
super.initState();
|
||||||
setState(() {
|
widget.page = page;
|
||||||
widget.selectedFolder = folder;
|
isBackDisabled = true;
|
||||||
});
|
_fetchEmails();
|
||||||
print(folder);
|
}
|
||||||
_fetchEmails();
|
|
||||||
}
|
String getPage() => widget.page.toString();
|
||||||
|
bool get backDisabled => isBackDisabled;
|
||||||
String getPage() {
|
|
||||||
return widget.page.toString();
|
void updateSelectedFolder(String folder) {
|
||||||
}
|
setState(() {
|
||||||
|
widget.selectedFolder = folder;
|
||||||
void updatePagenation(String option) {
|
});
|
||||||
if (option == "next") {
|
print(folder);
|
||||||
setState(() {
|
_fetchEmails();
|
||||||
widget.offset += 50;
|
}
|
||||||
widget.page += 1;
|
|
||||||
isBackDisabled = false;
|
// String getPage() => widget.page.toString();
|
||||||
});
|
|
||||||
} else if (option == "back") {
|
void updatePagenation(String option) {
|
||||||
setState(() {
|
if (option == "next") {
|
||||||
widget.offset -= 50;
|
setState(() {
|
||||||
widget.page -= 1;
|
widget.offset += 50;
|
||||||
if (widget.page == 1) {
|
widget.page += 1;
|
||||||
isBackDisabled = true;
|
currentPageNotifier.value = widget.page;
|
||||||
print("back dis");
|
isBackDisabled = false;
|
||||||
}
|
});
|
||||||
});
|
} else if (option == "back") {
|
||||||
}
|
setState(() {
|
||||||
// print(currentPage);
|
widget.offset -= 50;
|
||||||
_fetchEmails();
|
widget.page -= 1;
|
||||||
}
|
currentPageNotifier.value = widget.page;
|
||||||
|
if (widget.page == 1) {
|
||||||
void _fetchEmails() async {
|
isBackDisabled = true;
|
||||||
// print(selectedFolder)
|
print("back disabled");
|
||||||
try {
|
}
|
||||||
List<GetThreadResponse> fetchedEmails = await apiService
|
});
|
||||||
.fetchEmailsFromFolder(widget.selectedFolder, widget.offset);
|
}
|
||||||
if (!mounted) return;
|
// print(currentPage);
|
||||||
|
print(widget.page);
|
||||||
setState(() {
|
_fetchEmails();
|
||||||
emails = fetchedEmails; // Update the list of emails
|
}
|
||||||
});
|
|
||||||
} catch (e) {
|
void _fetchEmails() async {
|
||||||
print('Error fetching emails: $e');
|
try {
|
||||||
}
|
List<GetThreadResponse> fetchedEmails = await apiService
|
||||||
}
|
.fetchEmailsFromFolder(widget.selectedFolder, widget.offset);
|
||||||
|
if (!mounted) return;
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
setState(() {
|
||||||
_fetchEmails();
|
emails = fetchedEmails; // Update the list of emails
|
||||||
return Scaffold(
|
});
|
||||||
body: EmailListScreen(
|
} catch (e) {
|
||||||
emails: emails,
|
print('Error fetching emails: $e');
|
||||||
getEmailContent: apiService.fetchEmailContent,
|
}
|
||||||
folder: widget.selectedFolder,//try to grab from it directly
|
}
|
||||||
),
|
|
||||||
);
|
@override
|
||||||
}
|
Widget build(BuildContext context) {
|
||||||
}
|
return Scaffold(
|
||||||
|
body: EmailListScreen(
|
||||||
|
emails: emails,
|
||||||
|
getEmailContent: apiService.fetchEmailContent,
|
||||||
|
folder: widget.selectedFolder, //try to grab from it directly
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -16,6 +16,7 @@ class FolderDrawer extends StatefulWidget {
|
|||||||
|
|
||||||
class _FolderDrawerState extends State<FolderDrawer> {
|
class _FolderDrawerState extends State<FolderDrawer> {
|
||||||
List<String> folders = [];
|
List<String> folders = [];
|
||||||
|
final TextEditingController _renameController = TextEditingController();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -48,7 +49,7 @@ class _FolderDrawerState extends State<FolderDrawer> {
|
|||||||
icon: Icon(Icons.more_vert),
|
icon: Icon(Icons.more_vert),
|
||||||
onPressed: () => {
|
onPressed: () => {
|
||||||
///show options
|
///show options
|
||||||
_showOptions(context)
|
_showOptions(context, folder)
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
@ -65,7 +66,7 @@ class _FolderDrawerState extends State<FolderDrawer> {
|
|||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return NewMailbox(apiService: widget.apiService);
|
return NewMailbox(apiService: widget.apiService);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
// Navigator.of(context).pop();
|
// Navigator.of(context).pop();
|
||||||
@ -83,39 +84,105 @@ class _FolderDrawerState extends State<FolderDrawer> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
void _showOptions(BuildContext context) async {
|
|
||||||
final RenderBox overlay = Overlay.of(context).context.findRenderObject() as RenderBox;
|
|
||||||
|
|
||||||
await showMenu<String>(
|
|
||||||
context: context,
|
|
||||||
position: RelativeRect.fromLTRB(100, 100, overlay.size.width, overlay.size.height),
|
|
||||||
items: <PopupMenuEntry<String>>[
|
|
||||||
PopupMenuItem<String>(
|
|
||||||
value: 'Rename',
|
|
||||||
child: Text('Rename Folder'),
|
|
||||||
),
|
|
||||||
PopupMenuItem<String>(
|
|
||||||
value: 'Delete',
|
|
||||||
child: Text('Delete Folder'),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
).then((value) {
|
|
||||||
// Handle the action based on the selected menu item
|
|
||||||
if (value == 'Rename') {
|
|
||||||
// Logic for renaming the folder
|
|
||||||
print('Rename folder');
|
|
||||||
} else if (value == 'Delete') {
|
|
||||||
// Logic for deleting the folder
|
|
||||||
print('Delete folder');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
Future<bool> _renameDialog(String oldFolder) async {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return AlertDialog(
|
||||||
|
title: Text("Rename Mailbox"),
|
||||||
|
content: TextField(
|
||||||
|
controller: _renameController,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
hintText: "New Name",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
actions: <Widget>[
|
||||||
|
TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
String newfolderName = _renameController.text;
|
||||||
|
if (newfolderName.isNotEmpty) {
|
||||||
|
//make an and to make sure there's two folders with the same name
|
||||||
|
ApiService().renameFolder(oldFolder, newfolderName);
|
||||||
|
}
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
child: const Text("Rename"),
|
||||||
|
),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
child: const Text("Cancel"),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> doubleCheckDelete(String folderTobeDeleted) async {
|
||||||
|
return showDialog<void>(
|
||||||
|
context: context,
|
||||||
|
barrierDismissible: false,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return AlertDialog(
|
||||||
|
title: Text("Confirm delete of: $folderTobeDeleted"),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
ApiService().deleteFolder(folderTobeDeleted);
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
child: Text("Yes")),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
child: Text("No")),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _showOptions(BuildContext context, String folderName) async {
|
||||||
|
final RenderBox overlay =
|
||||||
|
Overlay.of(context).context.findRenderObject() as RenderBox;
|
||||||
|
print(folderName);
|
||||||
|
await showMenu<String>(
|
||||||
|
context: context,
|
||||||
|
position: RelativeRect.fromLTRB(
|
||||||
|
100, 100, overlay.size.width, overlay.size.height),
|
||||||
|
items: <PopupMenuEntry<String>>[
|
||||||
|
PopupMenuItem<String>(
|
||||||
|
value: 'Rename',
|
||||||
|
child: Text('Rename Folder'),
|
||||||
|
),
|
||||||
|
PopupMenuItem<String>(
|
||||||
|
value: 'Delete',
|
||||||
|
child: Text('Delete Folder'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
).then((value) {
|
||||||
|
// Handle the action based on the selected menu item
|
||||||
|
if (value == 'Rename') {
|
||||||
|
// Logic for renaming the folder
|
||||||
|
print('Rename folder $folderName');
|
||||||
|
_renameDialog(folderName);
|
||||||
|
} else if (value == 'Delete') {
|
||||||
|
// Logic for deleting the folder
|
||||||
|
print("Deleting $folderName");
|
||||||
|
doubleCheckDelete(folderName);
|
||||||
|
// ApiService().deleteFolder(folderName);
|
||||||
|
print('Deleted folder');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class NewMailbox extends StatelessWidget {
|
class NewMailbox extends StatelessWidget {
|
||||||
final ApiService apiService;
|
final ApiService apiService;
|
||||||
// final Function(String) onFolderCreated;
|
|
||||||
final TextEditingController _textFieldController = TextEditingController();
|
final TextEditingController _textFieldController = TextEditingController();
|
||||||
|
|
||||||
NewMailbox({required this.apiService});
|
NewMailbox({required this.apiService});
|
||||||
@ -127,7 +194,7 @@ class NewMailbox extends StatelessWidget {
|
|||||||
content: TextField(
|
content: TextField(
|
||||||
controller: _textFieldController,
|
controller: _textFieldController,
|
||||||
decoration: const InputDecoration(
|
decoration: const InputDecoration(
|
||||||
hintText: "EPIC FOLDER", // Your custom hint text here
|
hintText: "New Folder",
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
actions: <Widget>[
|
actions: <Widget>[
|
||||||
@ -138,13 +205,17 @@ class NewMailbox extends StatelessWidget {
|
|||||||
|
|
||||||
if (folderName.isNotEmpty) {
|
if (folderName.isNotEmpty) {
|
||||||
apiService.createFolder(folderName);
|
apiService.createFolder(folderName);
|
||||||
// onFolderCreated(folderName);
|
|
||||||
}
|
}
|
||||||
// apiService.createFolder(_textFieldController.text);
|
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
},
|
},
|
||||||
child: const Text("Approve"),
|
child: const Text("Approve"),
|
||||||
),
|
),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
child: const Text("Cancel"),
|
||||||
|
)
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,440 +1,454 @@
|
|||||||
import 'folder_drawer.dart';
|
import 'folder_drawer.dart';
|
||||||
import 'structs.dart';
|
import 'structs.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
import 'api_service.dart';
|
import 'api_service.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'email.dart';
|
import 'email.dart';
|
||||||
// import 'package:shared_preferences/shared_preferences.dart';
|
// import 'package:shared_preferences/shared_preferences.dart';
|
||||||
// import 'serialize.dart';
|
// import 'serialize.dart';
|
||||||
|
|
||||||
class HomeScreen extends StatefulWidget {
|
class HomeScreen extends StatefulWidget {
|
||||||
@override
|
@override
|
||||||
_HomeScreenState createState() => _HomeScreenState();
|
_HomeScreenState createState() => _HomeScreenState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin {
|
class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin {
|
||||||
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||||
final GlobalKey<EmailPageState> _emailPageKey = GlobalKey<EmailPageState>();
|
final GlobalKey<EmailPageState> _emailPageKey = GlobalKey<EmailPageState>();
|
||||||
ApiService apiService = ApiService();
|
ApiService apiService = ApiService();
|
||||||
bool _isSidebarOpen = true;
|
bool _isSidebarOpen = true;
|
||||||
bool querySearches = false;
|
bool querySearches = false;
|
||||||
String? _selectedOption = "INBOX";
|
String? _selectedOption = "INBOX";
|
||||||
|
|
||||||
List<String> _tabs = ['Emails'];
|
List<String> _tabs = ['Emails'];
|
||||||
Map<String, Widget> _tabWidgets = {};
|
Map<String, Widget> _tabWidgets = {};
|
||||||
TabController? _tabController;
|
TabController? _tabController;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_tabController = TabController(length: _tabs.length, vsync: this);
|
_tabController = TabController(length: _tabs.length, vsync: this);
|
||||||
_tabWidgets['Emails'] = EmailPage(
|
_tabWidgets['Emails'] = EmailPage(
|
||||||
key: _emailPageKey,
|
key: _emailPageKey,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add a new tab based on the search
|
// Add a new tab based on the search
|
||||||
void _performSearch(String query, String? list) {
|
void _performSearch(String query, String? list) {
|
||||||
setState(() {
|
setState(() {
|
||||||
if (!_tabs.contains(query)) {
|
if (!_tabs.contains(query)) {
|
||||||
_tabs.add(query);
|
_tabs.add(query);
|
||||||
_tabWidgets[query] = _buildSearchResultsWidget(
|
_tabWidgets[query] = _buildSearchResultsWidget(
|
||||||
query, list); // Store a different widget for this tab
|
query, list); // Store a different widget for this tab
|
||||||
_tabController = TabController(length: _tabs.length, vsync: this);
|
_tabController = TabController(length: _tabs.length, vsync: this);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void _showOptionsSearchDialog () async {
|
void _showOptionsSearchDialog () async {
|
||||||
List<String> folders = await apiService.fetchFolders();
|
List<String> folders = await apiService.fetchFolders();
|
||||||
|
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return AlertDialog(
|
return AlertDialog(
|
||||||
title: Text('Choose an Option'),
|
title: Text('Choose an Option'),
|
||||||
content: Column(
|
content: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: folders.map((option) {
|
children: folders.map((option) {
|
||||||
return ListTile(
|
return ListTile(
|
||||||
title: Text(option),
|
title: Text(option),
|
||||||
leading: Radio<String>(
|
leading: Radio<String>(
|
||||||
value: option,
|
value: option,
|
||||||
groupValue: _selectedOption, // Bind with _selectedOption
|
groupValue: _selectedOption, // Bind with _selectedOption
|
||||||
onChanged: (String? value) {
|
onChanged: (String? value) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_selectedOption = value;
|
_selectedOption = value;
|
||||||
});
|
});
|
||||||
Navigator.of(context).pop(); // Close the dialog on selection
|
Navigator.of(context).pop(); // Close the dialog on selection
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}).toList(),
|
}).toList(),
|
||||||
),
|
),
|
||||||
actions: <Widget>[
|
actions: <Widget>[
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
child: Text('Submit'),
|
child: Text('Submit'),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.of(context).pop(); // Close the dialog
|
Navigator.of(context).pop(); // Close the dialog
|
||||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||||
content: Text('You selected: $_selectedOption'),
|
content: Text('You selected: $_selectedOption'),
|
||||||
));
|
));
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);}
|
);}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Remove a tab
|
// Remove a tab
|
||||||
void _removeTab(int index) {
|
void _removeTab(int index) {
|
||||||
if (_tabs[index] != 'Emails') {
|
if (_tabs[index] != 'Emails') {
|
||||||
setState(() {
|
setState(() {
|
||||||
String tabToRemove = _tabs[index];
|
String tabToRemove = _tabs[index];
|
||||||
_tabs.removeAt(index);
|
_tabs.removeAt(index);
|
||||||
_tabWidgets
|
_tabWidgets
|
||||||
.remove(tabToRemove); // Remove widget associated with the tab
|
.remove(tabToRemove); // Remove widget associated with the tab
|
||||||
_tabController = TabController(length: _tabs.length, vsync: this);
|
_tabController = TabController(length: _tabs.length, vsync: this);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build a custom widget for each search query
|
// Build a custom widget for each search query
|
||||||
Widget _buildSearchResultsWidget(String query, String? list) {
|
Widget _buildSearchResultsWidget(String query, String? list) {
|
||||||
return FutureBuilder<List<SerializableMessage>>(
|
return FutureBuilder<List<SerializableMessage>>(
|
||||||
future: apiService.sonicSearch(list ?? "INBOX", 50, 0, query),
|
future: apiService.sonicSearch(list ?? "INBOX", 50, 0, query),
|
||||||
builder: (BuildContext context,
|
builder: (BuildContext context,
|
||||||
AsyncSnapshot<List<SerializableMessage>> snapshot) {
|
AsyncSnapshot<List<SerializableMessage>> snapshot) {
|
||||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||||
return Center(child: CircularProgressIndicator());
|
return Center(child: CircularProgressIndicator());
|
||||||
} else if (snapshot.hasError) {
|
} else if (snapshot.hasError) {
|
||||||
return Center(child: Text('Error: ${snapshot.error}'));
|
return Center(child: Text('Error: ${snapshot.error}'));
|
||||||
} else if (!snapshot.hasData || snapshot.data!.isEmpty) {
|
} else if (!snapshot.hasData || snapshot.data!.isEmpty) {
|
||||||
return Center(child: Text('No results found for: $query'));
|
return Center(child: Text('No results found for: $query'));
|
||||||
} else {
|
} else {
|
||||||
List<SerializableMessage> result = snapshot.data!;
|
List<SerializableMessage> result = snapshot.data!;
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
body: ListView.separated(
|
body: ListView.separated(
|
||||||
itemCount: result.length,
|
itemCount: result.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final SerializableMessage email = result[index];
|
final SerializableMessage email = result[index];
|
||||||
return ListTile(
|
return ListTile(
|
||||||
title: Text(email.from,
|
title: Text(email.from,
|
||||||
style: TextStyle(fontWeight: FontWeight.bold)),
|
style: TextStyle(fontWeight: FontWeight.bold)),
|
||||||
subtitle: Column(
|
subtitle: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [Text(email.subject)],
|
children: [Text(email.subject)],
|
||||||
),
|
),
|
||||||
trailing: Text(email.date.toString()),
|
trailing: Text(email.date.toString()),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
// print('tapped');
|
// print('tapped');
|
||||||
String emailContent =
|
String emailContent =
|
||||||
await apiService.fetchEmailContent([email.id], email.list);
|
await apiService.fetchEmailContent([email.id], email.list);
|
||||||
// print('content below');
|
// print('content below');
|
||||||
// print(emailContent);
|
// print(emailContent);
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => EmailView(
|
builder: (context) => EmailView(
|
||||||
emailContent: emailContent,
|
emailContent: emailContent,
|
||||||
from: email.from,
|
from: email.from,
|
||||||
name: email.name,
|
name: email.name,
|
||||||
to: email.to.toString(),
|
to: email.to.toString(),
|
||||||
subject: email.subject,
|
subject: email.subject,
|
||||||
date: email.date.toString(),
|
date: email.date.toString(),
|
||||||
id: email.id.toString(),
|
id: email.id.toString(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
separatorBuilder: (context, index) => Divider(),
|
separatorBuilder: (context, index) => Divider(),
|
||||||
),
|
),
|
||||||
// child: Column(
|
// child: Column(
|
||||||
// mainAxisAlignment: MainAxisAlignment.center,
|
// mainAxisAlignment: MainAxisAlignment.center,
|
||||||
// children: [
|
// children: [
|
||||||
// Text("Results for: $query", style: TextStyle(fontSize: 24)),
|
// Text("Results for: $query", style: TextStyle(fontSize: 24)),
|
||||||
// // Display the actual data
|
// // Display the actual data
|
||||||
// Text(result[0].name), // Accessing the first result safely
|
// Text(result[0].name), // Accessing the first result safely
|
||||||
// Text(result[0].from), // Displaying the 'from' field as an example
|
// Text(result[0].from), // Displaying the 'from' field as an example
|
||||||
// Text(result[0].hash),
|
// Text(result[0].hash),
|
||||||
// Text(result[0].subject),
|
// Text(result[0].subject),
|
||||||
// Text(result[0].uid.toString()),
|
// Text(result[0].uid.toString()),
|
||||||
// Text(result[0].list),
|
// Text(result[0].list),
|
||||||
// Text(result[0].id),
|
// Text(result[0].id),
|
||||||
|
|
||||||
// // Add more fields or customize the display
|
// // Add more fields or customize the display
|
||||||
// // SerializableEmailListScreen(emails: result, getEmailContent: getEmailContent)
|
// // SerializableEmailListScreen(emails: result, getEmailContent: getEmailContent)
|
||||||
// // Expanded(
|
// // Expanded(
|
||||||
|
|
||||||
// // child:
|
// // child:
|
||||||
// // ),
|
// // ),
|
||||||
// ],
|
// ],
|
||||||
);
|
);
|
||||||
// );
|
// );
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_tabController?.dispose();
|
_tabController?.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
key: _scaffoldKey,
|
key: _scaffoldKey,
|
||||||
drawer: FolderDrawer(
|
drawer: FolderDrawer(
|
||||||
apiService: apiService,
|
apiService: apiService,
|
||||||
onFolderTap: (folder) {
|
onFolderTap: (folder) {
|
||||||
_emailPageKey.currentState?.updateSelectedFolder(folder);
|
_emailPageKey.currentState?.updateSelectedFolder(folder);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
body: Stack(
|
body: Stack(
|
||||||
children: [
|
children: [
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
// Sidebar
|
// Sidebar
|
||||||
if (_isSidebarOpen)
|
if (_isSidebarOpen)
|
||||||
Container(
|
Container(
|
||||||
width: 70,
|
width: 70,
|
||||||
color: Color.fromARGB(17, 96, 122, 135),
|
color: Color.fromARGB(17, 96, 122, 135),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
ListTile(
|
ListTile(
|
||||||
leading: Icon(Icons.home),
|
leading: Icon(Icons.home),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
// Navigate to Home
|
// Navigate to Home
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
leading: Icon(Icons.settings),
|
leading: Icon(Icons.settings),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
// Navigate to Settings
|
// Navigate to Settings
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
leading: Icon(Icons.email),
|
leading: Icon(Icons.email),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
_scaffoldKey.currentState?.openDrawer();
|
_scaffoldKey.currentState?.openDrawer();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
Spacer(),
|
Spacer(),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: Align(
|
child: Align(
|
||||||
alignment: Alignment.bottomLeft,
|
alignment: Alignment.bottomLeft,
|
||||||
child: IconButton(
|
child: IconButton(
|
||||||
icon: Icon(Icons.close, color: Colors.white),
|
icon: Icon(Icons.close, color: Colors.white),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isSidebarOpen = false;
|
_isSidebarOpen = false;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// Main content
|
// Main content
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
padding: EdgeInsets.fromLTRB(8.0, 8.0, 8.0, 4.0),
|
padding: EdgeInsets.fromLTRB(8.0, 8.0, 8.0, 4.0),
|
||||||
color: Color.fromARGB(42, 36, 102, 132),
|
color: Color.fromARGB(42, 36, 102, 132),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
width: 800,
|
width: 800,
|
||||||
height: 40,
|
height: 40,
|
||||||
child: TextField(
|
child: TextField(
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
hintText: 'Search...',
|
hintText: 'Search...',
|
||||||
border: OutlineInputBorder(),
|
border: OutlineInputBorder(),
|
||||||
prefixIcon: Icon(Icons.search),
|
prefixIcon: Icon(Icons.search),
|
||||||
),
|
),
|
||||||
onSubmitted: (value) {
|
onSubmitted: (value) {
|
||||||
if (value.isNotEmpty) {
|
if (value.isNotEmpty) {
|
||||||
_performSearch(value, _selectedOption);
|
_performSearch(value, _selectedOption);
|
||||||
}
|
}
|
||||||
//this is the input box i mentioned
|
//this is the input box i mentioned
|
||||||
// if (value == '') {
|
// if (value == '') {
|
||||||
// setState(() {
|
// setState(() {
|
||||||
// querySearches = false;
|
// querySearches = false;
|
||||||
// });
|
// });
|
||||||
// }
|
// }
|
||||||
// Future<List<String>> results = apiService
|
// Future<List<String>> results = apiService
|
||||||
// .sonicSearch('INBOX', 20, 0, value);
|
// .sonicSearch('INBOX', 20, 0, value);
|
||||||
// // print(value);
|
// // print(value);
|
||||||
// print(results);
|
// print(results);
|
||||||
// setState(() {
|
// setState(() {
|
||||||
// querySearches = true;
|
// querySearches = true;
|
||||||
// });
|
// });
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 16,
|
width: 16,
|
||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
width: 80,
|
width: 80,
|
||||||
height: 40,
|
height: 40,
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
onPressed: _showOptionsSearchDialog,
|
onPressed: _showOptionsSearchDialog,
|
||||||
child: Icon(Icons.manage_search),
|
child: Icon(Icons.manage_search),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
padding: EdgeInsets.all(0.0),
|
padding: EdgeInsets.all(0.0),
|
||||||
color: Color.fromARGB(42, 36, 102, 132),
|
color: Color.fromARGB(42, 36, 102, 132),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
height: 2,
|
height: 2,
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
color: Color.fromARGB(255, 131, 110, 143),
|
color: Color.fromARGB(255, 131, 110, 143),
|
||||||
child: TabBar(
|
child: TabBar(
|
||||||
controller: _tabController,
|
controller: _tabController,
|
||||||
isScrollable: true,
|
isScrollable: true,
|
||||||
tabs: _tabs
|
tabs: _tabs
|
||||||
.asMap()
|
.asMap()
|
||||||
.entries
|
.entries
|
||||||
.map((entry) => Tab(
|
.map((entry) => Tab(
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Text(entry.value),
|
Text(entry.value),
|
||||||
if (entry.value != 'Emails')
|
if (entry.value != 'Emails')
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () => _removeTab(entry.key),
|
onTap: () => _removeTab(entry.key),
|
||||||
child: Icon(Icons.close, size: 16),
|
child: Icon(Icons.close, size: 16),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
))
|
))
|
||||||
.toList(),
|
.toList(),
|
||||||
labelColor: Colors.white,
|
labelColor: Colors.white,
|
||||||
indicatorColor: Colors.white,
|
indicatorColor: Colors.white,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
// alignment: Alignment.topLeft,
|
// alignment: Alignment.topLeft,
|
||||||
padding: EdgeInsets.all(8.0),
|
padding: EdgeInsets.all(8.0),
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
_emailPageKey.currentState!.isBackDisabled ? null: _emailPageKey.currentState
|
_emailPageKey.currentState!.isBackDisabled ? null: _emailPageKey.currentState
|
||||||
?.updatePagenation('back');
|
?.updatePagenation('back');
|
||||||
},
|
},
|
||||||
child: Icon(Icons.navigate_before),
|
child: Icon(Icons.navigate_before),
|
||||||
),
|
),
|
||||||
Text(_emailPageKey.currentState?.getPage() ?? '1'),
|
Builder(
|
||||||
ElevatedButton(
|
builder: (context) {
|
||||||
onPressed: () {
|
final emailState = _emailPageKey.currentState;
|
||||||
_emailPageKey.currentState
|
if (emailState == null) {
|
||||||
?.updatePagenation('next');
|
// Schedule a rebuild once the state is available
|
||||||
},
|
Future.microtask(() => setState(() {}));
|
||||||
child: Icon(Icons.navigate_next),
|
return Text('Loading...');
|
||||||
),
|
}
|
||||||
],
|
|
||||||
),
|
return ValueListenableBuilder<int>(
|
||||||
),
|
valueListenable: emailState.currentPageNotifier,
|
||||||
Expanded(
|
builder: (context, value, _) => Text('$value'),
|
||||||
child: TabBarView(
|
);
|
||||||
controller: _tabController,
|
},
|
||||||
children: _tabs.map((tab) {
|
),
|
||||||
return _tabWidgets[tab] ??
|
ElevatedButton(
|
||||||
Center(child: Text("No content found"));
|
onPressed: () {
|
||||||
// return Center(
|
_emailPageKey.currentState
|
||||||
// child: EmailPage(
|
?.updatePagenation('next');
|
||||||
// key: _emailPageKey,
|
},
|
||||||
// ));
|
child: Icon(Icons.navigate_next),
|
||||||
}).toList(),
|
),
|
||||||
),
|
],
|
||||||
),
|
),
|
||||||
|
),
|
||||||
// if (_tabs.isEmpty)
|
Expanded(
|
||||||
// Expanded(
|
child: TabBarView(
|
||||||
// child: EmailPage(key: _emailPageKey),
|
controller: _tabController,
|
||||||
// ),
|
children: _tabs.map((tab) {
|
||||||
// if (_tabs.isNotEmpty)
|
return _tabWidgets[tab] ??
|
||||||
// Expanded(
|
Center(child: Text("No content found"));
|
||||||
// // child: Text('supposed to be mails'),
|
// return Center(
|
||||||
// child: TabBarView(
|
// child: EmailPage(
|
||||||
// controller: _tabController,
|
// key: _emailPageKey,
|
||||||
// children: _tabs
|
// ));
|
||||||
// .map((tab) => Center(child: Text('Results for $tab')))
|
}).toList(),
|
||||||
// .toList(),
|
),
|
||||||
// ),
|
),
|
||||||
// ),
|
|
||||||
],
|
// if (_tabs.isEmpty)
|
||||||
),
|
// Expanded(
|
||||||
),
|
// child: EmailPage(key: _emailPageKey),
|
||||||
],
|
// ),
|
||||||
),
|
// if (_tabs.isNotEmpty)
|
||||||
if (!_isSidebarOpen)
|
// Expanded(
|
||||||
Positioned(
|
// // child: Text('supposed to be mails'),
|
||||||
bottom: 16,
|
// child: TabBarView(
|
||||||
left: 16,
|
// controller: _tabController,
|
||||||
child: FloatingActionButton(
|
// children: _tabs
|
||||||
child: Icon(Icons.menu),
|
// .map((tab) => Center(child: Text('Results for $tab')))
|
||||||
onPressed: () {
|
// .toList(),
|
||||||
setState(() {
|
// ),
|
||||||
_isSidebarOpen = true;
|
// ),
|
||||||
});
|
],
|
||||||
},
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
if (!_isSidebarOpen)
|
||||||
);
|
Positioned(
|
||||||
}
|
bottom: 16,
|
||||||
}
|
left: 16,
|
||||||
// void _showPopupMenu(BuildContext context, Offset position) async {
|
child: FloatingActionButton(
|
||||||
// final RenderBox overlay =
|
child: Icon(Icons.menu),
|
||||||
// Overlay.of(context).context.findRenderObject() as RenderBox;
|
onPressed: () {
|
||||||
|
setState(() {
|
||||||
// await showMenu<String>(
|
_isSidebarOpen = true;
|
||||||
// context: context,
|
});
|
||||||
// position: RelativeRect.fromLTRB(
|
},
|
||||||
// position.dx,
|
),
|
||||||
// position.dy,
|
),
|
||||||
// overlay.size.width - position.dx,
|
],
|
||||||
// overlay.size.height - position.dy,
|
),
|
||||||
// ),
|
);
|
||||||
// items: <PopupMenuEntry<String>>[
|
}
|
||||||
// PopupMenuItem<String>(
|
}
|
||||||
// value: 'Open',
|
// void _showPopupMenu(BuildContext context, Offset position) async {
|
||||||
// child: Text('Open'),
|
// final RenderBox overlay =
|
||||||
// ),
|
// Overlay.of(context).context.findRenderObject() as RenderBox;
|
||||||
// PopupMenuItem<String>(
|
|
||||||
// value: 'Reply',
|
// await showMenu<String>(
|
||||||
// child: Text('Reply'),
|
// context: context,
|
||||||
// ),
|
// position: RelativeRect.fromLTRB(
|
||||||
// PopupMenuItem<String>(
|
// position.dx,
|
||||||
// value: 'Delete',
|
// position.dy,
|
||||||
// child: Text('Delete'),
|
// overlay.size.width - position.dx,
|
||||||
// ),
|
// overlay.size.height - position.dy,
|
||||||
// ],
|
// ),
|
||||||
// );
|
// items: <PopupMenuEntry<String>>[
|
||||||
// }
|
// PopupMenuItem<String>(
|
||||||
// }
|
// value: 'Open',
|
||||||
|
// child: Text('Open'),
|
||||||
|
// ),
|
||||||
|
// PopupMenuItem<String>(
|
||||||
|
// value: 'Reply',
|
||||||
|
// child: Text('Reply'),
|
||||||
|
// ),
|
||||||
|
// PopupMenuItem<String>(
|
||||||
|
// value: 'Delete',
|
||||||
|
// child: Text('Delete'),
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
Loading…
Reference in New Issue
Block a user