Compare commits

..

No commits in common. "29f18b6876c5f84c65288d0993d27a870cbfa711" and "95697efdab0b74fc113ddd789e47022adef51efc" have entirely different histories.

2 changed files with 79 additions and 79 deletions

View File

@ -7,6 +7,7 @@ import 'dart:typed_data';
import 'package:pointer_interceptor/pointer_interceptor.dart';
import 'collapsableEmails.dart';
import 'structs.dart';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
@ -155,7 +156,6 @@ class ApiService {
Future<List<SerializableMessage>> threadsInSerializable(
String thread_id) async {
//actually a number
// 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 {
@ -462,40 +462,44 @@ class _EmailViewState extends State<EmailView> {
{'id': 'marker2', 'x': 150, 'y': 200},
{'id': 'marker3', 'x': 250, 'y': 300},
];
ApiService _apiService = ApiService();
@override
void initState() {
super.initState();
print("thread id? ${widget.id}");
List<String> currentContent = widget
.emailContent; //html of the email/ actually entire thread, gives me little space to play in between
// i wonder if the other attributes change? because if so i have to add like some zooms in and out of the emails, as in collapse
// _registerViewFactory(currentContent);
// viewTypeId = "iframe-${DateTime.now().millisecondsSinceEpoch}";
_registerViewFactory(currentContent);
// _markerPositionsFuture = ApiService().getMarkerPosition();
}
// void _registerViewFactory(List<String> currentContent) { // i think this doesnt work anymore
// setState(() { //update to do item per item
// // each item to have itsviewtype ID
// // is this necessarey here??
void _registerViewFactory(List<String> currentContent) {
setState(() { //update to do item per item
// each item to have itsviewtype ID
// is this necessarey here??
// //could just move to collapsable
//could just move to collapsable
// viewTypeId = 'iframe-${DateTime.now().millisecondsSinceEpoch}';
// final emailHTML = web.document.createElement('div') as web.HTMLDivElement
// ..id = viewTypeId
// ..innerHTML = currentContent[0].toJS; // temporarily index because it has to do all of them
// emailHTML.style
// ..width = '100%'
// ..height = '100%'
// ..overflow = 'auto'
// ..scrollBehavior = 'smooth';
// ui.platformViewRegistry.registerViewFactory(
// viewTypeId,
// (int viewId) => emailHTML,
// );
// });
// }
viewTypeId = 'iframe-${DateTime.now().millisecondsSinceEpoch}';
final emailHTML = web.document.createElement('div') as web.HTMLDivElement
..id = viewTypeId
..innerHTML = currentContent[0].toJS; // temporarily index because it has to do all of them
emailHTML.style
..width = '100%'
..height = '100%'
..overflow = 'auto'
..scrollBehavior = 'smooth';
ui.platformViewRegistry.registerViewFactory(
viewTypeId,
(int viewId) => emailHTML,
);
});
}
void _scrollToNumber(String spanId) {
AugmentClasses.handleJump(spanId);
@ -576,10 +580,8 @@ class _EmailViewState extends State<EmailView> {
),
Expanded(
child: CollapsableEmails(
//change here
thread: widget.messages,
threadHTML: widget.emailContent,
threadIDs: widget.id,
),
),
// Expanded(

View File

@ -8,12 +8,8 @@ import 'structs.dart';
class CollapsableEmails extends StatefulWidget {
final List<String> thread; // email id's in the form xyz@gmail.com
final List<String> threadHTML;
final String threadIDs;
CollapsableEmails(
{required this.thread,
required this.threadHTML,
required this.threadIDs});
CollapsableEmails({required this.thread, required this.threadHTML});
@override
State<CollapsableEmails> createState() => _CollapsableEmailsState();
@ -25,15 +21,12 @@ class _CollapsableEmailsState extends State<CollapsableEmails> {
Set<int> _expandedEmails = {}; //open emails
List viewtypeIDs = []; //IDs of the viewtypes, order matters
List heightOfViewTypes = []; //the height of each viewtype
List<SerializableMessage> emailsInThread = [];
bool _isLoaded = false;
@override
void initState() {
// TODO: implement initState
super.initState();
_registerViewFactory(widget.threadHTML);
_serializableData(widget.threadIDs);
}
void _registerViewFactory(List<String> currentContent) async {
@ -77,21 +70,27 @@ class _CollapsableEmailsState extends State<CollapsableEmails> {
viewtypeIDs.add(viewTypeId);
heightOfViewTypes.add(heightOfEmail);
}
}
void _serializableData(String threadID) async {
emailsInThread = await ApiService().threadsInSerializable(threadID);
print("done thread serializable");
if (!mounted) return;
setState(() {
_isLoaded = true;
});
// viewTypeId = 'iframe-${DateTime.now().millisecondsSinceEpoch}';
// final emailHTML = web.document.createElement('div') as web.HTMLDivElement
// ..id = viewTypeId
// ..innerHTML = currentContent[0].toJS; // temporarily index because it has to do all of them
// emailHTML.style
// ..width = '100%'
// ..height = '100%'
// ..overflow = 'auto'
// ..scrollBehavior = 'smooth';
// ui.platformViewRegistry.registerViewFactory(
// viewTypeId,
// (int viewId) => emailHTML,
// );
// });
}
@override
Widget build(BuildContext context) {
return _isLoaded
?Column(children: [
return Column(children: [
Expanded(
child: ListView.builder(
itemCount: widget.thread.length,
@ -101,8 +100,7 @@ class _CollapsableEmailsState extends State<CollapsableEmails> {
return Column(
children: [
ListTile(
title: Text(emailsInThread[index].from),
trailing: Text(emailsInThread[index].date),
title: Text("email $index"),
onTap: () {
setState(() {
if (isExpanded) {
@ -127,6 +125,6 @@ class _CollapsableEmailsState extends State<CollapsableEmails> {
},
),
)
]): const Center(child:CircularProgressIndicator());
]);
}
}