UNPKG

rn-inkpad

Version:

<img src="https://res.cloudinary.com/fercloudinary/image/upload/v1715452841/packages/inkpad-banner_acl0xl.png" />

93 lines (92 loc) 3.26 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.ActionButton = void 0; const react_1 = __importStar(require("react")); const react_native_1 = require("react-native"); const Icon_1 = require("../icon/Icon"); const ActionButton = ({ action, backgroundColor, marginTop, radius = 'none', showIconOnIos, style, textColor, theme, }) => { const [edges, setEdges] = (0, react_1.useState)({}); const isIos = theme === 'cupertino'; const { text, icon, iconColor, textStyle, onPress } = action; (0, react_1.useEffect)(() => { setEdges(border()); }, [radius]); const border = () => { if (!isIos) { return {}; } if (radius === 'all') { return { borderRadius: 10, }; } if (radius === 'top') { return { borderTopRightRadius: 10, borderTopLeftRadius: 10, }; } if (radius === 'bottom') { return { borderBottomLeftRadius: 10, borderBottomRightRadius: 10, }; } return {}; }; return (<react_native_1.Pressable onPress={onPress} style={[ { ...styles.buttonContainer, justifyContent: theme === 'cupertino' ? 'center' : 'flex-start', backgroundColor, marginTop, }, edges, style, ]}> {(!isIos || showIconOnIos) && icon && (<Icon_1.Icon name={icon} size={18} color={iconColor ? iconColor : theme === 'cupertino' ? textColor : '#757575'} style={isIos && styles.cupertinoIcon}/>)} <react_native_1.Text style={[{ color: textColor, fontWeight: '500' }, textStyle]}> {text} </react_native_1.Text> </react_native_1.Pressable>); }; exports.ActionButton = ActionButton; const styles = react_native_1.StyleSheet.create({ buttonContainer: { padding: 10, flexDirection: 'row', gap: 25, }, cupertinoIcon: { position: 'absolute', alignSelf: 'center', left: 15, }, });