Skip to content
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: "Add playlist view" #72

Merged
merged 5 commits into from
Jan 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions haruSpeak_iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
E5E984DA296EE2A300E5DE83 /* HomeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E5E984D9296EE2A300E5DE83 /* HomeViewController.swift */; };
E5E984DC296EE2AF00E5DE83 /* StudyViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E5E984DB296EE2AF00E5DE83 /* StudyViewController.swift */; };
E5E984DE296EE2BA00E5DE83 /* MyPageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E5E984DD296EE2BA00E5DE83 /* MyPageViewController.swift */; };
E5F7F4DA297F9A540004800E /* CommentCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = E5F7F4D9297F9A540004800E /* CommentCell.swift */; };
E5FD566629790E0A0088DDAF /* SearchFilterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E5FD566529790E0A0088DDAF /* SearchFilterView.swift */; };
E5FD5668297A2A640088DDAF /* PlaylistViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E5FD5667297A2A640088DDAF /* PlaylistViewController.swift */; };
/* End PBXBuildFile section */
Expand Down Expand Up @@ -113,6 +114,7 @@
E5E984D9296EE2A300E5DE83 /* HomeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeViewController.swift; sourceTree = "<group>"; };
E5E984DB296EE2AF00E5DE83 /* StudyViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StudyViewController.swift; sourceTree = "<group>"; };
E5E984DD296EE2BA00E5DE83 /* MyPageViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyPageViewController.swift; sourceTree = "<group>"; };
E5F7F4D9297F9A540004800E /* CommentCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommentCell.swift; sourceTree = "<group>"; };
E5FD566529790E0A0088DDAF /* SearchFilterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchFilterView.swift; sourceTree = "<group>"; };
E5FD5667297A2A640088DDAF /* PlaylistViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlaylistViewController.swift; sourceTree = "<group>"; };
E5FD566A297C29590088DDAF /* AppleSDGothicNeo-Semibold.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "AppleSDGothicNeo-Semibold.ttf"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -376,6 +378,7 @@
children = (
E51CE8BC296F77B500ADB07B /* CustomTabbar.swift */,
E51CE8BE296FBED100ADB07B /* RecordCell.swift */,
E5F7F4D9297F9A540004800E /* CommentCell.swift */,
);
path = Home;
sourceTree = "<group>";
Expand Down Expand Up @@ -642,6 +645,7 @@
68BD8E052971B80400939DFB /* RecordViewController.swift in Sources */,
68BD8E20297D7D1D00939DFB /* DeleteViewController.swift in Sources */,
E5E984B6296ED95300E5DE83 /* UIColor+.swift in Sources */,
E5F7F4DA297F9A540004800E /* CommentCell.swift in Sources */,
E51CE8C92971038A00ADB07B /* ClickRecordViewController.swift in Sources */,
E5FD5668297A2A640088DDAF /* PlaylistViewController.swift in Sources */,
E59D362629742C3B00A012C4 /* AssignmentView.swift in Sources */,
Expand Down
143 changes: 143 additions & 0 deletions haruSpeak_iOS/View/Home/CommentCell.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
//
// CommentCell.swift
// haruSpeak_iOS
//
// Created by 077tech on 2023/01/24.
//


import UIKit

final class CommentCell: UICollectionViewCell {
//MARK: - Properties
static let identifier = "RecordCell"

let profileImage = UIImageView().then{
$0.backgroundColor = .lightGray
}
let comment = UILabel().then{
$0.text = "Nothing beats About time"
$0.font = UIFont(name:"appleSDGothicNeo-Semibold", size: 16)
}
let date = UILabel().then{
$0.text = "01/10 13:41"
$0.font = UIFont(name:"appleSDGothicNeo-Regular", size: 13)
$0.textColor = .lightGray
}
let thumbsupImage = UIImageView().then{
$0.image = UIImage(named: "thumbsup.blue")?.withRenderingMode(.alwaysOriginal)
}
let countTumbsup = UILabel().then{
$0.text = "2"
$0.font = UIFont(name:"appleSDGothicNeo-Regular", size: 13)
$0.textColor = .mainColor
}
let commentImage = UIImageView().then{
$0.image = UIImage(named: "comment.unfill")?.withRenderingMode(.alwaysOriginal)
}
let divideView = UIView().then{
$0.backgroundColor = .lightGray
}
let clickThumbsup = UIImageView().then{
$0.image = UIImage(named: "thumbsup")?.withRenderingMode(.alwaysOriginal)
}
let line = UIView().then{
$0.backgroundColor = UIColor.systemGray5
}


//MARK: - ButtonArray
let thumbsupButtonArray = ["thumbsup","thumbsup.blue"]
var thumbsupindex = 0


//MARK: - Init
override init(frame: CGRect) {
super.init(frame: frame)
self.setupView()
self.setupLayout()
self.addTarget()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

//MARK: - Selector
@objc func didClickThumbsup(sender: UITapGestureRecognizer) {
self.thumbsupindex = (self.thumbsupindex >= self.thumbsupButtonArray.count-1) ? 0 : self.thumbsupindex+1
self.clickThumbsup.image = UIImage(named:thumbsupButtonArray[thumbsupindex])
if self.thumbsupindex == 0{
print("clickUnlike")
}else{
print("clickLike")
}
}
//MARK: - addSubView
private func setupView(){
self.addSubview(self.profileImage)
self.addSubview(self.comment)
self.addSubview(self.date)
self.addSubview(self.thumbsupImage)
self.addSubview(self.countTumbsup)
self.addSubview(self.commentImage)
self.addSubview(self.divideView)
self.addSubview(self.clickThumbsup)
self.addSubview(self.line)

}

//MARK: - layout
private func setupLayout(){
self.profileImage.snp.makeConstraints{
$0.leading.equalToSuperview().offset(34)
$0.top.equalToSuperview().offset(22)
$0.size.width.height.equalTo(35)
}
self.comment.snp.makeConstraints{
$0.leading.equalTo(self.profileImage.snp.trailing).offset(13)
$0.top.equalToSuperview().offset(22)
}
self.date.snp.makeConstraints{
$0.leading.equalTo(self.profileImage.snp.trailing).offset(13)
$0.top.equalTo(self.comment.snp.bottom).offset(3)
}
self.thumbsupImage.snp.makeConstraints{
$0.leading.equalTo(self.date.snp.trailing).offset(5)
$0.top.equalTo(self.comment.snp.bottom).offset(5)
}
self.countTumbsup.snp.makeConstraints{
$0.leading.equalTo(self.thumbsupImage.snp.trailing).offset(5)
$0.top.equalTo(self.comment.snp.bottom).offset(5)
}
self.clickThumbsup.snp.makeConstraints{
$0.centerY.equalToSuperview()
$0.trailing.equalToSuperview().offset(-14)
}
self.divideView.snp.makeConstraints{
$0.width.equalTo(1)
$0.height.equalTo(5)
$0.trailing.equalTo(self.clickThumbsup.snp.leading).offset(-3)
$0.centerY.equalToSuperview()
}
self.commentImage.snp.makeConstraints{
$0.trailing.equalTo(self.divideView.snp.leading).offset(-3)
$0.centerY.equalToSuperview()
}
self.line.snp.makeConstraints{
$0.bottom.equalToSuperview().offset(0)
$0.size.height.equalTo(1)
$0.leading.equalToSuperview().offset(13)
$0.trailing.equalToSuperview().offset(-13)
}

}

//MARK: - AddTarget
private func addTarget(){

let thumbsupBtn = UITapGestureRecognizer(target: self, action: #selector(didClickThumbsup))
clickThumbsup.isUserInteractionEnabled = true
clickThumbsup.addGestureRecognizer(thumbsupBtn)
}
}

85 changes: 81 additions & 4 deletions haruSpeak_iOS/ViewController/Home/PlaylistViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import UIKit
import SnapKit
import Then


class PlaylistViewController: UIViewController{
//MARK: - Properties
// NAVIGATION BAR
Expand Down Expand Up @@ -87,18 +88,33 @@ class PlaylistViewController: UIViewController{
}
//BOTTOMVIEW
let bottomView = UIView().then{
$0.backgroundColor = .yellow
$0.backgroundColor = .white
}
let labelBottomview = UILabel().then{
$0.text = "댓글"
$0.font = UIFont(name:"appleSDGothicNeo-Semibold", size: 15)
}
lazy var commentCollectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()).then {
$0.register(CommentCell.self, forCellWithReuseIdentifier: CommentCell.identifier)
$0.backgroundColor = .clear
$0.showsHorizontalScrollIndicator = false
$0.showsVerticalScrollIndicator = false
}




//COMMENTSUMBMIT
let bottomFixedView = UIView().then{
$0.backgroundColor = .white
}
let commentSubmitView = UIView().then{
$0.backgroundColor = .lightGray
$0.backgroundColor = .systemGray6
$0.roundCorners(cornerRadius: 10, maskedCorners: [.layerMaxXMaxYCorner, .layerMinXMaxYCorner, .layerMaxXMinYCorner, .layerMinXMinYCorner])
}
let commentTextField = UITextField().then{
$0.placeholder = "피드백을 남겨보세요!"
$0.font = UIFont(name:"appleSDGothicNeo-Regular", size: 13)

}
let submitButton = UIImageView().then{
Expand All @@ -116,6 +132,9 @@ class PlaylistViewController: UIViewController{
setupView()
setupLayout()
addTarget()
setupCollectionView()

self.navigationController?.navigationBar.isHidden = true;

}
//MARK: - Selector
Expand Down Expand Up @@ -148,8 +167,10 @@ class PlaylistViewController: UIViewController{
self.topView.addSubview(self.playButton)
self.topView.addSubview(self.heartImage)
self.topView.addSubview(self.heartCount)
//BOTTOMVIEW (추가사항 있음)
//BOTTOMVIEW
self.totalView.addSubview(self.bottomView)
self.bottomView.addSubview(self.labelBottomview)
self.bottomView.addSubview(self.commentCollectionView)
//COMMENTSUBMIT
view.addSubview(self.bottomFixedView)
self.bottomFixedView.addSubview(self.commentSubmitView)
Expand Down Expand Up @@ -261,7 +282,16 @@ class PlaylistViewController: UIViewController{
$0.trailing.equalToSuperview().offset(-35)
}
//BOTTOMVIEW

self.labelBottomview.snp.makeConstraints{
$0.top.equalToSuperview().offset(20)
$0.leading.equalToSuperview().offset(34)
}
self.commentCollectionView.snp.makeConstraints{
$0.top.equalTo(self.labelBottomview.snp.bottom).offset(0)
$0.leading.equalToSuperview().offset(10)
$0.trailing.equalToSuperview().offset(-10)
$0.bottom.equalToSuperview().offset(-10)
}

//COMMENTSUBMIT
self.bottomFixedView.snp.makeConstraints{
Expand All @@ -272,6 +302,7 @@ class PlaylistViewController: UIViewController{
$0.top.equalToSuperview().offset(7)
$0.leading.equalToSuperview().offset(7)
$0.trailing.equalToSuperview().offset(-7)
$0.size.height.equalTo(40)
}
self.commentTextField.snp.makeConstraints{
$0.centerY.equalToSuperview()
Expand All @@ -294,5 +325,51 @@ class PlaylistViewController: UIViewController{
backButton.addGestureRecognizer(backBtn)
}

//MARK: - SetupCollectionView
func setupCollectionView(){

self.commentCollectionView.delegate = self
self.commentCollectionView.dataSource = self
}

}



//CollectionVIew
extension PlaylistViewController: UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout {
func numberOfSections(in collectionView: UICollectionView) -> Int {
return 1
}

func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 10
}

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: CommentCell.identifier, for: indexPath) as! CommentCell



return cell
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: CommentCell.identifier, for: indexPath) as! CommentCell


}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
return 5
}

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
return 0
}

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {

return CGSize(width: self.view.frame.width , height: 70)
}


}