From 089636f3f839b278835aa33047caf93280dba1a8 Mon Sep 17 00:00:00 2001 From: Raymond Penners Date: Tue, 8 May 2012 10:57:57 +0200 Subject: [PATCH] Added support for showing info messages --- MTStatusBarOverlay.h | 6 +++++- MTStatusBarOverlay.m | 24 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/MTStatusBarOverlay.h b/MTStatusBarOverlay.h index 5a7ca0b..dae45a5 100755 --- a/MTStatusBarOverlay.h +++ b/MTStatusBarOverlay.h @@ -46,7 +46,8 @@ typedef enum MTDetailViewMode { typedef enum MTMessageType { MTMessageTypeActivity, // shows actvity indicator MTMessageTypeFinish, // shows checkmark - MTMessageTypeError // shows error-mark + MTMessageTypeError, // shows error-mark + MTMessageTypeInfo // shows informational-mark } MTMessageType; @@ -155,6 +156,9 @@ typedef enum MTMessageType { // clears the message queue and shows this message instantly - (void)postImmediateFinishMessage:(NSString *)message duration:(NSTimeInterval)duration animated:(BOOL)animated; +// clears the message queue and shows this message instantly +- (void)postImmediateInfoMessage:(NSString *)message duration:(NSTimeInterval)duration animated:(BOOL)animated; + // shows a error-sign instead of the activity indicator and hides the status bar after the specified duration - (void)postErrorMessage:(NSString *)message duration:(NSTimeInterval)duration; - (void)postErrorMessage:(NSString *)message duration:(NSTimeInterval)duration animated:(BOOL)animated; diff --git a/MTStatusBarOverlay.m b/MTStatusBarOverlay.m index 20bb465..e6ef3eb 100755 --- a/MTStatusBarOverlay.m +++ b/MTStatusBarOverlay.m @@ -132,6 +132,9 @@ #define kErrorText @"✗" #define kErrorFontSize 19.f +// Text that is displayed in the info-Label +#define kInfoText @"☞" +#define kInfoFontSize 22.f /////////////////////////////////////////////////////// @@ -538,6 +541,10 @@ - (void)postImmediateFinishMessage:(NSString *)message duration:(NSTimeInterval) [self postImmediateMessage:message type:MTMessageTypeFinish duration:duration animated:animated]; } +- (void)postImmediateInfoMessage:(NSString *)message duration:(NSTimeInterval)duration animated:(BOOL)animated { + [self postImmediateMessage:message type:MTMessageTypeInfo duration:duration animated:animated]; +} + - (void)postErrorMessage:(NSString *)message duration:(NSTimeInterval)duration { [self postErrorMessage:message duration:duration animated:YES]; } @@ -1176,6 +1183,7 @@ - (void)setColorSchemeForStatusBarStyle:(UIStatusBarStyle)style messageType:(MTM // set color of labels depending on messageType switch(messageType) { case MTMessageTypeFinish: + case MTMessageTypeInfo: self.statusLabel1.textColor = kLightThemeFinishedMessageTextColor; self.statusLabel2.textColor = kLightThemeFinishedMessageTextColor; self.finishedLabel.textColor = kLightThemeFinishedMessageTextColor; @@ -1218,6 +1226,7 @@ - (void)setColorSchemeForStatusBarStyle:(UIStatusBarStyle)style messageType:(MTM // set color of labels depending on messageType switch(messageType) { case MTMessageTypeFinish: + case MTMessageTypeInfo: self.statusLabel1.textColor = kDarkThemeFinishedMessageTextColor; self.statusLabel2.textColor = kDarkThemeFinishedMessageTextColor; self.finishedLabel.textColor = kDarkThemeFinishedMessageTextColor; @@ -1281,6 +1290,21 @@ - (void)updateUIForMessageType:(MTMessageType)messageType duration:(NSTimeInterv // update font and text self.finishedLabel.font = [UIFont fontWithName:@"HelveticaNeue-Bold" size:kFinishedFontSize]; self.finishedLabel.text = kFinishedText; + self.progress = 1.0; + break; + case MTMessageTypeInfo: + // will call hide after delay + self.hideInProgress = YES; + // show finished-label, hide acitvity indicator + self.finishedLabel.hidden = self.hidesActivity; + self.activityIndicator.hidden = YES; + + // stop activity indicator + [self.activityIndicator stopAnimating]; + + // update font and text + self.finishedLabel.font = [UIFont fontWithName:@"HelveticaNeue-Bold" size:kFinishedFontSize]; + self.finishedLabel.text = kInfoText; self.progress = 1.0; break; case MTMessageTypeError: