augment.dart 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. import 'package:flutter/material.dart';
  2. import 'package:http/http.dart' as http;
  3. import 'dart:convert';
  4. import 'dart:ui_web' as ui;
  5. import 'dart:html' as html;
  6. import 'dart:js' as js;
  7. class EmailToolbar extends StatefulWidget {
  8. final VoidCallback onButtonPressed;
  9. EmailToolbar({Key? key, required this.onButtonPressed}) : super(key: key);
  10. @override
  11. _DynamicClassesAugment createState() => _DynamicClassesAugment();
  12. }
  13. class _DynamicClassesAugment extends State<EmailToolbar> {
  14. String selectedClass = 'Class 1';
  15. late final FocusNode _JumpItemfocusNode;
  16. late final FocusNode _viewSpecsfocusNode;
  17. bool _jumpItemHasFocus = false;
  18. bool _viewSpecsHasFocus = false;
  19. @override
  20. void initState() {
  21. super.initState();
  22. _JumpItemfocusNode = FocusNode();
  23. _viewSpecsfocusNode = FocusNode();
  24. _JumpItemfocusNode.addListener(() {
  25. setState(() => _jumpItemHasFocus = _JumpItemfocusNode.hasFocus);
  26. });
  27. _viewSpecsfocusNode.addListener(() {
  28. setState(() => _viewSpecsHasFocus = _viewSpecsfocusNode.hasFocus);
  29. });
  30. }
  31. @override
  32. void dispose() {
  33. _JumpItemfocusNode.dispose();
  34. _viewSpecsfocusNode.dispose();
  35. super.dispose();
  36. }
  37. @override
  38. Widget build(BuildContext context) {
  39. const animationDuration = Duration(milliseconds: 250);
  40. return Column(children: [
  41. Row(
  42. children: [
  43. ElevatedButton(
  44. onPressed: () => AugmentClasses.handleHome(context),
  45. child: Text('Home'),
  46. ),
  47. SizedBox(width: 8),
  48. ElevatedButton(
  49. onPressed: AugmentClasses.handleReload,
  50. child: Text('Reload'),
  51. ),
  52. ElevatedButton(
  53. onPressed: AugmentClasses.handleImages,
  54. child: Text('Images'),
  55. ),
  56. SizedBox(width: 8),
  57. ElevatedButton(
  58. onPressed: AugmentClasses.handleOpen,
  59. child: Text('Open'),
  60. ),
  61. // SizedBox(width: 8),
  62. ElevatedButton(
  63. onPressed: AugmentClasses.handleFind,
  64. child: Text('Find'),
  65. ),
  66. // SizedBox(width: 8),
  67. ElevatedButton(
  68. onPressed: AugmentClasses.handleStop,
  69. child: Text('Stop'),
  70. ),
  71. Spacer(),
  72. PopupMenuButton<String>(
  73. onSelected: (String value) {
  74. setState(() {
  75. selectedClass = value;
  76. print(selectedClass);
  77. });
  78. },
  79. itemBuilder: (BuildContext context) => <PopupMenuEntry<String>>[
  80. const PopupMenuItem<String>(
  81. value: 'Class 1',
  82. child: Text('Class 1'),
  83. ),
  84. const PopupMenuItem<String>(
  85. value: 'Class 2',
  86. child: Text('Class 2'),
  87. ),
  88. const PopupMenuItem<String>(
  89. value: 'Turbo 3',
  90. child: Text('Turbo 3'),
  91. ),
  92. ],
  93. // child: ElevatedButton(
  94. // onPressed: () {},
  95. child: Text('Options'),
  96. ),
  97. ],
  98. ),
  99. if (selectedClass == 'Class 2')
  100. Stack(children: [
  101. Row(
  102. children: [
  103. Container(
  104. width: 150,
  105. height: 30,
  106. child: TextField(
  107. decoration: InputDecoration(
  108. labelText: 'Jump Item',
  109. border: OutlineInputBorder(),
  110. suffixIcon: Icon(Icons.search)),
  111. ),
  112. ),
  113. //TODO: Make an animation to make the button a textfield
  114. // AnimatedSwitcher(
  115. // duration: animationDuration,
  116. // transitionBuilder: (Widget child, Animation<double> animation) {
  117. // return FadeTransition(opacity: animation, child: child);
  118. // },
  119. // child: _jumpItemHasFocus
  120. // ? Container(
  121. // key: ValueKey('TextField1'),
  122. // width: 150,
  123. // child: TextField(
  124. // focusNode: _JumpItemfocusNode,
  125. // decoration: InputDecoration(
  126. // hintText: 'Enter Text',
  127. // border: OutlineInputBorder(),
  128. // ),
  129. // ),
  130. // )
  131. // : Container(
  132. // key: ValueKey('Button1'),
  133. // child: ElevatedButton(
  134. // onPressed: () => _JumpItemfocusNode.requestFocus(),
  135. // child: Text('Jump Item:'),
  136. // ),
  137. // ),
  138. // ),
  139. SizedBox(width: 8),
  140. Container(
  141. width: 150,
  142. height: 30,
  143. child: TextField(
  144. decoration: InputDecoration(
  145. labelText: 'viewSpecs',
  146. border: OutlineInputBorder(),
  147. suffixIcon: Icon(Icons.style_rounded)),
  148. ),
  149. ),
  150. ElevatedButton(
  151. onPressed: AugmentClasses.handleImages,
  152. child: Text('Filter'),
  153. ),
  154. SizedBox(width: 8),
  155. ElevatedButton(
  156. onPressed: AugmentClasses.handleOpen,
  157. child: Text('Lookup'),
  158. ),
  159. // SizedBox(width: 8),
  160. ElevatedButton(
  161. onPressed: AugmentClasses.handleFind,
  162. child: Text('Create Link'),
  163. ),
  164. ElevatedButton(
  165. onPressed: AugmentClasses.handleFind,
  166. child: Text('Paste Link'),
  167. ),
  168. ],
  169. )
  170. ])
  171. ]);
  172. }
  173. }
  174. class AugmentClasses {
  175. static void handleHome(BuildContext context) {
  176. Navigator.of(context).popUntil((route) => route.isFirst);
  177. }
  178. static void handleReload() {
  179. print("Reload button pressed");
  180. }
  181. static void handleImages() {
  182. print("Images button pressed");
  183. }
  184. static void handleOpen() {
  185. print("Open button pressed");
  186. }
  187. static void handleFind() {
  188. print("Find button pressed");
  189. }
  190. static void handleStop() {
  191. print("Stop button pressed");
  192. }
  193. }