From 98632edadbceeb377199d3150811b2cf997de5cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Je=CC=81re=CC=81my=20Marchand?= Date: Sun, 6 Jan 2019 13:19:45 +0100 Subject: [PATCH] Add light interface compatibility Replace checkmark image Fix focus on table view --- .../Checkmark.imageset/Contents.json | 12 +- .../Checkmark.imageset/checkmark.pdf | Bin 1104 -> 0 bytes .../Checkmark.imageset/checkmark.png | Bin 0 -> 953 bytes .../Checkmark.imageset/checkmark@2x.png | Bin 0 -> 1360 bytes Resources/TVVLCPlayer.storyboard | 188 ++++++++++-------- Sources/Panel/InfoViewController.swift | 20 +- Sources/Panel/PanelViewController.swift | 8 +- .../SelectorTableViewController.swift | 12 +- Sources/Panel/SlideAnimatedTransitioner.swift | 4 +- Sources/VLCPlayerViewController.swift | 4 - Sources/Views/Theme.swift | 27 +++ TVVLCPlayer.xcodeproj/project.pbxproj | 4 + 12 files changed, 175 insertions(+), 104 deletions(-) delete mode 100644 Resources/Images.xcassets/Checkmark.imageset/checkmark.pdf create mode 100644 Resources/Images.xcassets/Checkmark.imageset/checkmark.png create mode 100644 Resources/Images.xcassets/Checkmark.imageset/checkmark@2x.png create mode 100644 Sources/Views/Theme.swift diff --git a/Resources/Images.xcassets/Checkmark.imageset/Contents.json b/Resources/Images.xcassets/Checkmark.imageset/Contents.json index d1fb6a3..5b67bd9 100644 --- a/Resources/Images.xcassets/Checkmark.imageset/Contents.json +++ b/Resources/Images.xcassets/Checkmark.imageset/Contents.json @@ -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" : { diff --git a/Resources/Images.xcassets/Checkmark.imageset/checkmark.pdf b/Resources/Images.xcassets/Checkmark.imageset/checkmark.pdf deleted file mode 100644 index 69551c3c577ed23765d7c078b73c7cef841a10ff..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1104 zcmZWoYe-X39ESoQH^G81>BWf}x=in5?x75GZf;If=S(9?>UwwFuFiYcy=OHS_QF0$ z(HAWuEG#7YQXj;kFv!AX7St!RAf!I@Ks3JvW>n|gxjFQ3IOm?<`Jeye_xoR+$Kfnw zi;R@+;rxRosu(apZf&QmRzM$sk{<(kO^_59xV6T{)lJ8xS9!&Nz*3)xryWDLcQ=bj!~WTLmsZ#y!sxR%NdD*^DJc?KT7kE*T0b9fxi&zHa2M`LC(wJO~`V~GD5CyeJR{VOs7RZj< z7KyUtAj0H3N;!tLupC#ynhh3?Eo4l245LqpX-eZQg)uB{z*U%mTkFqMvewSRVi^)| xk;02XsAxZaqZoxaWg>=GmJuL@$2-O?waI{RuZgK5UO`%g7L$R}=_>1;)PH^wM?3%k diff --git a/Resources/Images.xcassets/Checkmark.imageset/checkmark.png b/Resources/Images.xcassets/Checkmark.imageset/checkmark.png new file mode 100644 index 0000000000000000000000000000000000000000..3c04716de57ef53af2e4914e6d97b805bcb8efeb GIT binary patch literal 953 zcmeAS@N?(olHy`uVBq!ia0vp^qChOd!3HFgyvvM%6k~CayA#8@b22X(7?`*-Ln2Bd ze0{8v^KP?Wt5Z@Sn2DRmzV368|&p4 zrRy77T3YHG80i}s=>k>g7FXt#Bv$C=6)QswftllyTAW;zSx}OhpQivaH!&%{w8U0P z31kr*K-^i9nTD__uNdkrpa=CqGWv#k2KsQbfm&@qqE`VV9cTs^WFy83{O{E~cNSQlj`d*+p- z76C0o(~VmN)GQl)P;emyA0%$TqQJKhy28{34Am*)N@WfxFFwPAFX}vEjuXrxjFmIpE6L88m)zjNjCwV{DQTKVzuRl4Qsq*yMhtBq$q5EpqZk)~=aEiAy zJ?hj$!!K$gqTx>--Y}V!A$@m&u87o?y>I3!$r^p@+4N_biTD=n)0>oE*%|B=eOvsq zN>qgy>EQaEq-){~SIsUCLVb5cn?Y{QL(fY6Z7&G2_7uAV!^MNv% Mr>mdKI;Vst0Luhk_W%F@ literal 0 HcmV?d00001 diff --git a/Resources/Images.xcassets/Checkmark.imageset/checkmark@2x.png b/Resources/Images.xcassets/Checkmark.imageset/checkmark@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..4e8f16f1349f540c3ef793c1c9407c44708ea8f8 GIT binary patch literal 1360 zcmeAS@N?(olHy`uVBq!ia0vp^T0pG9!3HEdxHAHP6k~CayA#8@b22Z19L@rd$YKTt zF;x&|^bAt@z`(%7of#5Q65;D(m7Jfemza{Dl&V*eTL4tez+h8h1!U%?mLw`vE(HYzo1&C7s~{IQsCFRF zRw<*Tq`*pFzr4I$uiRKKzbIYb(9+UU-@r)U$VeBcLbtdwuOzWTH?LS3VhGF}m(=3q zqRfJl%=|nBkhzIT`K2YcN=hJ$-~i&zlFT%OO?kyoZvj2150cS0)HBeBn+?=z0}{0g zN-fUMDFqoHnwME(XJi9bj4q6@4Wi3AKewPLwYV6l&CU?21z8MTy?;?=D$su*YvAgU z#n9CUWaO9R1H-x~Gubn*B((@=8Jcd~DxhZB=!1d_Dfl390~Q5FjvbecK0KoBxRi`D z{D8^go~MgrNCfBE8U7u+k!jXO+LYZT}tYANRvx#2kBfpP(87EBI}deILf73GS1|(vwO1)t0O4^#aWb z7E>v#ytY0(=TV!+KCxcq)x2VA2MbkqH9X zwlH4q`Qc#Ww}NudZR~DpT3%eg?d}{Nu``DA_Pft1+1h>GO(otm%zBm7&nAn!tudYQ zpVyW?Kk?EvpJ~s$3BiAQPAIG zbvEy)>|0ewJ^qDhZraTJntvL1aoC(X%pUs);b&RPyPo&{$ z(0#!<@tiZxvlKV(T_(tK{?ekQo%rpV6H&2C@EM7Bnb!E8R z;st-68UDXnaIa^M;q_2Hp`;my_^b`0$`y_nNBMD82P!{V_;FIjM&mS|M - + - - + + - + - + - + - - + + - - + + - + @@ -294,19 +294,22 @@ - - + + @@ -338,7 +341,7 @@ - + @@ -352,64 +355,79 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - + + + + - + @@ -454,10 +472,10 @@ - + - + @@ -466,7 +484,7 @@ - + @@ -481,7 +499,7 @@ - + @@ -506,10 +524,10 @@ - + - + @@ -518,7 +536,7 @@ - + @@ -527,7 +545,7 @@ - + @@ -541,7 +559,7 @@ - + @@ -581,8 +599,11 @@ @@ -590,22 +611,33 @@ + + + + + + + + @@ -645,7 +677,7 @@ - + diff --git a/Sources/Panel/InfoViewController.swift b/Sources/Panel/InfoViewController.swift index 9596cdd..98b5350 100644 --- a/Sources/Panel/InfoViewController.swift +++ b/Sources/Panel/InfoViewController.swift @@ -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 { @@ -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 { @@ -61,7 +64,6 @@ class InfoViewController: UIViewController { } else { titleLabel.text = player.media?.url.absoluteString } - titleLabel.textColor = .gray } func configureCaption() { @@ -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") @@ -92,7 +93,6 @@ class InfoViewController: UIViewController { textView.textContainerInset = UIEdgeInsets.zero textView.textContainer.lineFragmentPadding = 0 textView.isHidden = texts.isEmpty - textView.textColor = .gray } } diff --git a/Sources/Panel/PanelViewController.swift b/Sources/Panel/PanelViewController.swift index ceceabb..abf1ceb 100644 --- a/Sources/Panel/PanelViewController.swift +++ b/Sources/Panel/PanelViewController.swift @@ -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 { @@ -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 } @@ -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 } } diff --git a/Sources/Panel/Selection/SelectorTableViewController.swift b/Sources/Panel/Selection/SelectorTableViewController.swift index b6c4142..cd308d3 100644 --- a/Sources/Panel/Selection/SelectorTableViewController.swift +++ b/Sources/Panel/Selection/SelectorTableViewController.swift @@ -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 @@ -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 } @@ -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 { diff --git a/Sources/Panel/SlideAnimatedTransitioner.swift b/Sources/Panel/SlideAnimatedTransitioner.swift index 0889ef7..a23fc0b 100644 --- a/Sources/Panel/SlideAnimatedTransitioner.swift +++ b/Sources/Panel/SlideAnimatedTransitioner.swift @@ -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, diff --git a/Sources/VLCPlayerViewController.swift b/Sources/VLCPlayerViewController.swift index 4cb1644..a2bd1ce 100644 --- a/Sources/VLCPlayerViewController.swift +++ b/Sources/VLCPlayerViewController.swift @@ -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 { diff --git a/Sources/Views/Theme.swift b/Sources/Views/Theme.swift new file mode 100644 index 0000000..9831694 --- /dev/null +++ b/Sources/Views/Theme.swift @@ -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 + } + } +} diff --git a/TVVLCPlayer.xcodeproj/project.pbxproj b/TVVLCPlayer.xcodeproj/project.pbxproj index f0704b9..1b6a35f 100644 --- a/TVVLCPlayer.xcodeproj/project.pbxproj +++ b/TVVLCPlayer.xcodeproj/project.pbxproj @@ -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 */; }; @@ -110,6 +111,7 @@ 3F8FF6F221D63C8100A86CDF /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 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 = ""; }; + 3FC8AAF221DD72AF005C4068 /* Theme.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Theme.swift; sourceTree = ""; }; 3FE3F3F721D782E800F8C472 /* .swiftlint.yml */ = {isa = PBXFileReference; lastKnownFileType = text; path = .swiftlint.yml; sourceTree = ""; }; 3FE3F3F921D79D2B00F8C472 /* SelectorTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectorTableViewController.swift; sourceTree = ""; }; 3FE3F3FE21D7A2E800F8C472 /* SelectableCollection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectableCollection.swift; sourceTree = ""; }; @@ -250,6 +252,7 @@ children = ( 3F8FF6E021D63C6F00A86CDF /* ProgressBar.swift */, 3F8FF6E521D63C6F00A86CDF /* GradientView.swift */, + 3FC8AAF221DD72AF005C4068 /* Theme.swift */, ); path = Views; sourceTree = ""; @@ -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 */,