@arpitbhalla/rneui-base-dev
Version:
Cross Platform React Native UI Toolkit
104 lines (103 loc) • 5.7 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.Tile = void 0;
var react_1 = __importDefault(require("react"));
var react_native_1 = require("react-native");
var Image_1 = require("../Image");
var Text_1 = require("../Text");
var Icon_1 = require("../Icon");
var FeaturedTile_1 = require("./components/FeaturedTile");
var helpers_1 = require("../helpers");
var color_1 = __importDefault(require("color"));
var Tile = function (_a) {
var _b;
var featured = _a.featured, imageSrc = _a.imageSrc, icon = _a.icon, title = _a.title, children = _a.children, caption = _a.caption, titleStyle = _a.titleStyle, onPress = _a.onPress, activeOpacity = _a.activeOpacity, overlayContainerStyle = _a.overlayContainerStyle, captionStyle = _a.captionStyle, iconContainerStyle = _a.iconContainerStyle, imageContainerStyle = _a.imageContainerStyle, containerStyle = _a.containerStyle, contentContainerStyle = _a.contentContainerStyle, titleNumberOfLines = _a.titleNumberOfLines, _c = _a.ImageComponent, ImageComponent = _c === void 0 ? Image_1.Image : _c, _d = _a.imageProps, imageProps = _d === void 0 ? {} : _d, _e = _a.width, width = _e === void 0 ? react_native_1.Dimensions.get('window').width : _e, _f = _a.height, height = _f === void 0 ? width * 0.8 : _f, _g = _a.theme, theme = _g === void 0 ? helpers_1.defaultTheme : _g, attributes = __rest(_a, ["featured", "imageSrc", "icon", "title", "children", "caption", "titleStyle", "onPress", "activeOpacity", "overlayContainerStyle", "captionStyle", "iconContainerStyle", "imageContainerStyle", "containerStyle", "contentContainerStyle", "titleNumberOfLines", "ImageComponent", "imageProps", "width", "height", "theme"]);
if (featured) {
var featuredProps = {
title: title,
icon: icon,
caption: caption,
imageSrc: imageSrc,
onPress: onPress,
activeOpacity: activeOpacity,
containerStyle: containerStyle,
imageContainerStyle: imageContainerStyle,
overlayContainerStyle: overlayContainerStyle,
titleStyle: titleStyle,
captionStyle: captionStyle,
width: width,
height: height,
imageProps: imageProps,
ImageComponent: ImageComponent,
};
return react_1.default.createElement(FeaturedTile_1.FeaturedTile, __assign({}, featuredProps));
}
return (react_1.default.createElement(react_native_1.Pressable, __assign({}, __assign({ onPress: onPress, android_ripple: (0, helpers_1.androidRipple)((0, color_1.default)((_b = theme === null || theme === void 0 ? void 0 : theme.colors) === null || _b === void 0 ? void 0 : _b.primary).alpha(activeOpacity).rgb().toString()) }, attributes), { style: react_native_1.StyleSheet.flatten([
{
width: width,
height: height,
},
containerStyle && containerStyle,
]) }),
react_1.default.createElement(ImageComponent, __assign({ resizeMode: "cover", source: imageSrc, containerStyle: react_native_1.StyleSheet.flatten([
styles.imageContainer,
imageContainerStyle && imageContainerStyle,
]), style: __assign(__assign({}, react_native_1.StyleSheet.absoluteFillObject), { alignItems: 'center', justifyContent: 'center' }) }, imageProps),
react_1.default.createElement(react_native_1.View, { style: react_native_1.StyleSheet.flatten([
styles.iconContainer,
iconContainerStyle && iconContainerStyle,
]) }, icon && react_1.default.createElement(Icon_1.Icon, __assign({}, icon)))),
react_1.default.createElement(react_native_1.View, { style: react_native_1.StyleSheet.flatten([
styles.contentContainer,
contentContainerStyle && contentContainerStyle,
]) },
react_1.default.createElement(Text_1.Text, { testID: "tileTitle", h4: !titleStyle || !('fontSize' in titleStyle), style: react_native_1.StyleSheet.flatten([styles.text, titleStyle && titleStyle]), numberOfLines: titleNumberOfLines }, title),
children)));
};
exports.Tile = Tile;
var styles = react_native_1.StyleSheet.create({
imageContainer: {
flex: 2,
},
text: {
backgroundColor: 'rgba(0,0,0,0)',
marginBottom: 5,
},
contentContainer: {
paddingTop: 15,
paddingBottom: 5,
paddingLeft: 15,
paddingRight: 15,
},
iconContainer: {
justifyContent: 'center',
alignItems: 'center',
alignSelf: 'center',
},
});
exports.Tile.displayName = 'Tile';