Adapt registration views to RTL.

// FREEBIE
pull/1/head
Matthew Chen 8 years ago
parent d4f012fbb7
commit 656cc47de5

@ -80,6 +80,10 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value);
- (void)autoPinTrailingToView:(UIView *)view margin:(CGFloat)margin;
// Return Right on LTR and Right on RTL.
- (NSTextAlignment)textAlignmentUnnatural;
// Leading and trailing anchors honor layout margins.
// When using a UIView as a "div" to structure layout, we don't want it to have margins.
+ (UIView *)containerView;
- (void)setHLayoutMargins:(CGFloat)value;
#pragma mark - Debugging

@ -298,6 +298,23 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value)
return (self.isRTL ? NSTextAlignmentLeft : NSTextAlignmentRight);
}
+ (UIView *)containerView
{
UIView *view = [UIView new];
// Leading and trailing anchors honor layout margins.
// When using a UIView as a "div" to structure layout, we don't want it to have margins.
view.layoutMargins = UIEdgeInsetsMake(0, 0, 0, 0);
return view;
}
- (void)setHLayoutMargins:(CGFloat)value
{
UIEdgeInsets layoutMargins = self.layoutMargins;
layoutMargins.left = value;
layoutMargins.right = value;
self.layoutMargins = layoutMargins;
}
#pragma mark - Debugging
- (void)addBorderWithColor:(UIColor *)color

@ -126,6 +126,7 @@ NS_ASSUME_NONNULL_BEGIN
_phoneNumberLabel.font = [UIFont ows_regularFontWithSize:20.f];
_phoneNumberLabel.numberOfLines = 2;
_phoneNumberLabel.adjustsFontSizeToFitWidth = YES;
_phoneNumberLabel.textAlignment = NSTextAlignmentCenter;
[self.view addSubview:_phoneNumberLabel];
[_phoneNumberLabel autoPinWidthToSuperviewWithMargin:ScaleFromIPhone5(32)];
[_phoneNumberLabel autoPinEdge:ALEdgeTop

@ -90,25 +90,25 @@ NSString *const kKeychainKey_LastRegisteredPhoneNumber = @"kKeychainKey_LastRegi
[logoView autoPinEdge:ALEdgeBottom toEdge:ALEdgeTop ofView:headerLabel withOffset:-14.f];
}
UIView *contentView = [UIView new];
const CGFloat kRowHeight = 60.f;
const CGFloat kRowHMargin = 20.f;
const CGFloat kSeparatorHeight = 1.f;
const CGFloat kExamplePhoneNumberVSpacing = 8.f;
const CGFloat fontSizePoints = ScaleFromIPhone5To7Plus(16.f, 20.f);
UIView *contentView = [UIView containerView];
[contentView setHLayoutMargins:kRowHMargin];
contentView.backgroundColor = [UIColor whiteColor];
[self.view addSubview:contentView];
[contentView autoPinToBottomLayoutGuideOfViewController:self withInset:0];
[contentView autoPinWidthToSuperview];
[contentView autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:header];
const CGFloat kRowHeight = 60.f;
const CGFloat kRowLeftMargin = 20.f;
const CGFloat kRowRightMargin = 16.f;
const CGFloat kSeparatorHeight = 1.f;
const CGFloat kButtonHMargin = 30.f;
const CGFloat kExamplePhoneNumberVSpacing = 8.f;
const CGFloat fontSizePoints = ScaleFromIPhone5To7Plus(16.f, 20.f);
// Country
UIView *countryRow = [UIView new];
UIView *countryRow = [UIView containerView];
countryRow.preservesSuperviewLayoutMargins = YES;
[contentView addSubview:countryRow];
[countryRow autoPinWidthToSuperview];
[countryRow autoPinLeadingAndTrailingToSuperview];
[countryRow autoPinEdgeToSuperviewEdge:ALEdgeTop];
[countryRow autoSetDimension:ALDimensionHeight toSize:kRowHeight];
[countryRow
@ -122,7 +122,7 @@ NSString *const kKeychainKey_LastRegisteredPhoneNumber = @"kKeychainKey_LastRegi
countryNameLabel.font = [UIFont ows_mediumFontWithSize:fontSizePoints];
[countryRow addSubview:countryNameLabel];
[countryNameLabel autoVCenterInSuperview];
[countryNameLabel autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:kRowLeftMargin];
[countryNameLabel autoPinLeadingToSuperView];
UILabel *countryCodeLabel = [UILabel new];
self.countryCodeLabel = countryCodeLabel;
@ -130,7 +130,7 @@ NSString *const kKeychainKey_LastRegisteredPhoneNumber = @"kKeychainKey_LastRegi
countryCodeLabel.font = [UIFont ows_mediumFontWithSize:fontSizePoints + 2.f];
[countryRow addSubview:countryCodeLabel];
[countryCodeLabel autoVCenterInSuperview];
[countryCodeLabel autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:kRowRightMargin];
[countryCodeLabel autoPinTrailingToSuperView];
UIView *separatorView1 = [UIView new];
separatorView1.backgroundColor = [UIColor colorWithWhite:0.75f alpha:1.f];
@ -140,9 +140,10 @@ NSString *const kKeychainKey_LastRegisteredPhoneNumber = @"kKeychainKey_LastRegi
[separatorView1 autoSetDimension:ALDimensionHeight toSize:kSeparatorHeight];
// Phone Number
UIView *phoneNumberRow = [UIView new];
UIView *phoneNumberRow = [UIView containerView];
phoneNumberRow.preservesSuperviewLayoutMargins = YES;
[contentView addSubview:phoneNumberRow];
[phoneNumberRow autoPinWidthToSuperview];
[phoneNumberRow autoPinLeadingAndTrailingToSuperview];
[phoneNumberRow autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:separatorView1];
[phoneNumberRow autoSetDimension:ALDimensionHeight toSize:kRowHeight];
@ -153,7 +154,7 @@ NSString *const kKeychainKey_LastRegisteredPhoneNumber = @"kKeychainKey_LastRegi
phoneNumberLabel.font = [UIFont ows_mediumFontWithSize:fontSizePoints];
[phoneNumberRow addSubview:phoneNumberLabel];
[phoneNumberLabel autoVCenterInSuperview];
[phoneNumberLabel autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:kRowLeftMargin];
[phoneNumberLabel autoPinLeadingToSuperView];
UITextField *phoneNumberTextField = [UITextField new];
phoneNumberTextField.textAlignment = NSTextAlignmentRight;
@ -166,14 +167,14 @@ NSString *const kKeychainKey_LastRegisteredPhoneNumber = @"kKeychainKey_LastRegi
phoneNumberTextField.font = [UIFont ows_mediumFontWithSize:fontSizePoints + 2];
[phoneNumberRow addSubview:phoneNumberTextField];
[phoneNumberTextField autoVCenterInSuperview];
[phoneNumberTextField autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:kRowRightMargin];
[phoneNumberTextField autoPinTrailingToSuperView];
UILabel *examplePhoneNumberLabel = [UILabel new];
self.examplePhoneNumberLabel = examplePhoneNumberLabel;
examplePhoneNumberLabel.font = [UIFont ows_regularFontWithSize:fontSizePoints - 2.f];
examplePhoneNumberLabel.textColor = [UIColor colorWithWhite:0.5f alpha:1.f];
[contentView addSubview:examplePhoneNumberLabel];
[examplePhoneNumberLabel autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:kRowRightMargin];
[examplePhoneNumberLabel autoPinTrailingToSuperView];
[examplePhoneNumberLabel autoPinEdge:ALEdgeTop
toEdge:ALEdgeBottom
ofView:phoneNumberTextField
@ -199,8 +200,7 @@ NSString *const kKeychainKey_LastRegisteredPhoneNumber = @"kKeychainKey_LastRegi
[activateButton setContentHorizontalAlignment:UIControlContentHorizontalAlignmentCenter];
[activateButton setContentVerticalAlignment:UIControlContentVerticalAlignmentCenter];
[contentView addSubview:activateButton];
[activateButton autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:kButtonHMargin];
[activateButton autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:kButtonHMargin];
[activateButton autoPinLeadingAndTrailingToSuperview];
[activateButton autoPinEdge:ALEdgeTop
toEdge:ALEdgeBottom
ofView:separatorView2
@ -227,8 +227,7 @@ NSString *const kKeychainKey_LastRegisteredPhoneNumber = @"kKeychainKey_LastRegi
[existingAccountButton setContentHorizontalAlignment:UIControlContentHorizontalAlignmentCenter];
[existingAccountButton setContentVerticalAlignment:UIControlContentVerticalAlignmentCenter];
[contentView addSubview:existingAccountButton];
[existingAccountButton autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:kButtonHMargin];
[existingAccountButton autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:kButtonHMargin];
[existingAccountButton autoPinLeadingAndTrailingToSuperview];
[existingAccountButton autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:activateButton withOffset:9.f];
[existingAccountButton autoSetDimension:ALDimensionHeight toSize:36.f];
[existingAccountButton addTarget:self

@ -198,7 +198,7 @@ NSString *const kSelectRecipientViewControllerCellIdentifier = @"kSelectRecipien
previousRow:(nullable UIView *)previousRow
superview:(nullable UIView *)superview
{
UIView *row = [UIView new];
UIView *row = [UIView containerView];
[superview addSubview:row];
[row autoPinLeadingAndTrailingToSuperview];
if (previousRow) {
@ -207,7 +207,6 @@ NSString *const kSelectRecipientViewControllerCellIdentifier = @"kSelectRecipien
[row autoPinEdgeToSuperviewEdge:ALEdgeTop];
}
[row autoSetDimension:ALDimensionHeight toSize:height];
row.layoutMargins = UIEdgeInsetsMake(0, 0, 0, 0);
return row;
}

Loading…
Cancel
Save