import 'package:doctor_app_flutter/core/enum/view_state.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/utils/translations_delegate_base_utils.dart';
import 'package:doctor_app_flutter/widgets/bottom_sheet/custom_bottom_sheet_container.dart';
import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart';
import 'package:flutter/material.dart';

import '../../../../../../core/model/SOAP/allergy/get_patient_allergies_list_vida_plus.dart';
import '../../../../../../core/model/patient/patiant_info_model.dart';
import '../../../../patient_search/patient_search_header.dart';
import 'master_key_checkbox_search_allergies_widget.dart';

class AddAllergies extends StatefulWidget {
  final PatientAllergiesVidaPlus? myAllergiesList;
  final PatiantInformtion patientInfo;
  const AddAllergies({Key? key, this.myAllergiesList, required this.patientInfo})
      : super(key: key);

  @override
  _AddAllergiesState createState() => _AddAllergiesState();
}

class _AddAllergiesState extends State<AddAllergies> {
  // List<MasterKeyModel> allergiesList = [];
  // List<MasterKeyModel> allergySeverityList = [];
  //
  // myAllergiesListLocal = [];

  @override
  initState() {
    super.initState();
    // myAllergiesListLocal = [...?widget.myAllergiesList];
  }

  // GlobalKey key = new GlobalKey<AutoCompleteTextFieldState<MasterKeyModel>>();
  bool isFormSubmitted = false;

  @override
  Widget build(BuildContext context) {
    return BaseView<SOAPViewModel>(
      onModelReady: (model){
        WidgetsBinding.instance.addPostFrameCallback((_) {
          model.clearAllergy();
        });
      },
        builder: (_, model, w) => AppScaffold(
              isShowAppBar: true,
              isLoading: model.state == ViewState.BusyLocal,
              appBar: PatientSearchHeader(
                  title: TranslationBase.of(context).addAllergies),
              body: MasterKeyCheckboxSearchAllergiesWidget(
                model: model,
                  myAllergiesList: widget.myAllergiesList,
                  patientInfo: widget.patientInfo
              ),
              bottomSheet: CustomBottomSheetContainer(
                widthFactor: .9,
                buttonColor: Color(0xffEAEAEA),
                fontColor: Colors.black,
                label: TranslationBase.of(context).cancel,
                onTap: () {
                  Navigator.of(context).pop();
                },
              )),
            );
  }
}
