Showing
1 changed file
with
32 additions
and
22 deletions
| @@ -6,7 +6,6 @@ import 'package:gpt_markdown/gpt_markdown.dart'; | @@ -6,7 +6,6 @@ import 'package:gpt_markdown/gpt_markdown.dart'; | ||
| 6 | import 'package:flutter_math_fork/flutter_math.dart'; | 6 | import 'package:flutter_math_fork/flutter_math.dart'; |
| 7 | import 'package:watcher/watcher.dart'; | 7 | import 'package:watcher/watcher.dart'; |
| 8 | 8 | ||
| 9 | -// | ||
| 10 | void main() { | 9 | void main() { |
| 11 | runApp(const MyApp()); | 10 | runApp(const MyApp()); |
| 12 | } | 11 | } |
| @@ -37,7 +36,7 @@ class _MyAppState extends State<MyApp> { | @@ -37,7 +36,7 @@ class _MyAppState extends State<MyApp> { | ||
| 37 | colorSchemeSeed: Colors.blue, | 36 | colorSchemeSeed: Colors.blue, |
| 38 | ), | 37 | ), |
| 39 | home: MyHomePage( | 38 | home: MyHomePage( |
| 40 | - title: 'Flutter Demo Home Page', | 39 | + title: 'GptMarkdown', |
| 41 | onPressed: () { | 40 | onPressed: () { |
| 42 | setState(() { | 41 | setState(() { |
| 43 | _themeMode = (_themeMode == ThemeMode.dark) | 42 | _themeMode = (_themeMode == ThemeMode.dark) |
| @@ -50,7 +49,6 @@ class _MyAppState extends State<MyApp> { | @@ -50,7 +49,6 @@ class _MyAppState extends State<MyApp> { | ||
| 50 | } | 49 | } |
| 51 | } | 50 | } |
| 52 | 51 | ||
| 53 | -// | ||
| 54 | class MyHomePage extends StatefulWidget { | 52 | class MyHomePage extends StatefulWidget { |
| 55 | const MyHomePage({super.key, required this.title, required this.onPressed}); | 53 | const MyHomePage({super.key, required this.title, required this.onPressed}); |
| 56 | final VoidCallback? onPressed; | 54 | final VoidCallback? onPressed; |
| @@ -145,6 +143,7 @@ Markdown and LaTeX can be powerful tools for formatting text and mathematical ex | @@ -145,6 +143,7 @@ Markdown and LaTeX can be powerful tools for formatting text and mathematical ex | ||
| 145 | } | 143 | } |
| 146 | 144 | ||
| 147 | bool writingMod = true; | 145 | bool writingMod = true; |
| 146 | + bool selectable = false; | ||
| 148 | 147 | ||
| 149 | @override | 148 | @override |
| 150 | Widget build(BuildContext context) { | 149 | Widget build(BuildContext context) { |
| @@ -155,6 +154,19 @@ Markdown and LaTeX can be powerful tools for formatting text and mathematical ex | @@ -155,6 +154,19 @@ Markdown and LaTeX can be powerful tools for formatting text and mathematical ex | ||
| 155 | IconButton( | 154 | IconButton( |
| 156 | onPressed: () { | 155 | onPressed: () { |
| 157 | setState(() { | 156 | setState(() { |
| 157 | + selectable = !selectable; | ||
| 158 | + }); | ||
| 159 | + }, | ||
| 160 | + icon: Icon( | ||
| 161 | + Icons.select_all_outlined, | ||
| 162 | + color: selectable | ||
| 163 | + ? Theme.of(context).colorScheme.onSurfaceVariant | ||
| 164 | + : Theme.of(context).colorScheme.onSurface.withOpacity(0.38), | ||
| 165 | + ), | ||
| 166 | + ), | ||
| 167 | + IconButton( | ||
| 168 | + onPressed: () { | ||
| 169 | + setState(() { | ||
| 158 | _direction = TextDirection.values[(_direction.index + 1) % 2]; | 170 | _direction = TextDirection.values[(_direction.index + 1) % 2]; |
| 159 | }); | 171 | }); |
| 160 | }, | 172 | }, |
| @@ -168,7 +180,8 @@ Markdown and LaTeX can be powerful tools for formatting text and mathematical ex | @@ -168,7 +180,8 @@ Markdown and LaTeX can be powerful tools for formatting text and mathematical ex | ||
| 168 | onPressed: () => setState(() { | 180 | onPressed: () => setState(() { |
| 169 | writingMod = !writingMod; | 181 | writingMod = !writingMod; |
| 170 | }), | 182 | }), |
| 171 | - icon: const Icon(Icons.arrow_drop_down), | 183 | + icon: |
| 184 | + Icon(writingMod ? Icons.arrow_drop_down : Icons.arrow_drop_up), | ||
| 172 | ), | 185 | ), |
| 173 | ], | 186 | ], |
| 174 | ), | 187 | ), |
| @@ -193,16 +206,14 @@ Markdown and LaTeX can be powerful tools for formatting text and mathematical ex | @@ -193,16 +206,14 @@ Markdown and LaTeX can be powerful tools for formatting text and mathematical ex | ||
| 193 | AnimatedBuilder( | 206 | AnimatedBuilder( |
| 194 | animation: _controller, | 207 | animation: _controller, |
| 195 | builder: (context, _) { | 208 | builder: (context, _) { |
| 196 | - return Material( | ||
| 197 | - // color: Theme.of(context).colorScheme.surfaceVariant, | ||
| 198 | - shape: RoundedRectangleBorder( | ||
| 199 | - side: BorderSide( | 209 | + return Container( |
| 210 | + padding: const EdgeInsets.all(8), | ||
| 211 | + decoration: BoxDecoration( | ||
| 212 | + border: Border.all( | ||
| 200 | width: 1, | 213 | width: 1, |
| 201 | color: Theme.of(context).colorScheme.outline), | 214 | color: Theme.of(context).colorScheme.outline), |
| 202 | ), | 215 | ), |
| 203 | - child: | ||
| 204 | - LayoutBuilder(builder: (context, constraints) { | ||
| 205 | - return Theme( | 216 | + child: Theme( |
| 206 | data: Theme.of(context), | 217 | data: Theme.of(context), |
| 207 | // .copyWith( | 218 | // .copyWith( |
| 208 | // textTheme: const TextTheme( | 219 | // textTheme: const TextTheme( |
| @@ -220,23 +231,18 @@ Markdown and LaTeX can be powerful tools for formatting text and mathematical ex | @@ -220,23 +231,18 @@ Markdown and LaTeX can be powerful tools for formatting text and mathematical ex | ||
| 220 | // titleSmall: TextStyle(fontSize: 10), | 231 | // titleSmall: TextStyle(fontSize: 10), |
| 221 | // ), | 232 | // ), |
| 222 | // ), | 233 | // ), |
| 223 | - child: Padding( | ||
| 224 | - padding: const EdgeInsets.all(8.0), | ||
| 225 | - child: TexMarkdown( | 234 | + child: Builder( |
| 235 | + builder: (context) { | ||
| 236 | + Widget child = TexMarkdown( | ||
| 226 | _controller.text, | 237 | _controller.text, |
| 227 | textDirection: _direction, | 238 | textDirection: _direction, |
| 228 | onLinkTab: (url, title) { | 239 | onLinkTab: (url, title) { |
| 229 | debugPrint(url); | 240 | debugPrint(url); |
| 230 | debugPrint(title); | 241 | debugPrint(title); |
| 231 | }, | 242 | }, |
| 232 | - // maxLines: 7, | ||
| 233 | - // overflow: TextOverflow.ellipsis, | ||
| 234 | textAlign: TextAlign.justify, | 243 | textAlign: TextAlign.justify, |
| 235 | - // textScaler: const TextScaler.linear(1.3), | ||
| 236 | textScaler: const TextScaler.linear(1), | 244 | textScaler: const TextScaler.linear(1), |
| 237 | style: const TextStyle( | 245 | style: const TextStyle( |
| 238 | - // Regular text font size here. | ||
| 239 | - color: Colors.red, | ||
| 240 | fontSize: 15, | 246 | fontSize: 15, |
| 241 | ), | 247 | ), |
| 242 | latexWorkaround: (tex) { | 248 | latexWorkaround: (tex) { |
| @@ -344,11 +350,15 @@ Markdown and LaTeX can be powerful tools for formatting text and mathematical ex | @@ -344,11 +350,15 @@ Markdown and LaTeX can be powerful tools for formatting text and mathematical ex | ||
| 344 | ), | 350 | ), |
| 345 | ); | 351 | ); |
| 346 | }, | 352 | }, |
| 347 | - ), | 353 | + ); |
| 354 | + if (selectable) { | ||
| 355 | + child = SelectionArea(child: child); | ||
| 356 | + } | ||
| 357 | + return child; | ||
| 358 | + }, | ||
| 348 | ), | 359 | ), |
| 349 | // child: const Text("Hello"), | 360 | // child: const Text("Hello"), |
| 350 | - ); | ||
| 351 | - }), | 361 | + ), |
| 352 | ); | 362 | ); |
| 353 | }, | 363 | }, |
| 354 | ), | 364 | ), |
-
Please register or login to post a comment