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,74 +439,74 @@ 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),
), ),
items: [ dropdownColor: Theme.of(context).colorScheme.surface,
const DropdownMenuItem<String?>( menuMaxHeight: 300,
value: null, items: [
child: Text('None', style: TextStyle(fontSize: 14)), const DropdownMenuItem<String?>(
), value: null,
..._getAllBaseUnits().map((baseUnit) { child: Text('None', style: TextStyle(fontSize: 11)),
return DropdownMenuItem<String?>(
value: baseUnit,
child: Text(baseUnit, style: const TextStyle(fontSize: 14)),
);
}).toList(),
],
onChanged: (baseUnit) {
setState(() {
variable.unit = baseUnit;
});
},
), ),
..._getAllBaseUnits().map((baseUnit) {
return DropdownMenuItem<String?>(
value: baseUnit,
child: Text(baseUnit, style: const TextStyle(fontSize: 11)),
);
}).toList(),
], ],
onChanged: (baseUnit) {
setState(() {
variable.unit = baseUnit;
});
},
), ),
), ),
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),
), ),
items: [ dropdownColor: Theme.of(context).colorScheme.surface,
const DropdownMenuItem<String?>( menuMaxHeight: 300,
value: null, items: [
child: Text('None', style: TextStyle(fontSize: 14)), const DropdownMenuItem<String?>(
), value: null,
..._getDerivedUnits(variable.unit).map((unit) { child: Text('None', style: TextStyle(fontSize: 10)),
final unitSpec = widget.corpus.getUnit(unit);
return DropdownMenuItem<String?>(
value: unit,
child: Text(
'${unitSpec.symbol} - ${unit}',
style: const TextStyle(fontSize: 14),
overflow: TextOverflow.ellipsis,
),
);
}).toList(),
],
onChanged: (unit) {
setState(() {
variable.unit = unit;
});
},
), ),
..._getDerivedUnits(variable.unit).map((unit) {
final unitSpec = widget.corpus.getUnit(unit);
return DropdownMenuItem<String?>(
value: unit,
child: Text(
'${unitSpec.symbol}',
style: const TextStyle(fontSize: 10),
overflow: TextOverflow.ellipsis,
),
);
}).toList(),
], ],
onChanged: (unit) {
setState(() {
variable.unit = unit;
});
},
), ),
), ),
const SizedBox(width: 8), const SizedBox(width: 8),
@ -514,6 +514,8 @@ class _FormulaEditorState extends State<FormulaEditor> {
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,74 +544,74 @@ 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),
), ),
items: [ dropdownColor: Theme.of(context).colorScheme.surface,
const DropdownMenuItem<String?>( menuMaxHeight: 300,
value: null, items: [
child: Text('None', style: TextStyle(fontSize: 14)), const DropdownMenuItem<String?>(
), value: null,
..._getAllBaseUnits().map((baseUnit) { child: Text('None', style: TextStyle(fontSize: 11)),
return DropdownMenuItem<String?>(
value: baseUnit,
child: Text(baseUnit, style: const TextStyle(fontSize: 14)),
);
}).toList(),
],
onChanged: (baseUnit) {
setState(() {
_outputVariable.unit = baseUnit;
});
},
), ),
..._getAllBaseUnits().map((baseUnit) {
return DropdownMenuItem<String?>(
value: baseUnit,
child: Text(baseUnit, style: const TextStyle(fontSize: 11)),
);
}).toList(),
], ],
onChanged: (baseUnit) {
setState(() {
_outputVariable.unit = baseUnit;
});
},
), ),
), ),
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),
), ),
items: [ dropdownColor: Theme.of(context).colorScheme.surface,
const DropdownMenuItem<String?>( menuMaxHeight: 300,
value: null, items: [
child: Text('None', style: TextStyle(fontSize: 14)), const DropdownMenuItem<String?>(
), value: null,
..._getDerivedUnits(_outputVariable.unit).map((unit) { child: Text('None', style: TextStyle(fontSize: 10)),
final unitSpec = widget.corpus.getUnit(unit);
return DropdownMenuItem<String?>(
value: unit,
child: Text(
'${unitSpec.symbol} - ${unit}',
style: const TextStyle(fontSize: 14),
overflow: TextOverflow.ellipsis,
),
);
}).toList(),
],
onChanged: (unit) {
setState(() {
_outputVariable.unit = unit;
});
},
), ),
..._getDerivedUnits(_outputVariable.unit).map((unit) {
final unitSpec = widget.corpus.getUnit(unit);
return DropdownMenuItem<String?>(
value: unit,
child: Text(
'${unitSpec.symbol}',
style: const TextStyle(fontSize: 10),
overflow: TextOverflow.ellipsis,
),
);
}).toList(),
], ],
onChanged: (unit) {
setState(() {
_outputVariable.unit = unit;
});
},
), ),
), ),
], ],
@ -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(
child: CodeTheme( crossAxisAlignment: CrossAxisAlignment.start,
data: CodeThemeData(styles: monokaiSublimeTheme), children: [
child: Padding( const Text('D4RT Code (Dart syntax)', style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold)),
padding: const EdgeInsets.all(8.0), const SizedBox(height: 8),
child: SingleChildScrollView( ConstrainedBox(
child: CodeField(controller: _d4rtCodeController), constraints: const BoxConstraints(minHeight: 200),
child: CodeTheme(
data: CodeThemeData(styles: monokaiSublimeTheme),
child: SingleChildScrollView(
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) =>
corpus: corpus, ImportFromTextScreen(
), corpus: corpus,
),
), ),
).then((result) { ).then((result) {
if (result) { setState(() {
setState(() { // Refresh the list when returning from import
// Refresh the list when returning from import });
});
}
}); });
}); });
} }