-
-
Notifications
You must be signed in to change notification settings - Fork 246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Manual hide
functionality when using useHideAnimation
#528
Comments
I kinda get around it by having the const [bootSplashVisible, setBootSplashVisible] = useState<boolean | null>(
null
);
useEffect(() => {
SetNavBarColor(bootSplashVisible !== false? 'transparent' : isDarkMode ? '#242424' : '#FFFFFF', !isDarkMode, true);
}, [isDarkMode, bootSplashVisible]);
...
<StatusBar translucent={bootSplashVisible !== false} backgroundColor={bootSplashVisible !== false ? 'transparent' : isDarkMode ? '#242424' : '#FFFFFF' }
barStyle={isDarkMode ? 'light-content' : 'dark-content'} />
<NavigationContainer
onReady={() => {
setBootSplashVisible(true);
// void BootSplash.hide({fade: true});
}}
}}>
<MainNavigator />
</NavigationContainer>
{bootSplashVisible && (
<AnimatedBootSplash
onAnimationEnd={() => {
setBootSplashVisible(false);
}}
/>
)} |
This is a good idea, but having a What do you think about this instead? // ready is a prop and handled by the parent. default to true (auto hide)
const { container, logo } = BootSplash.useHideAnimation({
ready: isReady,
}); |
Hi. Yeah i also think this would be fine. |
After a bit if reflexion, it would be clearer with a TS union: const [bootSplashState, setBootSplashState] = useState<
"visible" | "hiding" | "hidden"
>("visible");
const barColor =
bootSplashState === "hidden"
? isDarkMode
? "#242424"
: "#FFFFFF"
: "transparent";
useEffect(() => {
SetNavBarColor(barColor, !isDarkMode, true);
}, [barColor, isDarkMode]);
// ...
return (
<>
<StatusBar
translucent={bootSplashState !== "hidden"}
barStyle={isDarkMode ? "light-content" : "dark-content"}
backgroundColor={barColor}
/>
<NavigationContainer
onReady={() => {
setBootSplashState("hiding");
}}
>
<MainNavigator />
</NavigationContainer>
{bootSplashState === "hiding" && (
<AnimatedBootSplash
onAnimationEnd={() => {
setBootSplashState("hidden");
}}
/>
)}
</>
); |
You can hide splash screen manually call start animation function |
Why it is needed?
Currently I don't have a way to hide the animated bootsplash only after load. it automatically hides on its own. When using the regular bootsplash i can call
hide
when i want which has been helpful for my use case. I'd really like to be able to call hide manually for the animated version. also react-navigation's initialization causes the animation to lag/hang and i am not able to delay it untilonReady
Possible implementation
No response
Code sample
The text was updated successfully, but these errors were encountered: