Last active
December 20, 2023 15:41
-
-
Save benigumocom/fca3016e1f65934b0494bf3ea483989e to your computer and use it in GitHub Desktop.
Jetpack Compose から SwiftUI に来ましたが今の謎をどうにかしたい 😩 👉 https://android.benigumo.com/20231221/swiftui-property-wrapper/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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