133 lines
4.5 KiB
Dart
133 lines
4.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:intl/intl.dart';
|
|
import '../../../../core/theme/app_theme.dart';
|
|
import '../../../../core/widgets/status_badge.dart';
|
|
import '../../data/models/stop_model.dart';
|
|
|
|
class StopCard extends StatelessWidget {
|
|
final StopModel stop;
|
|
final VoidCallback onTap;
|
|
final VoidCallback? onNavigate;
|
|
|
|
const StopCard({
|
|
super.key,
|
|
required this.stop,
|
|
required this.onTap,
|
|
this.onNavigate,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Card(
|
|
child: InkWell(
|
|
onTap: onTap,
|
|
borderRadius: BorderRadius.circular(12),
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(16),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Row(
|
|
children: [
|
|
Container(
|
|
width: 40,
|
|
height: 40,
|
|
decoration: BoxDecoration(
|
|
color: stop.type == StopType.pickup
|
|
? Colors.blue.withOpacity(0.1)
|
|
: Colors.green.withOpacity(0.1),
|
|
shape: BoxShape.circle,
|
|
),
|
|
child: Icon(
|
|
stop.type == StopType.pickup
|
|
? Icons.arrow_upward
|
|
: Icons.arrow_downward,
|
|
color: stop.type == StopType.pickup
|
|
? Colors.blue
|
|
: Colors.green,
|
|
),
|
|
),
|
|
const SizedBox(width: 12),
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
stop.customerName,
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
const SizedBox(height: 4),
|
|
Text(
|
|
stop.type == StopType.pickup ? 'Pickup' : 'Dropoff',
|
|
style: Theme.of(context).textTheme.bodySmall,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
StatusBadge(
|
|
status: stop.status.toString().split('.').last,
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(height: 12),
|
|
if (stop.location.address != null) ...[
|
|
Row(
|
|
children: [
|
|
const Icon(Icons.location_on, size: 16, color: Colors.grey),
|
|
const SizedBox(width: 8),
|
|
Expanded(
|
|
child: Text(
|
|
stop.location.address!,
|
|
style: Theme.of(context).textTheme.bodyMedium,
|
|
maxLines: 2,
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(height: 8),
|
|
],
|
|
Row(
|
|
children: [
|
|
const Icon(Icons.schedule, size: 16, color: Colors.grey),
|
|
const SizedBox(width: 8),
|
|
Text(
|
|
DateFormat('hh:mm a').format(stop.scheduledTime),
|
|
style: Theme.of(context).textTheme.bodyMedium,
|
|
),
|
|
],
|
|
),
|
|
if (stop.items.isNotEmpty) ...[
|
|
const SizedBox(height: 8),
|
|
Row(
|
|
children: [
|
|
const Icon(Icons.inventory_2, size: 16, color: Colors.grey),
|
|
const SizedBox(width: 8),
|
|
Text(
|
|
'${stop.items.length} items',
|
|
style: Theme.of(context).textTheme.bodyMedium,
|
|
),
|
|
],
|
|
),
|
|
],
|
|
if (onNavigate != null &&
|
|
stop.status != StopStatus.completed) ...[
|
|
const SizedBox(height: 12),
|
|
SizedBox(
|
|
width: double.infinity,
|
|
child: ElevatedButton.icon(
|
|
onPressed: onNavigate,
|
|
icon: const Icon(Icons.navigation, size: 20),
|
|
label: const Text('Navigate'),
|
|
),
|
|
),
|
|
],
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|