yattee/Apple TV/SearchView.swift

23 lines
510 B
Swift
Raw Normal View History

2021-06-11 12:36:26 +00:00
import SwiftUI
struct SearchView: View {
@ObservedObject private var provider = SearchedVideosProvider()
2021-06-17 10:02:39 +00:00
@EnvironmentObject private var state: AppState
2021-06-11 21:40:35 +00:00
@Binding var tabSelection: TabSelection
2021-06-11 21:11:59 +00:00
2021-06-17 10:02:39 +00:00
@State private var query = ""
2021-06-11 21:11:59 +00:00
2021-06-11 12:36:26 +00:00
var body: some View {
2021-06-17 10:02:39 +00:00
VideosView(tabSelection: $tabSelection, videos: videos)
2021-06-23 22:19:58 +00:00
.environmentObject(state)
2021-06-11 21:11:59 +00:00
.searchable(text: $query)
2021-06-11 12:36:26 +00:00
}
2021-06-11 21:54:00 +00:00
2021-06-11 21:40:35 +00:00
var videos: [Video] {
2021-06-14 18:05:02 +00:00
provider.load(query)
2021-06-11 12:36:26 +00:00
2021-06-11 21:40:35 +00:00
return provider.videos
2021-06-11 12:36:26 +00:00
}
}