show navbar for photo/album picker, not approval

pull/1/head
Michael Kirk 6 years ago
parent 753c88437f
commit 9bcc6a6c57

@ -291,11 +291,7 @@ class MediaGalleryNavigationController: OWSNavigationController {
return return
} }
navigationBar.respectsTheme = false navigationBar.overrideTheme(type: .alwaysDark)
navigationBar.barStyle = .black
navigationBar.titleTextAttributes = [NSAttributedStringKey.foregroundColor: Theme.darkThemePrimaryColor]
navigationBar.barTintColor = Theme.darkThemeBackgroundColor.withAlphaComponent(0.6)
navigationBar.tintColor = Theme.darkThemePrimaryColor
} }
override func viewDidAppear(_ animated: Bool) { override func viewDidAppear(_ animated: Bool) {

@ -59,12 +59,6 @@ class ImagePickerGridController: UICollectionViewController, PhotoLibraryDelegat
view.backgroundColor = .ows_gray95 view.backgroundColor = .ows_gray95
if let navBar = self.navigationController?.navigationBar as? OWSNavigationBar {
navBar.makeClear()
} else {
owsFailDebug("Invalid nav bar.")
}
let cancelButton = UIBarButtonItem(barButtonSystemItem: .stop, let cancelButton = UIBarButtonItem(barButtonSystemItem: .stop,
target: self, target: self,
action: #selector(didPressCancel)) action: #selector(didPressCancel))
@ -107,6 +101,12 @@ class ImagePickerGridController: UICollectionViewController, PhotoLibraryDelegat
override func viewWillAppear(_ animated: Bool) { override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated) super.viewWillAppear(animated)
if let navBar = self.navigationController?.navigationBar as? OWSNavigationBar {
navBar.overrideTheme(type: .alwaysDark)
} else {
owsFailDebug("Invalid nav bar.")
}
// Determine the size of the thumbnails to request // Determine the size of the thumbnails to request
let scale = UIScreen.main.scale let scale = UIScreen.main.scale
let cellSize = collectionViewFlowLayout.itemSize let cellSize = collectionViewFlowLayout.itemSize

@ -39,12 +39,6 @@ class PhotoCollectionPickerController: OWSTableViewController, PhotoLibraryDeleg
view.backgroundColor = .ows_gray95 view.backgroundColor = .ows_gray95
if let navBar = self.navigationController?.navigationBar as? OWSNavigationBar {
navBar.makeClear()
} else {
owsFailDebug("Invalid nav bar.")
}
if #available(iOS 11, *) { if #available(iOS 11, *) {
let titleLabel = UILabel() let titleLabel = UILabel()
titleLabel.text = previousPhotoCollection.localizedTitle() titleLabel.text = previousPhotoCollection.localizedTitle()
@ -77,6 +71,16 @@ class PhotoCollectionPickerController: OWSTableViewController, PhotoLibraryDeleg
updateContents() updateContents()
} }
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
if let navBar = self.navigationController?.navigationBar as? OWSNavigationBar {
navBar.overrideTheme(type: .alwaysDark)
} else {
owsFailDebug("Invalid nav bar.")
}
}
private func updateContents() { private func updateContents() {
photoCollections = library.allPhotoCollections() photoCollections = library.allPhotoCollections()

@ -145,7 +145,7 @@ public class AttachmentApprovalViewController: UIPageViewController, UIPageViewC
owsFailDebug("navigationBar was nil or unexpected class") owsFailDebug("navigationBar was nil or unexpected class")
return navController return navController
} }
navigationBar.makeClear() navigationBar.overrideTheme(type: .clear)
return navController return navController
} }
@ -247,6 +247,12 @@ public class AttachmentApprovalViewController: UIPageViewController, UIPageViewC
super.viewWillAppear(animated) super.viewWillAppear(animated)
CurrentAppContext().setStatusBarHidden(true, animated: animated) CurrentAppContext().setStatusBarHidden(true, animated: animated)
guard let navigationBar = navigationController?.navigationBar as? OWSNavigationBar else {
owsFailDebug("navigationBar was nil or unexpected class")
return
}
navigationBar.overrideTheme(type: .clear)
} }
override public func viewDidAppear(_ animated: Bool) { override public func viewDidAppear(_ animated: Bool) {

@ -59,14 +59,11 @@ public class OWSNavigationBar: UINavigationBar {
private func applyTheme() { private func applyTheme() {
guard respectsTheme else { guard respectsTheme else {
removeBlurEffectView()
self.setBackgroundImage(nil, for: .default)
return return
} }
if UIAccessibilityIsReduceTransparencyEnabled() { if UIAccessibilityIsReduceTransparencyEnabled() {
removeBlurEffectView() blurEffectView?.isHidden = true
let color = Theme.navbarBackgroundColor let color = Theme.navbarBackgroundColor
let backgroundImage = UIImage(color: color) let backgroundImage = UIImage(color: color)
self.setBackgroundImage(backgroundImage, for: .default) self.setBackgroundImage(backgroundImage, for: .default)
@ -189,38 +186,37 @@ public class OWSNavigationBar: UINavigationBar {
} }
} }
// MARK: // MARK: Override Theme
@objc @objc
public func makeClear() { public enum NavigationBarThemeOverride: Int {
self.backgroundColor = .clear case clear, alwaysDark
// Making a toolbar transparent requires setting an empty uiimage
self.setBackgroundImage(UIImage(), for: .default)
self.shadowImage = UIImage()
self.clipsToBounds = true
removeBlurEffectView()
} }
// MARK: @objc
public func overrideTheme(type: NavigationBarThemeOverride) {
private func removeBlurEffectView() { respectsTheme = false
// Avoid crash on iOS 10.3.3 and iOS 9.4.
// barStyle = .black
// Last Exception Backtrace: titleTextAttributes = [NSAttributedStringKey.foregroundColor: Theme.darkThemePrimaryColor]
// 0 CoreFoundation 0x1b6bfb38 __exceptionPreprocess + 124 (NSException.m:165) barTintColor = Theme.darkThemeBackgroundColor.withAlphaComponent(0.6)
// 1 libobjc.A.dylib 0x1a947062 objc_exception_throw + 34 (objc-exception.mm:521) tintColor = Theme.darkThemePrimaryColor
// 2 CoreFoundation 0x1b6bfa80 +[NSException raise:format:] + 104 (NSException.m:140)
// 3 UIKit 0x20bfc9fe -[UINavigationBar removeConstraint:] + 84 (UINavigationBar.m:4618) switch type {
// 4 UIKit 0x208ee3d4 _UIViewRemoveConstraintsMadeDanglyByChangingSuperview + 534 // (NSLayoutConstraint_UIKitAdditions.m:4716) case .clear:
// 5 UIKit 0x208ede90 __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 40 // (UIView.m:9467) blurEffectView?.isHidden = true
// 6 UIKit 0x208edd6c -[UIView(Hierarchy) _postMovedFromSuperview:] + 710 (UIView.m:361) clipsToBounds = true
// 7 UIKit 0x20bd19e8 __UIViewWasRemovedFromSuperview + 154 (UIView.m:8889)
// 8 UIKit 0x208ecf6a -[UIView(Hierarchy) removeFromSuperview] + 528 (UIView.m:8961) // Making a toolbar transparent requires setting an empty uiimage
// 9 SignalMessaging 0x1d42b64 OWSNavigationBar.applyTheme() + 218 (OWSNavigationBar.swift:62) setBackgroundImage(UIImage(), for: .default)
if #available(iOS 11, *) { shadowImage = UIImage()
self.blurEffectView?.removeFromSuperview() backgroundColor = .clear
} else { case .alwaysDark:
self.blurEffectView?.isHidden = true blurEffectView?.isHidden = false
clipsToBounds = false
setBackgroundImage(nil, for: .default)
shadowImage = nil
} }
} }
} }

Loading…
Cancel
Save