import 'package:doctor_app_flutter/screens/patients/profile/soap_update_vida_plus/widgets/SoapDetailItem.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/buttons/app_buttons_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:hexcolor/hexcolor.dart';

typedef OnSoapDetailActionClicked = Function(SoapDetailItemActions);

class PreviousDiagnosisItem extends StatelessWidget {
  final String title;
  final String condition;
  final String status;
  final String remarks;
  final String? type;
  final bool isPreviousAddedToCurrent;
  final OnSoapDetailActionClicked onSoapDetailActionClicked;

  const PreviousDiagnosisItem(
      {super.key,
      required this.title,
      required this.condition,
      required this.remarks,
      required this.onSoapDetailActionClicked,
      required this.status,
      this.type,
      required this.isPreviousAddedToCurrent});

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 8),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          // Stack(
          //   children: [
          Column(
            mainAxisSize: MainAxisSize.min,
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Row(
                children: [
                  Expanded(
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        AppText(
                          title,
                          color: Color(0XFF2B353E),
                          fontSize: 12,
                          fontWeight: FontWeight.bold,
                        ),
                        SizedBox(
                          height: 4,
                        ),
                        Row(
                          children: [
                            AppText(
                              "${TranslationBase.of(context).condition}:",
                              color: Color(0XFF2B353E),
                              fontSize: 10,
                              fontWeight: FontWeight.w500,
                            ),
                            SizedBox(
                              width: 4,
                            ),
                            AppText(
                              condition,
                              color: Color(0xffD02127),
                              fontSize: 10,
                              fontWeight: FontWeight.w500,
                            ),
                          ],
                        ),
                      ],
                    ),
                  ),
                  Status(status: status),
                ],
              ),
              Visibility(
                  visible: remarks.isNotEmpty,
                  child: Column(
                    children: [
                      SizedBox(
                        height: 8,
                      ),
                      AppText(
                        remarks,
                        color: Color(0XFF2B353E),
                        fontSize: 10,
                        fontWeight: FontWeight.w400,
                      ),
                    ],
                  ))
            ],
          ),
          // Align(
          //     alignment: Alignment.topRight, child: Status(status: status))
          // ],
          // ),
          SizedBox(
            height: 16,
          ),
          Row(
            mainAxisSize: MainAxisSize.max,
            mainAxisAlignment: MainAxisAlignment.end,
            children: [
              GestureDetector(
                behavior: HitTestBehavior.opaque,
                onTap: () =>
                    onSoapDetailActionClicked(SoapDetailItemActions.AUDIT),
                child: SoapDetailItemActionsView(
                  icon: 'assets/images/svgs/audit.svg',
                  fontColor: Color(0XFF2B353E),
                  text: TranslationBase.of(context).audit,
                ),
              ),
              SizedBox(
                width: 16,
              ),
              SizedBox(
                width: 187,
                height: 27,
                child: Material(
                  color: isPreviousAddedToCurrent
                      ? Color(0xffEAEAEA)
                      : HexColor("#D02127"),
                  shape: RoundedRectangleBorder(
                      borderRadius: BorderRadius.circular(5.0)),
                  child: InkWell(
                    onTap: () {
                      if (!isPreviousAddedToCurrent) // to make it clickable if it has not been added to the current diagnosis
                        onSoapDetailActionClicked(
                            SoapDetailItemActions.CHANGE_STATUS);
                    },
                    child: Center(
                        child: AppText(
                      TranslationBase.of(context).makeCurrentDiagnosis,
                      color: Colors.white,
                    )),
                  ),
                ),
              )
            ],
          )
        ],
      ),
    );
  }
}
