Messages: Add a failed outgoing message cell

This commit is contained in:
dtsbourg 2014-11-27 13:10:49 +01:00 committed by Frederic Jacobs
parent 211e20aaf7
commit 9b5379b3e2
7 changed files with 33 additions and 11 deletions

View File

@ -83,7 +83,7 @@ EXTERNAL SOURCES:
CHECKOUT OPTIONS:
JSQMessagesViewController:
:commit: 5fc12f5cba461203046a6f0b2c62d1b1470197a4
:commit: b22b7a4caf2d36ff9965b1970fea968a46898f4c
:git: https://github.com/dtsbourg/JSQMessagesViewController
SocketRocket:
:commit: d0585af165

View File

@ -8,10 +8,15 @@
#import <UIKit/UIKit.h>
@interface UIColor (UIColor_OWS)
@interface UIColor (OWS)
+ (UIColor *) ows_blueColor;
+ (UIColor *) ows_fadedBlueColor;
+ (UIColor *) ows_darkBackgroundColor;
+ (UIColor *) ows_darkGrayColor;
+(UIColor*) ows_blueColor;
+(UIColor*) ows_darkBackgroundColor;
+(UIColor*) ows_darkGrayColor;
@end

View File

@ -8,22 +8,27 @@
#import "UIColor+OWS.h"
@implementation UIColor (UIColor_OWS)
@implementation UIColor (OWS)
+(UIColor*) ows_blueColor
+ (UIColor*) ows_blueColor
{
return [UIColor colorWithRed:0.f/255.f green:122.f/255.f blue:255.f/255.f alpha:1.0f];
}
+(UIColor*) ows_darkGrayColor
+ (UIColor*) ows_darkGrayColor
{
return [UIColor colorWithRed:81.f/255.f green:81.f/255.f blue:81.f/255.f alpha:1.0f];
}
+(UIColor*) ows_darkBackgroundColor
+ (UIColor*) ows_darkBackgroundColor
{
return [UIColor colorWithRed:35.0f/255.0f green:31.0f/255.0f blue:32.0f/255.0f alpha:1.0f];
}
+ (UIColor *) ows_fadedBlueColor
{
return [UIColor colorWithRed:110.f/255.f green:178.f/255.f blue:1.0f alpha:1.0f];
}
@end

View File

@ -45,7 +45,6 @@
[_challengeButton setEnabled:NO];
[_challengeTextField resignFirstResponder];
//TODO: Lock UI interactions
[self registerWithSuccess:^{
[Environment.getCurrent.phoneDirectoryManager forceUpdate];

View File

@ -49,6 +49,7 @@ typedef enum : NSUInteger {
@property (nonatomic, strong) YapDatabaseViewMappings *messageMappings;
@property (nonatomic, retain) JSQMessagesBubbleImage *outgoingBubbleImageData;
@property (nonatomic, retain) JSQMessagesBubbleImage *incomingBubbleImageData;
@property (nonatomic, retain) JSQMessagesBubbleImage *outgoingMessageFailedImageData;
@end
@ -74,6 +75,7 @@ typedef enum : NSUInteger {
self.outgoingBubbleImageData = [bubbleFactory outgoingMessagesBubbleImageWithColor:[UIColor jsq_messageBubbleBlueColor]];
self.incomingBubbleImageData = [bubbleFactory incomingMessagesBubbleImageWithColor:[UIColor jsq_messageBubbleLightGrayColor]];
self.outgoingMessageFailedImageData = [bubbleFactory outgoingMessageFailedBubbleImageWithColor:[UIColor ows_fadedBlueColor]];
self.messageMappings = [[YapDatabaseViewMappings alloc] initWithGroups:@[self.thread.uniqueId] view:TSMessageDatabaseViewExtensionName];
@ -191,6 +193,9 @@ typedef enum : NSUInteger {
id<JSQMessageData> message = [self messageAtIndexPath:indexPath];
if ([message.senderId isEqualToString:self.senderId]) {
if (message.messageState == TSOutgoingMessageStateUnsent || message.messageState == TSOutgoingMessageStateAttemptingOut) {
return self.outgoingMessageFailedImageData;
}
return self.outgoingBubbleImageData;
}

View File

@ -82,7 +82,6 @@
[self performSegueWithIdentifier:@"codeSent" sender:self];
} failure:^(NSURLSessionDataTask *task, NSError *error) {
//TODO: Re-enable button
DDLogError(@"Registration failed with information %@", error.description);
UIAlertView *registrationErrorAV = [[UIAlertView alloc]initWithTitle:REGISTER_ERROR_ALERT_VIEW_TITLE

View File

@ -30,6 +30,7 @@
@property (nonatomic, retain) NSString *messageBody;
@property NSUInteger identifier;
@property NSInteger outgoingMessageStatus;
@end
@ -74,6 +75,10 @@
adapter.messageBody = @"Placeholder for ErrorMessage";
}
if ([interaction isKindOfClass:[TSOutgoingMessage class]]) {
adapter.outgoingMessageStatus = ((TSOutgoingMessage*)interaction).messageState;
}
return adapter;
}
@ -109,4 +114,8 @@
return self.identifier;
}
- (NSInteger)messageState{
return self.outgoingMessageStatus;
}
@end