import 'package:doctor_app_flutter/core/viewModel/PatientSearchViewModel.dart';
import 'package:doctor_app_flutter/widgets/patients/patient_card/PatientCard.dart';
import 'package:flutter/material.dart';

import '../../../routes.dart';
import 'NoData.dart';

class ListOfMyInpatient extends StatelessWidget {
  const ListOfMyInpatient({
    Key? key,
    required this.isAllClinic,
    required this.hasQuery,
    required this.patientSearchViewModel,
    required this.isVidaPlusProject,
  }) : super(key: key);

  final bool isAllClinic;
  final bool hasQuery;
  final bool isVidaPlusProject;
  final PatientSearchViewModel patientSearchViewModel;

  @override
  Widget build(BuildContext context) {
    return Expanded(
      child: Container(
        margin: EdgeInsets.symmetric(horizontal: 16.0),
        child: patientSearchViewModel.filteredMyInPatientItems.length == 0
            ? NoData()
            : NotificationListener(
                child: ListView.builder(
                    itemCount:
                        patientSearchViewModel.filteredMyInPatientItems.length,
                    scrollDirection: Axis.vertical,
                    // physics: ScrollPhysics(),
                    shrinkWrap: true,
                    itemBuilder: (context, index) {
                      return PatientCard(
                        patientInfo: patientSearchViewModel
                            .filteredMyInPatientItems[index],
                        patientType: "1",
                        arrivalType: "1",
                        isInpatient: true,
                        isMyPatient: true,
                        onTap: () {
                          FocusScopeNode currentFocus = FocusScope.of(context);
                          if (!currentFocus.hasPrimaryFocus) {
                            currentFocus.unfocus();
                          }

                          Navigator.of(context)
                              .pushNamed(PATIENTS_PROFILE, arguments: {
                            "patient": patientSearchViewModel
                                .filteredMyInPatientItems[index],
                            "patientType": "1",
                            "from": "0",
                            "to": "0",
                            "isSearch": false,
                            "isInpatient": true,
                            "arrivalType": "1",
                            "isMyPatient": true,
                            "isVidaPlusProject": isVidaPlusProject,
                          });
                        },
                      );
                    }),
                onNotification: (t) {
                  return false;
                },
              ),
      ),
    );
  }
}
