add filter panel to calculator
This commit is contained in:
@@ -82,39 +82,68 @@ class TractionCard extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Row(
|
||||
children: [
|
||||
TextButton.icon(
|
||||
onPressed: onShowInfo,
|
||||
icon: const Icon(Icons.info_outline),
|
||||
label: const Text('Details'),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
TextButton.icon(
|
||||
onPressed: onOpenTimeline,
|
||||
icon: const Icon(Icons.timeline),
|
||||
label: const Text('Timeline'),
|
||||
),
|
||||
if (hasMileageOrTrips && onOpenLegs != null) ...[
|
||||
const SizedBox(width: 8),
|
||||
LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final isNarrow = constraints.maxWidth < 520;
|
||||
final buttons = [
|
||||
TextButton.icon(
|
||||
onPressed: onOpenLegs,
|
||||
icon: const Icon(Icons.view_list),
|
||||
label: const Text('Legs'),
|
||||
onPressed: onShowInfo,
|
||||
icon: const Icon(Icons.info_outline),
|
||||
label: const Text('Details'),
|
||||
),
|
||||
],
|
||||
const Spacer(),
|
||||
if (selectionMode && onToggleSelect != null)
|
||||
TextButton.icon(
|
||||
onPressed: onToggleSelect,
|
||||
icon: Icon(
|
||||
isSelected
|
||||
? Icons.remove_circle_outline
|
||||
: Icons.add_circle_outline,
|
||||
onPressed: onOpenTimeline,
|
||||
icon: const Icon(Icons.timeline),
|
||||
label: const Text('Timeline'),
|
||||
),
|
||||
if (hasMileageOrTrips && onOpenLegs != null)
|
||||
TextButton.icon(
|
||||
onPressed: onOpenLegs,
|
||||
icon: const Icon(Icons.view_list),
|
||||
label: const Text('Legs'),
|
||||
),
|
||||
label: Text(isSelected ? 'Remove' : 'Add to entry'),
|
||||
),
|
||||
],
|
||||
];
|
||||
|
||||
final addButton = selectionMode && onToggleSelect != null
|
||||
? TextButton.icon(
|
||||
onPressed: onToggleSelect,
|
||||
icon: Icon(
|
||||
isSelected
|
||||
? Icons.remove_circle_outline
|
||||
: Icons.add_circle_outline,
|
||||
),
|
||||
label: Text(isSelected ? 'Remove' : 'Add to entry'),
|
||||
)
|
||||
: null;
|
||||
|
||||
if (isNarrow) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 4,
|
||||
children: buttons,
|
||||
),
|
||||
if (addButton != null) ...[
|
||||
const SizedBox(height: 6),
|
||||
addButton,
|
||||
],
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
return Row(
|
||||
children: [
|
||||
...buttons.expand((btn) sync* {
|
||||
yield btn;
|
||||
yield const SizedBox(width: 8);
|
||||
}).take(buttons.length * 2 - 1),
|
||||
const Spacer(),
|
||||
if (addButton != null) addButton,
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
Wrap(
|
||||
spacing: 8,
|
||||
|
||||
Reference in New Issue
Block a user