mirror of
https://github.com/austinried/subtracks.git
synced 2026-03-28 07:12:43 +01:00
disable/unmount tabs while clearing image cache
This commit is contained in:
@@ -18,10 +18,11 @@ const BottomTabButton = React.memo<{
|
||||
isFocused: boolean
|
||||
icon: OutlineFillIcon
|
||||
navigation: NavigationHelpers<ParamListBase, BottomTabNavigationEventMap>
|
||||
}>(({ routeKey, label, name, isFocused, icon, navigation }) => {
|
||||
disabled?: boolean
|
||||
}>(({ routeKey, label, name, isFocused, icon, navigation, disabled }) => {
|
||||
const firstRun = useFirstRun()
|
||||
|
||||
const disabled = firstRun && name !== 'settings'
|
||||
disabled = !!disabled || (firstRun && name !== 'settings')
|
||||
|
||||
const onPress = () => {
|
||||
const event = navigation.emit({
|
||||
@@ -67,6 +68,13 @@ const BottomTabBar: React.FC<BottomTabBarProps> = ({ state, descriptors, navigat
|
||||
? options.title
|
||||
: route.name
|
||||
|
||||
let iconKey = route.name
|
||||
let disabled = false
|
||||
if (route.name.endsWith('-disabled')) {
|
||||
iconKey = route.name.split('-')[0]
|
||||
disabled = true
|
||||
}
|
||||
|
||||
return (
|
||||
<BottomTabButton
|
||||
key={route.key}
|
||||
@@ -74,8 +82,9 @@ const BottomTabBar: React.FC<BottomTabBarProps> = ({ state, descriptors, navigat
|
||||
label={label}
|
||||
name={route.name}
|
||||
isFocused={state.index === index}
|
||||
icon={bottomTabIcons[route.name]}
|
||||
icon={bottomTabIcons[iconKey]}
|
||||
navigation={navigation}
|
||||
disabled={disabled}
|
||||
/>
|
||||
)
|
||||
})}
|
||||
|
||||
@@ -176,12 +176,24 @@ const Tab = createBottomTabNavigator()
|
||||
const BottomTabNavigator = withSuspense(() => {
|
||||
const { t } = useTranslation()
|
||||
const firstRun = useFirstRun()
|
||||
const resetServer = useStore(store => store.resetServer)
|
||||
const disableMusicTabs = useStore(store => store.disableMusicTabs)
|
||||
|
||||
return (
|
||||
<Tab.Navigator tabBar={BottomTabBar} initialRouteName={firstRun ? 'settings' : 'home'}>
|
||||
{resetServer ? (
|
||||
<></>
|
||||
{disableMusicTabs ? (
|
||||
<>
|
||||
<Tab.Screen name="home-disabled" children={() => null} options={{ tabBarLabel: t('navigation.tabs.home') }} />
|
||||
<Tab.Screen
|
||||
name="library-disabled"
|
||||
children={() => null}
|
||||
options={{ tabBarLabel: t('navigation.tabs.library') }}
|
||||
/>
|
||||
<Tab.Screen
|
||||
name="search-disabled"
|
||||
children={() => null}
|
||||
options={{ tabBarLabel: t('navigation.tabs.search') }}
|
||||
/>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Tab.Screen name="home" component={HomeTab} options={{ tabBarLabel: t('navigation.tabs.home') }} />
|
||||
|
||||
Reference in New Issue
Block a user