Rework isRTL.

pull/1/head
Matthew Chen 7 years ago
parent 8bbc251482
commit 1412998b4a

@ -1,5 +1,5 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
import UIKit
@ -21,7 +21,7 @@ class SlideOffAnimatedTransition: NSObject, UIViewControllerAnimatedTransitionin
}
let width = containerView.frame.width
let offsetFrame = fromView.frame.offsetBy(dx: (containerView.isRTL() ? +width : -width), dy: 0)
let offsetFrame = fromView.frame.offsetBy(dx: (CurrentAppContext().isRTL ? +width : -width), dy: 0)
toView.frame = fromView.frame
fromView.layer.shadowRadius = 15.0
@ -29,7 +29,7 @@ class SlideOffAnimatedTransition: NSObject, UIViewControllerAnimatedTransitionin
toView.layer.opacity = 0.9
containerView.insertSubview(toView, belowSubview: fromView)
UIView.animate(withDuration: transitionDuration(using: transitionContext), delay:0, options: .curveLinear, animations: {
UIView.animate(withDuration: transitionDuration(using: transitionContext), delay: 0, options: .curveLinear, animations: {
fromView.frame = offsetFrame
toView.layer.opacity = 1.0

@ -342,7 +342,7 @@
[subtitleLabel autoPinLeadingToSuperviewMargin];
[subtitleLabel autoPinEdgeToSuperviewEdge:ALEdgeBottom];
UIImage *disclosureImage = [UIImage imageNamed:(self.view.isRTL ? @"NavBarBack" : @"NavBarBackRTL")];
UIImage *disclosureImage = [UIImage imageNamed:(CurrentAppContext().isRTL ? @"NavBarBack" : @"NavBarBackRTL")];
OWSAssert(disclosureImage);
UIImageView *disclosureButton =
[[UIImageView alloc] initWithImage:[disclosureImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]];

@ -255,7 +255,7 @@ class CallViewController: OWSViewController, CallObserver, CallServiceObserver,
func createContactViews() {
leaveCallViewButton = UIButton()
let backButtonImage = self.view.isRTL() ? #imageLiteral(resourceName: "NavBarBackRTL") : #imageLiteral(resourceName: "NavBarBack")
let backButtonImage = CurrentAppContext().isRTL ? #imageLiteral(resourceName: "NavBarBackRTL") : #imageLiteral(resourceName: "NavBarBack")
leaveCallViewButton.setImage(backButtonImage, for: .normal)
leaveCallViewButton.autoSetDimensions(to: CGSize(width: 40, height: 40))
leaveCallViewButton.addTarget(self, action: #selector(didTapLeaveCall(sender:)), for: .touchUpInside)

@ -219,7 +219,7 @@ class ContactViewController: OWSViewController, ContactShareViewHelperDelegate {
backButton.autoPinEdge(toSuperviewEdge: .top)
backButton.autoPinLeadingToSuperviewMargin()
let backIconName = (self.view.isRTL() ? "system_disclosure_indicator" : "system_disclosure_indicator_rtl")
let backIconName = (CurrentAppContext().isRTL ? "system_disclosure_indicator" : "system_disclosure_indicator_rtl")
guard let backIconImage = UIImage(named: backIconName) else {
owsFail("\(logTag) missing icon.")
return topView

@ -203,7 +203,8 @@ NS_ASSUME_NONNULL_BEGIN
[labelsView addArrangedSubview:bottomLabel];
}
UIImage *disclosureImage = [UIImage imageNamed:(self.isRTL ? @"small_chevron_left" : @"small_chevron_right")];
UIImage *disclosureImage =
[UIImage imageNamed:(CurrentAppContext().isRTL ? @"small_chevron_left" : @"small_chevron_right")];
OWSAssert(disclosureImage);
UIImageView *disclosureImageView = [UIImageView new];
disclosureImageView.image = [disclosureImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];

@ -84,7 +84,8 @@ NS_ASSUME_NONNULL_BEGIN
[self.contentView addGestureRecognizer:longPress];
PanDirectionGestureRecognizer *panGesture = [[PanDirectionGestureRecognizer alloc]
initWithDirection:(self.isRTL ? PanDirectionLeft : PanDirectionRight)target:self
initWithDirection:(CurrentAppContext().isRTL ? PanDirectionLeft : PanDirectionRight)
target:self
action:@selector(handlePanGesture:)];
[self addGestureRecognizer:panGesture];
}
@ -227,19 +228,16 @@ NS_ASSUME_NONNULL_BEGIN
attributes:@{
NSFontAttributeName : self.dateHeaderFont,
NSForegroundColorAttributeName : [UIColor lightGrayColor],
}
referenceView:self];
}];
attributedText = [attributedText rtlSafeAppend:@" "
attributes:@{
NSFontAttributeName : self.dateHeaderFont,
}
referenceView:self];
}];
attributedText = [attributedText rtlSafeAppend:timeString
attributes:@{
NSFontAttributeName : self.dateHeaderFont,
NSForegroundColorAttributeName : [UIColor lightGrayColor],
}
referenceView:self];
}];
self.dateHeaderLabel.attributedText = attributedText;

@ -91,7 +91,7 @@ NS_ASSUME_NONNULL_BEGIN
UIImage *_Nullable statusIndicatorImage = nil;
MessageReceiptStatus messageStatus =
[MessageRecipientStatusUtils recipientStatusWithOutgoingMessage:outgoingMessage referenceView:self];
[MessageRecipientStatusUtils recipientStatusWithOutgoingMessage:outgoingMessage];
switch (messageStatus) {
case MessageReceiptStatusUploading:
case MessageReceiptStatusSending:
@ -175,8 +175,7 @@ NS_ASSUME_NONNULL_BEGIN
}
TSOutgoingMessage *outgoingMessage = (TSOutgoingMessage *)viewItem.interaction;
NSString *statusMessage =
[MessageRecipientStatusUtils receiptMessageWithOutgoingMessage:outgoingMessage referenceView:self];
NSString *statusMessage = [MessageRecipientStatusUtils receiptMessageWithOutgoingMessage:outgoingMessage];
return statusMessage;
}

@ -515,7 +515,7 @@ static const CGFloat ConversationInputToolbarBorderViewHeight = 0.5;
NSMutableAttributedString *cancelString = [NSMutableAttributedString new];
const CGFloat cancelArrowFontSize = ScaleFromIPhone5To7Plus(18.4, 20.f);
const CGFloat cancelFontSize = ScaleFromIPhone5To7Plus(14.f, 16.f);
NSString *arrowHead = (self.isRTL ? @"\uf105" : @"\uf104");
NSString *arrowHead = (CurrentAppContext().isRTL ? @"\uf105" : @"\uf104");
[cancelString
appendAttributedString:[[NSAttributedString alloc]
initWithString:arrowHead
@ -589,7 +589,7 @@ static const CGFloat ConversationInputToolbarBorderViewHeight = 0.5;
CGRect cancelLabelStartFrame = cancelLabel.frame;
CGRect cancelLabelEndFrame = cancelLabel.frame;
cancelLabelStartFrame.origin.x
= (self.isRTL ? -self.voiceMemoUI.bounds.size.width : self.voiceMemoUI.bounds.size.width);
= (CurrentAppContext().isRTL ? -self.voiceMemoUI.bounds.size.width : self.voiceMemoUI.bounds.size.width);
cancelLabel.frame = cancelLabelStartFrame;
[UIView animateWithDuration:0.35f
delay:0.f

@ -4864,14 +4864,12 @@ typedef enum : NSUInteger {
if (interactionType == OWSInteractionType_OutgoingMessage) {
TSOutgoingMessage *outgoingMessage = (TSOutgoingMessage *)viewItem.interaction;
MessageReceiptStatus receiptStatus =
[MessageRecipientStatusUtils recipientStatusWithOutgoingMessage:outgoingMessage
referenceView:self.view];
[MessageRecipientStatusUtils recipientStatusWithOutgoingMessage:outgoingMessage];
if (nextViewItem && nextViewItem.interaction.interactionType == interactionType) {
TSOutgoingMessage *nextOutgoingMessage = (TSOutgoingMessage *)nextViewItem.interaction;
MessageReceiptStatus nextReceiptStatus =
[MessageRecipientStatusUtils recipientStatusWithOutgoingMessage:nextOutgoingMessage
referenceView:self.view];
[MessageRecipientStatusUtils recipientStatusWithOutgoingMessage:nextOutgoingMessage];
NSString *nextTimestampText = [DateUtil formatTimestampShort:nextViewItem.interaction.timestamp];
// We can skip the "outgoing message status" footer if the next message
@ -5013,7 +5011,7 @@ typedef enum : NSUInteger {
self.currentShowMessageDetailsPanGesture = gestureRecognizer;
const CGFloat swipeTranslation
= ([gestureRecognizer translationInView:self.view].x * (self.view.isRTL ? +1.f : -1.f));
= ([gestureRecognizer translationInView:self.view].x * (CurrentAppContext().isRTL ? +1.f : -1.f));
const CGFloat ratioComplete = CGFloatClamp(swipeTranslation / self.view.frame.size.width, 0, 1);
switch (gestureRecognizer.state) {

@ -424,7 +424,7 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
// too far apart and too far from the edge of the screen. So we use a smaller
// leading inset tighten up the layout.
CGFloat hInset = round((kBarButtonSize - image.size.width) * 0.5f);
if (self.view.isRTL) {
if (CurrentAppContext().isRTL) {
imageEdgeInsets.right = hInset;
imageEdgeInsets.left = round((kBarButtonSize - (image.size.width + hInset)) * 0.5f);
} else {
@ -803,7 +803,7 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
cell.backgroundColor = [UIColor whiteColor];
UIImage *disclosureImage = [UIImage imageNamed:(cell.isRTL ? @"NavBarBack" : @"NavBarBackRTL")];
UIImage *disclosureImage = [UIImage imageNamed:(CurrentAppContext().isRTL ? @"NavBarBack" : @"NavBarBackRTL")];
OWSAssert(disclosureImage);
UIImageView *disclosureImageView = [UIImageView new];
disclosureImageView.image = [disclosureImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];

@ -235,7 +235,7 @@ class MessageDetailViewController: OWSViewController, MediaGalleryDataSourceDele
continue
}
let (recipientStatus, shortStatusMessage, _) = MessageRecipientStatusUtils.recipientStatusAndStatusMessage(outgoingMessage: outgoingMessage, recipientState: recipientState, referenceView: self.view)
let (recipientStatus, shortStatusMessage, _) = MessageRecipientStatusUtils.recipientStatusAndStatusMessage(outgoingMessage: outgoingMessage, recipientState: recipientState)
guard recipientStatus == recipientStatusGroup else {
continue
@ -279,14 +279,12 @@ class MessageDetailViewController: OWSViewController, MediaGalleryDataSourceDele
rows.append(valueRow(name: NSLocalizedString("MESSAGE_METADATA_VIEW_SENT_DATE_TIME",
comment: "Label for the 'sent date & time' field of the 'message metadata' view."),
value: DateUtil.formatPastTimestampRelativeToNow(message.timestamp,
isRTL: self.view.isRTL())))
value: DateUtil.formatPastTimestampRelativeToNow(message.timestamp)))
if message as? TSIncomingMessage != nil {
rows.append(valueRow(name: NSLocalizedString("MESSAGE_METADATA_VIEW_RECEIVED_DATE_TIME",
comment: "Label for the 'received date & time' field of the 'message metadata' view."),
value: DateUtil.formatPastTimestampRelativeToNow(message.timestampForSorting(),
isRTL: self.view.isRTL())))
value: DateUtil.formatPastTimestampRelativeToNow(message.timestampForSorting())))
}
rows += addAttachmentMetadataRows()

@ -46,7 +46,7 @@ public class OWS2FAReminderViewController: UIViewController, PinEntryViewDelegat
let attributes = [NSAttributedStringKey.font: pinEntryView.boldLabelFont]
let attributedInstructionsText = NSAttributedString(string: instructionsTextHeader, attributes: attributes).rtlSafeAppend(" ", referenceView: pinEntryView).rtlSafeAppend(instructionsTextBody, referenceView: pinEntryView)
let attributedInstructionsText = NSAttributedString(string: instructionsTextHeader, attributes: attributes).rtlSafeAppend(" ").rtlSafeAppend(instructionsTextBody)
pinEntryView.attributedInstructionsText = attributedInstructionsText

@ -27,40 +27,33 @@ public class MessageRecipientStatusUtils: NSObject {
// This method is per-recipient.
@objc
public class func recipientStatus(outgoingMessage: TSOutgoingMessage,
recipientState: TSOutgoingMessageRecipientState,
referenceView: UIView) -> MessageReceiptStatus {
recipientState: TSOutgoingMessageRecipientState) -> MessageReceiptStatus {
let (messageReceiptStatus, _, _) = recipientStatusAndStatusMessage(outgoingMessage: outgoingMessage,
recipientState: recipientState,
referenceView: referenceView)
recipientState: recipientState)
return messageReceiptStatus
}
// This method is per-recipient.
@objc
public class func shortStatusMessage(outgoingMessage: TSOutgoingMessage,
recipientState: TSOutgoingMessageRecipientState,
referenceView: UIView) -> String {
recipientState: TSOutgoingMessageRecipientState) -> String {
let (_, shortStatusMessage, _) = recipientStatusAndStatusMessage(outgoingMessage: outgoingMessage,
recipientState: recipientState,
referenceView: referenceView)
recipientState: recipientState)
return shortStatusMessage
}
// This method is per-recipient.
@objc
public class func longStatusMessage(outgoingMessage: TSOutgoingMessage,
recipientState: TSOutgoingMessageRecipientState,
referenceView: UIView) -> String {
recipientState: TSOutgoingMessageRecipientState) -> String {
let (_, _, longStatusMessage) = recipientStatusAndStatusMessage(outgoingMessage: outgoingMessage,
recipientState: recipientState,
referenceView: referenceView)
recipientState: recipientState)
return longStatusMessage
}
// This method is per-recipient.
class func recipientStatusAndStatusMessage(outgoingMessage: TSOutgoingMessage,
recipientState: TSOutgoingMessageRecipientState,
referenceView: UIView) -> (status: MessageReceiptStatus, shortStatusMessage: String, longStatusMessage: String) {
recipientState: TSOutgoingMessageRecipientState) -> (status: MessageReceiptStatus, shortStatusMessage: String, longStatusMessage: String) {
switch recipientState.state {
case .failed:
@ -83,20 +76,18 @@ public class MessageRecipientStatusUtils: NSObject {
}
case .sent:
if let readTimestamp = recipientState.readTimestamp {
let timestampString = DateUtil.formatPastTimestampRelativeToNow(readTimestamp.uint64Value,
isRTL: referenceView.isRTL())
let timestampString = DateUtil.formatPastTimestampRelativeToNow(readTimestamp.uint64Value)
let shortStatusMessage = timestampString
let longStatusMessage = NSLocalizedString("MESSAGE_STATUS_READ", comment: "message footer for read messages").rtlSafeAppend(" ", referenceView: referenceView)
.rtlSafeAppend(timestampString, referenceView: referenceView)
let longStatusMessage = NSLocalizedString("MESSAGE_STATUS_READ", comment: "message footer for read messages").rtlSafeAppend(" ")
.rtlSafeAppend(timestampString)
return (status:.read, shortStatusMessage:shortStatusMessage, longStatusMessage:longStatusMessage)
}
if let deliveryTimestamp = recipientState.deliveryTimestamp {
let timestampString = DateUtil.formatPastTimestampRelativeToNow(deliveryTimestamp.uint64Value,
isRTL: referenceView.isRTL())
let timestampString = DateUtil.formatPastTimestampRelativeToNow(deliveryTimestamp.uint64Value)
let shortStatusMessage = timestampString
let longStatusMessage = NSLocalizedString("MESSAGE_STATUS_DELIVERED",
comment: "message status for message delivered to their recipient.").rtlSafeAppend(" ", referenceView: referenceView)
.rtlSafeAppend(timestampString, referenceView: referenceView)
comment: "message status for message delivered to their recipient.").rtlSafeAppend(" ")
.rtlSafeAppend(timestampString)
return (status:.delivered, shortStatusMessage:shortStatusMessage, longStatusMessage:longStatusMessage)
}
let statusMessage =
@ -111,8 +102,7 @@ public class MessageRecipientStatusUtils: NSObject {
}
// This method is per-message.
internal class func receiptStatusAndMessage(outgoingMessage: TSOutgoingMessage,
referenceView: UIView) -> (status: MessageReceiptStatus, message: String) {
internal class func receiptStatusAndMessage(outgoingMessage: TSOutgoingMessage) -> (status: MessageReceiptStatus, message: String) {
switch outgoingMessage.messageState {
case .failed:
@ -145,18 +135,15 @@ public class MessageRecipientStatusUtils: NSObject {
// This method is per-message.
@objc
public class func receiptMessage(outgoingMessage: TSOutgoingMessage,
referenceView: UIView) -> String {
let (_, message ) = receiptStatusAndMessage(outgoingMessage: outgoingMessage,
referenceView: referenceView)
public class func receiptMessage(outgoingMessage: TSOutgoingMessage) -> String {
let (_, message ) = receiptStatusAndMessage(outgoingMessage: outgoingMessage)
return message
}
// This method is per-message.
@objc
public class func recipientStatus(outgoingMessage: TSOutgoingMessage, referenceView: UIView) -> MessageReceiptStatus {
let (status, _ ) = receiptStatusAndMessage(outgoingMessage: outgoingMessage,
referenceView: referenceView)
public class func recipientStatus(outgoingMessage: TSOutgoingMessage) -> MessageReceiptStatus {
let (status, _ ) = receiptStatusAndMessage(outgoingMessage: outgoingMessage)
return status
}

@ -18,7 +18,7 @@ NS_ASSUME_NONNULL_BEGIN
+ (BOOL)dateIsYesterday:(NSDate *)date;
+ (NSString *)formatPastTimestampRelativeToNow:(uint64_t)pastTimestamp
isRTL:(BOOL)isRTL NS_SWIFT_NAME(formatPastTimestampRelativeToNow(_:isRTL:));
NS_SWIFT_NAME(formatPastTimestampRelativeToNow(_:));
+ (NSString *)formatTimestampShort:(uint64_t)timestamp;
+ (NSString *)formatDateShort:(NSDate *)date;

@ -145,7 +145,7 @@ static NSString *const DATE_FORMAT_WEEKDAY = @"EEEE";
return [[calendar components:NSCalendarUnitDay fromDate:date1 toDate:date2 options:0] day];
}
+ (NSString *)formatPastTimestampRelativeToNow:(uint64_t)pastTimestamp isRTL:(BOOL)isRTL
+ (NSString *)formatPastTimestampRelativeToNow:(uint64_t)pastTimestamp
{
OWSCAssert(pastTimestamp > 0);
@ -161,8 +161,7 @@ static NSString *const DATE_FORMAT_WEEKDAY = @"EEEE";
} else {
dateString = [[self dateFormatter] stringFromDate:pastDate];
}
return [[dateString rtlSafeAppend:@" " isRTL:isRTL] rtlSafeAppend:[[self timeFormatter] stringFromDate:pastDate]
isRTL:isRTL];
return [[dateString rtlSafeAppend:@" "] rtlSafeAppend:[[self timeFormatter] stringFromDate:pastDate]];
}
+ (NSString *)formatTimestampShort:(uint64_t)timestamp

@ -132,8 +132,13 @@ NS_ASSUME_NONNULL_BEGIN
- (BOOL)isRTL
{
return
[[UIApplication sharedApplication] userInterfaceLayoutDirection] == UIUserInterfaceLayoutDirectionRightToLeft;
static BOOL isRTL = NO;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
isRTL = [[UIApplication sharedApplication] userInterfaceLayoutDirection]
== UIUserInterfaceLayoutDirectionRightToLeft;
});
return isRTL;
}
- (void)setStatusBarStyle:(UIStatusBarStyle)statusBarStyle

@ -92,7 +92,7 @@ class ReminderView: UIView {
// Show the disclosure indicator if this reminder has a tap action.
if tapAction != nil {
// Icon
let iconName = (self.isRTL() ? "system_disclosure_indicator_rtl" : "system_disclosure_indicator")
let iconName = (CurrentAppContext().isRTL ? "system_disclosure_indicator_rtl" : "system_disclosure_indicator")
guard let iconImage = UIImage(named: iconName) else {
owsFail("\(logTag) missing icon.")
return

@ -1,15 +1,13 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
NS_ASSUME_NONNULL_BEGIN
@interface NSAttributedString (OWS)
- (NSAttributedString *)rtlSafeAppend:(NSString *)text
attributes:(NSDictionary *)attributes
referenceView:(UIView *)referenceView;
- (NSAttributedString *)rtlSafeAppend:(NSAttributedString *)string referenceView:(UIView *)referenceView;
- (NSAttributedString *)rtlSafeAppend:(NSString *)text attributes:(NSDictionary *)attributes;
- (NSAttributedString *)rtlSafeAppend:(NSAttributedString *)string;
@end

@ -1,9 +1,10 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "NSAttributedString+OWS.h"
#import "UIView+OWS.h"
#import <SignalServiceKit/AppContext.h>
NS_ASSUME_NONNULL_BEGIN
@ -11,23 +12,20 @@ NS_ASSUME_NONNULL_BEGIN
- (NSAttributedString *)rtlSafeAppend:(NSString *)text
attributes:(NSDictionary *)attributes
referenceView:(UIView *)referenceView
{
OWSAssert(text);
OWSAssert(attributes);
OWSAssert(referenceView);
NSAttributedString *substring = [[NSAttributedString alloc] initWithString:text attributes:attributes];
return [self rtlSafeAppend:substring referenceView:referenceView];
return [self rtlSafeAppend:substring];
}
- (NSAttributedString *)rtlSafeAppend:(NSAttributedString *)string referenceView:(UIView *)referenceView
- (NSAttributedString *)rtlSafeAppend:(NSAttributedString *)string
{
OWSAssert(string);
OWSAssert(referenceView);
NSMutableAttributedString *result = [NSMutableAttributedString new];
if ([referenceView isRTL]) {
if (CurrentAppContext().isRTL) {
[result appendAttributedString:string];
[result appendAttributedString:self];
} else {

@ -8,8 +8,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface NSString (OWS)
- (NSString *)rtlSafeAppend:(NSString *)string referenceView:(UIView *)referenceView;
- (NSString *)rtlSafeAppend:(NSString *)string isRTL:(BOOL)isRTL;
- (NSString *)rtlSafeAppend:(NSString *)string;
- (NSString *)digitsOnly;

@ -4,6 +4,7 @@
#import "NSString+OWS.h"
#import "UIView+OWS.h"
#import <SignalServiceKit/AppContext.h>
NS_ASSUME_NONNULL_BEGIN
@ -14,19 +15,11 @@ NS_ASSUME_NONNULL_BEGIN
return [self stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
}
- (NSString *)rtlSafeAppend:(NSString *)string referenceView:(UIView *)referenceView
- (NSString *)rtlSafeAppend:(NSString *)string
{
OWSAssert(string);
OWSAssert(referenceView);
return [self rtlSafeAppend:string isRTL:referenceView.isRTL];
}
- (NSString *)rtlSafeAppend:(NSString *)string isRTL:(BOOL)isRTL
{
OWSAssert(string);
if (isRTL) {
if (CurrentAppContext().isRTL) {
return [string stringByAppendingString:self];
} else {
return [self stringByAppendingString:string];

@ -77,9 +77,6 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value);
// contents.
//
// NOTE: the margin values are inverted in RTL layouts.
//
// TODO: Remove this in favor of AppContext.isRTL()
- (BOOL)isRTL;
- (NSArray<NSLayoutConstraint *> *)autoPinLeadingAndTrailingToSuperviewMargin;
- (NSLayoutConstraint *)autoPinLeadingToSuperviewMargin;

@ -251,12 +251,6 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value)
#pragma mark - RTL
- (BOOL)isRTL
{
return ([UIView userInterfaceLayoutDirectionForSemanticContentAttribute:self.semanticContentAttribute]
== UIUserInterfaceLayoutDirectionRightToLeft);
}
- (NSLayoutConstraint *)autoPinLeadingToSuperviewMargin
{
return [self autoPinLeadingToSuperviewMarginWithInset:0];
@ -391,7 +385,7 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value)
- (NSTextAlignment)textAlignmentUnnatural
{
return (self.isRTL ? NSTextAlignmentLeft : NSTextAlignmentRight);
return (CurrentAppContext().isRTL ? NSTextAlignmentLeft : NSTextAlignmentRight);
}
- (void)setHLayoutMargins:(CGFloat)value

@ -2,9 +2,10 @@
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "UIViewController+OWS.h"
#import "UIColor+OWS.h"
#import "UIView+OWS.h"
#import "UIViewController+OWS.h"
#import <SignalServiceKit/AppContext.h>
NS_ASSUME_NONNULL_BEGIN
@ -53,7 +54,7 @@ NS_ASSUME_NONNULL_BEGIN
OWSAssert(selector);
UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
BOOL isRTL = [backButton isRTL];
BOOL isRTL = CurrentAppContext().isRTL;
// Nudge closer to the left edge to match default back button item.
const CGFloat kExtraLeftPadding = isRTL ? +0 : -8;

@ -15,6 +15,7 @@
#import <SignalMessaging/UIFont+OWS.h>
#import <SignalMessaging/UIUtil.h>
#import <SignalMessaging/UIView+OWS.h>
#import <SignalServiceKit/AppContext.h>
#import <SignalServiceKit/ContactsUpdater.h>
#import <SignalServiceKit/OWSBlockingManager.h>
#import <SignalServiceKit/PhoneNumberUtil.h>
@ -241,7 +242,7 @@ NSString *const kSelectRecipientViewControllerCellIdentifier = @"kSelectRecipien
{
_callingCode = callingCode;
NSString *titleFormat = ([UIView new].isRTL ? @"(%2$@) %1$@" : @"%1$@ (%2$@)");
NSString *titleFormat = (CurrentAppContext().isRTL ? @"(%2$@) %1$@" : @"%1$@ (%2$@)");
NSString *title = [NSString stringWithFormat:titleFormat, callingCode, countryCode.uppercaseString];
[self.countryCodeButton setTitle:title forState:UIControlStateNormal];
[self.countryCodeButton layoutSubviews];

@ -9,8 +9,6 @@ public class ConversationStyle: NSObject {
private let thread: TSThread
private let isRTL: Bool
// The width of the collection view.
@objc public var viewWidth: CGFloat = 0 {
didSet {
@ -54,7 +52,6 @@ public class ConversationStyle: NSObject {
public required init(thread: TSThread) {
self.thread = thread
self.isRTL = CurrentAppContext().isRTL
self.primaryColor = ConversationStyle.primaryColor(thread: thread)
super.init()

@ -26,7 +26,7 @@ NSString *NSStringForUIApplicationState(UIApplicationState value);
@property (nonatomic, readonly) BOOL isMainApp;
@property (nonatomic, readonly) BOOL isMainAppAndActive;
// Whether the user is using a right-to-left language like Arabic
// Whether the user is using a right-to-left language like Arabic.
@property (nonatomic, readonly) BOOL isRTL;
@property (nonatomic, readonly) BOOL isRunningTests;

@ -123,11 +123,16 @@ NS_ASSUME_NONNULL_BEGIN
- (BOOL)isRTL
{
// Borrowed from PureLayout's AppExtension compatible RTL support.
// App Extensions may not access -[UIApplication sharedApplication]; fall back to checking the bundle's preferred
// localization character direction
return [NSLocale characterDirectionForLanguage:[[NSBundle mainBundle] preferredLocalizations][0]]
== NSLocaleLanguageDirectionRightToLeft;
static BOOL isRTL = NO;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
// Borrowed from PureLayout's AppExtension compatible RTL support.
// App Extensions may not access -[UIApplication sharedApplication]; fall back to checking the bundle's
// preferred localization character direction
isRTL = [NSLocale characterDirectionForLanguage:[[NSBundle mainBundle] preferredLocalizations][0]]
== NSLocaleLanguageDirectionRightToLeft;
});
return isRTL;
}
- (void)setStatusBarStyle:(UIStatusBarStyle)statusBarStyle

Loading…
Cancel
Save