import 'package:doctor_app_flutter/core/viewModel/patient-referral-viewmodel.dart';
import 'package:doctor_app_flutter/screens/base/base_view.dart';
import 'package:doctor_app_flutter/screens/patients/profile/referral/referral_patient_detail_in-paint.dart';
import 'package:doctor_app_flutter/util/date-utils.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/patients/patient-referral-item-widget.dart';
import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
import 'package:doctor_app_flutter/widgets/transitions/fade_page.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';

class MyReferralInPatientScreen extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return BaseView<PatientReferralViewModel>(
      onModelReady: (model) => model.getMyReferralPatientService(),
      builder: (_, model, w) => AppScaffold(
        baseViewModel: model,
        isShowAppBar: false,
        appBarTitle: TranslationBase.of(context).referPatient,
        body: model.myReferralPatients.isEmpty
            ? Center(
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: [
                    SizedBox(
                      height: 100,
                    ),
                    Image.asset('assets/images/no-data.png'),
                    Padding(
                      padding: const EdgeInsets.all(8.0),
                      child: AppText(
                        TranslationBase.of(context).referralEmptyMsg,
                        color: Theme.of(context).errorColor,
                      ),
                    )
                  ],
                ),
              )
            : SingleChildScrollView(
                child: Container(
                  margin: EdgeInsets.only(top: 70),
                  // color: Colors.white,
                  // height: MediaQuery.of(context).size.height,
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      // SizedBox(height: 50),
                      ...List.generate(
                        model.myReferralPatients.length,
                        (index) => InkWell(
                          onTap: () {
                            Navigator.push(
                              context,
                              FadePage(
                                page: ReferralPatientDetailScreen(model.myReferralPatients[index],model),
                              ),
                            );
                          },
                          child: PatientReferralItemWidget(
                            referralStatus: model.getReferralStatusNameByCode(model.myReferralPatients[index].referralStatus,context),
                            referralStatusCode: model.myReferralPatients[index].referralStatus,
                            patientName: model.myReferralPatients[index].patientName,
                            patientGender: model.myReferralPatients[index].gender,
                            referredDate: DateUtils.getDayMonthYearDateFormatted(model.myReferralPatients[index].referralDate),
                            referredTime: DateUtils.getTimeHHMMA(model.myReferralPatients[index].referralDate),
                            patientID: "${model.myReferralPatients[index].patientID}",
                            isSameBranch: false,
                            isReferral: true,
                            isReferralClinic: true,
                            referralClinic:"${model.myReferralPatients[index].referringClinicDescription}",
                            remark: model.myReferralPatients[index].referringDoctorRemarks,
                            nationality: model.myReferralPatients[index].nationalityName,
                            nationalityFlag: model.myReferralPatients[index].nationalityFlagURL,
                            doctorAvatar: model.myReferralPatients[index].doctorImageURL,
                            referralDoctorName: model.myReferralPatients[index].referringDoctorName,
                            clinicDescription: model.myReferralPatients[index].referringClinicDescription,
                            infoIcon: Icon(FontAwesomeIcons.arrowRight,
                                size: 25, color: Colors.black),
                          ),
                        ),
                      ),
                    ],
                  ),
                ),
              ),
      ),
    );
  }
}
