Skip to content
Open
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
8 changes: 7 additions & 1 deletion Seminar/Seminar-7th/Seminar-7th/Controller/GestureVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,19 @@ class GestureVC: UIViewController {
let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(tapView(gestureRecognizer:)))

let tapRecognizer2 = UITapGestureRecognizer()
tapRecognizer2.addTarget(self, action: #selector(tapView(gestureRecognizer:)))
tapRecognizer2.addTarget(self, action: #selector(tapBackView(gestureRecognizer:)))

tapView.addGestureRecognizer(tapRecognizer)
view.addGestureRecognizer(tapRecognizer2)
}

@objc
private func tapView(gestureRecognizer: UIGestureRecognizer) {
print("tap tap")
}

@objc
private func tapBackView(gestureRecognizer: UIGestureRecognizer) {
print("back tap tap!!!")
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="19455" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="QbF-Ic-uYM">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="19455" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="vs9-wP-dMK">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19454"/>
Expand Down
8 changes: 8 additions & 0 deletions Youtube-Clone/Youtube-Clone.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

/* Begin PBXBuildFile section */
0BF0FDD2F0F8E52688A8C591 /* Pods_Youtube_Clone.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 116B126FDB9241A9A4C761ED /* Pods_Youtube_Clone.framework */; };
EDBD400D2775F522004D78C2 /* VideoVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDBD400C2775F522004D78C2 /* VideoVC.swift */; };
EDBD400F2775F8FE004D78C2 /* UITableViewCell+.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDBD400E2775F8FE004D78C2 /* UITableViewCell+.swift */; };
EDD5FBF52711DE3100CDC4CB /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = EDD5FBF42711DE3100CDC4CB /* GoogleService-Info.plist */; };
EDF32E9F270A0F9400BE49FC /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDF32E9E270A0F9400BE49FC /* AppDelegate.swift */; };
EDF32EA9270A0F9400BE49FC /* Youtube_Clone.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = EDF32EA7270A0F9400BE49FC /* Youtube_Clone.xcdatamodeld */; };
Expand Down Expand Up @@ -40,6 +42,8 @@
/* Begin PBXFileReference section */
116B126FDB9241A9A4C761ED /* Pods_Youtube_Clone.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Youtube_Clone.framework; sourceTree = BUILT_PRODUCTS_DIR; };
6361FB9BF21A793637C74691 /* Pods-Youtube-Clone.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Youtube-Clone.debug.xcconfig"; path = "Target Support Files/Pods-Youtube-Clone/Pods-Youtube-Clone.debug.xcconfig"; sourceTree = "<group>"; };
EDBD400C2775F522004D78C2 /* VideoVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VideoVC.swift; sourceTree = "<group>"; };
EDBD400E2775F8FE004D78C2 /* UITableViewCell+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UITableViewCell+.swift"; sourceTree = "<group>"; };
EDD5FBF42711DE3100CDC4CB /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
EDF32E9B270A0F9400BE49FC /* Youtube-Clone.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Youtube-Clone.app"; sourceTree = BUILT_PRODUCTS_DIR; };
EDF32E9E270A0F9400BE49FC /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -170,6 +174,7 @@
EDF32EC8270A244000BE49FC /* UITextField+.swift */,
EDF32ECE270A38E300BE49FC /* UIViewController+.swift */,
EDF62444272981A00099176B /* UIWindow+.swift */,
EDBD400E2775F8FE004D78C2 /* UITableViewCell+.swift */,
);
path = Extensions;
sourceTree = "<group>";
Expand Down Expand Up @@ -224,6 +229,7 @@
EDF624472729830F0099176B /* LockerVC.swift */,
EDF624262729729A0099176B /* HomeVC.swift */,
EDF624242729727E0099176B /* TabbarController.swift */,
EDBD400C2775F522004D78C2 /* VideoVC.swift */,
);
path = Main;
sourceTree = "<group>";
Expand Down Expand Up @@ -433,8 +439,10 @@
EDF624552729CC420099176B /* Thumbnail.swift in Sources */,
EDF624592729D63E0099176B /* HomeHeaderView.swift in Sources */,
EDF624612729E3370099176B /* HomeTopHeader.swift in Sources */,
EDBD400D2775F522004D78C2 /* VideoVC.swift in Sources */,
EDF6245F2729E0300099176B /* Channel.swift in Sources */,
EDF32EC5270A1DDC00BE49FC /* UIView+.swift in Sources */,
EDBD400F2775F8FE004D78C2 /* UITableViewCell+.swift in Sources */,
EDF624522729C6DC0099176B /* ThumbnailTVC.swift in Sources */,
EDF624482729830F0099176B /* LockerVC.swift in Sources */,
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "icn_dismissBtn.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "icn_expandBtn.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// UITableViewCell+.swift
// Youtube-Clone
//
// Created by SHIN YOON AH on 2021/12/24.
//

import UIKit

extension UITableViewCell {
func getTableCellIndexPath() -> Int {
var indexPath = 0

guard let superView = self.superview as? UITableView else {
return -1
}
indexPath = superView.indexPath(for: self)!.row

return indexPath
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public enum YoutubeIcon {
public static var wesoptWebPart: UIImage { .load(name: "wesoptWebPart")}
public static var wesoptiOSPart: UIImage { .load(name: "wesoptiOSPart")}
public static var windowSharingIcon: UIImage { .load(name: "windowSharingIcon")}
public static var icn_dismissBtn: UIImage { .load(name: "icn_dismissBtn")}
public static var icn_expandBtn: UIImage { .load(name: "icn_expandBtn")}
}

extension UIImage {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import UIKit
import Then
import SnapKit

protocol ImageViewDelegate: HomeVC {
func didClickedThumbnailImage(vc: UIViewController)
}

class HomeVC: UIViewController {

// MARK: - UI
Expand Down Expand Up @@ -69,6 +73,7 @@ extension HomeVC: UITableViewDataSource {
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
guard let cell = tableView.dequeueReusableCell(withIdentifier: ThumbnailTVC.identifier) as? ThumbnailTVC else { return UITableViewCell() }
cell.getCellConfigureAt(indexPath.row)
cell.delegate = self
return cell
}
}
Expand All @@ -94,10 +99,7 @@ extension HomeVC: UITableViewDelegate {
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
return UIView()
}
}

// MARK: - ScrollDelegate
extension HomeVC {

func scrollViewDidScroll(_ scrollView: UIScrollView) {
let offset = scrollView.contentOffset.y

Expand All @@ -119,3 +121,11 @@ extension HomeVC {
}
}
}

// MARK: - ImageViewDelegate
extension HomeVC: ImageViewDelegate {
func didClickedThumbnailImage(vc: UIViewController) {
vc.modalPresentationStyle = .fullScreen
present(vc, animated: true, completion: nil)
}
}
107 changes: 107 additions & 0 deletions Youtube-Clone/Youtube-Clone/Sources/ViewControllers/Main/VideoVC.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
//
// VideoVC.swift
// Youtube-Clone
//
// Created by SHIN YOON AH on 2021/12/24.
//

import UIKit

import Then
import SnapKit

final class VideoVC: UIViewController {

// MARK: - UI

private let menuButton = UIButton().then {
$0.setImage(YoutubeIcon.icn_expandBtn, for: .normal)
}
private let backButton = UIButton().then {
$0.setImage(YoutubeIcon.icn_dismissBtn, for: .normal)
$0.addTarget(self, action: #selector(touchUpBackButton), for: .touchUpInside)
}
private let titleLabel = UILabel().then {
$0.font = .systemFont(ofSize: 15)
$0.numberOfLines = 2
}
private let infoLabel = UILabel().then {
$0.font = .systemFont(ofSize: 13)
$0.textColor = .subGray
}
private let thumbnailImage = UIImageView().then {
$0.contentMode = .scaleToFill
}

// MARK: - Properties

private let manager = HomeManager.shared

// MARK: - View Life Cycle

override func viewDidLoad() {
super.viewDidLoad()
setupLayout()
configUI()
}

// MARK: - Setup Methods

private func setupLayout() {
view.addSubviews([thumbnailImage,
backButton,
menuButton,
titleLabel,
infoLabel])

thumbnailImage.snp.makeConstraints {
$0.top.leading.trailing.equalTo(view.safeAreaLayoutGuide)
$0.height.equalTo(212)
}

backButton.snp.makeConstraints {
$0.top.equalTo(thumbnailImage)
$0.leading.equalToSuperview()
$0.width.height.equalTo(36)
}

menuButton.snp.makeConstraints {
$0.top.equalTo(thumbnailImage.snp.bottom).offset(12)
$0.trailing.equalToSuperview().inset(7)
}

titleLabel.snp.makeConstraints {
$0.top.equalTo(menuButton)
$0.leading.equalToSuperview().inset(12)
$0.width.equalTo(UIScreen.main.bounds.size.width * 0.72)
}

infoLabel.snp.makeConstraints {
$0.top.equalTo(titleLabel.snp.bottom).offset(4)
$0.leading.equalTo(titleLabel)
}
}

private func configUI() {
view.backgroundColor = .white
}

// MARK: - Public Method

public func setVideoData(index: Int) {
thumbnailImage.image = manager.getThumbnailImage(index: index)
titleLabel.text = manager.getTitle(index: index)

let author = manager.getAuthor(index: index)
let views = manager.getViews(index: index)
let created = manager.getCreatedDate(index: index)
infoLabel.text = "\(author) ・ 조회수 \(views) ・ \(created) "
}

// MARK: - Selector

@objc
private func touchUpBackButton() {
dismiss(animated: true, completion: nil)
}
}
20 changes: 20 additions & 0 deletions Youtube-Clone/Youtube-Clone/Sources/Views/Cells/ThumbnailTVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ class ThumbnailTVC: UITableViewCell {

// MARK: - Properties
private let manager = HomeManager.shared
weak var delegate: ImageViewDelegate?

// MARK: - Initalizing
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
setupLayout()
setupTapGesture()
}

required init?(coder: NSCoder) {
Expand All @@ -52,6 +54,7 @@ class ThumbnailTVC: UITableViewCell {
menuButton,
titleLabel,
infoLabel])
sendSubviewToBack(contentView)

thumbnailImage.snp.makeConstraints {
$0.top.leading.trailing.equalToSuperview()
Expand Down Expand Up @@ -81,8 +84,25 @@ class ThumbnailTVC: UITableViewCell {
$0.bottom.equalToSuperview().inset(27)
}
}

private func setupTapGesture() {
let gesture = UITapGestureRecognizer(target: self, action: #selector(didTappedThumbnail(_:)))
thumbnailImage.addGestureRecognizer(gesture)
thumbnailImage.isUserInteractionEnabled = true
}

// MARK: - Selector

@objc
private func didTappedThumbnail(_ gesture: UITapGestureRecognizer) {
let vc = VideoVC()
let index = getTableCellIndexPath()
vc.setVideoData(index: index)
delegate?.didClickedThumbnailImage(vc: vc)
}

// MARK: - Public Method

public func getCellConfigureAt(_ index: Int) {
thumbnailImage.image = manager.getThumbnailImage(index: index)
titleLabel.text = manager.getTitle(index: index)
Expand Down