-
Notifications
You must be signed in to change notification settings - Fork 106
Nav - SaveableNavStack
#2439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: j-nav
Are you sure you want to change the base?
Nav - SaveableNavStack
#2439
Conversation
|
|
||
| public data class Record( | ||
| override val screen: Screen, | ||
| val args: Map<String, Any?> = emptyMap(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see the args being used in the full
prototype, what are these for? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a hold over from the current backstack. But yaa should just remove it, its not in the interface.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed with 7ad7d13
| override val forwardItems: Iterable<Record> | ||
| get() = entries.subList(0, currentIndex).asReversed() | ||
|
|
||
| override val backwardItems: Iterable<Record> | ||
| get() = entries.subList(currentIndex + 1, entries.size) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These have no checks for the currentIndex
being within the limits of the entries size,
is that a concern here?
Eg. you could pass
entries = [A, B, C],
currentIndex = 3
and this would crash with IllegalArgumentException
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
currentIndex is managed internally by SaveableNavStack and there are bounds checks before its ever mutated. For SaveableNavStackList here, its only ever visible to SaveableNavStack or the internal Saver.
| // Can't go backward anymore | ||
| assertFalse(navStack.backward()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this also verify that the current record
has not changed when it can't go back anymore?
| // Can't go backward anymore | |
| assertFalse(navStack.backward()) | |
| // Can't go backward anymore | |
| assertFalse(navStack.backward()) | |
| assertEquals(TestScreen.RootAlpha, navStack.currentRecord?.screen) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done with 85b2834
| // Can't go forward anymore | ||
| assertFalse(navStack.forward()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly here:
| // Can't go forward anymore | |
| assertFalse(navStack.forward()) | |
| // Can't go forward anymore | |
| assertFalse(navStack.forward()) | |
| assertEquals(TestScreen.ScreenC, navStack.currentRecord?.screen) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done with 85b2834
mck182
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! 👍
Changes
NavStackfrom AddNavStack#2418Demo
Screen_recording_20251119_170905.mp4