From e04cfb9a8b39aaea0657cd3f2f6242c2c9bd4ac3 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Tue, 4 Feb 2025 12:18:54 +0000 Subject: [PATCH] add new action --- Apps.js | 12 +++------ lib/initIcon.tsx | 68 ++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 63 insertions(+), 17 deletions(-) diff --git a/Apps.js b/Apps.js index d7cc579..385f0dd 100644 --- a/Apps.js +++ b/Apps.js @@ -14,15 +14,13 @@ export function AppContainer() { const Tab = createBottomTabNavigator(); const { areaInfo, areaIconBadgeText, isInfo } = useAreaInfo(); const navigationRef = React.useRef(); - const getTabProps = (name, label, icon, iconFamily, tabBarBadge, style) => ({ + const getTabProps = (name, label, icon, iconFamily, tabBarBadge, isInfo) => ({ name, options: { tabBarLabel: label, headerShown: false, gestureEnabled: true, - tabBarIcon: initIcon(icon, iconFamily), - tabBarBadge, - tabBarBadgeStyle: style, + tabBarIcon: initIcon(icon, iconFamily,tabBarBadge,isInfo), }, }); @@ -38,7 +36,6 @@ export function AppContainer() { screenOptions={{ lazy: false, animation: "shift", - tabBarVariant: "uikit", }} detachInactiveScreens={false} lazy={false} @@ -59,10 +56,7 @@ export function AppContainer() { "train", "Ionicons", areaInfo ? areaIconBadgeText : undefined, - isInfo && { - backgroundColor: "#00b8ff", - color: "white", - } + isInfo )} children={TNDView} /> diff --git a/lib/initIcon.tsx b/lib/initIcon.tsx index 3f52608..afc12fc 100644 --- a/lib/initIcon.tsx +++ b/lib/initIcon.tsx @@ -1,20 +1,72 @@ -import React from "react"; +import React, { FC } from "react"; import { Ionicons, AntDesign } from "@expo/vector-icons"; +import { Text, View } from "react-native"; type name = keyof typeof Ionicons.glyphMap & keyof typeof AntDesign.glyphMap; type type = "Ionicons" | "AntDesign"; -export const initIcon = (name: name, type:type) => { +export const initIcon = ( + name: name, + type: type, + tabBarBadge: string, + isInfo: boolean +) => { switch (type) { case "Ionicons": return ({ focused, color, size }) => ( - + <> + {!!tabBarBadge && } + + ); case "AntDesign": return ({ focused, color, size }) => ( - + <> + {!!tabBarBadge && } + + ); } }; +type BadgeProps = { tabBarBadge: string; isInfo: boolean }; + +export const Badge: FC = ({ tabBarBadge, isInfo }) => { + return ( + + + + {tabBarBadge} + + + + ); +};