import 'dart:developer';

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);
  static const Color disableDark = Color(0xff444756);
  static const Color switchBgColor = Color(0xff5A5E79);

  //background
  static const Color backgroundLight = Color(0xfff5f6fc);
  static const Color backgroundDark = Color(0xff080a14);
  static const Color backgroundTabBarDark = Color(0xff111427);
  static const Color containerDark = Color(0xff161A2D);
  static const Color containerBorderDark = Color(0xff3B3F56);
  static const Color containerBorderLight = Color(0xffEFEFEF);
  static const Color dropDownDark = Color(0xff1F2134);

  //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);
  static const Color whiteF3 = Color(0xffF1F1F3);

//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);
  static const Color black92 = Color(0xff929292);

  //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 const Color yellowBgColor = Color(0xffF4DC92);
  static const Color yellowTextColor = Color(0xff65531B);

  // new UI colors

  static const Color openChartColor = Color(0xff226187);
  static const Color inProgressChartColor = Color(0xff3DA5E5);
  static const Color completeChartColor = Color(0xff92D9F8);
  static const Color openColor = Color(0xff3DA5E5);
  static const Color inProgressColor = Color(0xffFDE19B);
  static const Color completedColor = Color(0xff54C166);
  static const Color overdueColor = Color(0xffFFC945);
  static const Color highPriorityColor = red30;
  static const Color unassignedColor = Color(0xff9F9FA8);
  static const Color lowPriorityColor = Color(0xff54C166);

  static const Color greenStatusColor = Color(0x1518C273);
  static const Color greenStatusTextColor = Color(0xff18C273);

  static const Color blueStatusColor = Color(0x303DA5E5);
  static const Color blueStatusTextColor = inProgressChartColor; //Color(0xff144F79);

  static const Color yellowStatusColor = Color(0x30F4A308);
  static const Color yellowStatusTextColor = Color(0xffD48D05);

  static const Color redStatusColor = Color(0x30F63939);
  static const Color redStatusTextColor = Color(0xffF63939);

  static const Color defaultStatusColorLight = Color(0xffEFEFF0);
  static const Color defaultStatusTextColorLight = Color(0xff2B353E);

  static const Color defaultStatusColorDark = Color(0xff262A3E);
  static const Color defaultStatusTextColorDark = Colors.white;

  static Color defaultStatusColor(BuildContext context) => context.isDark ? defaultStatusColorDark : defaultStatusColorLight;

  static Color defaultStatusTextColor(BuildContext context) => context.isDark ? defaultStatusTextColorDark : defaultStatusTextColorLight;

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

  static Color unassignedStatus(BuildContext context) => context.isDarkNotListen ? unassignedColor : white936;

  // 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.isDarkNotListen ? const Color(0xffFFC945) : orange70;

  static Color background(BuildContext context) => context.isDark ? containerDark : Colors.white;

  static Color tabBarBackground(BuildContext context) => context.isDark ? disableDark : neutral90;

  static Color tabBarBorder(BuildContext context) => context.isDark ? const Color(0xffCCCCCC) : neutral30;

  static Color scaffoldBackground(BuildContext context) => context.isDark ? backgroundDark : backgroundLight;

  static Color dropDownBackground(BuildContext context) => context.isDark ? dropDownDark : backgroundLight;

  static Color disableFieldBackground(BuildContext context) => context.isDark ? neutral60 : neutral40;

  static Color scaffold2Background(BuildContext context) => context.isDark ? backgroundDark : white20;

  static Color assetGroupBackground(BuildContext context) => context.isDark ? containerDark : Colors.white30;

  static Color backgroundTabBarColor(BuildContext context) => context.isDark ? backgroundTabBarDark : Colors.white;

  static Color loadingColor(BuildContext context) => context.isDarkNotListen ? Colors.white : primary10;

  static Color bottomSheetColor(BuildContext context) => context.isDarkNotListen ? containerDark : Colors.white;

  static Color borderColor(BuildContext context) => context.isDark ? containerBorderDark : containerBorderLight;

  static Color border2Color(BuildContext context) => context.isDark ? containerBorderDark : neutral30;

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

  static Color headingTextColor(BuildContext context) => context.isDark ? white10 : white936;

  static Color text9Color(BuildContext context) => context.isDark ? white10 : neutral120;

  static Color lightTextColor(BuildContext context) => context.isDark ? whiteF3 : neutral120;

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

  static Color icon2Color(BuildContext context) => context.isDark ? white10 : neutral50;
  static Color icon2ColorNotListen(BuildContext context) => context.isDarkNotListen ? white10 : neutral50;

  static Color textStyleColor(BuildContext context) => context.isDark ? white10 : neutral50;

  static Color labelTextStyleColor(BuildContext context) => context.isDark ? white10 : neutral50;

  static Color floatingTextStyleColor(BuildContext context) => context.isDark ? white10 : neutral120;

  static Color fieldBgColor(BuildContext context) => context.isDark ? neutral20 : neutral100;

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

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

  static Color noButtonColor(BuildContext context) => context.isDark ? AppColor.neutral70 : AppColor.white60;

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

  static Color getRequestStatusTextColorByName(BuildContext context, String? status) {
    switch ((status ?? "").toLowerCase()) {
      case "open":
        return blueStatusTextColor;
      case "in progress":
        return yellowStatusTextColor;
      case "high priority":
        return redStatusTextColor;
      case "emergency":
        return redStatusTextColor;
      case "yes":
        return redStatusTextColor;
      case "request completed":
        return greenStatusTextColor;
      case "complete":
        return greenStatusTextColor;
      case "low priority":
        return greenStatusTextColor;
      case "low":
        return greenStatusTextColor;
      case "close":
        return defaultStatusTextColor(context);
      case "closed":
        return defaultStatusTextColor(context);
      default:
        return yellowStatusTextColor;
    }
  }

  static Color getHistoryLogStatusTextColorByName(BuildContext context,String status) {
    switch ((status).toLowerCase()) {
      case "in progress":
        return yellowStatusTextColor;
      case "waiting for delivery":
        return yellowStatusTextColor;
      case "new":
        return blueStatusTextColor;
      case "open":
        return blueStatusTextColor;
      case "close":
        return defaultStatusTextColor(context);
      case "closed":
        return defaultStatusTextColor(context);
      case "completed":
        return greenStatusTextColor;
      case "fixed":
        return greenStatusTextColor;
      default:
        return defaultStatusTextColor(context);
    }
  }

  static Color getActivityTypeBgColor(String type) {
    switch (type) {
      case "Internal":
        return neutral50;
      case "External":
        return white90;
      default:
        return blueStatusColor;
    }
  }

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

  static Color getHistoryLogStatusColorByName(BuildContext context,String status) {
    switch ((status).toLowerCase()) {
      case "in progress":
        return yellowStatusColor;
      case "new":
        return blueStatusColor;
      case "open":
        return blueStatusColor;
      case "close":
        return defaultStatusColor(context);
      case "closed":
        return defaultStatusColor(context);
      case "completed":
        return greenStatusColor;
      case "fixed":
        return greenStatusColor;
      case "reject":
        return redStatusColor;
      case "cancelled":
        return redStatusColor;
      case "canceled":
        return redStatusColor;
      case "returned":
        return redStatusColor;
      case "waiting for delivery":
        return yellowStatusColor;
      case "waiting for medical gas specialist review":
        return yellowStatusColor;
      case "reviewed":
        return yellowStatusColor;
      case "returned for correction":
        return yellowStatusColor;
      default:
        return defaultStatusColor(context);
    }
  }

  static Color getRequestStatusColorByName(BuildContext context, String? status) {
    switch ((status ?? "").toLowerCase()) {
      case "medium":
        return blueStatusColor;
      case "in progress":
        return yellowStatusColor;
      case "complete":
        return greenStatusColor;
      case "request completed":
        return greenStatusColor;
      case "close":
        return defaultStatusColor(context);
      case "closed":
        return defaultStatusColor(context);
      case "high priority":
        return redStatusColor;
      case "emergency":
        return redStatusColor;
      case "yes":
        return redStatusColor;
      case "low priority":
        return greenStatusColor;
      case "open":
        return blueStatusColor;
      default:
        return yellowStatusColor;
    }
  }

  // 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 demoRequestStatus(BuildContext context, int id) {
    switch (id) {
      case 1:
        return blueStatusColor;
      case 2:
        return yellowStatusColor;
      case 3:
        return greenStatusColor;
      case 4:
        return yellowStatusColor;
      default:
        return yellowStatusColor;
    }
  }

  static Color demoRequestStatusTextColor(BuildContext context, int id) {
    switch (id) {
      case 2:
        return yellowStatusTextColor;
      case 4:
        return yellowStatusTextColor;
      case 9:
        return yellowStatusTextColor;
      default:
        return yellowStatusTextColor;
    }
  }

  static Color getPriorityStatusTextColor(BuildContext context, int id) {
    switch (id) {
      //low priority
      case 81:
        return greenStatusTextColor;
      case 370:
        return greenStatusTextColor;
      case 0:
        return greenStatusTextColor;
      case 1:
        //high priority
        return redStatusTextColor;
      case 82:
        //high priority
        return redStatusColor;
      default:
        return defaultStatusTextColor(context);
    }
  }

  static Color getPriorityStatusColor(BuildContext context, int id) {
    switch (id) {
      //low priority
      case 81:
        return greenStatusColor;
      case 370:
        return greenStatusColor;
      case 0:
        return greenStatusColor;
      //high priority
      case 82:
        return redStatusColor;
      case 1:
        return redStatusColor;
      default:
        return defaultStatusColor(context);
    }
  }

  static Color getEquipmentStatusColor(BuildContext context, int id) {
    switch (id) {
      case 368:
        //partially Down
        return greenStatusColor;
      case 369:
        // Completely Down
        return redStatusColor;
      case 790:
        //UP
        return blueStatusColor;
      default:
        return blueStatusColor;
    }
  }

  static Color getEquipmentStatusTextColor(BuildContext context, int id) {
    switch (id) {
      case 368:
      //partially Down
        return greenStatusTextColor;
      case 369:
      // Completely Down
        return redStatusTextColor;
      case 790:
      //UP
        return blueStatusTextColor;
      default:
        return blueStatusTextColor;
    }
  }
}
