solved layout issue

This commit is contained in:
Álvaro González 2026-04-02 21:01:22 +02:00
parent 07bd4e404d
commit 958050311e
3 changed files with 147 additions and 140 deletions

View file

@ -79,6 +79,7 @@
- It will show a screen with a text editor with dart syntax and a button "paste".
- The "paste" button will copy the clipboard into the text editor.
- A second button "import" will use the import preview screen
-[R] Launch test app_test.dart. Iterate until the test pass.
- [ ] 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.
- [ ] Make formulaSolver() asyncronous, and show a CircularProgressIndicator while the formula is being solved. Honor a new optinal parameter "timeout" in formulaSolver, that will throw a TimeoutException.
- [ ] When importing FormulaElements, save the FormulaElements in the database (currently, they are only added to the Corpus in memory).

View file

@ -439,26 +439,28 @@ class _FormulaEditorState extends State<FormulaEditor> {
),
),
const SizedBox(width: 8),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
DropdownButtonFormField<String?>(
Flexible(
flex: 1,
child: DropdownButtonFormField<String?>(
isDense: true,
isExpanded: true,
value: _getBaseUnit(variable.unit),
decoration: const InputDecoration(
border: OutlineInputBorder(),
labelText: "Base unit",
contentPadding: EdgeInsets.symmetric(horizontal: 12, vertical: 0),
contentPadding: EdgeInsets.symmetric(horizontal: 8, vertical: 0),
),
dropdownColor: Theme.of(context).colorScheme.surface,
menuMaxHeight: 300,
items: [
const DropdownMenuItem<String?>(
value: null,
child: Text('None', style: TextStyle(fontSize: 14)),
child: Text('None', style: TextStyle(fontSize: 11)),
),
..._getAllBaseUnits().map((baseUnit) {
return DropdownMenuItem<String?>(
value: baseUnit,
child: Text(baseUnit, style: const TextStyle(fontSize: 14)),
child: Text(baseUnit, style: const TextStyle(fontSize: 11)),
);
}).toList(),
],
@ -468,33 +470,33 @@ class _FormulaEditorState extends State<FormulaEditor> {
});
},
),
],
),
),
const SizedBox(width: 8),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
DropdownButtonFormField<String?>(
Flexible(
flex: 1,
child: DropdownButtonFormField<String?>(
isDense: true,
isExpanded: true,
value: variable.unit,
decoration: const InputDecoration(
border: OutlineInputBorder(),
labelText: "Derived unit",
contentPadding: EdgeInsets.symmetric(horizontal: 12, vertical: 0),
labelText: "Unit",
contentPadding: EdgeInsets.symmetric(horizontal: 8, vertical: 0),
),
dropdownColor: Theme.of(context).colorScheme.surface,
menuMaxHeight: 300,
items: [
const DropdownMenuItem<String?>(
value: null,
child: Text('None', style: TextStyle(fontSize: 14)),
child: Text('None', style: TextStyle(fontSize: 10)),
),
..._getDerivedUnits(variable.unit).map((unit) {
final unitSpec = widget.corpus.getUnit(unit);
return DropdownMenuItem<String?>(
value: unit,
child: Text(
'${unitSpec.symbol} - ${unit}',
style: const TextStyle(fontSize: 14),
'${unitSpec.symbol}',
style: const TextStyle(fontSize: 10),
overflow: TextOverflow.ellipsis,
),
);
@ -506,14 +508,14 @@ class _FormulaEditorState extends State<FormulaEditor> {
});
},
),
],
),
),
const SizedBox(width: 8),
IconButton(
icon: const Icon(Icons.delete, color: Colors.red),
onPressed: () => _removeInputVariable(index),
tooltip: 'Delete variable',
padding: EdgeInsets.zero,
constraints: const BoxConstraints(),
),
],
),
@ -542,26 +544,28 @@ class _FormulaEditorState extends State<FormulaEditor> {
),
),
const SizedBox(width: 8),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
DropdownButtonFormField<String?>(
Flexible(
flex: 1,
child: DropdownButtonFormField<String?>(
isDense: true,
isExpanded: true,
value: _getBaseUnit(_outputVariable.unit),
decoration: const InputDecoration(
border: OutlineInputBorder(),
labelText: "Base unit",
contentPadding: EdgeInsets.symmetric(horizontal: 12, vertical: 0),
contentPadding: EdgeInsets.symmetric(horizontal: 8, vertical: 0),
),
dropdownColor: Theme.of(context).colorScheme.surface,
menuMaxHeight: 300,
items: [
const DropdownMenuItem<String?>(
value: null,
child: Text('None', style: TextStyle(fontSize: 14)),
child: Text('None', style: TextStyle(fontSize: 11)),
),
..._getAllBaseUnits().map((baseUnit) {
return DropdownMenuItem<String?>(
value: baseUnit,
child: Text(baseUnit, style: const TextStyle(fontSize: 14)),
child: Text(baseUnit, style: const TextStyle(fontSize: 11)),
);
}).toList(),
],
@ -571,33 +575,33 @@ class _FormulaEditorState extends State<FormulaEditor> {
});
},
),
],
),
),
const SizedBox(width: 8),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
DropdownButtonFormField<String?>(
Flexible(
flex: 1,
child: DropdownButtonFormField<String?>(
isDense: true,
isExpanded: true,
value: _outputVariable.unit,
decoration: const InputDecoration(
border: OutlineInputBorder(),
labelText: "Derived unit",
contentPadding: EdgeInsets.symmetric(horizontal: 12, vertical: 0),
labelText: "Unit",
contentPadding: EdgeInsets.symmetric(horizontal: 8, vertical: 0),
),
dropdownColor: Theme.of(context).colorScheme.surface,
menuMaxHeight: 300,
items: [
const DropdownMenuItem<String?>(
value: null,
child: Text('None', style: TextStyle(fontSize: 14)),
child: Text('None', style: TextStyle(fontSize: 10)),
),
..._getDerivedUnits(_outputVariable.unit).map((unit) {
final unitSpec = widget.corpus.getUnit(unit);
return DropdownMenuItem<String?>(
value: unit,
child: Text(
'${unitSpec.symbol} - ${unit}',
style: const TextStyle(fontSize: 14),
'${unitSpec.symbol}',
style: const TextStyle(fontSize: 10),
overflow: TextOverflow.ellipsis,
),
);
@ -609,8 +613,6 @@ class _FormulaEditorState extends State<FormulaEditor> {
});
},
),
],
),
),
],
),
@ -622,18 +624,23 @@ class _FormulaEditorState extends State<FormulaEditor> {
Widget _buildD4rtCodeSection() {
return Card(
child: Expanded(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text('D4RT Code (Dart syntax)', style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold)),
const SizedBox(height: 8),
ConstrainedBox(
constraints: const BoxConstraints(minHeight: 200),
child: CodeTheme(
data: CodeThemeData(styles: monokaiSublimeTheme),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: SingleChildScrollView(
child: CodeField(controller: _d4rtCodeController),
),
),
),
],
),
),
);

View file

@ -57,16 +57,15 @@ class _CorpusLoaderState extends State<CorpusLoader> {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ImportFromTextScreen(
builder: (context) =>
ImportFromTextScreen(
corpus: corpus,
),
),
).then((result) {
if (result) {
setState(() {
// Refresh the list when returning from import
});
}
});
});
}