Replaces light theme with “opaque” dark theme
Previous dark theme has been renamed “translucent”
This commit is contained in:
parent
6b0ad3cf8f
commit
d3b4f25f20
@ -220,7 +220,7 @@ extension GameViewController
|
||||
{
|
||||
case "showGamesViewController":
|
||||
let gamesViewController = (segue.destination as! UINavigationController).topViewController as! GamesViewController
|
||||
gamesViewController.theme = .dark
|
||||
gamesViewController.theme = .translucent
|
||||
gamesViewController.activeEmulatorCore = self.emulatorCore
|
||||
|
||||
self.updateAutoSaveState()
|
||||
|
||||
@ -19,4 +19,9 @@ extension UIColor
|
||||
{
|
||||
return UIColor(red: 184.0/255.0, green: 97.0/255.0, blue: 253.0/255.0, alpha: 1.0)
|
||||
}
|
||||
}
|
||||
class var deltaDarkGray: UIColor
|
||||
{
|
||||
return UIColor(white: 0.15, alpha: 1.0)
|
||||
}
|
||||
}
|
||||
@ -23,9 +23,20 @@ class GameCollectionViewController: UICollectionViewController
|
||||
}
|
||||
}
|
||||
|
||||
var theme: Theme = .light {
|
||||
var theme: Theme = .opaque {
|
||||
didSet {
|
||||
self.collectionView?.reloadData()
|
||||
// self.collectionView?.reloadData()
|
||||
|
||||
// Calling reloadData sometimes will not update the cells correctly if an insertion/deletion animation is in progress
|
||||
// As a workaround, we manually iterate over and configure each cell ourselves
|
||||
for cell in self.collectionView?.visibleCells ?? []
|
||||
{
|
||||
if let indexPath = self.collectionView?.indexPath(for: cell)
|
||||
{
|
||||
self.configure(cell as! GridCollectionViewCell, for: indexPath)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -180,19 +191,18 @@ private extension GameCollectionViewController
|
||||
|
||||
switch self.theme
|
||||
{
|
||||
case .light:
|
||||
cell.textLabel.textColor = UIColor.darkText
|
||||
case .opaque:
|
||||
cell.isTextLabelVibrancyEnabled = false
|
||||
cell.isImageViewVibrancyEnabled = false
|
||||
|
||||
case .dark:
|
||||
cell.textLabel.textColor = UIColor.white
|
||||
case .translucent:
|
||||
cell.isTextLabelVibrancyEnabled = true
|
||||
cell.isImageViewVibrancyEnabled = true
|
||||
}
|
||||
|
||||
cell.maximumImageSize = CGSize(width: 90, height: 90)
|
||||
cell.textLabel.text = game.name
|
||||
cell.textLabel.textColor = UIColor.gray
|
||||
|
||||
if let artworkURL = game.artworkURL, !ignoreImageOperations
|
||||
{
|
||||
|
||||
@ -15,13 +15,24 @@ import Roxas
|
||||
|
||||
class GamesViewController: UIViewController
|
||||
{
|
||||
var theme: Theme = .light {
|
||||
var theme: Theme = .opaque {
|
||||
didSet {
|
||||
self.updateTheme()
|
||||
}
|
||||
}
|
||||
|
||||
weak var activeEmulatorCore: EmulatorCore?
|
||||
weak var activeEmulatorCore: EmulatorCore? {
|
||||
didSet
|
||||
{
|
||||
let game = oldValue?.game as? Game
|
||||
NotificationCenter.default.removeObserver(self, name: .NSManagedObjectContextObjectsDidChange, object: game?.managedObjectContext)
|
||||
|
||||
if let game = self.activeEmulatorCore?.game as? Game
|
||||
{
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(GamesViewController.managedObjectContextDidChange(with:)), name: .NSManagedObjectContextObjectsDidChange, object: game.managedObjectContext)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate var pageViewController: UIPageViewController!
|
||||
fileprivate var backgroundView: RSTBackgroundView!
|
||||
@ -72,6 +83,11 @@ extension GamesViewController
|
||||
|
||||
self.pageControl.centerXAnchor.constraint(equalTo: (self.navigationController?.toolbar.centerXAnchor)!, constant: 0).isActive = true
|
||||
self.pageControl.centerYAnchor.constraint(equalTo: (self.navigationController?.toolbar.centerYAnchor)!, constant: 0).isActive = true
|
||||
|
||||
self.navigationController?.navigationBar.barStyle = .blackTranslucent
|
||||
self.navigationController?.toolbar.barStyle = .blackTranslucent
|
||||
|
||||
self.updateTheme()
|
||||
}
|
||||
|
||||
override func viewWillAppear(_ animated: Bool)
|
||||
@ -140,15 +156,8 @@ private extension GamesViewController
|
||||
{
|
||||
switch self.theme
|
||||
{
|
||||
case .light:
|
||||
self.view.backgroundColor = UIColor.white
|
||||
self.navigationController?.navigationBar.barStyle = .default
|
||||
self.navigationController?.toolbar.barStyle = .default
|
||||
|
||||
case .dark:
|
||||
self.view.backgroundColor = nil
|
||||
self.navigationController?.navigationBar.barStyle = .blackTranslucent
|
||||
self.navigationController?.toolbar.barStyle = .blackTranslucent
|
||||
case .opaque: self.view.backgroundColor = UIColor.deltaDarkGray
|
||||
case .translucent: self.view.backgroundColor = nil
|
||||
}
|
||||
|
||||
if let viewControllers = self.pageViewController.viewControllers as? [GameCollectionViewController]
|
||||
@ -267,6 +276,30 @@ extension GamesViewController: ImportControllerDelegate
|
||||
}
|
||||
}
|
||||
|
||||
private extension GamesViewController
|
||||
{
|
||||
@objc func managedObjectContextDidChange(with notification: Notification)
|
||||
{
|
||||
guard let deletedObjects = notification.userInfo?[NSDeletedObjectsKey] as? Set<NSManagedObject> else { return }
|
||||
|
||||
if let game = self.activeEmulatorCore?.game as? Game
|
||||
{
|
||||
if deletedObjects.contains(game)
|
||||
{
|
||||
DispatchQueue.main.async {
|
||||
self.theme = .opaque
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DispatchQueue.main.async {
|
||||
self.theme = .opaque
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//MARK: - UIPageViewController -
|
||||
/// UIPageViewController
|
||||
extension GamesViewController: UIPageViewControllerDataSource, UIPageViewControllerDelegate
|
||||
|
||||
@ -26,7 +26,7 @@ class SaveStatesStoryboardSegue: UIStoryboardSegue
|
||||
let doneButton = UIBarButtonItem(barButtonSystemItem: .done, target: self, action: #selector(SaveStatesStoryboardSegue.handleDoneButton))
|
||||
saveStatesViewController.navigationItem.rightBarButtonItem = doneButton
|
||||
|
||||
guard saveStatesViewController.theme == .dark else { return }
|
||||
guard saveStatesViewController.theme == .translucent else { return }
|
||||
|
||||
let sourceView = self.source.navigationController!.view!
|
||||
|
||||
@ -53,7 +53,7 @@ class SaveStatesStoryboardUnwindSegue: UIStoryboardSegue
|
||||
{
|
||||
super.perform()
|
||||
|
||||
guard let saveStatesViewController = (self.source as? UINavigationController)?.topViewController as? SaveStatesViewController, saveStatesViewController.theme == .dark else { return }
|
||||
guard let saveStatesViewController = (self.source as? UINavigationController)?.topViewController as? SaveStatesViewController, saveStatesViewController.theme == .translucent else { return }
|
||||
|
||||
let destinationView = self.destination.navigationController!.view!
|
||||
|
||||
|
||||
@ -49,7 +49,7 @@ class SaveStatesViewController: UICollectionViewController
|
||||
|
||||
var mode = Mode.loading
|
||||
|
||||
var theme = Theme.dark {
|
||||
var theme = Theme.translucent {
|
||||
didSet {
|
||||
if self.isViewLoaded
|
||||
{
|
||||
@ -135,6 +135,9 @@ extension SaveStatesViewController
|
||||
|
||||
self.registerForPreviewing(with: self, sourceView: self.collectionView!)
|
||||
|
||||
self.navigationController?.navigationBar.barStyle = .blackTranslucent
|
||||
self.navigationController?.toolbar.barStyle = .blackTranslucent
|
||||
|
||||
self.updateBackgroundView()
|
||||
self.updateTheme()
|
||||
}
|
||||
@ -192,23 +195,17 @@ private extension SaveStatesViewController
|
||||
{
|
||||
switch self.theme
|
||||
{
|
||||
case .light:
|
||||
self.view.backgroundColor = UIColor.white
|
||||
|
||||
self.navigationController?.navigationBar.barStyle = .default
|
||||
self.navigationController?.toolbar.barStyle = .default
|
||||
case .opaque:
|
||||
self.view.backgroundColor = UIColor.deltaDarkGray
|
||||
|
||||
self.vibrancyView.effect = nil
|
||||
|
||||
self.backgroundView.textLabel.textColor = UIColor.gray
|
||||
self.backgroundView.detailTextLabel.textColor = UIColor.gray
|
||||
|
||||
case .dark:
|
||||
case .translucent:
|
||||
self.view.backgroundColor = nil
|
||||
|
||||
self.navigationController?.navigationBar.barStyle = .blackTranslucent
|
||||
self.navigationController?.toolbar.barStyle = .blackTranslucent
|
||||
|
||||
self.vibrancyView.effect = UIVibrancyEffect(blurEffect: UIBlurEffect(style: .dark))
|
||||
|
||||
self.backgroundView.textLabel.textColor = UIColor.white
|
||||
@ -224,20 +221,17 @@ private extension SaveStatesViewController
|
||||
|
||||
cell.imageView.backgroundColor = UIColor.white
|
||||
cell.imageView.image = UIImage(named: "DeltaPlaceholder")
|
||||
cell.textLabel.textColor = UIColor.gray
|
||||
|
||||
switch self.theme
|
||||
{
|
||||
case .light:
|
||||
case .opaque:
|
||||
cell.isTextLabelVibrancyEnabled = false
|
||||
cell.isImageViewVibrancyEnabled = false
|
||||
|
||||
cell.textLabel.textColor = UIColor.gray
|
||||
|
||||
case .dark:
|
||||
case .translucent:
|
||||
cell.isTextLabelVibrancyEnabled = true
|
||||
cell.isImageViewVibrancyEnabled = true
|
||||
|
||||
cell.textLabel.textColor = UIColor.white
|
||||
}
|
||||
|
||||
if !ignoreOperations
|
||||
@ -289,16 +283,12 @@ private extension SaveStatesViewController
|
||||
}
|
||||
|
||||
headerView.textLabel.text = title
|
||||
headerView.textLabel.textColor = UIColor.white
|
||||
|
||||
switch self.theme
|
||||
{
|
||||
case .light:
|
||||
headerView.textLabel.textColor = UIColor.gray
|
||||
headerView.isTextLabelVibrancyEnabled = false
|
||||
|
||||
case .dark:
|
||||
headerView.textLabel.textColor = UIColor.white
|
||||
headerView.isTextLabelVibrancyEnabled = true
|
||||
case .opaque: headerView.isTextLabelVibrancyEnabled = false
|
||||
case .translucent: headerView.isTextLabelVibrancyEnabled = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -10,6 +10,6 @@ import Foundation
|
||||
|
||||
enum Theme
|
||||
{
|
||||
case light
|
||||
case dark
|
||||
case opaque
|
||||
case translucent
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user