started working on searchbar, works but cannot be focussed after focus us lost
This commit is contained in:
parent
24a495625e
commit
1a431c1fb7
|
@ -53,24 +53,30 @@ struct LoginView: View{
|
|||
}
|
||||
struct VRTNuView: View{
|
||||
var vrtNu: VRTNu
|
||||
@State var searchText: String = ""
|
||||
|
||||
var body: some View {
|
||||
NavigationView(){
|
||||
List(vrtNu.getShows(), id: \.title){ show in
|
||||
NavigationLink(destination: ShowView(show: show)){
|
||||
HStack{
|
||||
AsyncImage(url: show.imageURL,placeholder: {
|
||||
//Image(name: "loading")
|
||||
Text("Loading...")
|
||||
}, image:{
|
||||
Image(uiImage:$0)
|
||||
.resizable()
|
||||
}).aspectRatio(contentMode: .fit).frame(width: 480, height:300)
|
||||
VStack(alignment: .leading){
|
||||
Text(show.title)
|
||||
.padding()
|
||||
Text(show.showURL.absoluteString)
|
||||
VStack{
|
||||
SearchBar(text: $searchText)
|
||||
.padding(.top, -30)
|
||||
List(vrtNu.getShows().filter({ searchText.isEmpty ? true : $0.showName.contains(searchText) }), id: \.title){ show in
|
||||
NavigationLink(destination: ShowView(show: show)){
|
||||
HStack{
|
||||
AsyncImage(url: show.imageURL,placeholder: {
|
||||
//Image(name: "loading")
|
||||
Text("Loading...")
|
||||
}, image:{
|
||||
Image(uiImage:$0)
|
||||
.resizable()
|
||||
}).aspectRatio(contentMode: .fit).frame(width: 480, height:300)
|
||||
VStack(alignment: .leading){
|
||||
Text(show.title)
|
||||
.padding()
|
||||
Text(show.showURL.absoluteString)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}.navigationTitle("Browse VRT Nu")//.listStyle(DefaultListStyle())
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
//
|
||||
// SearchBar.swift
|
||||
// vrtnu
|
||||
//
|
||||
// Created by Jens Timmerman on 29/10/2020.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct SearchBar: View {
|
||||
@Binding var text: String
|
||||
|
||||
@State private var isEditing = false
|
||||
|
||||
var body: some View {
|
||||
HStack {
|
||||
|
||||
TextField("Search ...", text: $text)
|
||||
.padding(7)
|
||||
.padding(.horizontal, 25)
|
||||
.cornerRadius(8).overlay(
|
||||
HStack {
|
||||
Image(systemName: "magnifyingglass")
|
||||
.foregroundColor(.gray)
|
||||
.frame(minWidth: 0, maxWidth: .infinity, alignment: .leading)
|
||||
.padding(.leading, 8)
|
||||
}
|
||||
)
|
||||
.padding(.horizontal, 10)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct SearchBar_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
SearchBar(text: .constant(""))
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue