WIP moving to stackview backed header view in conversation view

- iOS10 with large titles doesn't truncate
pull/1/head
Michael Kirk 7 years ago committed by Matthew Chen
parent 3d766e4cf8
commit b1bff71145

@ -195,7 +195,6 @@
34CF078A203E6B78005C4D61 /* end_call_tone_cept.caf in Resources */ = {isa = PBXBuildFile; fileRef = 34CF0786203E6B78005C4D61 /* end_call_tone_cept.caf */; };
34D1F0501F7D45A60066283D /* GifPickerCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34D1F04F1F7D45A60066283D /* GifPickerCell.swift */; };
34D1F0521F7E8EA30066283D /* GiphyDownloader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34D1F0511F7E8EA30066283D /* GiphyDownloader.swift */; };
34D1F0821F8678AA0066283D /* ConversationHeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D1F0661F8678AA0066283D /* ConversationHeaderView.m */; };
34D1F0831F8678AA0066283D /* ConversationInputTextView.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D1F0681F8678AA0066283D /* ConversationInputTextView.m */; };
34D1F0841F8678AA0066283D /* ConversationInputToolbar.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D1F06A1F8678AA0066283D /* ConversationInputToolbar.m */; };
34D1F0861F8678AA0066283D /* ConversationViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D1F06E1F8678AA0066283D /* ConversationViewController.m */; };
@ -384,6 +383,7 @@
45D231771DC7E8F10034FA89 /* SessionResetJob.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45D231761DC7E8F10034FA89 /* SessionResetJob.swift */; };
45D2AC02204885170033C692 /* OWS2FAReminderViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45D2AC01204885170033C692 /* OWS2FAReminderViewController.swift */; };
45D308AD2049A439000189E4 /* PinEntryView.m in Sources */ = {isa = PBXBuildFile; fileRef = 45D308AC2049A439000189E4 /* PinEntryView.m */; };
45DDA6242090CEB500DE97F8 /* ConversationHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45DDA6232090CEB500DE97F8 /* ConversationHeaderView.swift */; };
45DF5DF21DDB843F00C936C7 /* CompareSafetyNumbersActivity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45DF5DF11DDB843F00C936C7 /* CompareSafetyNumbersActivity.swift */; };
45E5A6991F61E6DE001E4A8A /* MarqueeLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45E5A6981F61E6DD001E4A8A /* MarqueeLabel.swift */; };
45E7A6A81E71CA7E00D44FB5 /* DisplayableTextFilterTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45E7A6A61E71CA7E00D44FB5 /* DisplayableTextFilterTest.swift */; };
@ -811,8 +811,6 @@
34CF0786203E6B78005C4D61 /* end_call_tone_cept.caf */ = {isa = PBXFileReference; lastKnownFileType = file; name = end_call_tone_cept.caf; path = Signal/AudioFiles/end_call_tone_cept.caf; sourceTree = SOURCE_ROOT; };
34D1F04F1F7D45A60066283D /* GifPickerCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GifPickerCell.swift; sourceTree = "<group>"; };
34D1F0511F7E8EA30066283D /* GiphyDownloader.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GiphyDownloader.swift; sourceTree = "<group>"; };
34D1F0651F8678AA0066283D /* ConversationHeaderView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ConversationHeaderView.h; sourceTree = "<group>"; };
34D1F0661F8678AA0066283D /* ConversationHeaderView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ConversationHeaderView.m; sourceTree = "<group>"; };
34D1F0671F8678AA0066283D /* ConversationInputTextView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ConversationInputTextView.h; sourceTree = "<group>"; };
34D1F0681F8678AA0066283D /* ConversationInputTextView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ConversationInputTextView.m; sourceTree = "<group>"; };
34D1F0691F8678AA0066283D /* ConversationInputToolbar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ConversationInputToolbar.h; sourceTree = "<group>"; };
@ -1023,6 +1021,7 @@
45D2AC01204885170033C692 /* OWS2FAReminderViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OWS2FAReminderViewController.swift; sourceTree = "<group>"; };
45D308AB2049A439000189E4 /* PinEntryView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PinEntryView.h; sourceTree = "<group>"; };
45D308AC2049A439000189E4 /* PinEntryView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PinEntryView.m; sourceTree = "<group>"; };
45DDA6232090CEB500DE97F8 /* ConversationHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConversationHeaderView.swift; sourceTree = "<group>"; };
45DF5DF11DDB843F00C936C7 /* CompareSafetyNumbersActivity.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CompareSafetyNumbersActivity.swift; sourceTree = "<group>"; };
45E282DE1D08E67800ADD4C8 /* gl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = gl; path = translations/gl.lproj/Localizable.strings; sourceTree = "<group>"; };
45E282DF1D08E6CC00ADD4C8 /* id */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = id; path = translations/id.lproj/Localizable.strings; sourceTree = "<group>"; };
@ -1472,8 +1471,6 @@
34D1F0951F867BFC0066283D /* Cells */,
34D1F0B21F86D31D0066283D /* ConversationCollectionView.h */,
34D1F0B31F86D31D0066283D /* ConversationCollectionView.m */,
34D1F0651F8678AA0066283D /* ConversationHeaderView.h */,
34D1F0661F8678AA0066283D /* ConversationHeaderView.m */,
34D1F0671F8678AA0066283D /* ConversationInputTextView.h */,
34D1F0681F8678AA0066283D /* ConversationInputTextView.m */,
34D1F0691F8678AA0066283D /* ConversationInputToolbar.h */,
@ -1486,6 +1483,7 @@
34D1F0701F8678AA0066283D /* ConversationViewItem.m */,
34D1F0711F8678AA0066283D /* ConversationViewLayout.h */,
34D1F0721F8678AA0066283D /* ConversationViewLayout.m */,
45DDA6232090CEB500DE97F8 /* ConversationHeaderView.swift */,
);
path = ConversationView;
sourceTree = "<group>";
@ -3140,7 +3138,6 @@
B6DA6B071B8A2F9A00CA6F98 /* AppStoreRating.m in Sources */,
451A13B11E13DED2000A50FD /* CallNotificationsAdapter.swift in Sources */,
450DF2091E0DD2C6003D14BE /* UserNotificationsAdaptee.swift in Sources */,
34D1F0821F8678AA0066283D /* ConversationHeaderView.m in Sources */,
34D1F0AB1F867BFC0066283D /* OWSContactOffersCell.m in Sources */,
340FC8C7204DE64D007AEB0F /* OWSBackupAPI.swift in Sources */,
343A65981FC4CFE7000477A1 /* ConversationScrollButton.m in Sources */,
@ -3248,6 +3245,7 @@
45BB93381E688E14001E3939 /* UIDevice+featureSupport.swift in Sources */,
34277A5E20751BDC006049F2 /* OWSQuotedMessageView.m in Sources */,
458DE9D61DEE3FD00071BB03 /* PeerConnectionClient.swift in Sources */,
45DDA6242090CEB500DE97F8 /* ConversationHeaderView.swift in Sources */,
45F32C242057297A00A300D5 /* MessageDetailViewController.swift in Sources */,
34D1F0841F8678AA0066283D /* ConversationInputToolbar.m in Sources */,
457F671B20746193000EABCD /* QuotedReplyPreview.swift in Sources */,

@ -7,7 +7,6 @@
// Separate iOS Frameworks from other imports.
#import "AppSettingsViewController.h"
#import "ConversationHeaderView.h"
#import "ConversationViewItem.h"
#import "DateUtil.h"
#import "DebugUIPage.h"

@ -1,14 +0,0 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
NS_ASSUME_NONNULL_BEGIN
@interface ConversationHeaderView : UIView
@property (nonatomic) UILabel *titleLabel;
@property (nonatomic) UILabel *subtitleLabel;
@end
NS_ASSUME_NONNULL_END

@ -1,65 +0,0 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import "ConversationHeaderView.h"
#import "UIView+OWS.h"
NS_ASSUME_NONNULL_BEGIN
@implementation ConversationHeaderView
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
self.layoutMargins = UIEdgeInsetsZero;
}
return self;
}
- (void)setBounds:(CGRect)bounds
{
[super setBounds:bounds];
[self layoutSubviews];
}
- (void)setFrame:(CGRect)frame
{
[super setFrame:frame];
[self layoutSubviews];
}
- (void)setCenter:(CGPoint)center
{
[super setCenter:center];
[self layoutSubviews];
}
- (void)layoutSubviews
{
[super layoutSubviews];
// We need to manually resize and position the title views;
// iOS AutoLayout doesn't work inside navigation bar items.
const int kTitleVSpacing = 0.f;
const int kTitleHMargin = 0.f;
CGFloat titleHeight = ceil([self.titleLabel sizeThatFits:CGSizeZero].height);
CGFloat subtitleHeight = ceil([self.subtitleLabel sizeThatFits:CGSizeZero].height);
CGFloat contentHeight = titleHeight + kTitleVSpacing + subtitleHeight;
CGFloat contentWidth = round(self.width - 2 * kTitleHMargin);
CGFloat y = MAX(0, round((self.height - contentHeight) * 0.5f));
self.titleLabel.frame = CGRectMake(kTitleHMargin, y, contentWidth, titleHeight);
self.subtitleLabel.frame
= CGRectMake(kTitleHMargin, ceil(y + titleHeight + kTitleVSpacing), contentWidth, subtitleHeight);
}
@end
NS_ASSUME_NONNULL_END

@ -0,0 +1,125 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
import Foundation
@objc
public protocol ConversationHeaderViewDelegate {
func didTapConversationHeaderView(_ conversationHeaderView: ConversationHeaderView)
}
@objc
public class ConversationHeaderView: UIStackView {
public weak var delegate: ConversationHeaderViewDelegate?
public var attributedTitle: NSAttributedString? {
get {
return self.titleLabel.attributedText
}
set {
self.titleLabel.attributedText = newValue
// self.layoutIfNeeded()
// self.titleLabel.sizeToFit()
// self.sizeToFit()
}
}
public var attributedSubtitle: NSAttributedString? {
get {
return self.subtitleLabel.attributedText
}
set {
self.subtitleLabel.attributedText = newValue
// self.layoutIfNeeded()
// self.subtitleLabel.sizeToFit()
// self.sizeToFit()
}
}
public let titlePrimaryFont: UIFont = UIFont.ows_boldFont(withSize: 20)
public let titleSecondaryFont: UIFont = UIFont.ows_regularFont(withSize: 11)
public let subtitleFont: UIFont = UIFont.ows_regularFont(withSize: 12)
// public let columns: UIStackView
// public let textRows: UIStackView
private let titleLabel: UILabel
private let subtitleLabel: UILabel
override init(frame: CGRect) {
// TODO
// let avatarView: UIImageView = UIImageView()
titleLabel = UILabel()
titleLabel.textColor = .white
titleLabel.lineBreakMode = .byTruncatingTail
titleLabel.font = titlePrimaryFont
titleLabel.setContentHuggingHigh()
subtitleLabel = UILabel()
subtitleLabel.textColor = .white
subtitleLabel.lineBreakMode = .byTruncatingTail
subtitleLabel.font = subtitleFont
subtitleLabel.setContentHuggingHigh()
// textRows = UIStackView(arrangedSubviews: [titleLabel, subtitleLabel])
// textRows.axis = .vertical
// textRows.alignment = .leading
// columns = UIStackView(arrangedSubviews: [avatarView, textRows])
super.init(frame: frame)
// needed for proper layout on iOS10
self.translatesAutoresizingMaskIntoConstraints = false
self.axis = .vertical
self.distribution = .fillProportionally
self.alignment = .leading
self.spacing = 0
self.addArrangedSubview(titleLabel)
self.addArrangedSubview(subtitleLabel)
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(didTapView))
self.addGestureRecognizer(tapGesture)
// titleLabel.setCompressionResistanceHigh()
// subtitleLabel.setCompressionResistanceHigh()
// self.setCompressionResistanceHigh()
// self.setContentHuggingLow()
// self.layoutIfNeeded()
// sizeToFit()
//
// self.translatesAutoresizingMaskIntoConstraints = true
// self.addSubview(columns)
// columns.autoPinEdgesToSuperviewEdges()
// self.addRedBorderRecursively()
}
required public init(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
public override var intrinsicContentSize: CGSize {
// Grow to fill as much of the navbar as possible.
if #available(iOS 11, *) {
return UILayoutFittingExpandedSize
} else {
return super.intrinsicContentSize
}
}
// MARK: Delegate Methods
func didTapView(tapGesture: UITapGestureRecognizer) {
guard tapGesture.state == .recognized else {
return
}
self.delegate?.didTapConversationHeaderView(self)
}
}

@ -8,7 +8,6 @@
#import "BlockListViewController.h"
#import "ContactsViewHelper.h"
#import "ConversationCollectionView.h"
#import "ConversationHeaderView.h"
#import "ConversationInputTextView.h"
#import "ConversationInputToolbar.h"
#import "ConversationScrollButton.h"
@ -124,6 +123,7 @@ typedef enum : NSUInteger {
CNContactViewControllerDelegate,
DisappearingTimerConfigurationViewDelegate,
OWSConversationSettingsViewDelegate,
ConversationHeaderViewDelegate,
ConversationViewLayoutDelegate,
ConversationViewCellDelegate,
ConversationInputTextViewDelegate,
@ -178,8 +178,8 @@ typedef enum : NSUInteger {
@property (nonatomic, nullable) NSTimer *readTimer;
@property (nonatomic) NSCache *cellMediaCache;
@property (nonatomic) ConversationHeaderView *navigationBarTitleView;
@property (nonatomic) UILabel *navigationBarTitleLabel;
@property (nonatomic) ConversationHeaderView *headerView;
//@property (nonatomic) UILabel *navigationBarTitleLabel;
@property (nonatomic) UILabel *navigationBarSubtitleLabel;
@property (nonatomic, nullable) UIView *bannerView;
@property (nonatomic, nullable) OWSDisappearingMessagesConfiguration *disappearingMessagesConfiguration;
@ -350,7 +350,7 @@ typedef enum : NSUInteger {
if (recipientId.length > 0 && [self.thread.recipientIdentifiers containsObject:recipientId]) {
if ([self.thread isKindOfClass:[TSContactThread class]]) {
// update title with profile name
[self setNavigationTitle];
[self updateNavigationTitle];
}
if (self.isGroupConversation) {
@ -489,7 +489,7 @@ typedef enum : NSUInteger {
[self createConversationScrollButtons];
[self createHeaderViews];
[self createBackButton];
// [self createBackButton];
[self addNotificationListeners];
[self loadDraftInCompose];
}
@ -623,7 +623,7 @@ typedef enum : NSUInteger {
[self updateDisappearingMessagesConfiguration];
[self updateBarButtonItems];
[self setNavigationTitle];
[self updateNavigationTitle];
// We want to set the initial scroll state the first time we enter the view.
if (!self.viewHasEverAppeared) {
@ -1082,7 +1082,7 @@ typedef enum : NSUInteger {
#pragma mark - Initiliazers
- (void)setNavigationTitle
- (void)updateNavigationTitle
{
NSAttributedString *name;
if (self.thread.isGroupThread) {
@ -1095,17 +1095,19 @@ typedef enum : NSUInteger {
OWSAssert(self.thread.contactIdentifier);
name = [self.contactsManager
attributedStringForConversationTitleWithPhoneIdentifier:self.thread.contactIdentifier
primaryFont:[self navigationBarTitleLabelFont]
secondaryFont:[UIFont ows_regularFontWithSize:11.f]];
primaryFont:self.headerView.titlePrimaryFont
secondaryFont:self.headerView.titleSecondaryFont];
}
self.title = nil;
if ([name isEqual:self.navigationBarTitleLabel.attributedText]) {
if ([name isEqual:self.headerView.attributedTitle]) {
return;
}
self.navigationBarTitleLabel.attributedText = name;
self.headerView.attributedTitle = name;
// self.navigationBarTitleLabel.attributedText = name;
// TODO layout still necessary with stackview?
// Changing the title requires relayout of the nav bar contents.
[self updateBarButtonItems];
}
@ -1124,34 +1126,35 @@ typedef enum : NSUInteger {
_backButtonUnreadCountLabel.font = [UIFont systemFontOfSize:11];
_backButtonUnreadCountLabel.textAlignment = NSTextAlignmentCenter;
self.navigationBarTitleView = [ConversationHeaderView new];
self.navigationBarTitleView.userInteractionEnabled = YES;
[self.navigationBarTitleView
addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self
action:@selector(navigationTitleTapped:)]];
ConversationHeaderView *headerView = [ConversationHeaderView new];
headerView.delegate = self;
self.headerView = headerView;
#ifdef USE_DEBUG_UI
[self.navigationBarTitleView addGestureRecognizer:[[UILongPressGestureRecognizer alloc]
initWithTarget:self
action:@selector(navigationTitleLongPressed:)]];
[self.headerView addGestureRecognizer:[[UILongPressGestureRecognizer alloc]
initWithTarget:self
action:@selector(navigationTitleLongPressed:)]];
#endif
self.navigationBarTitleLabel = [UILabel new];
self.navigationBarTitleView.titleLabel = self.navigationBarTitleLabel;
self.navigationBarTitleLabel.textColor = [UIColor whiteColor];
self.navigationBarTitleLabel.font = [self navigationBarTitleLabelFont];
self.navigationBarTitleLabel.lineBreakMode = NSLineBreakByTruncatingTail;
[self.navigationBarTitleView addSubview:self.navigationBarTitleLabel];
// self.navigationBarTitleLabel = [UILabel new];
// self.navigationBarTitleView.titleLabel = self.navigationBarTitleLabel;
// self.navigationBarTitleLabel.textColor = [UIColor whiteColor];
// self.navigationBarTitleLabel.font = [self navigationBarTitleLabelFont];
// self.navigationBarTitleLabel.lineBreakMode = NSLineBreakByTruncatingTail;
// [self.navigationBarTitleView addSubview:self.navigationBarTitleLabel];
self.navigationBarSubtitleLabel = [UILabel new];
self.navigationBarTitleView.subtitleLabel = self.navigationBarSubtitleLabel;
// self.navigationBarSubtitleLabel = [UILabel new];
// self.navigationBarTitleView.subtitleLabel = self.navigationBarSubtitleLabel;
[self updateNavigationBarSubtitleLabel];
[self.navigationBarTitleView addSubview:self.navigationBarSubtitleLabel];
// [self.navigationBarTitleView addSubview:self.navigationBarSubtitleLabel];
}
- (UIFont *)navigationBarTitleLabelFont
{
return [UIFont ows_boldFontWithSize:20.f];
}
//- (UIFont *)navigationBarTitleLabelFont
//{
// return [UIFont ows_boldFontWithSize:20.f];
//}
- (CGFloat)unreadCountViewDiameter
{
@ -1190,45 +1193,36 @@ typedef enum : NSUInteger {
- (void)updateBarButtonItems
{
// We want to leave space for the "back" button, the "timer" button, and the "call"
// button, and all of the whitespace around these views. There
// isn't a convenient way to calculate these in a navigation bar, so we just leave
// a constant amount of space which will be safe unless Apple makes radical changes
// to the appearance of the navigation bar.
int rightBarButtonItemCount = 0;
if ([self canCall]) {
rightBarButtonItemCount++;
}
if (self.disappearingMessagesConfiguration.isEnabled) {
rightBarButtonItemCount++;
}
CGFloat barButtonSize = 0;
switch (rightBarButtonItemCount) {
case 0:
barButtonSize = 70;
break;
case 1:
barButtonSize = 105;
break;
default:
OWSFail(@"%@ Unexpected number of right navbar items.", self.logTag);
// In production, fall through to the largest defined case.
case 2:
barButtonSize = 150;
break;
}
CGSize screenSize = [UIScreen mainScreen].bounds.size;
CGFloat screenWidth = MIN(screenSize.width, screenSize.height);
if (self.navigationItem.titleView != self.navigationBarTitleView) {
if (self.navigationItem.titleView == nil) {
// Request "full width" title; the navigation bar will truncate this
// to fit between the left and right buttons.
self.navigationBarTitleView.frame = CGRectMake(0, 0, screenWidth, 44);
self.navigationItem.titleView = self.navigationBarTitleView;
// self.navigationBarTitleView.frame = CGRectMake(0, 0, screenWidth, 44);
DDLogDebug(@"%@ assigning titleView", self.logTag);
UILabel *label1 = [UILabel new];
label1.text = @"title";
label1.textColor = UIColor.whiteColor;
label1.font = [UIFont ows_regularFontWithSize:17];
UILabel *label2 = [UILabel new];
label2.text = @"subtitle";
label2.textColor = UIColor.whiteColor;
label2.font = [UIFont ows_regularFontWithSize:12];
UIStackView *stackView = [[UIStackView alloc] initWithArrangedSubviews:@[ label1, label2 ]];
stackView.axis = UILayoutConstraintAxisVertical;
[label1 setCompressionResistanceHigh];
[label2 setCompressionResistanceHigh];
[stackView setCompressionResistanceHigh];
// [stackView autoSetDimensionsToSize:CGSizeMake(100, 40)];
// self.navigationItem.titleView = stackView;
self.navigationItem.titleView = self.headerView;
} else {
// Don't reset the frame of the navigationBarTitleView every time
// this method is called or we'll gave bad frames where it will appear
// in the wrong position.
[self.navigationBarTitleView layoutSubviews];
// [self.navigationBarTitleView layoutSubviews];
}
if (self.userLeftGroup) {
@ -1326,7 +1320,7 @@ typedef enum : NSUInteger {
appendAttributedString:[[NSAttributedString alloc]
initWithString:NSLocalizedString(@"GROUP_YOU_LEFT", @"")
attributes:@{
NSFontAttributeName : [UIFont ows_regularFontWithSize:9.f],
NSFontAttributeName : self.headerView.subtitleFont,
NSForegroundColorAttributeName : [UIColor colorWithWhite:0.9f alpha:1.f],
}]];
} else {
@ -1336,13 +1330,12 @@ typedef enum : NSUInteger {
@"The subtitle for the messages view title indicates that the "
@"title can be tapped to access settings for this conversation.")
attributes:@{
NSFontAttributeName : [UIFont ows_regularFontWithSize:9.f],
NSFontAttributeName : self.headerView.subtitleFont,
NSForegroundColorAttributeName : [UIColor colorWithWhite:0.9f alpha:1.f],
}]];
}
self.navigationBarSubtitleLabel.attributedText = subtitleText;
[self.navigationBarSubtitleLabel sizeToFit];
self.headerView.attributedSubtitle = subtitleText;
}
@ -3080,7 +3073,7 @@ typedef enum : NSUInteger {
}
}
}];
[self setNavigationTitle];
[self updateNavigationTitle];
}
[self updateDisappearingMessagesConfiguration];
@ -3845,13 +3838,11 @@ typedef enum : NSUInteger {
return @[];
}
#pragma mark - Event Handling
#pragma mark - ConversationHeaderViewDelegate
- (void)navigationTitleTapped:(UIGestureRecognizer *)gestureRecognizer
- (void)didTapConversationHeaderView:(ConversationHeaderView *)conversationHeaderView
{
if (gestureRecognizer.state == UIGestureRecognizerStateRecognized) {
[self showConversationSettings];
}
[self showConversationSettings];
}
#ifdef USE_DEBUG_UI

@ -273,11 +273,14 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
self.title = NSLocalizedString(@"HOME_VIEW_TITLE_ARCHIVE", @"Title for the home view's 'archive' mode.");
break;
}
// We don't show any text for the back button, so there's no need to localize it. But because we left align the
// conversation title view, we having a title which is just spaces, we can add tappable padding to the back button.
// Admittedly this is kind of a hack and not super fine grained, but it's simple and results in the interactive pop
// gesture animating our title view properly vs. creating our own back button bar item and adjusting padding that
// way.
self.navigationItem.backBarButtonItem =
[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"BACK_BUTTON", @"button text for back button")
style:UIBarButtonItemStylePlain
target:nil
action:nil];
[[UIBarButtonItem alloc] initWithTitle:@" " style:UIBarButtonItemStylePlain target:nil action:nil];
if ([self.traitCollection respondsToSelector:@selector(forceTouchCapability)]
&& (self.traitCollection.forceTouchCapability == UIForceTouchCapabilityAvailable)) {

@ -79,15 +79,28 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
let kSpacingBetweenItems: CGFloat = 20
let headerView = UIStackView()
headerView.axis = .vertical
headerView.alignment = .center
self.headerView = headerView
super.init(transitionStyle: .scroll,
navigationOrientation: .horizontal,
options: [UIPageViewControllerOptionInterPageSpacingKey: kSpacingBetweenItems])
// needed for proper layout on iOS10
headerView.translatesAutoresizingMaskIntoConstraints = false
headerView.axis = .vertical
headerView.alignment = .center
headerView.addArrangedSubview(headerNameLabel)
headerView.addArrangedSubview(headerDateLabel)
Logger.debug("\(self.logTag) in \(#function) 1 headerView.frame: \(headerView.frame)")
// headerView.layoutIfNeeded()
Logger.debug("\(self.logTag) in \(#function) 2 headerView.frame: \(headerView.frame)")
// headerView.sizeToFit()
Logger.debug("\(self.logTag) in \(#function) 3 headerView.frame: \(headerView.frame)")
self.dataSource = self
self.delegate = self
@ -123,8 +136,6 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
let backButton = OWSViewController.createOWSBackButton(withTarget: self, selector: #selector(didPressDismissButton))
self.navigationItem.leftBarButtonItem = backButton
headerView.addArrangedSubview(headerNameLabel)
headerView.addArrangedSubview(headerDateLabel)
self.navigationItem.titleView = headerView
self.updateTitle()

Loading…
Cancel
Save