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

Detail View User Interaction (Issue #4) #28

Closed
Closed
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
1 change: 1 addition & 0 deletions MTStatusBarOverlay.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ typedef enum MTMessageType {
// a detail-view that shows additional information. You can show a history of all the previous
// messages for free by setting historyEnabled to YES
@interface MTStatusBarOverlay : UIWindow <UITableViewDataSource> {
CGRect statusBarFrame_;
// holds all subviews, is touchable to change size of Status Bar
UIView *backgroundView_;
// the view that is shown in animation mode "FallDown" when the user touches the status bar
Expand Down
19 changes: 13 additions & 6 deletions MTStatusBarOverlay.m
Original file line number Diff line number Diff line change
Expand Up @@ -269,23 +269,23 @@ @implementation MTStatusBarOverlay

- (id)initWithFrame:(CGRect)frame {
if ((self = [super initWithFrame:frame])) {
CGRect statusBarFrame = [UIApplication sharedApplication].statusBarFrame;
statusBarFrame_ = [UIApplication sharedApplication].statusBarFrame;

// only use height of 20px even is status bar is doubled
statusBarFrame.size.height = statusBarFrame.size.height == 2*kStatusBarHeight ? kStatusBarHeight : statusBarFrame.size.height;
statusBarFrame_.size.height = statusBarFrame_.size.height == 2*kStatusBarHeight ? kStatusBarHeight : statusBarFrame_.size.height;
// if we are on the iPad but in iPhone-Mode (non-universal-app) correct the width
if(IsIPhoneEmulationMode) {
statusBarFrame.size.width = 320;
statusBarFrame_.size.width = 320;
}

// Place the window on the correct level and position
self.windowLevel = UIWindowLevelStatusBar+1.0f;
self.frame = statusBarFrame;
self.frame = statusBarFrame_;
self.alpha = 0.0f;
self.hidden = NO;

// Default Small size: just show Activity Indicator
smallFrame_ = CGRectMake(statusBarFrame.size.width - kWidthSmall, 0.0f, kWidthSmall, statusBarFrame.size.height);
smallFrame_ = CGRectMake(statusBarFrame_.size.width - kWidthSmall, 0.0f, kWidthSmall, statusBarFrame_.size.height);

// Default-values
animation_ = MTStatusBarOverlayAnimationNone;
Expand Down Expand Up @@ -336,7 +336,7 @@ - (id)initWithFrame:(CGRect)frame {
[self addSubview:detailView_];

// Create view that stores all the content
backgroundView_ = [[UIView alloc] initWithFrame:statusBarFrame];
backgroundView_ = [[UIView alloc] initWithFrame:statusBarFrame_];
backgroundView_.clipsToBounds = YES;
backgroundView_.autoresizingMask = UIViewAutoresizingFlexibleWidth;
oldBackgroundViewFrame_ = backgroundView_.frame;
Expand Down Expand Up @@ -938,6 +938,7 @@ - (void)setDetailViewHidden:(BOOL)hidden animated:(BOOL)animated {
animations: ^{
self.detailView.frame = CGRectMake(self.detailView.frame.origin.x, - self.detailView.frame.size.height,
self.detailView.frame.size.width, self.detailView.frame.size.height);
self.frame = statusBarFrame_;
}
completion:NULL];
}
Expand All @@ -956,14 +957,20 @@ - (void)setDetailViewHidden:(BOOL)hidden animated:(BOOL)animated {

self.historyTableView.frame = CGRectMake(self.historyTableView.frame.origin.x, kStatusBarHeight - y,
self.historyTableView.frame.size.width, self.historyTableView.frame.size.height);
self.frame = CGRectMake(statusBarFrame_.origin.x, statusBarFrame_.origin.y, statusBarFrame_.size.width,
MAX(statusBarFrame_.size.height, self.historyTableView.frame.size.height + kStatusBarHeight - y));
}

if (self.detailViewMode == MTDetailViewModeDetailText) {
self.detailView.frame = CGRectMake(self.detailView.frame.origin.x, y,
self.detailView.frame.size.width, self.detailTextView.frame.size.height + kStatusBarHeight);
self.frame = CGRectMake(statusBarFrame_.origin.x, statusBarFrame_.origin.y, statusBarFrame_.size.width,
MAX(statusBarFrame_.size.height, self.detailView.frame.size.height + y));
} else {
self.detailView.frame = CGRectMake(self.detailView.frame.origin.x, y,
self.detailView.frame.size.width, self.detailView.frame.size.height);
self.frame = CGRectMake(statusBarFrame_.origin.x, statusBarFrame_.origin.y, statusBarFrame_.size.width,
MAX(statusBarFrame_.size.height, self.detailView.frame.size.height + y));
}
}
completion:NULL];
Expand Down