feat: enhance UnitList with conversion factors and empty state
Co-authored-by: aider (openrouter/deepseek/deepseek-r1:free) <aider@aider.chat>
This commit is contained in:
parent
7a1060e773
commit
018579d4b9
1 changed files with 40 additions and 4 deletions
|
|
@ -60,17 +60,53 @@ class _UnitListState extends State<UnitList> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: ListView.builder(
|
child: _filteredUnits.isEmpty
|
||||||
|
? Center(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Icon(Icons.search_off, size: 40, color: Theme.of(context).colorScheme.outline),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
Text('No matching units found',
|
||||||
|
style: Theme.of(context).textTheme.titleSmall?.copyWith(
|
||||||
|
color: Theme.of(context).colorScheme.outline
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: ListView.builder(
|
||||||
itemCount: _filteredUnits.length,
|
itemCount: _filteredUnits.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final unit = _filteredUnits[index];
|
final unit = _filteredUnits[index];
|
||||||
return ListTile(
|
return ListTile(
|
||||||
title: Text(unit.name),
|
title: Text(unit.name),
|
||||||
subtitle: Text('Symbol: ${unit.symbol} • Base unit: ${unit.baseUnit}'),
|
subtitle: Column(
|
||||||
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text('Symbol: ${unit.symbol}'),
|
||||||
|
Text('Base: ${unit.baseUnit}',
|
||||||
|
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||||
|
color: Theme.of(context).colorScheme.onSurfaceVariant
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (unit.factorFromUnitToBase != null)
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(top: 4),
|
||||||
|
child: Text('1 ${unit.name} = ${unit.factorFromUnitToBase} ${unit.baseUnit}',
|
||||||
|
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||||
|
fontFeatures: [const FontFeature.tabularFigures()],
|
||||||
|
color: Theme.of(context).colorScheme.primary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||||
tileColor: index.isEven
|
tileColor: index.isEven
|
||||||
? Theme.of(context).colorScheme.surfaceVariant.withOpacity(0.3)
|
? Theme.of(context).colorScheme.surfaceVariant.withOpacity(0.2)
|
||||||
: null,
|
: null,
|
||||||
|
visualDensity: VisualDensity.compact,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue