import 'package:hmg_patient_app/config/size_config.dart';
import 'package:hmg_patient_app/core/viewModels/project_view_model.dart';
import 'package:hmg_patient_app/theme/colors.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

// OWNER : Ibrahim albitar
// DATE : 12-04-2020
// DESCRIPTION : Customization for Texts in app

class AppText extends StatefulWidget {
  final String data;
  final Color? color;
  final FontWeight fontWeight;
  final double? fontSize;
  final String? fontFamily;
  final double? margin;
  final double marginTop;
  final double marginRight;
  final double marginBottom;
  final double marginLeft;
  final bool visibility;
  final TextAlign? textAlign;
  final Color backGroundcolor;
  final bool underline;
  final double? height;
  final double? letterSpacing;

  AppText(this.data,
      {this.color,
      this.fontWeight = FontWeight.normal,
      this.fontSize,
//      this.fontFamily = 'WorkSans',
      this.fontFamily,
      this.margin,
      this.marginTop = 0,
      this.marginRight = 0,
      this.marginBottom = 0,
      this.marginLeft = 0,
      this.visibility = true,
      this.textAlign,
      this.underline = false,
      this.letterSpacing,
      this.height,
      this.backGroundcolor = Colors.white});

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

class _AppTextState extends State<AppText> {
  @override
  Widget build(BuildContext context) {
    ProjectViewModel projectViewModel = Provider.of(context);
    return Visibility(
      visible: widget.visibility,
      child: Container(
        margin: widget.margin != null ? EdgeInsets.all(widget.margin!) : EdgeInsets.only(top: widget.marginTop, right: widget.marginRight, bottom: widget.marginBottom, left: widget.marginLeft),
        child: Text(
          widget.data,
          textAlign: widget.textAlign,
          overflow: TextOverflow.clip,

          style: TextStyle(
              color: widget.color == null ? CustomColors.black : widget.color,
              fontWeight: widget.fontWeight,
              fontSize: widget.fontSize ?? (SizeConfig.textMultiplier! * 2),
              height: widget.height,
              fontFamily: "Poppins",
              letterSpacing: widget.letterSpacing,
              // fontFamily: widget.fontFamily == null
              //     ? projectViewModel.isArabic
              //         ? 'Cairo'
              //         : 'WorkSans'
              //     : widget.fontFamily,
              decoration: widget.underline == true ? TextDecoration.underline : TextDecoration.none
              ),
        ),
      ),
    );
  }
}
