Craft search experiences in SwiftUI

RSS for tag

Discuss the WWDC21 session Craft search experiences in SwiftUI.

Posts under wwdc21-10176 tag

3 Posts

Post

Replies

Boosts

Views

Activity

SwiftUI isSearching environment value not updating properly
Hello - I am new to Swift so my apologies in advance if this is an easy fix. I am intrigued by the new .searchable modifier in SwiftUI as this seems like the most logical way to implement search in a SwiftUI-based app (instead of integrating with UIKit etc.) I tried running the following code import SwiftUI struct SearchableView: View {     @State var searchTerm: String = ""          @Environment(\.isSearching)     private var isSearching: Bool          var body: some View {         NavigationView {             Text("\(String(describing: isSearching))")         }.searchable(text: $searchTerm)     } } However, the value of isSearching doesn't seem to be changing when I click on the search bar and start typing. I tried adding @State to the isSearching variable but this resulted in an error. I would be very grateful for any suggestions! Thank you
2
0
3.4k
Apr ’22
How to make search bar in iOS 15 appear by default?
I started to develop an application using iOS15 and the new .searchable modifier. I have a simple layout with some placeholder results on the main page and a search field attached to the navigationBar. Currently, if the user loads the page and looks at the results (even scrolls a bit) will not be able find the search field as it's hidden by default. The user needs to scroll in reverse for the search bar to appear. How is this a good for UX? The only workaround is the drawer placement with .always, but that will make the navigation title inline. I really want to achieve the result from the Notes app, that has the search bar visible all the time. Any workaround? Was this feature really tested by anyone in a real app?
0
0
1.1k
Nov ’21
SwiftUI isSearching environment value not updating properly
Hello - I am new to Swift so my apologies in advance if this is an easy fix. I am intrigued by the new .searchable modifier in SwiftUI as this seems like the most logical way to implement search in a SwiftUI-based app (instead of integrating with UIKit etc.) I tried running the following code import SwiftUI struct SearchableView: View {     @State var searchTerm: String = ""          @Environment(\.isSearching)     private var isSearching: Bool          var body: some View {         NavigationView {             Text("\(String(describing: isSearching))")         }.searchable(text: $searchTerm)     } } However, the value of isSearching doesn't seem to be changing when I click on the search bar and start typing. I tried adding @State to the isSearching variable but this resulted in an error. I would be very grateful for any suggestions! Thank you
Replies
2
Boosts
0
Views
3.4k
Activity
Apr ’22
How to make search bar in iOS 15 appear by default?
I started to develop an application using iOS15 and the new .searchable modifier. I have a simple layout with some placeholder results on the main page and a search field attached to the navigationBar. Currently, if the user loads the page and looks at the results (even scrolls a bit) will not be able find the search field as it's hidden by default. The user needs to scroll in reverse for the search bar to appear. How is this a good for UX? The only workaround is the drawer placement with .always, but that will make the navigation title inline. I really want to achieve the result from the Notes app, that has the search bar visible all the time. Any workaround? Was this feature really tested by anyone in a real app?
Replies
0
Boosts
0
Views
1.1k
Activity
Nov ’21