UNPKG

rn-inkpad

Version:

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

71 lines (70 loc) 3.11 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.BottomTabNavigation = void 0; const react_1 = __importStar(require("react")); const react_native_1 = require("react-native"); const NavigationItem_1 = require("./NavigationItem"); const BottomTabNavigation = ({ backgroundColor = '#FFFFFF', highlightedBgColor, highlightedIconColor, iconColor, iconSize, labelStyle, selectedColor = '#DB504A', selectedheight, selectedIndex, textColor, values = [{ icon: 'home', text: 'Home' }], }) => { const [selected, setSelected] = (0, react_1.useState)(); (0, react_1.useEffect)(() => { setSelected(selectedIndex); }, [selectedIndex]); const handlePress = (idx, isHighlighted = false) => { const item = values ? values[idx] : undefined; if (!!item?.onPress) { item.onPress(); } if (!isHighlighted) { setSelected(idx); } }; return (<react_native_1.View style={{ backgroundColor, ...styles.container, }}> <react_native_1.SafeAreaView> <react_native_1.View style={{ ...styles.navigationContainer }}> {values?.map((item, idx) => (<NavigationItem_1.NavigationItem item={item} key={idx} highlightedBgColor={highlightedBgColor} iconColor={item.highlighted ? highlightedIconColor : iconColor} iconSize={iconSize} selectedheight={selectedheight} selected={selected === idx} selectedColor={selectedColor} textColor={textColor} textStyle={labelStyle} onPress={() => handlePress(idx, item.highlighted)}/>))} </react_native_1.View> </react_native_1.SafeAreaView> </react_native_1.View>); }; exports.BottomTabNavigation = BottomTabNavigation; const styles = react_native_1.StyleSheet.create({ container: { bottom: 0, position: 'absolute', width: '100%', }, navigationContainer: { flexDirection: 'row', justifyContent: 'space-evenly', alignItems: 'center', paddingBottom: 3, paddingHorizontal: '3%', gap: 8, }, });