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{
|
struct VRTNuView: View{
|
||||||
var vrtNu: VRTNu
|
var vrtNu: VRTNu
|
||||||
|
@State var searchText: String = ""
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
NavigationView(){
|
NavigationView(){
|
||||||
List(vrtNu.getShows(), id: \.title){ show in
|
VStack{
|
||||||
NavigationLink(destination: ShowView(show: show)){
|
SearchBar(text: $searchText)
|
||||||
HStack{
|
.padding(.top, -30)
|
||||||
AsyncImage(url: show.imageURL,placeholder: {
|
List(vrtNu.getShows().filter({ searchText.isEmpty ? true : $0.showName.contains(searchText) }), id: \.title){ show in
|
||||||
//Image(name: "loading")
|
NavigationLink(destination: ShowView(show: show)){
|
||||||
Text("Loading...")
|
HStack{
|
||||||
}, image:{
|
AsyncImage(url: show.imageURL,placeholder: {
|
||||||
Image(uiImage:$0)
|
//Image(name: "loading")
|
||||||
.resizable()
|
Text("Loading...")
|
||||||
}).aspectRatio(contentMode: .fit).frame(width: 480, height:300)
|
}, image:{
|
||||||
VStack(alignment: .leading){
|
Image(uiImage:$0)
|
||||||
Text(show.title)
|
.resizable()
|
||||||
.padding()
|
}).aspectRatio(contentMode: .fit).frame(width: 480, height:300)
|
||||||
Text(show.showURL.absoluteString)
|
VStack(alignment: .leading){
|
||||||
|
Text(show.title)
|
||||||
|
.padding()
|
||||||
|
Text(show.showURL.absoluteString)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.navigationTitle("Browse VRT Nu")//.listStyle(DefaultListStyle())
|
}.navigationTitle("Browse VRT Nu")//.listStyle(DefaultListStyle())
|
||||||
|
|
38
vrtnu/vrtnu/dependencies/SearchBar.swift
Normal file
38
vrtnu/vrtnu/dependencies/SearchBar.swift
Normal file
|
@ -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 a new issue