Skip to content

Commit

Permalink
Merge pull request #153 from YAPP-Github/fix/#152-fetch-url-image
Browse files Browse the repository at this point in the history
  • Loading branch information
ShapeKim98 authored Oct 22, 2024
2 parents e12c070 + 495989f commit 809268a
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 42 deletions.
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

0 comments on commit 809268a

Please sign in to comment.