routing, and link handling
This commit is contained in:
		
							parent
							
								
									c025fbe07a
								
							
						
					
					
						commit
						b961be3e8b
					
				
					 1 changed files with 56 additions and 38 deletions
				
			
		| 
						 | 
				
			
			@ -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<Routinghandler> {
 | 
			
		||||
  List<String> markdownContent = [];
 | 
			
		||||
  bool _isLoaded = false;
 | 
			
		||||
  AugmentTree? aug;
 | 
			
		||||
 | 
			
		||||
  @override
 | 
			
		||||
  void initState() {
 | 
			
		||||
| 
						 | 
				
			
			@ -143,13 +145,15 @@ class _RoutingHandlerState extends State<Routinghandler> {
 | 
			
		|||
 | 
			
		||||
  Future<void> _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<Routinghandler> {
 | 
			
		|||
        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<StatefulWidget> createState() => _LinkViewerState();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class _LinkViewerState extends State<LinkViewer> {
 | 
			
		||||
  @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)),
 | 
			
		||||
                        ),
 | 
			
		||||
                      ),
 | 
			
		||||
                    ]),
 | 
			
		||||
            ]))));
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue