Skip to content

Commit

Permalink
Bugfix: Make dashboard & clear button show/hide more intuitive
Browse files Browse the repository at this point in the history
This commit removes the toggling of the notification list in favor of
simply closing both the dashboard and application switcher when
either (1) clearing all notifications or (2) closing the dashboard.

The functionality now is as follows:

 - Swipe the top "Missed Notifications" bar to show the clear all
   notifications button.

 - When the clear all button is displayed, to "cancel" clearing mode
   simply tap the top "Missed Notifications bar to hide the button

 - To dismiss the notifications dashboard and the application
   switcher simultaneously simply tap the top
   "Missed Notifications" bar.

 - Pressing the home button at any point will work as expected
  • Loading branch information
timnovinger committed Jun 6, 2011
1 parent 813c60c commit 90582de
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 50 deletions.
9 changes: 5 additions & 4 deletions MNAlertDashboardViewController.h
Expand Up @@ -57,6 +57,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
UITableView *alertListView;

bool dashboardShowing;
bool isClearButtonVisible;

UIActionSheet* clearActionSheet;

Expand All @@ -70,8 +71,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
UILabel* numberOfPendingAlertsLabel;
UILabel* mobileNotifierTextLabel;
UIButton* showAlertsListViewButton;

bool isExpanded;
}

-(id)initWithDelegate:(id)__delegate;
Expand All @@ -80,10 +79,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-(void)fadeDashboardAway;
-(void)showDashboard;
-(void)clearDashboardPushed:(id)sender;
-(void)toggleAlertListView:(id)sender;
-(void)expandAlertListview;
-(void)refresh;
-(bool)isShowing;
-(void)addClearButton;
-(void)removeClearButton;
-(void)dismissSwitcher;
-(void)dismissSwitcherOrClearButton;

@property (nonatomic, retain) UIWindow *window;
@property (readwrite) bool dashboardShowing;
Expand Down
78 changes: 32 additions & 46 deletions MNAlertDashboardViewController.m
Expand Up @@ -94,7 +94,6 @@ -(id)initWithDelegate:(id)__delegate;
// Table View Data Source
tableViewDataSourceEditable = [[MNAlertTableViewDataSourceEditable alloc] initWithStyle:kMNAlertTableViewDataSourceTypePending
andDelegate:_delegate];

// Create the tableview
alertListView = [[UITableView alloc] initWithFrame:CGRectMake(0,54,320,332) style:UITableViewStylePlain];
alertListView.delegate = self;
Expand All @@ -104,11 +103,17 @@ -(id)initWithDelegate:(id)__delegate;
alertListView.hidden = NO;
alertListView.allowsSelection = YES;

// Create and wire up the button for showing and hiding the alertListView
// Create and wire up the button for showing and hiding the dashboard,
// and hiding the clear all button
showAlertsListViewButton = [UIButton buttonWithType:UIButtonTypeCustom];
showAlertsListViewButton.frame = CGRectMake(0,0,320,54);
[showAlertsListViewButton addTarget:self action:@selector(toggleAlertListView:)
forControlEvents:UIControlEventTouchUpInside];
[showAlertsListViewButton addTarget:self action:@selector(dismissSwitcherOrClearButton) forControlEvents:UIControlEventTouchUpInside];

// Wireup swiping to the right to display clear all button
UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(addClearButton)];
swipeRight.direction = UISwipeGestureRecognizerDirectionRight;
[window addGestureRecognizer:swipeRight];
[swipeRight release];

[window addSubview:backgroundImageView];
[window addSubview:logoImageView];
Expand All @@ -119,7 +124,6 @@ -(id)initWithDelegate:(id)__delegate;
[window addSubview:showAlertsListViewButton];

dashboardShowing = NO;
isExpanded = NO;

[self refresh];
}
Expand All @@ -131,12 +135,14 @@ -(void)addClearButton
{
// Make the clear all button appear
[window addSubview:clearAllButton];
isClearButtonVisible = YES;
}

-(void)removeClearButton
{
// Make the clear all button go away
[clearAllButton removeFromSuperview];
isClearButtonVisible = NO;
}

-(void)refresh
Expand Down Expand Up @@ -165,11 +171,23 @@ -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *
[self refresh];
}

-(void)dismissSwitcher:(id)sender
-(void)dismissSwitcher
{
[_delegate dismissSwitcher];
}

-(void)dismissSwitcherOrClearButton
{
if (isClearButtonVisible == NO)
{
[self dismissSwitcher];
}
else
{
[self removeClearButton];
}
}

-(void)toggleDashboard
{
if (dashboardShowing)
Expand Down Expand Up @@ -228,6 +246,13 @@ -(void)showDashboard
window.hidden = NO;
dashboardShowing = YES;

// Ensure that the clear all button
// never shows when we load the dashboard
if (isClearButtonVisible)
{
[self removeClearButton];
}

// Restore previously transformed elements
alertListView.transform = CGAffineTransformIdentity;

Expand All @@ -237,49 +262,10 @@ -(void)showDashboard
[UIView commitAnimations];
}

-(void)toggleAlertListView:(id)sender
{
[self refresh];
if (isExpanded)
{
[UIView beginAnimations:@"listDisappear" context:NULL];
[UIView setAnimationDuration:0.1];
[window setFrame:CGRectMake(0,0,320,385)];
[self addClearButton];
[UIView commitAnimations];

alertListView.hidden = NO;
isExpanded = !isExpanded;

NSLog(@"new frame:%f x %f", window.frame.size.width, window.frame.size.height);
}
else
{
[self expandAlertListView];
}
}

-(void)expandAlertListView
{
[self refresh];
[UIView beginAnimations:@"listAppear" context:NULL];
[UIView setAnimationDuration:0.1];
[window setFrame:CGRectMake(0,0,320,54)];
[self removeClearButton];
[UIView commitAnimations];

alertListView.hidden = YES;
isExpanded = YES;

NSLog(@"new frame:%f x %f", window.frame.size.width, window.frame.size.height);
}

-(void)clearDashboardPushed:(id)sender
{
// Clear notifications!
[_delegate clearPending];
// Hide the dashboard view
[self fadeDashboardDown];
[self dismissSwitcher];
}

-(void)animationDidStop:(NSString*)animationID didFinish:(NSNumber*)finished inContext:(id)context
Expand Down

0 comments on commit 90582de

Please sign in to comment.