UNPKG

@rneui/layout

Version:
35 lines (34 loc) 1.46 kB
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; }; import React from 'react'; import { View } from 'react-native'; import { makeStyles } from '../system/makeStyles'; export const Stack = (_a) => { var { children, style } = _a, rest = __rest(_a, ["children", "style"]); const styles = useStyles(rest); return (React.createElement(View, { style: [styles.container, style] }, React.Children.map(children, (child) => (React.createElement(View, { style: styles.childProps }, child))))); }; const useStyles = makeStyles(({ align = 'flex-start', row = false, justify = 'flex-start', spacing = 0, reverse = false, }) => { const flexDirection = ((row ? 'row' : 'column') + (reverse ? '-reverse' : '')); return { container: { display: 'flex', flexDirection: flexDirection, alignItems: align, justifyContent: justify, }, childProps: { [row ? 'paddingHorizontal' : 'paddingVertical']: spacing, }, }; });