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 Calendar Stretch Function Added" TEMP #49

Merged
merged 1 commit into from
Jan 23, 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
Binary file not shown.
1 change: 1 addition & 0 deletions haruSpeak_iOS/View/Home/RecordCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ final class RecordCell: UICollectionViewCell {
print("clickPause")
}else{
print("clickPlay")
// HomeViewController().blueViewup()
}

}
Expand Down
106 changes: 89 additions & 17 deletions haruSpeak_iOS/ViewController/Home/HomeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ import MaterialComponents.MaterialButtons
class HomeViewController: UIViewController, FSCalendarDelegate, FSCalendarDataSource, FSCalendarDelegateAppearance{

//MARK: - Properties
private var calendarConstraint : Constraint?
// TOPVIEW START
private let topView = UIView().then{
let topView = UIView().then{
$0.roundCorners(cornerRadius: 30, maskedCorners: [.layerMaxXMaxYCorner, .layerMinXMaxYCorner])
$0.backgroundColor = .white
$0.layer.borderWidth = 0.3
Expand Down Expand Up @@ -68,15 +69,16 @@ class HomeViewController: UIViewController, FSCalendarDelegate, FSCalendarDataSo
}
// TOPVIEW END

private let recordCollectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()).then {
let recordCollectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()).then {
$0.register(RecordCell.self, forCellWithReuseIdentifier: RecordCell.identifier)
$0.backgroundColor = .systemGray6
}

var collectionViewindex = 0

//BLUE PLAYLIST VIEW
private let blueView = UIView().then{
var blueViewRemoved = true
let blueView = UIView().then{
$0.backgroundColor = .mainColor
}
private let playButton = UIImageView().then{
Expand Down Expand Up @@ -168,11 +170,6 @@ class HomeViewController: UIViewController, FSCalendarDelegate, FSCalendarDataSo

}
@objc func didClickAlarm(sender: UITapGestureRecognizer) {
//testcode start
let VC = PlaylistViewController()
VC.modalPresentationStyle = .fullScreen
present(VC, animated: true)
//testcode finish
print("didClickAlarm")
}
@objc func didClickAnnouncement(sender: UITapGestureRecognizer) {
Expand All @@ -188,12 +185,72 @@ class HomeViewController: UIViewController, FSCalendarDelegate, FSCalendarDataSo
}
}
@objc func didClickClose(_ sender: Any) {
print("Click Clost blue Playlist")
print("Click Close blue Playlist")

UIView.animate(withDuration: 0, delay: 0, options: .curveEaseIn, animations: {
self.recordCollectionView.snp.makeConstraints {
$0.top.equalTo(self.topView.snp.bottom).offset(20)
$0.bottom.trailing.leading.equalToSuperview()
}
}) { _ in
self.blueViewRemoved = true
self.view.layoutIfNeeded()
}
}


// //TEST (RecordCell에서 play버튼 누르면 popup하게 만들기)
// func blueViewup(){
// print("Click blueViewup")
//
// UIView.animate(withDuration: 0, delay: 0, options: .curveEaseIn, animations: {
// self.recordCollectionView.removeFromSuperview()
// self.blueView.removeFromSuperview()
//
// self.view.addSubview(self.recordCollectionView)
// self.view.addSubview(self.blueView)
//
// self.recordCollectionView.snp.makeConstraints {
// $0.top.equalTo(self.topView.snp.bottom).offset(20)
// $0.trailing.leading.equalToSuperview()
// $0.bottom.equalTo(self.blueView.snp.top)
// }
// self.blueView.snp.makeConstraints{
// $0.leading.trailing.equalToSuperview()
// $0.bottom.equalToSuperview().offset(-80)
// $0.size.height.equalTo(70)
// }
// }) { _ in
// self.blueViewRemoved = false
// self.view.layoutIfNeeded()
// }
// }
// //TEST

@objc func didClickBlueView(_ sender: Any) {
print("Click blue Playlist")
let VC = PlaylistViewController()
VC.modalPresentationStyle = .fullScreen
present(VC, animated: true)
}


// 캘린더 늘리기 일단 보류
// @objc func didDragCalendar(sender: UIPanGestureRecognizer) {
@objc func didDragCalendar(sender: UITapGestureRecognizer) {
if self.calendar.scope == .week{
self.calendarConstraint?.update(offset: 550)
UIView.animate(withDuration: 0.2){
self.calendar.scope = .month
self.view.layoutIfNeeded()
}
}else{
self.calendarConstraint?.update(offset: 320)
UIView.animate(withDuration: 0){
self.calendar.scope = .week
self.view.layoutIfNeeded()
}
}
}
// let velocity = sender.velocity(in: self.view) //속도
// let translation = sender.translation(in: self.view) //위치
// let height = self.topView.frame.maxY
Expand All @@ -217,11 +274,12 @@ class HomeViewController: UIViewController, FSCalendarDelegate, FSCalendarDataSo
//
// }
// }
//
// }






//MARK: - addSubView
private func setupView(){
self.view.addSubview(self.topView)
Expand All @@ -246,10 +304,11 @@ class HomeViewController: UIViewController, FSCalendarDelegate, FSCalendarDataSo


//MARK: - Layout

private func setupLayout(){
self.topView.snp.makeConstraints{
$0.top.trailing.leading.equalToSuperview().offset(0)
$0.height.equalTo(320)
self.calendarConstraint = $0.height.equalTo(320).constraint
}
self.date.snp.makeConstraints{
$0.top.equalTo(self.topView.snp.top).offset(54)
Expand Down Expand Up @@ -336,11 +395,15 @@ class HomeViewController: UIViewController, FSCalendarDelegate, FSCalendarDataSo
let closeBtn = UITapGestureRecognizer(target: self, action: #selector(didClickClose))
closeButton.isUserInteractionEnabled = true
closeButton.addGestureRecognizer(closeBtn)

let blueViewButton = UITapGestureRecognizer(target: self, action: #selector(didClickBlueView))
blueView.isUserInteractionEnabled = true
blueView.addGestureRecognizer(blueViewButton)
// 캘린더 늘리기 일단 보류
// let CalendarDrag = UIPanGestureRecognizer(target: self, action: #selector(didDragCalendar))
// lineView.isUserInteractionEnabled = true
// lineView.addGestureRecognizer(CalendarDrag)
//
let CalendarDrag = UITapGestureRecognizer(target: self, action: #selector(didDragCalendar))
lineView.isUserInteractionEnabled = true
lineView.addGestureRecognizer(CalendarDrag)

}


Expand Down Expand Up @@ -369,6 +432,15 @@ extension HomeViewController: UICollectionViewDelegate, UICollectionViewDataSour

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

// let playBtn = UITapGestureRecognizer(target: self, action: #selector(didClickPlayinRecordCell))
// cell.playButton.isUserInteractionEnabled = true
// cell.playButton.addGestureRecognizer(playBtn)





return cell
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
Expand Down