import 'package:doctor_app_flutter/core/model/dashboard/get_special_clinical_care_List_Respose_Model.dart';
import 'package:doctor_app_flutter/core/viewModel/PatientSearchViewModel.dart';
import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart';
import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart';
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

class InPatientHeader extends StatelessWidget implements PreferredSizeWidget {
  InPatientHeader({required this.model, required this.specialClinic, this.activeTab, this.selectedMapId, this.onChangeFunc}) : super();
  final PatientSearchViewModel model;
  final GetSpecialClinicalCareListResponseModel specialClinic;
  final activeTab;
  final selectedMapId;
  final onChangeFunc;

  @override
  Widget build(BuildContext context) {
    ProjectViewModel projectsProvider = Provider.of<ProjectViewModel>(context);

    return Container(
      padding: EdgeInsets.only(left: 0, right: 5, bottom: 5, top: 5),
      decoration: BoxDecoration(
        color: Colors.white,
      ),
      child: Container(
        padding: EdgeInsets.only(left: 10, right: 10, bottom: 10),
        margin: EdgeInsets.only(top: 50),
        child: Row(children: [
          IconButton(
            icon: Icon(Icons.arrow_back_ios),
            color: Color(0xFF2B353E), //Colors.black,
            onPressed: () => Navigator.pop(context),
          ),
          Expanded(
            child: AppText(
              TranslationBase.of(context).inPatient,
              fontSize: 24.0,
              fontWeight: FontWeight.w700,
              color: Color(0xFF2B353E),
              letterSpacing: -1.44,
            ),
          ),
          if (model.specialClinicalCareMappingList.isNotEmpty && specialClinic != null && activeTab != 2)
            Container(
              width: MediaQuery.of(context).size.width * .3,
              child: DropdownButtonHideUnderline(
                  child: DropdownButton(
                dropdownColor: Colors.white,
                iconEnabledColor: Colors.black,
                isExpanded: true,
                value: selectedMapId ?? model.specialClinicalCareMappingList[0].nursingStationID,
                iconSize: 25,
                elevation: 16,
                selectedItemBuilder: (BuildContext context) {
                  return model.specialClinicalCareMappingList.map((item) {
                    return Row(
                      mainAxisSize: MainAxisSize.max,
                      mainAxisAlignment: MainAxisAlignment.end,
                      children: <Widget>[
                        Column(
                          mainAxisAlignment: MainAxisAlignment.center,
                          children: [
                            Container(
                                padding: EdgeInsets.all(2),
                                margin: EdgeInsets.all(2),
                                decoration: new BoxDecoration(
                                  color: Colors.red[800],
                                  borderRadius: BorderRadius.circular(20),
                                ),
                                constraints: BoxConstraints(
                                  minWidth: 20,
                                  minHeight: 20,
                                ),
                                child: Center(
                                  child: AppText(
                                    model.specialClinicalCareMappingList.length.toString(),
                                    color: Colors.white,
                                    fontSize: projectsProvider.isArabic ? 10 : 11,
                                    textAlign: TextAlign.center,
                                  ),
                                )),
                          ],
                        ),
                        AppText(selectedMapId == null ? TranslationBase.of(context).all : item.description!, fontSize: 12, color: Colors.black, fontWeight: FontWeight.bold, textAlign: TextAlign.end),
                      ],
                    );
                  }).toList();
                },
                onChanged: (newValue) async {
                  onChangeFunc(newValue);
                },
                items: model.specialClinicalCareMappingList.map((item) {
                  return DropdownMenuItem(
                    child: AppText(
                      item.description!,
                      textAlign: TextAlign.left,
                    ),
                    value: item.nursingStationID,
                  );
                }).toList(),
              )),
            ),
        ]),
      ),
    );
  }

  @override
  Size get preferredSize => Size(double.maxFinite, 85);
}
