import 'package:byod/helper/helper.dart';
import 'package:flutter/material.dart';

// import '../../models/category_list.dart';
String fontFamily = 'K2D';

Text defaultText(
  BuildContext context,
  String text, {
  TextStyle? style,
  int? maxLines,
  TextOverflow? overFlow,
  TextAlign? textAlign,
  Key? key,
}) {
  return Text(
    text,
    key: (key != null) ? key : null,
    textScaleFactor: textScaleFactor,
    maxLines: (maxLines != null) ? maxLines : null,
    overflow: (overFlow != null) ? overFlow : null,
    textAlign: (textAlign != null) ? textAlign : null,
    style: (style != null) ? style : null,
  );
}

TextStyle tableNameStyle({font = 20, Color color = textColorTabel}) {
  return TextStyle(
    fontFamily: (fontFamily == '') ? null : fontFamily,
    fontSize: font,
    fontWeight: FontWeight.w400,
    color: color,
  );
}

TextStyle favNameStyle({font = 14, Color color = textColorBlack}) {
  return TextStyle(
    fontFamily: (fontFamily == '') ? null : fontFamily,
    fontSize: font,
    fontWeight: FontWeight.w600,
    color: color,
  );
}

TextStyle catNameStyle({font = 12, Color color = textColorBlack}) {
  return TextStyle(
    fontFamily: (fontFamily == '') ? null : fontFamily,
    fontSize: font,
    fontWeight: FontWeight.w700,
    color: color,
  );
}

TextStyle menuNameGridFav(
    {font = 12, Color color = textColorBlack, String fontFamilyStyle = ''}) {
  return TextStyle(
    fontFamily: 'Roboto',
    fontSize: font,
    fontWeight: FontWeight.w500,
    color: color,
  );
}

TextStyle menuPriceGridFav({
  font = 8,
  Color color = textColorBlack,
}) {
  return TextStyle(
    fontFamily: (fontFamily == '') ? null : fontFamily,
    fontSize: font,
    fontWeight: FontWeight.w400,
    color: color,
  );
}

TextStyle addButtonGridFav({
  font = 12,
  Color color = textInButton,
}) {
  return TextStyle(
    fontFamily: 'OpenSans',
    fontSize: font,
    fontWeight: FontWeight.w400,
    color: color,
  );
}

TextStyle amountGridFav({
  font = 12,
  Color color = textColorBlack,
}) {
  return TextStyle(
    fontFamily: 'OpenSans',
    fontSize: font,
    fontWeight: FontWeight.w500,
    color: color,
  );
}

TextStyle categoryStyle({
  font = 14,
  Color color = textColorBlack,
}) {
  return TextStyle(
    fontFamily: (fontFamily == '') ? null : fontFamily,
    fontSize: font,
    fontWeight: FontWeight.w600,
    color: color,
  );
}

TextStyle subCategoryStyle({
  font = 28,
  Color color = textColorBlack,
}) {
  return TextStyle(
    fontFamily: 'Roboto',
    fontSize: font,
    fontWeight: FontWeight.w500,
    color: color,
  );
}

TextStyle categoryNameStyle({
  font = 20,
  Color color = textColorBlack,
}) {
  return TextStyle(
    fontFamily: (fontFamily == '') ? null : fontFamily,
    fontSize: font,
    fontWeight: FontWeight.w600,
    color: color,
  );
}

TextStyle menuNameStyle({
  font = 16,
  Color color = textColorBlack,
}) {
  return TextStyle(
    fontFamily: 'Roboto',
    fontSize: font,
    fontWeight: FontWeight.w500,
    color: color,
  );
}

TextStyle deskripsiMenuStyle({
  font = 12,
  Color color = textColorBlack,
}) {
  return TextStyle(
    fontFamily: 'Roboto',
    fontSize: font,
    fontWeight: FontWeight.w300,
    color: color,
  );
}

TextStyle amountMenuStyle({
  font = 16,
  Color color = textColorBlack,
}) {
  return TextStyle(
    fontFamily: (fontFamily == '') ? null : fontFamily,
    fontSize: font,
    fontWeight: FontWeight.w300,
    color: color,
  );
}

TextStyle addButtonMenu({
  font = 12,
  Color color = textInButton,
}) {
  return TextStyle(
    fontFamily: 'OpenSans',
    fontSize: font,
    fontWeight: FontWeight.w400,
    color: color,
  );
}

TextStyle addButtonBotoomCart({
  font = 16,
  Color color = textInButton,
}) {
  return TextStyle(
    fontFamily: 'Roboto',
    fontSize: font,
    fontWeight: FontWeight.w600,
    color: color,
  );
}

Text fontAwesome(BuildContext context, String unicode, double fontSize,
    {Color? color, isBold = true}) {
  // double widthScreens = responsiveWidthScreen(context);
  double fontSizeResponsive = MediaQuery.of(context).size.height * fontSize;
  return Text(
    unicode,
    style: TextStyle(
      fontFamily: 'FontAwesome',
      fontSize: fontSizeResponsive,
      color: color,
      fontWeight: (isBold) ? FontWeight.w600 : FontWeight.w400,
    ),
  );
}

Text fontAwesomeCart(BuildContext context, String unicode, double fontSize,
    {Color? color, isBold = true}) {
  // double widthScreens = responsiveWidthScreen(context);
  // double fontSizeResponsive = MediaQuery.of(context).size.height * fontSize;
  return Text(
    unicode,
    style: TextStyle(
      fontFamily: 'FontAwesome',
      fontSize: fontSize,
      color: color,
      fontWeight: (isBold) ? FontWeight.w600 : FontWeight.w400,
    ),
  );
}

Text textCategory(BuildContext context, String text) {
  return defaultText(context, text, style: textStyleCategoryMenu(context));
}

Text textGroup(BuildContext context, String text) {
  return defaultText(
    context,
    text,
    style: textStyleGroup(context),
  );
}

Text textMenuList(BuildContext context, String text) {
  // return Text(
  //   text,
  //   maxLines: 3,
  //   textScaleFactor: textScaleFactor,
  //   overflow: TextOverflow.ellipsis,
  //   style: textStyleMenuList(context),
  // );
  return defaultText(
    context,
    text,
    maxLines: 3,
    overFlow: TextOverflow.ellipsis,
    style: textStyleMenuList(context),
  );
}

Text textMenuDescription(BuildContext context, String text) {
  // return Text(
  //   text,
  //   maxLines: 3,
  //   textScaleFactor: textScaleFactor,
  //   overflow: TextOverflow.ellipsis,
  //   style: textStyleMenuList(context),
  // );
  return defaultText(
    context,
    text,
    maxLines: 2,
    overFlow: TextOverflow.ellipsis,
    style: textStyleMenuDescription(context),
  );
}

Text textAmountMenu(BuildContext context, int amount) {
  return defaultText(context, formatNumber().format(amount),
      overFlow: TextOverflow.clip,
      style: textStyleAmount(
        context,
        font: normalFont,
      ));
  // return Text(
  //   formatNumber().format(amount),
  //   overflow: TextOverflow.clip,
  //   textScaleFactor: textScaleFactor,
  //   style: textStyleAmount(
  //     context,
  //     font: normalFont,
  //   ),
  // );
}

Text textAmountCoret(BuildContext context, int hargaCoret) {
  return defaultText(
    context,
    formatNumber().format(hargaCoret),
    overFlow: TextOverflow.clip,
    style: textStyleAmount(
      context,
      textColor: Colors.black45,
      decoration: TextDecoration.lineThrough,
    ),
  );
  // return Text(
  //   formatNumber().format(hargaCoret),
  //   overflow: TextOverflow.clip,
  //   style: textStyleAmount(
  //     context,
  //     textColor: Colors.black45,
  //     decoration: TextDecoration.lineThrough,
  //   ),
  // );
}

Text textAmoutBottomShetModalMenu(BuildContext context, int amount) {
  return defaultText(
    context,
    formatNumber().format(amount),
    overFlow: TextOverflow.clip,
    style: textStyleAmount(
      context,
      font: normalFont,
    ),
  );
  // return Text(
  //   formatNumber().format(amount),
  //   overflow: TextOverflow.clip,
  //   style: textStyleAmount(
  //     context,
  //     font: normalFont,
  //   ),
  // );
}

Text textMenuNameBottomShetModalMenu(BuildContext context, String text) {
  return defaultText(
    context,
    text,
    maxLines: 2,
    overFlow: TextOverflow.ellipsis,
    style: textStyleMenuList(context),
  );
  // return Text(
  //   text,
  //   maxLines: 2,
  //   overflow: TextOverflow.ellipsis,
  //   style: textStyleMenuList(context),
  // );
}

Text textDescriptionBottomShetModalMenu(BuildContext context, String text) {
  return defaultText(
    context,
    text,
    maxLines: 5,
    overFlow: TextOverflow.ellipsis,
    style: textStyleMenuDescription(context),
  );
  // return Text(
  //   text,
  //   maxLines: 2,
  //   overflow: TextOverflow.ellipsis,
  //   style: textStyleMenuList(context),
  // );
}

Text textAddButton(BuildContext context, String text) {
  return defaultText(
    context,
    text,
    style: textStyleAddButton(
      context,
      color: textInButton,
    ),
  );
  // return Text(text,
  //     style: textStyleAddButton(
  //       context,
  //       color: textInButton,
  //     ));
}

TextStyle textStyleListHistoryOrder(context,
    {font = listHistoryFontName, isBold = false}) {
  return TextStyle(
    fontFamily: (fontFamily == '') ? null : fontFamily,
    fontSize: MediaQuery.of(context).size.height * font,
    fontWeight: (isBold) ? FontWeight.w600 : FontWeight.w400,
  );
}

TextStyle textStyleCategoryMenu(context, {font = categoryFont}) {
  return TextStyle(
      fontFamily: (fontFamily == '') ? null : fontFamily,
      fontSize: MediaQuery.of(context).size.height * font,
      fontWeight: FontWeight.w600);
}

TextStyle textStyleGroup(context, {font = groupFont}) {
  return TextStyle(
      fontFamily: (fontFamily == '') ? null : fontFamily,
      fontSize: MediaQuery.of(context).size.height * font,
      fontWeight: FontWeight.w600);
}

TextStyle textStyleNormalFont(
  context, {
  font = normalFont,
  Color? color,
  FontStyle? fontStyle,
  bool isBold = false,
}) {
  // double widtScreens = responsiveWidthScreen(context);
  return TextStyle(
    fontFamily: (fontFamily == '') ? null : fontFamily,
    fontSize: MediaQuery.of(context).size.height * font,
    fontWeight: (!isBold) ? FontWeight.w400 : FontWeight.w600,
    color: (color == null) ? null : color,
    fontStyle: (fontStyle == null) ? null : fontStyle,
  );
}

TextStyle textStyleAddButton(
  context, {
  font = normalFont,
  Color? color,
  FontStyle? fontStyle,
  bool isBold = false,
}) {
  return TextStyle(
    fontFamily: (fontFamily == '') ? null : fontFamily,
    fontSize: MediaQuery.of(context).size.height * font,
    fontWeight: (!isBold) ? FontWeight.w400 : FontWeight.w600,
    color: (color == null) ? null : color,
    fontStyle: (fontStyle == null) ? null : fontStyle,
  );
}

TextStyle textStyleRefresh(context) {
  return TextStyle(
      fontFamily: (fontFamily == '') ? null : fontFamily,
      fontSize: MediaQuery.of(context).size.height * refreshFont,
      color: textInButton);
}

TextStyle textStyleTambahPesanan(context) {
  return TextStyle(
    fontFamily: (fontFamily == '') ? null : fontFamily,
    fontSize: MediaQuery.of(context).size.height * addMoreFont,
    color: textInButton,
  );
}

TextStyle textStyleVersionNumber(context) {
  return TextStyle(
    fontFamily: (fontFamily == '') ? null : fontFamily,
    fontSize: MediaQuery.of(context).size.height * versionFont,
    color: Colors.black54,
    fontStyle: FontStyle.italic,
  );
}

TextStyle textStyleVoucherListAddMore(context) {
  return TextStyle(
    fontFamily: (fontFamily == '') ? null : fontFamily,
    fontSize: MediaQuery.of(context).size.height * moreValueVoucher,
    color: Colors.black54,
    fontStyle: FontStyle.italic,
  );
}

TextStyle textStyleVoucherMinTrans(context, {Color? textColor}) {
  return TextStyle(
    fontFamily: (fontFamily == '') ? null : fontFamily,
    fontSize: MediaQuery.of(context).size.height * minTransFont,
    color: (textColor == null) ? null : textColor,
    fontStyle: FontStyle.italic,
  );
}

TextStyle textStyleMenuList(context,
    {Color? textColor, TextDecoration? decoration, font = menuFont}) {
  return TextStyle(
    fontFamily: (fontFamily == '') ? null : fontFamily,
    fontSize: MediaQuery.of(context).size.height * font,
    fontWeight: FontWeight.w600,
    color: (textColor == null) ? null : textColor,
    decoration: (decoration == null) ? null : decoration,
  );
}

TextStyle textStyleMenuDescription(context,
    {Color? textColor, TextDecoration? decoration, font = descriptionFont}) {
  return TextStyle(
    fontFamily: (fontFamily == '') ? null : fontFamily,
    fontSize: MediaQuery.of(context).size.height * font,
    fontWeight: FontWeight.w400,
    color: (textColor == null) ? null : textColor,
    decoration: (decoration == null) ? null : decoration,
  );
}

TextStyle textStyleTitleReward(context,
    {Color? textColor,
    TextDecoration? decoration,
    font = voucherListFont,
    isBold = false}) {
  return TextStyle(
    fontFamily: (fontFamily == '') ? null : fontFamily,
    fontSize: MediaQuery.of(context).size.height * font,
    fontWeight: (isBold) ? FontWeight.w600 : FontWeight.w400,
    color: (textColor == null) ? null : textColor,
    decoration: (decoration == null) ? null : decoration,
  );
}

TextStyle textStyleAmount(context,
    {Color? textColor, TextDecoration? decoration, font = normalFont}) {
  return TextStyle(
    fontFamily: (fontFamily == '') ? null : fontFamily,
    fontSize: MediaQuery.of(context).size.height * font,
    fontWeight: FontWeight.w500,
    color: (textColor == null) ? null : textColor,
    decoration: (decoration == null) ? null : decoration,
  );
}

TextStyle textStyleSelectedCategory(BuildContext context) {
  return TextStyle(
    fontSize: MediaQuery.of(context).size.height * categoryListFont,
    color: textInButton,
    fontWeight: FontWeight.w600,
  );
}

Container buttonBottom(
    BuildContext context, String text, Color colorButton, double widthButton,
    {Color colorText = textInButton}) {
  double widhtScreen = responsiveWidthScreen(context);
  return Container(
    height: MediaQuery.of(context).size.height * heigthButtonBottom,
    width: widhtScreen * widthButton,
    decoration: BoxDecoration(
      borderRadius: BorderRadius.circular(roundedButton),
      color: colorButton,
    ),
    child: Container(
      margin: const EdgeInsets.all(5),
      // color: Colors.red,
      child: Align(
          alignment: Alignment.center,
          child: Text(
            text,
            // style: TextStyle(
            //     fontWeight: FontWeight.w500,
            //     fontSize: 18,
            //     color: textInButton),
            style: textStyleNormalFont(context, color: colorText),
          )),
    ),
  );
}
