93 lines
2.9 KiB
Dart
93 lines
2.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
class TaxiListWidget extends StatelessWidget {
|
|
final List<Map<String,dynamic>> taxiList;
|
|
final Function(bool, Map<String,dynamic>, String) onOpen;
|
|
final Function(Map<String,dynamic>) onDeleteTaxi;
|
|
|
|
const TaxiListWidget({super.key, required this.taxiList, required this.onOpen, required this.onDeleteTaxi});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Padding(
|
|
padding: const EdgeInsets.all(16.0),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
"Taxi Booking List",
|
|
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
|
),
|
|
const SizedBox(height: 16),
|
|
Center(
|
|
child: SingleChildScrollView(
|
|
scrollDirection: Axis.horizontal,
|
|
child: SizedBox(
|
|
width: MediaQuery.of(context).size.width ,
|
|
child: DataTable(
|
|
border: TableBorder(
|
|
bottom: BorderSide(color: Colors.black12),
|
|
horizontalInside: BorderSide(color: Colors.black12), // Only horizontal lines
|
|
),
|
|
columns: const [
|
|
// DataColumn(label: Text('#')),
|
|
DataColumn(label: Text('Destination')),
|
|
DataColumn(label: Text('Location Of Pickup')),
|
|
DataColumn(label: Text('Date')),
|
|
DataColumn(label: Text('Taxi Required For')),
|
|
DataColumn(label: Text('Actions')),
|
|
],
|
|
rows: _buildDataRows(),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
List<DataRow> _buildDataRows() {
|
|
|
|
List<Map<String, dynamic>> filteredList = taxiList
|
|
.where((item) => item["is_active"] == "1")
|
|
.toList();
|
|
print("filteredList- $filteredList");
|
|
|
|
return filteredList.asMap().entries.map((entry) {
|
|
|
|
final Map<String, dynamic> item = entry.value;
|
|
|
|
return DataRow(cells: [
|
|
// DataCell(Text(item["indx"]?.toString() ?? "N/A")), // Index column
|
|
DataCell(Text(item["destination_city"]!)),
|
|
DataCell(Text(item["location_of_pickup"]!)),
|
|
DataCell(Text(item["date"]!)),
|
|
DataCell(Text(item["car_required_for"]!)),
|
|
DataCell(Row(
|
|
children: [
|
|
IconButton(
|
|
icon: Icon(Icons.remove_red_eye, color: Colors.blue),
|
|
onPressed: () {
|
|
// View action
|
|
},
|
|
),
|
|
IconButton(
|
|
icon: Icon(Icons.edit, color: Colors.green),
|
|
onPressed: () {
|
|
onOpen(true, item, "Taxi");
|
|
},
|
|
),
|
|
IconButton(
|
|
icon: Icon(Icons.delete, color: Colors.red),
|
|
onPressed: () {
|
|
onDeleteTaxi(item);
|
|
},
|
|
),
|
|
],
|
|
)),
|
|
]);
|
|
}).toList();
|
|
}
|
|
}
|