|
@@ -3,6 +3,9 @@ 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;
|
|
|
|
+// import 'package:flutter_web_plugins/flutter_web_plugins.dart';
|
|
|
|
|
|
class MailAddress {
|
|
class MailAddress {
|
|
final String? name;
|
|
final String? name;
|
|
@@ -108,7 +111,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 +127,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 +136,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 +157,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 +244,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 +271,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();
|
|
@@ -384,80 +342,102 @@ class EmailView extends StatefulWidget {
|
|
|
|
|
|
class _EmailViewState extends State<EmailView> {
|
|
class _EmailViewState extends State<EmailView> {
|
|
late Key iframeKey;
|
|
late Key iframeKey;
|
|
|
|
+ late String currentContent;
|
|
|
|
+ late String viewTypeId;
|
|
|
|
|
|
@override
|
|
@override
|
|
void initState() {
|
|
void initState() {
|
|
super.initState();
|
|
super.initState();
|
|
- iframeKey = Key("iframe-${widget.id}");
|
|
|
|
- ui.platformViewRegistry.registerViewFactory(
|
|
|
|
- // 'html-view33'
|
|
|
|
- iframeKey.toString(),
|
|
|
|
- (int viewId) => html.IFrameElement()
|
|
|
|
- ..width = '100%'
|
|
|
|
- ..height = '100%'
|
|
|
|
- ..srcdoc = widget.emailContent
|
|
|
|
- ..style.border = 'none',
|
|
|
|
- );
|
|
|
|
|
|
+ String currentContent = widget.emailContent;
|
|
|
|
+ viewTypeId = "iframe-${DateTime.now().millisecondsSinceEpoch}";
|
|
|
|
+ _registerViewFactory(currentContent);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ void _registerViewFactory(String currentContent) {
|
|
|
|
+ setState(() {
|
|
|
|
+ viewTypeId = 'iframe-${DateTime.now().millisecondsSinceEpoch}';
|
|
|
|
+ ui.platformViewRegistry.registerViewFactory(
|
|
|
|
+ viewTypeId,
|
|
|
|
+ (int viewId) => html.IFrameElement()
|
|
|
|
+ ..width = '100%'
|
|
|
|
+ ..height = '100%'
|
|
|
|
+ ..srcdoc = currentContent
|
|
|
|
+ ..style.border = 'none');
|
|
|
|
+ });
|
|
}
|
|
}
|
|
|
|
|
|
@override
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
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),
|
|
|
|
- )
|
|
|
|
- ],
|
|
|
|
- ),
|
|
|
|
|
|
+ appBar: AppBar(
|
|
|
|
+ title: Text(widget.name),
|
|
|
|
+ ),
|
|
|
|
+ body: Column(
|
|
|
|
+ children: [
|
|
|
|
+ EmailToolbar(
|
|
|
|
+ onButtonPressed: () {
|
|
|
|
+ _registerViewFactory(r"""
|
|
|
|
+ <h1>Welcome to My Website</h1>
|
|
|
|
+ <p>This is a simple HTML page.</p>
|
|
|
|
+ <h2>What is HTML?</h2>
|
|
|
|
+ <p>HTML (HyperText Markup Language) is the most basic building block of the Web. It defines the meaning and structure of web content. Other technologies besides HTML are generally used to describe a web page's appearance/presentation (CSS) or functionality/behavior (JavaScript).</p>
|
|
|
|
+ <h3>Here's a simple list:</h3>
|
|
|
|
+ <ul>
|
|
|
|
+ <li>HTML elements are the building blocks of HTML pages</li>
|
|
|
|
+ <li>HTML uses tags like <code><tag></code> to organize and format content</li>
|
|
|
|
+ <li>CSS is used with HTML to style pages</li>
|
|
|
|
+ </ul>
|
|
|
|
+ <p>Copyright © 2023</p>
|
|
|
|
+ """);
|
|
|
|
+ print("change");
|
|
|
|
+ // widget.emailContent = r"
|
|
|
|
|
|
- Expanded(
|
|
|
|
- child: HtmlElementView(
|
|
|
|
- key: iframeKey,
|
|
|
|
- viewType: iframeKey.toString(),
|
|
|
|
- // 'html-view33',
|
|
|
|
|
|
+// "
|
|
|
|
+ },
|
|
),
|
|
),
|
|
- )
|
|
|
|
- ],
|
|
|
|
- )
|
|
|
|
- );
|
|
|
|
|
|
+ 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: UniqueKey(),
|
|
|
|
+ viewType: viewTypeId,
|
|
|
|
+ ),
|
|
|
|
+ ),
|
|
|
|
+ ],
|
|
|
|
+ ));
|
|
}
|
|
}
|
|
}
|
|
}
|