UNPKG

omnipay-savings-sdk

Version:

Omnipay Savings SDK

72 lines (71 loc) 2.54 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const jsx_runtime_1 = require("react/jsx-runtime"); const react_1 = require("react"); const react_2 = require("react"); const react_native_1 = require("react-native"); const utils_1 = require("../../utils"); const threePane_1 = require("./threePane"); const ToggleTabs = ({ selectedTab, currentTab, firstLabel = '', secondLabel = '', unstyled = false, onPress, }) => { const [first, setFirst] = (0, react_2.useState)(true); const [second, setSecond] = (0, react_2.useState)(false); (0, react_1.useEffect)(() => { setFirst(currentTab === 0 ? true : false); setSecond(currentTab === 1 ? true : false); selectedTab(currentTab); }, [currentTab]); const toggle = (e) => { if (e === 0) { selectedTab(0); setFirst(true); setSecond(false); } else if (e === 1) { selectedTab(1); setFirst(false); setSecond(true); } else { return; } }; return ((0, jsx_runtime_1.jsxs)(react_native_1.View, Object.assign({ style: [ styles.container, { backgroundColor: unstyled ? utils_1.Colors.transparent : utils_1.Colors.tabBg, width: '100%', height: (0, utils_1.ms)(50), }, ] }, { children: [(0, jsx_runtime_1.jsx)(threePane_1.Tab, { twoPane: true, unstyled: unstyled, active: first, label: firstLabel, onPress: () => { toggle(0); //@ts-ignore onPress(0); } }), (0, jsx_runtime_1.jsx)(threePane_1.Tab, { twoPane: true, unstyled: unstyled, active: second, label: secondLabel, onPress: () => { toggle(1); //@ts-ignore onPress(1); } })] }))); }; const styles = react_native_1.StyleSheet.create({ container: { display: 'flex', flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', paddingHorizontal: (0, utils_1.ms)(5), paddingVertical: (0, utils_1.ms)(5), height: (0, utils_1.ms)(50), borderRadius: (0, utils_1.ms)(4), }, pill: { borderRadius: (0, utils_1.ms)(4), justifyContent: 'center', alignItems: 'center', width: '50%', height: '100%', }, title: { color: 'white', }, }); exports.default = ToggleTabs;