better derived formula management
This commit is contained in:
parent
e4f79ccab6
commit
72435341a9
2 changed files with 16 additions and 4 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.
|
||||
- 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
|
||||
- [ ] 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] When a formula is derived in FormulaScreen, the new FormulaScreen is not pushed in navigator, it replacles the current FormulaScreen
|
||||
- [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
|
||||
- [ ] 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.
|
||||
|
|
|
|||
|
|
@ -468,6 +468,18 @@ class _FormulaScreenState extends State<FormulaScreen> {
|
|||
return;
|
||||
}
|
||||
|
||||
// Check if the formula can be derived
|
||||
if (!DerivedFormula.isDerivable(formula)) {
|
||||
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 {
|
||||
// Create a DerivedFormula with this input variable as output
|
||||
final derivedFormula = DerivedFormula(
|
||||
|
|
@ -475,8 +487,8 @@ class _FormulaScreenState extends State<FormulaScreen> {
|
|||
originalFormula: formula,
|
||||
);
|
||||
|
||||
// Navigate to the new DerivedFormula screen
|
||||
Navigator.push(
|
||||
// Replace the current FormulaScreen with the new DerivedFormula screen
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => FormulaScreen(
|
||||
|
|
|
|||
Loading…
Reference in a new issue