95 lines
3.1 KiB
Dart
95 lines
3.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
class FlightListWidget extends StatelessWidget {
|
|
final List<Map<String,dynamic>> flightList;
|
|
final Function( bool,Map<String,dynamic>, String) onOpen;
|
|
final Function(Map<String,dynamic>) onDeleteFlight;
|
|
|
|
const FlightListWidget({super.key, required this.flightList, required this.onOpen, required this.onDeleteFlight});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Padding(
|
|
padding: const EdgeInsets.all(16.0),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
"Flight Booking List",
|
|
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
|
),
|
|
const SizedBox(height: 16),
|
|
|
|
SingleChildScrollView(
|
|
scrollDirection: Axis.horizontal,
|
|
child: SizedBox(
|
|
// width: 1000,
|
|
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('Trip Type')),
|
|
DataColumn(label: Text('From')),
|
|
DataColumn(label: Text('To')),
|
|
DataColumn(label: Text('Actions')),
|
|
],
|
|
rows: _buildDataRows(),
|
|
),
|
|
),
|
|
),
|
|
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
List<DataRow> _buildDataRows() {
|
|
|
|
List<Map<String, dynamic>> filteredList = flightList
|
|
.where((item) => item["is_active"] == "1")
|
|
.toList();
|
|
print("filteredList- $filteredList");
|
|
|
|
|
|
return filteredList.asMap().entries.map((entry) {
|
|
Map<String,dynamic> item = entry.value;
|
|
print("Trip Type: ${item["trip_type"]}");
|
|
|
|
|
|
return DataRow(cells: [
|
|
// DataCell(Text(item["indx"]?.toString() ?? "N/A")),
|
|
DataCell(Text(item["trip_type"]?.toString() ?? "N/A")),
|
|
DataCell(Text(item["trips"].isNotEmpty ? item["trips"][0]["from_place"]?.toString() ?? "N/A" : "N/A")),
|
|
DataCell(Text(item["trips"].isNotEmpty ? item["trips"][0]["to_place"]?.toString() ?? "N/A" : "N/A")),
|
|
|
|
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, "Flight");
|
|
},
|
|
),
|
|
IconButton(
|
|
icon: Icon(Icons.delete, color: Colors.red),
|
|
onPressed: () {
|
|
onDeleteFlight(item);
|
|
},
|
|
),
|
|
],
|
|
)),
|
|
]);
|
|
}).toList();
|
|
}
|
|
}
|