Skip to content

Instantly share code, notes, and snippets.

@benigumocom
Last active December 20, 2023 15:41
Show Gist options
  • Save benigumocom/fca3016e1f65934b0494bf3ea483989e to your computer and use it in GitHub Desktop.
Save benigumocom/fca3016e1f65934b0494bf3ea483989e to your computer and use it in GitHub Desktop.
Jetpack Compose から SwiftUI に来ましたが今の謎をどうにかしたい 😩 👉 https://android.benigumo.com/20231221/swiftui-property-wrapper/
import SwiftUI
import SwiftData
import BackyardBirdsData
struct BirdsSearchResults<Content: View>: View {
@Binding var searchText: String
var content: (Bird) -> Content
@Query(sort: \Bird.creationDate) private var birds: [Bird]
var body: some View {
let filtered = searchText.isEmpty ? birds : birds.filter { bird in
bird.speciesName.contains(searchText)
}
ForEach(filtered) { bird in
content(bird)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment