Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d5b1d7d544 | |||
| bc339c6387 | |||
| 5cf8d804db | |||
| 719cd350d8 | |||
| be0627889a | |||
| e0e96c1616 | |||
| 06e9ebd304 | |||
| 4b1d1c02d0 | |||
| a99278c591 |
@@ -0,0 +1,2 @@
|
||||
xcshareddata/
|
||||
xcuserdata/
|
||||
@@ -23,7 +23,7 @@ All extra views are located in Navigation Controller and Main View Controller in
|
||||
|
||||
## Compatibility
|
||||
|
||||
This project is written in Swift 3.0 and requires Xcode 8.2 to build and run.
|
||||
This project is written in Swift 3.0 and requires Xcode 8.2 or newer to build and run.
|
||||
|
||||
Youtube iOS Template is compatible with iOS 9.1+.
|
||||
|
||||
|
||||
@@ -167,20 +167,21 @@
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastSwiftUpdateCheck = 0800;
|
||||
LastUpgradeCheck = 0830;
|
||||
LastUpgradeCheck = 1020;
|
||||
ORGANIZATIONNAME = "Haik Aslanyan";
|
||||
TargetAttributes = {
|
||||
22AA44621D1302FB00CA6185 = {
|
||||
CreatedOnToolsVersion = 8.0;
|
||||
DevelopmentTeam = P6GDVV24N5;
|
||||
DevelopmentTeamName = "Haik Aslanyan (Personal Team)";
|
||||
LastSwiftMigration = 0900;
|
||||
ProvisioningStyle = Automatic;
|
||||
};
|
||||
};
|
||||
};
|
||||
buildConfigurationList = 22AA445E1D1302FB00CA6185 /* Build configuration list for PBXProject "YouTube" */;
|
||||
compatibilityVersion = "Xcode 3.2";
|
||||
developmentRegion = English;
|
||||
developmentRegion = en;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
@@ -249,20 +250,29 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
@@ -285,12 +295,13 @@
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
@@ -298,20 +309,29 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
@@ -328,10 +348,11 @@
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
SWIFT_VERSION = 5.0;
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
name = Release;
|
||||
@@ -348,7 +369,8 @@
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.haik.YouTube;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE = "";
|
||||
SWIFT_VERSION = 3.0;
|
||||
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = 1;
|
||||
};
|
||||
name = Debug;
|
||||
@@ -365,7 +387,8 @@
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.haik.YouTube;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE = "";
|
||||
SWIFT_VERSION = 3.0;
|
||||
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = 1;
|
||||
};
|
||||
name = Release;
|
||||
|
||||
Generated
BIN
Binary file not shown.
@@ -27,7 +27,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
|
||||
var window: UIWindow?
|
||||
|
||||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
|
||||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "hqdefault.jpg",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
+21
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "hqdefault-2.jpg",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
@@ -1050,7 +1050,7 @@
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="none" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="H4z-ax-9yb">
|
||||
<rect key="frame" x="0.0" y="64" width="375" height="573"/>
|
||||
<rect key="frame" x="0.0" y="64" width="375" height="603"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<prototypes>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="none" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="Header" rowHeight="120" id="vS7-wy-332" customClass="AccountHeaderCell" customModule="YouTube" customModuleProvider="target">
|
||||
@@ -1204,7 +1204,7 @@
|
||||
<constraint firstItem="H4z-ax-9yb" firstAttribute="top" secondItem="Qje-LE-mkz" secondAttribute="bottom" id="9JK-4X-1np"/>
|
||||
<constraint firstAttribute="trailing" secondItem="H4z-ax-9yb" secondAttribute="trailing" id="GAK-EV-y3k"/>
|
||||
<constraint firstItem="H4z-ax-9yb" firstAttribute="leading" secondItem="MQs-ls-4t6" secondAttribute="leading" id="f4E-2f-GW4"/>
|
||||
<constraint firstItem="VQX-7h-Dqp" firstAttribute="top" secondItem="H4z-ax-9yb" secondAttribute="bottom" constant="30" id="mjR-0j-m3a"/>
|
||||
<constraint firstItem="VQX-7h-Dqp" firstAttribute="top" secondItem="H4z-ax-9yb" secondAttribute="bottom" id="mjR-0j-m3a"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/>
|
||||
|
||||
@@ -32,12 +32,12 @@ extension UIColor{
|
||||
}
|
||||
|
||||
extension MutableCollection where Index == Int {
|
||||
mutating func shuffle() {
|
||||
mutating func myShuffle() {
|
||||
if count < 2 { return }
|
||||
for i in startIndex ..< endIndex - 1 {
|
||||
let j = Int(arc4random_uniform(UInt32(endIndex - i))) + i
|
||||
if i != j {
|
||||
swap(&self[i], &self[j])
|
||||
self.swapAt(i, j)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,26 +49,26 @@ class Video {
|
||||
|
||||
//MARK: Methods
|
||||
class func fetchVideos(completion: @escaping (([Video]) -> Void)) {
|
||||
let video1 = Video.init(title: "What Does Jared Kushner Believe?", channelName: "Nerdwriter1")
|
||||
let video2 = Video.init(title: "Moore's Law Is Ending... So, What's Next?", channelName: "Seeker")
|
||||
let video1 = Video.init(title: "What Does Jared Kushner Believe", channelName: "Nerdwriter1")
|
||||
let video2 = Video.init(title: "Moore's Law Is Ending. So, What's Next", channelName: "Seeker")
|
||||
let video3 = Video.init(title: "What Bill Gates is afraid of", channelName: "Vox")
|
||||
let video4 = Video.init(title: "Why Can't America Have a Grown-Up Healthcare Conversation?", channelName: "vlogbrothers")
|
||||
let video4 = Video.init(title: "Why Can't America Have a Grown-Up Healthcare Conversation", channelName: "vlogbrothers")
|
||||
let video5 = Video.init(title: "A New History for Humanity – The Human Era", channelName: "Kurzgesagt – In a Nutshell")
|
||||
let video6 = Video.init(title: "Neural Network that Changes Everything - Computerphile", channelName: "Computerphile")
|
||||
let video7 = Video.init(title: "TensorFlow Basics - Deep Learning with Neural Networks p. 2", channelName: "sentdex")
|
||||
let video8 = Video.init(title: "Scott Galloway: The Retailer Growing Faster Than Amazon", channelName: "L2inc")
|
||||
var items = [video1, video2, video3, video4, video5, video6, video7, video8]
|
||||
items.shuffle()
|
||||
items.myShuffle()
|
||||
completion(items)
|
||||
}
|
||||
|
||||
class func fetchVideo(completion: @escaping ((Video) -> Void)) {
|
||||
let video = Video.init(title: "Big Buck Bunny", channelName: "Blender Foundation")
|
||||
video.videoLink = URL.init(string: "http://sample-videos.com/video/mp4/360/big_buck_bunny_360p_10mb.mp4")!
|
||||
let suggestedVideo1 = SuggestedVideo.init(title: "What Does Jared Kushner Believe?", channelName: "Nerdwriter1")
|
||||
let suggestedVideo2 = SuggestedVideo.init(title: "Moore's Law Is Ending... So, What's Next?", channelName: "Seeker")
|
||||
let suggestedVideo1 = SuggestedVideo.init(title: "What Does Jared Kushner Believe", channelName: "Nerdwriter1")
|
||||
let suggestedVideo2 = SuggestedVideo.init(title: "Moore's Law Is Ending. So, What's Next", channelName: "Seeker")
|
||||
let suggestedVideo3 = SuggestedVideo.init(title: "What Bill Gates is afraid of", channelName: "Vox")
|
||||
let suggestedVideo4 = SuggestedVideo.init(title: "Why Can't America Have a Grown-Up Healthcare Conversation?", channelName: "vlogbrothers")
|
||||
let suggestedVideo4 = SuggestedVideo.init(title: "Why Can't America Have a Grown-Up Healthcare Conversation", channelName: "vlogbrothers")
|
||||
let suggestedVideo5 = SuggestedVideo.init(title: "TensorFlow Basics - Deep Learning with Neural Networks p. 2", channelName: "sentdex")
|
||||
let items = [suggestedVideo1, suggestedVideo2, suggestedVideo3, suggestedVideo4, suggestedVideo5]
|
||||
video.suggestedVideos = items
|
||||
@@ -103,7 +103,7 @@ class Channel {
|
||||
let channel = Channel.init(name: name, image: image!)
|
||||
items.append(channel)
|
||||
}
|
||||
items.shuffle()
|
||||
items.myShuffle()
|
||||
completion(items)
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ protocol PlayerVCDelegate {
|
||||
func didmaximize()
|
||||
func swipeToMinimize(translation: CGFloat, toState: stateOfVC)
|
||||
func didEndedSwipe(toState: stateOfVC)
|
||||
func setPreferStatusBarHidden(_ preferHidden: Bool)
|
||||
}
|
||||
|
||||
import UIKit
|
||||
@@ -46,7 +47,7 @@ class PlayerView: UIView, UITableViewDelegate, UITableViewDataSource, UIGestureR
|
||||
self.backgroundColor = UIColor.clear
|
||||
self.tableView.delegate = self
|
||||
self.tableView.dataSource = self
|
||||
self.tableView.rowHeight = UITableViewAutomaticDimension
|
||||
self.tableView.rowHeight = UITableView.automaticDimension
|
||||
self.tableView.estimatedRowHeight = 90
|
||||
self.player.layer.anchorPoint.applying(CGAffineTransform.init(translationX: -0.5, y: -0.5))
|
||||
self.tableView.tableFooterView = UIView.init(frame: CGRect.init(x: 0, y: 0, width: 0, height: 0))
|
||||
@@ -61,11 +62,11 @@ class PlayerView: UIView, UITableViewDelegate, UITableViewDataSource, UIGestureR
|
||||
self.minimizeButton.alpha = 1
|
||||
self.tableView.alpha = 1
|
||||
self.player.transform = CGAffineTransform.identity
|
||||
UIApplication.shared.isStatusBarHidden = true
|
||||
self.delegate?.setPreferStatusBarHidden(true)
|
||||
})
|
||||
case .minimized:
|
||||
UIView.animate(withDuration: 0.3, animations: {
|
||||
UIApplication.shared.isStatusBarHidden = false
|
||||
self.delegate?.setPreferStatusBarHidden(false)
|
||||
self.minimizeButton.alpha = 0
|
||||
self.tableView.alpha = 0
|
||||
let scale = CGAffineTransform.init(scaleX: 0.5, y: 0.5)
|
||||
@@ -84,7 +85,7 @@ class PlayerView: UIView, UITableViewDelegate, UITableViewDataSource, UIGestureR
|
||||
self.player.transform = trasform
|
||||
}
|
||||
|
||||
func tapPlayView() {
|
||||
@objc func tapPlayView() {
|
||||
self.videoPlayer.play()
|
||||
self.state = .fullScreen
|
||||
self.delegate?.didmaximize()
|
||||
@@ -180,7 +181,7 @@ class PlayerView: UIView, UITableViewDelegate, UITableViewDataSource, UIGestureR
|
||||
weakSelf.videoPlayer = AVPlayer.init(url: weakSelf.video.videoLink)
|
||||
let playerLayer = AVPlayerLayer.init(player: weakSelf.videoPlayer)
|
||||
playerLayer.frame = weakSelf.player.frame
|
||||
playerLayer.videoGravity = AVLayerVideoGravityResizeAspectFill
|
||||
playerLayer.videoGravity = AVLayerVideoGravity.resizeAspectFill
|
||||
|
||||
weakSelf.player.layer.addSublayer(playerLayer)
|
||||
if weakSelf.state != .hidden {
|
||||
|
||||
@@ -39,7 +39,7 @@ class TabBarView: UIView, UICollectionViewDelegateFlowLayout, UICollectionViewDa
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(self.animateMenu(notification:)), name: Notification.Name.init(rawValue: "scrollMenu"), object: nil)
|
||||
}
|
||||
|
||||
func animateMenu(notification: Notification) {
|
||||
@objc func animateMenu(notification: Notification) {
|
||||
if let info = notification.userInfo {
|
||||
let userInfo = info as! [String: CGFloat]
|
||||
self.whiteBarLeadingConstraint.constant = self.whiteBar.bounds.width * userInfo["length"]!
|
||||
|
||||
@@ -34,9 +34,9 @@ class AccountVC: UIViewController, UITableViewDelegate, UITableViewDataSource {
|
||||
//MARK: Methods
|
||||
|
||||
func customization() {
|
||||
self.tableView.contentInset = UIEdgeInsetsMake(50, 0, 0, 0)
|
||||
self.tableView.scrollIndicatorInsets = UIEdgeInsetsMake(50, 0, 0, 0)
|
||||
self.tableView.rowHeight = UITableViewAutomaticDimension
|
||||
self.tableView.contentInset = UIEdgeInsets(top: 50, left: 0, bottom: 0, right: 0)
|
||||
self.tableView.scrollIndicatorInsets = UIEdgeInsets(top: 50, left: 0, bottom: 0, right: 0)
|
||||
self.tableView.rowHeight = UITableView.automaticDimension
|
||||
self.tableView.estimatedRowHeight = 300
|
||||
User.fetchData { [weak self] response in
|
||||
guard let weakSelf = self else {
|
||||
|
||||
@@ -31,9 +31,9 @@ class HomeVC: UIViewController, UITableViewDelegate, UITableViewDataSource, UISc
|
||||
|
||||
//MARK: Methods
|
||||
func customization() {
|
||||
self.tableView.contentInset = UIEdgeInsetsMake(50, 0, 30, 0)
|
||||
self.tableView.scrollIndicatorInsets = UIEdgeInsetsMake(50, 0, 30, 0)
|
||||
self.tableView.rowHeight = UITableViewAutomaticDimension
|
||||
self.tableView.contentInset = UIEdgeInsets(top: 50, left: 0, bottom: 30, right: 0)
|
||||
self.tableView.scrollIndicatorInsets = UIEdgeInsets(top: 50, left: 0, bottom: 30, right: 0)
|
||||
self.tableView.rowHeight = UITableView.automaticDimension
|
||||
self.tableView.estimatedRowHeight = 300
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ class HomeVC: UIViewController, UITableViewDelegate, UITableViewDataSource, UISc
|
||||
return
|
||||
}
|
||||
weakSelf.videos = response
|
||||
weakSelf.videos.shuffle()
|
||||
weakSelf.videos.myShuffle()
|
||||
weakSelf.tableView.reloadData()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,15 +31,17 @@ class MainVC: UIViewController, UICollectionViewDataSource, UICollectionViewDele
|
||||
|
||||
//MARK: Methods
|
||||
func customization() {
|
||||
self.view.backgroundColor = UIColor.rbg(r: 228, g: 34, b: 24)
|
||||
//CollectionView Setup
|
||||
self.collectionView.contentInset = UIEdgeInsetsMake(44, 0, 0, 0)
|
||||
self.collectionView.contentInset = UIEdgeInsets(top: 44, left: 0, bottom: 0, right: 0)
|
||||
self.collectionView.frame = CGRect.init(x: 0, y: 0, width: UIScreen.main.bounds.width, height: (self.view.bounds.height))
|
||||
//TabbarView setup
|
||||
self.view.addSubview(self.tabBarView)
|
||||
self.tabBarView.translatesAutoresizingMaskIntoConstraints = false
|
||||
let _ = NSLayoutConstraint.init(item: self.view, attribute: .top, relatedBy: .equal, toItem: self.tabBarView, attribute: .top, multiplier: 1.0, constant: 0).isActive = true
|
||||
let _ = NSLayoutConstraint.init(item: self.view, attribute: .left, relatedBy: .equal, toItem: self.tabBarView, attribute: .left, multiplier: 1.0, constant: 0).isActive = true
|
||||
let _ = NSLayoutConstraint.init(item: self.view, attribute: .right, relatedBy: .equal, toItem: self.tabBarView, attribute: .right, multiplier: 1.0, constant: 0).isActive = true
|
||||
guard let v = self.view else { return }
|
||||
let _ = NSLayoutConstraint.init(item: v, attribute: .top, relatedBy: .equal, toItem: self.tabBarView, attribute: .top, multiplier: 1.0, constant: 0).isActive = true
|
||||
let _ = NSLayoutConstraint.init(item: v, attribute: .left, relatedBy: .equal, toItem: self.tabBarView, attribute: .left, multiplier: 1.0, constant: 0).isActive = true
|
||||
let _ = NSLayoutConstraint.init(item: v, attribute: .right, relatedBy: .equal, toItem: self.tabBarView, attribute: .right, multiplier: 1.0, constant: 0).isActive = true
|
||||
self.tabBarView.heightAnchor.constraint(equalToConstant: 64).isActive = true
|
||||
//ViewController init
|
||||
let homeVC = self.storyboard?.instantiateViewController(withIdentifier: "HomeVC")
|
||||
@@ -48,8 +50,8 @@ class MainVC: UIViewController, UICollectionViewDataSource, UICollectionViewDele
|
||||
let accountVC = self.storyboard?.instantiateViewController(withIdentifier: "AccountVC")
|
||||
let viewControllers = [homeVC, trendingVC, subscriptionsVC, accountVC]
|
||||
for vc in viewControllers {
|
||||
self.addChildViewController(vc!)
|
||||
vc!.didMove(toParentViewController: self)
|
||||
self.addChild(vc!)
|
||||
vc!.didMove(toParent: self)
|
||||
vc!.view.frame = CGRect.init(x: 0, y: 0, width: self.view.bounds.width, height: (self.view.bounds.height - 44))
|
||||
self.views.append(vc!.view)
|
||||
}
|
||||
@@ -59,14 +61,14 @@ class MainVC: UIViewController, UICollectionViewDataSource, UICollectionViewDele
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(self.hideBar(notification:)), name: NSNotification.Name("hide"), object: nil)
|
||||
}
|
||||
|
||||
func scrollViews(notification: Notification) {
|
||||
@objc func scrollViews(notification: Notification) {
|
||||
if let info = notification.userInfo {
|
||||
let userInfo = info as! [String: Int]
|
||||
self.collectionView.scrollToItem(at: IndexPath.init(row: userInfo["index"]!, section: 0), at: .centeredHorizontally, animated: true)
|
||||
}
|
||||
}
|
||||
|
||||
func hideBar(notification: NSNotification) {
|
||||
@objc func hideBar(notification: NSNotification) {
|
||||
let state = notification.object as! Bool
|
||||
self.navigationController?.setNavigationBarHidden(state, animated: true)
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ class NavVC: UINavigationController, PlayerVCDelegate {
|
||||
let settingsButton = UIButton.init(type: .system)
|
||||
settingsButton.setImage(UIImage.init(named: "navSettings"), for: .normal)
|
||||
settingsButton.tintColor = UIColor.white
|
||||
settingsButton.addTarget(self, action: #selector(self.showSettings), for: UIControlEvents.touchUpInside)
|
||||
settingsButton.addTarget(self, action: #selector(self.showSettings), for: UIControl.Event.touchUpInside)
|
||||
self.navigationBar.addSubview(settingsButton)
|
||||
settingsButton.translatesAutoresizingMaskIntoConstraints = false
|
||||
let _ = NSLayoutConstraint.init(item: self.navigationBar, attribute: .height, relatedBy: .equal, toItem: settingsButton, attribute: .height, multiplier: 1.0, constant: 0).isActive = true
|
||||
@@ -62,7 +62,7 @@ class NavVC: UINavigationController, PlayerVCDelegate {
|
||||
let searchButton = UIButton.init(type: .system)
|
||||
searchButton.setImage(UIImage.init(named: "navSearch"), for: .normal)
|
||||
searchButton.tintColor = UIColor.white
|
||||
searchButton.addTarget(self, action: #selector(self.showSearch), for: UIControlEvents.touchUpInside)
|
||||
searchButton.addTarget(self, action: #selector(self.showSearch), for: UIControl.Event.touchUpInside)
|
||||
self.navigationBar.addSubview(searchButton)
|
||||
searchButton.translatesAutoresizingMaskIntoConstraints = false
|
||||
let _ = NSLayoutConstraint.init(item: self.navigationBar, attribute: .height, relatedBy: .equal, toItem: searchButton, attribute: .height, multiplier: 1.0, constant: 0).isActive = true
|
||||
@@ -87,18 +87,19 @@ class NavVC: UINavigationController, PlayerVCDelegate {
|
||||
//SearchView setup
|
||||
self.view.addSubview(self.searchView)
|
||||
self.searchView.translatesAutoresizingMaskIntoConstraints = false
|
||||
let _ = NSLayoutConstraint.init(item: self.view, attribute: .top, relatedBy: .equal, toItem: self.searchView, attribute: .top, multiplier: 1.0, constant: 0).isActive = true
|
||||
let _ = NSLayoutConstraint.init(item: self.view, attribute: .left, relatedBy: .equal, toItem: self.searchView, attribute: .left, multiplier: 1.0, constant: 0).isActive = true
|
||||
let _ = NSLayoutConstraint.init(item: self.view, attribute: .right, relatedBy: .equal, toItem: self.searchView, attribute: .right, multiplier: 1.0, constant: 0).isActive = true
|
||||
let _ = NSLayoutConstraint.init(item: self.view, attribute: .bottom, relatedBy: .equal, toItem: self.searchView, attribute: .bottom, multiplier: 1.0, constant: 0).isActive = true
|
||||
guard let v = self.view else { return }
|
||||
let _ = NSLayoutConstraint.init(item: v, attribute: .top, relatedBy: .equal, toItem: self.searchView, attribute: .top, multiplier: 1.0, constant: 0).isActive = true
|
||||
let _ = NSLayoutConstraint.init(item: v, attribute: .left, relatedBy: .equal, toItem: self.searchView, attribute: .left, multiplier: 1.0, constant: 0).isActive = true
|
||||
let _ = NSLayoutConstraint.init(item: v, attribute: .right, relatedBy: .equal, toItem: self.searchView, attribute: .right, multiplier: 1.0, constant: 0).isActive = true
|
||||
let _ = NSLayoutConstraint.init(item: v, attribute: .bottom, relatedBy: .equal, toItem: self.searchView, attribute: .bottom, multiplier: 1.0, constant: 0).isActive = true
|
||||
self.searchView.isHidden = true
|
||||
//SettingsView setup
|
||||
self.view.addSubview(self.settingsView)
|
||||
self.settingsView.translatesAutoresizingMaskIntoConstraints = false
|
||||
let _ = NSLayoutConstraint.init(item: self.view, attribute: .top, relatedBy: .equal, toItem: self.settingsView, attribute: .top, multiplier: 1.0, constant: 0).isActive = true
|
||||
let _ = NSLayoutConstraint.init(item: self.view, attribute: .left, relatedBy: .equal, toItem: self.settingsView, attribute: .left, multiplier: 1.0, constant: 0).isActive = true
|
||||
let _ = NSLayoutConstraint.init(item: self.view, attribute: .right, relatedBy: .equal, toItem: self.settingsView, attribute: .right, multiplier: 1.0, constant: 0).isActive = true
|
||||
let _ = NSLayoutConstraint.init(item: self.view, attribute: .bottom, relatedBy: .equal, toItem: self.settingsView, attribute: .bottom, multiplier: 1.0, constant: 0).isActive = true
|
||||
let _ = NSLayoutConstraint.init(item: v, attribute: .top, relatedBy: .equal, toItem: self.settingsView, attribute: .top, multiplier: 1.0, constant: 0).isActive = true
|
||||
let _ = NSLayoutConstraint.init(item: v, attribute: .left, relatedBy: .equal, toItem: self.settingsView, attribute: .left, multiplier: 1.0, constant: 0).isActive = true
|
||||
let _ = NSLayoutConstraint.init(item: v, attribute: .right, relatedBy: .equal, toItem: self.settingsView, attribute: .right, multiplier: 1.0, constant: 0).isActive = true
|
||||
let _ = NSLayoutConstraint.init(item: v, attribute: .bottom, relatedBy: .equal, toItem: self.settingsView, attribute: .bottom, multiplier: 1.0, constant: 0).isActive = true
|
||||
self.settingsView.isHidden = true
|
||||
//PLayerView setup
|
||||
self.playerView.frame = CGRect.init(origin: self.hiddenOrigin, size: UIScreen.main.bounds.size)
|
||||
@@ -107,7 +108,7 @@ class NavVC: UINavigationController, PlayerVCDelegate {
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(self.changeTitle(notification:)), name: Notification.Name.init(rawValue: "scrollMenu"), object: nil)
|
||||
}
|
||||
|
||||
func showSearch() {
|
||||
@objc func showSearch() {
|
||||
self.searchView.alpha = 0
|
||||
self.searchView.isHidden = false
|
||||
UIView.animate(withDuration: 0.2, animations: {
|
||||
@@ -117,7 +118,7 @@ class NavVC: UINavigationController, PlayerVCDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
func showSettings() {
|
||||
@objc func showSettings() {
|
||||
self.settingsView.isHidden = false
|
||||
self.settingsView.tableViewBottomConstraint.constant = 0
|
||||
UIView.animate(withDuration: 0.3) {
|
||||
@@ -126,7 +127,7 @@ class NavVC: UINavigationController, PlayerVCDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
func changeTitle(notification: Notification) {
|
||||
@objc func changeTitle(notification: Notification) {
|
||||
if let info = notification.userInfo {
|
||||
let userInfo = info as! [String: CGFloat]
|
||||
self.titleLabel.text = self.names[Int(round(userInfo["length"]!))]
|
||||
@@ -183,6 +184,20 @@ class NavVC: UINavigationController, PlayerVCDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
func setPreferStatusBarHidden(_ preferHidden: Bool) {
|
||||
self.isHidden = preferHidden
|
||||
}
|
||||
|
||||
var isHidden = true {
|
||||
didSet {
|
||||
self.setNeedsStatusBarAppearanceUpdate()
|
||||
}
|
||||
}
|
||||
|
||||
override var prefersStatusBarHidden: Bool {
|
||||
return isHidden
|
||||
}
|
||||
|
||||
//MARK: ViewController lifecycle
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
@@ -49,7 +49,7 @@ class SubscriptionsCell: UITableViewCell, UICollectionViewDataSource, UICollecti
|
||||
func customization() {
|
||||
self.collectionView.delegate = self
|
||||
self.collectionView.dataSource = self
|
||||
self.collectionView.contentInset = UIEdgeInsetsMake(0, 10, 0, 10)
|
||||
self.collectionView.contentInset = UIEdgeInsets(top: 0, left: 10, bottom: 0, right: 10)
|
||||
Channel.fetchData { [weak self] channels in
|
||||
guard let weakSelf = self else {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user