Files
car_rental_app/lib/widgets/reservation_card.dart
T
2026-05-25 05:10:43 -04:00

83 lines
2.7 KiB
Dart

import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import '../core/models/reservation.dart';
import 'status_badge.dart';
class ReservationCard extends StatelessWidget {
final Reservation reservation;
final VoidCallback? onTap;
const ReservationCard({super.key, required this.reservation, this.onTap});
@override
Widget build(BuildContext context) {
final fmt = DateFormat('MMM d, yyyy');
return Card(
child: InkWell(
onTap: onTap,
borderRadius: BorderRadius.circular(12),
child: Padding(
padding: const EdgeInsets.all(14),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Expanded(
child: Text(
reservation.vehicle?.displayName ?? 'Reservation',
style: const TextStyle(
fontWeight: FontWeight.w600,
fontSize: 15,
),
),
),
StatusBadge(status: reservation.status),
],
),
if (reservation.customer != null) ...[
const SizedBox(height: 4),
Text(
reservation.customer!.fullName,
style: const TextStyle(
fontSize: 13, color: Color(0xFF6B7280)),
),
],
const SizedBox(height: 10),
Row(
children: [
const Icon(Icons.calendar_today,
size: 14, color: Color(0xFF9CA3AF)),
const SizedBox(width: 4),
Text(
'${fmt.format(reservation.startDate)}${fmt.format(reservation.endDate)}',
style: const TextStyle(
fontSize: 13, color: Color(0xFF6B7280)),
),
],
),
const SizedBox(height: 6),
Row(
children: [
const Icon(Icons.attach_money,
size: 14, color: Color(0xFF9CA3AF)),
const SizedBox(width: 4),
Text(
'\$${(reservation.totalAmount / 100).toStringAsFixed(2)}',
style: const TextStyle(
fontWeight: FontWeight.w600,
color: Color(0xFF111928),
),
),
const SizedBox(width: 8),
StatusBadge(status: reservation.paymentStatus),
],
),
],
),
),
),
);
}
}