-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathHomeSectionListRowView.swift
More file actions
62 lines (52 loc) · 1.97 KB
/
HomeSectionListRowView.swift
File metadata and controls
62 lines (52 loc) · 1.97 KB
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
//
// HomeSectionListRowView.swift
// berkeley-mobile
//
// Created by Baurzhan on 3/2/25.
// Copyright © 2025 ASUC OCTO. All rights reserved.
//
import SwiftUI
struct HomeSectionListRowView: View {
var rowItem: SearchItem & HasLocation & HasImage
var body: some View {
HStack {
VStack(alignment: .leading) {
Text(rowItem.searchName)
.foregroundStyle(Color(BMColor.blackText))
.font(Font(BMFont.bold(18)))
Spacer()
HStack {
Group {
openClosedStatusView
distanceLabelView
}
.applyHomeDrawerRowAttributesStyle()
}
}
.frame(height: 74)
Spacer()
imageView
}
.padding()
.shadowfy()
}
@ViewBuilder
private var openClosedStatusView: some View {
if let itemWithOpenClosedStatus = rowItem as? (any HasOpenClosedStatus) {
OpenClosedStatusView(status: itemWithOpenClosedStatus.isOpen ? .open : .closed)
}
}
private var distanceLabelView: some View {
DistanceLabelView(distance: rowItem.distanceToUser)
}
private var imageView: some View {
BMCachedAsyncImageView(imageURL: rowItem.imageURL, placeholderImage: BMConstants.doeGladeImage, aspectRatio: .fill)
.frame(maxWidth: 80, maxHeight: 80)
.clipShape(RoundedRectangle(cornerRadius: 12))
}
}
#Preview {
let foothillDiningHall = BMDiningHall(name: "Foothill", address: nil, phoneNumber: nil, imageLink: "https://firebasestorage.googleapis.com/v0/b/berkeley-mobile.appspot.com/o/images%2FFoothill.jpg?alt=media&token=b645d675-6f51-45ea-99f7-9b36576e14b7", hours: [], latitude: 37.87538, longitude: -122.25612109999999)
return HomeSectionListRowView(rowItem: foothillDiningHall)
.padding(40)
}