From 86d006ba1425b646538857e54e9f6554c630db7d Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Thu, 15 Nov 2018 13:14:07 -0500 Subject: [PATCH] Respond to CR. --- .../PhotoLibrary/ImagePickerController.swift | 40 +++++++++++-------- .../PhotoCollectionPickerController.swift | 36 +++++++++-------- 2 files changed, 44 insertions(+), 32 deletions(-) diff --git a/Signal/src/ViewControllers/PhotoLibrary/ImagePickerController.swift b/Signal/src/ViewControllers/PhotoLibrary/ImagePickerController.swift index 3d7f473de..1ed56ff00 100644 --- a/Signal/src/ViewControllers/PhotoLibrary/ImagePickerController.swift +++ b/Signal/src/ViewControllers/PhotoLibrary/ImagePickerController.swift @@ -56,21 +56,25 @@ class ImagePickerGridController: UICollectionViewController, PhotoLibraryDelegat target: self, action: #selector(didPressCancel)) - titleLabel.text = photoCollection.localizedTitle() - titleLabel.textColor = Theme.primaryColor - titleLabel.font = UIFont.ows_dynamicTypeBody.ows_mediumWeight() - - let titleIconView = UIImageView() - titleIconView.tintColor = Theme.primaryColor - titleIconView.image = UIImage(named: "navbar_disclosure_down")?.withRenderingMode(.alwaysTemplate) - - let titleView = UIStackView(arrangedSubviews: [titleLabel, titleIconView]) - titleView.axis = .horizontal - titleView.alignment = .center - titleView.spacing = 5 - titleView.isUserInteractionEnabled = true - titleView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(titleTapped))) - navigationItem.titleView = titleView + if #available(iOS 11, *) { + titleLabel.text = photoCollection.localizedTitle() + titleLabel.textColor = Theme.primaryColor + titleLabel.font = UIFont.ows_dynamicTypeBody.ows_mediumWeight() + + let titleIconView = UIImageView() + titleIconView.tintColor = Theme.primaryColor + titleIconView.image = UIImage(named: "navbar_disclosure_down")?.withRenderingMode(.alwaysTemplate) + + let titleView = UIStackView(arrangedSubviews: [titleLabel, titleIconView]) + titleView.axis = .horizontal + titleView.alignment = .center + titleView.spacing = 5 + titleView.isUserInteractionEnabled = true + titleView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(titleTapped))) + navigationItem.titleView = titleView + } else { + navigationItem.title = photoCollection.localizedTitle() + } let featureFlag_isMultiselectEnabled = true if featureFlag_isMultiselectEnabled { @@ -242,7 +246,11 @@ class ImagePickerGridController: UICollectionViewController, PhotoLibraryDelegat photoCollection = collection photoCollectionContents = photoCollection.contents() - titleLabel.text = photoCollection.localizedTitle() + if #available(iOS 11, *) { + titleLabel.text = photoCollection.localizedTitle() + } else { + navigationItem.title = photoCollection.localizedTitle() + } collectionView?.reloadData() } diff --git a/Signal/src/ViewControllers/PhotoLibrary/PhotoCollectionPickerController.swift b/Signal/src/ViewControllers/PhotoLibrary/PhotoCollectionPickerController.swift index 07b2ce7fd..4c5c4a981 100644 --- a/Signal/src/ViewControllers/PhotoLibrary/PhotoCollectionPickerController.swift +++ b/Signal/src/ViewControllers/PhotoLibrary/PhotoCollectionPickerController.swift @@ -37,22 +37,26 @@ class PhotoCollectionPickerController: OWSTableViewController, PhotoLibraryDeleg override func viewDidLoad() { super.viewDidLoad() - let titleLabel = UILabel() - titleLabel.text = previousPhotoCollection.localizedTitle() - titleLabel.textColor = Theme.primaryColor - titleLabel.font = UIFont.ows_dynamicTypeBody.ows_mediumWeight() - - let titleIconView = UIImageView() - titleIconView.tintColor = Theme.primaryColor - titleIconView.image = UIImage(named: "navbar_disclosure_up")?.withRenderingMode(.alwaysTemplate) - - let titleView = UIStackView(arrangedSubviews: [titleLabel, titleIconView]) - titleView.axis = .horizontal - titleView.alignment = .center - titleView.spacing = 5 - titleView.isUserInteractionEnabled = true - titleView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(titleTapped))) - navigationItem.titleView = titleView + if #available(iOS 11, *) { + let titleLabel = UILabel() + titleLabel.text = previousPhotoCollection.localizedTitle() + titleLabel.textColor = Theme.primaryColor + titleLabel.font = UIFont.ows_dynamicTypeBody.ows_mediumWeight() + + let titleIconView = UIImageView() + titleIconView.tintColor = Theme.primaryColor + titleIconView.image = UIImage(named: "navbar_disclosure_up")?.withRenderingMode(.alwaysTemplate) + + let titleView = UIStackView(arrangedSubviews: [titleLabel, titleIconView]) + titleView.axis = .horizontal + titleView.alignment = .center + titleView.spacing = 5 + titleView.isUserInteractionEnabled = true + titleView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(titleTapped))) + navigationItem.titleView = titleView + } else { + navigationItem.title = previousPhotoCollection.localizedTitle() + } library.add(delegate: self)