|
@@ -22,40 +22,40 @@ class EmailToolbar extends StatefulWidget {
|
|
|
|
|
|
class _DynamicClassesAugment extends State<EmailToolbar> {
|
|
|
String selectedClass = 'Class 1';
|
|
|
- TextEditingController _jumpController = TextEditingController();
|
|
|
+ // TextEditingController _jumpController = TextEditingController();
|
|
|
|
|
|
- late final FocusNode _JumpItemfocusNode;
|
|
|
- late final FocusNode _viewSpecsfocusNode;
|
|
|
+ // late final FocusNode _JumpItemfocusNode;
|
|
|
+ // late final FocusNode _viewSpecsfocusNode;
|
|
|
|
|
|
- bool _jumpItemHasFocus = false;
|
|
|
- bool _viewSpecsHasFocus = false;
|
|
|
+ // bool _jumpItemHasFocus = false;
|
|
|
+ // bool _viewSpecsHasFocus = false;
|
|
|
|
|
|
@override
|
|
|
void initState() {
|
|
|
super.initState();
|
|
|
- _JumpItemfocusNode = FocusNode();
|
|
|
- _viewSpecsfocusNode = FocusNode();
|
|
|
+ // _JumpItemfocusNode = FocusNode();
|
|
|
+ // _viewSpecsfocusNode = FocusNode();
|
|
|
|
|
|
- _JumpItemfocusNode.addListener(() {
|
|
|
- setState(() => _jumpItemHasFocus = _JumpItemfocusNode.hasFocus);
|
|
|
- });
|
|
|
+ // _JumpItemfocusNode.addListener(() {
|
|
|
+ // setState(() => _jumpItemHasFocus = _JumpItemfocusNode.hasFocus);
|
|
|
+ // });
|
|
|
|
|
|
- _viewSpecsfocusNode.addListener(() {
|
|
|
- setState(() => _viewSpecsHasFocus = _viewSpecsfocusNode.hasFocus);
|
|
|
- });
|
|
|
+ // _viewSpecsfocusNode.addListener(() {
|
|
|
+ // setState(() => _viewSpecsHasFocus = _viewSpecsfocusNode.hasFocus);
|
|
|
+ // });
|
|
|
}
|
|
|
|
|
|
@override
|
|
|
void dispose() {
|
|
|
// _JumpItemfocusNode.dispose();
|
|
|
// _viewSpecsfocusNode.dispose();
|
|
|
- _jumpController.dispose();
|
|
|
+ // _jumpController.dispose();
|
|
|
super.dispose();
|
|
|
}
|
|
|
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
|
- const animationDuration = Duration(milliseconds: 250);
|
|
|
+ // const animationDuration = Duration(milliseconds: 250);
|
|
|
|
|
|
return Column(children: [
|
|
|
Row(
|
|
@@ -120,15 +120,22 @@ class _DynamicClassesAugment extends State<EmailToolbar> {
|
|
|
Stack(children: [
|
|
|
Row(
|
|
|
children: [
|
|
|
+ ElevatedButton(
|
|
|
+ onPressed: () => AugmentClasses.JumpButton(context),
|
|
|
+ child: Text('JumpItem:'),
|
|
|
+ ),
|
|
|
+ // SizedBox(
|
|
|
+ // width: 8,
|
|
|
+ // ),
|
|
|
Container(
|
|
|
- width: 150,
|
|
|
+ width: 50,
|
|
|
height: 30,
|
|
|
child: TextField(
|
|
|
- controller: _jumpController,
|
|
|
+ // controller: _jumpController,
|
|
|
decoration: InputDecoration(
|
|
|
- labelText: 'Jump Item',
|
|
|
- border: OutlineInputBorder(),
|
|
|
- suffixIcon: Icon(Icons.search)),
|
|
|
+ border: OutlineInputBorder(),
|
|
|
+ // suffixIcon: Icon(Icons.search)
|
|
|
+ ),
|
|
|
onSubmitted: (value) {
|
|
|
print("onSubmitted");
|
|
|
if (value.isNotEmpty) {
|
|
@@ -165,14 +172,18 @@ class _DynamicClassesAugment extends State<EmailToolbar> {
|
|
|
// ),
|
|
|
// ),
|
|
|
SizedBox(width: 8),
|
|
|
+ ElevatedButton(
|
|
|
+ onPressed: () => AugmentClasses.ViewSpecsButton(context),
|
|
|
+ child: Text('ViewSpecs:')),
|
|
|
Container(
|
|
|
- width: 150,
|
|
|
+ width: 50,
|
|
|
height: 30,
|
|
|
child: TextField(
|
|
|
decoration: InputDecoration(
|
|
|
- labelText: 'viewSpecs',
|
|
|
- border: OutlineInputBorder(),
|
|
|
- suffixIcon: Icon(Icons.style_rounded)),
|
|
|
+ labelText: '',
|
|
|
+ border: OutlineInputBorder(),
|
|
|
+ // suffixIcon: Icon(Icons.style_rounded)
|
|
|
+ ),
|
|
|
),
|
|
|
),
|
|
|
ElevatedButton(
|
|
@@ -225,39 +236,7 @@ class AugmentClasses {
|
|
|
print("Stop button pressed");
|
|
|
}
|
|
|
|
|
|
- static void handleJump(String viewTypeId, String spanId) {
|
|
|
- print(spanId);
|
|
|
- // final jsCode = '''
|
|
|
- // var iframe = document.getElementById("iframe#$viewTypeId").contentWindow;
|
|
|
- // var element = iframe.document.getElementById('$spanId');
|
|
|
- // if (element) {
|
|
|
- // element.scrollIntoView({behavior: "smooth", block: "start"});
|
|
|
- // }
|
|
|
- // ''';
|
|
|
-// final jsCode = '''
|
|
|
-// var iframe = document.getElementById("$viewTypeId");
|
|
|
-// if (iframe) {
|
|
|
-// var iframeWindow = iframe.contentWindow;
|
|
|
-// if (iframeWindow && iframeWindow.document) {
|
|
|
-// var element = iframeWindow.document.getElementById('$spanId');
|
|
|
-// if (element) {
|
|
|
-// element.scrollIntoView({behavior: "smooth", block: "start"});
|
|
|
-// console.log("Scrolling to element with ID: $spanId");
|
|
|
-// } else {
|
|
|
-// console.error("Element with ID $spanId not found in iframe.");
|
|
|
-// }
|
|
|
-// } else {
|
|
|
-// console.error("Iframe contentWindow or document is not accessible.");
|
|
|
-// }
|
|
|
-// } else {
|
|
|
-// console.error("Iframe with ID $viewTypeId not found.");
|
|
|
-// }
|
|
|
-// ''';
|
|
|
- // print('jumped'); // For debugging in Dart
|
|
|
-
|
|
|
- // // Execute the JavaScript code
|
|
|
- // js.context.callMethod('eval', [jsCode]);
|
|
|
- // Select the first iframe on the page
|
|
|
+ static void handleJump(String spanId) {
|
|
|
String js_code = '''
|
|
|
var iframe = document.getElementsByTagName('iframe')[0]; // 0 for the first iframe, 1 for the second, etc.
|
|
|
|
|
@@ -280,6 +259,213 @@ class AugmentClasses {
|
|
|
console.log('Iframe not found or not loaded.');
|
|
|
}
|
|
|
''';
|
|
|
- js.context.callMethod('eval', [js_code]);
|
|
|
+ js.context.callMethod('eval', [js_code]);
|
|
|
+ }
|
|
|
+
|
|
|
+ static void invisibility(String htmlClass) {}
|
|
|
+
|
|
|
+ static Future<void> JumpButton(BuildContext context) async {
|
|
|
+ // FocusNode textFieldFocusNode = FocusNode();
|
|
|
+
|
|
|
+ AugmentClasses.disableIframePointerEvents();
|
|
|
+ await showDialog(
|
|
|
+ barrierDismissible: true,
|
|
|
+ // barrierColor: Colors.yellow,
|
|
|
+ context: context,
|
|
|
+ builder: (context) => AlertDialog(
|
|
|
+ title: Text('Jump Item:'),
|
|
|
+ content: Container(
|
|
|
+ width: 200,
|
|
|
+ height: 120,
|
|
|
+ child: Column(
|
|
|
+ mainAxisSize: MainAxisSize.min,
|
|
|
+ children: [
|
|
|
+ Text('Jump (to) Item (at)'),
|
|
|
+ SizedBox(height: 10),
|
|
|
+ TextField(
|
|
|
+ autofocus: true,
|
|
|
+ decoration: InputDecoration(
|
|
|
+ labelText: '...',
|
|
|
+ border: OutlineInputBorder(),
|
|
|
+ suffixIcon: Icon(Icons.search)),
|
|
|
+ onSubmitted: (value) {
|
|
|
+ print("onSubmitted: $value");
|
|
|
+ if (value.isNotEmpty) {
|
|
|
+ handleJump(value);
|
|
|
+ Navigator.of(context).pop();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ actions: [
|
|
|
+ TextButton(
|
|
|
+ onPressed: () {
|
|
|
+ Navigator.of(context).pop();
|
|
|
+ // print('close pressed');
|
|
|
+ },
|
|
|
+ child: Text('close'),
|
|
|
+ ),
|
|
|
+ ElevatedButton(
|
|
|
+ onPressed: () => ViewSpecsButton(context),
|
|
|
+ child: Text('viewspecs'))
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ).then((_) {
|
|
|
+ AugmentClasses.enableIframePointerEvents();
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ static Future<void> ViewSpecsButton(context) async {
|
|
|
+ //TODO: finish it
|
|
|
+
|
|
|
+ bool blankLines = false;
|
|
|
+ bool numbering = false;
|
|
|
+ bool statementSignatures = false;
|
|
|
+ AugmentClasses.disableIframePointerEvents();
|
|
|
+ await showDialog(
|
|
|
+ context: context,
|
|
|
+ builder: (context) => Container(
|
|
|
+ height: 150,
|
|
|
+ width: 300,
|
|
|
+ child: AlertDialog(
|
|
|
+ title: Text('Viewspecs(short)'),
|
|
|
+ content: Container(
|
|
|
+ width: 400, // Set the width to simulate the Windows style
|
|
|
+ child: Column(
|
|
|
+ mainAxisSize: MainAxisSize.min,
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
+ children: [
|
|
|
+ Row(
|
|
|
+ children: [
|
|
|
+ // First section: Checkboxes for "Show"
|
|
|
+ Expanded(
|
|
|
+ child: Column(
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
+ children: [
|
|
|
+ Text('Show'),
|
|
|
+ Row(
|
|
|
+ children: [
|
|
|
+ Text("y z"),
|
|
|
+ Checkbox(
|
|
|
+ value: blankLines,
|
|
|
+ onChanged: (bool? value) {
|
|
|
+ blankLines = value!;
|
|
|
+ },
|
|
|
+ ),
|
|
|
+ Text('Blank lines'),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ Row(
|
|
|
+ children: [
|
|
|
+ Text('m n'),
|
|
|
+ Checkbox(
|
|
|
+ value: numbering,
|
|
|
+ onChanged: (bool? value) {
|
|
|
+ numbering = value!;
|
|
|
+ },
|
|
|
+ ),
|
|
|
+ Text('Numbering'),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ Row(
|
|
|
+ children: [
|
|
|
+ Text('K L'),
|
|
|
+ Checkbox(
|
|
|
+ value: statementSignatures,
|
|
|
+ onChanged: (bool? value) {
|
|
|
+ statementSignatures = value!;
|
|
|
+ },
|
|
|
+ ),
|
|
|
+ Text('Statement signatures'),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ // Second section: Numeric input for Outline, Levels, and Lines
|
|
|
+ Expanded(
|
|
|
+ child: Column(
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
+ children: [
|
|
|
+ Text('Outline'),
|
|
|
+ Row(
|
|
|
+ children: [
|
|
|
+ Text('Levels'),
|
|
|
+ SizedBox(width: 10),
|
|
|
+ Container(
|
|
|
+ width: 40,
|
|
|
+ child: TextField(
|
|
|
+ decoration: InputDecoration(
|
|
|
+ isDense: true,
|
|
|
+ border: OutlineInputBorder(),
|
|
|
+ ),
|
|
|
+ keyboardType: TextInputType.number,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ Row(
|
|
|
+ children: [
|
|
|
+ Text('Lines'),
|
|
|
+ SizedBox(width: 10),
|
|
|
+ Container(
|
|
|
+ width: 40,
|
|
|
+ child: TextField(
|
|
|
+ decoration: InputDecoration(
|
|
|
+ isDense: true,
|
|
|
+ border: OutlineInputBorder(),
|
|
|
+ ),
|
|
|
+ keyboardType: TextInputType.number,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ SizedBox(height: 20),
|
|
|
+ Row(
|
|
|
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
+ children: [
|
|
|
+ ElevatedButton(onPressed: () {}, child: Text('OK')),
|
|
|
+ ElevatedButton(
|
|
|
+ onPressed: () {
|
|
|
+ Navigator.of(context).pop();
|
|
|
+ },
|
|
|
+ child: Text('Cancel')),
|
|
|
+ ElevatedButton(
|
|
|
+ onPressed: () {}, child: Text('Reset')),
|
|
|
+ ElevatedButton(onPressed: () {}, child: Text('Help')),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ )).then((_) {
|
|
|
+ AugmentClasses.enableIframePointerEvents();
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ static void disableIframePointerEvents() {
|
|
|
+ final iframes = html.document.getElementsByTagName('iframe');
|
|
|
+ for (var iframe in iframes) {
|
|
|
+ if (iframe is html.Element) {
|
|
|
+ iframe.style.pointerEvents = 'none'; // Disable pointer events
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ static void enableIframePointerEvents() {
|
|
|
+ final iframes = html.document.getElementsByTagName('iframe');
|
|
|
+ for (var iframe in iframes) {
|
|
|
+ if (iframe is html.Element) {
|
|
|
+ iframe.style.pointerEvents = 'auto'; // Re-enable pointer events
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|