Skip to content

Commit 1cd67be

Browse files
committed
Use better library for latex views
1 parent d8a7e23 commit 1cd67be

File tree

8 files changed

+97
-30
lines changed

8 files changed

+97
-30
lines changed

lib/screens/competition_planner_page/widgets/integrals_row.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class _IntegralsRowState extends State<IntegralsRow> {
8585

8686
return BasicWrapListItem(
8787
item: integral != null
88-
? LatexView(latex: integral.latexProblem, small: true)
88+
? LatexView(latex: integral.latexProblem)
8989
: Text(item),
9090
showRemove: true,
9191
onRemove: widget.enabled

lib/screens/integrals_page/integral_add_dialog.dart

+16-2
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,14 @@ class _IntegralAddDialogState extends State<IntegralAddDialog> {
112112
width: 400,
113113
child: Column(
114114
children: [
115-
Card(child: LatexView(latex: latexProblem)),
115+
Card(
116+
child: Container(
117+
width: 400,
118+
height: 150,
119+
alignment: Alignment.center,
120+
child: LatexView(latex: latexProblem),
121+
),
122+
),
116123
TextField(
117124
decoration: InputDecoration(
118125
border: InputBorder.none,
@@ -133,7 +140,14 @@ class _IntegralAddDialogState extends State<IntegralAddDialog> {
133140
width: 400,
134141
child: Column(
135142
children: [
136-
Card(child: LatexView(latex: latexSolution)),
143+
Card(
144+
child: Container(
145+
width: 400,
146+
height: 150,
147+
alignment: Alignment.center,
148+
child: LatexView(latex: latexSolution),
149+
),
150+
),
137151
TextField(
138152
decoration: InputDecoration(
139153
border: InputBorder.none,

lib/screens/integrals_page/integral_row.dart

+10-2
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,11 @@ class IntegralRow extends StatelessWidget {
8686
Expanded(
8787
flex: 3,
8888
child: Card(
89-
child: LatexView(latex: integral.latexProblem),
89+
child: Container(
90+
height: 150,
91+
alignment: Alignment.center,
92+
child: LatexView(latex: integral.latexProblem),
93+
),
9094
),
9195
),
9296

@@ -96,7 +100,11 @@ class IntegralRow extends StatelessWidget {
96100
Expanded(
97101
flex: 2,
98102
child: Card(
99-
child: LatexView(latex: integral.latexSolution),
103+
child: Container(
104+
height: 150,
105+
alignment: Alignment.center,
106+
child: LatexView(latex: integral.latexSolution),
107+
),
100108
),
101109
),
102110
],

lib/screens/mission_control_page/spare_integral_dialog.dart

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:flutter/material.dart';
2+
import 'package:flutter/widgets.dart';
23
import 'package:integration_bee_helper/models/integral_model/integral_model.dart';
34
import 'package:integration_bee_helper/services/basic_services/intl_service.dart';
45
import 'package:integration_bee_helper/widgets/latex_view.dart';
@@ -59,8 +60,10 @@ class _SpareIntegralDialogState extends State<SpareIntegralDialog> {
5960
},
6061
icon: const Icon(Icons.arrow_back_ios),
6162
),
62-
SizedBox(
63+
Container(
6364
width: 500,
65+
height: 150,
66+
alignment: Alignment.center,
6467
child: LatexView(
6568
latex: widget
6669
.potentialSpareIntegrals[selectedIndex].latexProblem,

lib/screens/presentation_screen/widgets/integral_view.dart

+7-10
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import 'package:flutter/material.dart';
2-
import 'package:flutter_tex/flutter_tex.dart';
32
import 'package:integration_bee_helper/models/agenda_item_model/problem_phase.dart';
3+
import 'package:integration_bee_helper/models/basic_models/latex_expression.dart';
44
import 'package:integration_bee_helper/models/integral_model/integral_model.dart';
55
import 'package:integration_bee_helper/services/basic_services/intl_service.dart';
6+
import 'package:integration_bee_helper/widgets/latex_view.dart';
67

78
class IntegralView extends StatelessWidget {
89
final IntegralModel? currentIntegral;
@@ -23,11 +24,11 @@ class IntegralView extends StatelessWidget {
2324
case ProblemPhase.idle:
2425
return '';
2526
case ProblemPhase.showProblem:
26-
return currentIntegral?.latexProblem.transformedWithDollarSigns ?? '';
27+
return currentIntegral?.latexProblem.transformed ?? '';
2728
case ProblemPhase.showSolution:
2829
case ProblemPhase.showSolutionAndWinner:
2930
return currentIntegral
30-
?.latexProblemAndSolution.transformedWithDollarSigns ??
31+
?.latexProblemAndSolution.transformed ??
3132
'';
3233
default:
3334
return '';
@@ -63,13 +64,9 @@ class IntegralView extends StatelessWidget {
6364
width: size.width,
6465
height: size.height,
6566
alignment: Alignment.center,
66-
child: TeXView(
67-
child: TeXViewDocument(
68-
latex,
69-
style: TeXViewStyle.fromCSS(
70-
'padding: 5px; font-size: ${(_integralSize * p).toInt()}px',
71-
),
72-
),
67+
child: LatexView(
68+
latex: LatexExpression(latex),
69+
fontSize: _integralSize * p,
7370
),
7471
);
7572
}

lib/widgets/latex_view.dart

+10-14
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,22 @@
11
import 'package:flutter/material.dart';
2-
import 'package:flutter_tex/flutter_tex.dart';
2+
import 'package:flutter_math_fork/flutter_math.dart';
33
import 'package:integration_bee_helper/models/basic_models/latex_expression.dart';
44

55
class LatexView extends StatelessWidget {
66
final LatexExpression latex;
7-
final bool small;
7+
final double fontSize;
88

9-
const LatexView({super.key, required this.latex, this.small = false});
9+
const LatexView({
10+
super.key,
11+
required this.latex,
12+
this.fontSize = 16,
13+
});
1014

1115
@override
1216
Widget build(BuildContext context) {
13-
return SizedBox(
14-
height: small ? 50 : 150,
15-
width: small ? 150 : null,
16-
child: TeXView(
17-
child: TeXViewDocument(
18-
latex.transformedWithDollarSigns,
19-
style: small
20-
? const TeXViewStyle.fromCSS('padding: 5px; font-size: 8px;')
21-
: const TeXViewStyle.fromCSS('padding: 5px;'),
22-
),
23-
),
17+
return Math.tex(
18+
latex.transformed,
19+
textStyle: TextStyle(fontSize: fontSize),
2420
);
2521
}
2622
}

pubspec.lock

+48
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,14 @@ packages:
299299
description: flutter
300300
source: sdk
301301
version: "0.0.0"
302+
flutter_math_fork:
303+
dependency: "direct main"
304+
description:
305+
name: flutter_math_fork
306+
sha256: "94bee4642892a94939af0748c6a7de0ff8318feee588379dcdfea7dc5cba06c8"
307+
url: "https://pub.dev"
308+
source: hosted
309+
version: "0.7.2"
302310
flutter_plugin_android_lifecycle:
303311
dependency: transitive
304312
description:
@@ -307,6 +315,14 @@ packages:
307315
url: "https://pub.dev"
308316
source: hosted
309317
version: "2.0.19"
318+
flutter_svg:
319+
dependency: transitive
320+
description:
321+
name: flutter_svg
322+
sha256: "7b4ca6cf3304575fe9c8ec64813c8d02ee41d2afe60bcfe0678bcb5375d596a2"
323+
url: "https://pub.dev"
324+
source: hosted
325+
version: "2.0.10+1"
310326
flutter_test:
311327
dependency: "direct dev"
312328
description: flutter
@@ -541,6 +557,14 @@ packages:
541557
url: "https://pub.dev"
542558
source: hosted
543559
version: "1.9.0"
560+
path_parsing:
561+
dependency: transitive
562+
description:
563+
name: path_parsing
564+
sha256: e3e67b1629e6f7e8100b367d3db6ba6af4b1f0bb80f64db18ef1fbabd2fa9ccf
565+
url: "https://pub.dev"
566+
source: hosted
567+
version: "1.0.1"
544568
path_provider:
545569
dependency: transitive
546570
description:
@@ -810,6 +834,30 @@ packages:
810834
url: "https://pub.dev"
811835
source: hosted
812836
version: "4.2.2"
837+
vector_graphics:
838+
dependency: transitive
839+
description:
840+
name: vector_graphics
841+
sha256: "32c3c684e02f9bc0afb0ae0aa653337a2fe022e8ab064bcd7ffda27a74e288e3"
842+
url: "https://pub.dev"
843+
source: hosted
844+
version: "1.1.11+1"
845+
vector_graphics_codec:
846+
dependency: transitive
847+
description:
848+
name: vector_graphics_codec
849+
sha256: c86987475f162fadff579e7320c7ddda04cd2fdeffbe1129227a85d9ac9e03da
850+
url: "https://pub.dev"
851+
source: hosted
852+
version: "1.1.11+1"
853+
vector_graphics_compiler:
854+
dependency: transitive
855+
description:
856+
name: vector_graphics_compiler
857+
sha256: "12faff3f73b1741a36ca7e31b292ddeb629af819ca9efe9953b70bd63fc8cd81"
858+
url: "https://pub.dev"
859+
source: hosted
860+
version: "1.1.11+1"
813861
vector_math:
814862
dependency: transitive
815863
description:

pubspec.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ dependencies:
5353
image: ^4.2.0
5454
image_picker: ^1.1.2
5555
url_launcher: ^6.3.0
56+
flutter_math_fork: ^0.7.2
5657

5758
dev_dependencies:
5859
flutter_test:

0 commit comments

Comments
 (0)