Your Second iOS & SwiftUI App

Nov 4 2021 · Swift 5.5, iOS 15, Xcode 13

Part 1: List View Fundamentals

08. Challenge: View Reuse

Episode complete

Play next episode

Next
About this episode

Leave a rating/review

See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 07. Navigation Next episode: 09. Conclusion

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

You’re now displaying what we’re calling a “detail view” for a book. But after you navigate to it, you’re actually seeing fewer details than in the list. That doesn’t make any sense!

        VStack(alignment: .leading) {

      HStack {
        Book.Image(title: book.title)
        TitleAndAuthorStack()
      }
    ContentView()
  }
}

struct TitleAndAuthorStack: View {
struct TitleAndAuthorStack: View {
  let book: Book

  var body: some View {
TitleAndAuthorStack(book: book)
        TitleAndAuthorStack(book: book)
          .lineLimit(1)
import SwiftUI

struct TitleAndAuthorStack: View {
  let book: Book

  var body: some View {
    VStack(alignment: .leading) {
      Text(book.title)
        .font(.title2)
      Text(book.author)
        .font(.title3)
        .foregroundColor(.secondary)
    }
    .lineLimit(1)
  }
}

extension Book {
    VStack {
      TitleAndAuthorStack(book: book)
      Book.Image(title: book.title)
    let title: String
    var size: CGFloat?

    var body: some View {
.frame(width: size, height: size)
      Spacer()
    }
    .padding()
  }
VStack(alignment: .leading) {
Book.Image(title: book.title, size: 80)
struct TitleAndAuthorStack: View {
  let book: Book
  let titleFont: Font
  let authorFont: Font
        .font(titleFont)
      Text(book.author)
        .font(authorFont)
        Book.Image(title: book.title, size: 80)

        TitleAndAuthorStack(
          book: book,
          titleFont: .title2,
          authorFont: .title3
        )
        .lineLimit(1)
    VStack(alignment: .leading) {
      TitleAndAuthorStack(
        book: book,
        titleFont: .title,
        authorFont: .title2
      )
      Book.Image(title: book.title)
    VStack {
      TitleAndAuthorStack(
        book: .init(),
        titleFont: .title,
        authorFont: .title2
      )
      Book.Image(title: Book().title)