Components
Avatar
A graphical representation of an object or entity
Status component contains a list of checks and completeness that has been tested and owned by each component
Usage
Avatar are used to defines graphical representation of a user or the user’s character or persona
Use Legion avatar styles to modify avatar with lots of attributes that make you easier
Default LegionUI, ThemeLGN, ThemeAGR, ThemeMyTEnS, ThemeIHS & ThemeEazy
LGNAvatarVariant()
Variant
Legion iOS Have 3 Variant of Avatar :
Avatar Image
A. Avatar Image Local
LGNAvatarImage(imageNamed: "SomeAssetName",).setBadgeOn(isOn: true)
B. Avatar Image System
LGNAvatarImage(systemName: "person.3.fill",).setBadgeOn(isOn: true)
C. Avatar Image Async
LGNAvatarImage(urlString: "https://i.ibb.co/1btpjhH/persegipanjangvertical.jpg",).setBadgeOn(isOn: true).setPlaceholder(isProgressViewOn: true)
Avatar Icon
A. Avatar Icon Local
LGNAvatarIcon(imageNamed: "SomeAssetName",).setBadgeOn(isOn: true)
B. Avatar Icon System
LGNAvatarIcon(systemName: "house").setBadgeOn(isOn: true)
C. Avatar Icon Async
LGNAvatarIcon(urlString: "https://i.ibb.co/yQPCHqz/houseicon.png",).setBadgeOn(isOn: true).setPlaceholder(isProgressViewOn: true)
Avatar Initial
Avatar Initial should add label: "value"
where value
consist the avatar initial
LGNAvatarInitials(label: "Telkom Indonesia",).setBadgeOn(isOn: true)
Attribute
Legion Have 3 Attributes for Costumize Avatar :
Size
This size attribute for user to choose the size of the avatar.
Size | Small | Medium | Large |
Choose type avatar LGNAvatarImage
, LGNAvatarIcon
or LGNAvatarInitial
, add sources imageNamed: "Link"
, systemName: "Link"
or urlString: "Link"
where Link
consist the value of the image. And add size: .sizeAvatar
where .sizeAvatar
consist .small
, .medium
or .large
This code sample demonstrates how to modify the size of the avatar :
A. Avatar Image Local Small
LGNAvatarImage(imageNamed: "SomeAssetName",size: .small).setBadgeOn(isOn: true)
B. Avatar Image System Small
LGNAvatarImage(systemName: "person.3.fill",size: .small).setBadgeOn(isOn: true)
C. Avatar Image Async Small
LGNAvatarImage(urlString: "https://i.ibb.co/1btpjhH/persegipanjangvertical.jpg",size: .smallsize: .small).setBadgeOn(isOn: true).setPlaceholder(isProgressViewOn: true)
D. Avatar Image Local Medium
LGNAvatarImage(imageNamed: "SomeAssetName",size: .medium).setBadgeOn(isOn: true)
E. Avatar Image System Medium
LGNAvatarImage(systemName: "person.3.fill",size: .medium).setBadgeOn(isOn: true)
F. Avatar Image Async Medium
LGNAvatarImage(urlString: "https://i.ibb.co/1btpjhH/persegipanjangvertical.jpg",size: .medium).setBadgeOn(isOn: true).setPlaceholder(isProgressViewOn: true)
G. Avatar Image Local Large
LGNAvatarImage(imageNamed: "SomeAssetName",size: .large).setBadgeOn(isOn: true)
H. Avatar Image System Large
LGNAvatarImage(systemName: "person.3.fill",size: .large).setBadgeOn(isOn: true)
I. Avatar Image Async Large
LGNAvatarImage(urlString: "https://i.ibb.co/1btpjhH/persegipanjangvertical.jpg",size: .large).setBadgeOn(isOn: true).setPlaceholder(isProgressViewOn: true)
J. Avatar Icon Local Small
LGNAvatarIcon(imageNamed: "SomeAssetName",size: .small).setBadgeOn(isOn: true)
K. Avatar Icon System Small
LGNAvatarIcon(systemName: "house",size: .small).setBadgeOn(isOn: true)
L. Avatar Icon Async Small
LGNAvatarIcon(urlString: "https://i.ibb.co/yQPCHqz/houseicon.png",size: .small).setBadgeOn(isOn: true).setPlaceholder(isProgressViewOn: true)
M. Avatar Icon Local Medium
LGNAvatarIcon(imageNamed: "SomeAssetName",size: .medium).setBadgeOn(isOn: true)
N. Avatar Icon System Medium
LGNAvatarIcon(systemName: "house",size: .medium).setBadgeOn(isOn: true)
O. Avatar Icon Async Medium
LGNAvatarIcon(urlString: "https://i.ibb.co/yQPCHqz/houseicon.png",size: .medium).setBadgeOn(isOn: true).setPlaceholder(isProgressViewOn: true)
P. Avatar Icon Local Large
LGNAvatarIcon(imageNamed: "SomeAssetName",size: .large).setBadgeOn(isOn: true)
Q. Avatar Icon System Large
LGNAvatarIcon(systemName: "house",size: .large).setBadgeOn(isOn: true)
R. Avatar Icon Async Large
LGNAvatarIcon(urlString: "https://i.ibb.co/yQPCHqz/houseicon.png",size: .large).setBadgeOn(isOn: true).setPlaceholder(isProgressViewOn: true)
S. Avatar Initial Small
LGNAvatarInitials(label: "Telkom Indonesia",size: .small).setBadgeOn(isOn: true)
T. Avatar Initial Medium
LGNAvatarInitials(label: "Telkom Indonesia",size: .medium).setBadgeOn(isOn: true)
U. Avatar Intial Large
Theme (ThemeAGR, ThemeMyTEnS, ThemeIHS & ThemeEazy)
LGNAvatarInitials(label: "Telkom Indonesia",size: .large).setBadgeOn(isOn: true)
Ratio
This avatar attribute for user to choose the ration image position inside the avatar.
Choose size of the avatar size: .sizeAvatar
where .sizeAvatar
consist .small
, .medium
or .large
and Use this function .aspectRatio(contentMode: .ratio)
where ratio
consist fit
or fill
if you add fit
must add the backgroundColor: .color
below size: .sizeAvatar
where color
is the color value
This code sample demonstrates how to modify the ratio of the avatar :
A. Small Fit
LGNAvatarImage(imageNamed: "SomeAssetName",size: .small,backgroundColor: .purple).setBadgeOn(isOn: true).aspectRatio(contentMode: .fit)
B. Small Fill
LGNAvatarImage(imageNamed: "SomeAssetName",size: .small).setBadgeOn(isOn: true).aspectRatio(contentMode: .fill)
C. Medium Fit
LGNAvatarImage(imageNamed: "SomeAssetName",size: .mediumbackgroundColor: .purple).setBadgeOn(isOn: true).aspectRatio(contentMode: .fit)
D. Medium Fill
LGNAvatarImage(imageNamed: "SomeAssetName",size: .medium).setBadgeOn(isOn: true).aspectRatio(contentMode: .fill)
E. Large Fit
LGNAvatarImage(imageNamed: "SomeAssetName",size: .largebackgroundColor: .purple).setBadgeOn(isOn: true).aspectRatio(contentMode: .fit)
F. Large Fill
LGNAvatarImage(imageNamed: "SomeAssetName",size: .large).setBadgeOn(isOn: true).aspectRatio(contentMode: .fill)
Show Progress
This label attribute to customize show progress async from url for avatar.
add sources imageNamed: "Link"
, systemName: "Link"
or urlString: "Link"
where Link
consist the value of the image. And add size: .sizeAvatar
where .sizeAvatar
consist .small
, .medium
or .large
finish it with .setPlaceholder(isProgressViewOn: true)
or .setPlaceholder(isProgressViewOn: false)
This code sample demonstrates how to modify the show progress of the async avatar :
A. Small Show Progress
LGNAvatarIcon(urlString: "https://i.ibb.co/yQPCHqz/houseicon.png",size: .small).setBadgeOn(isOn: true).setPlaceholder(isProgressViewOn: true)
B. Small Not Show Progress
Default LegionUI
LGNAvatarIcon(urlString: "https://i.ibb.co/yQPCHqz/houseicon.png",size: .small).setBadgeOn(isOn: true).setPlaceholder(isProgressViewOn: false)
C. Medium Show Progress
LGNAvatarIcon(urlString: "https://i.ibb.co/yQPCHqz/houseicon.png",size: .medium).setBadgeOn(isOn: true).setPlaceholder(isProgressViewOn: true)
D. Medium Not Show Progress
LGNAvatarIcon(urlString: "https://i.ibb.co/yQPCHqz/houseicon.png",size: .medium).setBadgeOn(isOn: true).setPlaceholder(isProgressViewOn: false)
E. Large Show Progress
LGNAvatarIcon(urlString: "https://i.ibb.co/yQPCHqz/houseicon.png",size: .large).setBadgeOn(isOn: true).setPlaceholder(isProgressViewOn: true)
F. Large Not Show Progress
LGNAvatarIcon(urlString: "https://i.ibb.co/yQPCHqz/houseicon.png",size: .large).setBadgeOn(isOn: true).setPlaceholder(isProgressViewOn: false)
Properties
LGNAvatarImage
Properties | Description | Default Value |
---|---|---|
imageNamed | The name of the local asset that you want to use. | required or no default value |
size | The size of the avatar, there are three size: .small , .medium , .large | required or no default value |
backgroundColor | The color of the avatar background. | Color.LGNTheme.tertiary100 |
systemName | The name of the system name from SF Symbols that you want to use. (https://developer.apple.com/design/resources/#sf-symbols) | required or no default value |
size | The size of the avatar, there are three size: .small , .medium , .large | required or no default value |
backgroundColor | The color of the avatar background. | Color.LGNTheme.tertiary100 |
urlString | The url asset that you want to use. We recommend you to use .jpg, .jpeg, and .png format. | required or no default value |
size | The size of the avatar, there are three size: .small , .medium , .large | required or no default value |
backgroundColor | The color of the avatar background. | Color.LGNTheme.tertiary100 |
LGNAvatarIcon
Properties | Description | Default Value |
---|---|---|
imageNamed | The name of the local asset that you want to use. | required or no default value |
size | The size of the avatar, there are three size: .small , .medium , .large | required or no default value |
iconColor | The color of the icon. | Color.white |
backgroundColor | The color of the avatar background. | Color.LGNTheme.tertiary500 |
systemName | The name of the system name from SF Symbols that you want to use. (https://developer.apple.com/design/resources/#sf-symbols ) | required or no default value |
size | The size of the avatar, there are three size: .small , .medium , .large | required or no default value |
iconColor | The color of the icon. | Color.white |
backgroundColor | The color of the avatar background. | Color.LGNTheme.tertiary500 |
urlString | The url asset that you want to use. We recommend you to use .jpg, .jpeg, and .png format. | required or no default value |
size | The size of the avatar, there are three size: .small , .medium , .large | required or no default value |
iconColor | The color of the icon. | Color.white |
backgroundColor | The color of the avatar background. | Color.LGNTheme.tertiary500 |
LGNAvatarInitials
Properties | Description | Default Value |
---|---|---|
label | The long text that you want to take the initials of to appear on the avatar. | required or no default value |
fontFamily | The font family for the label. | "" |
textColor | The color of the text string. | Color.white |
backgroundColor | The color of the avatar background. | Color.LGNTheme.primary500 |
Example Project
LGNAvatarIcon(urlString: "https://picsum.photos/100", size: .small, iconColor: .blue, backgroundColor: .red)LGNAvatarIcon(imageNamed: "foo", size: .small, backgroundColor: .gray)LGNAvatarIcon(systemName: "heart", size: .small, backgroundColor: .clear).setPlaceholder(isProgressViewOn: true, backgroundColor: .clear).setPlaceholder(systemName: "xmark", isProgressViewOn: true, backgroundColor: .clear).setPlaceholder(imageNamed: "asset-image", isProgressViewOn: true, backgroundColor: .clear).setPlaceholder(label: "loading..", isProgressViewOn: true, fontFamily: "", textColor: .white, backgroundColor: .clear).aspectRatio(contentMode: .fill).setBackgroundColor(color: .red)