diff --git a/CLAUDE.md b/CLAUDE.md index 9d17b44..62e8f27 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -9,7 +9,7 @@ - `flutter pub get` --> `./flutterw pub get` - `flutter run -d linux` --> `./flutterw run -d linux` - See `./Makefile` for more examples. -- If you are an agent, you may be also containerized. Try `distrobox-host-exec $(pwd)/flutterw` +- If you are an agent, you may be also containerized. If podman or docker is not available, try `distrobox-host-exec ./flutterw` # MANDATORY WORKFLOW diff --git a/evaluation-2.png b/evaluation-2.png new file mode 100644 index 0000000..3fad4ba Binary files /dev/null and b/evaluation-2.png differ diff --git a/evaluation-with-expression.png b/evaluation-with-expression.png new file mode 100644 index 0000000..0b75e39 Binary files /dev/null and b/evaluation-with-expression.png differ diff --git a/evaluation.png b/evaluation.png new file mode 100644 index 0000000..992342d Binary files /dev/null and b/evaluation.png differ diff --git a/formula-list.png b/formula-list.png new file mode 100644 index 0000000..d056359 Binary files /dev/null and b/formula-list.png differ diff --git a/import-from-dart-literal.png b/import-from-dart-literal.png new file mode 100644 index 0000000..a7a674f Binary files /dev/null and b/import-from-dart-literal.png differ diff --git a/import-preview.png b/import-preview.png new file mode 100644 index 0000000..1bf9a10 Binary files /dev/null and b/import-preview.png differ diff --git a/lib/ai/formula_editor.dart b/lib/ai/formula_editor.dart index 50f980b..d12a5af 100644 --- a/lib/ai/formula_editor.dart +++ b/lib/ai/formula_editor.dart @@ -443,17 +443,17 @@ class _FormulaEditorState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - const Text('Base Unit', style: TextStyle(fontSize: 12)), DropdownButtonFormField( value: _getBaseUnit(variable.unit), decoration: const InputDecoration( border: OutlineInputBorder(), + labelText: "Base unit", contentPadding: EdgeInsets.symmetric(horizontal: 12, vertical: 0), ), items: [ const DropdownMenuItem( value: null, - child: Text('None', style: TextStyle(fontSize: 14)), + child: Text('None', style: TextStyle(fontSize: 14)), ), ..._getAllBaseUnits().map((baseUnit) { return DropdownMenuItem( @@ -476,11 +476,11 @@ class _FormulaEditorState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - const Text('Derived Unit', style: TextStyle(fontSize: 12)), DropdownButtonFormField( value: variable.unit, decoration: const InputDecoration( border: OutlineInputBorder(), + labelText: "Derived unit", contentPadding: EdgeInsets.symmetric(horizontal: 12, vertical: 0), ), items: [ @@ -546,11 +546,11 @@ class _FormulaEditorState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - const Text('Base Unit', style: TextStyle(fontSize: 12)), DropdownButtonFormField( value: _getBaseUnit(_outputVariable.unit), decoration: const InputDecoration( border: OutlineInputBorder(), + labelText: "Base unit", contentPadding: EdgeInsets.symmetric(horizontal: 12, vertical: 0), ), items: [ @@ -579,11 +579,11 @@ class _FormulaEditorState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - const Text('Derived Unit', style: TextStyle(fontSize: 12)), DropdownButtonFormField( value: _outputVariable.unit, decoration: const InputDecoration( border: OutlineInputBorder(), + labelText: "Derived unit", contentPadding: EdgeInsets.symmetric(horizontal: 12, vertical: 0), ), items: [ diff --git a/lib/main.dart b/lib/main.dart index e1da391..94778f8 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -16,26 +16,28 @@ void main() async { // Setup service locator and initialize the database setupLocator(); - runApp(const MyApp()); + var corpusFuture = loadCorpusFromDatabaseOrAssets(); + + runApp( MyApp(corpusFuture)); } final GlobalKey<_CorpusLoaderState> corpusLoaderKey = GlobalKey<_CorpusLoaderState>(); class MyApp extends StatelessWidget { - const MyApp({Key? key}) : super(key: key); - - get corpusFuture => corpusLoaderKey.currentState?._corpusFuture; + final Future corpusFuture; + MyApp(this.corpusFuture, {Key? key}) : super(key: key); @override Widget build(BuildContext context) { return MaterialApp( - home: CorpusLoader(), + home: CorpusLoader(corpusFuture), ); } } class CorpusLoader extends StatefulWidget { - CorpusLoader({Key? key}) : super(key: corpusLoaderKey); + final Future corpusFuture; + CorpusLoader(this.corpusFuture, {Key? key}) : super(key: corpusLoaderKey); @override State createState() => _CorpusLoaderState(); @@ -44,11 +46,10 @@ class CorpusLoader extends StatefulWidget { class _CorpusLoaderState extends State { late Future _corpusFuture; - @override void initState() { super.initState(); - _corpusFuture = loadCorpusFromDatabaseOrAssets(); + _corpusFuture = widget.corpusFuture; } void _handleImport() { diff --git a/list-with-search.png b/list-with-search.png new file mode 100644 index 0000000..5990459 Binary files /dev/null and b/list-with-search.png differ diff --git a/screenshots.org b/screenshots.org new file mode 100644 index 0000000..40527f5 --- /dev/null +++ b/screenshots.org @@ -0,0 +1,2 @@ +[[file:evaluation-2.png]][[file:evaluation-with-expression.png]][[file:list-with-search.png]] +[[file:sharing-formula.png]][[file:import-from-dart-literal.png]][[file:import-preview.png]] diff --git a/sharing-formula.png b/sharing-formula.png new file mode 100644 index 0000000..1b45c62 Binary files /dev/null and b/sharing-formula.png differ diff --git a/test/app_test.dart b/test/app_test.dart new file mode 100644 index 0000000..2f51bb7 --- /dev/null +++ b/test/app_test.dart @@ -0,0 +1,44 @@ +import 'dart:async'; + +import 'package:d4rt_formulas/defaults/default_corpus.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:d4rt_formulas/main.dart'; +import 'package:d4rt_formulas/corpus.dart'; +import 'package:d4rt_formulas/formula_models.dart'; +import 'package:d4rt_formulas/database/database_service.dart'; +import 'package:d4rt_formulas/service_locator.dart'; +import 'package:get_it/get_it.dart'; + +void main() { + + testWidgets('selects first formula and opens editor from AppBar', (WidgetTester tester) async { + // Build the app + var corpus = await createDefaultCorpus(); + var corpusCompleter = Completer(); + corpusCompleter.complete(corpus); + var app = MyApp(corpusCompleter.future); + await tester.pumpWidget(app); + await tester.pump(); + await tester.pumpAndSettle(const Duration(seconds: 10)); + + // Verify FormulaList is shown + expect(find.byType(ListView), findsOneWidget); + + // Find and tap the first formula in the list + final formulaTile = find.byType(ListTile).first; + expect(formulaTile, findsOneWidget); + await tester.tap(formulaTile); + await tester.pumpAndSettle(); + + + // Find and tap the edit icon in the AppBar + final editIcon = find.byIcon(Icons.edit); + expect(editIcon, findsOneWidget); + await tester.tap(editIcon); + await tester.pumpAndSettle(); + + // Verify FormulaEditor is shown + expect(find.text('Edit Formula'), findsOneWidget); + }); +}