Skip to content

Instantly share code, notes, and snippets.

@artur-ios-dev
Created February 3, 2020 20:45
Show Gist options
  • Select an option

  • Save artur-ios-dev/5bd32381de3e170298976d392a0d8d86 to your computer and use it in GitHub Desktop.

Select an option

Save artur-ios-dev/5bd32381de3e170298976d392a0d8d86 to your computer and use it in GitHub Desktop.

Revisions

  1. artur-ios-dev created this gist Feb 3, 2020.
    20 changes: 20 additions & 0 deletions searchbar_usage.swift
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    struct SearchView: View {
    let array = "SwiftUI is great but some views might need an extra work".components(separatedBy: " ")

    @State private var searchText = ""

    var body: some View {
    VStack {
    SearchBar(text: $searchText)

    List {
    ForEach(array.filter{$0.hasPrefix(searchText) || searchText == ""}, id:\.self) {
    searchText in Text(searchText)
    }
    }
    .gesture(DragGesture().onChanged { _ in
    UIApplication.shared.endEditing(true)
    })
    }
    }
    }