import 'package:doctor_app_flutter/config/size_config.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:eva_icons_flutter/eva_icons_flutter.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:hexcolor/hexcolor.dart';

class ExpandableSOAPWidget extends StatelessWidget {
  final bool isExpanded;
  final Widget? child;
  final Function() onTap;
  final headerTitle;
  final bool isRequired;

  const ExpandableSOAPWidget({Key? key, this.isExpanded = false, this.child, required this.onTap, this.headerTitle, this.isRequired = true}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.symmetric(vertical: SizeConfig.isHeightVeryShort ? 10 : 20, horizontal: 10),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.all(
          Radius.circular(10.0),
        ),
        border: Border.all(color: HexColor('#707070'), width: 0.30),
      ),
      child: HeaderBodyExpandableNotifier(
        headerWidget: InkWell(
          onTap: onTap,
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              InkWell(
                onTap: onTap,
                child: Row(
                  children: [
                    AppText(
                      headerTitle,
                      variant: isExpanded ? "bodyText" : '',
                      fontSize: SizeConfig.getTextMultiplierBasedOnWidth() *
                          (SizeConfig.isHeightVeryShort
                              ? 4.8
                              : SizeConfig.isWidthLarge
                                  ? 4
                                  : 5),
                      letterSpacing: -0.64,
                      fontWeight: FontWeight.w700,
                      color: Color(0xFF2E303A),
                    ),
                    if (isRequired)
                      Icon(
                        FontAwesomeIcons.asterisk.data,
                        size: SizeConfig.getTextMultiplierBasedOnWidth() * 2.5,
                      )
                  ],
                ),
              ),
              InkWell(
                onTap: onTap,
                child: Icon(isExpanded ? EvaIcons.arrowIosUpwardOutline : EvaIcons.arrowIosDownwardOutline),
              )
            ],
          ),
        ),
        bodyWidget: child!,
        isExpand: isExpanded,
      ),
    );
  }
}
