Skip to content

Commit 80fec61

Browse files
committed
[feat] #180 링크 url 이동 구현
1 parent 84b61f8 commit 80fec61

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

Projects/Feature/FeatureRecommend/Sources/Recommend/RecommendFeature.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ public struct RecommendFeature {
1818
private var contentClient
1919
@Dependency(UserClient.self)
2020
private var userClient
21-
@Dependency(PasteboardClient.self)
22-
private var pasteBoard
21+
@Dependency(\.openURL)
22+
private var openURL
2323
/// - State
2424
@ObservableState
2525
public struct State: Equatable {
@@ -71,6 +71,7 @@ public struct RecommendFeature {
7171
case 링크_공유_완료되었을때
7272
case 검색_버튼_눌렀을때
7373
case 알림_버튼_눌렀을때
74+
case 추천_컨텐츠_눌렀을때(String)
7475
}
7576

7677
public enum InnerAction: Equatable {
@@ -168,6 +169,9 @@ private extension RecommendFeature {
168169
return .send(.delegate(.검색_버튼_눌렀을때))
169170
case .알림_버튼_눌렀을때:
170171
return .send(.delegate(.알림_버튼_눌렀을때))
172+
case let .추천_컨텐츠_눌렀을때(urlString):
173+
guard let url = URL(string: urlString) else { return .none }
174+
return .run { _ in await openURL(url) }
171175
}
172176
}
173177

Projects/Feature/FeatureRecommend/Sources/Recommend/RecommendView.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ private extension RecommendView {
158158
ScrollView {
159159
LazyVStack(spacing: 8) {
160160
ForEach(recommendedList) { content in
161-
recomendedCard(content)
161+
recommendedCard(content)
162162
}
163163

164164
if store.hasNext {
@@ -170,9 +170,16 @@ private extension RecommendView {
170170
.padding(.bottom, 150)
171171
}
172172
}
173+
174+
@ViewBuilder
175+
func recommendedCard(_ content: BaseContentItem) -> some View {
176+
Button(action: { send(.추천_컨텐츠_눌렀을때(content.data)) }) {
177+
recomendedCardLabel(content)
178+
}
179+
}
173180

174181
@ViewBuilder
175-
func recomendedCard(_ content: BaseContentItem) -> some View {
182+
func recomendedCardLabel(_ content: BaseContentItem) -> some View {
176183
VStack(alignment: .leading, spacing: 0) {
177184
if let url = URL(string: content.thumbNail) {
178185
recommendedImage(url: url)

0 commit comments

Comments
 (0)