mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-29 07:42:40 +00:00
Merge pull request #2047 from vector-im/riot_2046
BF: Weird text color when selecting a message
This commit is contained in:
commit
a7cf268b24
4 changed files with 40 additions and 12 deletions
|
@ -10,6 +10,7 @@ Improvements:
|
|||
|
||||
Bug fix:
|
||||
* Fix missing read receipts when lazy-loading room members.
|
||||
* Weird text color when selecting a message (#2046).
|
||||
|
||||
Changes in 0.7.3 (2018-08-27)
|
||||
===============================================
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#import "EventFormatter.h"
|
||||
|
||||
#import "AvatarGenerator.h"
|
||||
#import "Tools.h"
|
||||
|
||||
static NSAttributedString *timestampVerticalWhitespace = nil;
|
||||
static NSAttributedString *readReceiptVerticalWhitespace = nil;
|
||||
|
@ -194,12 +195,7 @@ static NSAttributedString *readReceiptVerticalWhitespace = nil;
|
|||
if (selectedComponentIndex != NSNotFound && selectedComponentIndex != index && componentString.length)
|
||||
{
|
||||
// Apply alpha to blur this component
|
||||
NSMutableAttributedString *customComponentString = [[NSMutableAttributedString alloc] initWithAttributedString:componentString];
|
||||
UIColor *color = [componentString attribute:NSForegroundColorAttributeName atIndex:0 effectiveRange:nil];
|
||||
color = [color colorWithAlphaComponent:0.2];
|
||||
|
||||
[customComponentString addAttribute:NSForegroundColorAttributeName value:color range:NSMakeRange(0, customComponentString.length)];
|
||||
componentString = customComponentString;
|
||||
componentString = [Tools setTextColorAlpha:.2 inAttributedString:componentString];
|
||||
}
|
||||
|
||||
// Check whether the timestamp is displayed for this component, and check whether a vertical whitespace is required
|
||||
|
@ -238,12 +234,7 @@ static NSAttributedString *readReceiptVerticalWhitespace = nil;
|
|||
if (selectedComponentIndex != NSNotFound && selectedComponentIndex != index && componentString.length)
|
||||
{
|
||||
// Apply alpha to blur this component
|
||||
NSMutableAttributedString *customComponentString = [[NSMutableAttributedString alloc] initWithAttributedString:componentString];
|
||||
UIColor *color = [componentString attribute:NSForegroundColorAttributeName atIndex:0 effectiveRange:nil];
|
||||
color = [color colorWithAlphaComponent:0.2];
|
||||
|
||||
[customComponentString addAttribute:NSForegroundColorAttributeName value:color range:NSMakeRange(0, customComponentString.length)];
|
||||
componentString = customComponentString;
|
||||
componentString = [Tools setTextColorAlpha:.2 inAttributedString:componentString];
|
||||
}
|
||||
|
||||
// Check whether the timestamp is displayed
|
||||
|
|
|
@ -54,4 +54,15 @@
|
|||
*/
|
||||
+ (NSURL*)fixURLWithSeveralHashKeys:(NSURL*)url;
|
||||
|
||||
#pragma mark - String utilities
|
||||
|
||||
/**
|
||||
Change the alpha value of all text colors of an attibuted string.
|
||||
|
||||
@param alpha the alpha value to apply.
|
||||
@param attributedString the attributed string to update.
|
||||
@return a new attributed string.
|
||||
*/
|
||||
+ (NSAttributedString *)setTextColorAlpha:(CGFloat)alpha inAttributedString:(NSAttributedString*)attributedString;
|
||||
|
||||
@end
|
||||
|
|
|
@ -117,4 +117,29 @@
|
|||
return fixedURL;
|
||||
}
|
||||
|
||||
#pragma mark - String utilities
|
||||
|
||||
+ (NSAttributedString *)setTextColorAlpha:(CGFloat)alpha inAttributedString:(NSAttributedString*)attributedString
|
||||
{
|
||||
NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithAttributedString:attributedString];
|
||||
|
||||
// Check all attributes one by one
|
||||
[string enumerateAttributesInRange:NSMakeRange(0, attributedString.length) options:0 usingBlock:^(NSDictionary *attrs, NSRange range, BOOL *stop)
|
||||
{
|
||||
// Replace only colored texts
|
||||
if (attrs[NSForegroundColorAttributeName])
|
||||
{
|
||||
UIColor *color = attrs[NSForegroundColorAttributeName];
|
||||
color = [color colorWithAlphaComponent:0.2];
|
||||
|
||||
NSMutableDictionary *newAttrs = [NSMutableDictionary dictionaryWithDictionary:attrs];
|
||||
newAttrs[NSForegroundColorAttributeName] = color;
|
||||
|
||||
[string setAttributes:newAttrs range:range];
|
||||
}
|
||||
}];
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in a new issue