Code Monkey home page Code Monkey logo

Comments (5)

kyle-belle avatar kyle-belle commented on July 18, 2024

I kinda get around it by having the visible state default to null then then only showing the animated bootSplash (setting visible to true) when the onReady is called

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

from react-native-bootsplash.

zoontek avatar zoontek commented on July 18, 2024

This is a good idea, but having a hide function to call is actually a breaking change as we will need to fire it.

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,
});

from react-native-bootsplash.

kyle-belle avatar kyle-belle commented on July 18, 2024

This is a good idea, but having a hide function to call is actually a breaking change as we will need to fire it.

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.

from react-native-bootsplash.

zoontek avatar zoontek commented on July 18, 2024

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");
        }}
      />
    )}
  </>
);

from react-native-bootsplash.

maksim-romanov avatar maksim-romanov commented on July 18, 2024

You can hide splash screen manually call start animation function

from react-native-bootsplash.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.