messaging: add composing indicator
Change-Id: I1fab81ce01ec666887b48fb8bd09cd2d7c375e45
diff --git a/src/views/IMTableCellView.h b/src/views/IMTableCellView.h
index 463d2e1..be70887 100644
--- a/src/views/IMTableCellView.h
+++ b/src/views/IMTableCellView.h
@@ -38,6 +38,9 @@
@property (nonatomic, strong) IBOutlet NSImageView* messageFailed;
@property (nonatomic, strong) IBOutlet NSView* messageStatus;
@property (nonatomic, strong) IBOutlet NSButton* openImagebutton;
+@property (nonatomic, strong) IBOutlet NSView* compozingIndicator1;
+@property (nonatomic, strong) IBOutlet NSView* compozingIndicator2;
+@property (nonatomic, strong) IBOutlet NSView* compozingIndicator3;
- (uint64_t) interaction;
@@ -47,5 +50,7 @@
- (void) updateImageConstraint: (CGFloat) width andHeight: (CGFloat) height;
- (void) updateImageConstraintWithMax: (CGFloat) maxDimension;
- (void) invalidateImageConstraints;
-
+- (void) animateCompozingIndicator:(BOOL) animate;
+- (void) startBlinkAnimation:(NSView*) view withDelay:(CGFloat) delay;
+- (void) blinkAnimation: (NSView*) view;
@end
diff --git a/src/views/IMTableCellView.mm b/src/views/IMTableCellView.mm
index 7249695..ed252a7 100644
--- a/src/views/IMTableCellView.mm
+++ b/src/views/IMTableCellView.mm
@@ -20,6 +20,7 @@
#import "IMTableCellView.h"
#import "NSColor+RingTheme.h"
+#import <QuartzCore/QuartzCore.h>
@implementation IMTableCellView {
@@ -36,6 +37,7 @@
@synthesize progressIndicator;
@synthesize statusLabel;
@synthesize openImagebutton;
+@synthesize compozingIndicator2, compozingIndicator3, compozingIndicator1;
- (void) setupDirection
{
@@ -158,4 +160,42 @@
return interaction;
}
+- (void) animateCompozingIndicator: (BOOL) animate
+{
+ if (!animate) {
+ [[compozingIndicator1 layer] removeAllAnimations];
+ [[compozingIndicator2 layer] removeAllAnimations];
+ [[compozingIndicator3 layer] removeAllAnimations];
+ return;
+ }
+ [self startBlinkAnimation:compozingIndicator1 withDelay:0];
+ [self startBlinkAnimation:compozingIndicator2 withDelay:0.5];
+ [self startBlinkAnimation:compozingIndicator3 withDelay:1];
+}
+
+- (void) startBlinkAnimation:(NSView*) view withDelay:(CGFloat) delay {
+ [view setWantsLayer: YES];
+ view.layer.backgroundColor = [NSColor.ringDarkBlue CGColor];
+ view.layer.cornerRadius = 5;
+ view.layer.masksToBounds = true;
+ if (delay == 0) {
+ [self blinkAnimation:view];
+ return;
+ }
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, delay * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
+ [self blinkAnimation:view];
+ });
+}
+
+- (void) blinkAnimation:(NSView*) view {
+ CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"opacity"];
+ [animation setFromValue:[NSNumber numberWithFloat:1.0]];
+ [animation setToValue:[NSNumber numberWithFloat:0.2]];
+ [animation setDuration:0.7];
+ [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]];
+ [animation setAutoreverses:YES];
+ [animation setRepeatCount:HUGE_VALF];
+ [[view layer] addAnimation:animation forKey:@"opacity"];
+}
+
@end