From 31782af2f1594bc428ea2823c1310b85da39b457 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Sun, 25 Nov 2018 17:49:30 -0600 Subject: [PATCH] dark theme section headers in tile gallery --- .../MediaTileViewController.swift | 49 ++++++++++++------- .../AttachmentApprovalViewController.swift | 14 ------ SignalMessaging/appearance/Theme.h | 5 ++ SignalMessaging/appearance/Theme.m | 21 ++++++-- 4 files changed, 53 insertions(+), 36 deletions(-) diff --git a/Signal/src/ViewControllers/MediaTileViewController.swift b/Signal/src/ViewControllers/MediaTileViewController.swift index 2f9acb261..b9073a6fa 100644 --- a/Signal/src/ViewControllers/MediaTileViewController.swift +++ b/Signal/src/ViewControllers/MediaTileViewController.swift @@ -54,6 +54,32 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryDa notImplemented() } + // MARK: Subviews + + lazy var footerBar: UIToolbar = { + let footerBar = UIToolbar() + let footerItems = [ + UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil), + deleteButton, + UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil) + ] + footerBar.setItems(footerItems, animated: false) + + footerBar.barTintColor = Theme.darkThemeNavbarBackgroundColor + footerBar.tintColor = Theme.darkThemeNavbarIconColor + + return footerBar + }() + + lazy var deleteButton: UIBarButtonItem = { + let deleteButton = UIBarButtonItem(barButtonSystemItem: .trash, + target: self, + action: #selector(didPressDelete)) + deleteButton.tintColor = Theme.darkThemeNavbarIconColor + + return deleteButton + }() + // MARK: View Lifecycle Overrides override public func viewDidLoad() { @@ -77,19 +103,6 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryDa // feels a bit weird to have content smashed all the way to the bottom edge. collectionView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: 20, right: 0) - let footerBar = UIToolbar() - self.footerBar = footerBar - let deleteButton = UIBarButtonItem(barButtonSystemItem: .trash, - target: self, - action: #selector(didPressDelete)) - self.deleteButton = deleteButton - let footerItems = [ - UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil), - deleteButton, - UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil) - ] - footerBar.setItems(footerItems, animated: false) - self.view.addSubview(self.footerBar) footerBar.autoPinWidthToSuperview() footerBar.autoSetDimension(.height, toSize: kFooterBarHeight) @@ -592,8 +605,6 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryDa present(actionSheet, animated: true) } - var footerBar: UIToolbar! - var deleteButton: UIBarButtonItem! var footerBarBottomConstraint: NSLayoutConstraint! let kFooterBarHeight: CGFloat = 40 @@ -812,16 +823,16 @@ private class MediaGallerySectionHeader: UICollectionReusableView { override init(frame: CGRect) { label = UILabel() - label.textColor = Theme.primaryColor + label.textColor = Theme.darkThemePrimaryColor - let blurEffect = Theme.barBlurEffect + let blurEffect = Theme.darkThemeBarBlurEffect let blurEffectView = UIVisualEffectView(effect: blurEffect) blurEffectView.autoresizingMask = [.flexibleWidth, .flexibleHeight] super.init(frame: frame) - self.backgroundColor = Theme.navbarBackgroundColor.withAlphaComponent(OWSNavigationBar.backgroundBlurMutingFactor) + self.backgroundColor = Theme.darkThemeNavbarBackgroundColor.withAlphaComponent(OWSNavigationBar.backgroundBlurMutingFactor) self.addSubview(blurEffectView) self.addSubview(label) @@ -859,7 +870,7 @@ private class MediaGalleryStaticHeader: UICollectionViewCell { addSubview(label) - label.textColor = Theme.primaryColor + label.textColor = Theme.darkThemePrimaryColor label.textAlignment = .center label.numberOfLines = 0 label.autoPinEdgesToSuperviewMargins() diff --git a/SignalMessaging/ViewControllers/AttachmentApprovalViewController.swift b/SignalMessaging/ViewControllers/AttachmentApprovalViewController.swift index f802ea5ce..e12babbc8 100644 --- a/SignalMessaging/ViewControllers/AttachmentApprovalViewController.swift +++ b/SignalMessaging/ViewControllers/AttachmentApprovalViewController.swift @@ -144,20 +144,6 @@ public class AttachmentApprovalViewController: UIPageViewController, UIPageViewC pagerScrollView.isScrollEnabled = attachmentItems.count > 1 } - private func makeClearToolbar() -> UIToolbar { - let toolbar = UIToolbar() - - toolbar.backgroundColor = UIColor.clear - - // Making a toolbar transparent requires setting an empty uiimage - toolbar.setBackgroundImage(UIImage(), forToolbarPosition: .any, barMetrics: .default) - - // hide 1px top-border - toolbar.clipsToBounds = true - - return toolbar - } - // MARK: UIPageViewControllerDelegate public func pageViewController(_ pageViewController: UIPageViewController, willTransitionTo pendingViewControllers: [UIViewController]) { diff --git a/SignalMessaging/appearance/Theme.h b/SignalMessaging/appearance/Theme.h index 580825752..61264d078 100644 --- a/SignalMessaging/appearance/Theme.h +++ b/SignalMessaging/appearance/Theme.h @@ -39,8 +39,13 @@ extern NSString *const ThemeDidChangeNotification; @property (class, readonly, nonatomic) UIColor *cellSelectedColor; @property (class, readonly, nonatomic) UIColor *cellSeparatorColor; +// In some contexts, e.g. media viewing/sending, we always use "dark theme" UI regardless of the +// users chosen theme. +@property (class, readonly, nonatomic) UIColor *darkThemeNavbarIconColor; +@property (class, readonly, nonatomic) UIColor *darkThemeNavbarBackgroundColor; @property (class, readonly, nonatomic) UIColor *darkThemeBackgroundColor; @property (class, readonly, nonatomic) UIColor *darkThemePrimaryColor; +@property (class, readonly, nonatomic) UIBlurEffect *darkThemeBarBlurEffect; #pragma mark - diff --git a/SignalMessaging/appearance/Theme.m b/SignalMessaging/appearance/Theme.m index f9e523c83..3feab3a48 100644 --- a/SignalMessaging/appearance/Theme.m +++ b/SignalMessaging/appearance/Theme.m @@ -90,12 +90,22 @@ NSString *const ThemeKeyThemeEnabled = @"ThemeKeyThemeEnabled"; + (UIColor *)navbarBackgroundColor { - return (Theme.isDarkThemeEnabled ? UIColor.ows_blackColor : UIColor.ows_whiteColor); + return (Theme.isDarkThemeEnabled ? self.darkThemeNavbarBackgroundColor : UIColor.ows_whiteColor); +} + ++ (UIColor *)darkThemeNavbarBackgroundColor +{ + return UIColor.ows_blackColor; } + (UIColor *)navbarIconColor { - return (Theme.isDarkThemeEnabled ? UIColor.ows_gray25Color : UIColor.ows_gray60Color); + return (Theme.isDarkThemeEnabled ? self.darkThemeNavbarIconColor : UIColor.ows_gray60Color); +} + ++ (UIColor *)darkThemeNavbarIconColor; +{ + return UIColor.ows_gray25Color; } + (UIColor *)navbarTitleColor @@ -135,10 +145,15 @@ NSString *const ThemeKeyThemeEnabled = @"ThemeKeyThemeEnabled"; + (UIBlurEffect *)barBlurEffect { - return Theme.isDarkThemeEnabled ? [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark] + return Theme.isDarkThemeEnabled ? self.darkThemeBarBlurEffect : [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]; } ++ (UIBlurEffect *)darkThemeBarBlurEffect +{ + return [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark]; +} + + (UIKeyboardAppearance)keyboardAppearance { return Theme.isDarkThemeEnabled ? UIKeyboardAppearanceDark : UIKeyboardAppearanceDefault;