added shareplus
This commit is contained in:
parent
9b6887f58a
commit
4fb89fa78b
6 changed files with 43 additions and 9 deletions
3
TODO.md
3
TODO.md
|
|
@ -32,5 +32,4 @@
|
|||
- [X] Add a Share button to the formula list. It will export the array string literal of the formula with the units from Corpus.withDependencies().
|
||||
- [X] Replace flutter-markdown with flutter-markdown-plus
|
||||
- [X] Heron's formula: investigate why a=3, b=40, c=5 yields NaN. Root cause: input values don't form a valid triangle (violate triangle inequality: 3+5=8 is not > 40). Added documentation note to the formula description.
|
||||
- [ ]
|
||||
- [ ] Investigate startup time when there is no previous database and corpus is loaded from assets.
|
||||
- [ ] Change Share package to share_plus, because share is deprecated.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,35 @@
|
|||
[
|
||||
{"name":"Snell's Law","input":[{"name":"n1","unit":"scalar"},{"name":"n2","unit":"scalar"},{"name":"theta1","unit":"degree"}],"output":{"name":"theta2","unit":"degree"},"d4rtCode":"var theta1Rad = theta1 * (pi / 180); var sinTheta2 = (n1 * sin(theta1Rad)) / n2; theta2 = asin(sinTheta2) * (180 / pi);","tags":["physics","optics","light"]}
|
||||
]
|
||||
{
|
||||
"name": "Snell's Law",
|
||||
"description": r'''
|
||||
Refraction of light when passing through different media
|
||||
|
||||
$$n_1 \sin(\theta_1) = n_2 \sin(\theta_2)$$
|
||||
|
||||
Where:
|
||||
- $n_1$: Refractive index of the first medium
|
||||
- $n_2$: Refractive index of the second medium
|
||||
- $\theta_1$: Angle of incidence (degrees)
|
||||
- $\theta_2$: Angle of refraction (degrees)
|
||||
|
||||

|
||||
|
||||
Snell's Law describes how light bends when traveling between media with different refractive indices.
|
||||
The product of refractive index and sine of angle remains constant across the interface.
|
||||
|
||||
''',
|
||||
"input": [
|
||||
{"name": "n1", "unit": "scalar"},
|
||||
{"name": "n2", "unit": "scalar"},
|
||||
{"name": "theta1", "unit": "degree"}
|
||||
],
|
||||
"output": {"name": "theta2", "unit": "degree"},
|
||||
"d4rtCode": r"""
|
||||
var theta1Rad = theta1 * (pi / 180);
|
||||
var sinTheta2 = (n1 * sin(theta1Rad)) / n2;
|
||||
theta2 = asin(sinTheta2) * (180 / pi);
|
||||
""",
|
||||
"tags": ["physics", "optics", "light"]
|
||||
}
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import 'package:flutter/services.dart'; // For Clipboard
|
|||
import 'package:d4rt_formulas/formula_models.dart';
|
||||
import '../corpus.dart';
|
||||
import 'formula_screen.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
import 'package:share_plus/share_plus.dart' as share_plus;
|
||||
|
||||
class FormulaList extends StatefulWidget {
|
||||
final Corpus corpus;
|
||||
|
|
@ -63,9 +63,11 @@ class _FormulaListState extends State<FormulaList> {
|
|||
final exportString = '[${literals.join(', ')}]';
|
||||
|
||||
// Share the string
|
||||
await Share.share(
|
||||
exportString,
|
||||
await share_plus.SharePlus.instance.share(
|
||||
share_plus.ShareParams(
|
||||
text: exportString,
|
||||
subject: 'Sharing formula: ${formula.name}',
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
_showErrorDialog('Error sharing formula: $e');
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ class D4rtEditingController extends TextEditingController {
|
|||
|
||||
FormulaResult? get d4rtValue => _lastValue;
|
||||
|
||||
@override
|
||||
set text(String newText) {
|
||||
super.text = newText;
|
||||
validate();
|
||||
|
|
|
|||
|
|
@ -505,7 +505,7 @@ packages:
|
|||
source: hosted
|
||||
version: "1.3.0"
|
||||
markdown:
|
||||
dependency: transitive
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: markdown
|
||||
sha256: "935e23e1ff3bc02d390bad4d4be001208ee92cc217cb5b5a6c19bc14aaa318c1"
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ dependencies:
|
|||
resource_portable:
|
||||
d4rt: ^0.2.0
|
||||
analyzer: ^8.4.1
|
||||
markdown:
|
||||
flutter_markdown_plus:
|
||||
flutter_markdown_plus_latex:
|
||||
flutter_code_editor:
|
||||
|
|
|
|||
Loading…
Reference in a new issue