Your Second iOS & SwiftUI App

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

Part 3: Managing Rows

22. Challenge: New Book Sheet

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: 21. ForEach Next episode: 23. Environment

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've reached locked video content where the transcript will be shown as obfuscated text.

So! You’ve got a view that says “Add New Book”! Alas, it doesn’t actually do that. Yet!

@Published var 
@Published var 
class Book: ObservableObject {
  @Published var title: String
  @Published var author: String
  @Published var microReview: String
struct NewBookView: View {
  var book = Book(title: "", author: "")

  var body: some View {
@ObservedObject var book = Book(title: "", author: "")
  var body: some View {
    VStack {
      
    }
  }
    VStack {
      TextField("Title", text: $book.title)
    }
      TextField("Title", text: $book.title)
      TextField("Author", text: $book.author)
    }
    })
    .padding()
  }
      }

      ReviewAndImageStack()

      Spacer()
      }

      ReviewAndImageStack()
    }
        updateButton
      }

      Spacer()
    }
      ReviewAndImageStack()
    }
    .padding()
  }
}
      Spacer()
    }
    .sheet(isPresented: $showingImagePicker) {
      PHPickerViewController.View(image: $image)
    }
    .confirmationDialog(isPresented: $showingAlert) {
    }
  }
}
  @Binding var image: UIImage?

  var body: some View {
struct ReviewAndImageStack: View {
  @State var showingImagePicker = false
  @State var showingDialog = false

  var body: some View {
struct ReviewAndImageStack: View {
  @ObservedObject var book: Book
  @Binding var image: UIImage?
  @State var showingImagePicker = false
ReviewAndImageStack(book: book, image: $image)
/// THE SOFTWARE.

import class PhotosUI.PHPickerViewController
import SwiftUI
ReviewAndImageStack(book: .init(), image: .constant(nil)
    ReviewAndImageStack(book: .init(), image: .constant(nil))
      .padding(.horizontal)
  }
      .padding(.horizontal)
      .previewedInAllColorSchemes
  }
  @ObservedObject var book = Book(title: "", author: "")
  @State var image: Image? = nil

  var body: some View {
      TextField("Author", text: $book.author)
      ReviewAndImageStack(book: book, image: $image)
    })
VStack(spacing: 24, content: {
struct ContentView: View {
  @State var addingNewBook = false
  @State var library = Library()
        Button {
          addingNewBook = true
        } label: {
        .padding(.vertical, 8)
        .sheet(isPresented: /*@START_MENU_TOKEN@*//*@PLACEHOLDER=Is Presented@*/.constant(false)/*@END_MENU_TOKEN@*/, content: {
          /*@START_MENU_TOKEN@*//*@PLACEHOLDER=Content@*/Text("Sheet Content")/*@END_MENU_TOKEN@*/
        })

        ForEach(library.sortedBooks) { book in
.sheet(isPresented: $addingNewBook, content: {
        .sheet(
          isPresented: $addingNewBook,
          content: NewBookView.init
        )

        ForEach(library.sortedBooks) { book in