mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
61f59067b6
* Add support for contacts with more than one Signal account using ContactAccount class. * Use OWSTableViewController in contact-related views. * Let users add non-contacts to groups. * Improve the "new group" and "edit group" views. * Add utility methods for displaying alerts. * Warn users before discarding unsaved changes in "edit group" view. * Pull out "contact view helper" to de-duplicate common logic among contact-related views. * Pull out "group view helper" to de-duplicate common logic among group-related views. * Pull out new base class for view used to add accounts to groups or the block list. // FREEBIE
64 lines
2.1 KiB
Objective-C
64 lines
2.1 KiB
Objective-C
//
|
|
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
|
//
|
|
|
|
#import "UIViewController+OWS.h"
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
@implementation UIViewController (OWS)
|
|
|
|
- (UIBarButtonItem *)createOWSBackButton
|
|
{
|
|
return [self createOWSBackButtonWithTarget:self selector:@selector(backButtonPressed:)];
|
|
}
|
|
|
|
- (UIBarButtonItem *)createOWSBackButtonWithTarget:(id)target selector:(SEL)selector
|
|
{
|
|
OWSAssert(target);
|
|
OWSAssert(selector);
|
|
|
|
// Nudge closer to the left edge to match default back button item.
|
|
const CGFloat kExtraLeftPadding = -8;
|
|
|
|
// Give some extra hit area to the back button. This is a little smaller
|
|
// than the default back button, but makes sense for our left aligned title
|
|
// view in the MessagesViewController
|
|
const CGFloat kExtraRightPadding = 10;
|
|
|
|
// Extra hit area above/below
|
|
const CGFloat kExtraHeightPadding = 4;
|
|
|
|
// Matching the default backbutton placement is tricky.
|
|
// We can't just adjust the imageEdgeInsets on a UIBarButtonItem directly,
|
|
// so we adjust the imageEdgeInsets on a UIButton, then wrap that
|
|
// in a UIBarButtonItem.
|
|
UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
[backButton addTarget:target action:selector forControlEvents:UIControlEventTouchUpInside];
|
|
|
|
UIImage *backImage = [UIImage imageNamed:@"NavBarBack"];
|
|
OWSAssert(backImage);
|
|
[backButton setImage:backImage forState:UIControlStateNormal];
|
|
|
|
backButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
|
|
|
|
// Default back button is 1.5 pixel lower than our extracted image.
|
|
const CGFloat kTopInsetPadding = 1.5;
|
|
backButton.imageEdgeInsets = UIEdgeInsetsMake(kTopInsetPadding, kExtraLeftPadding, 0, 0);
|
|
|
|
backButton.frame = CGRectMake(0, 0, backImage.size.width + kExtraRightPadding, backImage.size.height + kExtraHeightPadding);
|
|
|
|
UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
|
|
|
|
return backItem;
|
|
}
|
|
|
|
#pragma mark - Event Handling
|
|
|
|
- (void)backButtonPressed:(id)sender {
|
|
[self.navigationController popViewControllerAnimated:YES];
|
|
}
|
|
|
|
@end
|
|
|
|
NS_ASSUME_NONNULL_END
|