From 96fd5e11e5201dad9adc04eff12ef12477fb5eff Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Tue, 11 Jul 2017 13:32:03 -0400 Subject: [PATCH] Adapt more UI elements to RTL. // FREEBIE --- Signal/src/UIView+OWS.h | 2 +- Signal/src/UIView+OWS.m | 10 ++++++---- .../ViewControllers/CodeVerificationViewController.m | 10 +++++----- .../src/ViewControllers/RegistrationViewController.m | 2 +- .../ViewControllers/SendExternalFileViewController.m | 6 +++--- .../src/ViewControllers/SettingsTableViewController.m | 8 ++++---- 6 files changed, 20 insertions(+), 18 deletions(-) diff --git a/Signal/src/UIView+OWS.h b/Signal/src/UIView+OWS.h index 8a13c2b22..c571bc986 100644 --- a/Signal/src/UIView+OWS.h +++ b/Signal/src/UIView+OWS.h @@ -67,7 +67,7 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value); // // NOTE: the margin values are inverted in RTL layouts. - (BOOL)isRTL; -- (NSLayoutConstraint *)autoPinLeadingAndTrailingToSuperview; +- (NSArray *)autoPinLeadingAndTrailingToSuperview; - (NSLayoutConstraint *)autoPinLeadingToSuperView; - (NSLayoutConstraint *)autoPinLeadingToSuperViewWithMargin:(CGFloat)margin; - (NSLayoutConstraint *)autoPinTrailingToSuperView; diff --git a/Signal/src/UIView+OWS.m b/Signal/src/UIView+OWS.m index fded4f690..726c32f25 100644 --- a/Signal/src/UIView+OWS.m +++ b/Signal/src/UIView+OWS.m @@ -35,7 +35,6 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value) { [self autoPinEdge:ALEdgeLeft toEdge:ALEdgeLeft ofView:self.superview withOffset:+margin]; [self autoPinEdge:ALEdgeRight toEdge:ALEdgeRight ofView:self.superview withOffset:-margin]; - // TODO: } - (void)autoPinWidthToSuperview @@ -44,10 +43,13 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value) [self autoPinEdge:ALEdgeRight toEdge:ALEdgeRight ofView:self.superview]; } -- (void)autoPinLeadingAndTrailingToSuperview +- (NSArray *)autoPinLeadingAndTrailingToSuperview { - [self autoPinLeadingToSuperView]; - [self autoPinTrailingToSuperView]; + NSArray *result = @[ + [self autoPinLeadingToSuperView], + [self autoPinTrailingToSuperView], + ]; + return result; } - (void)autoPinHeightToSuperviewWithMargin:(CGFloat)margin diff --git a/Signal/src/ViewControllers/CodeVerificationViewController.m b/Signal/src/ViewControllers/CodeVerificationViewController.m index de51033bc..f98c44c8a 100644 --- a/Signal/src/ViewControllers/CodeVerificationViewController.m +++ b/Signal/src/ViewControllers/CodeVerificationViewController.m @@ -181,8 +181,8 @@ NS_ASSUME_NONNULL_BEGIN [_submitCodeSpinner autoSetDimension:ALDimensionWidth toSize:kSpinnerSize]; [_submitCodeSpinner autoSetDimension:ALDimensionHeight toSize:kSpinnerSize]; [_submitCodeSpinner autoVCenterInSuperview]; - [_submitCodeSpinner autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:kSpinnerSpacing]; - + [_submitCodeSpinner autoPinTrailingToSuperViewWithMargin:kSpinnerSpacing]; + _sendCodeViaSMSAgainButton = [UIButton buttonWithType:UIButtonTypeCustom]; _sendCodeViaSMSAgainButton.backgroundColor = [UIColor whiteColor]; [_sendCodeViaSMSAgainButton setTitle:NSLocalizedString(@"VERIFICATION_CHALLENGE_SUBMIT_AGAIN", @"button text during registration to request another SMS code be sent") @@ -204,8 +204,8 @@ NS_ASSUME_NONNULL_BEGIN [_requestCodeAgainSpinner autoSetDimension:ALDimensionWidth toSize:kSpinnerSize]; [_requestCodeAgainSpinner autoSetDimension:ALDimensionHeight toSize:kSpinnerSize]; [_requestCodeAgainSpinner autoVCenterInSuperview]; - [_requestCodeAgainSpinner autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:kSpinnerSpacing]; - + [_requestCodeAgainSpinner autoPinTrailingToSuperViewWithMargin:kSpinnerSpacing]; + _sendCodeViaVoiceButton = [UIButton buttonWithType:UIButtonTypeCustom]; _sendCodeViaVoiceButton.backgroundColor = [UIColor whiteColor]; [_sendCodeViaVoiceButton setTitle:NSLocalizedString(@"VERIFICATION_CHALLENGE_SEND_VIA_VOICE", @@ -227,7 +227,7 @@ NS_ASSUME_NONNULL_BEGIN [_requestCallSpinner autoSetDimension:ALDimensionWidth toSize:kSpinnerSize]; [_requestCallSpinner autoSetDimension:ALDimensionHeight toSize:kSpinnerSize]; [_requestCallSpinner autoVCenterInSuperview]; - [_requestCallSpinner autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:kSpinnerSpacing]; + [_requestCallSpinner autoPinTrailingToSuperViewWithMargin:kSpinnerSpacing]; } - (NSString *)phoneNumberText diff --git a/Signal/src/ViewControllers/RegistrationViewController.m b/Signal/src/ViewControllers/RegistrationViewController.m index c76dd40a7..51cfd4641 100644 --- a/Signal/src/ViewControllers/RegistrationViewController.m +++ b/Signal/src/ViewControllers/RegistrationViewController.m @@ -215,7 +215,7 @@ NSString *const kKeychainKey_LastRegisteredPhoneNumber = @"kKeychainKey_LastRegi [spinnerView autoVCenterInSuperview]; [spinnerView autoSetDimension:ALDimensionWidth toSize:20.f]; [spinnerView autoSetDimension:ALDimensionHeight toSize:20.f]; - [spinnerView autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:20]; + [spinnerView autoPinTrailingToSuperViewWithMargin:20.f]; [spinnerView stopAnimating]; // Existing Account Button diff --git a/Signal/src/ViewControllers/SendExternalFileViewController.m b/Signal/src/ViewControllers/SendExternalFileViewController.m index a1bf00c47..553aa76fd 100644 --- a/Signal/src/ViewControllers/SendExternalFileViewController.m +++ b/Signal/src/ViewControllers/SendExternalFileViewController.m @@ -110,15 +110,15 @@ NS_ASSUME_NONNULL_BEGIN [fileView addSubview:imageView]; [imageView autoSetDimension:ALDimensionWidth toSize:imageSize]; [imageView autoSetDimension:ALDimensionHeight toSize:imageSize]; - [imageView autoPinEdgeToSuperviewEdge:ALEdgeLeft]; + [imageView autoPinLeadingToSuperView]; [imageView autoPinEdgeToSuperviewEdge:ALEdgeTop]; [imageView autoPinEdgeToSuperviewEdge:ALEdgeBottom]; UIView *fileNameLabel = [self createFileNameLabel]; [fileView addSubview:fileNameLabel]; [fileNameLabel autoAlignAxis:ALAxisHorizontal toSameAxisOfView:imageView]; - [fileNameLabel autoPinEdge:ALEdgeLeft toEdge:ALEdgeRight ofView:imageView withOffset:imageLabelSpacing]; - [fileNameLabel autoPinEdgeToSuperviewEdge:ALEdgeRight]; + [fileNameLabel autoPinLeadingToTrailingOfView:imageView margin:imageLabelSpacing]; + [fileNameLabel autoPinTrailingToSuperView]; [header addSubview:searchBar]; [searchBar autoPinWidthToSuperview]; diff --git a/Signal/src/ViewControllers/SettingsTableViewController.m b/Signal/src/ViewControllers/SettingsTableViewController.m index ef1068eab..a18f4765f 100644 --- a/Signal/src/ViewControllers/SettingsTableViewController.m +++ b/Signal/src/ViewControllers/SettingsTableViewController.m @@ -203,6 +203,8 @@ [section addItem:[OWSTableItem itemWithCustomCellBlock:^{ UITableViewCell *cell = [UITableViewCell new]; + cell.preservesSuperviewLayoutMargins = YES; + cell.contentView.preservesSuperviewLayoutMargins = YES; UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; button.backgroundColor = [UIColor ows_destructiveRedColor]; [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; @@ -212,10 +214,8 @@ [cell.contentView addSubview:button]; [button autoSetDimension:ALDimensionHeight toSize:50.f]; [button autoVCenterInSuperview]; - [button autoPinEdgeToSuperviewEdge:ALEdgeLeft - withInset:cell.layoutMargins.left + cell.contentView.layoutMargins.left]; - [button autoPinEdgeToSuperviewEdge:ALEdgeRight - withInset:cell.layoutMargins.right + cell.contentView.layoutMargins.right]; + [button autoPinLeadingToSuperView]; + [button autoPinTrailingToSuperView]; [button addTarget:self action:@selector(unregisterUser) forControlEvents:UIControlEventTouchUpInside]; cell.selectionStyle = UITableViewCellSelectionStyleNone; return cell;