Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
gpt_markdown
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
saminsohag
2024-11-17 12:12:00 +0600
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
25313c01c350247860aac24fc2bf7f09719e1e5f
25313c01
1 parent
955d69af
example file improved
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
41 deletions
gpt_markdown/example/lib/main.dart
gpt_markdown/example/lib/main.dart
View file @
25313c0
...
...
@@ -6,7 +6,6 @@ import 'package:gpt_markdown/gpt_markdown.dart';
import
'package:flutter_math_fork/flutter_math.dart'
;
import
'package:watcher/watcher.dart'
;
//
void
main
(
)
{
runApp
(
const
MyApp
());
}
...
...
@@ -37,7 +36,7 @@ class _MyAppState extends State<MyApp> {
colorSchemeSeed:
Colors
.
blue
,
),
home:
MyHomePage
(
title:
'
Flutter Demo Home Page
'
,
title:
'
GptMarkdown
'
,
onPressed:
()
{
setState
(()
{
_themeMode
=
(
_themeMode
==
ThemeMode
.
dark
)
...
...
@@ -50,7 +49,6 @@ class _MyAppState extends State<MyApp> {
}
}
//
class
MyHomePage
extends
StatefulWidget
{
const
MyHomePage
({
super
.
key
,
required
this
.
title
,
required
this
.
onPressed
});
final
VoidCallback
?
onPressed
;
...
...
@@ -145,6 +143,7 @@ Markdown and LaTeX can be powerful tools for formatting text and mathematical ex
}
bool writingMod = true;
bool selectable = false;
@override
Widget build(BuildContext context) {
...
...
@@ -155,6 +154,19 @@ Markdown and LaTeX can be powerful tools for formatting text and mathematical ex
IconButton(
onPressed: () {
setState(() {
selectable = !selectable;
});
},
icon: Icon(
Icons.select_all_outlined,
color: selectable
? Theme.of(context).colorScheme.onSurfaceVariant
: Theme.of(context).colorScheme.onSurface.withOpacity(0.38),
),
),
IconButton(
onPressed: () {
setState(() {
_direction = TextDirection.values[(_direction.index + 1) % 2];
});
},
...
...
@@ -168,7 +180,8 @@ Markdown and LaTeX can be powerful tools for formatting text and mathematical ex
onPressed: () => setState(() {
writingMod = !writingMod;
}),
icon: const Icon(Icons.arrow_drop_down),
icon:
Icon(writingMod ? Icons.arrow_drop_down : Icons.arrow_drop_up),
),
],
),
...
...
@@ -193,50 +206,43 @@ Markdown and LaTeX can be powerful tools for formatting text and mathematical ex
AnimatedBuilder(
animation: _controller,
builder: (context, _) {
return Material(
// color: Theme.of(context).colorScheme.surfaceVariant,
shape: RoundedRectangleBorder(
side: BorderSide(
return Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
border: Border.all(
width: 1,
color: Theme.of(context).colorScheme.outline),
),
child:
LayoutBuilder(builder: (context, constraints) {
return Theme(
data: Theme.of(context),
// .copyWith(
// textTheme: const TextTheme(
// // For H1.
// headlineLarge: TextStyle(fontSize: 55),
// // For H2.
// headlineMedium: TextStyle(fontSize: 45),
// // For H3.
// headlineSmall: TextStyle(fontSize: 35),
// // For H4.
// titleLarge: TextStyle(fontSize: 25),
// // For H5.
// titleMedium: TextStyle(fontSize: 15),
// // For H6.
// titleSmall: TextStyle(fontSize: 10),
// ),
// ),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: TexMarkdown(
child: Theme(
data: Theme.of(context),
// .copyWith(
// textTheme: const TextTheme(
// // For H1.
// headlineLarge: TextStyle(fontSize: 55),
// // For H2.
// headlineMedium: TextStyle(fontSize: 45),
// // For H3.
// headlineSmall: TextStyle(fontSize: 35),
// // For H4.
// titleLarge: TextStyle(fontSize: 25),
// // For H5.
// titleMedium: TextStyle(fontSize: 15),
// // For H6.
// titleSmall: TextStyle(fontSize: 10),
// ),
// ),
child: Builder(
builder: (context) {
Widget child = TexMarkdown(
_controller.text,
textDirection: _direction,
onLinkTab: (url, title) {
debugPrint(url);
debugPrint(title);
},
// maxLines: 7,
// overflow: TextOverflow.ellipsis,
textAlign: TextAlign.justify,
// textScaler: const TextScaler.linear(1.3),
textScaler: const TextScaler.linear(1),
style: const TextStyle(
// Regular text font size here.
color: Colors.red,
fontSize: 15,
),
latexWorkaround: (tex) {
...
...
@@ -344,11 +350,15 @@ Markdown and LaTeX can be powerful tools for formatting text and mathematical ex
),
);
},
),
),
// child: const Text("Hello"),
);
}),
);
if (selectable) {
child = SelectionArea(child: child);
}
return child;
},
),
// child: const Text("Hello"),
),
);
},
),
...
...
Please
register
or
login
to post a comment