add benzin to gasview
This commit is contained in:
@@ -23,14 +23,68 @@ class GasStationCard extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
// Hilfsmethode zur Erstellung eines einzelnen Preis-Badges
|
||||
Widget _buildPriceBadge(Prices? priceInfo) {
|
||||
if (priceInfo == null || priceInfo.amount == null) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
final double price = priceInfo.amount!;
|
||||
final String label = priceInfo.label ?? priceInfo.fuelType ?? '';
|
||||
final Color badgeColor = _getPriceColor(price);
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
||||
decoration: BoxDecoration(
|
||||
color: badgeColor.withAlpha(35),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: badgeColor, width: 1.5),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(Icons.local_gas_station, color: badgeColor, size: 22),
|
||||
const SizedBox(width: 6),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
'€ ${price.toStringAsFixed(3)}',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: badgeColor,
|
||||
),
|
||||
),
|
||||
if (label.isNotEmpty)
|
||||
Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 10,
|
||||
color: Colors.grey[700],
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final price = station.prices?.isNotEmpty == true
|
||||
? station.prices!.first.amount
|
||||
: null;
|
||||
final priceLabel = station.prices?.isNotEmpty == true
|
||||
? station.prices!.first.label
|
||||
: '';
|
||||
// Suchen nach Diesel und Super/Benzin im Prices-Array
|
||||
final dieselPrice = station.prices?.firstWhere(
|
||||
(p) => p.fuelType == 'DIE' || (p.label?.toLowerCase().contains('diesel') ?? false),
|
||||
orElse: () => station.prices?.isNotEmpty == true ? station.prices!.first : Prices(),
|
||||
);
|
||||
|
||||
final supPrice = station.prices?.firstWhere(
|
||||
(p) => p.fuelType == 'SUP' || (p.label?.toLowerCase().contains('benzin') ?? false) || (p.label?.toLowerCase().contains('super') ?? false),
|
||||
orElse: () => Prices(),
|
||||
);
|
||||
|
||||
return Card(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
@@ -50,7 +104,7 @@ class GasStationCard extends StatelessWidget {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Header Row with Position and Status
|
||||
// Header Row
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
@@ -113,7 +167,7 @@ class GasStationCard extends StatelessWidget {
|
||||
Text(
|
||||
station.name ?? 'Unbekannte Tankstelle',
|
||||
style: const TextStyle(
|
||||
fontSize: 20,
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.black87,
|
||||
),
|
||||
@@ -134,7 +188,7 @@ class GasStationCard extends StatelessWidget {
|
||||
'${station.location?.address ?? ''}, '
|
||||
'${station.location?.postalCode ?? ''} '
|
||||
'${station.location?.city ?? ''}',
|
||||
style: TextStyle(fontSize: 14, color: Colors.grey[700]),
|
||||
style: TextStyle(fontSize: 13, color: Colors.grey[700]),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
@@ -143,80 +197,47 @@ class GasStationCard extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
// Price and Distance Row
|
||||
// Prices & Distance Row
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
// Price
|
||||
if (price != null)
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 10,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: _getPriceColor(price).withAlpha(50),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(
|
||||
color: _getPriceColor(price),
|
||||
width: 2,
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.local_gas_station,
|
||||
color: _getPriceColor(price),
|
||||
size: 24,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'€ ${price.toStringAsFixed(3)}',
|
||||
style: TextStyle(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: _getPriceColor(price),
|
||||
),
|
||||
),
|
||||
if (priceLabel?.isNotEmpty == true)
|
||||
Text(
|
||||
priceLabel!,
|
||||
style: TextStyle(
|
||||
fontSize: 10,
|
||||
color: Colors.grey[600],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
// Diesel & Benzin Preise nebeneinander
|
||||
Expanded(
|
||||
child: Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
children: [
|
||||
if (dieselPrice?.amount != null)
|
||||
_buildPriceBadge(dieselPrice),
|
||||
if (supPrice?.amount != null)
|
||||
_buildPriceBadge(supPrice),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// Distance
|
||||
// Distance Badge
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 10,
|
||||
horizontal: 12,
|
||||
vertical: 8,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.blue[50],
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.navigation,
|
||||
color: Colors.blue[700],
|
||||
size: 20,
|
||||
size: 18,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
_formatDistance(station.distance),
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.blue[700],
|
||||
),
|
||||
@@ -232,4 +253,4 @@ class GasStationCard extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user