Compare commits
2 Commits
95697efdab
...
29f18b6876
Author | SHA1 | Date | |
---|---|---|---|
29f18b6876 | |||
7ec032c0f2 |
@ -7,7 +7,6 @@ import 'dart:typed_data';
|
|||||||
import 'package:pointer_interceptor/pointer_interceptor.dart';
|
import 'package:pointer_interceptor/pointer_interceptor.dart';
|
||||||
import 'collapsableEmails.dart';
|
import 'collapsableEmails.dart';
|
||||||
|
|
||||||
|
|
||||||
import 'structs.dart';
|
import 'structs.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
@ -156,6 +155,7 @@ class ApiService {
|
|||||||
|
|
||||||
Future<List<SerializableMessage>> threadsInSerializable(
|
Future<List<SerializableMessage>> threadsInSerializable(
|
||||||
String thread_id) async {
|
String thread_id) async {
|
||||||
|
//actually a number
|
||||||
// grab all of the emails in thread anyways, for the future it'll come in handy
|
// 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});
|
var url = Uri.http('$ip:$port', 'get_thread_messages', {'id': thread_id});
|
||||||
try {
|
try {
|
||||||
@ -462,44 +462,40 @@ class _EmailViewState extends State<EmailView> {
|
|||||||
{'id': 'marker2', 'x': 150, 'y': 200},
|
{'id': 'marker2', 'x': 150, 'y': 200},
|
||||||
{'id': 'marker3', 'x': 250, 'y': 300},
|
{'id': 'marker3', 'x': 250, 'y': 300},
|
||||||
];
|
];
|
||||||
ApiService _apiService = ApiService();
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
print("thread id? ${widget.id}");
|
||||||
List<String> currentContent = widget
|
List<String> currentContent = widget
|
||||||
.emailContent; //html of the email/ actually entire thread, gives me little space to play in between
|
.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
|
// 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
|
||||||
// viewTypeId = "iframe-${DateTime.now().millisecondsSinceEpoch}";
|
// _registerViewFactory(currentContent);
|
||||||
_registerViewFactory(currentContent);
|
|
||||||
// _markerPositionsFuture = ApiService().getMarkerPosition();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _registerViewFactory(List<String> currentContent) {
|
// void _registerViewFactory(List<String> currentContent) { // i think this doesnt work anymore
|
||||||
setState(() { //update to do item per item
|
// setState(() { //update to do item per item
|
||||||
// each item to have itsviewtype ID
|
// // each item to have itsviewtype ID
|
||||||
// is this necessarey here??
|
// // 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 = 'iframe-${DateTime.now().millisecondsSinceEpoch}';
|
// viewTypeId,
|
||||||
final emailHTML = web.document.createElement('div') as web.HTMLDivElement
|
// (int viewId) => emailHTML,
|
||||||
..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) {
|
void _scrollToNumber(String spanId) {
|
||||||
AugmentClasses.handleJump(spanId);
|
AugmentClasses.handleJump(spanId);
|
||||||
@ -508,7 +504,7 @@ class _EmailViewState extends State<EmailView> {
|
|||||||
// TODO: void _invisibility(String ) //to make purple numbers not visible
|
// TODO: void _invisibility(String ) //to make purple numbers not visible
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
// print("thread id ${widget.id}");
|
// print("thread id ${widget.id}");
|
||||||
ApiService.currThreadID = widget.id;
|
ApiService.currThreadID = widget.id;
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
@ -580,8 +576,10 @@ class _EmailViewState extends State<EmailView> {
|
|||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: CollapsableEmails(
|
child: CollapsableEmails(
|
||||||
|
//change here
|
||||||
thread: widget.messages,
|
thread: widget.messages,
|
||||||
threadHTML: widget.emailContent,
|
threadHTML: widget.emailContent,
|
||||||
|
threadIDs: widget.id,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// Expanded(
|
// Expanded(
|
||||||
|
@ -8,8 +8,12 @@ import 'structs.dart';
|
|||||||
class CollapsableEmails extends StatefulWidget {
|
class CollapsableEmails extends StatefulWidget {
|
||||||
final List<String> thread; // email id's in the form xyz@gmail.com
|
final List<String> thread; // email id's in the form xyz@gmail.com
|
||||||
final List<String> threadHTML;
|
final List<String> threadHTML;
|
||||||
|
final String threadIDs;
|
||||||
|
|
||||||
CollapsableEmails({required this.thread, required this.threadHTML});
|
CollapsableEmails(
|
||||||
|
{required this.thread,
|
||||||
|
required this.threadHTML,
|
||||||
|
required this.threadIDs});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<CollapsableEmails> createState() => _CollapsableEmailsState();
|
State<CollapsableEmails> createState() => _CollapsableEmailsState();
|
||||||
@ -21,12 +25,15 @@ class _CollapsableEmailsState extends State<CollapsableEmails> {
|
|||||||
Set<int> _expandedEmails = {}; //open emails
|
Set<int> _expandedEmails = {}; //open emails
|
||||||
List viewtypeIDs = []; //IDs of the viewtypes, order matters
|
List viewtypeIDs = []; //IDs of the viewtypes, order matters
|
||||||
List heightOfViewTypes = []; //the height of each viewtype
|
List heightOfViewTypes = []; //the height of each viewtype
|
||||||
|
List<SerializableMessage> emailsInThread = [];
|
||||||
|
bool _isLoaded = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
// TODO: implement initState
|
// TODO: implement initState
|
||||||
super.initState();
|
super.initState();
|
||||||
_registerViewFactory(widget.threadHTML);
|
_registerViewFactory(widget.threadHTML);
|
||||||
|
_serializableData(widget.threadIDs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _registerViewFactory(List<String> currentContent) async {
|
void _registerViewFactory(List<String> currentContent) async {
|
||||||
@ -70,61 +77,56 @@ class _CollapsableEmailsState extends State<CollapsableEmails> {
|
|||||||
viewtypeIDs.add(viewTypeId);
|
viewtypeIDs.add(viewTypeId);
|
||||||
heightOfViewTypes.add(heightOfEmail);
|
heightOfViewTypes.add(heightOfEmail);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// viewTypeId = 'iframe-${DateTime.now().millisecondsSinceEpoch}';
|
void _serializableData(String threadID) async {
|
||||||
// final emailHTML = web.document.createElement('div') as web.HTMLDivElement
|
emailsInThread = await ApiService().threadsInSerializable(threadID);
|
||||||
// ..id = viewTypeId
|
print("done thread serializable");
|
||||||
// ..innerHTML = currentContent[0].toJS; // temporarily index because it has to do all of them
|
if (!mounted) return;
|
||||||
// emailHTML.style
|
setState(() {
|
||||||
// ..width = '100%'
|
_isLoaded = true;
|
||||||
// ..height = '100%'
|
});
|
||||||
// ..overflow = 'auto'
|
|
||||||
// ..scrollBehavior = 'smooth';
|
|
||||||
|
|
||||||
// ui.platformViewRegistry.registerViewFactory(
|
|
||||||
// viewTypeId,
|
|
||||||
// (int viewId) => emailHTML,
|
|
||||||
// );
|
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Column(children: [
|
return _isLoaded
|
||||||
Expanded(
|
?Column(children: [
|
||||||
child: ListView.builder(
|
Expanded(
|
||||||
itemCount: widget.thread.length,
|
child: ListView.builder(
|
||||||
itemBuilder: (context, index) {
|
itemCount: widget.thread.length,
|
||||||
final isExpanded =
|
itemBuilder: (context, index) {
|
||||||
_expandedEmails.contains(index); //check if email is expanded
|
final isExpanded =
|
||||||
return Column(
|
_expandedEmails.contains(index); //check if email is expanded
|
||||||
children: [
|
return Column(
|
||||||
ListTile(
|
children: [
|
||||||
title: Text("email $index"),
|
ListTile(
|
||||||
onTap: () {
|
title: Text(emailsInThread[index].from),
|
||||||
setState(() {
|
trailing: Text(emailsInThread[index].date),
|
||||||
if (isExpanded) {
|
onTap: () {
|
||||||
_expandedEmails.remove(index);
|
setState(() {
|
||||||
} else {
|
if (isExpanded) {
|
||||||
_expandedEmails.add(index);
|
_expandedEmails.remove(index);
|
||||||
}
|
} else {
|
||||||
});
|
_expandedEmails.add(index);
|
||||||
},
|
}
|
||||||
),
|
});
|
||||||
if (isExpanded)
|
},
|
||||||
// if(viewtypeIDs[index] == null || heightOfViewTypes[index] == null)
|
|
||||||
// const SizedBox(height: 100, child: Center(child: CircularProgressIndicator())),
|
|
||||||
SizedBox(
|
|
||||||
height:heightOfViewTypes[index].toDouble(),
|
|
||||||
child: HtmlElementView(
|
|
||||||
key: UniqueKey(), viewType: viewtypeIDs[index]),
|
|
||||||
),
|
),
|
||||||
Divider(),
|
if (isExpanded)
|
||||||
],
|
// if(viewtypeIDs[index] == null || heightOfViewTypes[index] == null)
|
||||||
);
|
// const SizedBox(height: 100, child: Center(child: CircularProgressIndicator())),
|
||||||
},
|
SizedBox(
|
||||||
),
|
height: heightOfViewTypes[index].toDouble(),
|
||||||
)
|
child: HtmlElementView(
|
||||||
]);
|
key: UniqueKey(), viewType: viewtypeIDs[index]),
|
||||||
|
),
|
||||||
|
Divider(),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
)
|
||||||
|
]): const Center(child:CircularProgressIndicator());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user