2.0.2 • Published 2 years ago

react-native-preloader-shimmer v2.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

react-native-preloader-shimmer

  • Demo Screens
MainLoaderPageLoaderPostLoader

Profile Loader

Install packages

npm install react-native-preloader-shimmer --save

yarn add react-native-preloader-shimmer

Other Dependency - Mostly auto install

yarn add react-native-shimmer

and

cd ios && pod install

If any error occur's without installing react-native-shimmer

if any error occur's without installing react-native-shimmer then

yarn add react-native-shimmer

Usage

Main Loader

MainLoaderMainLoader Dark
import React from "react";
import { View, StyleSheet } from "react-native";
import { MainLoader } from "react-native-preloader-shimmer";

const App = () => {
  return (
    <View style={{ flex: 1, backgroundColor: "white" }}>
      <MainLoader
        barStyle={"dark-content"} //Status bar icon color -required filed light-content or dark-content
        animSpeed={100} // Animation Run speed - default 100ms
        visible={true} //Visibility of MainLoader default true
        backgroundColor={"white"} // backgroundColor of main container default = #ffffff
      />
    </View>
  );
};

export default App;
NAME PROPSANDROIDIOSTYPE
barStylerequiredrequireddark-content light-content
animSpeedrequiredrequiredNumber 1 - 1000
backgroundColornot requirednot requiredDefault - white #ffffff
visiblenot requiresnot requiresBoolean default is true

Post Loader

PostLoaderPostLoader Dark
  • Make a Loader for your post like facebook
import React from 'react'
import { View } from 'react-native';
import { PostLoader } from 'react-native-preloader-shimmer'

const App = () => {
  return (
    <View style={{ flex: 1, backgroundColor: 'white' }}>
      <PostLoader
        barStyle={'dark-content'} //---> StatusBar Icon color 
        animSpeed={100} //----> Animation Speed default 100
        visible={true} //----> Visibility  
        backgroundColor={'white'} />
    </View>
  )
}

export default App;
NAME PROPSANDROIDIOSTYPE
barStylerequiredrequireddark-content light-content
animSpeedrequiredrequiredNumber 1 - 1000
backgroundColornot requirednot requiredDefault - white #ffffff
visiblenot requiresnot requiresBoolean default is true

Page Loader

PageLoaderPageLoader Dark
  • PreBuild PageLoader for BlogPost / Terms and conditions fetching from internet
import React from 'react'
import { View } from 'react-native';
import { PageLoader } from 'react-native-preloader-shimmer'

const App = () => {
  return (
    <View style={{ flex: 1, backgroundColor: 'white' }}>
      <PageLoader
        barStyle={'dark-content'} //----> StatusBar icon Color
        animSpeed={100} //----> Animation Speed default 100
        visible={true} //----> Visibility  true/false
        includeProfile={true} //---> Hide 2 profile shimmer
        backgroundColor={'white'} />
    </View>
  )
}

export default App;
NAME PROPSANDROIDIOSTYPE
includeProfilenot requirednot requiredtrue/ false
barStylerequiredrequireddark-content light-content
animSpeedrequiredrequiredNumber 1 - 1000
backgroundColornot requirednot requiredDefault - white #ffffff
visiblenot requiresnot requiresBoolean default is true

Profile Loader

ProfileLoader

ProfileLoader Dark

  • PreBuild Loader for profile if it's empty or fetching
import React from 'react'
import { View } from 'react-native';
import { ProfileLoader } from 'react-native-preloader-shimmer'

const App = () => {
  return (
    <View style={{ padding: 10 }}>
      <ProfileLoader
        animSpeed={100} //----> Animation Speed default 100
        visible={true} //----> Visibility  true/false
        backgroundColor={'white'} />
    </View>
  )
}

export default App;
NAME PROPSANDROIDIOSTYPE
animSpeedrequiredrequiredNumber 1 - 1000
backgroundColornot requirednot requiredDefault - white #ffffff
visiblenot requiresnot requiresBoolean default is true

Full Example

  • Fetching data from server
  • After fetching success profileLoader will invisible
import React, { useEffect, useState } from 'react'
import { View, Text, StyleSheet, Image } from 'react-native';
import { ProfileLoader } from 'react-native-preloader-shimmer'
const App = () => {

  const [showLoader, setShowLoader] = useState(true)
  const [data, setData] = useState([])

  useEffect(() => {
    setTimeout(() => {
      getProfile() //---> Fetch may work fast ... this is for demo purpose
    }, 2000);
  }, [])

  const getProfile = async () => {
    /*
    Usage of async function means here if will call only after first 2 function works
    */
    const ftch = await fetch('https://demo.chzapps.com/get-user-demo.json'); //----> May load fast
    const json = await ftch.json()
    if (json) {
      setShowLoader(false) //This is for invisible Loader and visible other text and images
      setData(json)
    }
  }

  return (
    <View style={{ backgroundColor: 'white', flex: 1 }}>
      <View style={{ padding: 10 }}>
        {/* Wrapped in View for padding 10 Default ProfileLoader not support style */}
        {
          showLoader ? <ProfileLoader
            animSpeed={100} //----> Animation Speed default 100
            visible={showLoader} //----> Visibility  true/false
            backgroundColor={'white'} /> :
            <View>
              <Image
                source={{ uri: data.profile }}
                style={{ height: 50, width: 50 }} />
              <Text style={styles.name}>Name : {data.name}</Text>
              <Text style={styles.name}>Work : {data.workingtype}</Text>
              <Text style={styles.name}>Age : {data.age}</Text>
            </View>
        }
      </View>
    </View>
  )
}

//StyleSheet
const styles = StyleSheet.create({
  name: {
    fontSize: 20,
  }
})

export default App;

/**
 * this is only a demo purpose
 * Fetched image was from internet
 */
2.0.2

2 years ago

2.0.1

2 years ago

1.2.19

3 years ago

1.2.20

3 years ago

1.2.21

3 years ago

1.2.23-cr0

3 years ago

1.2.18

3 years ago

1.2.12

3 years ago

1.2.13

3 years ago

1.2.16

3 years ago

1.2.17

3 years ago

1.2.14

3 years ago

1.2.15

3 years ago

1.2.10

3 years ago

1.1.0

3 years ago

1.0.10

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.2.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.0.0

3 years ago