{
+ static defaultProps = {
+ initials: '',
+ size: 50,
+ };
+
+ renderTouchableAvatar = () => {
+ const styles = getStyles(this.props.size);
+ return (
+
+ {this.renderAvatar()}
+
+ );
+ };
+
+ renderAvatar = () => {
+ const { url, style, initials, size } = this.props;
+ const styles = getStyles(size);
+
+ if (url) {
+ return ;
+ }
+ const overlay = require('../assets/avatartGradient.png');
+ return (
+
+
+ {initials.slice(0, 2)}
+
+
+ );
+ };
+
+ render() {
+ const { onPress } = this.props;
+ if (onPress) return this.renderTouchableAvatar();
+ return this.renderAvatar();
+ }
+}
+
+export default withTheme(Avatar);
+
+const getStyles = (avatarSize: number) =>
+ StyleSheet.create({
+ letterWrapper: {
+ height: avatarSize,
+ width: avatarSize,
+ borderRadius: avatarSize / 2,
+ justifyContent: 'center',
+ backgroundColor: 'transparent',
+ },
+ letters: {
+ fontSize: avatarSize / 2.4,
+ fontFamily: 'ArialRoundedMTBold',
+ textAlign: 'center',
+ backgroundColor: 'transparent',
+ color: 'white',
+ },
+ avatar: {
+ width: avatarSize,
+ height: avatarSize,
+ borderRadius: avatarSize / 2,
+ },
+ });
diff --git a/src/index.js b/src/index.js
index d860c63b..ecef7a36 100644
--- a/src/index.js
+++ b/src/index.js
@@ -5,6 +5,7 @@ export { default as ThemeProvider } from './core/ThemeProvider';
export { default as DefaultTheme } from './styles/DefaultTheme';
export { default as DarkTheme } from './styles/DarkTheme';
+export { default as Avatar } from './components/Avatar';
export { default as Button } from './components/Button';
export { default as CheckboxRow } from './components/CheckboxRow';
export { default as Icon } from './components/Icon';
diff --git a/website/core/Footer.js b/website/core/Footer.js
index d33ba659..e030f194 100644
--- a/website/core/Footer.js
+++ b/website/core/Footer.js
@@ -49,7 +49,7 @@ class Footer extends React.Component {
Community
diff --git a/website/i18n/en.json b/website/i18n/en.json
index 75e3ddb0..9f874c59 100644
--- a/website/i18n/en.json
+++ b/website/i18n/en.json
@@ -4,6 +4,7 @@
"next": "Next",
"previous": "Previous",
"tagline": "The missing React Native UI Kit for iOS.",
+ "avatar": "Avatar",
"button": "Button",
"checkbox-row": "CheckboxRow",
"customization": "Customization",
diff --git a/website/sidebars.json b/website/sidebars.json
index 53129d21..16b56c80 100644
--- a/website/sidebars.json
+++ b/website/sidebars.json
@@ -2,6 +2,7 @@
"docs": {
"Getting Started": ["installation", "usage", "customization", "theme"],
"API": [
+ "avatar",
"button",
"checkbox-row",
"icon",
diff --git a/website/siteConfig.js b/website/siteConfig.js
index 52cf4e9e..db0a3be9 100644
--- a/website/siteConfig.js
+++ b/website/siteConfig.js
@@ -8,7 +8,7 @@ const siteConfig = {
baseUrl: '/react-native-ios-kit/',
headerLinks: [
{ doc: 'installation', label: 'Docs' },
- { doc: 'button', label: 'API' },
+ { doc: 'avatar', label: 'API' },
{ page: 'help', label: 'Help' },
],
users,