import React, { useState } from 'react'
import { Text, View, Pressable } from 'react-native'
import { BottomTabBarProps } from '@react-navigation/bottom-tabs'
import textStyles from '@app/styles/text'
import colors from '@app/styles/colors'
import FastImage from 'react-native-fast-image'
import NowPlayingBar from '@app/components/NowPlayingBar'
const icons: { [key: string]: any } = {
home: {
regular: require('../../res/home.png'),
fill: require('../../res/home-fill.png'),
},
library: {
regular: require('../../res/library.png'),
fill: require('../../res/library-fill.png'),
},
search: {
regular: require('../../res/search.png'),
fill: require('../../res/search-fill.png'),
},
settings: {
regular: require('../../res/settings.png'),
fill: require('../../res/settings-fill.png'),
},
}
const BottomTabButton: React.FC<{
routeKey: string
label: string
name: string
isFocused: boolean
img: { regular: number; fill: number }
navigation: any
}> = ({ routeKey, label, name, isFocused, img, navigation }) => {
const [opacity, setOpacity] = useState(1)
const onPress = () => {
const event = navigation.emit({
type: 'tabPress',
target: routeKey,
canPreventDefault: true,
})
if (!isFocused && !event.defaultPrevented) {
navigation.navigate(name)
}
}
return (
setOpacity(0.6)}
onPressOut={() => setOpacity(1)}
style={{
alignItems: 'center',
flex: 1,
opacity,
}}>
{label}
)
}
const BottomTabBar: React.FC = ({ state, descriptors, navigation }) => {
return (
{state.routes.map((route, index) => {
const { options } = descriptors[route.key] as any
const label =
options.tabBarLabel !== undefined
? (options.tabBarLabel as string)
: options.title !== undefined
? options.title
: route.name
return (
)
})}
)
}
export default BottomTabBar