import * as React from "react"; import { View, StyleSheet, Pressable } from "react-native"; import { useState } from "react"; import Blocks from "../../components/blocks/blocks"; import type { BuilderBlock } from "../../types/builder-block"; import type { TabsProps } from "./tabs.types"; function Tabs(props: TabsProps) { const [activeTab, setActiveTab] = useState(() => props.defaultActiveTab ? props.defaultActiveTab - 1 : 0 ); function activeTabContent(active: number) { return props.tabs && props.tabs[active].content; } function getTabStyle(index: number) { return index === activeTab ? props.activeTabStyle : {}; } function onClick(index: number) { if (index === activeTab && props.collapsible) { setActiveTab(-1); } else { setActiveTab(index); } } return ( {props.tabs?.map((tab, index) => ( onClick(index)} > ))} {activeTabContent(activeTab) ? ( ) : null} ); } export default Tabs;