saminsohag

Table heading color added

... ... @@ -122,84 +122,94 @@ Markdown and LaTeX can be powerful tools for formatting text and mathematical ex
Column(
children: [
Expanded(
child: SingleChildScrollView(
child: Column(
children: [
AnimatedBuilder(
animation: _controller,
builder: (context, _) {
return Material(
// color: Theme.of(context).colorScheme.surfaceVariant,
shape: RoundedRectangleBorder(
side: BorderSide(
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: ListView(
children: [
AnimatedBuilder(
animation: _controller,
builder: (context, _) {
return Material(
// color: Theme.of(context).colorScheme.surfaceVariant,
shape: RoundedRectangleBorder(
side: BorderSide(
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: TexMarkdown(
_controller.text,
textDirection: _direction,
onLinkTab: (url, title) {
log(title, name: "title");
log(url, name: "url");
},
textAlign: TextAlign.justify,
// textScaler: const TextScaler.linear(1.3),
textScaler: MediaQuery.textScalerOf(context),
style: const TextStyle(
// Regular text font size here.
fontSize: 15,
),
latexWorkaround: (tex) =>
tex.replaceAllMapped(RegExp(r"align\*"),
(match) => "aligned"),
latexBuilder: (contex, tex) {
var controller = ScrollController();
return Column(
children: [
Scrollbar(
),
child: TexMarkdown(
_controller.text,
textDirection: _direction,
onLinkTab: (url, title) {
log(title, name: "title");
log(url, name: "url");
},
textAlign: TextAlign.justify,
// textScaler: const TextScaler.linear(1.3),
textScaler: MediaQuery.textScalerOf(context),
style: const TextStyle(
// Regular text font size here.
fontSize: 15,
),
latexWorkaround: (tex) =>
tex.replaceAllMapped(RegExp(r"align\*"),
(match) => "aligned"),
latexBuilder: (contex, tex) {
if (tex.contains(r"\begin{tabular}")) {
// return table.
String tableString = "|${(RegExp(
r"^\\begin\{tabular\}\{.*?\}(.*?)\\end\{tabular\}$",
multiLine: true,
dotAll: true,
).firstMatch(tex)?[1] ?? "").trim()}|";
tableString = tableString
.replaceAll(r"\\", "|\n|")
.replaceAll("&", "|");
return TexMarkdown(tableString);
}
var controller = ScrollController();
return Column(
children: [
Scrollbar(
controller: controller,
child: SingleChildScrollView(
controller: controller,
child: SingleChildScrollView(
controller: controller,
scrollDirection: Axis.horizontal,
child: Math.tex(
tex,
textStyle: const TextStyle(
fontSize: 17,
),
scrollDirection: Axis.horizontal,
child: Math.tex(
tex,
textStyle: const TextStyle(
fontSize: 17,
),
),
),
],
);
},
),
// child: const Text("Hello"),
);
}),
);
},
),
],
),
),
],
);
},
),
// child: const Text("Hello"),
);
}),
);
},
),
],
),
),
ConstrainedBox(
... ...
... ... @@ -58,6 +58,8 @@ class MdWidget extends StatelessWidget {
.asMap(),
)
.toList();
bool heading =
RegExp(r"^\|.*?\|\n\|-[-\\ |]*?-\|\n").hasMatch(eachLn.trim());
int maxCol = 0;
for (final each in value) {
if (maxCol < each.keys.length) {
... ... @@ -80,11 +82,23 @@ class MdWidget extends StatelessWidget {
color: Theme.of(context).colorScheme.onSurface,
),
children: value
.asMap()
.entries
.map<TableRow>(
(e) => TableRow(
(entry) => TableRow(
decoration: (heading)
? BoxDecoration(
color: (entry.key == 0)
? Theme.of(context)
.colorScheme
.surfaceVariant
: null,
)
: null,
children: List.generate(
maxCol,
(index) {
var e = entry.value;
String data = e[index] ?? "";
if (RegExp(r"^---+$").hasMatch(data.trim())) {
return const SizedBox();
... ...