Skip to content

Commit

Permalink
Data and Image Literal
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick committed Jul 16, 2021
1 parent b34081e commit 43869ef
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions DesignCode/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ struct HomeView: View {

ScrollView(.horizontal, showsIndicators: false) {
HStack(spacing: 30) {
ForEach(/*@START_MENU_TOKEN@*/0 ..< 5/*@END_MENU_TOKEN@*/) { item in
SectionView()
ForEach(sectionData) { item in
SectionView(section: item)
}
}
.padding(30)
Expand All @@ -44,30 +44,47 @@ struct HomeView_Previews: PreviewProvider {
}

struct SectionView: View {
var section: Section
var body: some View {
VStack {
HStack(alignment: .top) {
Text("Prototype designs in SwiftUI")
Text(section.title)
.font(.system(size: 24, weight: .bold))
.frame(width: 160, alignment: .leading)
.foregroundColor(.white)
Spacer()
Image("Logo1")
Image(section.logo)
}
Text("18 sections".uppercased())
Text(section.text.uppercased())
.frame(maxWidth: .infinity, alignment: .leading)


Image("Card1")
section.image
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 210)
}
.padding(.top, 20)
.padding(.horizontal, 20)
.frame(width: 275, height: 275)
.background(Color("card1"))
.background(section.color)
.cornerRadius(30)
.shadow(color: Color("card1").opacity(0.3), radius: 20, x: 0, y: 20)
.shadow(color: section.color.opacity(0.3), radius: 20, x: 0, y: 20)
}
}


struct Section: Identifiable {
var id = UUID()
var title: String
var text: String
var logo: String
var image: Image
var color: Color

}

let sectionData = [
Section(title: "Prototype designs in SwiftUI", text: "18 sections", logo: "Logo1", image: Image("Card2"), color: Color("card2")),
Section(title: "Bruagttias and hoes", text: "22 sections", logo: "Logo2", image: Image("Card2"), color: Color("card1"))
]

0 comments on commit 43869ef

Please sign in to comment.