139 lines
4.7 KiB
Dart
139 lines
4.7 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:google_fonts/google_fonts.dart';
|
|
import '../models/order_model.dart';
|
|
import '../models/serviceboy_model.dart';
|
|
import 'assign_serviceboy_dialog.dart';
|
|
|
|
class OrderCard extends StatefulWidget {
|
|
final Order order;
|
|
|
|
OrderCard({required this.order});
|
|
|
|
@override
|
|
State<OrderCard> createState() => _OrderCardState();
|
|
}
|
|
|
|
class _OrderCardState extends State<OrderCard> {
|
|
ServiceBoy? assignedBoy;
|
|
|
|
List<ServiceBoy> serviceBoys = [
|
|
ServiceBoy(name: 'John Doe', phone: '9875643210'),
|
|
ServiceBoy(name: 'Amit Raj', phone: '9765432180'),
|
|
ServiceBoy(name: 'Manoj Sinha', phone: '9543219876'),
|
|
];
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Card(
|
|
color: Colors.white,
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
|
|
margin: EdgeInsets.all(12),
|
|
elevation: 4,
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(16),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text("Order Details", style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600)),
|
|
SizedBox(height: 12),
|
|
Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Image.asset(widget.order.imagePath, width: 100, height: 100, fit: BoxFit.contain),
|
|
SizedBox(width: 16),
|
|
Expanded(
|
|
child: Column(
|
|
children: [
|
|
_buildRow("Customer Name", widget.order.customerName),
|
|
_buildRow("Mobile Number", widget.order.mobileNumber),
|
|
_buildRow("Service Type", widget.order.serviceType),
|
|
_buildRow("Service", widget.order.service),
|
|
_buildRow("Price", widget.order.price),
|
|
_buildRow("Service Time", widget.order.time),
|
|
_buildRow("Service Date", widget.order.date),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
SizedBox(height: 12),
|
|
Center(
|
|
child: Text(
|
|
widget.order.carName,
|
|
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
|
),
|
|
),
|
|
Divider(height: 28),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(
|
|
widget.order.status,
|
|
style: TextStyle(
|
|
color: widget.order.status == "Confirmed" ? Colors.green : Colors.orange,
|
|
fontWeight: FontWeight.bold,
|
|
fontSize: 16,
|
|
),
|
|
),
|
|
assignedBoy == null
|
|
? ElevatedButton(
|
|
onPressed: () async {
|
|
final selected = await showDialog<ServiceBoy>(
|
|
context: context,
|
|
builder: (_) => AssignServiceBoyDialog(serviceBoys: serviceBoys),
|
|
);
|
|
|
|
if (selected != null) {
|
|
setState(() {
|
|
assignedBoy = selected;
|
|
});
|
|
}
|
|
},
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: Color(0xFF1B1464),
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(30)),
|
|
),
|
|
child: Text("Assign",style: GoogleFonts.inter(
|
|
fontSize: 12,color: Colors.white
|
|
,fontWeight: FontWeight.w500
|
|
),),
|
|
|
|
)
|
|
: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text("Assigned to: ${assignedBoy!.name}",
|
|
style: const TextStyle(fontWeight: FontWeight.bold)),
|
|
Text("Phone: ${assignedBoy!.phone}"),
|
|
],
|
|
),
|
|
],
|
|
)
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildRow(String label, String value) {
|
|
return Padding(
|
|
padding: const EdgeInsets.symmetric(vertical: 3),
|
|
child: Row(
|
|
children: [
|
|
Expanded(flex: 2, child: Text(label, style: GoogleFonts.inter(
|
|
fontSize: 10,color: Colors.black
|
|
,fontWeight: FontWeight.w500
|
|
))),
|
|
Expanded(flex: 3, child: Text(value, style: GoogleFonts.inter(
|
|
fontSize: 10,color: Colors.black
|
|
,fontWeight: FontWeight.w500
|
|
))),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
|