-
Notifications
You must be signed in to change notification settings - Fork 0
/
AnimalListView.swift
54 lines (43 loc) · 1.12 KB
/
AnimalListView.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
//
// AnimalListView.swift
// AfricaApp
//
// Created by Rubén García Figueroa on 17/11/21.
//
import SwiftUI
struct AnimalListItemView: View {
// MARK: - PROPERTIES
let animal: Animal
// MARK: - BODY
var body: some View {
HStack(alignment: .center, spacing: 16) {
Image(animal.image)
.resizable()
.scaledToFill()
.frame(width: 90, height: 90)
.clipShape(
RoundedRectangle(cornerRadius: 12)
)
VStack(alignment: .leading, spacing: 8) {
Text(animal.name)
.font(.title2)
.fontWeight(.heavy)
.foregroundColor(.accentColor)
Text(animal.headline)
.font(.footnote)
.multilineTextAlignment(.leading)
.lineLimit(2)
.padding(.trailing, 8)
} //: VSTACK
} //: HSTACK
}
}
// MARK: - PREVIEW
struct AnimalListItemView_Previews: PreviewProvider {
static let animals: [Animal] = Bundle.main.decode("animals.json")
static var previews: some View {
AnimalListItemView(animal: animals[1])
.previewLayout(.sizeThatFits)
.padding()
}
}