Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: 인스타그램 등 일부 도메인에서 이미지 조회가 안되는 문제 수정 #153

Merged
merged 3 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 18 additions & 16 deletions Projects/App/ShareExtension/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>TeamID</key>
<string>$(TeamID)</string>
<key>GIDClientID</key>
<string>$(GIDClientID)</string>
<key>AppleKeyID</key>
<string>$(AppleKeyID)</string>
<key>CFBundleDisplayName</key>
<string>Pokit</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleName</key>
<string>Pokit</string>
<key>CFBundleShortVersionString</key>
<string>1.0.4</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
Expand All @@ -19,34 +25,30 @@
</array>
</dict>
</array>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>CFBundleName</key>
<string>Pokit</string>
<key>CFBundleDisplayName</key>
<string>Pokit</string>
<key>GIDClientID</key>
<string>$(GIDClientID)</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
<dict>
<key>NSExtensionActivationRule</key>
<dict>
<key>NSExtensionActivationSupportsText</key>
<true/>
<key>NSExtensionActivationSupportsWebPageWithMaxCount</key>
<integer>1000</integer>
<key>NSExtensionActivationSupportsWebURLWithMaxCount</key>
<integer>1000</integer>
<key>NSExtensionActivationSupportsText</key>
<true/>
</dict>
</dict>
<key>NSExtensionPrincipalClass</key>
<string>$(PRODUCT_MODULE_NAME).ShareViewController</string>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.share-services</string>
<key>NSExtensionPrincipalClass</key>
<string>$(PRODUCT_MODULE_NAME).ShareViewController</string>
</dict>
<key>TeamID</key>
<string>$(TeamID)</string>
</dict>
</plist>
40 changes: 28 additions & 12 deletions Projects/DSKit/Sources/Components/PokitLinkCard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ public struct PokitLinkCard<Item: PokitLinkCardItem>: View {
@MainActor
private var buttonLabel: some View {
HStack(spacing: 12) {
thumbleNail
if let url = URL(string: link.thumbNail) {
thumbleNail(url: url)
} else {
placeholder
}

VStack(spacing: 8) {
HStack {
Expand Down Expand Up @@ -105,27 +109,27 @@ public struct PokitLinkCard<Item: PokitLinkCardItem>: View {
}

@MainActor
private var thumbleNail: some View {
LazyImage(url: .init(string: link.thumbNail)) { phase in
private func thumbleNail(url: URL) -> some View {
var request = URLRequest(url: url)
request.setValue(
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36",
forHTTPHeaderField: "User-Agent"
)

return LazyImage(request: .init(urlRequest: request)) { phase in
Group {
if let image = phase.image {
image
.resizable()
.aspectRatio(contentMode: .fill)
} else {
ZStack {
Color.pokit(.bg(.disable))

PokitSpinner()
.foregroundStyle(.pokit(.icon(.brand)))
.frame(width: 48, height: 48)
}
placeholder
}
}
.animation(.pokitDissolve, value: phase.image)
.frame(width: 124, height: 94)
.clipShape(RoundedRectangle(cornerRadius: 8, style: .continuous))
}
.frame(width: 124, height: 94)
.clipShape(RoundedRectangle(cornerRadius: 8, style: .continuous))
}

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

private var placeholder: some View {
ZStack {
Color.pokit(.bg(.disable))

PokitSpinner()
.foregroundStyle(.pokit(.icon(.brand)))
.frame(width: 48, height: 48)
}
.frame(width: 124, height: 94)
.clipShape(RoundedRectangle(cornerRadius: 8, style: .continuous))
}

@ViewBuilder
public func divider(isFirst: Bool, isLast: Bool) -> some View {
let edge: Edge.Set = isFirst ? .bottom : isLast ? .top : .vertical
Expand Down
46 changes: 32 additions & 14 deletions Projects/Feature/FeatureRemind/Sources/Remind/RemindView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -137,25 +137,15 @@ extension RemindView {
Button(action: { send(.컨텐츠_항목_눌렀을때(content: content)) }) {
recommendedContentCellLabel(content: content)
}

}

@ViewBuilder
private func recommendedContentCellLabel(content: BaseContentItem) -> some View {
ZStack(alignment: .bottom) {
LazyImage(url: .init(string: content.thumbNail)) { phase in
if let image = phase.image {
image
.resizable()
} else {
ZStack {
Color.pokit(.bg(.disable))

PokitSpinner()
.foregroundStyle(.pokit(.icon(.brand)))
.frame(width: 48, height: 48)
}
}
if let url = URL(string: content.thumbNail) {
recommendedContentCellImage(url: url)
} else {
imagePlaceholder
}

LinearGradient(
Expand Down Expand Up @@ -205,6 +195,34 @@ extension RemindView {
.clipShape(RoundedRectangle(cornerRadius: 12, style: .continuous))
}

@MainActor
private func recommendedContentCellImage(url: URL) -> some View {
var request = URLRequest(url: url)
request.setValue(
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36",
forHTTPHeaderField: "User-Agent"
)

return LazyImage(request: .init(urlRequest: request)) { phase in
if let image = phase.image {
image
.resizable()
} else {
imagePlaceholder
}
}
}

private var imagePlaceholder: some View {
ZStack {
Color.pokit(.bg(.disable))

PokitSpinner()
.foregroundStyle(.pink)
.frame(width: 48, height: 48)
}
}

@ViewBuilder
private func kebabButton(action: @escaping () -> Void) -> some View {
Button(action: action) {
Expand Down
Loading