-
Notifications
You must be signed in to change notification settings - Fork 0
PopUpRegisterViewControler 분리 #106
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
Merged
zzangzzangguy
merged 4 commits into
develop
from
refactor/#102-popup-register-viewcontroller-split
Apr 13, 2025
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c6f406e
refactor/#102: PopUpRegisterViewController Reactor 분리
zzangzzangguy 29738f8
refactor/#102: RegisterVC View와 PopUpImagesColletionView로 분리
zzangzzangguy 2d5909d
chore/#102: 주석 제거 및 등록 시간 15분 단위로 수정
zzangzzangguy b8bc440
style/#102: Apply SwiftLint autocorrect
github-actions[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
Poppool/Poppool/Presentation/Admin/AdminRegister/PopUpImagesCollectionView.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| import UIKit | ||
|
|
||
| import SnapKit | ||
|
|
||
| final class PopUpImagesCollectionView: UICollectionView { | ||
| // MARK: - Properties | ||
| enum Constant { | ||
| static let imageWidth: CGFloat = 80 | ||
| static let imageHeight: CGFloat = 120 | ||
| static let imageSpacing: CGFloat = 8 | ||
| } | ||
|
|
||
| var onImageSelected: ((Int) -> Void)? | ||
| var onMainImageToggled: ((Int) -> Void)? | ||
| var onImageDeleted: ((Int) -> Void)? | ||
|
Member
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. Rx가 아니라 클로저로 스트림을 연결한 이유가 따로 있을까요?
Contributor
Author
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. 단순이벤트라 판단되어 연산자체인에 오버헤드인지 .. 빌드에서 무한빌드가 되는케이스가 있었습니다 |
||
|
|
||
| private var images: [ExtendedImage] = [] | ||
|
|
||
| // MARK: - init | ||
| init() { | ||
| let layout = UICollectionViewFlowLayout() | ||
| layout.scrollDirection = .horizontal | ||
| layout.itemSize = CGSize(width: Constant.imageWidth, height: Constant.imageHeight) | ||
| layout.minimumLineSpacing = Constant.imageSpacing | ||
|
|
||
| super.init(frame: .zero, collectionViewLayout: layout) | ||
|
|
||
| self.addViews() | ||
| self.setupContstraints() | ||
| self.configureUI() | ||
| } | ||
|
|
||
| required init?(coder: NSCoder) { | ||
| fatalError("\(#file), \(#function) Error") | ||
| } | ||
| } | ||
|
|
||
| // MARK: - Setup | ||
| private extension PopUpImagesCollectionView { | ||
| func addViews() { } | ||
|
|
||
| func setupContstraints() { } | ||
|
|
||
| func configureUI() { | ||
| self.backgroundColor = .clear | ||
| self.register(ImageCell.self, forCellWithReuseIdentifier: ImageCell.identifier) | ||
| self.dataSource = self | ||
| self.delegate = self | ||
| self.showsHorizontalScrollIndicator = false | ||
| } | ||
| } | ||
|
|
||
| // MARK: - Public Methods | ||
| extension PopUpImagesCollectionView { | ||
| func updateImages(_ images: [ExtendedImage]) { | ||
| self.images = images | ||
| self.reloadData() | ||
| } | ||
| } | ||
|
|
||
| // MARK: - UICollectionViewDataSource | ||
| extension PopUpImagesCollectionView: UICollectionViewDataSource { | ||
| func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { | ||
| return self.images.count | ||
| } | ||
|
|
||
| func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { | ||
| guard let cell = collectionView.dequeueReusableCell( | ||
| withReuseIdentifier: ImageCell.identifier, | ||
| for: indexPath | ||
| ) as? ImageCell else { | ||
| return UICollectionViewCell() | ||
| } | ||
|
|
||
| let item = self.images[indexPath.item] | ||
| cell.configure(with: item) | ||
|
|
||
| // 대표이미지 변경 | ||
| cell.onMainCheckToggled = { [weak self] in | ||
| self?.onMainImageToggled?(indexPath.item) | ||
| } | ||
|
|
||
| // 개별 삭제 | ||
| cell.onDeleteTapped = { [weak self] in | ||
| self?.onImageDeleted?(indexPath.item) | ||
| } | ||
|
|
||
| return cell | ||
| } | ||
| } | ||
|
|
||
| // MARK: - UICollectionViewDelegate | ||
| extension PopUpImagesCollectionView: UICollectionViewDelegate { | ||
| func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { | ||
| self.onImageSelected?(indexPath.item) | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
저희가 맞추기로 하였던 상수값을 빼는 부분을 적용해 주셨군요 좋습니다 :>