UNPKG

@brightlayer-ui/react-native-auth-workflow

Version:

Re-usable workflow components for Authentication and Registration within Eaton applications.

49 lines (48 loc) 2.62 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 { Dimensions, Platform, StyleSheet, View } from 'react-native'; import { useScreenDimensions } from '../../hooks/useScreenDimensions'; import { Card } from 'react-native-paper'; import { WorkflowCardInstructions } from './WorkflowCardInstructions'; import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view'; const makeStyles = (isTablet) => StyleSheet.create({ viewContainer: { flex: 1, }, workflowBody: { marginHorizontal: isTablet ? 24 : 16, paddingTop: 32, paddingBottom: isTablet ? 32 : 24, paddingHorizontal: 0, flex: 1, }, }); /** * Component that renders the body content for the workflow card. * * @param {CardContentProps} props - Props of CardContentProps component * * @category Component */ export const WorkflowCardBody = (props) => { const { children, style, scrollable = true, WorkflowCardInstructionProps } = props, otherCardContentProps = __rest(props, ["children", "style", "scrollable", "WorkflowCardInstructionProps"]); const { isTablet } = useScreenDimensions(); const defaultStyles = makeStyles(isTablet); const windowHeight = Dimensions.get('window').height; return (React.createElement(React.Fragment, null, scrollable ? (React.createElement(KeyboardAwareScrollView, { contentInsetAdjustmentBehavior: "always", bounces: false, keyboardShouldPersistTaps: 'handled', extraScrollHeight: Platform.OS === 'ios' ? -windowHeight * 0.07 : 0 }, React.createElement(WorkflowCardInstructions, Object.assign({}, WorkflowCardInstructionProps)), React.createElement(Card.Content, Object.assign({ style: [defaultStyles.workflowBody, style] }, otherCardContentProps), children))) : (React.createElement(React.Fragment, null, React.createElement(WorkflowCardInstructions, Object.assign({}, WorkflowCardInstructionProps)), React.createElement(Card.Content, Object.assign({ style: [defaultStyles.workflowBody, style] }, otherCardContentProps), React.createElement(View, { style: defaultStyles.viewContainer }, children)))))); };