Merge remote-tracking branch 'codeberg/feature/derivable-formula-screen' into feature/derivable-formula-screen
# Conflicts: # lib/ai/formula_screen.dart
This commit is contained in:
commit
2f8da74bee
2 changed files with 20 additions and 6 deletions
4
TODO.md
4
TODO.md
|
|
@ -64,7 +64,7 @@
|
||||||
- This button will create a DerivedFormula, with the input variable as output, and the rest of the input variables as inputs.
|
- This button will create a DerivedFormula, with the input variable as output, and the rest of the input variables as inputs.
|
||||||
- The DerivedFormula will then be displayed in the FormulaScreen
|
- The DerivedFormula will then be displayed in the FormulaScreen
|
||||||
- [R] If the Formula displayed in FormulaScreen is a DerivedFormula, the edit button will be disabled
|
- [R] If the Formula displayed in FormulaScreen is a DerivedFormula, the edit button will be disabled
|
||||||
- [ ] When a formula is derived in FormulaScreen, the new FormulaScreen is not pushed in navigator, it replacles the current FormulaScreen
|
- [R] When a formula is derived in FormulaScreen, the new FormulaScreen is not pushed in navigator, it replacles the current FormulaScreen
|
||||||
- [ ] In FormulaScreen, a Formula cant be derived if DerivedFormula.isDerivable() returns false
|
- [R] In FormulaScreen, a Formula cant be derived if DerivedFormula.isDerivable() returns false
|
||||||
- [ ] The algorithm of formulaSolver should be https://en.wikipedia.org/wiki/Newton%27s_method
|
- [ ] The algorithm of formulaSolver should be https://en.wikipedia.org/wiki/Newton%27s_method
|
||||||
- [ ] Add a uuid column to the table or FormulaElements, so it is not necessary to load all the formulas to find a formula by uuid. This will improve performance when updating and deleting.
|
- [ ] Add a uuid column to the table or FormulaElements, so it is not necessary to load all the formulas to find a formula by uuid. This will improve performance when updating and deleting.
|
||||||
|
|
|
||||||
|
|
@ -457,17 +457,31 @@ class _FormulaScreenState extends State<FormulaScreen> {
|
||||||
}
|
}
|
||||||
|
|
||||||
void _solveForVariable(VariableSpec variable) {
|
void _solveForVariable(VariableSpec variable) {
|
||||||
// Check if the formula is already a DerivedFormula
|
|
||||||
|
var rootFormula = FormulaInterface.getRootFormula(formula);
|
||||||
|
|
||||||
|
// Check if the formula can be derived
|
||||||
|
if (!DerivedFormula.isDerivable(rootFormula)) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
const SnackBar(
|
||||||
|
content: Text('This formula cannot be derived because it contains non number variables'),
|
||||||
|
duration: Duration(seconds: 2),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Create a DerivedFormula with this input variable as output
|
// Create a DerivedFormula with this input variable as output
|
||||||
var rootFormula = FormulaInterface.getRootFormula(formula);
|
|
||||||
final derivedFormula = DerivedFormula(
|
final derivedFormula = DerivedFormula(
|
||||||
outputName: variable.name,
|
outputName: variable.name,
|
||||||
originalFormula: rootFormula
|
originalFormula: rootFormula
|
||||||
);
|
);
|
||||||
|
|
||||||
// Navigate to the new DerivedFormula screen
|
|
||||||
Navigator.push(
|
|
||||||
|
// Replace the current FormulaScreen with the new DerivedFormula screen
|
||||||
|
Navigator.pushReplacement(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => FormulaScreen(
|
builder: (context) => FormulaScreen(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue