From 85a77edfca361f06fa8165152e62a136b7ee57b2 Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Mon, 20 Jan 2020 14:44:51 +1100 Subject: [PATCH] Clean up photo editing screen --- .../GifPicker/GifPickerViewController.swift | 9 +++-- .../MediaDetailViewController.m | 8 +---- .../MediaPageViewController.swift | 5 +-- .../Photos/ImagePickerController.swift | 35 +++++++++++-------- .../PhotoCollectionPickerController.swift | 18 +++++----- .../SendMediaNavigationController.swift | 28 +++++++-------- .../AttachmentApprovalViewController.swift | 20 ++++++----- .../ImageEditorTextViewController.swift | 2 +- .../OWSViewController+ImageEditor.swift | 12 ++++++- 9 files changed, 77 insertions(+), 60 deletions(-) diff --git a/Signal/src/ViewControllers/GifPicker/GifPickerViewController.swift b/Signal/src/ViewControllers/GifPicker/GifPickerViewController.swift index de94fc828..5a5f53600 100644 --- a/Signal/src/ViewControllers/GifPicker/GifPickerViewController.swift +++ b/Signal/src/ViewControllers/GifPicker/GifPickerViewController.swift @@ -115,8 +115,13 @@ class GifPickerViewController: OWSViewController, UISearchBarDelegate, UICollect self.navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .cancel, target: self, action: #selector(donePressed)) - self.navigationItem.title = NSLocalizedString("GIF_PICKER_VIEW_TITLE", - comment: "Title for the 'GIF picker' dialog.") + + // Loki: Customize title + let titleLabel = UILabel() + titleLabel.text = NSLocalizedString("GIF", comment: "") + titleLabel.textColor = Colors.text + titleLabel.font = .boldSystemFont(ofSize: Values.veryLargeFontSize) + navigationItem.titleView = titleLabel createViews() diff --git a/Signal/src/ViewControllers/MediaDetailViewController.m b/Signal/src/ViewControllers/MediaDetailViewController.m index 3643f7fb7..c79cdd908 100644 --- a/Signal/src/ViewControllers/MediaDetailViewController.m +++ b/Signal/src/ViewControllers/MediaDetailViewController.m @@ -107,16 +107,10 @@ NS_ASSUME_NONNULL_BEGIN { [super viewDidLoad]; - self.view.backgroundColor = [UIColor clearColor]; + self.view.backgroundColor = LKColors.navigationBarBackground; [self updateContents]; - // Loki: Set gradient background - self.view.backgroundColor = UIColor.clearColor; - LKGradient *gradient = LKGradients.defaultLokiBackground; - self.view.backgroundColor = UIColor.clearColor; - [self.view setGradient:gradient]; - // Loki: Set navigation bar background color UINavigationBar *navigationBar = self.navigationController.navigationBar; [navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault]; diff --git a/Signal/src/ViewControllers/MediaPageViewController.swift b/Signal/src/ViewControllers/MediaPageViewController.swift index 61cafc88b..351060cdf 100644 --- a/Signal/src/ViewControllers/MediaPageViewController.swift +++ b/Signal/src/ViewControllers/MediaPageViewController.swift @@ -152,8 +152,9 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou } // Views - - view.backgroundColor = Theme.darkThemeBackgroundColor + pagerScrollView.backgroundColor = Colors.navigationBarBackground + + view.backgroundColor = Colors.navigationBarBackground captionContainerView.delegate = self updateCaptionContainerVisibility() diff --git a/Signal/src/ViewControllers/Photos/ImagePickerController.swift b/Signal/src/ViewControllers/Photos/ImagePickerController.swift index c30191517..42393dfa6 100644 --- a/Signal/src/ViewControllers/Photos/ImagePickerController.swift +++ b/Signal/src/ViewControllers/Photos/ImagePickerController.swift @@ -59,7 +59,7 @@ class ImagePickerGridController: UICollectionViewController, PhotoLibraryDelegat // ensure images at the end of the list can be scrolled above the bottom buttons let bottomButtonInset = -1 * SendMediaNavigationController.bottomButtonsCenterOffset + SendMediaNavigationController.bottomButtonWidth / 2 collectionView.contentInset.bottom = bottomButtonInset + 8 - view.backgroundColor = Colors.navigationBarBackground + view.backgroundColor = .white // The PhotoCaptureVC needs a shadow behind it's cancel button, so we use a custom icon. // This VC has a visible navbar so doesn't need the shadow, but because the user can @@ -69,19 +69,12 @@ class ImagePickerGridController: UICollectionViewController, PhotoLibraryDelegat let cancelImage = UIImage(imageLiteralResourceName: "X") let cancelButton = UIBarButtonItem(image: cancelImage, style: .plain, target: self, action: #selector(didPressCancel)) - cancelButton.tintColor = Colors.text + cancelButton.tintColor = .black navigationItem.leftBarButtonItem = cancelButton let titleView = TitleView() titleView.delegate = self titleView.text = photoCollection.localizedTitle() - - // Loki: Set navigation bar background color - let navigationBar = navigationController!.navigationBar - navigationBar.setBackgroundImage(UIImage(), for: UIBarMetrics.default) - navigationBar.shadowImage = UIImage() - navigationBar.isTranslucent = false - navigationBar.barTintColor = Colors.navigationBarBackground if #available(iOS 11, *) { // do nothing @@ -93,7 +86,7 @@ class ImagePickerGridController: UICollectionViewController, PhotoLibraryDelegat navigationItem.titleView = titleView self.titleView = titleView - collectionView.backgroundColor = Colors.navigationBarBackground + collectionView.backgroundColor = .white let selectionPanGesture = DirectionalPanGestureRecognizer(direction: [.horizontal], target: self, action: #selector(didPanSelection)) selectionPanGesture.delegate = self @@ -106,7 +99,7 @@ class ImagePickerGridController: UICollectionViewController, PhotoLibraryDelegat case select, deselect } var selectionPanGestureMode: BatchSelectionGestureMode = .select - + @objc func didPanSelection(_ selectionPanGesture: UIPanGestureRecognizer) { guard let collectionView = collectionView else { @@ -194,6 +187,17 @@ class ImagePickerGridController: UICollectionViewController, PhotoLibraryDelegat override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) + // Loki: Set navigation bar background color + let navigationBar = navigationController!.navigationBar + navigationBar.setBackgroundImage(UIImage(), for: UIBarMetrics.default) + navigationBar.shadowImage = UIImage() + navigationBar.isTranslucent = false + navigationBar.barTintColor = .white + (navigationBar as! OWSNavigationBar).respectsTheme = false + navigationBar.backgroundColor = .white + let backgroundImage = UIImage(color: .white) + navigationBar.setBackgroundImage(backgroundImage, for: .default) + // Determine the size of the thumbnails to request let scale = UIScreen.main.scale let cellSize = collectionViewFlowLayout.itemSize @@ -219,12 +223,12 @@ class ImagePickerGridController: UICollectionViewController, PhotoLibraryDelegat scrollToBottom(animated: false) } } - + override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) hasEverAppeared = true - + // Since we're presenting *over* the ConversationVC, we need to `becomeFirstResponder`. // // Otherwise, the `ConversationVC.inputAccessoryView` will appear over top of us whenever @@ -440,6 +444,7 @@ class ImagePickerGridController: UICollectionViewController, PhotoLibraryDelegat collectionPickerView.autoPinEdgesToSuperviewEdges(with: .zero, excludingEdge: .top) collectionPickerView.autoPinEdge(toSuperviewSafeArea: .top) collectionPickerView.layoutIfNeeded() + collectionPickerView.backgroundColor = .white // Initially position offscreen, we'll animate it in. collectionPickerView.frame = collectionPickerView.frame.offsetBy(dx: 0, dy: collectionPickerView.frame.height) @@ -602,10 +607,10 @@ class TitleView: UIView { addSubview(stackView) stackView.autoPinEdgesToSuperviewEdges() - label.textColor = Colors.text + label.textColor = .black label.font = .boldSystemFont(ofSize: Values.mediumFontSize) - iconView.tintColor = Colors.text + iconView.tintColor = .black iconView.image = UIImage(named: "navbar_disclosure_down")?.withRenderingMode(.alwaysTemplate) addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(titleTapped))) diff --git a/Signal/src/ViewControllers/Photos/PhotoCollectionPickerController.swift b/Signal/src/ViewControllers/Photos/PhotoCollectionPickerController.swift index 4ff7d0371..a386e51ff 100644 --- a/Signal/src/ViewControllers/Photos/PhotoCollectionPickerController.swift +++ b/Signal/src/ViewControllers/Photos/PhotoCollectionPickerController.swift @@ -34,8 +34,8 @@ class PhotoCollectionPickerController: OWSTableViewController, PhotoLibraryDeleg override func viewDidLoad() { super.viewDidLoad() - view.backgroundColor = Colors.navigationBarBackground - tableView.backgroundColor = Colors.navigationBarBackground + view.backgroundColor = .white + tableView.backgroundColor = .white tableView.separatorColor = .clear library.add(delegate: self) @@ -68,21 +68,21 @@ class PhotoCollectionPickerController: OWSTableViewController, PhotoLibraryDeleg private func buildTableCell(collection: PhotoCollection) -> UITableViewCell { let cell = OWSTableItem.newCell() - cell.backgroundColor = Theme.darkThemeBackgroundColor - cell.contentView.backgroundColor = Theme.darkThemeBackgroundColor + cell.backgroundColor = .white + cell.contentView.backgroundColor = .white cell.selectedBackgroundView?.backgroundColor = UIColor(white: 0.2, alpha: 1) let contents = collection.contents() let titleLabel = UILabel() titleLabel.text = collection.localizedTitle() - titleLabel.font = UIFont.ows_dynamicTypeBody - titleLabel.textColor = Theme.darkThemePrimaryColor + titleLabel.font = .systemFont(ofSize: Values.mediumFontSize) + titleLabel.textColor = .black let countLabel = UILabel() countLabel.text = numberFormatter.string(for: contents.assetCount) - countLabel.font = UIFont.ows_dynamicTypeCaption1 - countLabel.textColor = Theme.darkThemePrimaryColor + countLabel.font = .systemFont(ofSize: Values.smallFontSize) + countLabel.textColor = .black let textStack = UIStackView(arrangedSubviews: [titleLabel, countLabel]) textStack.axis = .vertical @@ -98,7 +98,7 @@ class PhotoCollectionPickerController: OWSTableViewController, PhotoLibraryDeleg let hStackView = UIStackView(arrangedSubviews: [imageView, textStack]) hStackView.axis = .horizontal hStackView.alignment = .center - hStackView.spacing = 11 + hStackView.spacing = Values.mediumSpacing let photoMediaSize = PhotoMediaSize(thumbnailSize: CGSize(width: kImageSize, height: kImageSize)) if let assetItem = contents.lastAssetItem(photoMediaSize: photoMediaSize) { diff --git a/Signal/src/ViewControllers/Photos/SendMediaNavigationController.swift b/Signal/src/ViewControllers/Photos/SendMediaNavigationController.swift index 8e82b7eb7..94382bfb2 100644 --- a/Signal/src/ViewControllers/Photos/SendMediaNavigationController.swift +++ b/Signal/src/ViewControllers/Photos/SendMediaNavigationController.swift @@ -257,13 +257,13 @@ class SendMediaNavigationController: OWSNavigationController { extension SendMediaNavigationController: UINavigationControllerDelegate { func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) { - if let navbarTheme = preferredNavbarTheme(viewController: viewController) { - if let owsNavBar = navigationBar as? OWSNavigationBar { - owsNavBar.overrideTheme(type: navbarTheme) - } else { - owsFailDebug("unexpected navigationBar: \(navigationBar)") - } - } +// if let navbarTheme = preferredNavbarTheme(viewController: viewController) { +// if let owsNavBar = navigationBar as? OWSNavigationBar { +// owsNavBar.overrideTheme(type: navbarTheme) +// } else { +// owsFailDebug("unexpected navigationBar: \(navigationBar)") +// } +// } switch viewController { case is PhotoCaptureViewController: @@ -286,13 +286,13 @@ extension SendMediaNavigationController: UINavigationControllerDelegate { // In case back navigation was canceled, we re-apply whatever is showing. func navigationController(_ navigationController: UINavigationController, didShow viewController: UIViewController, animated: Bool) { - if let navbarTheme = preferredNavbarTheme(viewController: viewController) { - if let owsNavBar = navigationBar as? OWSNavigationBar { - owsNavBar.overrideTheme(type: navbarTheme) - } else { - owsFailDebug("unexpected navigationBar: \(navigationBar)") - } - } +// if let navbarTheme = preferredNavbarTheme(viewController: viewController) { +// if let owsNavBar = navigationBar as? OWSNavigationBar { +// owsNavBar.overrideTheme(type: navbarTheme) +// } else { +// owsFailDebug("unexpected navigationBar: \(navigationBar)") +// } +// } self.updateButtons(topViewController: viewController) } diff --git a/SignalMessaging/ViewControllers/AttachmentApproval/AttachmentApprovalViewController.swift b/SignalMessaging/ViewControllers/AttachmentApproval/AttachmentApprovalViewController.swift index 80768e4cb..464ff7859 100644 --- a/SignalMessaging/ViewControllers/AttachmentApproval/AttachmentApprovalViewController.swift +++ b/SignalMessaging/ViewControllers/AttachmentApproval/AttachmentApprovalViewController.swift @@ -92,13 +92,6 @@ public class AttachmentApprovalViewController: UIPageViewController, UIPageViewC vc.approvalDelegate = approvalDelegate let navController = OWSNavigationController(rootViewController: vc) navController.ows_prefersStatusBarHidden = true - - guard let navigationBar = navController.navigationBar as? OWSNavigationBar else { - owsFailDebug("navigationBar was nil or unexpected class") - return navController - } - navigationBar.overrideTheme(type: .clear) - return navController } @@ -138,7 +131,7 @@ public class AttachmentApprovalViewController: UIPageViewController, UIPageViewC override public func viewDidLoad() { super.viewDidLoad() - self.view.backgroundColor = .black + self.view.backgroundColor = .red // avoid an unpleasant "bounce" which doesn't make sense in the context of a single item. pagerScrollView?.isScrollEnabled = attachmentItems.count > 1 @@ -176,7 +169,16 @@ public class AttachmentApprovalViewController: UIPageViewController, UIPageViewC owsFailDebug("navigationBar was nil or unexpected class") return } - navigationBar.overrideTheme(type: .clear) + + // Loki: Set navigation bar background color + navigationBar.setBackgroundImage(UIImage(), for: UIBarMetrics.default) + navigationBar.shadowImage = UIImage() + navigationBar.isTranslucent = false + navigationBar.barTintColor = UIColor(rgbHex: 0x161616) // Colors.navigationBarBackground + navigationBar.respectsTheme = true + navigationBar.backgroundColor = UIColor(rgbHex: 0x161616) // Colors.navigationBarBackground + let backgroundImage = UIImage(color: UIColor(rgbHex: 0x161616)) // Colors.navigationBarBackground + navigationBar.setBackgroundImage(backgroundImage, for: .default) updateContents() } diff --git a/SignalMessaging/Views/ImageEditor/ImageEditorTextViewController.swift b/SignalMessaging/Views/ImageEditor/ImageEditorTextViewController.swift index 5b593cb9a..ca380da0a 100644 --- a/SignalMessaging/Views/ImageEditor/ImageEditorTextViewController.swift +++ b/SignalMessaging/Views/ImageEditor/ImageEditorTextViewController.swift @@ -169,7 +169,7 @@ public class ImageEditorTextViewController: OWSViewController, VAlignTextViewDel canvasView.autoPinEdgesToSuperviewEdges() let tintView = UIView() - tintView.backgroundColor = UIColor(white: 0, alpha: 0.33) + tintView.backgroundColor = .clear tintView.isOpaque = false self.view.addSubview(tintView) tintView.autoPinEdgesToSuperviewEdges() diff --git a/SignalMessaging/Views/ImageEditor/OWSViewController+ImageEditor.swift b/SignalMessaging/Views/ImageEditor/OWSViewController+ImageEditor.swift index 9b233fd3f..dd0d41f1a 100644 --- a/SignalMessaging/Views/ImageEditor/OWSViewController+ImageEditor.swift +++ b/SignalMessaging/Views/ImageEditor/OWSViewController+ImageEditor.swift @@ -35,7 +35,7 @@ public extension UIViewController { stackView.axis = .horizontal stackView.spacing = spacing stackView.alignment = .center - + // Ensure layout works on older versions of iOS. var stackSize = CGSize.zero for item in navigationBarItems { @@ -49,5 +49,15 @@ public extension UIViewController { stackView.frame = CGRect(origin: .zero, size: stackSize) self.navigationItem.rightBarButtonItem = UIBarButtonItem(customView: stackView) + + // Loki: Set navigation bar background color + let navigationBar = navigationController!.navigationBar + navigationBar.setBackgroundImage(UIImage(), for: UIBarMetrics.default) + navigationBar.shadowImage = UIImage() + navigationBar.isTranslucent = false + navigationBar.barTintColor = UIColor(rgbHex: 0x161616) // Colors.navigationBarBackground + navigationBar.backgroundColor = UIColor(rgbHex: 0x161616) // Colors.navigationBarBackground + let backgroundImage = UIImage(color: UIColor(rgbHex: 0x161616)) // Colors.navigationBarBackground + navigationBar.setBackgroundImage(backgroundImage, for: .default) } }