Skip to content

Commit

Permalink
Implemented UI View and filtering function
Browse files Browse the repository at this point in the history
TODO : Fix Search Bar appearance
  • Loading branch information
martingdela committed Feb 19, 2020
1 parent 29f6079 commit 26fa54d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 8 additions & 2 deletions FlinkChallenge/FlinkChallenge/Views/CharacterFeedView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,16 @@ import SwiftUI

struct CharacterFeedView: View {
@ObservedObject var characterFeed = CharacterFeed()
@State private var searchText : String = ""

var body: some View {
VStack {
List(characterFeed) { (character: APICharacter) in
ZStack {
SearchBar(text: $searchText)
List {
ForEach(self.characterFeed.filter {
self.searchText.isEmpty ? true : $0.name!.lowercased().contains(self.searchText.lowercased())
}, id: \.id) { character in
ZStack {
Card(character: character).frame(width: 300, height: 300)
.onAppear {
self.characterFeed.loadMoreCharacters(currentItem: character)
Expand All @@ -27,6 +32,7 @@ struct CharacterFeedView: View {
}
}
}
}

struct CharacterFeedView_Previews: PreviewProvider {
static var previews: some View {
Expand Down
2 changes: 2 additions & 0 deletions FlinkChallenge/FlinkChallenge/Views/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import SwiftUI

struct ContentView: View {


var body: some View {
NavigationView {
CharacterFeedView().navigationBarTitle(Text("Characters"))
Expand Down

0 comments on commit 26fa54d

Please sign in to comment.