import 'package:flutter/material.dart';
import 'package:json_annotation/json_annotation.dart';

@JsonSerializable()
class CustomThemeColor {
  final String color1; //
  final String color2;
  final String color3;
  final String color4;
  final String color5;
  final String color6;
  final String color7;
  final String color8;
  final String color9;
  final String color10;
  final String color11;
  final String color12;
  final String color13;
  final String color14;
  final String color15;
  final String color16;
  final String color17;
  final String color18;
  final String color19;
  final String color20;
  final String color21;
  final String color22;
  final String color25;
  final String color26;
  final String color27;
  final String color28;
  final String color29;
  final String color30;
  final String color31;
  final String color32;
  final String color33;
  final String color34;

  final String color38;
  final String color39;
  final String color40;

  CustomThemeColor({
    required this.color1,
    required this.color2,
    required this.color3,
    required this.color4,
    required this.color5,
    required this.color6,
    required this.color7,
    required this.color8,
    required this.color9,
    required this.color10,
    required this.color11,
    required this.color12,
    required this.color13,
    required this.color14,
    required this.color15,
    required this.color16,
    required this.color17,
    required this.color18,
    required this.color19,
    required this.color20,
    required this.color21,
    required this.color22,
    required this.color25,
    required this.color26,
    required this.color27,
    required this.color28,
    required this.color29,
    required this.color30,
    required this.color31,
    required this.color32,
    required this.color33,
    required this.color34,
    required this.color38,
    required this.color39,
    required this.color40,
  });

  //浅色模式
  static final light = CustomThemeColor(
      color1: '#45D989',
      color2: "#00C1AA",
      color3: "#333333",
      color4: "#D3D3D3",
      color6: "#FBF5D5",
      color5: "#FFFFFF006",
      color7: "#00C1AA",
      color8: "#FF9F66",
      color9: "#FF7159",
      color10: "#E60012",
      color11: "#00C1AA",
      color12: "#10CFF1",
      color13: "#FF9F66",
      color14: "#FF7159",
      color15: "#F6F6F6",
      color16: "#333333",
      color17: "#FFFFFF",
      color18: "#FFFFFF",
      color19: "#FFFFFF",
      color20: "#f7f8fa",
      color21: "#eaeaea",
      color22: "#eaeaea",
      color25: "#FF7159",
      color26: "#4AD8FA",
      color27: "#f7f8fa",
      color28: "#4E8408",
      color29: "#79BC31",
      color30: "#E55E92",
      color31: "#FF1D25",
      color32: "#7bbb33",
      color33: "#fe15b8d",
      color34: "#EE0000",
      color38: "#E3E4E5",
      color39: "#F3F5F6",
      color40: "#333333");
  //深色模式
  static final dark = CustomThemeColor(
      color1: '#45D989',
      color2: "#00C1AA",
      color3: "#FFFFFF",
      color4: "#999999",
      color5: "#FFFFFF06",
      color6: "#FBF5D5",
      color7: "#00C1AA",
      color8: "#FF9F66",
      color9: "#FF7159",
      color10: "#E60012",
      color11: "#00C1AA",
      color12: "#10CFF1",
      color13: "#FF9F66",
      color14: "#FF7159",
      color15: "#161B28",
      color16: "#FFFFFF",
      color17: "#242835",
      color18: "#EAEAEA",
      color19: "#FFFFFF",
      color20: "#f7f8fa",
      color21: "#333844",
      color22: "#333844",
      color25: "#FF7159",
      color26: "#4AD8FA",
      color27: "#f7f8fa",
      color28: "#4E8408",
      color29: "#79BC31",
      color30: "#E55E92",
      color31: "#FF1D25",
      color32: "#7bbb33",
      color33: "#fe15b8d",
      color34: "#EE0000",
      color38: "#E3E4E5",
      color39: "#F3F5F6",
      color40: "#333333");

  //获取颜色1 菜单栏颜色
  Color get sc1 => getColor(color1);
  //获取颜色2
  Color get sc2 => getColor(color2);
  //获取颜色3
  Color get sc3 => getColor(color3);
  //获取颜色4
  Color get sc4 => getColor(color4);
  //获取颜色5
  Color get sc5 => getColor(color5);
  //获取颜色6
  Color get sc6 => getColor(color6);
  //获取颜色7
  Color get sc7 => getColor(color7);
  //获取颜色8
  Color get sc8 => getColor(color8);
  //获取颜色9
  Color get sc9 => getColor(color9);
  //获取颜色10
  Color get sc10 => getColor(color10);
  Color get sc11 => getColor(color11);
  Color get sc12 => getColor(color12);
  Color get sc13 => getColor(color13);
  Color get sc14 => getColor(color14);
  Color get sc15 => getColor(color15);
  Color get sc16 => getColor(color16);
  Color get sc17 => getColor(color17);
  Color get sc18 => getColor(color18);
  Color get sc19 => getColor(color19);
  Color get sc20 => getColor(color20);
  Color get sc21 => getColor(color21);
  Color get sc22 => getColor(color22);
  Color get sc25 => getColor(color25);
  Color get sc26 => getColor(color26);
  Color get sc27 => getColor(color27);
  Color get sc28 => getColor(color28);
  Color get sc29 => getColor(color29);
  Color get sc30 => getColor(color30);
  Color get sc31 => getColor(color31);
  Color get sc32 => getColor(color32);
  Color get sc33 => getColor(color33);
  Color get sc34 => getColor(color34);
  Color get sc38 => getColor(color38);
  Color get sc39 => getColor(color39);
  Color get sc40 => getColor(color40);

  Color getColor(String color) {
    color = color.replaceAll("#", "");

    if (color.length == 6) {
      color = "0xFF$color";
    } else if (color.length == 8) {
      String alphaHex = color.substring(6, 8);
      String rgbHex = color.substring(0, 6);

      int alphaInt = int.parse(alphaHex);
      double alpha = alphaInt / 100.0;

      return Color(int.parse("0xFF$rgbHex")).withOpacity(alpha);
    } else {
      color = "0x$color";
    }

    return Color(int.parse(color));
  }

  //序列化反序列化
  factory CustomThemeColor.fromJson(Map<String, dynamic> json) =>
      CustomThemeColor(
          color1: json['color1'],
          color2: json['color2'],
          color3: json['color3'],
          color4: json['color4'],
          color5: json['color5'],
          color6: json['color6'],
          color7: json['color7'],
          color8: json['color8'],
          color9: json['color9'],
          color10: json['color10'],
          color11: json['color11'],
          color12: json['color12'],
          color13: json['color13'],
          color14: json['color14'],
          color15: json['color15'],
          color16: json['color16'],
          color17: json['color17'],
          color18: json['color18'],
          color19: json['color19'],
          color20: json['color20'],
          color21: json['color21'],
          color22: json['color22'],
          color25: json['color25'],
          color26: json['color26'],
          color27: json['color27'],
          color28: json['color28'],
          color29: json['color29'],
          color30: json['color30'],
          color31: json['color31'],
          color32: json['color32'],
          color33: json['color33'],
          color34: json['color34'],
          color38: json['color38'],
          color39: json['color39'],
          color40: json['color40']);

  Map<String, dynamic> toJson() => {
        'color1': color1,
        'color2': color2,
        'color3': color3,
        'color4': color4,
        'color5': color5,
        'color6': color6,
        'color7': color7,
        'color8': color8,
        'color9': color9,
        'color10': color10,
        'color11': color11,
        'color12': color12,
        'color13': color13,
        'color14': color14,
        'color15': color15,
        'color16': color16,
        'color17': color17,
        'color18': color18,
        'color19': color19,
        'color20': color20,
        'color21': color21,
        'color22': color22,
        'color25': color25,
        'color26': color26,
        'color27': color27,
        'color28': color28,
        'color29': color29,
        'color30': color30,
        'color31': color31,
        'color32': color32,
        'color33': color33,
        'color34': color34,
        'color38': color38,
        'color39': color39,
        'color40': color40,
      };
}
