-
Notifications
You must be signed in to change notification settings - Fork 1
/
ContentView.swift
76 lines (70 loc) · 2.83 KB
/
ContentView.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//
// ContentView.swift
// MovieBook
//
// Created by Mehmet Ateş on 28.09.2021.
//
import SwiftUI
struct ContentView: View {
@ObservedObject var filmlistem : FilmArrayViewModel
@State var searchMovie = ""
@State private var isEditing = false
init(){
self.filmlistem = FilmArrayViewModel()
self.filmlistem.searchFilm(arama: "")
}
var body: some View {
NavigationView {
VStack {
TextField("Enter Movie Name",text:$searchMovie,onEditingChanged: {_ in} ,onCommit: {
self.filmlistem.searchFilm(arama: self.searchMovie.trimmingCharacters(in: .whitespacesAndNewlines).addingPercentEncoding(withAllowedCharacters: .urlHostAllowed) ?? searchMovie)
}).padding(7)
.padding(.horizontal, 25)
.background(Color(.systemGray6))
.cornerRadius(8)
.padding(.horizontal, 10)
.onTapGesture {
self.isEditing = true
}
.overlay(
HStack {
Image(systemName: "magnifyingglass")
.foregroundColor(.gray)
.frame(minWidth: 0, maxWidth: .infinity, alignment: .leading)
.padding(.leading, 15)
if isEditing {
Button(action: {
self.searchMovie = ""
}) {
Image(systemName: "multiply.circle.fill")
.foregroundColor(.gray)
.padding(.trailing, 15)
}
}
}
)
List(filmlistem.filmler , id: \.imdbID){
film in
NavigationLink(destination: DetailView(imdbId: film.imdbID)) {
VStack{
CustomImage(url: film.poster)
.frame(height:UIScreen.main.bounds.width * 1.25)
.cornerRadius(30.0)
Text(film.title)
.font(.largeTitle)
.multilineTextAlignment(.center)
Text(film.year)
.font(.subheadline)
.foregroundColor(.blue)
}
}
}
}.navigationTitle("Search")
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}