-
Notifications
You must be signed in to change notification settings - Fork 1
/
TopMoviePreview.swift
90 lines (72 loc) · 2.65 KB
/
TopMoviePreview.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
//
// TopMoviePreview.swift
// BuildNetflixClone
//
// Created by Siddhant Mulajkar on 05/03/21.
//
import SwiftUI
import KingfisherSwiftUI
struct TopMoviePreview: View {
var movie: Movie
//this is for the small dot image after the main image displaying the categories
func isCategoryLast(_ cat: String) -> Bool {
let catCount = movie.categories.count //4
//if 0 + 1 !=4
if let index = movie.categories.firstIndex(of: cat) {
if index + 1 != catCount {
return false
}
}
return true
}
var body: some View {
ZStack {
KFImage(movie.thumbnailURL)
.resizable()
.scaledToFill()
.clipped()
VStack {
Spacer()
HStack{
ForEach(movie.categories, id: \.self) { category in
HStack {
Text(category)
.font(.footnote)
if !isCategoryLast(category) {
Image(systemName: "circle.fill")
.foregroundColor(/*@START_MENU_TOKEN@*/.blue/*@END_MENU_TOKEN@*/)
.font(.system(size: 3))
}
}
}
}
HStack {
Spacer()
SmallVerticalButton(text: "My List", isOnImage: "checkmark", isOffImage: "plus", isOn: true) {
//action goes here
}
Spacer()
WhiteButton(text: "play", imageName: "play.fill") {
// play button code goes here
}
.frame(width: 120)
Spacer()
SmallVerticalButton(text: "Info", isOnImage: "info.circle", isOffImage: "info.circle", isOn: true) {
//detail action again goes here
}
Spacer()
}
}
.background(
LinearGradient.blackOpacityGradient
.padding(.top, 250)
)
}
.foregroundColor(.white)
}
}
struct TopMoviePreview_Previews: PreviewProvider {
static var previews: some View {
TopMoviePreview(movie: exampleMovie1)
}
}