From b961be3e8bf0f6630bcb0400bf5a29b62236557a Mon Sep 17 00:00:00 2001 From: juan Date: Wed, 23 Jul 2025 10:29:28 -0400 Subject: [PATCH] routing, and link handling --- lib/routingHandler.dart | 94 ++++++++++++++++++++++++----------------- 1 file changed, 56 insertions(+), 38 deletions(-) diff --git a/lib/routingHandler.dart b/lib/routingHandler.dart index f3052a6..55c7b26 100644 --- a/lib/routingHandler.dart +++ b/lib/routingHandler.dart @@ -4,6 +4,7 @@ import 'package:go_router/go_router.dart'; import 'package:markdown/markdown.dart' as md; import 'package:markdown_widget/markdown_widget.dart'; import 'api_service.dart'; +import 'structs.dart'; class Routinghandler extends StatefulWidget { Routinghandler(String link, emailID) { @@ -133,6 +134,7 @@ class Routinghandler extends StatefulWidget { class _RoutingHandlerState extends State { List markdownContent = []; bool _isLoaded = false; + AugmentTree? aug; @override void initState() { @@ -143,13 +145,15 @@ class _RoutingHandlerState extends State { Future _loadMarkdown() async { String folder = ApiService.currFolder; - // print(folder); print(widget.getEmailID()); String emailID = widget.emailID; print("inside _loadMarkdown in routinghandler $emailID"); markdownContent = - await ApiService().fetchMarkdownContent([emailID], "INBOX"); + await ApiService().fetchMarkdownContent([emailID], folder); // print(markdownContent); + aug = AugmentTree.fromMD(markdownContent[0]); + aug!.addNumbering(); + setState(() { _isLoaded = true; }); @@ -162,44 +166,58 @@ class _RoutingHandlerState extends State { child: CircularProgressIndicator(), ); } - return Scaffold( - appBar: AppBar( - title: Text("Routing Handler"), - leading: IconButton( - onPressed: () { - GoRouter.of(context).go('/home'); - }, - icon: const Icon(Icons.arrow_back_ios)), - ), - body: ConstrainedBox( - constraints: BoxConstraints( - minHeight: 100, - maxHeight: MediaQuery.of(context).size.height * 0.7, - ), - child: SingleChildScrollView( - child:MarkdownBlock(data: markdownContent[0]))), - ); - } -} - -class LinkViewer extends StatefulWidget { - const LinkViewer({super.key}); - - @override - State createState() => _LinkViewerState(); -} - -class _LinkViewerState extends State { - @override - Widget build(BuildContext context) { - // this should be a class that opens a popup of the email on the view it wants - return Scaffold( appBar: AppBar( - title: Text('url viewer'), + title: Text("Routing Handler"), + leading: IconButton( + onPressed: () { + GoRouter.of(context).go('/home'); + }, + icon: const Icon(Icons.arrow_back_ios)), ), - body: Column( - children: [], - )); + body: ConstrainedBox( + constraints: BoxConstraints( + minHeight: 100, + maxHeight: MediaQuery.of(context).size.height * 0.7, + ), + child: SingleChildScrollView( + //inside here put the bunch rows + //make rows of markdownBlocks, but firstly i need to conveert the content into a tree + // child:MarkdownBlock(data: markdownContent[0]) + + child: Column(children: [ + for (int i = 0; i < this.aug!.children![0]!.children.length; i++) + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // if (leftNumbering) + Padding( + padding: const EdgeInsets.fromLTRB(0, 10, 5, 0), + child: Text( + aug!.children![0]!.children![i]!.numbering, + style: TextStyle( + color: Color(Colors.purple[400]!.value)), + ), + ), + Expanded( + child: Align( + alignment: Alignment.topLeft, + child: Wrap(children: [ + MarkdownBlock( + data: aug!.children![0]!.children![i]!.data ?? ''), + ],) + ) + ), + Padding( + padding: const EdgeInsets.fromLTRB(0, 10, 5, 0), + child: Text( + aug!.children![0]!.children![i]!.numbering, + style: TextStyle( + color: Color(Colors.purple[400]!.value)), + ), + ), + ]), + ])))); } }