$UikScrollCarouselPropsFromJson function

UikScrollCarouselProps $UikScrollCarouselPropsFromJson(
  1. Map<String, dynamic> json
)

Implementation

UikScrollCarouselProps $UikScrollCarouselPropsFromJson(
    Map<String, dynamic> json) {
  final UikScrollCarouselProps uikScrollCarouselProps =
      UikScrollCarouselProps();

  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    uikScrollCarouselProps.id = id;
  }

  final double? height = jsonConvert.convert<double>(json['height']);
  if (height != null) {
    uikScrollCarouselProps.height = height;
  }
  final double? topMargin = jsonConvert.convert<double>(json['topMargin']);
  if (topMargin != null) {
    uikScrollCarouselProps.topMargin = topMargin;
  }
  final double? bottomMargin =
      jsonConvert.convert<double>(json['bottomMargin']);
  if (bottomMargin != null) {
    uikScrollCarouselProps.bottomMargin = bottomMargin;
  }
  final double? leftMargin = jsonConvert.convert<double>(json['leftMargin']);
  if (leftMargin != null) {
    uikScrollCarouselProps.leftMargin = leftMargin;
  }
  final double? rightMargin = jsonConvert.convert<double>(json['rightMargin']);
  if (rightMargin != null) {
    uikScrollCarouselProps.rightMargin = rightMargin;
  }
  final double? viewPort = jsonConvert.convert<double>(json['viewPort']);
  if (viewPort != null) {
    uikScrollCarouselProps.viewPort = viewPort;
  }
  final bool? autoscrollEnabled =
      jsonConvert.convert<bool>(json['autoScrollEnabled']);
  if (autoscrollEnabled != null) {
    uikScrollCarouselProps.autoScrollEnabled = autoscrollEnabled;
  }
  final bool? swipeEnabled = jsonConvert.convert<bool>(json['swipeEnabled']);
  if (swipeEnabled != null) {
    uikScrollCarouselProps.swipeEnabled = swipeEnabled;
  }
  final bool? buttonEnabled = jsonConvert.convert<bool>(json['buttonEnabled']);
  if (buttonEnabled != null) {
    uikScrollCarouselProps.buttonEnabled = buttonEnabled;
  }
  final bool? enlargeCenter = jsonConvert.convert<bool>(json['enlargeCenter']);
  if (enlargeCenter != null) {
    uikScrollCarouselProps.enlargeCenter = enlargeCenter;
  }
  final bool? disableCenter = jsonConvert.convert<bool>(json['disableCenter']);
  if (disableCenter != null) {
    uikScrollCarouselProps.disableCenter = disableCenter;
  }
  final bool? pageSnapping = jsonConvert.convert<bool>(json['pageSnapping']);
  if (pageSnapping != null) {
    uikScrollCarouselProps.pageSnapping = pageSnapping;
  }
  final bool? infinteScroll = jsonConvert.convert<bool>(json['infiniteScroll']);
  if (infinteScroll != null) {
    uikScrollCarouselProps.infiniteScroll = infinteScroll;
  }
  final int? autoPlayInterval =
      jsonConvert.convert<int>(json['autoPlayInterval']);
  if (autoPlayInterval != null) {
    uikScrollCarouselProps.autoPlayInterval = autoPlayInterval;
  }
  final String? scrollAxis = jsonConvert.convert<String>(json['scrollAxis']);
  if (scrollAxis != null) {
    if (scrollAxis == "Axis.vertical") {
      uikScrollCarouselProps.scrollAxis = Axis.vertical;
    }
    if (scrollAxis == "Axis.horizontal") {
      uikScrollCarouselProps.scrollAxis = Axis.horizontal;
    }
  }

  final String? buttonAlign = jsonConvert.convert<String>(json['buttonAlign']);
  if (buttonAlign != null) {
    if (buttonAlign == "end") {
      uikScrollCarouselProps.buttonAlign = MainAxisAlignment.end;
    }
    if (buttonAlign == "spaceAround") {
      uikScrollCarouselProps.buttonAlign = MainAxisAlignment.spaceAround;
    }
    if (buttonAlign == "spaceBetween") {
      uikScrollCarouselProps.buttonAlign = MainAxisAlignment.spaceBetween;
    }
    if (buttonAlign == "spaceEvenly") {
      uikScrollCarouselProps.buttonAlign = MainAxisAlignment.spaceEvenly;
    }
    if (buttonAlign == "start") {
      uikScrollCarouselProps.buttonAlign = MainAxisAlignment.start;
    }
    if (buttonAlign == "center") {
      uikScrollCarouselProps.buttonAlign = MainAxisAlignment.center;
    }
  }

  final Map<String, dynamic>? icons =
      jsonConvert.convert<Map<String, dynamic>>(json['icons']);
  if (buttonEnabled != null && icons != null) {
    if (buttonEnabled) {
      final double? prevIconSize =
          jsonConvert.convert<double>(icons['prevIconSize']);
      if (prevIconSize != null) {
        uikScrollCarouselProps.prevIconSize = prevIconSize;
      }
      final double? nextIconSize =
          jsonConvert.convert<double>(icons['nextIconSize']);
      if (nextIconSize != null) {
        uikScrollCarouselProps.nextIconSize = nextIconSize;
      }
      final String? nextIconColor =
          jsonConvert.convert<String>(icons['nextIconColor']);
      if (nextIconColor != null) {
        uikScrollCarouselProps.nextIconColor = nextIconColor.toColor();
      }
      final String? prevIconColor =
          jsonConvert.convert<String>(icons['prevIconColor']);
      if (prevIconColor != null) {
        uikScrollCarouselProps.prevIconColor = prevIconColor.toColor();
      }
      final String? nextIconbgColor =
          jsonConvert.convert<String>(icons['nextIconbgColor']);
      if (nextIconbgColor != null) {
        uikScrollCarouselProps.nextIconbgColor = nextIconbgColor.toColor();
      }
      final String? prevIconbgColor =
          jsonConvert.convert<String>(icons['prevIconbgColor']);
      if (prevIconbgColor != null) {
        uikScrollCarouselProps.prevIconbgColor = prevIconbgColor.toColor();
      }
      final double? prevIconBorderRadius =
          jsonConvert.convert<double>(icons['prevIconBorderRadius']);
      if (prevIconBorderRadius != null) {
        uikScrollCarouselProps.prevIconBorderRadius = prevIconBorderRadius;
      }
      final double? nextIconBorderRadius =
          jsonConvert.convert<double>(icons['nextIconBorderRadius']);
      if (nextIconBorderRadius != null) {
        uikScrollCarouselProps.nextIconBorderRadius = nextIconBorderRadius;
      }
    }
  }

  final List<dynamic>? widgets =
      jsonConvert.convert<List<dynamic>>(json['widgets']);
  // final String? type = jsonConvert.convert<String>(json['type']);
  // print("laveshlaveshlavesh  ${type}");
  if (widgets != null) {
    for (int i = 0; i < widgets.length; i++) {
      final String? type = jsonConvert.convert<String>(widgets[i]["id"]);
      if (type == "image") {
        uikScrollCarouselProps.widgets.add(
            UikImage(WidgetType.UikText, UikImageProps.fromJson(widgets[i])));
      } else if (type == "productcard") {
        uikScrollCarouselProps.widgets.add(UikHomeCardEleven(
            WidgetType.UikText, UikHomeCardElevenProps.fromJson(widgets[i])));
      } else if (type == "lokalAcademy") {
        uikScrollCarouselProps.widgets.add(UikLokalAcademyCard(
            WidgetType.UikLokalAcademyCard,
            UikLokalAcademyCardProps.fromJson(widgets[i])));
      } else if (type == "twoRow") {
        uikScrollCarouselProps.widgets.add(UikTwoComponentRow(
            WidgetType.UikText, UikTwoComponentRowProps.fromJson(widgets[i])));
      } else if (type == "threetextcolumn") {
        uikScrollCarouselProps.widgets.add(UikThreeTextCard(
            WidgetType.UikText, UikThreeTextCardProps.fromJson(widgets[i])));
      } else if (type == "card") {
        uikScrollCarouselProps.widgets.add(
            UikCard(WidgetType.UikText, UikCardProps.fromJson(widgets[i])));
      } else if (type == "container") {
        uikScrollCarouselProps.widgets.add(UikContainer(
            WidgetType.UikText, UikContainerProps.fromJson(widgets[i])));
      } else {
        uikScrollCarouselProps.widgets.add(
            UikImage(WidgetType.UikText, UikImageProps.fromJson(widgets[i])));
      }
    }
  }
  return uikScrollCarouselProps;
}