$UikJobBoxPropsFromJson function

UikJobBoxProps $UikJobBoxPropsFromJson(
  1. Map<String, dynamic> json
)

Implementation

UikJobBoxProps $UikJobBoxPropsFromJson(Map<String, dynamic> json) {
  final UikJobBoxProps uikJobBoxProps = UikJobBoxProps();

  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    uikJobBoxProps.id = id;
  }
  final String? wholeBgImage =
      jsonConvert.convert<String>(json['wholeBgImage']);
  if (wholeBgImage != null) {
    uikJobBoxProps.wholeBgImage = wholeBgImage;
  }
  final String? upperBgImage =
      jsonConvert.convert<String>(json['upperBgImage']);
  if (upperBgImage != null) {
    uikJobBoxProps.upperBgImage = upperBgImage;
  }
  final String? lowerBgImage =
      jsonConvert.convert<String>(json['lowerBgImage']);
  if (lowerBgImage != null) {
    uikJobBoxProps.lowerBgImage = lowerBgImage;
  }
  final double? elevation = jsonConvert.convert<double>(json['elevation']);
  if (elevation != null) {
    uikJobBoxProps.elevation = elevation;
  }
  final String? image = jsonConvert.convert<String>(json['image']);
  if (image != null) {
    uikJobBoxProps.image = image;
  }
  final String? cityName = jsonConvert.convert<String>(json['cityName']);
  if (cityName != null) {
    uikJobBoxProps.cityName = cityName;
  }
  final String? jobType = jsonConvert.convert<String>(json['jobType']);
  if (jobType != null) {
    uikJobBoxProps.jobType = jobType;
  }
  final Map<String, dynamic>? jobName =
      jsonConvert.convert<Map<String, dynamic>>(json['jobName']);
  if (jobName != null) {
    uikJobBoxProps.jobName = UikContainerText(
        WidgetType.UikText, UikContainerTextProps.fromJson(jobName));
  }
  final Map<String, dynamic>? companyText =
      jsonConvert.convert<Map<String, dynamic>>(json['companyText']);
  if (companyText != null) {
    uikJobBoxProps.companyNamefirstText = companyText["text"][0];
    uikJobBoxProps.companyText = UikContainerText(
        WidgetType.UikText, UikContainerTextProps.fromJson(companyText));
  }
  final Map<String, dynamic>? viewDetails =
      jsonConvert.convert<Map<String, dynamic>>(json['viewDetails']);
  if (viewDetails != null) {
    uikJobBoxProps.viewDetails = UikContainerText(
        WidgetType.UikText, UikContainerTextProps.fromJson(viewDetails));
  }
  final int? vacancy = jsonConvert.convert<int>(json['vacancy']);
  if (vacancy != null) {
    uikJobBoxProps.vacancy = vacancy;
  }
  final Map<String, dynamic>? salary =
      jsonConvert.convert<Map<String, dynamic>>(json['salary']);
  if (salary != null) {
    uikJobBoxProps.salary = UikContainerText(
        WidgetType.UikText, UikContainerTextProps.fromJson(salary));
  }
  final bool? isUrgentHiring =
      jsonConvert.convert<bool>(json['isUrgentHiring']);
  if (isUrgentHiring != null) {
    uikJobBoxProps.isUrgentHiring = isUrgentHiring;
  }

  final String? lowerColor = jsonConvert.convert<String>(json['lowerColor']);
  if (lowerColor != null) {
    uikJobBoxProps.lowerColor = lowerColor.toColor();
  }
  final String? upperBorderColor =
      jsonConvert.convert<String>(json['upperBorderColor']);
  if (upperBorderColor != null) {
    uikJobBoxProps.upperBorderColor = upperBorderColor.toColor();
  }

  List<Color> mapToListSortedByKey(Map<String, dynamic> map) {
    List<String> sortedKeys = map.keys.toList()..sort();

    List<Color> sortedList = sortedKeys
        .map((key) => map[key].toString().toColor())
        .where((color) => color != null)
        .toList();
    // if(sortedList.isEmpty){
    //   return  [Colors.yellow.shade400, Colors.yellow.shade100];
    // }

    return sortedList;
  }

  final String? gradient = jsonConvert.convert<String>(json['gradient']);
  if (gradient != null) {
    final List<dynamic> jsons = json["gradient"];
    //   List<Color> sortedList = mapToListSortedByKey(jsons);
    List<Color> list = [];
    for (var i = 0; i < jsons.length; i++) {
      list.add(jsons[i].toString().toColor());
    }
    uikJobBoxProps.gradient = list;
  }
  final List<dynamic>? tag = jsonConvert.convert<List<dynamic>>(json["tag"]);
  if (tag != null) {
    for (var i = 0; i < tag.length; i++) {
      var icons;
      var texts;
      var bgColors;
      var textColors;
      final Map<String, dynamic>? icon =
          jsonConvert.convert<Map<String, dynamic>>(tag[i]['icon']);
      if (icon != null) {
        icons = UikIcon(WidgetType.UikText, UikIconProps.fromJson(icon));
      }
      final Map<String, dynamic>? text =
          jsonConvert.convert<Map<String, dynamic>>(tag[i]['text']);
      if (text != null) {
        texts = UikText(WidgetType.UikText, UikTextProps.fromJson(text));
        // final String? id = jsonConvert.convert<String>(tag[i]['id']);
        // if (id != null) {
        //   texts = "$text $id";
        // } else {
        //   texts = text;
        // }
      }

      final String? bgColor = jsonConvert.convert<String>(tag[i]['bgColor']);
      if (bgColor != null) {
        bgColors = bgColor.toColor();
      }
      uikJobBoxProps.tag.add(TagProps(
        icon: icons,
        text: texts,
        bgColor: bgColors ?? Colors.black,
      ));
    }
  }

  final UikAction? action = jsonConvert.convert<UikAction>(json['action']);
  if (action != null) {
    uikJobBoxProps.action = action;
  }
  return uikJobBoxProps;
}