-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWebItemRow.swift
More file actions
66 lines (59 loc) · 1.68 KB
/
Copy pathWebItemRow.swift
File metadata and controls
66 lines (59 loc) · 1.68 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
63
64
65
66
//
// WebItemRow.swift
// DevLog
//
// Created by 최윤진 on 2/24/26.
//
import SwiftUI
struct WebItemRow: View {
@Environment(\.sceneWidth) private var sceneWidth
let item: WebPageItem
let showsChevron: Bool
var body: some View {
HStack {
thumbnail
.frame(width: sceneWidth * 0.08, height: sceneWidth * 0.08)
.clipShape(RoundedRectangle(cornerRadius: 10))
VStack(alignment: .leading) {
Text(item.title)
.foregroundStyle(Color.primary)
.multilineTextAlignment(.leading)
.lineLimit(2)
Text(item.displayURL)
.foregroundStyle(Color.blue)
.underline()
}
Spacer()
if showsChevron {
Image(systemName: "chevron.right")
.font(.caption2.bold())
.foregroundStyle(.gray)
}
}
.padding(.vertical, 4)
}
@ViewBuilder
private var thumbnail: some View {
if let imageURL = item.imageURL {
AsyncImage(url: imageURL) { phase in
switch phase {
case .success(let image):
image
.resizable()
.scaledToFill()
case .empty:
ProgressView()
default:
placeholderImage
}
}
} else {
placeholderImage
}
}
private var placeholderImage: some View {
Image(systemName: "globe")
.resizable()
.scaledToFit()
}
}