feat: add markdown support for formula descriptions
This commit is contained in:
parent
1a7fd0c884
commit
1da336e71a
4 changed files with 57 additions and 1 deletions
|
|
@ -1,6 +1,7 @@
|
|||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_markdown/flutter_markdown.dart';
|
||||
import '../formula_models.dart';
|
||||
import '../formula_evaluator.dart';
|
||||
import '../corpus.dart';
|
||||
|
|
@ -106,6 +107,7 @@ class _FormulaScreenState extends State<FormulaScreen> {
|
|||
padding: const EdgeInsets.all(16.0),
|
||||
child: ListView(
|
||||
children: [
|
||||
_buildDescriptionSection(),
|
||||
_buildInputSection(),
|
||||
const SizedBox(height: 24),
|
||||
_buildOutputSection(),
|
||||
|
|
@ -116,6 +118,38 @@ class _FormulaScreenState extends State<FormulaScreen> {
|
|||
);
|
||||
}
|
||||
|
||||
Widget _buildDescriptionSection() {
|
||||
if (widget.formula.description == null ||
|
||||
widget.formula.description!.isEmpty) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Description',
|
||||
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.surfaceVariant,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: MarkdownBody(
|
||||
data: widget.formula.description!,
|
||||
shrinkWrap: true,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildInputSection() {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
|
|
|
|||
|
|
@ -54,6 +54,11 @@ class _UnitListState extends State<UnitList> {
|
|||
VariableSpec(name: 'mass', unit: 'kilogram'),
|
||||
VariableSpec(name: 'velocity', unit: 'meters_per_second'),
|
||||
],
|
||||
description : """
|
||||
# titulo
|
||||
hola
|
||||
## otro titulo
|
||||
""",
|
||||
output: VariableSpec(name: 'energy', unit: 'joule'),
|
||||
d4rtCode: "energy = 0.5 * mass * velocity * velocity;",
|
||||
);
|
||||
|
|
|
|||
18
pubspec.lock
18
pubspec.lock
|
|
@ -150,6 +150,14 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "5.0.0"
|
||||
flutter_markdown:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: flutter_markdown
|
||||
sha256: "04c4722cc36ec5af38acc38ece70d22d3c2123c61305d555750a091517bbe504"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.6.23"
|
||||
flutter_test:
|
||||
dependency: "direct dev"
|
||||
description: flutter
|
||||
|
|
@ -251,6 +259,14 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.3.0"
|
||||
markdown:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: markdown
|
||||
sha256: "935e23e1ff3bc02d390bad4d4be001208ee92cc217cb5b5a6c19bc14aaa318c1"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "7.3.0"
|
||||
matcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
@ -522,4 +538,4 @@ packages:
|
|||
version: "3.1.3"
|
||||
sdks:
|
||||
dart: ">=3.8.1 <4.0.0"
|
||||
flutter: ">=3.18.0-18.0.pre.54"
|
||||
flutter: ">=3.19.0"
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ dependencies:
|
|||
resource_portable:
|
||||
d4rt:
|
||||
flutter_d4rt:
|
||||
flutter_markdown: ^0.6.0
|
||||
|
||||
collection: any
|
||||
dev_dependencies:
|
||||
|
|
|
|||
Loading…
Reference in a new issue