Commit 513aa21b authored by Robert Gordon's avatar Robert Gordon Committed by Carola Nitz

MediaNavigationController: Navigation bar for the MovieViewController in the New UI

parent 46156a42
/*****************************************************************************
* MediaNavigationBar.swift
*
* Copyright © 2019 VLC authors and VideoLAN
*
* Authors: Robert Gordon <robwaynegordon@gmail.com>
*
*
* Refer to the COPYING file of the official project for license.
*****************************************************************************/
@objc (VLCMediaNavigationBarDelegate)
protocol VLCMediaNavigationBarDelegate {
func didMinimizePlayback(_ navigationBar: MediaNavigationBar)
func didToggleChromeCast(_ navigationBar: MediaNavigationBar)
func didToggleAirPlay(_ navigationBar: MediaNavigationBar)
}
@objc (VLCMediaNavigationBar)
@objcMembers class MediaNavigationBar: UIView {
// MARK: Instance Variables
weak var delegate: VLCMediaNavigationBarDelegate?
lazy var minimizePlaybackButton: UIButton = {
var minButton = UIButton(type: .system)
minButton.addTarget(self, action: #selector(minimizePlayback), for: .touchUpInside)
minButton.setImage(UIImage(named: "minimizePlayback"), for: .normal)
minButton.tintColor = .white
// Constraints
minButton.translatesAutoresizingMaskIntoConstraints = false
return minButton
}()
private var mediaTitleTextLabel: UILabel = {
var label = UILabel()
label.numberOfLines = 1
label.textColor = .white
label.font = UIFont(name: "SFProDisplay-Medium", size: 17)
label.text = NSLocalizedString("TITLE", comment: "Video Title")
label.isUserInteractionEnabled = false
label.translatesAutoresizingMaskIntoConstraints = false
return label
}()
lazy var chromeCastButton: UIButton = {
var chromeButton = UIButton(type: .system)
chromeButton.addTarget(self, action: #selector(toggleChromeCast), for: .touchUpInside)
chromeButton.setImage(UIImage(named: "renderer"), for: .normal)
chromeButton.tintColor = .white
chromeButton.translatesAutoresizingMaskIntoConstraints = false
return chromeButton
}()
lazy var airPlayButton: UIButton = {
var airPlayButton = UIButton(type: .system)
airPlayButton.addTarget(self, action: #selector(toggleAirPlay), for: .touchUpInside)
airPlayButton.setImage(UIImage(named: "TVBroadcastIcon"), for: .normal)
airPlayButton.tintColor = .white
airPlayButton.translatesAutoresizingMaskIntoConstraints = false
return airPlayButton
}()
private func setupConstraints() {
NSLayoutConstraint.activate([
minimizePlaybackButton.leadingAnchor.constraint(equalTo: self.leadingAnchor),
minimizePlaybackButton.topAnchor.constraint(equalTo: self.topAnchor),
minimizePlaybackButton.widthAnchor.constraint(equalToConstant: minimizePlaybackButton.frame.width),
minimizePlaybackButton.bottomAnchor.constraint(equalTo: self.bottomAnchor),
mediaTitleTextLabel.leadingAnchor.constraint(equalTo: minimizePlaybackButton.trailingAnchor, constant: 16),
mediaTitleTextLabel.topAnchor.constraint(equalTo: self.topAnchor),
mediaTitleTextLabel.trailingAnchor.constraint(equalTo: chromeCastButton.leadingAnchor, constant: 50),
chromeCastButton.trailingAnchor.constraint(equalTo: airPlayButton.leadingAnchor, constant: 20),
chromeCastButton.topAnchor.constraint(equalTo: self.topAnchor),
chromeCastButton.widthAnchor.constraint(equalToConstant: 24),
airPlayButton.trailingAnchor.constraint(equalTo: self.trailingAnchor, constant: 20),
airPlayButton.topAnchor.constraint(equalTo: self.topAnchor),
airPlayButton.widthAnchor.constraint(equalToConstant: 24)
])
}
private func setupViews() {
self.addSubview(minimizePlaybackButton)
self.addSubview(mediaTitleTextLabel)
self.addSubview(chromeCastButton)
self.addSubview(airPlayButton)
if UIApplication.shared.statusBarOrientation.isLandscape {
mediaTitleTextLabel.isHidden = true
}
}
// MARK: Initializers
required init(coder: NSCoder) {
fatalError("init(coder: NSCoder) not implemented")
}
init() {
super.init(frame: .zero)
setupViews()
setupConstraints()
}
// MARK: Instance Methods
func setMediaTitleLabelText(_ titleText: String) {
mediaTitleTextLabel.text = titleText
}
// Mark: Button Actions
func minimizePlayback() {
guard let delegate = delegate else {
print("Delegate not set for MediaNavigationBar")
return
}
delegate.didMinimizePlayback(self)
}
func toggleChromeCast() {
guard let delegate = delegate else {
print("Delegate not set for MediaNavigationBar")
return
}
delegate.didToggleChromeCast(self)
}
func toggleAirPlay() {
guard let delegate = delegate else {
print("Delegate not set for MediaNavigationBar")
return
}
delegate.didToggleAirPlay(self)
}
}
......@@ -382,6 +382,7 @@
DDF908E01CF4E04A00108B70 /* VLCNetworkLoginDataSourceSavedLogins.m in Sources */ = {isa = PBXBuildFile; fileRef = DDF908DF1CF4E04A00108B70 /* VLCNetworkLoginDataSourceSavedLogins.m */; };
DDF908E41CFCD97400108B70 /* VLCNetworkLoginDataSourceProtocol.m in Sources */ = {isa = PBXBuildFile; fileRef = DDF908E31CFCD97400108B70 /* VLCNetworkLoginDataSourceProtocol.m */; };
E016D07322B0FB4B009FC7CA /* VideoOptionsControlBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = E016D07222B0FB4B009FC7CA /* VideoOptionsControlBar.swift */; };
E03DECA622BEE27E00F44A05 /* MediaNavigationBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = E03DECA522BEE27E00F44A05 /* MediaNavigationBar.swift */; };
E0C04F951A25B4410080331A /* VLCDocumentPickerController.m in Sources */ = {isa = PBXBuildFile; fileRef = E0C04F941A25B4410080331A /* VLCDocumentPickerController.m */; };
/* End PBXBuildFile section */
......@@ -1008,6 +1009,7 @@
DDF908E21CFCD97400108B70 /* VLCNetworkLoginDataSourceProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCNetworkLoginDataSourceProtocol.h; path = Sources/LocalNetworkConnectivity/VLCNetworkLoginDataSourceProtocol.h; sourceTree = SOURCE_ROOT; };
DDF908E31CFCD97400108B70 /* VLCNetworkLoginDataSourceProtocol.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCNetworkLoginDataSourceProtocol.m; path = Sources/LocalNetworkConnectivity/VLCNetworkLoginDataSourceProtocol.m; sourceTree = SOURCE_ROOT; };
E016D07222B0FB4B009FC7CA /* VideoOptionsControlBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = VideoOptionsControlBar.swift; path = Sources/VideoOptionsControlBar.swift; sourceTree = "<group>"; };
E03DECA522BEE27E00F44A05 /* MediaNavigationBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = MediaNavigationBar.swift; path = Sources/MediaNavigationBar.swift; sourceTree = "<group>"; };
E0C04F931A25B4410080331A /* VLCDocumentPickerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCDocumentPickerController.h; path = Sources/VLCDocumentPickerController.h; sourceTree = SOURCE_ROOT; };
E0C04F941A25B4410080331A /* VLCDocumentPickerController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCDocumentPickerController.m; path = Sources/VLCDocumentPickerController.m; sourceTree = SOURCE_ROOT; };
E39E49F085F7C54D2DB79534 /* Pods-VLC-iOSTests.distribution.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-VLC-iOSTests.distribution.xcconfig"; path = "Pods/Target Support Files/Pods-VLC-iOSTests/Pods-VLC-iOSTests.distribution.xcconfig"; sourceTree = "<group>"; };
......@@ -1277,6 +1279,7 @@
8DF966B021188BDB00D0FCD6 /* EditController.swift */,
41B4DA3D21400E8E000BA27D /* MediaEditCell.xib */,
8D2AD4D722786F4000393833 /* AddToPlaylistViewController.swift */,
E03DECA522BEE27E00F44A05 /* MediaNavigationBar.swift */,
);
name = "UI Elements";
sourceTree = "<group>";
......@@ -2972,6 +2975,7 @@
DDEAECCD1BDECCB800756C83 /* VLCNetworkListViewController.m in Sources */,
8DE18894210B5F8200A091D2 /* AlbumModel.swift in Sources */,
7D3784E9183A9A15009EE944 /* main.m in Sources */,
E03DECA622BEE27E00F44A05 /* MediaNavigationBar.swift in Sources */,
7D30F3C2183AB24C00FFC021 /* VLCHTTPConnection.m in Sources */,
4129CF2F22D5E498005EF5E8 /* AppUtitlity.swift in Sources */,
DD3EFF371BDEBCE500B68579 /* VLCLocalNetworkServiceNetService.m in Sources */,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment