diff --git a/examples/react-template/screens/Tab.tsx b/examples/react-template/screens/Tab.tsx index 8bd56dd5..2756b5ee 100644 --- a/examples/react-template/screens/Tab.tsx +++ b/examples/react-template/screens/Tab.tsx @@ -42,9 +42,34 @@ export const TabScreen = (): JSX.Element => { - + setActivateIndexEventTab(0)} + > + Centered + + setActivateIndexEventTab(1)} + > + Two + + setActivateIndexEventTab(2)} + > + Three + + + + + setActivateIndexEventTab(0)} @@ -52,6 +77,7 @@ export const TabScreen = (): JSX.Element => { One setActivateIndexEventTab(1)} diff --git a/examples/react-template/screens/index.ts b/examples/react-template/screens/index.ts index 3aa5fe0d..f06c8b51 100644 --- a/examples/react-template/screens/index.ts +++ b/examples/react-template/screens/index.ts @@ -15,7 +15,6 @@ export * from "./CountDown"; export * from "./Divider"; export * from "./Dropdown"; export * from "./Fab"; -export * from "./Form"; export * from "./Hero"; export * from "./Image"; export * from "./Icon"; diff --git a/packages/react/components/tabs/Tabs.native.tsx b/packages/react/components/tabs/Tabs.native.tsx index 5979fe6d..939e1c87 100644 --- a/packages/react/components/tabs/Tabs.native.tsx +++ b/packages/react/components/tabs/Tabs.native.tsx @@ -13,8 +13,9 @@ import { ComponentName } from '../enumsComponentsName' * @param activeIndex {number} default active tab index * @param disabled {boolean} Disabled tabs * @param inverted {boolean} dark mode + * @param centered {boolean} Is centered */ -const Tabs = ({ children, onClick, activeIndex, disabled, inverted, ...others }: TabsProps): JSX.Element => { +const Tabs = ({ children, onClick, activeIndex, disabled, centered, inverted, ...others }: TabsProps): JSX.Element => { const [activateIndex, setActivateIndex] = useState(activeIndex) const [isIcons, setIsIcons] = React.useState(false) @@ -41,13 +42,13 @@ const Tabs = ({ children, onClick, activeIndex, disabled, inverted, ...others }: tabs: { height: isIcons ? 64 : 48, flexDirection: 'row', - backgroundColor: inverted ? getColorStyle(TrilogyColor.MAIN) : getColorStyle(TrilogyColor.WHITE), - overflow: 'visible', + backgroundColor: inverted ? getColorStyle(TrilogyColor.MAIN) : getColorStyle(TrilogyColor.WHITE) }, }) return ( - + {children && Array.isArray(children) && // eslint-disable-next-line @typescript-eslint/no-explicit-any diff --git a/packages/react/components/tabs/item/TabsItem.native.tsx b/packages/react/components/tabs/item/TabsItem.native.tsx index ea414cb4..f11145cc 100644 --- a/packages/react/components/tabs/item/TabsItem.native.tsx +++ b/packages/react/components/tabs/item/TabsItem.native.tsx @@ -1,5 +1,5 @@ import React, { useEffect, useState } from "react" -import { StyleSheet, TouchableOpacity, View } from "react-native" +import { StyleSheet, TouchableOpacity, View, Dimensions } from "react-native" import { TabsItemProps } from "./TabsItemProps" import { getColorStyle, TrilogyColor } from "../../../objects/facets/Color" import { TypographyBold } from "../../../objects" @@ -28,42 +28,43 @@ const TabsItem = ({ const [activeItem, setActiveItem] = useState(active || false) const [isPressIn, setInPressIn] = useState(false) + const getIconColor = React.useMemo(() => { if (inverted) { - if (disabled) return TrilogyColor.DISABLED + if (disabled) return TrilogyColor.NEUTRAL_LIGHT return TrilogyColor.WHITE } if (disabled) return TrilogyColor.DISABLED if (active) return TrilogyColor.MAIN - return TrilogyColor.MAIN + return TrilogyColor.MAIN +}, [inverted, disabled, active]) + + const getBorderColor = React.useMemo(() => { + if (disabled) + return 'transparent' + if (inverted) { + if (active) return getColorStyle(TrilogyColor.WHITE) + return getColorStyle(TrilogyColor.FONT, 1) + } + if (active) return getColorStyle(TrilogyColor.MAIN) + return getColorStyle(TrilogyColor.FONT, 1) }, [inverted, disabled, active]) const styles = StyleSheet.create({ tabsItem: { - marginRight: 8, alignItems: "center", justifyContent: "center", - ...(tabIndex === 0 && { marginLeft: 24 }), - padding: 8, + paddingVertical: 6, + paddingHorizontal: 14, position: "relative", + borderBottomWidth: 2, + height: iconName ? 60 : 44, + borderBottomColor: getBorderColor, }, text: { - color: - isPressIn && !inverted && !disabled - ? getColorStyle(TrilogyColor.MAIN) - : getColorStyle(getIconColor), + color: getColorStyle(getIconColor), textAlign: "center", }, - activeBar: { - height: 2, - backgroundColor: inverted - ? getColorStyle(TrilogyColor.WHITE) - : getColorStyle(TrilogyColor.MAIN), - width: "100%", - position: "absolute", - bottom: 4, - borderRadius: 2, - }, }) useEffect(() => { @@ -87,7 +88,7 @@ const TabsItem = ({ {...others} > {iconName && ( - + )} @@ -108,7 +109,6 @@ const TabsItem = ({ ) : ( children ))} - {active && !disabled && } ) }