-
Notifications
You must be signed in to change notification settings - Fork 2
[FEAT/#1] 참가자 화면 컬렉션 뷰를 구현합니다. #42
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
Merged
Changes from 10 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
142b9af
feat/#1 :: 참여자 화면 컬렉션 뷰와 셀 구현
Kiyoung-Kim-57 a814b6b
chore/#1 :: Update .pbxproj
Kiyoung-Kim-57 32d140c
feat/#1 :: 자간 설정 메소드 UILabel 익스텐션으로 추가
youn9k dae76a7
feat/#1 :: 참여자뷰Cell 구현
youn9k 39a523d
feat/#1 :: 참여자 컬렉션뷰 DiffableDataSource SectioItem 구현
youn9k e68812e
feat/#1 ::참여자 컬렉션 뷰 DiffableDataSource 구현
youn9k 9a7d4d3
feat/#1 :: 참여자화면CollectionViewController 데이터 소스 연결
youn9k 6ed4935
chore/#1 :: pbxproj 변경
youn9k 95cc1b6
chore/#1 :: 파일명 수정
youn9k f544f94
fix :: lint 에러에 따른 코드 수정
youn9k e74def4
fix/#1 :: 코멘트 반영
youn9k 755f77d
fix/#1 :: 코멘트 반영
youn9k 13cd274
fix/#1 :: 코멘트 반영
youn9k 840fdc4
chore :: SwiftLint SPM 의존성 제거
youn9k 7db815d
Merge branch 'develop' into feat/#1-participants-view
youn9k 65439db
fix/#1 :: 코멘트 반영
youn9k 5c2595e
fix/#1 :: 코멘트 반영
youn9k 880b6d5
feat/#1 :: 코멘트 반영
youn9k 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
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
26 changes: 26 additions & 0 deletions
26
PhotoGether/PresentationLayer/BaseFeature/BaseFeature/Extension/UILabel+setKern.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,26 @@ | ||
| import UIKit | ||
|
|
||
| public extension UILabel { | ||
| /// 자간을 설정하는 메소드입니다. | ||
| /// - Parameter kernValue: 자간입니다. | ||
| /// - Parameter lineBreakMode: 텍스트가 짤릴 경우 어떻게 처리할 것인지 | ||
| /// - Parameter alignment: 텍스트를 어떻게 정렬할 것인지 | ||
| func setKern( | ||
| kernValue: Double? = -0.32, | ||
| lineBreakMode: NSLineBreakMode = .byTruncatingTail, | ||
| alignment: NSTextAlignment = .left | ||
| ) { | ||
| let paragraphStyle = NSMutableParagraphStyle() | ||
|
|
||
| paragraphStyle.lineBreakMode = lineBreakMode | ||
| paragraphStyle.alignment = alignment | ||
|
|
||
| let attributes: [NSAttributedString.Key: Any] = [ | ||
| .paragraphStyle: paragraphStyle, | ||
| .kern: kernValue ?? 0.0 | ||
| ] | ||
| let attributedString = NSMutableAttributedString(string: text ?? "", attributes: attributes) | ||
|
|
||
| self.attributedText = attributedString | ||
| } | ||
| } |
43 changes: 43 additions & 0 deletions
43
...onLayer/EditPhotoRoomFeature/EditPhotoRoomFeature/Source/EditPhotoRoomHostViewModel.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,43 @@ | ||
| import Foundation | ||
| import Combine | ||
|
|
||
| public final class EditPhotoRoomHostViewModel { | ||
| enum Input { | ||
| case stickerButtonDidTap | ||
| } | ||
|
|
||
| enum Output { | ||
| case rectangle(rect: Rectangle) | ||
| } | ||
|
|
||
| private var cancellables = Set<AnyCancellable>() | ||
| private var output = PassthroughSubject<Output, Never>() | ||
|
|
||
| public init() { } | ||
|
|
||
| func transform(input: AnyPublisher<Input, Never>) -> AnyPublisher<Output, Never> { | ||
| input.sink { [weak self] in | ||
| switch $0 { | ||
| case .stickerButtonDidTap: | ||
| self?.generateRectangle() | ||
| } | ||
| } | ||
| .store(in: &cancellables) | ||
|
|
||
| return output.eraseToAnyPublisher() | ||
| } | ||
|
|
||
| private func generateRectangle() { | ||
| let randomX = Int.random(in: 10..<100) | ||
| let randomY = Int.random(in: 10..<100) | ||
| let width = Int.random(in: 10..<100) | ||
| let height = Int.random(in: 10..<100) | ||
|
|
||
| let rectangle = Rectangle( | ||
| position: CGPoint(x: randomX, y: randomY), | ||
| size: CGSize(width: width, height: height) | ||
| ) | ||
|
|
||
| output.send(.rectangle(rect: rectangle)) | ||
| } | ||
| } |
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
30 changes: 30 additions & 0 deletions
30
...RoomFeature/PhotoRoomFeature/Source/DataSource/ParticipantsCollectionViewDataSource.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,30 @@ | ||
| import UIKit | ||
|
|
||
| public typealias Section = Int | ||
| public typealias SectionItem = ParticipantsSectionItem | ||
|
|
||
| public final class ParticipantsCollectionViewDataSource: UICollectionViewDiffableDataSource<Section, SectionItem> { | ||
| public static func create( | ||
| collectionView: UICollectionView | ||
| ) -> UICollectionViewDiffableDataSource<Section, SectionItem> { | ||
| let dataSource = UICollectionViewDiffableDataSource<Section, SectionItem>( | ||
| collectionView: collectionView | ||
| ) { collectionView, indexPath, _ in | ||
| return configureCell(collectionView: collectionView, indexPath: indexPath) | ||
| } | ||
| return dataSource | ||
| } | ||
|
|
||
| private static func configureCell( | ||
| collectionView: UICollectionView, | ||
| indexPath: IndexPath | ||
| ) -> UICollectionViewCell? { | ||
| guard let cell = collectionView.dequeueReusableCell( | ||
| withReuseIdentifier: ParticipantsCollectionViewCell.reuseIdentifier, | ||
| for: indexPath | ||
| ) as? ParticipantsCollectionViewCell else { | ||
| return UICollectionViewCell() | ||
| } | ||
| return cell | ||
| } | ||
| } |
26 changes: 26 additions & 0 deletions
26
...ntationLayer/PhotoRoomFeature/PhotoRoomFeature/Source/Model/ParticipantsSectionItem.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,26 @@ | ||
| import Foundation | ||
|
|
||
| public struct ParticipantsSectionItem: Hashable, Equatable { | ||
| public private(set) var nickname: String | ||
| public let videoID: Int | ||
| private let identifier = UUID() | ||
|
|
||
| public init(videoID: Int, nickname: String) { | ||
| self.videoID = videoID | ||
| self.nickname = nickname | ||
| } | ||
|
|
||
| public mutating func setNickname(_ nickname: String) { | ||
| self.nickname = nickname | ||
| } | ||
| } | ||
|
|
||
| public extension ParticipantsSectionItem { | ||
| func hash(into hasher: inout Hasher) { | ||
| hasher.combine(identifier) | ||
| } | ||
|
|
||
| static func == (lhs: ParticipantsSectionItem, rhs: ParticipantsSectionItem) -> Bool { | ||
| lhs.identifier == rhs.identifier | ||
| } | ||
| } | ||
youn9k marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
65 changes: 65 additions & 0 deletions
65
...nLayer/PhotoRoomFeature/PhotoRoomFeature/Source/View/ParticipantsCollectionViewCell.swift
youn9k marked this conversation as resolved.
Show resolved
Hide resolved
|
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,65 @@ | ||
| import UIKit | ||
| import BaseFeature | ||
| import SnapKit | ||
|
|
||
| public final class ParticipantsCollectionViewCell: UICollectionViewCell { | ||
| public static let reuseIdentifier = "\(ParticipantsCollectionViewCell.self)" | ||
youn9k marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| private let nicknameLabel = UILabel() | ||
| private var videoView = UIView() | ||
|
|
||
| public override init(frame: CGRect) { | ||
| super.init(frame: frame) | ||
| addViews() | ||
| setConstraints() | ||
| configureUI() | ||
| } | ||
|
|
||
| public required init?(coder: NSCoder) { | ||
| fatalError() | ||
| } | ||
|
|
||
| public func setNickname(_ nickname: String) { | ||
| self.nicknameLabel.text = nickname | ||
| } | ||
|
|
||
| public func setVideoView(_ videoView: UIView) { | ||
| self.videoView = videoView | ||
| } | ||
|
|
||
| private func addViews() { | ||
| [videoView, nicknameLabel].forEach { | ||
| contentView.addSubview($0) | ||
| } | ||
| } | ||
|
|
||
| private func setConstraints() { | ||
| videoView.snp.makeConstraints { | ||
| $0.edges.equalToSuperview() | ||
| } | ||
|
|
||
| nicknameLabel.snp.makeConstraints { | ||
| $0.width.equalTo(Constants.nicknameLabelWidth) | ||
| $0.height.equalTo(Constants.nicknameLabelHeight) | ||
| $0.top.equalToSuperview().offset(Constants.nicknameLabelTopSpacing) | ||
| $0.trailing.equalToSuperview().inset(Constants.nicknameLabelTrailingSpacing) | ||
| } | ||
| } | ||
|
|
||
| private func configureUI() { | ||
| nicknameLabel.font = .systemFont(ofSize: 11) | ||
| nicknameLabel.setKern() | ||
| nicknameLabel.textColor = .white.withAlphaComponent(0.8) | ||
| nicknameLabel.backgroundColor = UIColor.black.withAlphaComponent(0.4) | ||
| nicknameLabel.layer.cornerRadius = 20 | ||
| } | ||
| } | ||
|
|
||
| extension ParticipantsCollectionViewCell { | ||
| enum Constants { | ||
| static let nicknameLabelWidth: CGFloat = 40 | ||
| static let nicknameLabelHeight: CGFloat = 20 | ||
| static let nicknameLabelTopSpacing: CGFloat = 8 | ||
| static let nicknameLabelTrailingSpacing: CGFloat = 8 | ||
| } | ||
| } | ||
youn9k marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Oops, something went wrong.
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.
자간 설정하는건 처음보는데 이렇게 하는군요!
저희도 라벨 쓰는곳이 있었는데 디벨롭에 들어오면 적용해봐야겠네요☺️