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';

/*
 *@author: Mohammad Aljammal
 *@Date:27/4/2020
 *@param: Widget
 *@return:
 *@desc: Card With Bg Widget
 */

class CardWithBgWidget extends StatelessWidget {
  final Widget widget;
  final Color bgColor;
  final bool hasBorder;

  CardWithBgWidget(
      {@required this.widget, this.bgColor, this.hasBorder = true});

  @override
  Widget build(BuildContext context) {
    ProjectViewModel projectProvider = Provider.of(context);
    return Container(
      margin: EdgeInsets.symmetric(vertical: 10.0),
      // width: double.infinity,
      decoration: BoxDecoration(
        borderRadius: BorderRadius.all(
          Radius.circular(10.0),
        ),
        border: Border.all(
            color: hasBorder ? HexColor('#707070') : Colors.transparent,
            width: hasBorder ? 0.30 : 0),
      ),
      child: Material(
        borderRadius: BorderRadius.all(Radius.circular(10.0)),
        child: Stack(
          children: [
            if (projectProvider.isArabic)
              Positioned(
                child:  Container(
                  decoration: BoxDecoration(
                    color: bgColor ?? HexColor('#58434F'),

                    borderRadius: BorderRadius.only(
                      topLeft: Radius.circular(10),
                      bottomLeft: Radius.circular(10),),),
                  width: 10,
                ),
                bottom: 1,
                top: 1,
                right: 1,
              )
            else
              Positioned(
                child: Container(
                  decoration: BoxDecoration(
                      color: bgColor ?? HexColor('#58434F'),

                      borderRadius: BorderRadius.only(
                          topLeft: Radius.circular(10),
                          bottomLeft: Radius.circular(10),),),
                  width: 10,
                ),
                bottom: 1,
                top: 1,
                left: 1,
              ),
            Container(
                padding: EdgeInsets.all(15.0),
                margin: EdgeInsets.only(left: 10),
                child: widget)
          ],
        ),
      ),
    );
  }
}
