react-native-material-elements
Version:
React native material elements is a sophisticated UI library crafted to enhance your React Native development workflow. Designed for simplicity and elegance, nex-ui provides a rich collection of components and utilities to effortlessly create polished mob
28 lines (23 loc) • 693 B
text/typescript
import { ViewStyle } from 'react-native';
import { GetStackInnerContainerStylesParams } from './Stack';
export const getStackInnerContainerStyles = ({
index,
spacing,
direction,
count,
}: GetStackInnerContainerStylesParams): ViewStyle => {
if (count === 0) {
return {};
}
if (spacing !== undefined && spacing <= 0) {
return {};
}
const isRowDirection = direction === 'row';
const isFirstItem = index === 0;
const applyToSpacing = !isRowDirection && !isFirstItem && count > 1;
const applyLeftSpacing = !isFirstItem && isRowDirection;
return {
...(applyToSpacing && { marginTop: spacing }),
...(applyLeftSpacing && { marginLeft: spacing }),
};
};