UNPKG

@arpitbhalla/rneui-base-dev

Version:
130 lines (129 loc) 5 kB
"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.FAB = void 0; var react_1 = __importDefault(require("react")); var react_native_1 = require("react-native"); var Button_1 = require("../Button"); var helpers_1 = require("../helpers"); var FAB = function (_a) { var _b; var _c, _d; var color = _a.color, _e = _a.size, size = _e === void 0 ? 'large' : _e, _f = _a.visible, visible = _f === void 0 ? true : _f, disabled = _a.disabled, upperCase = _a.upperCase, _g = _a.theme, theme = _g === void 0 ? helpers_1.defaultTheme : _g, style = _a.style, titleStyle = _a.titleStyle, buttonStyle = _a.buttonStyle, containerStyle = _a.containerStyle, iconContainerStyle = _a.iconContainerStyle, placement = _a.placement, rest = __rest(_a, ["color", "size", "visible", "disabled", "upperCase", "theme", "style", "titleStyle", "buttonStyle", "containerStyle", "iconContainerStyle", "placement"]); var animation = react_1.default.useRef(new react_native_1.Animated.Value(Number(visible))).current; react_1.default.useEffect(function () { react_native_1.Animated.timing(animation, { toValue: Number(visible), duration: 200, useNativeDriver: true, }).start(); }, [animation, visible]); return (react_1.default.createElement(react_native_1.Animated.View, { style: react_native_1.StyleSheet.flatten([ { opacity: animation, transform: [{ scale: animation }], }, styles.content, placement && (_b = {}, _b[placement] = 0, _b.position = 'absolute', _b.margin = 16, _b.bottom = 0, _b), style, ]) }, react_1.default.createElement(Button_1.Button, __assign({ buttonStyle: react_native_1.StyleSheet.flatten([ rest.title ? size === 'small' ? styles.smallExtendedLabel : styles.extendedLabel : size === 'small' ? styles.smallFAB : styles.largeFAB, { backgroundColor: color || ((_c = theme === null || theme === void 0 ? void 0 : theme.colors) === null || _c === void 0 ? void 0 : _c.secondary), }, buttonStyle, ]), iconContainerStyle: [ rest.title ? {} : size === 'small' ? styles.smallFAB : styles.largeFAB, iconContainerStyle, ], containerStyle: react_native_1.StyleSheet.flatten([ styles.container, disabled && styles.disabled, containerStyle, ]), titleStyle: [ styles.label, { color: (_d = theme === null || theme === void 0 ? void 0 : theme.colors) === null || _d === void 0 ? void 0 : _d.white }, upperCase && styles.upperCaseLabel, titleStyle, ] }, rest, { disabled: disabled, theme: theme })))); }; exports.FAB = FAB; var styles = react_native_1.StyleSheet.create({ container: { elevation: 4, borderRadius: 28, }, largeFAB: { height: 56, width: 56, padding: 16, }, smallFAB: { height: 40, width: 40, padding: 8, }, content: { flexDirection: 'row', alignItems: 'center', justifyContent: 'center', borderRadius: 28, }, label: { marginHorizontal: 8, }, upperCaseLabel: { textTransform: 'uppercase', }, extendedLabel: { height: 48, paddingHorizontal: 16, }, smallExtendedLabel: { height: 40, paddingHorizontal: 12, }, disabled: { elevation: 0, }, }); exports.FAB.displayName = 'FAB';