Skip to content

Conversation

@stagg
Copy link
Collaborator

@stagg stagg commented Dec 3, 2025

Changes

  • Saveable implementation of NavStack from Add NavStack #2418
  • Going to be a number of PRs for this as its changing core functionality
    • Full prototype setup is here

Demo

Screen_recording_20251119_170905.mp4

@stagg stagg requested a review from CamiloVega December 3, 2025 22:47
@stagg stagg marked this pull request as ready for review December 3, 2025 23:39

public data class Record(
override val screen: Screen,
val args: Map<String, Any?> = emptyMap(),
Copy link

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? 🤔

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed with 7ad7d13

Comment on lines +273 to +277
override val forwardItems: Iterable<Record>
get() = entries.subList(0, currentIndex).asReversed()

override val backwardItems: Iterable<Record>
get() = entries.subList(currentIndex + 1, entries.size)
Copy link

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

Copy link
Collaborator Author

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.

Comment on lines +134 to +135
// Can't go backward anymore
assertFalse(navStack.backward())
Copy link

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?

Suggested change
// Can't go backward anymore
assertFalse(navStack.backward())
// Can't go backward anymore
assertFalse(navStack.backward())
assertEquals(TestScreen.RootAlpha, navStack.currentRecord?.screen)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done with 85b2834

Comment on lines +149 to +150
// Can't go forward anymore
assertFalse(navStack.forward())
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly here:

Suggested change
// Can't go forward anymore
assertFalse(navStack.forward())
// Can't go forward anymore
assertFalse(navStack.forward())
assertEquals(TestScreen.ScreenC, navStack.currentRecord?.screen)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done with 85b2834

@stagg stagg requested a review from mck182 December 4, 2025 21:49
Copy link

@mck182 mck182 left a 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! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants