diff --git a/assignment-Youtube/assignment-Youtube.xcodeproj/project.pbxproj b/assignment-Youtube/assignment-Youtube.xcodeproj/project.pbxproj index be04440..bf1e19e 100644 --- a/assignment-Youtube/assignment-Youtube.xcodeproj/project.pbxproj +++ b/assignment-Youtube/assignment-Youtube.xcodeproj/project.pbxproj @@ -17,6 +17,7 @@ 1430B1602710A298005A0538 /* LoginViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1430B15F2710A298005A0538 /* LoginViewController.swift */; }; 1430B1622710A2C5005A0538 /* SignUpViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1430B1612710A2C5005A0538 /* SignUpViewController.swift */; }; 1430B1642710A2D0005A0538 /* CompleteViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1430B1632710A2D0005A0538 /* CompleteViewController.swift */; }; + 143AEB8C2775FDB30024789D /* HomeDetailVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 143AEB8B2775FDB30024789D /* HomeDetailVC.swift */; }; 146C9E942710980D0065A609 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 146C9E932710980D0065A609 /* AppDelegate.swift */; }; 146C9E962710980D0065A609 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 146C9E952710980D0065A609 /* SceneDelegate.swift */; }; 146C9E982710980D0065A609 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 146C9E972710980D0065A609 /* ViewController.swift */; }; @@ -47,6 +48,7 @@ 1430B15F2710A298005A0538 /* LoginViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginViewController.swift; sourceTree = ""; }; 1430B1612710A2C5005A0538 /* SignUpViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SignUpViewController.swift; sourceTree = ""; }; 1430B1632710A2D0005A0538 /* CompleteViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CompleteViewController.swift; sourceTree = ""; }; + 143AEB8B2775FDB30024789D /* HomeDetailVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeDetailVC.swift; sourceTree = ""; }; 146C9E902710980D0065A609 /* assignment-Youtube.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "assignment-Youtube.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 146C9E932710980D0065A609 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 146C9E952710980D0065A609 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; @@ -142,6 +144,7 @@ 14020A092722F24C00AF0375 /* SubscriptionVC.swift */, 146C9E972710980D0065A609 /* ViewController.swift */, 14020A012722F1FD00AF0375 /* YoutubeTabBarController.swift */, + 143AEB8B2775FDB30024789D /* HomeDetailVC.swift */, ); path = VC; sourceTree = ""; @@ -372,6 +375,7 @@ 1430B1622710A2C5005A0538 /* SignUpViewController.swift in Sources */, 14020A062722F22800AF0375 /* ShortsVC.swift in Sources */, 1430B1642710A2D0005A0538 /* CompleteViewController.swift in Sources */, + 143AEB8C2775FDB30024789D /* HomeDetailVC.swift in Sources */, 14EFE90D2741419900864A81 /* NetworkResult.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/assignment-Youtube/assignment-Youtube/Source/Screen/Cell/HomeTableViewCell.swift b/assignment-Youtube/assignment-Youtube/Source/Screen/Cell/HomeTableViewCell.swift index d3c0667..319d124 100644 --- a/assignment-Youtube/assignment-Youtube/Source/Screen/Cell/HomeTableViewCell.swift +++ b/assignment-Youtube/assignment-Youtube/Source/Screen/Cell/HomeTableViewCell.swift @@ -16,14 +16,29 @@ class HomeTableViewCell: UITableViewCell { @IBOutlet weak var homeVideoSpec: UILabel! @IBOutlet weak var homeVideoActButton: UIButton! + var showVideoDetail: (() -> ())? + override func awakeFromNib() { super.awakeFromNib() +// homeVideoThumbnail.addGestureRecognizer(UIGestureRecognizer(target: self, action: #selector(imageTapped(_:)))) + setGesture() + } + + func setGesture() { + let gesture = UITapGestureRecognizer(target: self, action: #selector(imageTapped)) + homeVideoThumbnail.addGestureRecognizer(gesture) + homeVideoThumbnail.isUserInteractionEnabled = true } override func setSelected(_ selected: Bool, animated: Bool) { super.setSelected(selected, animated: animated) } + @objc func imageTapped(_ sender: UITapGestureRecognizer) { + print("taptap") + showVideoDetail?() + } + func setData(appData: HomeVideo) { homeVideoThumbnail.image = appData.makeVideoThumbnailImage() homeVideoProfileImage.image = appData.makeVideoOwnerImage() diff --git a/assignment-Youtube/assignment-Youtube/Source/Screen/Component/HomeTableViewCell.xib b/assignment-Youtube/assignment-Youtube/Source/Screen/Component/HomeTableViewCell.xib index f2dad5f..39bdf06 100644 --- a/assignment-Youtube/assignment-Youtube/Source/Screen/Component/HomeTableViewCell.xib +++ b/assignment-Youtube/assignment-Youtube/Source/Screen/Component/HomeTableViewCell.xib @@ -1,8 +1,8 @@ - + - + @@ -18,6 +18,7 @@ + diff --git a/assignment-Youtube/assignment-Youtube/Source/Screen/Storyboard/Base.lproj/Main.storyboard b/assignment-Youtube/assignment-Youtube/Source/Screen/Storyboard/Base.lproj/Main.storyboard index 3277508..ae90518 100644 --- a/assignment-Youtube/assignment-Youtube/Source/Screen/Storyboard/Base.lproj/Main.storyboard +++ b/assignment-Youtube/assignment-Youtube/Source/Screen/Storyboard/Base.lproj/Main.storyboard @@ -1,5 +1,5 @@ - + @@ -565,6 +565,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assignment-Youtube/assignment-Youtube/Source/Screen/VC/HomeDetailVC.swift b/assignment-Youtube/assignment-Youtube/Source/Screen/VC/HomeDetailVC.swift new file mode 100644 index 0000000..50de896 --- /dev/null +++ b/assignment-Youtube/assignment-Youtube/Source/Screen/VC/HomeDetailVC.swift @@ -0,0 +1,42 @@ +// +// HomeDetailVC.swift +// assignment-Youtube +// +// Created by 이남준 on 2021/12/24. +// + +import UIKit + +class HomeDetailVC: UIViewController { + + static let identifier = "HomeDetailVC" + + @IBOutlet weak var detailImageView: UIImageView! + @IBOutlet weak var detailVideoNameLabel: UILabel! + @IBOutlet weak var detailVideoSpecLabel: UILabel! + @IBOutlet weak var goToVideoListButton: UIButton! + + var detailInfo: HomeVideo? + + override func viewDidLoad() { + super.viewDidLoad() + setData() + } + + func setUIConfigure() { + goToVideoListButton.layer.zPosition = 1000 + } + + func setData() { + guard let detailInfo = self.detailInfo else {return} + self.detailImageView.image = detailInfo.makeVideoThumbnailImage() + self.detailVideoNameLabel.text = detailInfo.videoName + self.detailVideoSpecLabel.text = detailInfo.videoDescription + } + + @IBAction func goToVideoList(_ sender: Any) { +// guard let presentingVC = self.presentingViewController as? UINavigationController else { return } +// let viewControllerStack = presentingVC.viewControllers + self.dismiss(animated: true, completion: nil) + } +} diff --git a/assignment-Youtube/assignment-Youtube/Source/Screen/VC/HomeVC.swift b/assignment-Youtube/assignment-Youtube/Source/Screen/VC/HomeVC.swift index df7f61b..3c24526 100644 --- a/assignment-Youtube/assignment-Youtube/Source/Screen/VC/HomeVC.swift +++ b/assignment-Youtube/assignment-Youtube/Source/Screen/VC/HomeVC.swift @@ -8,6 +8,7 @@ import UIKit class HomeVC: UIViewController { + @IBOutlet weak var accountButton: UIButton! @IBOutlet weak var homeVideoTableView: UITableView! @@ -69,6 +70,11 @@ class HomeVC: UIViewController { self.present(nextVC, animated: true, completion: nil) } + func showVideoDetail() { + guard let detailVC = self.storyboard?.instantiateViewController(withIdentifier: "HomeDetailVC") as? HomeDetailVC else {return} + + self.present(detailVC, animated: true, completion: nil) + } } extension HomeVC: UITableViewDelegate { @@ -87,10 +93,18 @@ extension HomeVC: UITableViewDataSource { HomeTableViewCell else {return UITableViewCell()} cell.setData(appData: homeVideoList[indexPath.row]) + + cell.showVideoDetail = { + guard let detailVC = self.storyboard?.instantiateViewController(withIdentifier: "HomeDetailVC") as? HomeDetailVC else {return} + + detailVC.detailInfo = self.homeVideoList[indexPath.row] + + detailVC.modalPresentationStyle = .fullScreen + self.present(detailVC, animated: true, completion: nil) + } + return cell } - - } extension HomeVC: UICollectionViewDataSource { @@ -103,6 +117,7 @@ extension HomeVC: UICollectionViewDataSource { as? HomeCollectionViewCell else {return UICollectionViewCell()} cell.setData(iconImage: homeShortsVideoList[indexPath.row].makeVideoOwnerImage(), nameLabel: homeShortsVideoList[indexPath.row].videoOwnerName) + return cell } }