From dcb93a18c690a17a7e716bc619699020d86ab337 Mon Sep 17 00:00:00 2001 From: juan Date: Tue, 8 Jul 2025 13:24:54 -0400 Subject: [PATCH] added copying the link to your device --- lib/augment.dart | 161 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 158 insertions(+), 3 deletions(-) diff --git a/lib/augment.dart b/lib/augment.dart index 4be4e23..42f2d3a 100644 --- a/lib/augment.dart +++ b/lib/augment.dart @@ -1,15 +1,19 @@ import 'package:crab_ui/api_service.dart'; import 'package:crab_ui/attachmentDownload.dart'; +import 'package:crab_ui/collapsableEmails.dart'; import 'package:crab_ui/structs.dart'; import 'package:flutter/material.dart'; import 'package:pointer_interceptor/pointer_interceptor.dart'; import 'attachmentWidget.dart'; +import 'package:flutter/services.dart'; class EmailToolbar extends StatefulWidget { final Function(String) onJumpToNumbering; final Function(String) onViewspecs; final VoidCallback onButtonPressed; final Function(String) onFiltering; + final List emails; + final String subject; EmailToolbar({ Key? key, @@ -17,6 +21,8 @@ class EmailToolbar extends StatefulWidget { required this.onJumpToNumbering, required this.onViewspecs, required this.onFiltering, + required this.emails, + required this.subject, }) : super(key: key); @override @@ -27,6 +33,8 @@ class _DynamicClassesAugment extends State { String selectedClass = 'Class 1'; TextEditingController _jumpController = TextEditingController(); TextEditingController _viewspecsController = TextEditingController(); + AugmentClasses? localAugment; + List? emailsInThread; // late final FocusNode _JumpItemfocusNode; // late final FocusNode _viewSpecsfocusNode; @@ -47,6 +55,17 @@ class _DynamicClassesAugment extends State { // _viewSpecsfocusNode.addListener(() { // setState(() => _viewSpecsHasFocus = _viewSpecsfocusNode.hasFocus); // }); + _serializableData(widget.emails); + } + + void _serializableData(List threadID) async { + // emailsInThread = await ApiService().threadsInSerializable(); + print("done thread serializable"); + + if (!mounted) return; + // setState(() { + // _isLoaded = true; + // }); } @override @@ -201,7 +220,8 @@ class _DynamicClassesAugment extends State { ), ), ElevatedButton( - onPressed: () => AugmentClasses().filterButton(context, widget.onFiltering), + onPressed: () => + AugmentClasses().filterButton(context, widget.onFiltering), child: Text('Filter'), ), SizedBox(width: 8), @@ -211,7 +231,8 @@ class _DynamicClassesAugment extends State { ), // SizedBox(width: 8), ElevatedButton( - onPressed: AugmentClasses.handleFind, + onPressed: () => AugmentClasses() + .handleCreateLink(context, widget.emails, widget.subject), child: Text('Create Link'), ), ElevatedButton( @@ -226,6 +247,13 @@ class _DynamicClassesAugment extends State { } class AugmentClasses { + CollapsableEmails? localCollapsable; + String? nameOfDocument; + + // AugmentClasses(CollapsableEmails localCollapsable) { + // localCollapsable = localCollapsable; + // } + static OverlayEntry? _overlayEntry; static String? selectedFolder; // Manage selected folder at the class level @@ -491,6 +519,131 @@ class AugmentClasses { print("Find button pressed"); } + _copyLink(String anchor, String target, String format, String viewspecs, + String nameOfDocument) { + String form = "$anchor < $nameOfDocument, $target :$viewspecs >"; + final link = ClipboardData(text: form); + Clipboard.setData(link); + } + + Future handleCreateLink(BuildContext context, + List emailsInThread, String nameOfDocument) async { + print("create link button pressed"); + final TextEditingController targetController = TextEditingController(); + final TextEditingController anchorController = TextEditingController(); + final TextEditingController viewspecsController = TextEditingController(); + final TextEditingController formatController = TextEditingController(); + + // String anchorPhrase = ''; + String format = 'augment'; + // String target = ''; + // String viewspecs = ''; + + await showDialog( + context: context, + builder: (context) => AlertDialog( + title: Text('Create URL Link'), + content: SizedBox( + height: 400, + child: Column( + children: [ + Row( + children: [ + Text("Which email? "), + SizedBox( + width: 350.0, + child: Text(nameOfDocument), + // child: ListView.builder( + // itemCount: emailsInThread.length, + // itemBuilder: (context, index) { + // // var item = emailsInThread[index]; + // // ApiService(). + // return ListTile( + // title: Text(nameOfDocument), + // ); + // }), + ) + ], + ), + Row( + children: [ + Text("Link to target item at: "), + SizedBox( + width: 350.0, + child: TextField( + controller: targetController, + autofocus: true, + maxLines: 1, + decoration: const InputDecoration( + border: OutlineInputBorder(), + ), + ), + ), + ], + ), + SizedBox(height: 8), + Row( + children: [ + ElevatedButton( + onPressed: () => ViewSpecsButton(context), + child: Text("Viewspecs:")), + SizedBox( + width: 150.0, + child: TextField( + controller: viewspecsController, + maxLines: 1, + decoration: const InputDecoration( + border: OutlineInputBorder(), + ), + ), + ), + ], + ), + SizedBox(height: 8), + Row( + children: [ + Text("Using anchor phrase: "), + SizedBox( + width: 150.0, + child: TextField( + controller: anchorController, + maxLines: 1, + decoration: const InputDecoration( + border: OutlineInputBorder(), + ), + ), + ), + ], + ), + SizedBox(height: 8), + Row( + children: [ + Text("Using link format: "), + SizedBox( + width: 250.0, + child: Text("Augment"), + ), + ], + ) + ], + ), + ), + actions: [ + ElevatedButton( + onPressed: () => { + _copyLink(anchorController.text, targetController.text, format, viewspecsController.text, + nameOfDocument), + Navigator.of(context).pop() + }, + child: Text("OK")), + ElevatedButton( + onPressed: () => Navigator.of(context).pop(), + child: Text("Cancel")), + ElevatedButton(onPressed: null, child: Text("Help")), + ], + )); + } + static void handleStop() { print("Stop button pressed"); } @@ -728,7 +881,8 @@ class AugmentClasses { return []; } - Future filterButton(context, Function(String) onFilteringCallback) async { + Future filterButton( + context, Function(String) onFilteringCallback) async { //this is literally ctrl+F :skull: //idea is to search in file, extract the

tags that contain these //words and highlight, then when zoom, you just jump to that paragraph @@ -756,6 +910,7 @@ class AugmentClasses { SizedBox( width: 175, child: TextField( + autofocus: true, maxLines: 1, decoration: const InputDecoration( border: OutlineInputBorder(),