Skip to content

Commit 809268a

Browse files
authored
Merge pull request #153 from YAPP-Github/fix/#152-fetch-url-image
2 parents e12c070 + 495989f commit 809268a

File tree

3 files changed

+78
-42
lines changed

3 files changed

+78
-42
lines changed

Projects/App/ShareExtension/Info.plist

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@
22
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33
<plist version="1.0">
44
<dict>
5-
<key>TeamID</key>
6-
<string>$(TeamID)</string>
7-
<key>GIDClientID</key>
8-
<string>$(GIDClientID)</string>
95
<key>AppleKeyID</key>
106
<string>$(AppleKeyID)</string>
7+
<key>CFBundleDisplayName</key>
8+
<string>Pokit</string>
9+
<key>CFBundleExecutable</key>
10+
<string>$(EXECUTABLE_NAME)</string>
11+
<key>CFBundleIdentifier</key>
12+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
13+
<key>CFBundleName</key>
14+
<string>Pokit</string>
15+
<key>CFBundleShortVersionString</key>
16+
<string>1.0.4</string>
1117
<key>CFBundleURLTypes</key>
1218
<array>
1319
<dict>
@@ -19,34 +25,30 @@
1925
</array>
2026
</dict>
2127
</array>
22-
<key>CFBundleExecutable</key>
23-
<string>$(EXECUTABLE_NAME)</string>
24-
<key>CFBundleIdentifier</key>
25-
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
2628
<key>CFBundleVersion</key>
2729
<string>1</string>
28-
<key>CFBundleName</key>
29-
<string>Pokit</string>
30-
<key>CFBundleDisplayName</key>
31-
<string>Pokit</string>
30+
<key>GIDClientID</key>
31+
<string>$(GIDClientID)</string>
3232
<key>NSExtension</key>
3333
<dict>
3434
<key>NSExtensionAttributes</key>
3535
<dict>
3636
<key>NSExtensionActivationRule</key>
3737
<dict>
38+
<key>NSExtensionActivationSupportsText</key>
39+
<true/>
3840
<key>NSExtensionActivationSupportsWebPageWithMaxCount</key>
3941
<integer>1000</integer>
4042
<key>NSExtensionActivationSupportsWebURLWithMaxCount</key>
4143
<integer>1000</integer>
42-
<key>NSExtensionActivationSupportsText</key>
43-
<true/>
4444
</dict>
4545
</dict>
46-
<key>NSExtensionPrincipalClass</key>
47-
<string>$(PRODUCT_MODULE_NAME).ShareViewController</string>
4846
<key>NSExtensionPointIdentifier</key>
4947
<string>com.apple.share-services</string>
48+
<key>NSExtensionPrincipalClass</key>
49+
<string>$(PRODUCT_MODULE_NAME).ShareViewController</string>
5050
</dict>
51+
<key>TeamID</key>
52+
<string>$(TeamID)</string>
5153
</dict>
5254
</plist>

Projects/DSKit/Sources/Components/PokitLinkCard.swift

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ public struct PokitLinkCard<Item: PokitLinkCardItem>: View {
3434
@MainActor
3535
private var buttonLabel: some View {
3636
HStack(spacing: 12) {
37-
thumbleNail
37+
if let url = URL(string: link.thumbNail) {
38+
thumbleNail(url: url)
39+
} else {
40+
placeholder
41+
}
3842

3943
VStack(spacing: 8) {
4044
HStack {
@@ -105,27 +109,27 @@ public struct PokitLinkCard<Item: PokitLinkCardItem>: View {
105109
}
106110

107111
@MainActor
108-
private var thumbleNail: some View {
109-
LazyImage(url: .init(string: link.thumbNail)) { phase in
112+
private func thumbleNail(url: URL) -> some View {
113+
var request = URLRequest(url: url)
114+
request.setValue(
115+
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36",
116+
forHTTPHeaderField: "User-Agent"
117+
)
118+
119+
return LazyImage(request: .init(urlRequest: request)) { phase in
110120
Group {
111121
if let image = phase.image {
112122
image
113123
.resizable()
114124
.aspectRatio(contentMode: .fill)
115125
} else {
116-
ZStack {
117-
Color.pokit(.bg(.disable))
118-
119-
PokitSpinner()
120-
.foregroundStyle(.pokit(.icon(.brand)))
121-
.frame(width: 48, height: 48)
122-
}
126+
placeholder
123127
}
124128
}
125129
.animation(.pokitDissolve, value: phase.image)
130+
.frame(width: 124, height: 94)
131+
.clipShape(RoundedRectangle(cornerRadius: 8, style: .continuous))
126132
}
127-
.frame(width: 124, height: 94)
128-
.clipShape(RoundedRectangle(cornerRadius: 8, style: .continuous))
129133
}
130134

131135
private var divider: some View {
@@ -134,6 +138,18 @@ public struct PokitLinkCard<Item: PokitLinkCardItem>: View {
134138
.frame(height: 1)
135139
}
136140

141+
private var placeholder: some View {
142+
ZStack {
143+
Color.pokit(.bg(.disable))
144+
145+
PokitSpinner()
146+
.foregroundStyle(.pokit(.icon(.brand)))
147+
.frame(width: 48, height: 48)
148+
}
149+
.frame(width: 124, height: 94)
150+
.clipShape(RoundedRectangle(cornerRadius: 8, style: .continuous))
151+
}
152+
137153
@ViewBuilder
138154
public func divider(isFirst: Bool, isLast: Bool) -> some View {
139155
let edge: Edge.Set = isFirst ? .bottom : isLast ? .top : .vertical

Projects/Feature/FeatureRemind/Sources/Remind/RemindView.swift

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -137,25 +137,15 @@ extension RemindView {
137137
Button(action: { send(.컨텐츠_항목_눌렀을때(content: content)) }) {
138138
recommendedContentCellLabel(content: content)
139139
}
140-
141140
}
142141

143142
@ViewBuilder
144143
private func recommendedContentCellLabel(content: BaseContentItem) -> some View {
145144
ZStack(alignment: .bottom) {
146-
LazyImage(url: .init(string: content.thumbNail)) { phase in
147-
if let image = phase.image {
148-
image
149-
.resizable()
150-
} else {
151-
ZStack {
152-
Color.pokit(.bg(.disable))
153-
154-
PokitSpinner()
155-
.foregroundStyle(.pokit(.icon(.brand)))
156-
.frame(width: 48, height: 48)
157-
}
158-
}
145+
if let url = URL(string: content.thumbNail) {
146+
recommendedContentCellImage(url: url)
147+
} else {
148+
imagePlaceholder
159149
}
160150

161151
LinearGradient(
@@ -205,6 +195,34 @@ extension RemindView {
205195
.clipShape(RoundedRectangle(cornerRadius: 12, style: .continuous))
206196
}
207197

198+
@MainActor
199+
private func recommendedContentCellImage(url: URL) -> some View {
200+
var request = URLRequest(url: url)
201+
request.setValue(
202+
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36",
203+
forHTTPHeaderField: "User-Agent"
204+
)
205+
206+
return LazyImage(request: .init(urlRequest: request)) { phase in
207+
if let image = phase.image {
208+
image
209+
.resizable()
210+
} else {
211+
imagePlaceholder
212+
}
213+
}
214+
}
215+
216+
private var imagePlaceholder: some View {
217+
ZStack {
218+
Color.pokit(.bg(.disable))
219+
220+
PokitSpinner()
221+
.foregroundStyle(.pink)
222+
.frame(width: 48, height: 48)
223+
}
224+
}
225+
208226
@ViewBuilder
209227
private func kebabButton(action: @escaping () -> Void) -> some View {
210228
Button(action: action) {

0 commit comments

Comments
 (0)