Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for showing info messages #51

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion MTStatusBarOverlay.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;


Expand Down Expand Up @@ -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;
Expand Down
24 changes: 24 additions & 0 deletions MTStatusBarOverlay.m
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@
#define kErrorText @"✗"
#define kErrorFontSize 19.f

// Text that is displayed in the info-Label
#define kInfoText @"☞"
#define kInfoFontSize 22.f


///////////////////////////////////////////////////////
Expand Down Expand Up @@ -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];
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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:
Expand Down