NatAvatar

public final class NatAvatar : UIView

NatAvatar is a class that represents a component from the Design System. The avatar colors change according to the current brand configured in the Design System.

It has 3 styles:

  • Icon
  • Label
  • Image

And 5 sizes:

  • standard
  • semi
  • semiX
  • medium
  • largeXXX

The default size is standard and the default type is Icon. The component’s size is not changeable. It’s type can change according to the configuration methods called after its initialization.

Example of usage:

// using default configuration:
let avatar = NatAvatar()
// or:
let avatar = NatAvatar(size: .medium, style: .image)

Requires

It’s necessary to configure the Design System with a theme or fatalError will be raised.

DesignSystem().configure(with: AvailableTheme)

Inits

Deinit

  • Undocumented

    Declaration

    Swift

    public override func layoutSubviews()
  • Size is a enum that represents size values for NatAvatar component.

    These are all sizes allowed for a NatAvatar:

    • standard
    • semi
    • semiX
    • medium
    • largeXXX

    Requires

    It’s necessary to configure the Design System with a theme or fatalError will be raised.

    DesignSystem().configure(with: AvailableTheme)

    See more

    Declaration

    Swift

    public enum Size : CaseIterable
  • Style is a enum that represents style values for NatAvatar component.

    These are the allowed styles for a NatAvatar:

    • icon
    • label
    • image

      Requires

      It’s necessary to configure the Design System with a theme or fatalError will be raised.

      DesignSystem().configure(with: AvailableTheme)

    See more

    Declaration

    Swift

    public enum Types : CaseIterable

Public methods

  • Sets the label text for NatAvatar with label type

    Declaration

    Swift

    public func configure(name: String)

    Parameters

    name

    a string with the full name for the avatar or the initials with 2 characters. If the name has more than 2 words, the initials will be the first letter from the first and last names

  • Sets an image for NatAvatar with image type

    Declaration

    Swift

    public func configure(image: UIImage?)

    Parameters

    image

    an UIImage with the image to be displayed. If image is nil, the component will show the default icon

  • Sets a remote image for NatAvatar with image type

    Declaration

    Swift

    public func configure(imageURL: URL?)

    Parameters

    imageURL

    a URL containing an image

  • Configures an icon as a fallback. It will appear if the configuration with the remote image fails.

    Declaration

    Swift

    public func configure(setFallbackIcon: String?)

    Parameters

    setFallbackIcon

    An icon from NatDSIcons, which is sent as a string. Example: getIcon(.outlinedDefaultMockup)

  • Sets an icon for NatAvatar with icon type

    Declaration

    Swift

    public func configure(icon: String?)

    Parameters

    icon

    An icon from NatDSIcons, which is sent as a string. Example: getIcon(.outlinedDefaultMockup)

  • Sets the default icon outlinedDefaultMock for NatAvatar.

    Declaration

    Swift

    public func configureWithDefaultIcon()