WIP: android/ios-adaption feature, markdown, and augment #6
@ -9,11 +9,14 @@ class CollapsableEmails extends StatefulWidget {
|
||||
final List<String> thread; // email id's in the form xyz@gmail.com
|
||||
final List<String> threadHTML;
|
||||
final String threadIDs;
|
||||
final String? targetJumpNumbering;
|
||||
|
||||
CollapsableEmails(
|
||||
{required this.thread,
|
||||
required this.threadHTML,
|
||||
required this.threadIDs});
|
||||
const CollapsableEmails({
|
||||
required this.thread,
|
||||
required this.threadHTML,
|
||||
required this.threadIDs,
|
||||
this.targetJumpNumbering,
|
||||
});
|
||||
|
||||
@override
|
||||
State<CollapsableEmails> createState() => _CollapsableEmailsState();
|
||||
@ -60,6 +63,16 @@ class _CollapsableEmailsState extends State<CollapsableEmails> {
|
||||
_markdown2Tree(allMarkdown);
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(covariant CollapsableEmails oldWidget) {
|
||||
// TODO: implement didUpdateWidget
|
||||
super.didUpdateWidget(oldWidget);
|
||||
if (widget.targetJumpNumbering != null &&
|
||||
widget.targetJumpNumbering != oldWidget.targetJumpNumbering) {
|
||||
_handleJump(widget.targetJumpNumbering!);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
@ -266,6 +279,54 @@ class _CollapsableEmailsState extends State<CollapsableEmails> {
|
||||
);
|
||||
}
|
||||
|
||||
void _handleJump(String queryNumbering) {
|
||||
print(queryNumbering);
|
||||
if (queryNumbering.isEmpty) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Please enter a numbering to jump to.')),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
final int targetEmailIndex = _expandedEmails.first;
|
||||
if (targetEmailIndex >= threadNodes.length) {
|
||||
// Error handling
|
||||
return;
|
||||
}
|
||||
|
||||
final AugmentTree rootOfCurrentEmail = threadNodes[targetEmailIndex];
|
||||
final AugmentTree? foundNode =
|
||||
_findNodeByNumbering(rootOfCurrentEmail, queryNumbering);
|
||||
|
||||
if (foundNode != null) {
|
||||
setState(() {
|
||||
currentZoomTree[targetEmailIndex] = foundNode; // Update the state
|
||||
});
|
||||
} else {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Numbering "$queryNumbering" not found.')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Placeholder for your actual node finding logic within AugmentTree
|
||||
AugmentTree? _findNodeByNumbering(AugmentTree root, String numbering) {
|
||||
// Implement your tree traversal here (e.g., DFS or BFS)
|
||||
// to find the AugmentTree node corresponding to the `numbering`.
|
||||
// This is a simplified example:
|
||||
if (root.numbering == numbering) {
|
||||
// Assuming 'id' can be your numbering
|
||||
return root;
|
||||
}
|
||||
for (var child in root.children) {
|
||||
final found = _findNodeByNumbering(child, numbering);
|
||||
if (found != null) {
|
||||
return found;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return _isLoaded
|
||||
|
Loading…
Reference in New Issue
Block a user