@arpitbhalla/rneui-base-dev
Version:
Cross Platform React Native UI Toolkit
157 lines (156 loc) • 7.14 kB
JavaScript
"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SocialIcon = void 0;
var react_1 = __importDefault(require("react"));
var react_native_1 = require("react-native");
var Icon_1 = require("../Icon");
var Text_1 = require("../Text");
var fonts_1 = __importDefault(require("../helpers/fonts"));
var helpers_1 = require("../helpers");
var colors = {
'github-alt': '#000000',
'google-plus-official': '#dd4b39',
google: '#dd4b39',
'reddit-alien': '#fc461e',
'stack-overflow': '#f27f33',
angellist: '#1c4082',
codepen: '#000000',
envelope: '#000000',
etsy: '#f2581e',
facebook: '#4267B2',
'facebook-messenger': '#0084ff',
flickr: '#ff0084',
foursquare: '#0072b1',
github: '#000000',
gitlab: '#e14329',
instagram: '#517fa4',
linkedin: '#007bb6',
medium: '#02b875',
pinterest: '#cb2027',
quora: '#a82400',
soundcloud: '#f50',
steam: '#c6c3c1',
stumbleupon: '#EB4823',
tumblr: '#32506d',
twitch: '#6441A5',
twitter: '#00aced',
vimeo: '#aad450',
vk: '#5181b8',
wechat: '#7bb32e',
weibo: '#e6162d',
whatsapp: '#075e54',
wordpress: '#21759b',
youtube: '#bb0000',
microsoft: '#46A4F2',
reddit: '#ed452f',
};
var SocialIcon = function (_a) {
var activityIndicatorStyle = _a.activityIndicatorStyle, _b = _a.button, button = _b === void 0 ? false : _b, disabled = _a.disabled, fontFamily = _a.fontFamily, fontStyle = _a.fontStyle, fontWeight = _a.fontWeight, _c = _a.iconType, iconType = _c === void 0 ? 'font-awesome' : _c, _d = _a.iconColor, iconColor = _d === void 0 ? 'white' : _d, _e = _a.iconSize, iconSize = _e === void 0 ? 24 : _e, iconStyle = _a.iconStyle, light = _a.light, loading = _a.loading, onLongPress = _a.onLongPress, onPress = _a.onPress, onPressOut = _a.onPressOut, onPressIn = _a.onPressIn, _f = _a.Component, Component = _f === void 0 ? onPress || onLongPress || onPressIn || onPressOut
? react_native_1.Pressable
: react_native_1.View : _f, _g = _a.raised, raised = _g === void 0 ? true : _g, small = _a.small, style = _a.style, title = _a.title, type = _a.type, underlayColor = _a.underlayColor, pressableProps = _a.pressableProps, attributes = __rest(_a, ["activityIndicatorStyle", "button", "disabled", "fontFamily", "fontStyle", "fontWeight", "iconType", "iconColor", "iconSize", "iconStyle", "light", "loading", "onLongPress", "onPress", "onPressOut", "onPressIn", "Component", "raised", "small", "style", "title", "type", "underlayColor", "pressableProps"]);
var shouldShowExpandedButton = button && title;
return (react_1.default.createElement(Component, __assign({}, __assign(__assign({ onLongPress: onLongPress, onPress: onPress, onPressOut: onPressOut, onPressIn: onPressIn, android_ripple: (0, helpers_1.androidRipple)(light ? 'white' : underlayColor || (type && colors[type])) }, pressableProps), attributes), { testID: "RNE_SocialIcon", underlayColor: light ? 'white' : underlayColor || (type && colors[type]), disabled: disabled, style: react_native_1.StyleSheet.flatten([
raised && styles.raised,
styles.container,
button && styles.button,
!button && raised && styles.icon,
!button &&
!light &&
!raised && {
width: iconSize * 2 + 4,
height: iconSize * 2 + 4,
borderRadius: iconSize * 2,
},
{ backgroundColor: type && colors[type] },
{
width: iconSize * 2 + 4,
height: iconSize * 2 + 4,
borderRadius: iconSize * 2,
},
light && { backgroundColor: 'white' },
style && style,
]) }),
react_1.default.createElement(react_native_1.View, { style: styles.wrapper },
(shouldShowExpandedButton || !loading) && (react_1.default.createElement(Icon_1.Icon, { testID: "RNE_Icon", iconStyle: react_native_1.StyleSheet.flatten([iconStyle && iconStyle]), color: light ? type && colors[type] : iconColor, name: type, size: iconSize, type: iconType })),
shouldShowExpandedButton && (react_1.default.createElement(Text_1.Text, { style: react_native_1.StyleSheet.flatten([
styles.title,
light && { color: type && colors[type] },
fontFamily && { fontFamily: fontFamily },
fontWeight && { fontWeight: fontWeight },
fontStyle && fontStyle,
]) }, title)),
loading && (react_1.default.createElement(react_native_1.ActivityIndicator, { testID: "RNE_ActivityIndicator", animating: true, style: react_native_1.StyleSheet.flatten([
styles.activityIndicatorStyle,
activityIndicatorStyle,
]), color: light ? type && colors[type] : iconColor || 'white', size: (small && 'small') || 'large' })))));
};
exports.SocialIcon = SocialIcon;
var styles = react_native_1.StyleSheet.create({
container: {
margin: 7,
borderRadius: 30,
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
},
button: {
paddingTop: 14,
paddingBottom: 14,
},
raised: __assign({}, react_native_1.Platform.select({
android: {
elevation: 2,
},
default: {
shadowColor: 'rgba(0,0,0, .4)',
shadowOffset: { height: 1, width: 1 },
shadowOpacity: 1,
shadowRadius: 1,
},
})),
wrapper: {
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
},
title: __assign({ color: 'white', marginLeft: 15 }, react_native_1.Platform.select({
android: __assign({}, fonts_1.default.android.black),
default: {
fontWeight: 'bold',
},
})),
icon: {
height: 52,
width: 52,
},
activityIndicatorStyle: {
marginHorizontal: 10,
height: 0,
},
});
exports.SocialIcon.displayName = 'SocialIcon';