mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Tweak message send failed indicator.
This commit is contained in:
parent
5fc16c1d93
commit
19699fd45f
|
@ -2,17 +2,17 @@
|
|||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "message_send_failure@1x.png",
|
||||
"filename" : "error-20@1x.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "message_send_failure@2x.png",
|
||||
"filename" : "error-20@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "message_send_failure@3x.png",
|
||||
"filename" : "error-20@3x.png",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
BIN
Signal/Images.xcassets/message_send_failed.imageset/error-20@1x.png
vendored
Normal file
BIN
Signal/Images.xcassets/message_send_failed.imageset/error-20@1x.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 365 B |
BIN
Signal/Images.xcassets/message_send_failed.imageset/error-20@2x.png
vendored
Normal file
BIN
Signal/Images.xcassets/message_send_failed.imageset/error-20@2x.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 765 B |
BIN
Signal/Images.xcassets/message_send_failed.imageset/error-20@3x.png
vendored
Normal file
BIN
Signal/Images.xcassets/message_send_failed.imageset/error-20@3x.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.7 KiB |
Binary file not shown.
Before Width: | Height: | Size: 2.4 KiB |
Binary file not shown.
Before Width: | Height: | Size: 3.3 KiB |
|
@ -20,12 +20,15 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
@property (nonatomic) UIView *dateStrokeView;
|
||||
@property (nonatomic) UILabel *dateHeaderLabel;
|
||||
@property (nonatomic) AvatarImageView *avatarView;
|
||||
@property (nonatomic, nullable) UIImageView *sendFailureBadgeView;
|
||||
|
||||
@property (nonatomic, nullable) NSMutableArray<NSLayoutConstraint *> *viewConstraints;
|
||||
@property (nonatomic) BOOL isPresentingMenuController;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
|
||||
@implementation OWSMessageCell
|
||||
|
||||
// `[UIView init]` invokes `[self initWithFrame:...]`.
|
||||
|
@ -131,6 +134,15 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
return self.viewItem.interaction.interactionType == OWSInteractionType_OutgoingMessage;
|
||||
}
|
||||
|
||||
- (BOOL)shouldHavesendFailureBadge
|
||||
{
|
||||
if (![self.viewItem.interaction isKindOfClass:[TSOutgoingMessage class]]) {
|
||||
return NO;
|
||||
}
|
||||
TSOutgoingMessage *outgoingMessage = (TSOutgoingMessage *)self.viewItem.interaction;
|
||||
return outgoingMessage.messageState == TSOutgoingMessageStateFailed;
|
||||
}
|
||||
|
||||
#pragma mark - Load
|
||||
|
||||
- (void)loadForDisplayWithTransaction:(YapDatabaseReadTransaction *)transaction
|
||||
|
@ -158,13 +170,42 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
relation:NSLayoutRelationGreaterThanOrEqual],
|
||||
]];
|
||||
} else {
|
||||
[self.viewConstraints addObjectsFromArray:@[
|
||||
[self.messageBubbleView autoPinEdgeToSuperviewEdge:ALEdgeLeading
|
||||
withInset:self.conversationStyle.gutterLeading
|
||||
relation:NSLayoutRelationGreaterThanOrEqual],
|
||||
[self.messageBubbleView autoPinEdgeToSuperviewEdge:ALEdgeTrailing
|
||||
withInset:self.conversationStyle.gutterTrailing],
|
||||
]];
|
||||
if (self.shouldHavesendFailureBadge) {
|
||||
self.sendFailureBadgeView = [UIImageView new];
|
||||
self.sendFailureBadgeView.image =
|
||||
[self.sendFailureBadge imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
|
||||
self.sendFailureBadgeView.tintColor = [UIColor ows_destructiveRedColor];
|
||||
[self.contentView addSubview:self.sendFailureBadgeView];
|
||||
|
||||
CGFloat sendFailureBadgeBottomMargin
|
||||
= round(self.conversationStyle.lastTextLineAxis - self.sendFailureBadgeSize * 0.5f);
|
||||
[self.viewConstraints addObjectsFromArray:@[
|
||||
[self.messageBubbleView autoPinEdgeToSuperviewEdge:ALEdgeLeading
|
||||
withInset:self.conversationStyle.gutterLeading
|
||||
relation:NSLayoutRelationGreaterThanOrEqual],
|
||||
[self.sendFailureBadgeView autoPinLeadingToTrailingEdgeOfView:self.messageBubbleView
|
||||
offset:self.sendFailureBadgeSpacing],
|
||||
// V-align the "send failure" badge with the
|
||||
// last line of the text (if any, or where it
|
||||
// would be).
|
||||
[self.messageBubbleView autoPinEdge:ALEdgeBottom
|
||||
toEdge:ALEdgeBottom
|
||||
ofView:self.sendFailureBadgeView
|
||||
withOffset:sendFailureBadgeBottomMargin],
|
||||
[self.sendFailureBadgeView autoPinEdgeToSuperviewEdge:ALEdgeTrailing
|
||||
withInset:self.conversationStyle.gutterTrailing],
|
||||
[self.sendFailureBadgeView autoSetDimension:ALDimensionWidth toSize:self.sendFailureBadgeSize],
|
||||
[self.sendFailureBadgeView autoSetDimension:ALDimensionHeight toSize:self.sendFailureBadgeSize],
|
||||
]];
|
||||
} else {
|
||||
[self.viewConstraints addObjectsFromArray:@[
|
||||
[self.messageBubbleView autoPinEdgeToSuperviewEdge:ALEdgeLeading
|
||||
withInset:self.conversationStyle.gutterLeading
|
||||
relation:NSLayoutRelationGreaterThanOrEqual],
|
||||
[self.messageBubbleView autoPinEdgeToSuperviewEdge:ALEdgeTrailing
|
||||
withInset:self.conversationStyle.gutterTrailing],
|
||||
]];
|
||||
}
|
||||
}
|
||||
|
||||
[self updateDateHeader];
|
||||
|
@ -184,6 +225,24 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
}
|
||||
}
|
||||
|
||||
- (UIImage *)sendFailureBadge
|
||||
{
|
||||
UIImage *image = [UIImage imageNamed:@"message_send_failed"];
|
||||
OWSAssert(image);
|
||||
OWSAssert(image.size.width == self.sendFailureBadgeSize && image.size.height == self.sendFailureBadgeSize);
|
||||
return image;
|
||||
}
|
||||
|
||||
- (CGFloat)sendFailureBadgeSize
|
||||
{
|
||||
return 20.f;
|
||||
}
|
||||
|
||||
- (CGFloat)sendFailureBadgeSpacing
|
||||
{
|
||||
return 8.f;
|
||||
}
|
||||
|
||||
// * If cell is visible, lazy-load (expensive) view contents.
|
||||
// * If cell is not visible, eagerly unload view contents.
|
||||
- (void)ensureMediaLoadState
|
||||
|
@ -362,6 +421,10 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
cellSize.height += self.dateHeaderHeight;
|
||||
|
||||
if (self.shouldHavesendFailureBadge) {
|
||||
cellSize.width += self.sendFailureBadgeSize + self.sendFailureBadgeSpacing;
|
||||
}
|
||||
|
||||
cellSize = CGSizeCeil(cellSize);
|
||||
|
||||
return cellSize;
|
||||
|
@ -404,6 +467,9 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
self.avatarView.image = nil;
|
||||
[self.avatarView removeFromSuperview];
|
||||
|
||||
[self.sendFailureBadgeView removeFromSuperview];
|
||||
self.sendFailureBadgeView = nil;
|
||||
|
||||
[self hideMenuControllerIfNecessary];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
|
|
|
@ -79,7 +79,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
+ (UIColor *)ows_destructiveRedColor
|
||||
{
|
||||
return [UIColor colorWithRed:0.98639106750488281 green:0.10408364236354828 blue:0.33135244250297546 alpha:1.f];
|
||||
return [UIColor colorWithRed:255.f / 255.f green:38.f / 255.f blue:31.f / 255.f alpha:1.0f];
|
||||
}
|
||||
|
||||
+ (UIColor *)ows_errorMessageBorderColor
|
||||
|
|
Loading…
Reference in a new issue