UNPKG

rn-inkpad

Version:

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

71 lines (70 loc) 3.1 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.TabControl = void 0; const react_1 = __importStar(require("react")); const react_native_1 = require("react-native"); const TabControl = ({ values, selectedIndex = 0, label, labelStyle, backgroundTabColor = '#CCCCCC', tabTintColor = '#FFFFFF', textColor = '#000000', selectedTextColor = '#000000', containerStyle, style, }) => { const [selected, setSelected] = (0, react_1.useState)(selectedIndex); const handlePress = (idx) => { setSelected(idx); }; const Component = values[selected].renderItem; return (<react_native_1.View style={style}> {!!label && <react_native_1.Text style={labelStyle}>{label}</react_native_1.Text>} <react_native_1.View style={{ flexDirection: 'row', justifyContent: 'center', paddingTop: 2, paddingLeft: 1, paddingRight: 1, backgroundColor: backgroundTabColor, borderTopLeftRadius: 5, borderTopRightRadius: 5, marginTop: 5, }}> {values.map((value, index) => (<react_native_1.Pressable onPress={() => handlePress(index)} key={index} style={{ flex: 1, backgroundColor: selected === index ? tabTintColor : backgroundTabColor, paddingVertical: 5, borderTopLeftRadius: index === 0 ? 5 : 0, borderTopRightRadius: index === values.length - 1 ? 5 : 0, }}> <react_native_1.Text style={{ textAlign: 'center', fontWeight: '700', color: selected === index ? selectedTextColor : textColor, fontSize: 16, }}> {value.key} </react_native_1.Text> </react_native_1.Pressable>))} </react_native_1.View> <react_native_1.View style={[{ paddingBottom: 5 }, containerStyle]}> <Component /> </react_native_1.View> </react_native_1.View>); }; exports.TabControl = TabControl;