fixed linking, now it works universally
This commit is contained in:
		
							parent
							
								
									dea8f03fe1
								
							
						
					
					
						commit
						42c97a5f5d
					
				
					 2 changed files with 31 additions and 25 deletions
				
			
		| 
						 | 
				
			
			@ -237,13 +237,13 @@ class _DynamicClassesAugment extends State<EmailToolbar> {
 | 
			
		|||
              // SizedBox(width: 8),
 | 
			
		||||
              ElevatedButton(
 | 
			
		||||
                onPressed: () => AugmentClasses()
 | 
			
		||||
                    .handleCreateLink(context, widget.emails, widget.subject),
 | 
			
		||||
                    .handleCreateLink(context, widget.emails, widget.subject, widget.emails[0]), //need to add the email ids
 | 
			
		||||
                child: Text('Create Link'),
 | 
			
		||||
              ),
 | 
			
		||||
              ElevatedButton(
 | 
			
		||||
                // onPressed: () => localAugment!.handlePaste(context),
 | 
			
		||||
                onPressed: () =>
 | 
			
		||||
                    AugmentClasses().handlePaste(context, widget.emails[0]),
 | 
			
		||||
                    AugmentClasses().handlePaste(context),
 | 
			
		||||
                child: Text('Paste Link'),
 | 
			
		||||
              ),
 | 
			
		||||
            ],
 | 
			
		||||
| 
						 | 
				
			
			@ -552,14 +552,14 @@ class AugmentClasses {
 | 
			
		|||
  }
 | 
			
		||||
 | 
			
		||||
  _copyLink(String anchor, String target, String format, String viewspecs,
 | 
			
		||||
      String nameOfDocument) {
 | 
			
		||||
    String form = "$anchor < $nameOfDocument, $target :$viewspecs >";
 | 
			
		||||
      String nameOfDocument, emailID) {
 | 
			
		||||
    String form = "$anchor < $nameOfDocument, $target :$viewspecs > $emailID";
 | 
			
		||||
    final link = ClipboardData(text: form);
 | 
			
		||||
    Clipboard.setData(link);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  Future<void> handleCreateLink(BuildContext context,
 | 
			
		||||
      List<String> emailsInThread, String nameOfDocument) async {
 | 
			
		||||
      List<String> emailsInThread, String nameOfDocument, String emailID) async {
 | 
			
		||||
    print("create link button pressed");
 | 
			
		||||
    final TextEditingController targetController = TextEditingController();
 | 
			
		||||
    final TextEditingController anchorController = TextEditingController();
 | 
			
		||||
| 
						 | 
				
			
			@ -670,7 +670,9 @@ class AugmentClasses {
 | 
			
		|||
                              targetController.text,
 | 
			
		||||
                              format,
 | 
			
		||||
                              viewspecsController.text,
 | 
			
		||||
                              nameOfDocument),
 | 
			
		||||
                              nameOfDocument,
 | 
			
		||||
                              emailID,
 | 
			
		||||
                              ),
 | 
			
		||||
                          Navigator.of(context).pop()
 | 
			
		||||
                        },
 | 
			
		||||
                    child: Text("OK")),
 | 
			
		||||
| 
						 | 
				
			
			@ -682,7 +684,7 @@ class AugmentClasses {
 | 
			
		|||
            ));
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  Future<void> handlePaste(BuildContext context, String emailID) async {
 | 
			
		||||
  Future<void> handlePaste(BuildContext context) async {
 | 
			
		||||
    final TextEditingController gotoLink = TextEditingController();
 | 
			
		||||
 | 
			
		||||
    Routinghandler localRouting;
 | 
			
		||||
| 
						 | 
				
			
			@ -716,18 +718,16 @@ class AugmentClasses {
 | 
			
		|||
                ElevatedButton(
 | 
			
		||||
                    onPressed: () {
 | 
			
		||||
                      print('pressed');
 | 
			
		||||
                      // i need this shit to be processed into args
 | 
			
		||||
                      print("email_id given $emailID");
 | 
			
		||||
                      Navigator.of(context).pop();
 | 
			
		||||
                      final localRouting =
 | 
			
		||||
                          Routinghandler(gotoLink.text, emailID);
 | 
			
		||||
                          Routinghandler(gotoLink.text);
 | 
			
		||||
                      final String subject =
 | 
			
		||||
                          localRouting.docName; // This is your :subject
 | 
			
		||||
                      final String target =
 | 
			
		||||
                          localRouting.target; // This is your :target
 | 
			
		||||
                      final String viewspecs =
 | 
			
		||||
                          localRouting.viewspecs; // This is your :viewspecs
 | 
			
		||||
                      final String finalEmailID = emailID;
 | 
			
		||||
                      final String finalEmailID = localRouting.emailID;
 | 
			
		||||
 | 
			
		||||
                      final encodedSubject = Uri.encodeComponent(subject);
 | 
			
		||||
                      final encodedTarget = Uri.encodeComponent(target);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,7 +7,7 @@ import 'api_service.dart';
 | 
			
		|||
import 'structs.dart';
 | 
			
		||||
 | 
			
		||||
class Routinghandler extends StatefulWidget {
 | 
			
		||||
  Routinghandler(String link, emailID) {
 | 
			
		||||
  Routinghandler(String link) {
 | 
			
		||||
    bool anchorDone = false;
 | 
			
		||||
 | 
			
		||||
    bool docNameDone = false;
 | 
			
		||||
| 
						 | 
				
			
			@ -16,6 +16,8 @@ class Routinghandler extends StatefulWidget {
 | 
			
		|||
 | 
			
		||||
    bool targetDone = false;
 | 
			
		||||
 | 
			
		||||
    bool emailIdDone = false;
 | 
			
		||||
 | 
			
		||||
    for (int letter = 0; letter < link.length; letter++) {
 | 
			
		||||
      if (!anchorDone) {
 | 
			
		||||
        if (link[letter] != '<') {
 | 
			
		||||
| 
						 | 
				
			
			@ -44,6 +46,8 @@ class Routinghandler extends StatefulWidget {
 | 
			
		|||
        } else {
 | 
			
		||||
          viewspecsDone = true;
 | 
			
		||||
        }
 | 
			
		||||
      } else if (!emailIdDone) {
 | 
			
		||||
        emailID += link[letter];
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    anchor = anchor.trim();
 | 
			
		||||
| 
						 | 
				
			
			@ -55,11 +59,11 @@ class Routinghandler extends StatefulWidget {
 | 
			
		|||
  }
 | 
			
		||||
  Routinghandler.fromParameters(String anchor, String docName, String target,
 | 
			
		||||
      String viewspecs, String emailID) {
 | 
			
		||||
    this.anchor = anchor;
 | 
			
		||||
    this.docName = docName;
 | 
			
		||||
    this.viewspecs = viewspecs;
 | 
			
		||||
    this.target = target;
 | 
			
		||||
    this.emailID = emailID;
 | 
			
		||||
        this.anchor = anchor;
 | 
			
		||||
        this.docName = docName;
 | 
			
		||||
        this.viewspecs = viewspecs;
 | 
			
		||||
        this.target = target;
 | 
			
		||||
        this.emailID = emailID;
 | 
			
		||||
  }
 | 
			
		||||
  Routinghandler.copyConstructor(Routinghandler other) {
 | 
			
		||||
    anchor = other.anchor;
 | 
			
		||||
| 
						 | 
				
			
			@ -201,14 +205,16 @@ class _RoutingHandlerState extends State<Routinghandler> {
 | 
			
		|||
                        ),
 | 
			
		||||
                      ),
 | 
			
		||||
                      Expanded(
 | 
			
		||||
                        child: Align(
 | 
			
		||||
                          alignment: Alignment.topLeft,
 | 
			
		||||
                          child: Wrap(children: [
 | 
			
		||||
                            MarkdownBlock(
 | 
			
		||||
                              data: aug!.children![0]!.children![i]!.data ?? ''),
 | 
			
		||||
                          ],)
 | 
			
		||||
                        )
 | 
			
		||||
                        ),
 | 
			
		||||
                          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(
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue