Adapt voice messages UI to RTL.

// FREEBIE
pull/1/head
Matthew Chen 8 years ago
parent 8005cf0227
commit c799e18c74

@ -117,7 +117,7 @@ NS_ASSUME_NONNULL_BEGIN
forState:UIControlStateNormal]; forState:UIControlStateNormal];
backButton.titleLabel.font = [UIFont ows_mediumFontWithSize:14.f]; backButton.titleLabel.font = [UIFont ows_mediumFontWithSize:14.f];
[header addSubview:backButton]; [header addSubview:backButton];
[backButton autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:10]; [backButton autoPinLeadingToSuperViewWithMargin:10.f];
[backButton autoAlignAxis:ALAxisHorizontal toSameAxisOfView:titleLabel]; [backButton autoAlignAxis:ALAxisHorizontal toSameAxisOfView:titleLabel];
[backButton addTarget:self action:@selector(backButtonPressed:) forControlEvents:UIControlEventTouchUpInside]; [backButton addTarget:self action:@selector(backButtonPressed:) forControlEvents:UIControlEventTouchUpInside];

@ -771,7 +771,7 @@ typedef enum : NSUInteger {
OWSAssert(title.length > 0); OWSAssert(title.length > 0);
OWSAssert(bannerColor); OWSAssert(bannerColor);
UIView *bannerView = [UIView new]; UIView *bannerView = [UIView containerView];
bannerView.backgroundColor = bannerColor; bannerView.backgroundColor = bannerColor;
bannerView.layer.cornerRadius = 2.5f; bannerView.layer.cornerRadius = 2.5f;
@ -794,7 +794,7 @@ typedef enum : NSUInteger {
[bannerView addSubview:closeButton]; [bannerView addSubview:closeButton];
const CGFloat kBannerCloseButtonPadding = 8.f; const CGFloat kBannerCloseButtonPadding = 8.f;
[closeButton autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:kBannerCloseButtonPadding]; [closeButton autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:kBannerCloseButtonPadding];
[closeButton autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:kBannerCloseButtonPadding]; [closeButton autoPinTrailingToSuperViewWithMargin:kBannerCloseButtonPadding];
[closeButton autoSetDimension:ALDimensionWidth toSize:closeIcon.size.width]; [closeButton autoSetDimension:ALDimensionWidth toSize:closeIcon.size.width];
[closeButton autoSetDimension:ALDimensionHeight toSize:closeIcon.size.height]; [closeButton autoSetDimension:ALDimensionHeight toSize:closeIcon.size.height];
@ -802,9 +802,9 @@ typedef enum : NSUInteger {
[label autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:5]; [label autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:5];
[label autoPinEdgeToSuperviewEdge:ALEdgeBottom withInset:5]; [label autoPinEdgeToSuperviewEdge:ALEdgeBottom withInset:5];
const CGFloat kBannerHPadding = 15.f; const CGFloat kBannerHPadding = 15.f;
[label autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:kBannerHPadding]; [label autoPinLeadingToSuperViewWithMargin:kBannerHPadding];
const CGFloat kBannerHSpacing = 10.f; const CGFloat kBannerHSpacing = 10.f;
[label autoPinEdge:ALEdgeRight toEdge:ALEdgeLeft ofView:closeButton withOffset:-kBannerHSpacing]; [closeButton autoPinLeadingToTrailingOfView:label margin:kBannerHSpacing];
[bannerView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:tapSelector]]; [bannerView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:tapSelector]];
@ -1081,7 +1081,7 @@ typedef enum : NSUInteger {
[backItem.customView addSubview:_backButtonUnreadCountView]; [backItem.customView addSubview:_backButtonUnreadCountView];
// TODO: // TODO:
[_backButtonUnreadCountView autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:-6]; [_backButtonUnreadCountView autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:-6];
[_backButtonUnreadCountView autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:1]; [_backButtonUnreadCountView autoPinLeadingToSuperViewWithMargin:1];
[_backButtonUnreadCountView autoSetDimension:ALDimensionHeight toSize:unreadCountViewDiameter]; [_backButtonUnreadCountView autoSetDimension:ALDimensionHeight toSize:unreadCountViewDiameter];
// We set a min width, but we will also pin to our subview label, so we can grow to accommodate multiple digits. // We set a min width, but we will also pin to our subview label, so we can grow to accommodate multiple digits.
[_backButtonUnreadCountView autoSetDimension:ALDimensionWidth [_backButtonUnreadCountView autoSetDimension:ALDimensionWidth

@ -81,9 +81,18 @@ NS_ASSUME_NONNULL_BEGIN
NSMutableAttributedString *cancelString = [NSMutableAttributedString new]; NSMutableAttributedString *cancelString = [NSMutableAttributedString new];
const CGFloat cancelArrowFontSize = ScaleFromIPhone5To7Plus(18.4, 20.f); const CGFloat cancelArrowFontSize = ScaleFromIPhone5To7Plus(18.4, 20.f);
const CGFloat cancelFontSize = ScaleFromIPhone5To7Plus(14.f, 16.f); const CGFloat cancelFontSize = ScaleFromIPhone5To7Plus(14.f, 16.f);
NSString *arrowHead = (self.isRTL ? @"\uf105" : @"\uf104");
[cancelString [cancelString
appendAttributedString:[[NSAttributedString alloc] appendAttributedString:[[NSAttributedString alloc]
initWithString:@"\uf104 " initWithString:arrowHead
attributes:@{
NSFontAttributeName : [UIFont ows_fontAwesomeFont:cancelArrowFontSize],
NSForegroundColorAttributeName : [UIColor ows_destructiveRedColor],
NSBaselineOffsetAttributeName : @(-1.f),
}]];
[cancelString
appendAttributedString:[[NSAttributedString alloc]
initWithString:@" "
attributes:@{ attributes:@{
NSFontAttributeName : [UIFont ows_fontAwesomeFont:cancelArrowFontSize], NSFontAttributeName : [UIFont ows_fontAwesomeFont:cancelArrowFontSize],
NSForegroundColorAttributeName : [UIColor ows_destructiveRedColor], NSForegroundColorAttributeName : [UIColor ows_destructiveRedColor],
@ -99,7 +108,15 @@ NS_ASSUME_NONNULL_BEGIN
}]]; }]];
[cancelString [cancelString
appendAttributedString:[[NSAttributedString alloc] appendAttributedString:[[NSAttributedString alloc]
initWithString:@" \uf104" initWithString:@" "
attributes:@{
NSFontAttributeName : [UIFont ows_fontAwesomeFont:cancelArrowFontSize],
NSForegroundColorAttributeName : [UIColor ows_destructiveRedColor],
NSBaselineOffsetAttributeName : @(-1.f),
}]];
[cancelString
appendAttributedString:[[NSAttributedString alloc]
initWithString:arrowHead
attributes:@{ attributes:@{
NSFontAttributeName : [UIFont ows_fontAwesomeFont:cancelArrowFontSize], NSFontAttributeName : [UIFont ows_fontAwesomeFont:cancelArrowFontSize],
NSForegroundColorAttributeName : [UIColor ows_destructiveRedColor], NSForegroundColorAttributeName : [UIColor ows_destructiveRedColor],
@ -126,9 +143,9 @@ NS_ASSUME_NONNULL_BEGIN
[whiteIconView autoCenterInSuperview]; [whiteIconView autoCenterInSuperview];
[imageView autoVCenterInSuperview]; [imageView autoVCenterInSuperview];
[imageView autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:10]; [imageView autoPinLeadingToSuperViewWithMargin:10.f];
[self.recordingLabel autoVCenterInSuperview]; [self.recordingLabel autoVCenterInSuperview];
[self.recordingLabel autoPinEdge:ALEdgeLeft toEdge:ALEdgeRight ofView:imageView withOffset:5.f]; [self.recordingLabel autoPinLeadingToTrailingOfView:imageView margin:5.f];
[cancelLabel autoVCenterInSuperview]; [cancelLabel autoVCenterInSuperview];
[cancelLabel autoHCenterInSuperview]; [cancelLabel autoHCenterInSuperview];
[self.voiceMemoUI setNeedsLayout]; [self.voiceMemoUI setNeedsLayout];
@ -137,7 +154,8 @@ NS_ASSUME_NONNULL_BEGIN
// Slide in the "slide to cancel" label. // Slide in the "slide to cancel" label.
CGRect cancelLabelStartFrame = cancelLabel.frame; CGRect cancelLabelStartFrame = cancelLabel.frame;
CGRect cancelLabelEndFrame = cancelLabel.frame; CGRect cancelLabelEndFrame = cancelLabel.frame;
cancelLabelStartFrame.origin.x = self.voiceMemoUI.bounds.size.width; cancelLabelStartFrame.origin.x
= (self.isRTL ? -self.voiceMemoUI.bounds.size.width : self.voiceMemoUI.bounds.size.width);
cancelLabel.frame = cancelLabelStartFrame; cancelLabel.frame = cancelLabelStartFrame;
[UIView animateWithDuration:0.35f [UIView animateWithDuration:0.35f
delay:0.f delay:0.f

@ -142,7 +142,7 @@ NS_ASSUME_NONNULL_BEGIN
if (self.isRecordingVoiceMemo) { if (self.isRecordingVoiceMemo) {
// Check for "slide to cancel" gesture. // Check for "slide to cancel" gesture.
CGPoint location = [sender locationInView:self]; CGPoint location = [sender locationInView:self];
CGFloat offset = MAX(0, self.voiceMemoGestureStartLocation.x - location.x); CGFloat offset = fabs(self.voiceMemoGestureStartLocation.x - location.x);
// The lower this value, the easier it is to cancel by accident. // The lower this value, the easier it is to cancel by accident.
// The higher this value, the harder it is to cancel. // The higher this value, the harder it is to cancel.
const CGFloat kCancelOffsetPoints = 100.f; const CGFloat kCancelOffsetPoints = 100.f;

@ -598,8 +598,7 @@ NS_ASSUME_NONNULL_BEGIN
threadTitleLabel.lineBreakMode = NSLineBreakByTruncatingTail; threadTitleLabel.lineBreakMode = NSLineBreakByTruncatingTail;
[threadNameView addSubview:threadTitleLabel]; [threadNameView addSubview:threadTitleLabel];
[threadTitleLabel autoPinEdgeToSuperviewEdge:ALEdgeTop]; [threadTitleLabel autoPinEdgeToSuperviewEdge:ALEdgeTop];
[threadTitleLabel autoPinEdgeToSuperviewEdge:ALEdgeLeft]; [threadTitleLabel autoPinWidthToSuperview];
[threadTitleLabel autoPinEdgeToSuperviewEdge:ALEdgeRight];
__block UIView *lastTitleView = threadTitleLabel; __block UIView *lastTitleView = threadTitleLabel;

Loading…
Cancel
Save