Skip to content

Commit f584467

Browse files
author
Mithun
committed
Modal Presentation
1 parent 73ba611 commit f584467

File tree

1 file changed

+47
-8
lines changed

1 file changed

+47
-8
lines changed

DesignCode/HomeList.swift

+47-8
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,22 @@
99
import SwiftUI
1010

1111
struct HomeList: View {
12+
13+
var courses = coursesData
14+
1215
var body: some View {
1316
ScrollView(.horizontal, showsIndicators: false) {
14-
HStack {
15-
ForEach(/*@START_MENU_TOKEN@*/0 ..< 5/*@END_MENU_TOKEN@*/) { _ in
16-
CourseView()
17+
HStack(spacing: 30.0) {
18+
ForEach(courses) { item in
19+
PresentationLink(destination: ContentView()) {
20+
CourseView(title: item.title,
21+
image: item.image,
22+
color: item.color,
23+
shadowColor: item.shadowColor)
24+
}
1725
}
1826
}
27+
.padding(.leading, 30)
1928
Spacer()
2029
}
2130
}
@@ -30,23 +39,53 @@ struct HomeList_Previews: PreviewProvider {
3039
#endif
3140

3241
struct CourseView: View {
42+
43+
var title = "Build an app with SwiftUI"
44+
var image = "Illustration1"
45+
var color = Color("background3")
46+
var shadowColor = Color("backgroundShadow3")
47+
3348
var body: some View {
3449
return VStack(alignment: .leading) {
35-
Text("Build an app with SwiftUI")
50+
Text(title)
3651
.font(/*@START_MENU_TOKEN@*/ .title/*@END_MENU_TOKEN@*/)
3752
.fontWeight(/*@START_MENU_TOKEN@*/ .bold/*@END_MENU_TOKEN@*/)
3853
.color(.white)
3954
.padding(20)
4055
.lineLimit(4)
41-
.frame(width: 150)
56+
.padding(.trailing, 50)
4257

4358
Spacer()
4459

45-
Image("Illustration1")
60+
Image(image)
61+
.resizable()
62+
.renderingMode(.original)
63+
.aspectRatio(contentMode: .fit)
64+
.frame(width: 246, height: 200)
65+
.padding(.bottom, 30)
4666
}
47-
.background(Color("background3"))
67+
.background(color)
4868
.cornerRadius(30)
4969
.frame(width: 246, height: 360)
50-
.shadow(color: Color("backgroundShadow3"), radius: 20, x: 0, y: 20)
70+
.shadow(color: shadowColor, radius: 20, x: 0, y: 20)
5171
}
5272
}
73+
74+
struct Course: Identifiable {
75+
var id = UUID()
76+
var title: String
77+
var image: String
78+
var color: Color
79+
var shadowColor: Color
80+
}
81+
82+
let coursesData = [
83+
Course(title: "Build an app with SwiftUI",
84+
image: "Illustration1",
85+
color: Color("background3"),
86+
shadowColor: Color("backgroundShadow3")),
87+
Course(title: "Design Course",
88+
image: "Illustration2",
89+
color: Color("background4"),
90+
shadowColor: Color("backgroundShadow4"))
91+
]

0 commit comments

Comments
 (0)