Fix Books navigation — tapping a book no longer re-pushes the library
BookLibraryView is itself pushed from PracticeView's NavigationStack, so the .navigationDestination(for: Book.self) it declared was a non-root registration. Combined with NavigationLink(value: book), that resolved the push to *both* the destination handler and the closure that produced BookLibraryView originally — pushing the chapter list underneath, then re-pushing the library on top. Hitting back popped the library and revealed the chapter list, in the wrong order. Switched both Library→ChapterList and ChapterList→Reader to closure- based NavigationLinks. Destinations attach directly to the link, no type-keyed registry involved. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -19,7 +19,9 @@ struct BookChapterListView: View {
|
||||
var body: some View {
|
||||
List {
|
||||
ForEach(allChapters) { chapter in
|
||||
NavigationLink(value: chapter) {
|
||||
NavigationLink {
|
||||
BookReaderView(chapter: chapter)
|
||||
} label: {
|
||||
HStack(spacing: 12) {
|
||||
Text("\(chapter.number)")
|
||||
.font(.subheadline.weight(.bold).monospacedDigit())
|
||||
|
||||
@@ -17,7 +17,9 @@ struct BookLibraryView: View {
|
||||
ScrollView {
|
||||
LazyVStack(spacing: 12) {
|
||||
ForEach(books) { book in
|
||||
NavigationLink(value: book) {
|
||||
NavigationLink {
|
||||
BookChapterListView(book: book)
|
||||
} label: {
|
||||
BookCard(book: book)
|
||||
}
|
||||
.tint(.primary)
|
||||
@@ -29,12 +31,6 @@ struct BookLibraryView: View {
|
||||
}
|
||||
.navigationTitle("Books")
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.navigationDestination(for: Book.self) { book in
|
||||
BookChapterListView(book: book)
|
||||
}
|
||||
.navigationDestination(for: BookChapter.self) { chapter in
|
||||
BookReaderView(chapter: chapter)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user