Open inaseem opened 4 years ago
@naseemali925 I works fine on my Device.
@AminullahTajMuhammad I tested the code also and as of now there is no back stack maintained. I don't know how you are testing this. 😕
Could you please attach a GIF to show if this works fine on your device?
@isabelcosta @foongminwong I would love your response on this feature. Can I work on this feature?
@isabelcosta @foongminwong I would love your response on this. :smile:
Not sure if it makes sense within the main screen that contains the fragments, bottom options. I feel that back button in that context should lead to closing/move to background the app. @m-murad @foongminwong @annabauza any thoughts on this?
The back button should
What I think is not right with approach that the author of issue is suggesting - Imagine a user has been using the app for 15mins and has visited all the fragments multiple times (let's say 100), now to exit the app user should press the back button 100 times.
Hi all. I agree with @m-murad that a 'Home' button (which we already have as Home icon on bottom left of navbar)should bring us back to the Homepage of the application. But in terms of the '<' or 'Back' button that will bring us back to the previous screen, I agree that this function is needed coz it could be useful for if the user change their mind and just want to go one step backward. However, I don't think it's necessary to add the '<' button from within the app. Coz I'm sure the Android Native '<' button is available for user to do just that (going back one step).
Thank you @isabelcosta @m-murad @mtreacy002 for your comments. @m-murad you are correct to say that if a user keeps on navigating and switches too many times/around 100 times then it would be a trouble to go to Home as it would require too many Back/UP events.
Let the flow be Home > Profile > Members > Requests > Profile > Home
Pseudo Code
if ( Pressed Item already in Stack ) {
//Pop all items uptil the entry item matches to the Navigation Item Selected
while ( Stack.peek()!=Pressed Item ) {
Stack.pop();
}
} else {
Stack.push(Pressed Item);
}
Dry Run For The Flow Above
Select = Home => Stack.push(Home);Home
<-Stack
Select = Profile => Stack.push(Profile);Home > Profile
Select = Members => Stack.push(Members);Home > Profile > Members
Select = Requests => Stack.push(Requests);Home > Profile > Members > Requests
Select = Profile => {
Stack.pop(Requests);
Stack.push(Members);
}Home > Profile
Select = Home => {
Stack.pop(Profile);
}Home
NOTE: At Home the back functions the same way.
Let me know if you have any suggestions or improvements.
@isabelcosta @m-murad Could you please take a look and give your feedback.
Hello @anna4j could I get a review of what this issue is about?
Hello @anna4j
Is your feature request related to a problem? Please describe. When I open the app
Home
is selected by default. Then I select the Navigation items in some random order ex.Home -> Profile -> Requests -> Members -> Relation
. So when I press back button it should replace the fragments in the orderRelation -> Members -> Requests -> Profile -> Home
and then exit. But now it always moves toHome
when back or up is pressed.Describe the solution you'd like We can maintain a back stack that contains the destinations you've visited. The first destination of the app is placed on the stack when the user opens the app. Each call to the
replaceFragment()
method can put another destination on top of the stack. Tapping Back or Up will pop the top most Item from stack and replace it.Describe alternatives you've considered
Stack<Fragment>
to maintain the order of visited destinations. When a Back or Up is pressed then pop items from this stack to replace the top most item from Stack with the current fragment.FragmentManager
[Source](https://developer.android.com/reference/android/app/FragmentManager#popBackStack())Additional context
@isabelcosta @foongminwong Can I work on this?