Commit f44b4a9c authored by Mike JS. Choi's avatar Mike JS. Choi Committed by Carola Nitz

Actionsheet: Add theme observer (fixes #301)

parent 2a3d7f3c
......@@ -171,6 +171,8 @@ class VLCActionSheet: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
NotificationCenter.default.addObserver(self, selector: #selector(updateTheme), name: .VLCThemeDidChangeNotification, object: nil)
view.addSubview(backgroundView)
view.addSubview(mainStackView)
......@@ -230,6 +232,20 @@ class VLCActionSheet: UIViewController {
@objc func setAction(closure action: @escaping (_ item: Any) -> Void) {
self.action = action
}
@objc fileprivate func updateTheme() {
collectionView.backgroundColor = PresentationTheme.current.colors.background
headerView.backgroundColor = PresentationTheme.current.colors.background
headerView.title.textColor = PresentationTheme.current.colors.cellTextColor
bottomBackgroundView.backgroundColor = PresentationTheme.current.colors.background
for cell in collectionView.visibleCells {
if let cell = cell as? VLCActionSheetCell {
cell.backgroundColor = PresentationTheme.current.colors.background
cell.name.textColor = PresentationTheme.current.colors.cellTextColor
}
}
collectionView.layoutIfNeeded()
}
}
// MARK: UICollectionViewDelegateFlowLayout
......
......@@ -39,7 +39,6 @@ class VLCRendererDiscovererManager: NSObject {
@objc init(presentingViewController: UIViewController?) {
self.presentingViewController = presentingViewController
super.init()
NotificationCenter.default.addObserver(self, selector: #selector(updateTheme), name: .VLCThemeDidChangeNotification, object: nil)
}
// Returns renderers of *all* discoverers
......@@ -203,20 +202,6 @@ extension VLCRendererDiscovererManager: VLCRendererDiscovererDelegate {
cell.icon.image = image
cell.name.textColor = textColor
}
@objc fileprivate func updateTheme() {
actionSheet.collectionView.backgroundColor = PresentationTheme.current.colors.background
actionSheet.headerView.backgroundColor = PresentationTheme.current.colors.background
actionSheet.headerView.title.textColor = PresentationTheme.current.colors.cellTextColor
actionSheet.bottomBackgroundView.backgroundColor = PresentationTheme.current.colors.background
for cell in actionSheet.collectionView.visibleCells {
if let cell = cell as? VLCActionSheetCell {
cell.backgroundColor = PresentationTheme.current.colors.background
cell.name.textColor = PresentationTheme.current.colors.cellTextColor
}
}
actionSheet.collectionView.layoutIfNeeded()
}
}
// MARK: VLCActionSheetDelegate
......
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