-
Notifications
You must be signed in to change notification settings - Fork 1
/
HomeView.swift
110 lines (92 loc) · 3.02 KB
/
HomeView.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
//
// HomeView.swift
// BuildNetflixClone
//
// Created by Siddhant Mulajkar on 01/03/21.
//
import SwiftUI
struct HomeView: View {
var vm = HomeVM()
let screen = UIScreen.main.bounds
var body: some View {
ZStack{
Color.black
.edgesIgnoringSafeArea(/*@START_MENU_TOKEN@*/.all/*@END_MENU_TOKEN@*/)
// main vstack
ScrollView(showsIndicators: false) {
LazyVStack {
TopRowButtons()
TopMoviePreview(movie: exampleMovie5)
.frame(width: screen.width)
.padding(.top, -110)
.zIndex(-1)
ForEach(vm.allCategories, id: \.self) { category in
VStack {
HStack {
Text(category)
.font(.title3)
.bold()
Spacer()
}
ScrollView(.horizontal, showsIndicators: false) {
LazyHStack{
ForEach(vm.getMovie(forCat: category)) { movie in
StandardHomeMovie(movie: movie)
.frame(width: 100, height: 200)
.padding(.horizontal, 20)
}
}
}
}
}
}
}
}
.foregroundColor(.white)
}
}
struct HomeView_Previews: PreviewProvider {
static var previews: some View {
HomeView()
}
}
struct TopRowButtons: View {
var body: some View {
HStack {
Spacer()
Button(action: {
//click action
}, label: {
Image("netflix_logo")
.resizable()
.scaledToFit()
.frame(width: 50)
})
.buttonStyle(PlainButtonStyle())
Spacer()
Button(action: {
//click action
}, label: {
Text("TV Shows")
})
.buttonStyle(PlainButtonStyle())
Spacer()
Button(action: {
//click action
}, label: {
Text("Movies")
})
.buttonStyle(PlainButtonStyle())
Spacer()
Button(action: {
//click action
}, label: {
Text("My List")
})
.buttonStyle(PlainButtonStyle())
Spacer()
}
.padding(.leading, 10)
.padding(.trailing, 20)
}
}