-
-
Save sturdysturge/1840a803bac3351ea371292551746b22 to your computer and use it in GitHub Desktop.
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 | |
| @available(iOS 16.0, *) | |
| struct ContentView: View { | |
| @ObservedObject var viewModel = ViewModel() | |
| var body: some View { | |
| NavigationStack { | |
| List(viewModel.items) { item in | |
| NavigationLink(value: item.fullID?.videoID) { | |
| VStack { | |
| AsyncImage(url: item.defaultThumbnailURL) { image in | |
| image | |
| .resizable() | |
| .scaledToFit() | |
| } placeholder: { ProgressView() } | |
| Text(item.snippet?.title ?? "???") | |
| } | |
| } | |
| } | |
| .navigationDestination(for: String.self) { videoID in | |
| YTPlayer(videoID: videoID) | |
| .aspectRatio(1.3, contentMode: .fit) | |
| .frame(maxHeight:.infinity, alignment: .top) | |
| } | |
| } | |
| .submitLabel(.search) | |
| .searchable(text: $viewModel.search) | |
| .onSubmit(of: .search, viewModel.performSearch) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment