From 0828c4ca07889a7047f4243cd1a1b25e6dfd708a Mon Sep 17 00:00:00 2001 From: withseon Date: Thu, 21 Mar 2024 21:36:12 +0900 Subject: [PATCH] =?UTF-8?q?[Edit]=20likeAction()=20=EC=82=AD=EC=A0=9C=20#1?= =?UTF-8?q?66?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xcshareddata/swiftpm/Package.resolved | 10 +++--- .../JUDA/Resource/Components/PostCell.swift | 33 ++++++++----------- 2 files changed, 18 insertions(+), 25 deletions(-) diff --git a/JUDA_iOS/JUDA.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/JUDA_iOS/JUDA.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 18ff2f6b..77914dd4 100644 --- a/JUDA_iOS/JUDA.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/JUDA_iOS/JUDA.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "e61f9af2a013864b7919deedca43e2aaa74a995ba2089949eea130f3ce6b99f5", + "originHash" : "9d00d6d19aea4480f6191998a2ec62f9eee0bcf6df419b0690743e83bbd804c1", "pins" : [ { "identity" : "abseil-cpp-binary", @@ -128,12 +128,12 @@ } }, { - "identity" : "lottie-ios", + "identity" : "lottie-spm", "kind" : "remoteSourceControl", - "location" : "https://github.com/airbnb/lottie-ios.git", + "location" : "https://github.com/airbnb/lottie-spm.git", "state" : { - "branch" : "master", - "revision" : "41dfe7b0d8c3349adc7a5a03a1c6aaac8746433d" + "revision" : "3bd43e12d6fb54654366a61f7cfaca787318b8ce", + "version" : "4.4.1" } }, { diff --git a/JUDA_iOS/JUDA/Resource/Components/PostCell.swift b/JUDA_iOS/JUDA/Resource/Components/PostCell.swift index fec0463a..146d46b0 100644 --- a/JUDA_iOS/JUDA/Resource/Components/PostCell.swift +++ b/JUDA_iOS/JUDA/Resource/Components/PostCell.swift @@ -76,16 +76,25 @@ struct PostCell: View { // 좋아요를 해제 -> 테두리가 회색인 하트 Button { // TODO: 로그인 안 되어 있을 때, 로그인 페이지 넘어가기 - likeAction() + if authViewModel.signInStatus { + isLike.toggle() + debouncer.call { + if isLike { + likeCount += 1 + } else { + likeCount -= 1 + } + Task { + await authViewModel.updateLikedPosts(isLiked: isLike, selectedPost: post) + } + } + } } label: { Image(systemName: isLike ? "heart.fill" : "heart") .foregroundStyle(isLike ? .mainAccent01 : .gray01) } Text(Formatter.formattedPostLikesCount(likeCount)) .foregroundStyle(.gray01) - .onTapGesture { - likeAction() - } } .font(.regular14) .padding(.trailing, 5) @@ -102,22 +111,6 @@ struct PostCell: View { self.likeCount = post.likedUsersID.count } } - - private func likeAction() { - if authViewModel.signInStatus { - isLike.toggle() - debouncer.call { - if isLike { - likeCount += 1 - } else { - likeCount -= 1 - } - Task { - await authViewModel.updateLikedPosts(isLiked: isLike, selectedPost: post) - } - } - } - } } // MARK: - PostCell 의 이미지 프로필에서 사용하는 KFImage