-
Notifications
You must be signed in to change notification settings - Fork 96
/
Copy pathHomeList.swift
128 lines (114 loc) · 3.63 KB
/
HomeList.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
//
// HomeList.swift
// DesignCode
//
// Created by Mithun x on 7/13/19.
// Copyright © 2019 Mithun. All rights reserved.
//
import SwiftUI
struct HomeList: View {
var courses = coursesData
var body: some View {
ScrollView {
VStack {
HStack {
VStack(alignment: .leading) {
Text("Courses")
.font(.largeTitle)
.fontWeight(.heavy)
Text("22 Courses")
.color(.gray)
}
Spacer()
}
.padding(.leading, 70.0)
ScrollView(.horizontal, showsIndicators: false) {
HStack(spacing: 30.0) {
ForEach(courses) { item in
PresentationLink(destination: ContentView()) {
GeometryReader { geometry in
CourseView(title: item.title,
image: item.image,
color: item.color,
shadowColor: item.shadowColor)
.rotation3DEffect(Angle(degrees: Double(geometry.frame(in: .global).minX - 40) / -20), axis: (x: 0, y: 10.0, z: 0))
}
.frame(width: 246, height: 150)
}
}
}
.padding(.leading, 40)
.padding(.top, 30)
Spacer()
}
.frame(height: 450)
CertificateRow()
}
.padding(.top, 78)
}
}
}
#if DEBUG
struct HomeList_Previews: PreviewProvider {
static var previews: some View {
HomeList()
}
}
#endif
struct CourseView: View {
var title = "Build an app with SwiftUI"
var image = "Illustration1"
var color = Color("background3")
var shadowColor = Color("backgroundShadow3")
var body: some View {
return VStack(alignment: .leading) {
Text(title)
.font(.title)
.fontWeight(.bold)
.color(.white)
.padding(30)
.lineLimit(4)
.padding(.trailing, 50)
Spacer()
Image(image)
.resizable()
.renderingMode(.original)
.aspectRatio(contentMode: .fit)
.frame(width: 246, height: 150)
.padding(.bottom, 30)
}
.background(color)
.cornerRadius(30)
.frame(width: 246, height: 360)
.shadow(color: shadowColor, radius: 20, x: 0, y: 20)
}
}
struct Course: Identifiable {
var id = UUID()
var title: String
var image: String
var color: Color
var shadowColor: Color
}
let coursesData = [
Course(title: "Build an app with SwiftUI",
image: "Illustration1",
color: Color("background3"),
shadowColor: Color("backgroundShadow3")),
Course(title: "Design and animate your UI",
image: "Illustration2",
color: Color("background4"),
shadowColor: Color("backgroundShadow4")),
Course(title: "Swift UI Advanced",
image: "Illustration3",
color: Color("background7"),
shadowColor: Color(hue: 0.677, saturation: 0.701, brightness: 0.788, opacity: 0.5)),
Course(title: "Framer Playground",
image: "Illustration4",
color: Color("background8"),
shadowColor: Color(hue: 0.677, saturation: 0.701, brightness: 0.788, opacity: 0.5)),
Course(title: "Flutter for Designers",
image: "Illustration5",
color: Color("background9"),
shadowColor: Color(hue: 0.677, saturation: 0.701, brightness: 0.788, opacity: 0.5)),
]