-
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
Feat [#43] 마이페이지 뷰 SegmentControl 상단 고정 기능 구현 완료 #49
Changes from all commits
cad880c
75f34d5
f449e58
049992b
60a7c27
4ca7a86
c269ae1
8d03a15
d5f2096
a6e52f0
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 |
---|---|---|
|
@@ -11,7 +11,7 @@ final class CircleProgressbar: UIView { | |
|
||
var lineWidth: CGFloat = 2 | ||
var circleBackgroundColor: UIColor = .gray | ||
var circleTintColor: UIColor = .black | ||
var circleTintColor: UIColor = .clear | ||
|
||
var value: Double? { | ||
didSet { | ||
|
@@ -33,7 +33,11 @@ final class CircleProgressbar: UIView { | |
override func draw(_ rect: CGRect) { | ||
let bezierPath = UIBezierPath() | ||
|
||
bezierPath.addArc(withCenter: CGPoint(x: rect.midX, y: rect.midY), radius: rect.midX - ((lineWidth - 1) / 2), startAngle: 0, endAngle: .pi * 2, clockwise: true) | ||
bezierPath.addArc(withCenter: CGPoint(x: rect.midX, y: rect.midY), | ||
radius: rect.midX - ((lineWidth) / 2), | ||
startAngle: 0, | ||
endAngle: .pi * 2, | ||
clockwise: true) | ||
|
||
bezierPath.lineWidth = lineWidth | ||
circleBackgroundColor.set() | ||
|
@@ -45,17 +49,22 @@ final class CircleProgressbar: UIView { | |
return | ||
} | ||
|
||
|
||
self.subviews.forEach { $0.removeFromSuperview() } | ||
self.layer.sublayers?.forEach { $0.removeFromSuperlayer() } | ||
|
||
let bezierPath = UIBezierPath() | ||
|
||
bezierPath.addArc(withCenter: CGPoint(x: rect.midX, y: rect.midY), radius: rect.midX - ((lineWidth - 1) / 2), startAngle: -.pi / 2, endAngle: ((.pi * 2) * value) - (.pi / 2), clockwise: true) | ||
bezierPath.addArc(withCenter: CGPoint(x: rect.midX, y: rect.midY), | ||
radius: rect.midX - ((lineWidth) / 2), | ||
startAngle: -.pi / 2, | ||
endAngle: ((.pi * 2) * value) - (.pi / 2), | ||
clockwise: true) | ||
|
||
let shapeLayer = CAShapeLayer() | ||
|
||
shapeLayer.path = bezierPath.cgPath | ||
shapeLayer.lineCap = .square | ||
shapeLayer.lineCap = .round | ||
|
||
shapeLayer.strokeColor = circleTintColor.cgColor | ||
shapeLayer.fillColor = UIColor.clear.cgColor | ||
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 |
---|---|---|
|
@@ -7,23 +7,22 @@ | |
|
||
import UIKit | ||
|
||
class MyPageCommentViewController: UIViewController { | ||
import SnapKit | ||
|
||
final class MyPageCommentViewController: UIViewController { | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
self.view.backgroundColor = .donWhite | ||
setUI() | ||
setLayout() | ||
} | ||
|
||
|
||
/* | ||
// MARK: - Navigation | ||
|
||
// In a storyboard-based application, you will often want to do a little preparation before navigation | ||
override func prepare(for segue: UIStoryboardSegue, sender: Any?) { | ||
// Get the new view controller using segue.destination. | ||
// Pass the selected object to the new view controller. | ||
private func setUI() { | ||
self.view.backgroundColor = .donPale | ||
} | ||
|
||
private func setLayout() { | ||
|
||
} | ||
*/ | ||
|
||
} | ||
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. 아래는 코드 패치입니다. 코드 리뷰를 짧게 도와드리겠습니다. 버그 위험과/또는 개선 제안이 있는지 확인해주세요. ❌ "import SnapKit" 라인이 @@ -7,23 +7,22 @@ 와 함께 추가되어 코드가 병합된 것으로 보입니다. 따라서 코드 조각 전체가 제공되지 않았으며 누락된 부분을 파악하기 어렵습니다. 요약:
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. 이 코드 패치에 대한 간단한 코드 리뷰를 도와드리겠습니다. 버그 위험과/또는 개선 제안을 환영합니다. 주어진 코드 패치는 SnapKit 라이브러리를 추가로 임포트하고 UI 구성과 레이아웃 설정하는 데 사용되는 메서드가 추가되었습니다. 버그 위험:
개선 제안:
일반적으로 코드 리뷰는 더 많은 상황과 코드 내용을 고려해야하지만, 주어진 정보로는 일부 개선 제안 및 버그 위험을 알려드릴 수 있었습니다. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,23 +7,224 @@ | |
|
||
import UIKit | ||
|
||
class MyPageContentViewController: UIViewController { | ||
import SnapKit | ||
|
||
final class MyPageContentViewController: UIViewController { | ||
|
||
// MARK: - Properties | ||
|
||
var tabBarHeight: CGFloat = 0 | ||
var showUploadToastView: Bool = false | ||
var deleteBottomsheet = DontBeBottomSheetView(singleButtonImage: ImageLiterals.Posting.btnDelete) | ||
private let refreshControl = UIRefreshControl() | ||
|
||
// MARK: - UI Components | ||
|
||
lazy var homeCollectionView = HomeCollectionView().collectionView | ||
private let uploadToastView = DontBeToastView() | ||
|
||
private let transparentButtonPopupView = DontBePopupView(popupImage: ImageLiterals.Popup.transparentButtonImage, | ||
popupTitle: StringLiterals.Home.transparentPopupTitleLabel, | ||
popupContent: StringLiterals.Home.transparentPopupContentLabel, | ||
leftButtonTitle: StringLiterals.Home.transparentPopupLefteftButtonTitle, | ||
rightButtonTitle: StringLiterals.Home.transparentPopupRightButtonTitle) | ||
|
||
// MARK: - Life Cycles | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
getAPI() | ||
setUI() | ||
setHierarchy() | ||
setLayout() | ||
setDelegate() | ||
setNotification() | ||
setRefreshControll() | ||
} | ||
|
||
// MARK: - TabBar Height | ||
|
||
override func viewDidLayoutSubviews() { | ||
super.viewDidLayoutSubviews() | ||
|
||
tabBarHeight = tabBarController?.tabBar.frame.size.height ?? 0 | ||
} | ||
} | ||
|
||
self.view.backgroundColor = .donWhite | ||
// MARK: - Extensions | ||
|
||
extension MyPageContentViewController { | ||
private func setUI() { | ||
self.view.backgroundColor = UIColor.donGray1 | ||
self.navigationController?.navigationBar.isHidden = true | ||
uploadToastView.alpha = 0 | ||
transparentButtonPopupView.alpha = 0 | ||
} | ||
|
||
private func setHierarchy() { | ||
view.addSubviews(homeCollectionView, | ||
uploadToastView, | ||
transparentButtonPopupView) | ||
} | ||
|
||
private func setLayout() { | ||
homeCollectionView.snp.makeConstraints { | ||
$0.top.equalTo(self.view.safeAreaLayoutGuide.snp.top) | ||
$0.leading.trailing.bottom.equalToSuperview() | ||
$0.width.equalTo(UIScreen.main.bounds.width) | ||
} | ||
|
||
uploadToastView.snp.makeConstraints { | ||
$0.leading.trailing.equalToSuperview().inset(16.adjusted) | ||
$0.bottom.equalTo(tabBarHeight).inset(6.adjusted) | ||
$0.height.equalTo(44) | ||
} | ||
|
||
transparentButtonPopupView.snp.makeConstraints { | ||
$0.edges.equalToSuperview() | ||
} | ||
} | ||
|
||
private func setDelegate() { | ||
homeCollectionView.dataSource = self | ||
homeCollectionView.delegate = self | ||
transparentButtonPopupView.delegate = self | ||
} | ||
|
||
private func setNotification() { | ||
NotificationCenter.default.addObserver(self, selector: #selector(showToast(_:)), name: WriteViewController.showUploadToastNotification, object: nil) | ||
} | ||
|
||
private func setRefreshControll() { | ||
refreshControl.addTarget(self, action: #selector(refreshPost), for: .valueChanged) | ||
homeCollectionView.refreshControl = refreshControl | ||
refreshControl.backgroundColor = .donGray1 | ||
} | ||
|
||
@objc | ||
func refreshPost() { | ||
DispatchQueue.main.async { | ||
// ✅ 서버 통신 영역 | ||
// | ||
} | ||
self.homeCollectionView.reloadData() | ||
self.perform(#selector(self.finishedRefreshing), with: nil, afterDelay: 0.1) | ||
} | ||
|
||
@objc | ||
func finishedRefreshing() { | ||
refreshControl.endRefreshing() | ||
} | ||
|
||
|
||
|
||
@objc func showToast(_ notification: Notification) { | ||
if let showToast = notification.userInfo?["showToast"] as? Bool { | ||
if showToast == true { | ||
uploadToastView.alpha = 1 | ||
|
||
var value: Double = 0.0 | ||
let duration: TimeInterval = 1.0 // 애니메이션 기간 (초 단위) | ||
let increment: Double = 0.01 // 증가량 | ||
|
||
// 0에서 1까지 1초 동안 0.01씩 증가하는 애니메이션 블록 | ||
UIView.animate(withDuration: duration, delay: 0.0, options: .curveLinear, animations: { | ||
for i in 1...100 { | ||
DispatchQueue.main.asyncAfter(deadline: .now() + (duration / 100) * TimeInterval(i)) { | ||
value = Double(i) * increment | ||
self.uploadToastView.circleProgressBar.value = value | ||
} | ||
} | ||
}) | ||
|
||
DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) { | ||
self.uploadToastView.circleProgressBar.alpha = 0 | ||
self.uploadToastView.checkImageView.alpha = 1 | ||
self.uploadToastView.toastLabel.text = StringLiterals.Toast.uploaded | ||
self.uploadToastView.container.backgroundColor = .donPrimary | ||
} | ||
|
||
UIView.animate(withDuration: 1.0, delay: 3, options: .curveEaseIn) { | ||
self.uploadToastView.alpha = 0 | ||
} | ||
|
||
DispatchQueue.main.asyncAfter(deadline: .now() + 4.0) { | ||
self.uploadToastView.circleProgressBar.alpha = 1 | ||
self.uploadToastView.checkImageView.alpha = 0 | ||
self.uploadToastView.toastLabel.text = StringLiterals.Toast.uploading | ||
self.uploadToastView.container.backgroundColor = .donGray3 | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
// MARK: - Network | ||
|
||
/* | ||
// MARK: - Navigation | ||
extension MyPageContentViewController { | ||
private func getAPI() { | ||
|
||
} | ||
} | ||
|
||
extension MyPageContentViewController: UICollectionViewDelegate { } | ||
|
||
extension MyPageContentViewController: UICollectionViewDataSource, UICollectionViewDelegateFlowLayout { | ||
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { | ||
return 10 | ||
} | ||
|
||
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { | ||
let cell = | ||
HomeCollectionViewCell.dequeueReusableCell(collectionView: collectionView, indexPath: indexPath) | ||
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 = { | ||
self.transparentButtonPopupView.alpha = 1 | ||
} | ||
return cell | ||
} | ||
|
||
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { | ||
return CGSize(width: 343.adjusted, height: 210.adjusted) | ||
} | ||
Comment on lines
+194
to
+196
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. P1 |
||
|
||
func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView { | ||
guard let footer = homeCollectionView.dequeueReusableSupplementaryView(ofKind: UICollectionView.elementKindSectionFooter, withReuseIdentifier: "HomeCollectionFooterView", for: indexPath) as? HomeCollectionFooterView else { return UICollectionReusableView() } | ||
return footer | ||
} | ||
|
||
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForFooterInSection section: Int) -> CGSize { | ||
|
||
return CGSize(width: UIScreen.main.bounds.width, height: 24.adjusted) | ||
} | ||
} | ||
|
||
// In a storyboard-based application, you will often want to do a little preparation before navigation | ||
override func prepare(for segue: UIStoryboardSegue, sender: Any?) { | ||
// Get the new view controller using segue.destination. | ||
// Pass the selected object to the new view controller. | ||
extension MyPageContentViewController: UIScrollViewDelegate { | ||
func scrollViewDidScroll(_ scrollView: UIScrollView) { | ||
let yOffset = scrollView.contentOffset.y | ||
let navigationBarHeight = self.navigationController?.navigationBar.frame.height ?? 0 | ||
if yOffset > 0 { | ||
scrollView.isScrollEnabled = true | ||
} else if yOffset < 0 { | ||
scrollView.isScrollEnabled = false | ||
} | ||
} | ||
*/ | ||
} | ||
|
||
extension MyPageContentViewController: DontBePopupDelegate { | ||
func cancleButtonTapped() { | ||
transparentButtonPopupView.alpha = 0 | ||
} | ||
|
||
func confirmButtonTapped() { | ||
transparentButtonPopupView.alpha = 0 | ||
// ✅ 투명도 주기 버튼 클릭 시 액션 추가 | ||
} | ||
} | ||
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.
제시된 코드 패치의 주요 변경 사항은 다음과 같습니다:
[...] MyPageSegmentedControlView.swift in Sources
와 관련된 부분이 변경되었습니다.3C49936A2B4FF118002A99CF
)가 제거되었습니다.PBXBuildFile
및PBXFileReference
에서 해당 파일을 참조하고 있던 항목들이 삭제되었습니다.추가적으로,
Cells
그룹에 대한 새로운PBXGroup
이 추가되었습니다. 하지만 현재로서는 비어 있습니다.개선 제안 및 버그 위험 사항 등에 대해서는 보여진 코드만으로는 파악하기 어렵습니다. 전체 소스 코드나 실행 환경 정보를 알 수 없기 때문입니다. 이러한 세부 정보를 함께 제공해주시면 추가적인 도움을 드릴 수 있습니다.