$30 off During Our Annual Pro Sale. View Details »

The Search is Over! DevCommunity Summit 2021

The Search is Over! DevCommunity Summit 2021

Slides for my talk "The Search is Over! Quickly Build a Searchable List Filter Using SwiftUI". Presented to DevCommunity Summit on October 1, 2021.

In this talk, I go over how to build a searchable list filter quickly, easily, and with minimal code using SwiftUI.

Vui Nguyen

October 01, 2021
Tweet

Other Decks in Programming

Transcript

  1. The Search is Over! Quickly Build a Searchable List Filter

    Using SwiftUI Presented by: Vui Nguyen, @sunfishgurl, sunfishempire.com DevCommunity Summit 2021
  2. Let’s Dive Right In …. What Problem Are We Solving?

    • Demo • Problem: how to build a searchable filter on a list ◦ Do this quickly, easily, and with minimal code • Can you imagine building this in UIKit?!
  3. The Problems with UIKit …. More Code, More Problems •

    How to build that list without so much code?! 😰 • UITableView, anyone? • Don’t forget delegates like UITableViewDelegate, UITableViewSource, etc • How to update UI easily when data changes? 🍝 • SwiftUI to the rescue!! 😍
  4. Overview • Demo Part I: Defining the Problem • How

    does SwiftUI make solving my problem easier? • Code Overview • BONUS: Demo Part II • Key Highlights in SwiftUI Solution • Questions?
  5. Code Overview • UI: ◦ ContentView, FilterView, CheckboxView • Filtering:

    ◦ CheckboxView: toggle() ◦ FilterViewModel: checkFilter() • Update UI: ◦ FilterViewModel: @Published filteredListResults ◦ ContentView: (listening for changes to & displaying updated) filteredListResults ◦ 🤯
  6. BONUS: Demo Part II • Surprise! 🎁 • Your gift

    for staying until the end: None of the Above filter
  7. Key Highlights in SwiftUI Solution • A LOT less code

    to build the UI • Making use of Set instead of Array to build filter list • Using Swift functional method filter() makes actual filtering easy!
  8. Key Highlights in SwiftUI Solution • @Published filteredListResults : list

    view listens for changes in filtered data and updates itself without messaging list view directly • @Published noneFilterSelected : filter checkboxes listen for changes in None filter and update themselves without messaging checkboxes directly • NO completion handlers or delegates needed!! • SwiftUI FTW! 💪💫
  9. Resources • Source code for project: https://github.com/vuinguyen/SearchIsOver • Checkbox code:

    https://makeapppie.com/2019/10/16/checkboxes-in-swiftui/
  10. Questions? Follow me on Twitter! Vui Nguyen, @sunfishgurl