-
Notifications
You must be signed in to change notification settings - Fork 0
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
Network [#91] 투명도 낮추기 API 연결, 투명도 적용 토스트 메시지 분기 처리 완료, 답글 조회 API 연결 #94
Changes from 8 commits
1745dfb
1aec25f
8dbd1dd
f94d55f
202af37
e85428d
0a3c1cd
f91188e
fabeac8
ab657e9
2661909
d26e17e
fbf18da
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,6 +58,7 @@ enum ImageLiterals { | |
|
||
enum Home { | ||
static var textLogo: UIImage { .load(name: "Logo") } | ||
static var icnNotice: UIImage { .load(name: "icn_notice") } | ||
} | ||
|
||
enum Posting { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아래는 코드 패치입니다. 해당 패치에 대한 간단한 코드 리뷰를 도와드리겠습니다. 버그 위험 및 개선 제안은 환영합니다.
개선 제안:
좀 더 자세한 코드 분석이 필요하다면 전체 코드 범위와 다른 파일/클래스에 대한 정보를 제공해주시면 됩니다. |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,6 +64,7 @@ enum StringLiterals { | |
enum Toast { | ||
static let uploading = "게시 중..." | ||
static let uploaded = "게시 완료!" | ||
static let alreadyTransparency = "이미 투명도를 적용한 유저예요." | ||
} | ||
|
||
enum Notification { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 주어진 코드 패치에는 별다른 버그나 위험은 발견되지 않았습니다. 그러나 몇 가지 개선 제안이 있습니다:
필요에 따라 이러한 제안들을 참고하여 코드 패치를 수정하는 것이 좋습니다. |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "icn_notice.png", | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"filename" : "icn_notice@2x.png", | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"filename" : "icn_notice@3x.png", | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 위의 코드 패치를 간단히 검토해 드리겠습니다. 이 코드는 JSON 형식으로 되어 있으며, "images" 배열 내에 이미지 파일 정보가 포함되어 있습니다. 각 이미지는 "filename" (파일 이름), "idiom" (용도), "scale" (배율) 속성을 가지고 있습니다. 이 속성들은 각각 이미지 파일의 이름, 일반적인 용도, 배율을 나타냅니다. 코드 자체에 버그나 위험이 없으며, 개선 제안 사항도 별다른 것이 없습니다. 이는 단순히 이미지 파일 정보를 담고 있는 JSON 데이터이기 때문에 수정할 필요가 없을 수 있습니다. 크게 문제가 있다거나 개선이 필요한 부분이 있다면 추가로 알려주세요. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// PostTransparencyRequestDTO.swift | ||
// DontBe-iOS | ||
// | ||
// Created by 변상우 on 1/18/24. | ||
// | ||
|
||
import Foundation | ||
|
||
// MARK: - PostTransparencyRequestDTO | ||
|
||
struct PostTransparencyRequestDTO: Encodable { | ||
let alarmTriggerType: String | ||
let targetMemberId: Int | ||
let alarmTriggerId: Int | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이 코드 패치는 이 코드에 현재 확인할 수 있는 버그나 위험이 없어 보입니다. 그러나 몇 가지 개선점이 있을 수 있습니다:
그 외에는 현재 코드의 명료성과 안전성이 보존되며, 문제가 없어 보입니다. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,9 @@ final class HomeCollectionViewCell: UICollectionViewCell, UICollectionViewRegist | |
var LikeButtonAction: (() -> Void) = {} | ||
var TransparentButtonAction: (() -> Void) = {} | ||
var isLiked: Bool = false | ||
var alarmTriggerType: String = "" | ||
var targetMemberId: Int = 0 | ||
var alarmTriggerdId: Int = 0 | ||
|
||
// MARK: - UI Components | ||
|
||
|
@@ -187,7 +190,7 @@ extension HomeCollectionViewCell { | |
|
||
func setLayout() { | ||
backgroundUIView.snp.makeConstraints { | ||
$0.edges.equalToSuperview() | ||
$0.top.bottom.equalToSuperview() | ||
$0.width.equalTo(UIScreen.main.bounds.width - 32) | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아래는 코드 패치입니다. 버그 위험 또는 개선 제안이 있는지 간단한 코드 리뷰를 도와드리겠습니다.
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,12 +29,16 @@ final class HomeViewController: UIViewController { | |
let destinationViewController = PostViewController(viewModel: PostViewModel(networkProvider: NetworkService())) | ||
|
||
var contentId: Int = 0 | ||
var alarmTriggerType: String = "" | ||
var targetMemberId: Int = 0 | ||
var alarmTriggerdId: Int = 0 | ||
|
||
// MARK: - UI Components | ||
|
||
private let myView = HomeView() | ||
lazy var homeCollectionView = HomeCollectionView().collectionView | ||
private var uploadToastView: DontBeToastView? | ||
private var alreadyTransparencyToastView: DontBeToastView? | ||
|
||
// MARK: - Life Cycles | ||
|
||
|
@@ -135,6 +139,7 @@ extension HomeViewController { | |
private func setDelegate() { | ||
homeCollectionView.dataSource = self | ||
homeCollectionView.delegate = self | ||
transparentPopupVC.transparentButtonPopupView.delegate = self | ||
} | ||
|
||
private func setNotification() { | ||
|
@@ -210,6 +215,33 @@ extension HomeViewController { | |
} | ||
} | ||
} | ||
|
||
func showAlreadyTransparencyToast() { | ||
DispatchQueue.main.async { | ||
self.alreadyTransparencyToastView = DontBeToastView() | ||
self.alreadyTransparencyToastView?.toastLabel.text = StringLiterals.Toast.alreadyTransparency | ||
self.alreadyTransparencyToastView?.circleProgressBar.alpha = 0 | ||
self.alreadyTransparencyToastView?.checkImageView.alpha = 1 | ||
self.alreadyTransparencyToastView?.checkImageView.image = ImageLiterals.Home.icnNotice | ||
self.alreadyTransparencyToastView?.container.backgroundColor = .donPrimary | ||
|
||
self.view.addSubviews(self.alreadyTransparencyToastView ?? DontBeToastView()) | ||
|
||
self.alreadyTransparencyToastView?.snp.makeConstraints { | ||
$0.leading.trailing.equalToSuperview().inset(16.adjusted) | ||
$0.bottom.equalTo(self.tabBarHeight.adjusted).inset(6.adjusted) | ||
$0.height.equalTo(44) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3 |
||
} | ||
|
||
UIView.animate(withDuration: 1.5, delay: 1, options: .curveEaseIn) { | ||
self.alreadyTransparencyToastView?.alpha = 0 | ||
} | ||
|
||
DispatchQueue.main.asyncAfter(deadline: .now() + 2.5) { | ||
self.alreadyTransparencyToastView?.removeFromSuperview() | ||
} | ||
} | ||
} | ||
} | ||
|
||
// MARK: - Network | ||
|
@@ -246,25 +278,27 @@ extension HomeViewController: UICollectionViewDataSource, UICollectionViewDelega | |
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { | ||
let cell = | ||
HomeCollectionViewCell.dequeueReusableCell(collectionView: collectionView, indexPath: indexPath) | ||
cell.alarmTriggerType = "contentGhost" | ||
cell.targetMemberId = viewModel.postData[indexPath.row].memberId | ||
cell.alarmTriggerdId = viewModel.postData[indexPath.row].contentId | ||
if viewModel.postData[indexPath.row].memberId == loadUserData()?.memberId { | ||
cell.ghostButton.isHidden = true | ||
cell.verticalTextBarView.isHidden = true | ||
cell.KebabButtonAction = { | ||
self.deleteBottomsheet.showSettings() | ||
} | ||
} else { | ||
cell.ghostButton.isHidden = false | ||
cell.verticalTextBarView.isHidden = false | ||
cell.KebabButtonAction = { | ||
self.deleteBottomsheet.showSettings() | ||
} | ||
} | ||
cell.KebabButtonAction = { | ||
self.deleteBottomsheet.showSettings() | ||
} | ||
cell.LikeButtonAction = { | ||
cell.isLiked.toggle() | ||
cell.likeButton.setImage(cell.isLiked ? ImageLiterals.Posting.btnFavoriteActive : ImageLiterals.Posting.btnFavoriteInActive, for: .normal) | ||
} | ||
cell.TransparentButtonAction = { | ||
// present | ||
self.alarmTriggerType = cell.alarmTriggerType | ||
self.targetMemberId = cell.targetMemberId | ||
self.alarmTriggerdId = cell.alarmTriggerdId | ||
self.present(self.transparentPopupVC, animated: false, completion: nil) | ||
} | ||
cell.nicknameLabel.text = viewModel.postData[indexPath.row].memberNickname | ||
|
@@ -295,3 +329,29 @@ extension HomeViewController: UICollectionViewDataSource, UICollectionViewDelega | |
return CGSize(width: UIScreen.main.bounds.width, height: 24.adjusted) | ||
} | ||
} | ||
|
||
extension HomeViewController: DontBePopupDelegate { | ||
func cancleButtonTapped() { | ||
self.dismiss(animated: false) | ||
} | ||
|
||
func confirmButtonTapped() { | ||
self.dismiss(animated: false) | ||
Task { | ||
do { | ||
if let accessToken = KeychainWrapper.loadToken(forKey: "accessToken") { | ||
let result = try await self.viewModel.postDownTransparency(accessToken: accessToken, | ||
alarmTriggerType: self.alarmTriggerType, | ||
targetMemberId: self.targetMemberId, | ||
alarmTriggerId: self.alarmTriggerdId) | ||
if result?.status == 400 { | ||
// 이미 투명도를 누른 대상인 경우, 토스트 메시지 보여주기 | ||
showAlreadyTransparencyToast() | ||
} | ||
} | ||
} catch { | ||
print(error) | ||
} | ||
} | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아래는 코드 패치에 대한 간략한 코드 리뷰입니다. 버그 위험 또는 개선 제안 사항을 환영합니다:
위의 사항들을 고려하여 코드를 개선할 수 있습니다. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,9 @@ final class PostReplyCollectionViewCell: UICollectionViewCell, UICollectionViewR | |
var LikeButtonAction: (() -> Void) = {} | ||
var TransparentButtonAction: (() -> Void) = {} | ||
var isLiked: Bool = false | ||
var alarmTriggerType: String = "" | ||
var targetMemberId: Int = 0 | ||
var alarmTriggerdId: Int = 0 | ||
|
||
// MARK: - UI Components | ||
|
||
|
@@ -106,13 +109,13 @@ final class PostReplyCollectionViewCell: UICollectionViewCell, UICollectionViewR | |
return label | ||
}() | ||
|
||
private let ghostButton: UIButton = { | ||
let ghostButton: UIButton = { | ||
let button = UIButton() | ||
button.setImage(ImageLiterals.Posting.btnTransparent, for: .normal) | ||
return button | ||
}() | ||
|
||
private let verticalTextBarView: UIView = { | ||
let verticalTextBarView: UIView = { | ||
let view = UIView() | ||
view.backgroundColor = .donPale | ||
return view | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아래는 코드 패치입니다. 이 코드에 대한 간략한 코드 리뷰를 도와드리겠습니다. 버그 위험 또는 개선 제안이 있으면 알려주세요.
개선 제안:
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 코드 패치는 주어진 파일들을 프로젝트에 추가하는 역할을 합니다. 패치 내용을 살펴보면, 3CF4651B2B58398900997FCA 파일과 관련된 빌드 설정과 파일 참조가 추가되었습니다.
개선 사항: