disable/unmount tabs while clearing image cache

This commit is contained in:
austinried
2022-04-21 12:32:01 +09:00
parent 05e4b46469
commit 1944add558
4 changed files with 74 additions and 39 deletions

View File

@@ -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}
/>
)
})}

View File

@@ -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') }} />