android/ios-adaption feature, markdown, and augment #6
					 1 changed files with 65 additions and 4 deletions
				
			
		| 
						 | 
					@ -9,11 +9,14 @@ 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;
 | 
					  final String threadIDs;
 | 
				
			||||||
 | 
					  final String? targetJumpNumbering;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  CollapsableEmails(
 | 
					  const CollapsableEmails({
 | 
				
			||||||
      {required this.thread,
 | 
					    required this.thread,
 | 
				
			||||||
      required this.threadHTML,
 | 
					    required this.threadHTML,
 | 
				
			||||||
      required this.threadIDs});
 | 
					    required this.threadIDs,
 | 
				
			||||||
 | 
					    this.targetJumpNumbering,
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @override
 | 
					  @override
 | 
				
			||||||
  State<CollapsableEmails> createState() => _CollapsableEmailsState();
 | 
					  State<CollapsableEmails> createState() => _CollapsableEmailsState();
 | 
				
			||||||
| 
						 | 
					@ -60,6 +63,16 @@ class _CollapsableEmailsState extends State<CollapsableEmails> {
 | 
				
			||||||
    _markdown2Tree(allMarkdown);
 | 
					    _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
 | 
					  @override
 | 
				
			||||||
  void dispose() {
 | 
					  void dispose() {
 | 
				
			||||||
    super.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
 | 
					  @override
 | 
				
			||||||
  Widget build(BuildContext context) {
 | 
					  Widget build(BuildContext context) {
 | 
				
			||||||
    return _isLoaded
 | 
					    return _isLoaded
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue