import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart';
import 'package:flutter/material.dart';
import 'package:hexcolor/hexcolor.dart';
import 'package:provider/provider.dart';

class CardWithBgWidget extends StatelessWidget {
  final Widget widget;
  final Color? bgColor;
  final bool hasBorder;
  final double padding;
  final double marginLeft;
  final double marginSymmetric;

  CardWithBgWidget(
      {required this.widget,
      this.bgColor,
      this.hasBorder = true,
      this.padding = 15.0,
      this.marginLeft = 10.0,
      this.marginSymmetric = 10.0});

  @override
  Widget build(BuildContext context) {
    ProjectViewModel projectProvider = Provider.of(context);
    return Container(
      margin: EdgeInsets.symmetric(vertical: marginSymmetric),
      // width: double.infinity,
      decoration: BoxDecoration(
        borderRadius: BorderRadius.all(
          Radius.circular(10.0),
        ),
        border: Border.all(
            color: hasBorder ? Color(0xFF707070) : Colors.transparent,
            width: hasBorder ? 0.30 : 0),
        boxShadow: [
          BoxShadow(
            color: HexColor('#0000000D').withOpacity(0.03),
            //color: Colors.grey.withOpacity(0.5),
            spreadRadius: 5,
            blurRadius: 5,
            offset: Offset(0, 3), // changes position of shadow
          ),
        ],
      ),

      child: Material(
        borderRadius: BorderRadius.all(Radius.circular(10.0)),
        child: Stack(
          children: [
            if (projectProvider.isArabic)
              Positioned(
                child: Container(
                  decoration: BoxDecoration(
                    color: bgColor ?? Color(0xFF58434F),
                    borderRadius: BorderRadius.only(
                      topRight: Radius.circular(10),
                      bottomRight: Radius.circular(10),
                    ),
                  ),

                  width: 6,
                ),
                bottom: 1,
                top: 1,
                right: 1,
              )
            else
              Positioned(
                child: Container(
                  decoration: BoxDecoration(
                    color: bgColor ?? Color(0xFF58434F),
                    borderRadius: BorderRadius.only(
                      topLeft: Radius.circular(10),
                      bottomLeft: Radius.circular(10),
                    ),

                  ),

                  width: 5,
                ),
                bottom: 1,
                top: 1,
                left: 1,
              ),
            Container(
                padding: EdgeInsets.all(padding),
                margin: EdgeInsets.only(
                    left: !projectProvider.isArabic ? marginLeft : 0,
                    right: projectProvider.isArabic ? marginLeft : 0),
                child: widget)
          ],
        ),
      ),
    );
  }
}
