Git Product home page Git Product logo

react-native-animated-splash-screen's Introduction

React Native Animated Splash Screen

Animated splash screen for Android and iOS. It is based on Implementing Twitter’s App Loading Animation in React Native topic from RN. This use an Image instead of MaskedView to work on both platforms.

license Version npm GitHub issues PRs Welcome runs with expo

GitHub followers GitHub stars


SplashAnimated example app.

Features

  • Custom background color.
  • Custom background image.
  • Custom logo.
  • Custom logo size.
  • It works both: Expo and Pure React Native. (Thanks to WrathChaos!)

Installation

yarn add react-native-animated-splash-screen or npm install --save react-native-animated-splash-screen

Usage

import AnimatedSplash from "react-native-animated-splash-screen";

render() {
    return (
      <AnimatedSplash
        translucent={true}
        isLoaded={this.state.isLoaded}
        logoImage={require("./assets/logo.png")}
        backgroundColor={"#262626"}
        logoHeight={150}
        logoWidth={150}
      >
        <App />
      </AnimatedSplash>
    );
  }

Props

Name Description Type Required Default Value
isLoaded Condition to show children component and finish the animation. Boolean false
backgroundColor Splash screen background color. String #f00 '#f00'
logoImage Splash screen logo image. Object null
logoWidth Logo image width in px. Number 150
logoHeight Logo image height in px. Number 150
children Children to render inside this component. Node null
preload Condition to load children component while wait isLoaded prop be True. Boolean true
disableBackgroundImage Disable the background image Boolean false
translucent When translucent is set to true, the app will draw under the status bar. Example: here! Boolean false
customComponent Add a logo component instead of a logo image. React Component null

Example with React Navigation

const AppNavigator = createStackNavigator(
  {
    home: {
      screen: HomeScreen,
      navigationOptions: {
        header: null,
      },
    },
    dashboard: {
      screen: DashboardScreen,
      navigationOptions: {
        title: "Dashboard",
      },
    },
  },
  {
    initialRouteName: "home",
  }
)

const Container = createAppContainer(AppNavigator)

class App extends React.Component {
  state = {
    isLoaded: false,
  }

  async componentDidMount() {
    await loadAsync()
    this.setState({ isLoaded: true })
  }

  render() {
    return (
      <AnimatedSplash
        translucent={true}
        isLoaded={this.state.isLoaded}
        logoImage={require("./assets/logo.png")}
        backgroundColor={"#262626"}
        logoHeight={150}
        logoWidth={150}
      >
        <Container />
      </AnimatedSplash>
    )
  }
}

export default App

Example with React Navigation (setting isLoaded inside a screen of navigator)

Navigator

const AppNavigator = createSwitchNavigator(
  {
    home: {
      screen: props => (
        <HomeScreen {...props} setAppLoaded={props.screenProps.setAppLoaded} />
      ),
    },
    dashboard: { screen: DashboardScreen },
  },
  {
    initialRouteName: "home",
  }
)

const Container = createAppContainer(AppNavigator)

class App extends React.Component {
  state = {
    isLoaded: false,
  }

  setAppLoaded = () => {
    this.setState({ isLoaded: true })
  }

  render() {
    return (
      <AnimatedSplash
        translucent={true}
        isLoaded={this.state.isLoaded}
        logoImage={require("./assets/logo.png")}
        backgroundColor={"#262626"}
        logoHeight={150}
        logoWidth={150}
      >
        <Container screenProps={{ setAppLoaded: this.setAppLoaded }} />
      </AnimatedSplash>
    )
  }
}

export default App

HomeScreen

class HomeScreen extends React.Component {

...

  async componentDidMount() {
    await loadAsync();
    this.props.setAppLoaded();
  }

...

}

export default HomeScreen

Example of translucent prop


translucent={true}

translucent={false}

Author

Fabio Freitas

License

MIT

react-native-animated-splash-screen's People

Contributors

ajp8164 avatar dependabot[bot] avatar elforastero avatar fabio-alss-freitas avatar wrathchaos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

react-native-animated-splash-screen's Issues

App stop on Splash screen

Issue Description:

I have installed the react-animated-splash-screen. At the launch of the application the Splash screen appears and nothing happen then...
Test has been done on IOS simulator IOS11 and not on Android yet.

The following warning appear on the bottom of the splash screen :

Possible Unhandled Promise Rejection (id: 0): ReferenceError: Can't find variable: loadAsync

Code Description:

On App.js

`
import AnimatedSplash from 'react-native-animated-splash-screen';
....

const AppNavigator = createSwitchNavigator(
  {
  Auth: AuthStack,
  Sinister: SinisterStack,
  CivicMain: CivicContainer,
  },
  {
    initialRouteName: 'Auth',
    mode:'modal',

  
  }
);


const AppContainer = createAppContainer(AppNavigator);


export default class App extends React.Component {
 

  
    state = {
      isLoaded: false,

    }
    
 

  async componentDidMount() {
    await loadAsync()
    this.setState({ isLoaded: true })
  }

 

  render() {
    return (

        <AnimatedSplash
          translucent={true}
          isLoaded={this.state.isLoaded}
          logoImage={require("./assets/img/IconBlanc.png")}
          backgroundColor={"#ffffff"}
          logoHeight={200}
          logoWidth={200}
        >
          <AppContainer />
        </AnimatedSplash>

    );
  }
}
`

Expected Behaviour

After the Splash Screen the initial Route name 'Auth' should appear.

Environment:

React Native 0.62 (Not Expo)
React Navigation 4.x
MacOS 10.15.22

Needing your help and support thank you!

Animated

Hello,

Would it be possible to add a gif, video or a lottie component?

Couldn't find declaration file for 'react-native-animated-splash-screen'

Issue
Hello!
I've recently installed the splash screen via Yarn, but when I try and import the AnimatedSplash component, this shows up on my IDE!

Could not find a declaration file for module 'react-native-animated-splash-screen'. 'c:/Users/moallim10/StuLink/stulink-app/node_modules/react-native-animated-splash-screen/index.js' implicitly has an 'any' type. Try npm install @types/react-native-animated-splash-screenif it exists or add a new declaration (.d.ts) file containingdeclare module 'react-native-animated-splash-screen';

This then doesn't let me use the AnimatedSplash component properly!

Enviroment
React Navigation V5
React Native 0.63
Expo SDK 38

Forced Dark Mode breaks colors on splash screen

When using the latest API to build an app, Android forces dark mode in some applications. This breaks the splash screen by changing the color of Animated.View component.

The only way to prevent that from happening is disabling forced dark mode.

android/app/src/main/res/values/styles.xml

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        //...
        <item name="android:forceDarkAllowed">false</item> // <- add this
    </style>

</resources>


Header gets cut off

When i use AnimatedSplash in my app.js, all my headers get cut off because AnimatedSplash isn't using SafeAreaView...

[Question] how is the children prop meant to be used?

Hello!

I've been getting an issue these past few days. I can't seem to add more than two elements inside the AnimatedSplash component. How can I use the children prop to render more than one element?

Thanks in advance!

flicker when loading logo

I seem to have a small flicker when the logo before the is loaded.

It seems to complete the rendering of the component but the image has completed. A small flicker is shown just before it is loaded

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.