mirror of https://github.com/oxen-io/session-ios
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1021 B
Matlab
40 lines
1021 B
Matlab
8 years ago
|
//
|
||
7 years ago
|
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||
8 years ago
|
//
|
||
|
|
||
|
#import "NSAttributedString+OWS.h"
|
||
|
#import "UIView+OWS.h"
|
||
5 years ago
|
#import <SignalUtilitiesKit/AppContext.h>
|
||
8 years ago
|
|
||
|
NS_ASSUME_NONNULL_BEGIN
|
||
|
|
||
|
@implementation NSAttributedString (OWS)
|
||
|
|
||
7 years ago
|
- (NSAttributedString *)rtlSafeAppend:(NSString *)text attributes:(NSDictionary *)attributes
|
||
8 years ago
|
{
|
||
7 years ago
|
OWSAssertDebug(text);
|
||
|
OWSAssertDebug(attributes);
|
||
8 years ago
|
|
||
|
NSAttributedString *substring = [[NSAttributedString alloc] initWithString:text attributes:attributes];
|
||
7 years ago
|
return [self rtlSafeAppend:substring];
|
||
8 years ago
|
}
|
||
|
|
||
7 years ago
|
- (NSAttributedString *)rtlSafeAppend:(NSAttributedString *)string
|
||
8 years ago
|
{
|
||
7 years ago
|
OWSAssertDebug(string);
|
||
8 years ago
|
|
||
|
NSMutableAttributedString *result = [NSMutableAttributedString new];
|
||
7 years ago
|
if (CurrentAppContext().isRTL) {
|
||
8 years ago
|
[result appendAttributedString:string];
|
||
|
[result appendAttributedString:self];
|
||
|
} else {
|
||
|
[result appendAttributedString:self];
|
||
|
[result appendAttributedString:string];
|
||
|
}
|
||
|
return [result copy];
|
||
|
}
|
||
|
|
||
|
@end
|
||
|
|
||
|
NS_ASSUME_NONNULL_END
|