Adapt conversation settings view to RTL.

// FREEBIE
This commit is contained in:
Matthew Chen 2017-07-11 12:17:28 -04:00
parent 656cc47de5
commit 693e74e868
9 changed files with 71 additions and 28 deletions

View File

@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "NavBarBackWhiteRTL@1x.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "NavBarBackWhiteRTL@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "NavBarBackWhiteRTL@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -1079,6 +1079,7 @@ typedef enum : NSUInteger {
// This method gets called multiple times, so it's important we re-layout the unread badge
// with respect to the new backItem.
[backItem.customView addSubview:_backButtonUnreadCountView];
// TODO:
[_backButtonUnreadCountView autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:-6];
[_backButtonUnreadCountView autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:1];
[_backButtonUnreadCountView autoSetDimension:ALDimensionHeight toSize:unreadCountViewDiameter];
@ -1097,7 +1098,7 @@ typedef enum : NSUInteger {
const CGFloat kTitleVSpacing = 0.f;
if (!self.navigationBarTitleView) {
self.navigationBarTitleView = [UIView new];
self.navigationBarTitleView = [UIView containerView];
[self.navigationBarTitleView
addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self
action:@selector(navigationTitleTapped:)]];
@ -1161,7 +1162,9 @@ typedef enum : NSUInteger {
+ kTitleVSpacing);
self.navigationBarTitleLabel.frame
= CGRectMake(0, 0, titleViewWidth, self.navigationBarTitleLabel.frame.size.height);
self.navigationBarSubtitleLabel.frame = CGRectMake(0,
self.navigationBarSubtitleLabel.frame = CGRectMake((self.view.isRTL ? self.navigationBarTitleView.frame.size.width
- self.navigationBarSubtitleLabel.frame.size.width
: 0),
self.navigationBarTitleView.frame.size.height - self.navigationBarSubtitleLabel.frame.size.height,
titleViewWidth,
self.navigationBarSubtitleLabel.frame.size.height);

View File

@ -293,18 +293,20 @@ NS_ASSUME_NONNULL_BEGIN
[mainSection
addItem:[OWSTableItem itemWithCustomCellBlock:^{
UITableViewCell *cell = [UITableViewCell new];
cell.preservesSuperviewLayoutMargins = YES;
cell.contentView.preservesSuperviewLayoutMargins = YES;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
UIView *topView = [UIView new];
UIView *topView = [UIView containerView];
[cell.contentView addSubview:topView];
[topView autoPinWidthToSuperview];
[topView autoPinLeadingAndTrailingToSuperview];
[topView autoPinEdgeToSuperviewEdge:ALEdgeTop];
[topView autoSetDimension:ALDimensionHeight toSize:kOWSTable_DefaultCellHeight];
UIImageView *iconView = [self viewForIconWithName:@"table_ic_hourglass"];
[topView addSubview:iconView];
[iconView autoVCenterInSuperview];
[iconView autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:16.f];
[iconView autoPinLeadingToSuperView];
UILabel *rowLabel = [UILabel new];
rowLabel.text = NSLocalizedString(@"DISAPPEARING_MESSAGES", @"table cell label in conversation settings");
@ -313,7 +315,7 @@ NS_ASSUME_NONNULL_BEGIN
rowLabel.lineBreakMode = NSLineBreakByTruncatingTail;
[topView addSubview:rowLabel];
[rowLabel autoVCenterInSuperview];
[rowLabel autoPinEdge:ALEdgeLeft toEdge:ALEdgeRight ofView:iconView withOffset:12.f];
[rowLabel autoPinLeadingToTrailingOfView:iconView margin:weakSelf.iconSpacing];
UISwitch *switchView = [UISwitch new];
switchView.on = self.disappearingMessagesConfiguration.isEnabled;
@ -322,7 +324,8 @@ NS_ASSUME_NONNULL_BEGIN
forControlEvents:UIControlEventValueChanged];
[topView addSubview:switchView];
[switchView autoVCenterInSuperview];
[switchView autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:16.f];
[switchView autoPinLeadingToTrailingOfView:rowLabel margin:weakSelf.iconSpacing];
[switchView autoPinTrailingToSuperView];
UILabel *subtitleLabel = [UILabel new];
subtitleLabel.text
@ -333,8 +336,8 @@ NS_ASSUME_NONNULL_BEGIN
subtitleLabel.lineBreakMode = NSLineBreakByWordWrapping;
[cell.contentView addSubview:subtitleLabel];
[subtitleLabel autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:topView];
[subtitleLabel autoPinEdge:ALEdgeLeft toEdge:ALEdgeLeft ofView:rowLabel];
[subtitleLabel autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:16.f];
[subtitleLabel autoPinEdge:ALEdgeLeading toEdge:ALEdgeLeading ofView:rowLabel];
[subtitleLabel autoPinTrailingToSuperView];
return cell;
}
@ -347,18 +350,20 @@ NS_ASSUME_NONNULL_BEGIN
addItem:[OWSTableItem
itemWithCustomCellBlock:^{
UITableViewCell *cell = [UITableViewCell new];
cell.preservesSuperviewLayoutMargins = YES;
cell.contentView.preservesSuperviewLayoutMargins = YES;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
UIView *topView = [UIView new];
UIView *topView = [UIView containerView];
[cell.contentView addSubview:topView];
[topView autoPinWidthToSuperview];
[topView autoPinLeadingAndTrailingToSuperview];
[topView autoPinEdgeToSuperviewEdge:ALEdgeTop];
[topView autoSetDimension:ALDimensionHeight toSize:kOWSTable_DefaultCellHeight];
UIImageView *iconView = [self viewForIconWithName:@"table_ic_hourglass"];
[topView addSubview:iconView];
[iconView autoVCenterInSuperview];
[iconView autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:16.f];
[iconView autoPinLeadingToSuperView];
UILabel *rowLabel = self.disappearingMessagesDurationLabel;
[self updateDisappearingMessagesDurationLabel];
@ -367,7 +372,7 @@ NS_ASSUME_NONNULL_BEGIN
rowLabel.lineBreakMode = NSLineBreakByTruncatingTail;
[topView addSubview:rowLabel];
[rowLabel autoVCenterInSuperview];
[rowLabel autoPinEdge:ALEdgeLeft toEdge:ALEdgeRight ofView:iconView withOffset:12.f];
[rowLabel autoPinLeadingToTrailingOfView:iconView margin:weakSelf.iconSpacing];
UISlider *slider = [UISlider new];
slider.maximumValue = (float)(self.disappearingMessagesDurations.count - 1);
@ -379,8 +384,8 @@ NS_ASSUME_NONNULL_BEGIN
forControlEvents:UIControlEventValueChanged];
[cell.contentView addSubview:slider];
[slider autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:topView];
[slider autoPinEdge:ALEdgeLeft toEdge:ALEdgeLeft ofView:rowLabel];
[slider autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:16.f];
[slider autoPinEdge:ALEdgeLeading toEdge:ALEdgeLeading ofView:rowLabel];
[slider autoPinTrailingToSuperView];
return cell;
}
@ -431,12 +436,14 @@ NS_ASSUME_NONNULL_BEGIN
OWSTableSection *muteSection = [OWSTableSection new];
[muteSection addItem:[OWSTableItem itemWithCustomCellBlock:^{
UITableViewCell *cell = [UITableViewCell new];
cell.preservesSuperviewLayoutMargins = YES;
cell.contentView.preservesSuperviewLayoutMargins = YES;
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
UIImageView *iconView = [self viewForIconWithName:@"table_ic_mute_thread"];
[cell.contentView addSubview:iconView];
[iconView autoVCenterInSuperview];
[iconView autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:16.f];
[iconView autoPinLeadingToSuperView];
UILabel *rowLabel = [UILabel new];
rowLabel.text = NSLocalizedString(
@ -446,7 +453,7 @@ NS_ASSUME_NONNULL_BEGIN
rowLabel.lineBreakMode = NSLineBreakByTruncatingTail;
[cell.contentView addSubview:rowLabel];
[rowLabel autoVCenterInSuperview];
[rowLabel autoPinEdge:ALEdgeLeft toEdge:ALEdgeRight ofView:iconView withOffset:12.f];
[rowLabel autoPinLeadingToTrailingOfView:iconView margin:weakSelf.iconSpacing];
NSString *muteStatus = NSLocalizedString(
@"CONVERSATION_SETTINGS_MUTE_NOT_MUTED", @"Indicates that the current thread is not muted.");
@ -481,7 +488,8 @@ NS_ASSUME_NONNULL_BEGIN
statusLabel.text = muteStatus;
[cell.contentView addSubview:statusLabel];
[statusLabel autoVCenterInSuperview];
[statusLabel autoPinEdgeToSuperviewEdge:ALEdgeRight];
// [statusLabel autoPinLeadingToTrailingOfView:rowLabel margin:weakSelf.iconSpacing];
[statusLabel autoPinTrailingToSuperView];
return cell;
}
customRowHeight:45.f
@ -523,18 +531,25 @@ NS_ASSUME_NONNULL_BEGIN
[self.tableView reloadData];
}
- (CGFloat)iconSpacing
{
return 12.f;
}
- (UITableViewCell *)disclosureCellWithName:(NSString *)name iconName:(NSString *)iconName
{
OWSAssert(name.length > 0);
OWSAssert(iconName.length > 0);
UITableViewCell *cell = [UITableViewCell new];
cell.preservesSuperviewLayoutMargins = YES;
cell.contentView.preservesSuperviewLayoutMargins = YES;
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
UIImageView *iconView = [self viewForIconWithName:iconName];
[cell.contentView addSubview:iconView];
[iconView autoVCenterInSuperview];
[iconView autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:16.f];
[iconView autoPinLeadingToSuperView];
UILabel *rowLabel = [UILabel new];
rowLabel.text = name;
@ -543,7 +558,8 @@ NS_ASSUME_NONNULL_BEGIN
rowLabel.lineBreakMode = NSLineBreakByTruncatingTail;
[cell.contentView addSubview:rowLabel];
[rowLabel autoVCenterInSuperview];
[rowLabel autoPinEdge:ALEdgeLeft toEdge:ALEdgeRight ofView:iconView withOffset:12.f];
[rowLabel autoPinLeadingToTrailingOfView:iconView margin:self.iconSpacing];
[rowLabel autoPinTrailingToSuperView];
return cell;
}

View File

@ -7,7 +7,6 @@
#import "ContactTableViewCell.h"
#import "ContactsViewHelper.h"
#import "Environment.h"
#import "InboxTableViewCell.h"
#import "OWSContactsManager.h"
#import "OWSContactsSearcher.h"
#import "OWSTableViewController.h"

View File

@ -3,9 +3,8 @@
//
#import <UIKit/UIKit.h>
#import "InboxTableViewCell.h"
#import "Contact.h"
#import "TSGroupModel.h"
@class TSThread;
@interface SignalsViewController : UIViewController

View File

@ -2,6 +2,7 @@
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import "UIView+OWS.h"
#import "UIViewController+OWS.h"
NS_ASSUME_NONNULL_BEGIN
@ -18,13 +19,16 @@ NS_ASSUME_NONNULL_BEGIN
OWSAssert(target);
OWSAssert(selector);
UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
BOOL isRTL = [backButton isRTL];
// Nudge closer to the left edge to match default back button item.
const CGFloat kExtraLeftPadding = -8;
const CGFloat kExtraLeftPadding = isRTL ? +0 : -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;
const CGFloat kExtraRightPadding = isRTL ? -0 : +10;
// Extra hit area above/below
const CGFloat kExtraHeightPadding = 4;
@ -33,10 +37,9 @@ NS_ASSUME_NONNULL_BEGIN
// 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"];
UIImage *backImage = [UIImage imageNamed:(isRTL ? @"NavBarBackRTL" : @"NavBarBack")];
OWSAssert(backImage);
[backButton setImage:backImage forState:UIControlStateNormal];