|
@@ -3,6 +3,8 @@ import 'package:http/http.dart' as http;
|
|
import 'dart:convert';
|
|
import 'dart:convert';
|
|
import 'dart:ui_web' as ui;
|
|
import 'dart:ui_web' as ui;
|
|
import 'dart:html' as html;
|
|
import 'dart:html' as html;
|
|
|
|
+import 'augment.dart';
|
|
|
|
+import 'dart:js' as js;
|
|
|
|
|
|
class MailAddress {
|
|
class MailAddress {
|
|
final String? name;
|
|
final String? name;
|
|
@@ -108,7 +110,6 @@ class _EmailPageState extends State<EmailPage> {
|
|
List<dynamic> json = jsonDecode(response.body);
|
|
List<dynamic> json = jsonDecode(response.body);
|
|
for (var item in json) {
|
|
for (var item in json) {
|
|
if (item.length > 1 && item[0] is String && item[1] is List) {
|
|
if (item.length > 1 && item[0] is String && item[1] is List) {
|
|
- // print('Date: ${item[0]}, Threads: ${item[1]}');
|
|
|
|
List<int> threadIDs = List<int>.from(item[1]);
|
|
List<int> threadIDs = List<int>.from(item[1]);
|
|
for (var threadId in threadIDs) {
|
|
for (var threadId in threadIDs) {
|
|
await fetchThreadMessages(threadId, allEmails);
|
|
await fetchThreadMessages(threadId, allEmails);
|
|
@@ -125,7 +126,6 @@ class _EmailPageState extends State<EmailPage> {
|
|
emails.clear();
|
|
emails.clear();
|
|
// emails = messagesMap.values.toList().expand((list) => list).toList();
|
|
// emails = messagesMap.values.toList().expand((list) => list).toList();
|
|
emails.addAll(allEmails);
|
|
emails.addAll(allEmails);
|
|
- // print(emails);
|
|
|
|
;
|
|
;
|
|
});
|
|
});
|
|
}
|
|
}
|
|
@@ -135,9 +135,9 @@ class _EmailPageState extends State<EmailPage> {
|
|
try {
|
|
try {
|
|
var url = Uri.http(
|
|
var url = Uri.http(
|
|
'127.0.0.1:3001', 'get_thread_messages', {'id': threadId.toString()});
|
|
'127.0.0.1:3001', 'get_thread_messages', {'id': threadId.toString()});
|
|
- // print(url);
|
|
|
|
|
|
+
|
|
var response = await http.get(url);
|
|
var response = await http.get(url);
|
|
- // print(response.body);
|
|
|
|
|
|
+
|
|
if (response.statusCode == 200) {
|
|
if (response.statusCode == 200) {
|
|
List<dynamic> messagesJson = jsonDecode(response.body);
|
|
List<dynamic> messagesJson = jsonDecode(response.body);
|
|
List<SerializableMessage> messages =
|
|
List<SerializableMessage> messages =
|
|
@@ -156,59 +156,22 @@ class _EmailPageState extends State<EmailPage> {
|
|
String content = r"""
|
|
String content = r"""
|
|
|
|
|
|
""";
|
|
""";
|
|
- // String restcontent = "";
|
|
|
|
|
|
+
|
|
try {
|
|
try {
|
|
var url = Uri.http('127.0.0.1:3001', 'email', {'id': id});
|
|
var url = Uri.http('127.0.0.1:3001', 'email', {'id': id});
|
|
- // print(url);
|
|
|
|
|
|
+
|
|
var response = await http.get(url);
|
|
var response = await http.get(url);
|
|
- // print(response.body);
|
|
|
|
|
|
+
|
|
if (response.statusCode == 200) {
|
|
if (response.statusCode == 200) {
|
|
- print('ok');
|
|
|
|
content = response.body;
|
|
content = response.body;
|
|
- // try {
|
|
|
|
- // var restUrl =
|
|
|
|
- // Uri.http('127.0.0.1:3001', 'get_thread_messages', {'id': id});
|
|
|
|
- // // print(restUrl);
|
|
|
|
- // var restresponse = await http.get(restUrl);
|
|
|
|
- // // print(restresponse.statusCode);
|
|
|
|
- // if (restresponse.statusCode == 200) {
|
|
|
|
- // print("ok squared");
|
|
|
|
- // // restcontent = restresponse.body;
|
|
|
|
- // }
|
|
|
|
- // } catch (i) {
|
|
|
|
- // print('jsoncontent caught error: $i');
|
|
|
|
- // }
|
|
|
|
}
|
|
}
|
|
} catch (e) {
|
|
} catch (e) {
|
|
print('_getEmailContent caught error: $e');
|
|
print('_getEmailContent caught error: $e');
|
|
}
|
|
}
|
|
- // print(content);
|
|
|
|
- // print(restcontent);
|
|
|
|
|
|
+
|
|
return content;
|
|
return content;
|
|
}
|
|
}
|
|
|
|
|
|
- // Future<String> _getThreadMessagesJson(String threadId) async {
|
|
|
|
- // String jsonResponse = "";
|
|
|
|
-
|
|
|
|
- // try {
|
|
|
|
- // var url =
|
|
|
|
- // Uri.http('127.0.0.1:3001', 'get_thread_messages', {'id': threadId});
|
|
|
|
- // // print(url);
|
|
|
|
- // var response = await http.get(url);
|
|
|
|
- // // print(response.statusCode);
|
|
|
|
- // // print(response.body);
|
|
|
|
- // if (response.statusCode == 200) {
|
|
|
|
- // jsonResponse = response.body; // Here you get the JSON response
|
|
|
|
- // } else {
|
|
|
|
- // throw Exception('Failed to load thread messages');
|
|
|
|
- // }
|
|
|
|
- // } catch (e) {
|
|
|
|
- // print('_getThreadMessagesJson caught error: $e');
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
- // return jsonResponse; // Returns the JSON string
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
Future<List<Widget>> _getDrawerItems() async {
|
|
Future<List<Widget>> _getDrawerItems() async {
|
|
List<String> drawerItems = [];
|
|
List<String> drawerItems = [];
|
|
|
|
|
|
@@ -280,17 +243,14 @@ class _EmailPageState extends State<EmailPage> {
|
|
class EmailListScreen extends StatelessWidget {
|
|
class EmailListScreen extends StatelessWidget {
|
|
final List emails;
|
|
final List emails;
|
|
final Future<String> Function(String) getEmailContent;
|
|
final Future<String> Function(String) getEmailContent;
|
|
- // final Future<String> Function(String) getJsonEmail;
|
|
|
|
|
|
|
|
EmailListScreen({
|
|
EmailListScreen({
|
|
required this.emails,
|
|
required this.emails,
|
|
required this.getEmailContent,
|
|
required this.getEmailContent,
|
|
- // required this.getJsonEmail
|
|
|
|
});
|
|
});
|
|
|
|
|
|
@override
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
Widget build(BuildContext context) {
|
|
- // print(emails);
|
|
|
|
return Scaffold(
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
appBar: AppBar(
|
|
title: Text('Emails'),
|
|
title: Text('Emails'),
|
|
@@ -310,9 +270,6 @@ class EmailListScreen extends StatelessWidget {
|
|
trailing: Text(emails[index].date.toString()),
|
|
trailing: Text(emails[index].date.toString()),
|
|
onTap: () async {
|
|
onTap: () async {
|
|
String emailContent = await getEmailContent(emails[index].id);
|
|
String emailContent = await getEmailContent(emails[index].id);
|
|
- // String jsonContent =
|
|
|
|
- // await getJsonEmail(emails[index].uid.toString());
|
|
|
|
- // print(emails[index]);
|
|
|
|
String from = emails[index].from.toString();
|
|
String from = emails[index].from.toString();
|
|
String name = emails[index].name.toString();
|
|
String name = emails[index].name.toString();
|
|
String to = emails[index].to.toString();
|
|
String to = emails[index].to.toString();
|
|
@@ -388,6 +345,7 @@ class _EmailViewState extends State<EmailView> {
|
|
@override
|
|
@override
|
|
void initState() {
|
|
void initState() {
|
|
super.initState();
|
|
super.initState();
|
|
|
|
+ print(widget.id);
|
|
iframeKey = Key("iframe-${widget.id}");
|
|
iframeKey = Key("iframe-${widget.id}");
|
|
ui.platformViewRegistry.registerViewFactory(
|
|
ui.platformViewRegistry.registerViewFactory(
|
|
// 'html-view33'
|
|
// 'html-view33'
|
|
@@ -397,67 +355,77 @@ class _EmailViewState extends State<EmailView> {
|
|
..height = '100%'
|
|
..height = '100%'
|
|
..srcdoc = widget.emailContent
|
|
..srcdoc = widget.emailContent
|
|
..style.border = 'none',
|
|
..style.border = 'none',
|
|
|
|
+ // ..style.width = '100%',
|
|
|
|
+ // ..style.height = '100%'
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
@override
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
Widget build(BuildContext context) {
|
|
- return Scaffold(
|
|
|
|
- appBar: AppBar(
|
|
|
|
- title: Text(widget.name),
|
|
|
|
- ),
|
|
|
|
- body: Column(
|
|
|
|
- children: [
|
|
|
|
- // Container(
|
|
|
|
- // color: Colors.amber,
|
|
|
|
- // child: Text(
|
|
|
|
- // widget.from ,),
|
|
|
|
- // ),
|
|
|
|
- Row(
|
|
|
|
- // title of email
|
|
|
|
- children: [
|
|
|
|
- Text(
|
|
|
|
- widget.subject,
|
|
|
|
- style: TextStyle(fontSize: 30),
|
|
|
|
- ),
|
|
|
|
- ],
|
|
|
|
- ),
|
|
|
|
- Row(
|
|
|
|
- children: [
|
|
|
|
- Text(
|
|
|
|
- 'from ${widget.name}',
|
|
|
|
- style: TextStyle(fontSize: 18),
|
|
|
|
- ),
|
|
|
|
- Text(
|
|
|
|
- '<${widget.from}>',
|
|
|
|
- style: TextStyle(fontSize: 18),
|
|
|
|
- ),
|
|
|
|
- Spacer(),
|
|
|
|
- Text(
|
|
|
|
- '${widget.date}',
|
|
|
|
- textAlign: TextAlign.right,
|
|
|
|
- )
|
|
|
|
- ],
|
|
|
|
- ),
|
|
|
|
- // TODO: make a case where if one of these is the user's email it just says me :)))))
|
|
|
|
- Row(
|
|
|
|
- children: [
|
|
|
|
- Text(
|
|
|
|
- 'to ${widget.to.toString()}',
|
|
|
|
- style: TextStyle(fontSize: 15),
|
|
|
|
- )
|
|
|
|
- ],
|
|
|
|
- ),
|
|
|
|
|
|
+ void _handleNumbering() {
|
|
|
|
+ // Check if the iframe content window is accessible
|
|
|
|
+ try {
|
|
|
|
+ js.context.callMethod('applyNumberingVisibility');
|
|
|
|
+ } catch (e) {
|
|
|
|
+ print('Error accessing iframe method: $e');
|
|
|
|
+ // Optionally, use postMessage for cross-origin communication
|
|
|
|
+ // js.context['iframeElement'].contentWindow.postMessage(jsify({'action': 'toggleNumbering'}), '*');
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
- Expanded(
|
|
|
|
- child: HtmlElementView(
|
|
|
|
- key: iframeKey,
|
|
|
|
- viewType: iframeKey.toString(),
|
|
|
|
- // 'html-view33',
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return Scaffold(
|
|
|
|
+ appBar: AppBar(
|
|
|
|
+ title: Text(widget.name),
|
|
|
|
+ ),
|
|
|
|
+ body: Column(
|
|
|
|
+ children: [
|
|
|
|
+ EmailToolbar(onButtonPressed: _handleNumbering),
|
|
|
|
+ Row(
|
|
|
|
+ // title of email
|
|
|
|
+ children: [
|
|
|
|
+ Text(
|
|
|
|
+ widget.subject,
|
|
|
|
+ style: TextStyle(fontSize: 30),
|
|
|
|
+ ),
|
|
|
|
+ ],
|
|
),
|
|
),
|
|
- )
|
|
|
|
- ],
|
|
|
|
- )
|
|
|
|
- );
|
|
|
|
|
|
+ Row(
|
|
|
|
+ children: [
|
|
|
|
+ Text(
|
|
|
|
+ 'from ${widget.name}',
|
|
|
|
+ style: TextStyle(fontSize: 18),
|
|
|
|
+ ),
|
|
|
|
+ Text(
|
|
|
|
+ '<${widget.from}>',
|
|
|
|
+ style: TextStyle(fontSize: 18),
|
|
|
|
+ ),
|
|
|
|
+ Spacer(),
|
|
|
|
+ Text(
|
|
|
|
+ '${widget.date}',
|
|
|
|
+ textAlign: TextAlign.right,
|
|
|
|
+ )
|
|
|
|
+ ],
|
|
|
|
+ ),
|
|
|
|
+ // TODO: make a case where if one of these is the user's email it just says me :)))))
|
|
|
|
+ Row(
|
|
|
|
+ children: [
|
|
|
|
+ Text(
|
|
|
|
+ 'to ${widget.to.toString()}',
|
|
|
|
+ style: TextStyle(fontSize: 15),
|
|
|
|
+ )
|
|
|
|
+ ],
|
|
|
|
+ ),
|
|
|
|
+
|
|
|
|
+ Expanded(
|
|
|
|
+ child: HtmlElementView(
|
|
|
|
+ key: iframeKey,
|
|
|
|
+ viewType: iframeKey.toString(),
|
|
|
|
+ // 'html-view33',
|
|
|
|
+ ),
|
|
|
|
+ ),
|
|
|
|
+ ],
|
|
|
|
+ ));
|
|
}
|
|
}
|
|
}
|
|
}
|