Design polish for the "profile pic in conversation view" and "archived conversations in home view."

pull/1/head
Matthew Chen 8 years ago
parent b702695793
commit 45be54f7ac

@ -74,7 +74,7 @@ public class ConversationHeaderView: UIStackView {
textRows.distribution = .fillProportionally textRows.distribution = .fillProportionally
textRows.spacing = 0 textRows.spacing = 0
textRows.layoutMargins = UIEdgeInsets(top: 0, left: 4, bottom: 0, right: 4) textRows.layoutMargins = UIEdgeInsets(top: 0, left: 8, bottom: 0, right: 8)
textRows.isLayoutMarginsRelativeArrangement = true textRows.isLayoutMarginsRelativeArrangement = true
// low content hugging so that the text rows push container to the right bar button item(s) // low content hugging so that the text rows push container to the right bar button item(s)

@ -274,6 +274,18 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
break; break;
} }
[self applyDefaultBackButton];
if ([self.traitCollection respondsToSelector:@selector(forceTouchCapability)]
&& (self.traitCollection.forceTouchCapability == UIForceTouchCapabilityAvailable)) {
[self registerForPreviewingWithDelegate:self sourceView:self.tableView];
}
[self updateBarButtonItems];
}
- (void)applyDefaultBackButton
{
// We don't show any text for the back button, so there's no need to localize it. But because we left align the // 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 add a little tappable padding after the back button, by having a title of spaces. // conversation title view, we add a little tappable padding after the back button, by having a title of spaces.
// Admittedly this is kind of a hack and not super fine grained, but it's simple and results in the interactive pop // Admittedly this is kind of a hack and not super fine grained, but it's simple and results in the interactive pop
@ -284,13 +296,15 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
self.navigationItem.backBarButtonItem = self.navigationItem.backBarButtonItem =
[[UIBarButtonItem alloc] initWithTitle:paddingString style:UIBarButtonItemStylePlain target:nil action:nil]; [[UIBarButtonItem alloc] initWithTitle:paddingString style:UIBarButtonItemStylePlain target:nil action:nil];
}
if ([self.traitCollection respondsToSelector:@selector(forceTouchCapability)] - (void)applyArchiveBackButton
&& (self.traitCollection.forceTouchCapability == UIForceTouchCapabilityAvailable)) { {
[self registerForPreviewingWithDelegate:self sourceView:self.tableView]; self.navigationItem.backBarButtonItem =
} [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"BACK_BUTTON", @"button text for back button")
style:UIBarButtonItemStylePlain
[self updateBarButtonItems]; target:nil
action:nil];
} }
- (void)viewDidAppear:(BOOL)animated - (void)viewDidAppear:(BOOL)animated
@ -298,6 +312,7 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
[super viewDidAppear:animated]; [super viewDidAppear:animated];
[self displayAnyUnseenUpgradeExperience]; [self displayAnyUnseenUpgradeExperience];
[self applyDefaultBackButton];
} }
- (void)updateBarButtonItems - (void)updateBarButtonItems
@ -408,6 +423,7 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
- (void)viewWillAppear:(BOOL)animated - (void)viewWillAppear:(BOOL)animated
{ {
[super viewWillAppear:animated]; [super viewWillAppear:animated];
__block BOOL hasAnyMessages; __block BOOL hasAnyMessages;
[self.uiDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction * _Nonnull transaction) { [self.uiDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction * _Nonnull transaction) {
hasAnyMessages = [self hasAnyMessagesWithTransaction:transaction]; hasAnyMessages = [self hasAnyMessagesWithTransaction:transaction];
@ -442,6 +458,7 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
} }
[self checkIfEmptyView]; [self checkIfEmptyView];
[self applyDefaultBackButton];
} }
- (void)viewWillDisappear:(BOOL)animated - (void)viewWillDisappear:(BOOL)animated
@ -985,6 +1002,10 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
{ {
OWSAssert(self.homeViewMode == HomeViewMode_Inbox); OWSAssert(self.homeViewMode == HomeViewMode_Inbox);
// When showing archived conversations, we want to use a conventional "back" button
// to return to the "inbox" home view.
[self applyArchiveBackButton];
// Push a separate instance of this view using "archive" mode. // Push a separate instance of this view using "archive" mode.
HomeViewController *homeView = [HomeViewController new]; HomeViewController *homeView = [HomeViewController new];
homeView.homeViewMode = HomeViewMode_Archive; homeView.homeViewMode = HomeViewMode_Archive;

@ -79,17 +79,29 @@ class ReminderView: UIView {
self.addSubview(container) self.addSubview(container)
container.autoPinWidthToSuperview(withMargin: 16) container.autoPinWidthToSuperview(withMargin: 16)
container.autoPinHeightToSuperview(withMargin: 16) switch (mode) {
case .nag:
container.autoPinHeightToSuperview(withMargin: 16)
case .explanation:
container.autoPinHeightToSuperview(withMargin: 12)
}
// Margin: top and bottom 12 left and right 16.
// Label // Label
label.font = UIFont.ows_regularFont(withSize: 14) switch (mode) {
case .nag:
label.font = UIFont.ows_regularFont(withSize: 14)
case .explanation:
label.font = UIFont.ows_dynamicTypeSubheadline
}
container.addSubview(label) container.addSubview(label)
label.textColor = UIColor.black.withAlphaComponent(0.9)
label.numberOfLines = 0 label.numberOfLines = 0
label.lineBreakMode = .byWordWrapping label.lineBreakMode = .byWordWrapping
label.autoPinEdge(toSuperviewEdge: .top)
label.autoPinLeadingToSuperviewMargin() label.autoPinLeadingToSuperviewMargin()
label.autoPinEdge(toSuperviewEdge: .top)
label.autoPinEdge(toSuperviewEdge: .bottom) label.autoPinEdge(toSuperviewEdge: .bottom)
label.textColor = UIColor.black.withAlphaComponent(0.9)
guard mode == .nag else { guard mode == .nag else {
label.autoPinTrailingToSuperviewMargin() label.autoPinTrailingToSuperviewMargin()

Loading…
Cancel
Save