first ai version of formula screen
This commit is contained in:
parent
30a61eaa70
commit
eb8b32c762
5 changed files with 47 additions and 4 deletions
3
aider.sh
3
aider.sh
|
|
@ -1,3 +1,2 @@
|
|||
aider --git --watch-files --read README.md --read CLAUDE.md
|
||||
notify-send "LLM session ended"
|
||||
aider --git --watch-files --read CLAUDE.md --notifications
|
||||
|
||||
|
|
|
|||
38
lib/ai/unit_dropdown.dart
Normal file
38
lib/ai/unit_dropdown.dart
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import '../../formula_models.dart';
|
||||
import '../../corpus.dart';
|
||||
|
||||
class UnitDropdown extends StatelessWidget {
|
||||
final UnitCorpus corpus;
|
||||
final VariableSpec variable;
|
||||
final String? selectedUnit;
|
||||
final ValueChanged<String?> onUnitChanged;
|
||||
|
||||
const UnitDropdown({
|
||||
super.key,
|
||||
required this.corpus,
|
||||
required this.variable,
|
||||
required this.selectedUnit,
|
||||
required this.onUnitChanged,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final availableUnits = corpus.allUnits().where((unit) => unit.baseUnit == variable.magnitude).toList();
|
||||
|
||||
return DropdownButton<String>(
|
||||
value: selectedUnit ?? variable.magnitude,
|
||||
icon: const Icon(Icons.arrow_drop_down),
|
||||
elevation: 16,
|
||||
style: TextStyle(color: Theme.of(context).colorScheme.primary, fontSize: 14),
|
||||
underline: Container(height: 1, color: Theme.of(context).dividerColor),
|
||||
onChanged: onUnitChanged,
|
||||
items: availableUnits.map<DropdownMenuItem<String>>((UnitSpec unit) {
|
||||
return DropdownMenuItem<String>(
|
||||
value: unit.name,
|
||||
child: Text(unit.symbol, style: const TextStyle(fontSize: 14)),
|
||||
);
|
||||
}).toList(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import '../corpus.dart';
|
||||
import '../formula_models.dart';
|
||||
import 'formula_screen.dart';
|
||||
|
||||
class UnitList extends StatefulWidget {
|
||||
final UnitCorpus corpus;
|
||||
|
|
@ -54,7 +55,7 @@ class _UnitListState extends State<UnitList> {
|
|||
VariableSpec(name: 'velocity', magnitude: 'meters_per_second'),
|
||||
],
|
||||
output: VariableSpec(name: 'energy', magnitude: 'joules'),
|
||||
d4rtCode: "main() {\n return 0.5 * mass * velocity * velocity;\n}",
|
||||
d4rtCode: "energy = 0.5 * mass * velocity * velocity;",
|
||||
);
|
||||
|
||||
Navigator.push(
|
||||
|
|
|
|||
|
|
@ -93,4 +93,6 @@ class UnitCorpus {
|
|||
|
||||
return xTo;
|
||||
}
|
||||
|
||||
Iterable<UnitSpec> allUnits() => _allUnits.values;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,9 +2,12 @@ import 'package:d4rt_formulas/ai/FormulaWidget.dart';
|
|||
import 'package:d4rt_formulas/formula_models.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:resource/resource.dart';
|
||||
import 'package:resource_portable/resource.dart' show Resource;
|
||||
import 'dart:convert';
|
||||
|
||||
import 'ai/unit_list.dart';
|
||||
import 'corpus.dart';
|
||||
|
||||
void main() {
|
||||
runApp(MaterialApp(
|
||||
home: FutureBuilder<UnitCorpus>(
|
||||
|
|
|
|||
Loading…
Reference in a new issue