// ignore: must_be_immutable
import 'package:doctor_app_flutter/config/size_config.dart';
import 'package:doctor_app_flutter/core/model/SOAP/master_key_model.dart';
import 'package:doctor_app_flutter/core/model/SOAP/physical_exam/GeneralSpeciality.dart';
import 'package:doctor_app_flutter/core/model/SOAP/selected_items/my_selected_examination.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:doctor_app_flutter/widgets/shared/expandable-widget-header-body.dart';
import 'package:doctor_app_flutter/widgets/shared/text_fields/app-textfield-custom.dart';
import 'package:flutter/material.dart';
import 'package:hexcolor/hexcolor.dart';
import 'package:provider/provider.dart';

// ignore: must_be_immutable
class AddExaminationVidaPlusWidget extends StatefulWidget {
  GeneralSpeciality? item;
  final Function(GeneralSpeciality?) removeExamination;
  final Function(GeneralSpeciality?) addExamination;

  final List<GeneralSpeciality>? mySelectedExamination;

  AddExaminationVidaPlusWidget({
    this.item,
    required this.removeExamination,
    required this.addExamination,
    this.mySelectedExamination,
  });

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

class _AddExaminationVidaPlusWidgetState extends State<AddExaminationVidaPlusWidget> {
  int status = 1;
  TextEditingController remarksController = TextEditingController();
  MySelectedExamination examination = MySelectedExamination();

  @override
  void initState() {

    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    ProjectViewModel projectViewModel = Provider.of(context);

    return Row(
      mainAxisAlignment: MainAxisAlignment.spaceBetween,
      children: [
        InkWell(
          onTap: () {
            onExamTap();
          },
          child: Row(
            children: [
              Checkbox(
                  value:widget.item?.isSelected ?? false,
                  activeColor: Colors.red[800],
                  onChanged: (bool? newValue) {
                    onExamTap();
                  }),
              Container(
                child: AppText(
                  widget.item?.name ?? '',
                  color: Color(0xFF575757),
                  fontSize: SizeConfig.getTextMultiplierBasedOnWidth() * (SizeConfig.isWidthLarge ? 3 : 3.8),
                  letterSpacing: -0.56,
                ),
              ),
            ],
          ),
        ),
      ],
    );
  }

  onExamTap() {
    if(widget.item != null ){
      if(widget.item?.isSelected == true){
        widget.removeExamination(widget.item);
      }else{
        widget.addExamination(widget.item);

      }
    }
  }

}
