import 'package:flutter/material.dart';
import 'package:test_sa/extensions/context_extension.dart';

class AppColor {
  AppColor._();

  //primary
  static const Color primary10 = Color(0xff3DA5E5);
  static const Color primary30 = Color(0xffA2E2F8);
  static const Color primary40 = Color(0xff75BDE0);
  static const Color primary50 = Color(0xff4A8DB7);
  static const Color primary60 = Color(0xff3B7097);
  static const Color primary70 = Color(0xff163A51);
  static const Color primary80 = Color(0xff161D27);
  static const Color primary90 = Color(0xff1E95DE);
  static const Color primary63 = Color(0xff63A4D1);

  //texts
  static const Color neutral10 = Color(0xffBCBCBC);
  static const Color neutral20 = Color(0xff767676);
  static const Color neutral30 = Color(0xffEAF1F4);
  static const Color neutral40 = Color(0xffE4E5E6);
  static const Color neutral50 = Color(0xff3B3D4A);
  static const Color neutral60 = Color(0xff2C2C31);
  static const Color neutral70 = Color(0xff111427);
  static const Color neutral80 = Color(0xffF3F3F3);
  static const Color neutral90 = Color(0xffF7F9FB);
  static const Color neutral100 = Color(0xffF4F6FC);
  static const Color neutral110 = Color(0xffF3F5FB);
  static const Color neutral120 = Color(0xff7D859A);
  static const Color neutral130 = Color(0xffE0E0E0);
  static const Color neutral140 = Color(0xffE6E6E6);
  static const Color neutral150 = Color(0xffA1A1A1);
  static const Color neutral160 = Color(0xffE5E5E5);
  static const Color neutral170 = Color(0xff6E6E6E);

  //background
  static const Color backgroundLight = Color(0xfff7f9fb);
  static const Color backgroundDark = Color(0xff111427);

  //white
  static const Color white10 = Color(0xffFFFFFF);
  static const Color white20 = Color(0xffF7F9FB);
  static const Color white30 = Color(0xffE7EBF2);
  static const Color white40 = Color(0xffE4EBEE);
  static const Color white50 = Color(0xffECECEC);
  static const Color white60 = Color(0xffEFEFEF);
  static const Color white70 = Color(0xffF1F1F1);
  static const Color white80 = Color(0xffF2F4FA);
  static const Color white90 = Color(0xffBFD1E4);
  static const Color white936 = Color(0xff212936);

//black
  static const Color black10 = Color(0xff3B3D4A);
  static const Color black20 = Color(0xff212936);
  static const Color black35 = Color(0xff222A36);
  static const Color black1E = Color(0xff1E1F20);

  //red
  static const Color red20 = Color(0xfff2c5ca);
  static const Color red30 = Color(0xffF63939);
  static const Color red40 = Color(0xffFFDBDC);
  static const Color red50 = Color(0xffD02127);
  static const Color red60 = Color(0xff8C050A);
  static const Color red70 = Color(0xffF63939);
  static const Color red80 = Color(0xfffdcdcd);

  //green
  static const Color green40 = Color(0xffBAFFE1);
  static const Color green50 = Color(0xff62BE96);
  static const Color green30 = Color(0xffd8efe5);
  static const Color green60 = Color(0xff065E38);
  static const Color green70 = Color(0xff54C166);
  static const Color green15 = Color(0xff157D14);
  static const Color green20 = Color(0xffcde6e1);

  //orange
  static const Color orange30 = Color(0xffFDE19B);
  static const Color orange40 = Color(0xffFFEDBC);
  static const Color orange50 = Color(0xffCC9B14);
  static const Color orange60 = Color(0xff886400);
  static const Color orange70 = Color(0xffFFC945);
  static const Color orange80 = Color(0xff65531B);

  // static Color greenStatus(BuildContext context) => context.isDark ? const Color(0xff1FA269) : green50;
  static Color greenStatus(BuildContext context) => context.isDark ? const Color(0xff54C166) : green70.withOpacity(.5);

  // static Color blueStatus(BuildContext context) => context.isDark ? primary40 : primary50;
  static Color blueStatus(BuildContext context) => context.isDark ? primary40 : primary90;

  static Color redStatus(BuildContext context) => context.isDark ? const Color(0xffFFB6B8) : red30;

  // static Color yellowStatus(BuildContext context) => context.isDark ? const Color(0xffFFDA76) : orange40;
  static Color yellowStatus(BuildContext context) => context.isDark ? const Color(0xffFFC945) : orange30;

  static Color yellowIcon(BuildContext context) => context.isDark ? const Color(0xffFFC945) : orange70;

  static Color background(BuildContext context) => context.isDark ? neutral60 : Colors.white;
  static Color textColor(BuildContext context) =>context.isDark ? AppColor.neutral30 : AppColor.neutral50;
  static Color headingTextColor(BuildContext context) =>context.isDark ? AppColor.neutral30 : AppColor.black10;
  static Color lightTextColor(BuildContext context) =>AppColor.neutral120;
  static Color iconColor(BuildContext context) =>context.isDark ? AppColor.neutral30 : AppColor.neutral50;
  static Color fieldBgColor(BuildContext context) => context.isDark ? AppColor.neutral20 : AppColor.neutral100;

  static Color selectedButtonColor(BuildContext context) => context.isDark ? neutral60 : neutral30;

  static Color unSelectedButtonColor(BuildContext context) => context.isDark ? neutral60 : Colors.white;

  static Color filterButtonTextColor(BuildContext context) => context.isDark ? neutral30 : neutral50;

  static Color getRequestStatusTextColorByName(BuildContext context, String? status) {
    switch ((status ?? "").toLowerCase()) {
      case "in progress":
        return orange60;
      case "high priority":
        return white10;
      case "yes":
        return white10;
      case "low priority":
        return green15;
      case "low":
        return green15;
      default:
        return Colors.white;
    }
  }

  static Color getHistoryLogStatusTextColorByName(String status) {
    switch ((status).toLowerCase()) {
      case "in progress":
        return white936;
      case "new":
        return primary63;
      case "open":
        return primary63;
      case "closed":
        return black1E;
      case "completed":
        return green15;
      case "fixed":
        return green15;
      default:
        return Colors.white;
    }
  }
  static Color getActivityTypeBgColor(String type) {
   switch (type) {
      case "Internal":
        return neutral50;
      case "External":
        return white90;
      default:

        return primary10;
    }
  }
static Color getActivityTypeTextColor(String type) {
    switch (type) {
      case "Internal":
        return white10;
      case "External":
        return black10;
      default:
        return Colors.white;
    }
  }

  static Color getHistoryLogStatusColorByName(String status) {
    switch ((status).toLowerCase()) {
      case "in progress":
        return orange30;
      case "new":
        return primary10.withOpacity(.30);
      case "open":
        return primary10.withOpacity(.30);
      case "closed":
        return white936.withOpacity(.30);
      case "completed":
        return green70.withOpacity(.5);
      case "fixed":
        return green70.withOpacity(.5);
      case "reject":
        return red30;
      case "cancelled":
        return red30;
      case "canceled":
        return red30;
      case "returned":
        return red30;
      default:
        return Colors.white;
    }
  }

  static Color getRequestStatusColorByName(BuildContext context, String? status) {
    switch ((status ?? "").toLowerCase()) {
      case "medium":
        return blueStatus(context);
      case "in progress":
        return yellowStatus(context);
      case "complete":
        return greenStatus(context);
      case "closed":
        return greenStatus(context);
      case "high priority":
        return redStatus(context);
      case "yes":
        return redStatus(context);
      case "low priority":
        return greenStatus(context);
      case "open":
        return blueStatus(context);
      default:
        return greenStatus(context);
    }
  }

  static Color getRequestStatusColor(BuildContext context, int id) {
    switch (id) {
      case 1:
        return blueStatus(context);
      case 2:
        return yellowStatus(context);
      case 3:
        return greenStatus(context);
      case 4:
        return redStatus(context);
      case 6:
        return greenStatus(context);
      case 5:
        return greenStatus(context);
      case 8:
        return greenStatus(context);
      case 9:
        return orange40;
      default:
        return blueStatus(context);
    }
  }

  static Color getRequestStatusTextColor(BuildContext context, int id) {
    switch (id) {
      case 2:
        return orange60;
      case 4:
        return red60;
      case 9:
        return orange60;
      default:
        return Colors.white;
    }
  }

  static Color getPriorityStatusTextColor(BuildContext context, int id) {
    switch (id) {
      //low priority
      case 81:
        return green15;
      case 370:
        return green15;
      case 82:
        //high priority
        return white10;
      default:
        return blueStatus(context);
    }
  }

  static Color getPriorityStatusColor(BuildContext context, int id) {
    switch (id) {
      //low priority
      case 81:
        return greenStatus(context);
      case 370:
        return greenStatus(context);
      //high priority
      case 82:
        return redStatus(context);
      default:
        return blueStatus(context);
    }
  }
  static Color getEquipmentStatusColor(BuildContext context, int id) {
    switch (id) {
      case 368:
      //partially Down
        return greenStatus(context);
      case 369:
      // Completely Down
        return redStatus(context);
      case 790:
      //UP
        return blueStatus(context);
      default:
        return blueStatus(context);
    }
  }
}
