From a07d4b3954bfaf4f84584bc9bde93bfefc7f8a94 Mon Sep 17 00:00:00 2001 From: jongnan Date: Fri, 2 Aug 2024 01:02:11 +0900 Subject: [PATCH 1/5] =?UTF-8?q?fix:=20=EB=A1=9C=ED=8B=B0=20=EC=9D=B4?= =?UTF-8?q?=EC=8A=88=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RecommendMemeButtonView.swift | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/Projects/Features/Recommend/Sources/Presentation/RecommendMemeButtonView.swift b/Projects/Features/Recommend/Sources/Presentation/RecommendMemeButtonView.swift index b78bbe8..9e48ede 100644 --- a/Projects/Features/Recommend/Sources/Presentation/RecommendMemeButtonView.swift +++ b/Projects/Features/Recommend/Sources/Presentation/RecommendMemeButtonView.swift @@ -15,7 +15,8 @@ import PPACModels import Lottie struct RecommendMemeButtonView : View { - @State var playbackMode: LottiePlaybackMode = .paused(at: .progress(100)) + @State var playbackMode: LottiePlaybackMode = .paused + @State var isTapLikeButton: Bool = false @Binding var meme: MemeDetail? @@ -30,20 +31,25 @@ struct RecommendMemeButtonView : View { LikeButton( reactionCount: meme.reaction, didTapped: { + self.isTapLikeButton = true playbackMode = .playing( - .fromProgress(0, toProgress: 1, loopMode: .playOnce) + .fromProgress(0, toProgress: 0.7, loopMode: .playOnce) ) self.reactionButtonTapped() } ) - .overlay(content: { + .disabled(self.isTapLikeButton) + .overlay { LottieView(animation: AnimationAsset.kkEffect.animation) .playbackMode(playbackMode) .animationDidFinish { _ in - playbackMode = .paused(at: .progress(100)) + self.isTapLikeButton = false + playbackMode = .paused } - .offset(y: -50) - }) + .frame(width: 200, height: 200, alignment: .center) + .offset(y: -115) + .allowsHitTesting(false) + } copyButton(copyButtonTapped) @@ -113,7 +119,7 @@ func saveButton( return RecommendMemeButtonView( meme: $meme, - reactionButtonTapped: { meme?.reaction += 1 }, + reactionButtonTapped: {meme?.reaction += 1}, copyButtonTapped: { print("copy~~") }, shareButtonTapped: { print("share~~") }, saveButtonTapped: { From 892c4924e4eed88bd8e161a0dbbabdc547562d74 Mon Sep 17 00:00:00 2001 From: jongnan Date: Fri, 2 Aug 2024 01:02:26 +0900 Subject: [PATCH 2/5] =?UTF-8?q?fix:=20=EB=B2=84=ED=8A=BC=20=EA=B7=B8?= =?UTF-8?q?=EB=A6=BC=EC=9E=90=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Projects/Core/DesignSystem/Sources/View/CircleButton.swift | 4 ++++ .../Recommend/Sources/Presentation/View/LikeButton.swift | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/Projects/Core/DesignSystem/Sources/View/CircleButton.swift b/Projects/Core/DesignSystem/Sources/View/CircleButton.swift index 76988f0..dccfc75 100644 --- a/Projects/Core/DesignSystem/Sources/View/CircleButton.swift +++ b/Projects/Core/DesignSystem/Sources/View/CircleButton.swift @@ -43,6 +43,10 @@ public struct CircleButton: View { height: self.height, alignment: .center ) + .shadow( + color: Color.Background.primary.opacity(0.05), + radius: 20 + ) } } } diff --git a/Projects/Features/Recommend/Sources/Presentation/View/LikeButton.swift b/Projects/Features/Recommend/Sources/Presentation/View/LikeButton.swift index 760182b..35bdb9f 100644 --- a/Projects/Features/Recommend/Sources/Presentation/View/LikeButton.swift +++ b/Projects/Features/Recommend/Sources/Presentation/View/LikeButton.swift @@ -39,6 +39,10 @@ public struct LikeButton: View { .frame(width: 156 ,height: 50, alignment: .center) .background(Color.Background.white) .cornerRadius(40) + .shadow( + color: Color.Background.primary.opacity(0.05), + radius: 20 + ) .clipped(antialiased: true) .onTapGesture { playbackMode = .playing( From c5fbc9cf66b278f0af87ec11e240077fdf7e5838 Mon Sep 17 00:00:00 2001 From: jongnan Date: Fri, 2 Aug 2024 01:02:52 +0900 Subject: [PATCH 3/5] =?UTF-8?q?fix:=20=EC=B6=94=EC=B2=9C=20=EB=B0=88=20?= =?UTF-8?q?=ED=85=8D=EC=8A=A4=ED=8A=B8=20=EC=83=89=EC=83=81=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Recommend/Sources/Presentation/RecommendHeaderView.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Projects/Features/Recommend/Sources/Presentation/RecommendHeaderView.swift b/Projects/Features/Recommend/Sources/Presentation/RecommendHeaderView.swift index f7b311c..518be26 100644 --- a/Projects/Features/Recommend/Sources/Presentation/RecommendHeaderView.swift +++ b/Projects/Features/Recommend/Sources/Presentation/RecommendHeaderView.swift @@ -77,8 +77,8 @@ private func recommendProgressBar( private func recommendText(_ text: String) -> some View { Text(text) - .font(Font.Weight.semiBold) - .foregroundStyle(Color.Text.secondary) + .font(Font.Weight.medium) + .foregroundStyle(Color.Text.tertiary) } #Preview { From 0eaac09c3ce839ddc7b6d2f5db0ebb6cc09c1117 Mon Sep 17 00:00:00 2001 From: jongnan Date: Fri, 2 Aug 2024 23:09:54 +0900 Subject: [PATCH 4/5] =?UTF-8?q?feat:=20=EB=B2=84=ED=8A=BC=EA=B3=BC=20?= =?UTF-8?q?=ED=83=AD=EB=B0=94=20=EC=82=AC=EC=9D=B4=20=EA=B0=84=EA=B2=A9=20?= =?UTF-8?q?=EB=84=93=ED=9E=88=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Presentation/RecommendMemeButtonView.swift | 4 ++-- .../Sources/Presentation/RecommendView.swift | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Projects/Features/Recommend/Sources/Presentation/RecommendMemeButtonView.swift b/Projects/Features/Recommend/Sources/Presentation/RecommendMemeButtonView.swift index 9e48ede..6025a55 100644 --- a/Projects/Features/Recommend/Sources/Presentation/RecommendMemeButtonView.swift +++ b/Projects/Features/Recommend/Sources/Presentation/RecommendMemeButtonView.swift @@ -60,8 +60,8 @@ struct RecommendMemeButtonView : View { } } } - .padding(.vertical, 30) - .padding(.horizontal, 32) + .frame(maxWidth: .infinity) + .frame(height: 110, alignment: .center) .background( LinearGradient( colors: [ diff --git a/Projects/Features/Recommend/Sources/Presentation/RecommendView.swift b/Projects/Features/Recommend/Sources/Presentation/RecommendView.swift index e480e6f..2c44ec9 100644 --- a/Projects/Features/Recommend/Sources/Presentation/RecommendView.swift +++ b/Projects/Features/Recommend/Sources/Presentation/RecommendView.swift @@ -20,16 +20,14 @@ public struct RecommendView: View { @ObservedObject private var viewModel: RecommendViewModel + @State private var memeContentsHeight: CGFloat = 0 @State private var memeImageHeight: CGFloat = 0 - @State private var zstackHeight: CGFloat = 0 - @State private var buttonHeight: CGFloat = 0 - @State private var currentMeme: MemeDetail? + @State private var buttonViewHeight: CGFloat = 0 + @State private var currentMeme: MemeDetail? @State var isActiveCopyPopup: Bool = false - @State var isFarmemed: Bool = false @State var isActiveFarmemePopup: Bool = false - @State private var currentOffsetY: CGFloat = 0 public init( @@ -59,7 +57,7 @@ public struct RecommendView: View { ZStack { VStack { - let isOverlapView = memeImageHeight + buttonHeight > zstackHeight + 30 + let isOverlapView = memeImageHeight + buttonViewHeight > memeContentsHeight + 30 if viewModel.state.recommendMemes.count > 0 { RecommendMemeImagesView( @@ -86,14 +84,16 @@ public struct RecommendView: View { shareButtonTapped : shareButtonTap, saveButtonTapped : saveButtonTap ) + .padding(.bottom, 10) .onReadSize { size in - buttonHeight = size.height + print(size.height) + buttonViewHeight = size.height } } .zIndex(2) } .onReadSize { size in - zstackHeight = size.height + memeContentsHeight = size.height } Spacer(minLength: 98) From c9908464ca236653b50b51be8c531b82f9f03139 Mon Sep 17 00:00:00 2001 From: jongnan Date: Sun, 4 Aug 2024 21:35:31 +0900 Subject: [PATCH 5/5] =?UTF-8?q?fix:=20=ED=99=88=ED=99=94=EB=A9=B4=20?= =?UTF-8?q?=EC=9D=B4=EC=8A=88=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/View/Meme/MemeListView.swift | 2 +- .../Sources/DTO/MemeResponseDTO.swift | 6 +- .../PPACModels/Sources/Meme/MemeDetail.swift | 8 +- .../Core/PPACUtil/Sources/User/UserInfo.swift | 2 +- .../Presentation/RecommendHeaderView.swift | 14 ++- .../RecommendMemeButtonView.swift | 92 +++++++++---------- .../Presentation/RecommendMemeImageView.swift | 63 +++++++++---- .../Sources/Presentation/RecommendView.swift | 26 ++++-- .../Presentation/RecommendViewModel.swift | 1 + .../Presentation/View/LikeButton.swift | 43 +++++++-- .../Presentation/View/MemeImageView.swift | 17 +++- 11 files changed, 179 insertions(+), 95 deletions(-) diff --git a/Projects/Core/DesignSystem/Sources/View/Meme/MemeListView.swift b/Projects/Core/DesignSystem/Sources/View/Meme/MemeListView.swift index c5cde64..89434fa 100644 --- a/Projects/Core/DesignSystem/Sources/View/Meme/MemeListView.swift +++ b/Projects/Core/DesignSystem/Sources/View/Meme/MemeListView.swift @@ -104,6 +104,6 @@ public struct MemeListView: View { keywords: MemeDetail.mock.keywords, imageUrlString: mockImageList[$0 % 4], source: MemeDetail.mock.source, - isTodayMeme: true, reaction: $0 % 4, isFarmemed: true) } + isTodayMeme: true, reaction: $0 % 4, isFarmemed: true, isReaction: false) } return MemeListView(memeDetailList: $memeDetailList) } diff --git a/Projects/Core/PPACData/Sources/DTO/MemeResponseDTO.swift b/Projects/Core/PPACData/Sources/DTO/MemeResponseDTO.swift index f74e8cc..dc3cdb3 100644 --- a/Projects/Core/PPACData/Sources/DTO/MemeResponseDTO.swift +++ b/Projects/Core/PPACData/Sources/DTO/MemeResponseDTO.swift @@ -54,6 +54,7 @@ struct MemeResponseDTO: Decodable { let createdAt: String? let updatedAt: String let isSaved: Bool + let isReaction: Bool let watch: Int public init( @@ -68,6 +69,7 @@ struct MemeResponseDTO: Decodable { createdAt: String?, updatedAt: String, isSaved: Bool, + isReaction: Bool, watch: Int ) { @@ -82,6 +84,7 @@ struct MemeResponseDTO: Decodable { self.createdAt = createdAt self.updatedAt = updatedAt self.isSaved = isSaved + self.isReaction = isReaction self.watch = watch } } @@ -110,7 +113,8 @@ extension MemeResponseDTO { source: self.source, isTodayMeme: self.isTodayMeme, reaction: self.reaction, - isFarmemed: self.isSaved + isFarmemed: self.isSaved, + isReaction: self.isReaction ) } } diff --git a/Projects/Core/PPACModels/Sources/Meme/MemeDetail.swift b/Projects/Core/PPACModels/Sources/Meme/MemeDetail.swift index 50cd00a..dc5e972 100644 --- a/Projects/Core/PPACModels/Sources/Meme/MemeDetail.swift +++ b/Projects/Core/PPACModels/Sources/Meme/MemeDetail.swift @@ -18,6 +18,7 @@ public struct MemeDetail: Identifiable, Hashable { public let isTodayMeme: Bool public var reaction: Int public var isFarmemed: Bool + public var isReaction: Bool // MARK: - Initializers @@ -29,7 +30,8 @@ public struct MemeDetail: Identifiable, Hashable { source: String, isTodayMeme: Bool, reaction: Int, - isFarmemed: Bool + isFarmemed: Bool, + isReaction: Bool ) { self.id = id self.title = title @@ -39,6 +41,7 @@ public struct MemeDetail: Identifiable, Hashable { self.isTodayMeme = isTodayMeme self.reaction = reaction self.isFarmemed = isFarmemed + self.isReaction = isReaction } } @@ -51,6 +54,7 @@ public extension MemeDetail { source: "깃허브", isTodayMeme: true, reaction: 4, - isFarmemed: false + isFarmemed: false, + isReaction: false ) } diff --git a/Projects/Core/PPACUtil/Sources/User/UserInfo.swift b/Projects/Core/PPACUtil/Sources/User/UserInfo.swift index 3449ece..cd79ac4 100644 --- a/Projects/Core/PPACUtil/Sources/User/UserInfo.swift +++ b/Projects/Core/PPACUtil/Sources/User/UserInfo.swift @@ -19,5 +19,5 @@ public class UserInfo { @UserDefault(key:"deviceId", defaultValue: "") public var deviceId: String - public let testDeviceId: String = "uni-test" + public let testDeviceId: String = "uni-test2" } diff --git a/Projects/Features/Recommend/Sources/Presentation/RecommendHeaderView.swift b/Projects/Features/Recommend/Sources/Presentation/RecommendHeaderView.swift index 518be26..0b48bc3 100644 --- a/Projects/Features/Recommend/Sources/Presentation/RecommendHeaderView.swift +++ b/Projects/Features/Recommend/Sources/Presentation/RecommendHeaderView.swift @@ -15,16 +15,20 @@ struct RecommendHeaderView: View { @Binding var recommendMemeSize: Int public var body: some View { - VStack { + VStack(spacing: 0) { ResourceKitAsset.Icon.homeLogo.swiftUIImage + .resizable() + .frame(width: 212, height: 45, alignment: .center) .padding(.bottom, 10) recommendTitle + .padding(.bottom, 16) recommendProgressBar( seenMemeCount: self.seenMemeCount, total: recommendMemeSize ) + .padding(.bottom, 8) recommendText(getRecommendText()) } @@ -48,7 +52,7 @@ struct RecommendHeaderView: View { } private var recommendTitle : some View { - Text("이번주 이 밈 어때!") + Text("이번 주 이 밈 어때!") .font(Font.Heading.Large.semiBold) .padding(.bottom, 8) } @@ -57,7 +61,7 @@ private func recommendProgressBar( seenMemeCount: Int, total: Int ) -> some View { - HStack { + HStack(spacing: 0) { ResourceKitAsset.Icon.squareCheck.swiftUIImage ProgressView( @@ -77,8 +81,8 @@ private func recommendProgressBar( private func recommendText(_ text: String) -> some View { Text(text) - .font(Font.Weight.medium) - .foregroundStyle(Color.Text.tertiary) + .font(Font.Body.Medium.medium) + .foregroundStyle(Color.Text.secondary) } #Preview { diff --git a/Projects/Features/Recommend/Sources/Presentation/RecommendMemeButtonView.swift b/Projects/Features/Recommend/Sources/Presentation/RecommendMemeButtonView.swift index 6025a55..a98b939 100644 --- a/Projects/Features/Recommend/Sources/Presentation/RecommendMemeButtonView.swift +++ b/Projects/Features/Recommend/Sources/Presentation/RecommendMemeButtonView.swift @@ -18,8 +18,10 @@ struct RecommendMemeButtonView : View { @State var playbackMode: LottiePlaybackMode = .paused @State var isTapLikeButton: Bool = false - @Binding var meme: MemeDetail? - + var isReaction: Bool + var reactionCnt: Int + var isFarmemed: Bool + let isOverlapView: Bool let reactionButtonTapped: () -> Void let copyButtonTapped: () -> Void let shareButtonTapped: () -> Void @@ -27,37 +29,36 @@ struct RecommendMemeButtonView : View { public var body: some View { HStack { - if let meme { - LikeButton( - reactionCount: meme.reaction, - didTapped: { - self.isTapLikeButton = true - playbackMode = .playing( - .fromProgress(0, toProgress: 0.7, loopMode: .playOnce) - ) - self.reactionButtonTapped() - } - ) - .disabled(self.isTapLikeButton) - .overlay { - LottieView(animation: AnimationAsset.kkEffect.animation) - .playbackMode(playbackMode) - .animationDidFinish { _ in - self.isTapLikeButton = false - playbackMode = .paused - } - .frame(width: 200, height: 200, alignment: .center) - .offset(y: -115) - .allowsHitTesting(false) - } - - copyButton(copyButtonTapped) - - shareButton(shareButtonTapped) - - saveButton(isFarmemed: meme.isFarmemed) { - saveButtonTapped() + LikeButton( + isReaction: isReaction, + reactionCount: reactionCnt, + didTapped: { + self.isTapLikeButton = true + playbackMode = .playing( + .fromProgress(0, toProgress: 0.7, loopMode: .playOnce) + ) + self.reactionButtonTapped() } + ) + .disabled(self.isTapLikeButton) + .overlay { + LottieView(animation: AnimationAsset.kkEffect.animation) + .playbackMode(playbackMode) + .animationDidFinish { _ in + self.isTapLikeButton = false + playbackMode = .paused + } + .frame(width: 200, height: 200, alignment: .center) + .offset(y: -115) + .allowsHitTesting(false) + } + + copyButton(copyButtonTapped) + + shareButton(shareButtonTapped) + + saveButton(isFarmemed: isFarmemed) { + saveButtonTapped() } } .frame(maxWidth: .infinity) @@ -66,7 +67,7 @@ struct RecommendMemeButtonView : View { LinearGradient( colors: [ Color.Background.brandsubassistive.opacity(0), - Color.Background.brandsubassistive + isOverlapView ? Color.Background.brandsubassistive : Color.Background.brandsubassistive.opacity(0) ], startPoint: .top, endPoint: .bottom @@ -106,24 +107,23 @@ func saveButton( } #Preview { - @State var meme: MemeDetail? = MemeDetail( - id: "1234", - title: "안녕하세요!", - keywords: ["웃김", "재미", "신나"], - imageUrlString: "https://host.com/asdf", - source: "종난", - isTodayMeme: true, - reaction: 130, - isFarmemed: true - ) + var isReaction: Bool = true + var reactionCnt: Int = 1 + var isFarmemed: Bool = false return RecommendMemeButtonView( - meme: $meme, - reactionButtonTapped: {meme?.reaction += 1}, + isReaction: isReaction, + reactionCnt: reactionCnt, + isFarmemed: isFarmemed, + isOverlapView: true, + reactionButtonTapped: { + isReaction = true + reactionCnt = +1 + }, copyButtonTapped: { print("copy~~") }, shareButtonTapped: { print("share~~") }, saveButtonTapped: { - print("isFarmemed: \(meme?.isFarmemed)") + isFarmemed.toggle() } ) } diff --git a/Projects/Features/Recommend/Sources/Presentation/RecommendMemeImageView.swift b/Projects/Features/Recommend/Sources/Presentation/RecommendMemeImageView.swift index 77ec278..e7e2106 100644 --- a/Projects/Features/Recommend/Sources/Presentation/RecommendMemeImageView.swift +++ b/Projects/Features/Recommend/Sources/Presentation/RecommendMemeImageView.swift @@ -16,23 +16,44 @@ import PPACModels struct RecommendMemeImagesView: View { @Binding var currentMeme: MemeDetail? + @State var value: CGFloat = 0 + var memes: [MemeDetail] var isTagHidden: Bool = false public var body: some View { VStack(spacing: 0) { ScrollView(.horizontal) { - LazyHStack { - ForEach(memes, id: \.self) { meme in - MemeImageView( - imageUrl: meme.imageUrlString, - isDimmed: meme.id != currentMeme?.id - ) - .animation(.smooth, value: meme) - .scrollTransition { content, phase in - content - .scaleEffect(phase.isIdentity ? 1.0 : 0.9) - .blur(radius: phase.isIdentity ? 0 : 1) + ZStack { + // Image + LazyHStack(spacing: 0) { + ForEach(memes, id: \.self) { meme in + MemeImageView( + imageUrl: meme.imageUrlString, + isDimmed: meme.id != currentMeme?.id + ) + .scrollTransition { content, phase in + content + .offset(x: phase.value * -3) + .scaleEffect(phase.isIdentity ? 1 : 0.9) + .blur(radius: phase.isIdentity ? 0 : 1) + } + .animation(.smooth, value: meme) + } + } + + // Border + HStack(spacing: 0) { + ForEach(memes, id: \.self) { meme in + RoundedRectangle(cornerRadius: 20) + .inset(by: 1) + .stroke(Color.Border.primary, lineWidth: 2) + .scrollTransition { content, phase in + content + .offset(x: phase.value * -3) + .scaleEffect(phase.isIdentity ? 1 : 0.905) + } + .animation(.smooth, value: meme) } } } @@ -69,11 +90,12 @@ struct RecommendMemeImagesView: View { id: "668a44950289555e368174a6", title: "심란한 명수옹", keywords: ["공부", "학생", "시험기간"], - imageUrlString: "https://avatars.githubusercontent.com/u/26344479?s=64&v=4", + imageUrlString: "https://ppac-meme.s3.ap-northeast-2.amazonaws.com/17207014936770.png", source: "깃허브", isTodayMeme: true, reaction: 4, - isFarmemed: false + isFarmemed: false, + isReaction: false ) ), memes: [ @@ -85,7 +107,8 @@ struct RecommendMemeImagesView: View { source: "깃허브", isTodayMeme: true, reaction: 4, - isFarmemed: false + isFarmemed: false, + isReaction: false ), MemeDetail( id: "2", @@ -95,7 +118,8 @@ struct RecommendMemeImagesView: View { source: "깃허브", isTodayMeme: true, reaction: 1, - isFarmemed: false + isFarmemed: false, + isReaction: false ), MemeDetail( id: "3", @@ -105,7 +129,8 @@ struct RecommendMemeImagesView: View { source: "깃허브", isTodayMeme: true, reaction: 0, - isFarmemed: false + isFarmemed: false, + isReaction: false ), MemeDetail( id: "4", @@ -115,7 +140,8 @@ struct RecommendMemeImagesView: View { source: "깃허브", isTodayMeme: true, reaction: 4, - isFarmemed: false + isFarmemed: false, + isReaction: false ), MemeDetail( id: "5", @@ -125,7 +151,8 @@ struct RecommendMemeImagesView: View { source: "깃허브", isTodayMeme: true, reaction: 4, - isFarmemed: false + isFarmemed: false, + isReaction: false ) ], isTagHidden: false diff --git a/Projects/Features/Recommend/Sources/Presentation/RecommendView.swift b/Projects/Features/Recommend/Sources/Presentation/RecommendView.swift index 2c44ec9..53da691 100644 --- a/Projects/Features/Recommend/Sources/Presentation/RecommendView.swift +++ b/Projects/Features/Recommend/Sources/Presentation/RecommendView.swift @@ -56,8 +56,8 @@ public struct RecommendView: View { ) ZStack { - VStack { - let isOverlapView = memeImageHeight + buttonViewHeight > memeContentsHeight + 30 + let isOverlapView = memeImageHeight + buttonViewHeight > memeContentsHeight + 30 + VStack(spacing: 0) { if viewModel.state.recommendMemes.count > 0 { RecommendMemeImagesView( @@ -74,17 +74,19 @@ public struct RecommendView: View { } .zIndex(1) - VStack { + VStack(spacing: 0) { Spacer() RecommendMemeButtonView( - meme: $currentMeme, + isReaction: currentMeme?.isReaction ?? false, + reactionCnt: currentMeme?.reaction ?? 0, + isFarmemed: currentMeme?.isFarmemed ?? false, + isOverlapView: isOverlapView, reactionButtonTapped: reactionButtonTap, copyButtonTapped: copyButtonTap, shareButtonTapped : shareButtonTap, saveButtonTapped : saveButtonTap ) - .padding(.bottom, 10) .onReadSize { size in print(size.height) buttonViewHeight = size.height @@ -92,11 +94,23 @@ public struct RecommendView: View { } .zIndex(2) } + .frame(maxHeight: 490) .onReadSize { size in memeContentsHeight = size.height } - Spacer(minLength: 98) + Spacer() + + // 높이를 위한 가짜 탭뷰 + Rectangle() + .frame(maxWidth: .infinity, maxHeight: 98) + .background(.white.opacity(0)) + .clipShape( + .rect( + topLeadingRadius: 30, + topTrailingRadius: 30 + ) + ) } .offset(y: currentOffsetY) .frame(maxWidth: .infinity, maxHeight: .infinity) diff --git a/Projects/Features/Recommend/Sources/Presentation/RecommendViewModel.swift b/Projects/Features/Recommend/Sources/Presentation/RecommendViewModel.swift index ab5ec87..edc37cb 100644 --- a/Projects/Features/Recommend/Sources/Presentation/RecommendViewModel.swift +++ b/Projects/Features/Recommend/Sources/Presentation/RecommendViewModel.swift @@ -127,6 +127,7 @@ private extension RecommendViewModel { try await reactToMemeUseCase.execute(memeId: memeId) if let index = self.state.recommendMemes.firstIndex(where: { $0.id == memeId }) { + self.state.recommendMemes[index].isReaction = true self.state.recommendMemes[index].reaction += 1 } } catch { diff --git a/Projects/Features/Recommend/Sources/Presentation/View/LikeButton.swift b/Projects/Features/Recommend/Sources/Presentation/View/LikeButton.swift index 35bdb9f..7a44dc4 100644 --- a/Projects/Features/Recommend/Sources/Presentation/View/LikeButton.swift +++ b/Projects/Features/Recommend/Sources/Presentation/View/LikeButton.swift @@ -16,15 +16,18 @@ public struct LikeButton: View { @State var playbackMode: LottiePlaybackMode = .paused(at: .progress(100)) + private let isReaction: Bool private let reactionCount: Int private let didTapped: () -> Void // MARK: - Initializers public init( + isReaction: Bool?, reactionCount: Int?, didTapped: @escaping () -> Void ) { + self.isReaction = isReaction ?? false self.reactionCount = reactionCount ?? 0 self.didTapped = didTapped } @@ -39,11 +42,11 @@ public struct LikeButton: View { .frame(width: 156 ,height: 50, alignment: .center) .background(Color.Background.white) .cornerRadius(40) + .clipped(antialiased: true) .shadow( color: Color.Background.primary.opacity(0.05), radius: 20 ) - .clipped(antialiased: true) .onTapGesture { playbackMode = .playing( .fromProgress(0, toProgress: 1, loopMode: .playOnce) @@ -58,12 +61,16 @@ public struct LikeButton: View { if reactionCount <= 0 { ResourceKitAsset.Icon.ㅋ.swiftUIImage } else { - LottieView(animation: AnimationAsset.kkButtonActive.animation) - .playbackMode(playbackMode) - .animationDidFinish { _ in - playbackMode = .paused(at: .progress(100)) - } - .frame(width: 44, height: 22) + if isReaction { + LottieView(animation: AnimationAsset.kkButtonActive.animation) + .playbackMode(playbackMode) + .animationDidFinish { _ in + playbackMode = .paused(at: .progress(100)) + } + .frame(width: 44, height: 22) + } else { + ResourceKitAsset.Icon.ㅋㅋ.swiftUIImage + } } } @@ -74,13 +81,29 @@ public struct LikeButton: View { (reactionCount > 0) ? Font.Heading.Medium.bold :Font.Family2.outLine ) .foregroundColor( - (reactionCount > 0) ? Color.Text.brand : Color.Text.primary + (isReaction) ? Color.Text.brand : Color.Text.primary ) } } #Preview { - var count: Int = 0 + var count: Int = 3 - return LikeButton(reactionCount: count, didTapped: { }) + return VStack { + LikeButton( + isReaction: false, + reactionCount: count, + didTapped: { + print("AA") + } + ) + + LikeButton( + isReaction: true, + reactionCount: count, + didTapped: { + print("AA") + } + ) + } } diff --git a/Projects/Features/Recommend/Sources/Presentation/View/MemeImageView.swift b/Projects/Features/Recommend/Sources/Presentation/View/MemeImageView.swift index fdb4a29..0047703 100644 --- a/Projects/Features/Recommend/Sources/Presentation/View/MemeImageView.swift +++ b/Projects/Features/Recommend/Sources/Presentation/View/MemeImageView.swift @@ -14,18 +14,25 @@ struct MemeImageView: View { let isDimmed: Bool public var body: some View { - KFImage(URL(string: imageUrl)) - .resizable() + Rectangle() .frame(width: 270, height: 310) .cornerRadius(20) .overlay { + KFImage(URL(string: imageUrl)) + .resizable() + .aspectRatio(contentMode: .fit) + if isDimmed { RoundedRectangle(cornerRadius: 20) .foregroundStyle(Color.Background.dimmer) } - RoundedRectangle(cornerRadius: 20) - .inset(by: 1) - .stroke(Color.Border.primary, lineWidth: 2) } } } + +#Preview { + MemeImageView( + imageUrl: "https://ppac-meme.s3.ap-northeast-2.amazonaws.com/17204513204087.jpg", + isDimmed: false + ) +}