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

View file

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