viewspecs and jump textfield controller

This commit is contained in:
Juan Marulanda De Los Rios 2025-06-12 16:07:31 -04:00
parent 34989d8213
commit edec45669d

View File

@ -1,16 +1,18 @@
import 'package:crab_ui/api_service.dart'; import 'package:crab_ui/api_service.dart';
import 'package:crab_ui/attachmentDownload.dart'; import 'package:crab_ui/attachmentDownload.dart';
import 'package:crab_ui/collapsableEmails.dart';
import 'package:crab_ui/structs.dart'; import 'package:crab_ui/structs.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:pointer_interceptor/pointer_interceptor.dart'; import 'package:pointer_interceptor/pointer_interceptor.dart';
import 'attachmentWidget.dart'; import 'attachmentWidget.dart';
class EmailToolbar extends StatefulWidget { class EmailToolbar extends StatefulWidget {
final Function(String) onJumpToSpan; final Function(String) onJumpToNumbering;
final Function(String) onViewspecs;
final VoidCallback onButtonPressed; final VoidCallback onButtonPressed;
EmailToolbar( EmailToolbar(
{Key? key, required this.onButtonPressed, required this.onJumpToSpan}) {Key? key, required this.onButtonPressed, required this.onJumpToNumbering, required this.onViewspecs})
: super(key: key); : super(key: key);
@override @override
@ -19,7 +21,8 @@ class EmailToolbar extends StatefulWidget {
class _DynamicClassesAugment extends State<EmailToolbar> { class _DynamicClassesAugment extends State<EmailToolbar> {
String selectedClass = 'Class 1'; String selectedClass = 'Class 1';
// TextEditingController _jumpController = TextEditingController(); TextEditingController _jumpController = TextEditingController();
TextEditingController _viewspecsController = TextEditingController();
// late final FocusNode _JumpItemfocusNode; // late final FocusNode _JumpItemfocusNode;
// late final FocusNode _viewSpecsfocusNode; // late final FocusNode _viewSpecsfocusNode;
@ -46,7 +49,7 @@ class _DynamicClassesAugment extends State<EmailToolbar> {
void dispose() { void dispose() {
// _JumpItemfocusNode.dispose(); // _JumpItemfocusNode.dispose();
// _viewSpecsfocusNode.dispose(); // _viewSpecsfocusNode.dispose();
// _jumpController.dispose(); _jumpController.dispose();
super.dispose(); super.dispose();
} }
@ -71,20 +74,20 @@ class _DynamicClassesAugment extends State<EmailToolbar> {
child: Text('Attachments'), child: Text('Attachments'),
), ),
SizedBox(width: 8), SizedBox(width: 8),
ElevatedButton( // ElevatedButton(
onPressed: AugmentClasses.handleOpen, // onPressed: AugmentClasses.handleOpen,
child: Text('Open'), // child: Text('Open'),
), // ),
// SizedBox(width: 8), // SizedBox(width: 8),
ElevatedButton( ElevatedButton(
onPressed: AugmentClasses.handleFind, onPressed: AugmentClasses.handleFind,
child: Text('Find'), child: Text('Find'),
), ),
// SizedBox(width: 8), // SizedBox(width: 8),
ElevatedButton( // ElevatedButton(
onPressed: AugmentClasses.handleStop, // onPressed: AugmentClasses.handleStop,
child: Text('Stop'), // child: Text('Stop'),
), // ),
ElevatedButton( ElevatedButton(
onPressed: () { onPressed: () {
AugmentClasses.handleMove(context); AugmentClasses.handleMove(context);
@ -131,10 +134,10 @@ class _DynamicClassesAugment extends State<EmailToolbar> {
// width: 8, // width: 8,
// ), // ),
Container( Container(
width: 50, width: 100,
height: 30, height: 30,
child: TextField( child: TextField(
// controller: _jumpController, controller: _jumpController,
decoration: InputDecoration( decoration: InputDecoration(
border: OutlineInputBorder(), border: OutlineInputBorder(),
// suffixIcon: Icon(Icons.search) // suffixIcon: Icon(Icons.search)
@ -142,7 +145,7 @@ class _DynamicClassesAugment extends State<EmailToolbar> {
onSubmitted: (value) { onSubmitted: (value) {
print("onSubmitted"); print("onSubmitted");
if (value.isNotEmpty) { if (value.isNotEmpty) {
widget.onJumpToSpan(value); widget.onJumpToNumbering(value);
} }
}, },
), ),
@ -179,14 +182,18 @@ class _DynamicClassesAugment extends State<EmailToolbar> {
onPressed: () => AugmentClasses.ViewSpecsButton(context), onPressed: () => AugmentClasses.ViewSpecsButton(context),
child: Text('ViewSpecs:')), child: Text('ViewSpecs:')),
Container( Container(
width: 50, width: 100,
height: 30, height: 30,
child: TextField( child: TextField(
controller: _viewspecsController,
decoration: InputDecoration( decoration: InputDecoration(
labelText: '', labelText: '',
border: OutlineInputBorder(), border: OutlineInputBorder(),
// suffixIcon: Icon(Icons.style_rounded) // suffixIcon: Icon(Icons.style_rounded)
), ),
onSubmitted: (value) {
widget.onViewspecs(value);
},
), ),
), ),
ElevatedButton( ElevatedButton(
@ -484,30 +491,8 @@ class AugmentClasses {
print("Stop button pressed"); print("Stop button pressed");
} }
static void handleJump(String spanId) { static void handleJump(String value) {
String js_code = ''' print(value);
var iframe = document.getElementsByTagName('iframe')[0]; // 0 for the first iframe, 1 for the second, etc.
// Check if the iframe is loaded and has content
if (iframe && iframe.contentDocument) {
// Access the document inside the iframe
var iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
// Find the element with the specific id inside the iframe
var targetElement = iframeDoc.getElementById("$spanId"); // Replace '36 ' with the actual id of the target element
// If the element exists, scroll to it
if (targetElement) {
targetElement.scrollIntoView();
console.log('Scrolled to element with id "$spanId" inside the iframe.');
} else {
console.log('Element with id "$spanId" not found inside the iframe.');
}
} else {
console.log('Iframe not found or not loaded.');
}
''';
// js.context.callMethod('eval', [js_code]);
} }
static void invisibility(String htmlClass) {} static void invisibility(String htmlClass) {}