Coder Social home page Coder Social logo

react-navigation-v5-mix's Introduction

React Navigation v5 mix

This project is part of YouTube tutorial series on React Navigation 5. Here I have used every navigator option available and combine them in a single project to create a seemless user navigation experience for the app user.

Then I have created some extra things such as login, signup & splash screen and provided an authentication flow using AsycStorage. Also I have created form validation for the login screen.

Here you can find complete tutorial series and each video link.

YouTube Video List

Project Demo

React Navigation v5 Mix App iPhone Demo

iPhone Demo

React Navigation v5 Mix App Android Demo

Android Demo

react-navigation-v5-mix's People

Contributors

itzpradip avatar rvs1337 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-navigation-v5-mix's Issues

How to get AsyncStorage data in DrawerContent

Hello,

I need to display name of user from async storage in Drawercontent.

Ho do i pass as props or get from storage and display
i am using getItem in other components -- but unable to get in Drawercontent

Not able to add sign out icon

I followed all your lectures on react navigation series. While creating custom in DrawerContent.js when i try to add icon for sign out i get the following error -
image

Following is the code for DrawerContent.js. If i comment the Icon code everything works fine.
image

Please look into this and provide a solution. I am stuck at this point.

double header

hi ,
1-I got double header on home page
2-I got errors while switching to dark mode
3- with colors
...NavigationDarkTheme.colors,
...PaperDarkTheme.colors,

Screenshot_20230507-201737

Putting Icons and details on Navbar

This includes polishing it and making the logout button show at the bottom. Putting applicable buttons to make it look nicer for the final product.

app restart after select a image with "react-native-image-picker"

Android 10 , on "SupportScreen", add image-picker code.
after select a image, app navigate to the loading screen. it seems restart.

"react": "16.11.0",
"react-native": "0.62.2",
"react-native-image-picker": "^2.3.1",
import React, { useState, useEffect } from 'react';
import {
  View, Text, Button, StyleSheet, Image,
  PermissionsAndroid, Linking, Alert
} from 'react-native';
import ImagePicker from 'react-native-image-picker';


const SupportScreen = () => {
  const [source, setSource] = useState(null);
  const defaultImage = require('../assets/logo.png');
  const options = {
    title: 'Select Image',
    quality: 0.5,
    maxWidth: 600,
    maxHeight: 500,
    cancelButtonTitle: 'Cancel',
    takePhotoButtonTitle: 'Camera',
    chooseFromLibraryButtonTitle: 'Select from library',
    chooseWhichLibraryTitle: 'Select',
    cameraType: 'back',
    mediaType: 'photo',
    // customButtons: [{ name: 'fb', title: 'Choose Photo from Facebook' }],
    storageOptions: {
      skipBackup: true,
      path: 'images',
    },
    // allowsEditing: false,
    noData: true,
    permissionDenied: {
      title: 'Need permissons',
      text: 'Please authorize the Camera and Photo permissions',
      reTryTitle: 'Go to settings',
      okTitle: 'OK'
    },
  };
  // android permissions
  const _showPicker = (type, option) => {
    PermissionsAndroid.requestMultiple([
      PermissionsAndroid.PERMISSIONS.CAMERA,
      PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE
    ]).then(granted => {
      console.log('global.CheckAndroidPermissions', granted)
      if (granted[PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE] === PermissionsAndroid.RESULTS.NEVER_ASK_AGAIN
        || granted[PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE] === PermissionsAndroid.RESULTS.DENIED) {//GRANTED
        Alert.alert(''Need permissons', 'Please authorize the Camera and Photo permissions', [
          {
            text: 'Cancel', style: "cancel", onPress: () => {
              // Linking.openSettings()
            },
          },
          {
            text: 'Go to settings', onPress: () => {
              Linking.openSettings()
            },
          }
        ], { cancelable: false });
        return;
      }
     
      //#region //select a image
      try {
        ImagePicker.showImagePicker(options, (response) => {
          console.log('Response = ', response);
          // return;

          if (response.didCancel) {
            console.log('User cancelled image picker');
          } else if (response.error) {
            console.log('ImagePicker Error: ', response.error);
          } else if (response.customButton) {
            console.log('User tapped custom button: ', response.customButton);
          } else {
            const source = { uri: `file://${response.path}` };

            // You can also display the image using data:
            // const source = { uri: 'data:image/jpeg;base64,' + response.data };

            // setSource(source)

          }
        });
      } catch (err) {
        console.log(err)
      }
      //#endregion
    })
  }
  return (
    <View style={styles.container}>
      <Text>Support Screen</Text>
      <Button
        title="Click Here"
        onPress={() => _showPicker()}
      />
      <View>
        <Image source={source ? { uri: source } : defaultImage} resizeMode='cover'
          style={{ width: 100, height: 100 }} />
      </View>
    </View>
  );
};

export default SupportScreen;

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center'
  },
});


app crashes on onPress={() => navigation.navigate('SignInScreen')}

import React from 'react';
import {
  View,
  Text,
  Button,
  StyleSheet,
  Dimensions,
  Image,
  TouchableOpacity,
} from 'react-native';
import * as Animatable from 'react-native-animatable';
import LinearGradient from 'react-native-linear-gradient';
import MaterialIcons from 'react-native-vector-icons/MaterialIcons';

const SplashScreen = ({navigation}) => {
  return (
    <View style={Styles.container}>
      <View style={Styles.header}>
        <Animatable.Image
          animation="bounceIn"
          duration={1500}
          source={require('../assets/logo.png')}
          style={Styles.logo}
          resizeMode="stretch"
        />
      </View>
      <Animatable.View style={Styles.footer} animation="fadeInUpBig">
        <Text style={Styles.title}>Stay connected with everyone!</Text>
        <Text style={Styles.text}>Sign in with account</Text>
        <View style={Styles.button}>
          <TouchableOpacity onPress={() => navigation.navigate('SignInScreen')}>
            <LinearGradient
              colors={['#08d4c4', '#01ab9d']}
              style={Styles.signIn}>
              <Text style={Styles.textSign}>Get Started</Text>
              <MaterialIcons name="navigate-next" color="#fff" size={20} />
            </LinearGradient>
          </TouchableOpacity>
        </View>
      </Animatable.View>
    </View>
  );
};

export default SplashScreen;

const {height} = Dimensions.get('screen');
const height_logo = height * 0.28;

const Styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#009387',
  },
  header: {
    flex: 2,
    justifyContent: 'center',
    alignItems: 'center',
  },
  footer: {
    flex: 1,
    backgroundColor: '#fff',
    borderTopLeftRadius: 30,
    borderTopRightRadius: 30,
    paddingVertical: 50,
    paddingHorizontal: 30,
  },
  logo: {
    width: height_logo,
    height: height_logo,
  },
  title: {
    color: '#05375a',
    fontSize: 30,
    fontWeight: 'bold',
  },
  text: {
    color: 'gray',
    marginTop: 5,
  },
  button: {
    alignItems: 'flex-end',
    marginTop: 30,
  },
  signIn: {
    width: 150,
    height: 40,
    justifyContent: 'center',
    alignItems: 'center',
    borderRadius: 50,
    flexDirection: 'row',
  },
  textSign: {
    color: 'white',
    fontWeight: 'bold',
  },
});

this tutorial at 10:20

fantastic

Thank you for your demo. I learned a lot

setTimeout is causing memory leaks.

The setTimeout function which you are using in App.js is causing memory leaks. To fix this you can clear the timeout

useEffect(() => {
    const timeout = setTimeout(async() => {
    
      let userToken;
      userToken = null;
      try {
        userToken = await AsyncStorage.getItem('userToken');
      } catch(e) {
        console.log(e);
      }
      dispatch({ type: 'RETRIEVE_TOKEN', token: userToken });
    }, 1000);
   return = () => {
      timeout() 
   }
  }, []);

Data

How can i pass data to drawer (username)

How to retrieve data from useContext?

As per your example, your using useMemo for creating multiple actions in App.js and adding login data in singIn.js.
I need to get these login data using useContex without asyncStorage in Home.js
example: I want to pass tokenID to APIs header without asyncStorage..Anyone can please help me

ERROR TypeError: Cannot read property 'level2' of undefined

hi ,
1-run normally
2-i got error while
logged in as user1 and password

so cannot login ....

This error is located at:
in BottomNavigation.Bar (created by BottomNavigation)
in RCTView (created by View)
in View (created by BottomNavigation)
in BottomNavigation (created by MaterialBottomTabViewInner)
in MaterialBottomTabViewInner (created by MaterialBottomTabView)
in RCTView (created by View)
in View (created by SafeAreaInsetsContext)
in SafeAreaProviderCompat (created by MaterialBottomTabView)
in MaterialBottomTabView (created by MaterialBottomTabNavigator)
in PreventRemoveProvider (created by NavigationContent)
in NavigationContent
in Unknown (created by MaterialBottomTabNavigator)
in MaterialBottomTabNavigator (created by MainTabScreen)
in MainTabScreen (created by SceneView)
in StaticContainer
in EnsureSingleNavigator (created by SceneView)
in SceneView (created by Drawer)
in RCTView (created by View)
in View (created by Screen)
in RCTView (created by View)
in View (created by Background)
in Background (created by Screen)
in Screen (created by Drawer)
in RNSScreen (created by AnimatedComponent)
in AnimatedComponent
in AnimatedComponentWrapper (created by InnerScreen)
in Suspender (created by Freeze)
in Suspense (created by Freeze)
in Freeze (created by DelayedFreeze)
in DelayedFreeze (created by InnerScreen)
in InnerScreen (created by Screen)
in Screen (created by MaybeScreen)
in MaybeScreen (created by Drawer)
in RNSScreenContainer (created by ScreenContainer)
in ScreenContainer (created by MaybeScreenContainer)
in MaybeScreenContainer (created by Drawer)
in RCTView (created by View)
in View (created by Drawer)
in RCTView (created by View)
in View (created by AnimatedComponent(View))
in AnimatedComponent(View)
in Unknown (created by Drawer)
in RCTView (created by View)
in View (created by AnimatedComponent(View))
in AnimatedComponent(View)
in Unknown (created by PanGestureHandler)
in PanGestureHandler (created by Drawer)
in Drawer (created by DrawerViewBase)
in DrawerViewBase (created by DrawerView)
in RNGestureHandlerRootView (created by GestureHandlerRootView)
in GestureHandlerRootView (created by DrawerView)
in RCTView (created by View)
in View (created by SafeAreaInsetsContext)
in SafeAreaProviderCompat (created by DrawerView)
in DrawerView (created by DrawerNavigator)
in PreventRemoveProvider (created by NavigationContent)
in NavigationContent
in Unknown (created by DrawerNavigator)
in DrawerNavigator (created by App)
in EnsureSingleNavigator
in BaseNavigationContainer
in ThemeProvider
in NavigationContainerInner (created by App)
in ThemeProvider (created by Provider)
in RCTView (created by View)
in View (created by Portal.Host)
in Portal.Host (created by Provider)
in RNCSafeAreaProvider (created by SafeAreaProvider)
in SafeAreaProvider (created by SafeAreaInsetsContext)
in SafeAreaProviderCompat (created by Provider)
in Provider (created by App)
in App
in RCTView (created by View)
in View (created by AppContainer)
in RCTView (created by View)
in View (created by AppContainer)
in AppContainer
in BarcodeReader(RootComponent), js engine: hermes
WARN Possible Unhandled Promise Rejection (id: 0):
TypeError: Cannot read property 'level2' of undefined
TypeError: Cannot read property 'level2' of undefined
at BottomNavigation.Bar (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.barcodereader&modulesOnly=false&runModule=true:145872:76)
at renderWithHooks (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.barcodereader&modulesOnly=false&runModule=true:67392:33)
at mountIndeterminateComponent (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.barcodereader&modulesOnly=false&runModule=true:69922:34)
at beginWork (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.barcodereader&modulesOnly=false&runModule=true:70834:49)
at beginWork$1 (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.barcodereader&modulesOnly=false&runModule=true:74188:29)
at performUnitOfWork (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.barcodereader&modulesOnly=false&runModule=true:73701:29)
at workLoopSync (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.barcodereader&modulesOnly=false&runModule=true:73649:28)
at renderRootSync (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.barcodereader&modulesOnly=false&runModule=true:73631:25)
at performSyncWorkOnRoot (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.barcodereader&modulesOnly=false&runModule=true:73421:40)
at flushSyncCallbacks (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.barcodereader&modulesOnly=false&runModule=true:64796:36)
at flushSyncCallbacksOnlyInLegacyMode (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.barcodereader&modulesOnly=false&runModule=true:64781:29)
at scheduleUpdateOnFiber (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.barcodereader&modulesOnly=false&runModule=true:73129:47)
at dispatchReducerAction (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.barcodereader&modulesOnly=false&runModule=true:68142:34)
at ?anon_0_ (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.barcodereader&modulesOnly=false&runModule=true:117444:21)
at next (native)
at asyncGeneratorStep (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.barcodereader&modulesOnly=false&runModule=true:21109:26)
at _next (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.barcodereader&modulesOnly=false&runModule=true:21128:29)
at tryCallOne (/root/react-native/ReactAndroid/hermes-engine/.cxx/Release/5e6w3h5p/arm64-v8a/lib/InternalBytecode/InternalBytecode.js:53:16)
at anonymous (/root/react-native/ReactAndroid/hermes-engine/.cxx/Release/5e6w3h5p/arm64-v8a/lib/InternalBytecode/InternalBytecode.js:139:27)
at apply (native)
at anonymous (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.barcodereader&modulesOnly=false&runModule=true:26639:26)
at _callTimer (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.barcodereader&modulesOnly=false&runModule=true:26558:17)
at _callReactNativeMicrotasksPass (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.barcodereader&modulesOnly=false&runModule=true:26588:17)
at callReactNativeMicrotasks (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.barcodereader&modulesOnly=false&runModule=true:26751:44)
at __callReactNativeMicrotasks (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.barcodereader&modulesOnly=false&runModule=true:5058:46)
at anonymous (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.barcodereader&modulesOnly=false&runModule=true:4870:45)
at __guard (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.barcodereader&modulesOnly=false&runModule=true:5042:15)
at flushedQueue (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.barcodereader&modulesOnly=false&runModule=true:4869:21)
at invokeCallbackAndReturnFlushedQueue (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.barcodereader&modulesOnly=false&runModule=true:4863:33)

after login navigation is not found on home page

Screenshot_1591363363

Getting this error
Steps to reproduce
-> when login and try navigation from the Home page directly.

But when coming to another tab then navigation from the Home page is working.

Please help
Thanks in advance.

Menu bar

I write everything same for open drawer to click on menu but in my project show error that is
undefine is not an object('evaluating navigation.openDrawer)
Plz tell me how to solve

@expo/vector-icons/icon could not be found within the project

hello,
I'm getting this following error

Unable to resolve module @expo/vector-icons/icon from E:\myapp\App.js: @expo/vector-icons/icon could not be found within the project.

If you are sure the module exists, try these steps:

  1. Clear watchman watches: watchman watch-del-all
  2. Delete node_modules and run yarn install
  3. Reset Metro's cache: yarn start --reset-cache
  4. Remove the cache: rm -rf /tmp/metro-*

note: I've run this command "npm install --save @expo/vector-icons
WhatsApp Image 2021-09-20 at 5 15 07 PM

SignUpScreen named SignInScreen

The component defined in SignUpScreen.js is called SignInScreen. This creates an issue while running import SignUpScreen from './SignUpScreen' in RootStackScreen.js.
To fix this, rename the component like so:

\\ ./screens/SignUpScreen.js

const SignUpScreen = ({navigation}) => {
    const [data, setData] = React.useState({
       ...
      </View>
    );
};

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.