getImageXMLElement function

XmlElement getImageXMLElement({
  1. String? elementId,
  2. String? imageName,
  3. String? contentMode,
})

Implementation

XmlElement getImageXMLElement({
  String? elementId,
  String? imageName,
  String? contentMode,
}) {
  return XmlElement(
    /// Adds image element to storyboard.
    XmlName(IOSStrings.imageViewElement),
    [
      XmlAttribute(
        XmlName(IOSStrings.opaque),
        IOSStrings.opaqueValue,
      ),
      XmlAttribute(
        XmlName(IOSStrings.clipsSubviews),
        IOSStrings.clipsSubviewsValue,
      ),
      XmlAttribute(
        XmlName(IOSStrings.multipleTouchEnabled),
        IOSStrings.multipleTouchEnabledValue,
      ),
      XmlAttribute(
        XmlName(IOSStrings.contentMode),
        IosContentMode.fromString(contentMode ?? IOSStrings.contentModeValue)
            .mode,
      ),
      XmlAttribute(
        XmlName(IOSStrings.image),
        imageName ?? IOSStrings.imageValue,
      ),
      XmlAttribute(
        XmlName(IOSStrings.translatesAutoresizingMaskIntoConstraints),
        IOSStrings.translatesAutoresizingMaskIntoConstraintsVal,
      ),
      XmlAttribute(
        XmlName(IOSStrings.defaultImageViewId),
        elementId ?? IOSStrings.defaultImageViewIdValue,
      ),
    ],
    [
      /// Adds rect element for imageView in storyboard.
      XmlElement(
        XmlName(IOSStrings.rectElement),
        [
          XmlAttribute(
            XmlName(IOSStrings.rectElementKeyAttr),
            IOSStrings.rectElementKeyAttrValue,
          ),
          XmlAttribute(
            XmlName(IOSStrings.rectElementXAttr),
            IOSStrings.rectElementXAttrVal,
          ),
          XmlAttribute(
            XmlName(IOSStrings.rectElementYAttr),
            IOSStrings.rectElementYAttrVal,
          ),
          XmlAttribute(
            XmlName(IOSStrings.rectElementWidthAttr),
            IOSStrings.rectElementWidthAttrVal,
          ),
          XmlAttribute(
            XmlName(IOSStrings.rectElementHeightAttr),
            IOSStrings.rectElementHeightAttrVal,
          ),
        ],
      ),
    ],
  );
}