import 'package:doctor_app_flutter/core/model/SOAP/chief_complaint/get_chief_complaint_vida_plus.dart';
import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart';
import 'package:doctor_app_flutter/core/viewModel/SOAP_view_model.dart';
import 'package:doctor_app_flutter/screens/base/base_view.dart';
import 'package:doctor_app_flutter/screens/patients/profile/soap_update/subjective/medication/update_medication_widget.dart';
import 'package:doctor_app_flutter/screens/patients/profile/soap_update_vida_plus/subjective/chief_complaint/AddChiefComplaints.dart';
import 'package:doctor_app_flutter/screens/patients/profile/soap_update_vida_plus/subjective/chief_complaint/widgets/add_soap_item.dart';
import 'package:doctor_app_flutter/screens/patients/profile/soap_update_vida_plus/subjective/chief_complaint/widgets/complaint_items.dart';
import 'package:doctor_app_flutter/screens/patients/profile/soap_update_vida_plus/subjective/chief_complaint/widgets/empty_complaints.dart';
import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart';
import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart';
import 'package:doctor_app_flutter/widgets/shared/text_fields/app-textfield-custom.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';

class UpdateChiefComplaints extends StatelessWidget {
  final List<String> complaints;
  final PatiantInformtion patientInfo;

  const UpdateChiefComplaints({Key? key, required this.complaints, required this.patientInfo})
      : super(key: key);

  @override

  Widget build(BuildContext context) {
    TextEditingController medicationController = TextEditingController();
    return BaseView<SOAPViewModel>(
        onModelReady: (model){
      WidgetsBinding.instance.addPostFrameCallback((_) {
        getChiefComplaints(model);
      });
    },
    builder: (_, model, w) => Padding(
      padding: const EdgeInsets.all(12.0),
      child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
        AddSoapItem(
          onAddSoapItemClicked: () {
            Navigator.push(
                context,
                MaterialPageRoute(
                  builder: (BuildContext context) => AddChiefComplaint(
                      complaints: model.getChiefComplaintListVidaPlus,
                     patientInfo: patientInfo,

                      selectedType: '',
                      firstField: '',
                      secondField: '',
                      thirdField: ''),
                ));
          },
          title: TranslationBase.of(context).addChiefComplaint,
        ),
        SizedBox(height: 16),
                    if (model.getChiefComplaintListVidaPlus.isEmpty) ...{
                      SizedBox(
                        width: MediaQuery.sizeOf(context).width,
                        child: EmptyComplaints(),
                      )
                    } else ...{
                      Container(
                          width: MediaQuery.of(context).size.width,
                          height: 40,
                          child: ListView.builder(
                              shrinkWrap: true,
                              scrollDirection: Axis.horizontal,
                              itemCount:
                                  model.getChiefComplaintListVidaPlus.length,
                              itemBuilder: (_, index) => ComplaintItems(
                                  complaint: model
                                      .getChiefComplaintListVidaPlus[index]!,
                                  onCrossClicked: (complaints) {}))),
                    }
                  ]),
            ));
  }
  getChiefComplaints(SOAPViewModel model){
   model.getChiefComplaint(patientInfo);
  }

}
