Skip to content

Commit

Permalink
Add light interface compatibility
Browse files Browse the repository at this point in the history
Replace checkmark image
Fix focus on table view
  • Loading branch information
kodlian committed Jan 6, 2019
1 parent 87c4715 commit 98632ed
Show file tree
Hide file tree
Showing 12 changed files with 175 additions and 104 deletions.
12 changes: 11 additions & 1 deletion Resources/Images.xcassets/Checkmark.imageset/Contents.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,17 @@
"images" : [
{
"idiom" : "universal",
"filename" : "checkmark.pdf"
"filename" : "checkmark.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "checkmark@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
Expand Down
Binary file not shown.
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.
188 changes: 110 additions & 78 deletions Resources/TVVLCPlayer.storyboard

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions Sources/Panel/InfoViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,8 @@ class InfoViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()
configureTitle()
configureCaption()
configureArtwork()
configureDescription()
view.layoutIfNeeded()

configure()

// TODO: Find a better way to handle variable height of the info panel
var height = mainStackView.frame.height
if artworkImageView.isHidden {
Expand All @@ -42,7 +38,14 @@ class InfoViewController: UIViewController {
preferredContentSize = CGSize(width: 1920,
height: height)
}


func configure() {
configureTitle()
configureCaption()
configureArtwork()
configureDescription()
}

func configureArtwork() {
let mediaDict = player.media?.metaDictionary
if let image = mediaDict?[VLCMetaInformationArtwork] as? UIImage {
Expand All @@ -61,7 +64,6 @@ class InfoViewController: UIViewController {
} else {
titleLabel.text = player.media?.url.absoluteString
}
titleLabel.textColor = .gray
}

func configureCaption() {
Expand All @@ -72,7 +74,6 @@ class InfoViewController: UIViewController {
}

captionLabel.text = caption
captionLabel.textColor = .gray

if player.videoSize >= CGSize(width: 3840, height: 2160) {
qualityImageView.image = UIImage(named: "4k")
Expand All @@ -92,7 +93,6 @@ class InfoViewController: UIViewController {
textView.textContainerInset = UIEdgeInsets.zero
textView.textContainer.lineFragmentPadding = 0
textView.isHidden = texts.isEmpty
textView.textColor = .gray
}
}

Expand Down
8 changes: 3 additions & 5 deletions Sources/Panel/PanelViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ class PanelViewController: UIViewController {
self.delegate?.panelViewController(self, didSelectTabAtIndex: selectedIndex)
}
}
public override var preferredUserInterfaceStyle: UIUserInterfaceStyle {
return .dark
}

private var currentViewController: UIViewController?
private var viewControllers: [UIViewController] = [] {
didSet {
Expand Down Expand Up @@ -81,7 +79,7 @@ class PanelViewController: UIViewController {
audioViewController.title = "Audio"
audioViewController.player = player
viewControllers = [infoViewController, subtitlesViewController, audioViewController]

contentView.layer.masksToBounds = true // Avoid content to appear on tabbar during panel content transition and height animation

}
Expand All @@ -97,7 +95,7 @@ class PanelViewController: UIViewController {

override func didUpdateFocus(in context: UIFocusUpdateContext, with coordinator: UIFocusAnimationCoordinator) {
if let nextView = context.nextFocusedView {
tabBar.tintColor = nextView.hasSuperview(tabBar) ? .white : .gray
tabBar.tintColor = nextView.hasSuperview(tabBar) ? .white : traitCollection.userInterfaceStyle.textColor
}
}

Expand Down
12 changes: 9 additions & 3 deletions Sources/Panel/Selection/SelectorTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ class SelectorTableViewController: UIViewController {
tableView.scrollToRow(at: IndexPath(row: selectedIndex, section: 0), at: .middle, animated: animated)
}
}

override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
super.traitCollectionDidChange(previousTraitCollection)
tableView.reloadData()
}
}

// MARK: Data Source
Expand All @@ -57,8 +62,9 @@ extension SelectorTableViewController: UITableViewDataSource {
fatalError()
}
cell.label.text = collection[indexPath.row]
cell.checkmarkView.isHidden = collection.selectedIndex != indexPath.row
update(cell, with: .gray)
let isSelected = collection.selectedIndex == indexPath.row
cell.checkmarkView.isHidden = !isSelected
update(cell, with: traitCollection.userInterfaceStyle.textColor)
return cell
}

Expand All @@ -70,7 +76,7 @@ extension SelectorTableViewController: UITableViewDataSource {
func tableView(_ tableView: UITableView, didUpdateFocusIn context: UITableViewFocusUpdateContext, with coordinator: UIFocusAnimationCoordinator) {
if let indexPath = context.previouslyFocusedIndexPath,
let cell = tableView.cellForRow(at: indexPath) as? SelectableTableViewCell {
update(cell, with: .gray)
update(cell, with: traitCollection.userInterfaceStyle.textColor)
}
if let nextIndexPath = context.nextFocusedIndexPath,
let cell = tableView.cellForRow(at: nextIndexPath) as? SelectableTableViewCell {
Expand Down
4 changes: 1 addition & 3 deletions Sources/Panel/SlideAnimatedTransitioner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ class SlideDownAnimatedTransitioner: NSObject, UIViewControllerAnimatedTransitio
let firstVCView = transitionContext.containerView
firstVCView.addSubview(secondVCView)

let rect = secondVC.preferredContentSize
secondVCView.frame.size = rect
secondVCView.frame.origin.y = -secondVCView.frame.height
secondVCView.frame.origin.y = -secondVC.preferredContentSize.height

UIView.animate(withDuration: animatonDuration,
delay: 0.0,
Expand Down
4 changes: 0 additions & 4 deletions Sources/VLCPlayerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,6 @@ public class VLCPlayerViewController: UIViewController {
return displayedPanelViewController != nil
}

public override var preferredUserInterfaceStyle: UIUserInterfaceStyle {
return .dark
}

public override func viewDidLoad() {
super.viewDidLoad()
guard self.player.media != nil else {
Expand Down
27 changes: 27 additions & 0 deletions Sources/Views/Theme.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// Color.swift
// TVVLCPlayer
//
// Created by Jérémy Marchand on 02/01/2019.
// Copyright © 2019 Jérémy Marchand. All rights reserved.
//

import Foundation

struct DarkTheme {
static let textColor = UIColor(white: 0.5, alpha: 1.0)
}

struct LightTheme {
static let textColor = UIColor(white: 0.0, alpha: 0.6)
}

extension UIUserInterfaceStyle {
var textColor: UIColor {
if self == .dark {
return DarkTheme.textColor
} else {
return LightTheme.textColor
}
}
}
4 changes: 4 additions & 0 deletions TVVLCPlayer.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
3F8FF70D21D63EF400A86CDF /* TVVLCPlayer.h in Headers */ = {isa = PBXBuildFile; fileRef = 3F8FF6F121D63C8100A86CDF /* TVVLCPlayer.h */; settings = {ATTRIBUTES = (Public, ); }; };
3F8FF71121D6438C00A86CDF /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3F8FF71021D6438C00A86CDF /* Foundation.framework */; };
3F94CA0421DA55AE0010B78B /* InfoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F94CA0321DA55AE0010B78B /* InfoViewController.swift */; };
3FC8AAF321DD72AF005C4068 /* Theme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3FC8AAF221DD72AF005C4068 /* Theme.swift */; };
3FE3F3F821D782E800F8C472 /* .swiftlint.yml in Resources */ = {isa = PBXBuildFile; fileRef = 3FE3F3F721D782E800F8C472 /* .swiftlint.yml */; };
3FE3F3FA21D79D2B00F8C472 /* SelectorTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3FE3F3F921D79D2B00F8C472 /* SelectorTableViewController.swift */; };
3FE3F3FF21D7A2E800F8C472 /* SelectableCollection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3FE3F3FE21D7A2E800F8C472 /* SelectableCollection.swift */; };
Expand Down Expand Up @@ -110,6 +111,7 @@
3F8FF6F221D63C8100A86CDF /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
3F8FF71021D6438C00A86CDF /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
3F94CA0321DA55AE0010B78B /* InfoViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InfoViewController.swift; sourceTree = "<group>"; };
3FC8AAF221DD72AF005C4068 /* Theme.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Theme.swift; sourceTree = "<group>"; };
3FE3F3F721D782E800F8C472 /* .swiftlint.yml */ = {isa = PBXFileReference; lastKnownFileType = text; path = .swiftlint.yml; sourceTree = "<group>"; };
3FE3F3F921D79D2B00F8C472 /* SelectorTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectorTableViewController.swift; sourceTree = "<group>"; };
3FE3F3FE21D7A2E800F8C472 /* SelectableCollection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectableCollection.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -250,6 +252,7 @@
children = (
3F8FF6E021D63C6F00A86CDF /* ProgressBar.swift */,
3F8FF6E521D63C6F00A86CDF /* GradientView.swift */,
3FC8AAF221DD72AF005C4068 /* Theme.swift */,
);
path = Views;
sourceTree = "<group>";
Expand Down Expand Up @@ -447,6 +450,7 @@
3F8FF6EF21D63C7500A86CDF /* PositionController.swift in Sources */,
3F8FF6EE21D63C7500A86CDF /* GradientView.swift in Sources */,
3FE3F40421D7E75A00F8C472 /* SlideAnimatedTransitioner.swift in Sources */,
3FC8AAF321DD72AF005C4068 /* Theme.swift in Sources */,
3F8FF6E721D63C7500A86CDF /* VLCPlayerViewController.swift in Sources */,
3F8FF6EA21D63C7500A86CDF /* RemoteActionPositionController.swift in Sources */,
3FE3F40621D7E85300F8C472 /* PanelViewController.swift in Sources */,
Expand Down

0 comments on commit 98632ed

Please sign in to comment.