Get current screen name of drawer navigation - android

I'm using React Navigation for my react native app. Currently, my drawer have 5 menus. Let's assume there are Home screen, ScreenA, ScreenB, Screen,C, and ScreenD.
I want a behaviour like this
If user press back button on Android on Home Screen, the screen will show pop up
If user press back button on Android on other screen except Home Screen, the screen will navigate to Home Screen.
I also use Redux Integration and did all the setup as described in React Navigation's documentation.
Need your help guys. Thanks

Related

How can I Lock app and disable navigation bar?

Are there any way for prevent user open difference app?.
I tried to use startLockTask(); in activity, and make application full screen, but user still out this mode by press on back and menu button.
So how can I prevent android show navigation bar when user touch down from top or touch up from bottom of screen?

react native picker - doesn't hide when android back button pressed

I have a listener on the whole app for the back button press event in android to override the default behaviour of back button(exit the app).
Also in some component i have override it too if i want the back button to be disabled or do something else.
The problem is when i open a react-native-picker, the picker stays on the screen ignoring the back button press.
I want it to first close (on the first back button press) and only then do what the higher component ordered to do when back button is pressed.
so i can't override the the higher component back button handling
i thought maybe to add the picker as a screen in the navigator and instead of planting it as a component, navigate to it, so it will be added to the stack navigator.
then by default it will first pop it of the stack when pressing back.
how can i add the picker component as a screen to navigate to, or is there a better way to do that?
By default the back behavior collapses or closes the picker on Android (depending on the mode you have chosen). You can see a working example here.

Navigation Component with Login / Register / Home flow

I would like to use the new Navigation Component for my next application but I can't quite wrap my head around the overall flow of navigation.
The Android team recommends a single activity as an entry point. They also suggest that conditional elements like a login / register should not be the entry point.
But then how do you display the login and register buttons if the entry screen is supposed to be the home screen?
Another idea is to use a Splash screen, have the logic there to determine if the user is already logged in, if so go to the home screen, if not show the login / register screen(s).
My other issue is with the single activity. My home screen would need to be a screen with a Bottom Navigation.
How do you tie all of this the "right way"? Do I need to have a separate navigation graph for the Home view, with the Bottom Navigation and the many screens that will flow from there?
All the examples I have found have been very straightforward, and the few I have seen with a Splash screen splitting into Home and Login have a very simple Home fragment, which in my case would be . more complex with the Bottom Nav.
Thanks.
One way to do this, you hide the bottom navigation in the login and popup the homepage when you navigate to the login page so the user would not be able to go back to the splash screen
1-you can hide the bottom naviagtion bar in the login fragment like this
val toolbar = activity!!.findViewById<Toolbar>(R.id.toolbar)
val bottombar = activity!!.findViewById<BottomNavigationView>(R.id.bottomNavigationView)
toolbar.visibility = View.GONE
bottombar.visibility = View.GONE
2- popup the splash fragment when you navigate to the login page
<action
android:id="#+id/action_splashFragment_to_loginFragment"
app:destination="#id/loginFragment"
app:popUpTo="#+id/splashFragment"
app:popUpToInclusive="true"/>
Hopefully it will work for you
Simple example =
Single activity, Multi fragment with bottom navigation bar and with Android Navigation comp.
Plan:
Show a splash screen with a timer like 3000 milis.
End of the milis navigate the user to login screen if already logged (check it on splash) navigate user to home screen
Now you can show a bottom nav. bar. For example "Home" "News"
You can handle backPresses in navigation. Handle for home (Disable to returning splash)
That's all folks!

ionic2 with angular js 2 side menu icon not appearing after navCtrl push

I'm working in ionic2 , here i'm having a login page and on it will redirect to a side menu with swipe tabs page**HomePage output home.html**.
I've used **this.nav.push('HomePage')**to redirect from login page to home page. But I'm not getting the menu icon, it disappears and back icon is showing up.
Can anyone help me out?
This is happening because you used nav.push instead of nav.setRoot. In Ionic, pushing a page adds it to a stack, and the back button pops it off the stack.
You want to use setRoot here:
this.nav.setRoot('HomePage');

Nested Navigators React Native

I am using TabNavigator as per this: https://reactnavigation.org/docs/navigators/tab.
The app already has Navigator from react-native to handle Navigation between different Screens. The Navigator is connected to the redux store. My problem is when I go to any screen after clicking on the button on Tab Screen it goes to the particular screen (Which is handled by Navigator) but while coming back it doesn't come back to the Tab Screen.
I also looked into https://reactnavigation.org/docs/intro/nesting but I want to do it with react Navigator.
Any suggestion/guide to this will be really helpful.

Categories

Resources