savedPassengersCard method

Widget savedPassengersCard()

Implementation

Widget savedPassengersCard() {
  return Column(
    crossAxisAlignment: CrossAxisAlignment.start,
    children: [
      // Title
      Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Flexible(
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Text(
                  'Saved Passengers',
                  style: TextStyle(
                    fontSize: 18.dp,
                    fontWeight: FontWeight.w600,
                    color: ColorHelper.neutralText,
                  ),
                ),
                Text(
                  '3 Designated adult for the current subscription year.',
                  style: TextStyle(
                    fontSize: 14.dp,
                    fontWeight: FontWeight.w400,
                    color: ColorHelper.grey02,
                  ),
                ),
              ],
            ),
          ),
          10.dp.SpaceY,
          ElevatedButton.icon(
            onPressed: () {
              AddPassengerDialog(
                id: Get.parameters['id'] ?? '',
              ).show();
            },
            icon: const Icon(
              Icons.add,
              color: Colors.white,
            ),
            label: Container(
              margin: const EdgeInsets.symmetric(vertical: 8),
              child: const Text(
                'Add New',
                style: TextStyle(
                  color: Colors.white,
                  fontSize: 16,
                  fontWeight: FontWeight.w500,
                ),
              ),
            ),
            style: ElevatedButton.styleFrom(
              maximumSize: const Size(140, 55),
              backgroundColor: ColorHelper.gradient2,
              shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.circular(8), // Rounded corners
              ),
            ),
          )
        ],
      ),
      24.dp.SpaceX,
      // Details Card
      Obx(() {
        if (controller.listPassengers.isEmpty) {
          return _noDataWidget(
            "No passengers have been added yet. Please add passenger details to continue with the booking.",
          );
        }

        return Container(
          decoration: BoxDecoration(
              borderRadius: BorderRadius.circular(16),
              border: Border.all(color: ColorHelper.grey01, width: 1),
              color: Colors.white),
          child: SingleChildScrollView(
            scrollDirection: Axis.horizontal,
            child: SizedBox(
              width: Get.width < 664
                  ? Get.width / 0.4
                  : Get.width < 837
                      ? Get.width / 0.5
                      : Get.width < 1000
                          ? Get.width / 0.6
                          : Get.width < 1130
                              ? Get.width / 0.7
                              : Get.width < 1290
                                  ? Get.width - 350
                                  : Get.width < 1345
                                      ? Get.width - 350
                                      : Get.width - 425,
              child: Table(
                columnWidths: const {
                  0: FlexColumnWidth(0.2),
                  1: FlexColumnWidth(1),
                  2: FlexColumnWidth(0.5),
                  3: FlexColumnWidth(1),
                  4: FlexColumnWidth(1),
                  5: FlexColumnWidth(0.5),
                  6: FlexColumnWidth(0.5),
                  7: FlexColumnWidth(0.5),
                  8: FlexColumnWidth(0.5),
                  9: FlexColumnWidth(0.5),
                },
                children: [
                  TableRow(
                    decoration: const BoxDecoration(
                        color: ColorHelper.lightBg02,
                        borderRadius: BorderRadius.only(
                          topLeft: Radius.circular(16),
                          topRight: Radius.circular(16),
                        )),
                    children: [
                      tableLabel('#'),
                      tableLabel('Full Name'),
                      tableLabel('Gender'),
                      tableLabel('Passport Number'),
                      tableLabel('Passport Issuing Country'),
                      tableLabel('Passport Expiry Date'),
                      tableLabel('Nationality'),
                      tableLabel('Date of Birth'),
                      tableLabel('Type'),
                      tableLabel(''),
                    ],
                  ),
                  ...List.generate(controller.listPassengers.length, (index) {
                    Passengers passenger = controller.listPassengers[index];
                    return buildSavedPassengersTableRow(
                        '${index + 1}',
                        '${passenger.firstName} ${passenger.lastName}',
                        '${passenger.gender}',
                        '${passenger.passportNo}',
                        '${passenger.passportIssuingCountry}',
                        '${passenger.passportExpiry}',
                        '${passenger.nationality}',
                        '${passenger.dob}',
                        FlightUtils.passengerText(passenger.type),
                        0);
                  }),
                ],
              ),
            ),
          ),
        );
      }),
    ],
  );
}