From e070082f4a9e0676cfe526e056a790d285b6a2d8 Mon Sep 17 00:00:00 2001 From: Maarten Billemont Date: Mon, 21 Apr 2014 23:35:29 -0400 Subject: [PATCH] Restructured passwords UI a bit for a saner nav bar. --- External/Pearl | 2 +- .../ObjC/iOS/MPCombinedViewController.h | 1 + .../ObjC/iOS/MPCombinedViewController.m | 3 +- MasterPassword/ObjC/iOS/MPPasswordsSegue.m | 8 +- .../ObjC/iOS/MPPasswordsViewController.h | 4 +- .../ObjC/iOS/MPPasswordsViewController.m | 25 +++- MasterPassword/ObjC/iOS/MPPopdownSegue.m | 6 - .../ObjC/iOS/MPUsersViewController.m | 2 + MasterPassword/ObjC/iOS/Storyboard.storyboard | 133 +++++++++--------- 9 files changed, 96 insertions(+), 88 deletions(-) diff --git a/External/Pearl b/External/Pearl index 76449ca7..9a506ea9 160000 --- a/External/Pearl +++ b/External/Pearl @@ -1 +1 @@ -Subproject commit 76449ca7a47814189ffffd7f34053c390085d7d2 +Subproject commit 9a506ea9d153dfee48b6d67babf7d33e7aaa5982 diff --git a/MasterPassword/ObjC/iOS/MPCombinedViewController.h b/MasterPassword/ObjC/iOS/MPCombinedViewController.h index 8fe951f0..43762f46 100644 --- a/MasterPassword/ObjC/iOS/MPCombinedViewController.h +++ b/MasterPassword/ObjC/iOS/MPCombinedViewController.h @@ -24,5 +24,6 @@ typedef NS_ENUM(NSUInteger, MPCombinedMode) { @interface MPCombinedViewController : UIViewController @property(assign, nonatomic) MPCombinedMode mode; +@property(strong, nonatomic) IBOutlet UIView *usersView; @end diff --git a/MasterPassword/ObjC/iOS/MPCombinedViewController.m b/MasterPassword/ObjC/iOS/MPCombinedViewController.m index 1673410a..abaeb6c9 100644 --- a/MasterPassword/ObjC/iOS/MPCombinedViewController.m +++ b/MasterPassword/ObjC/iOS/MPCombinedViewController.m @@ -130,10 +130,10 @@ [self.usersVC setNeedsStatusBarAppearanceUpdate]; [self.usersVC.view setNeedsUpdateConstraints]; [self.usersVC.view setNeedsLayout]; - dbg(@"top layout length: %f", self.usersVC.topLayoutGuide.length); switch (self.mode) { case MPCombinedModeUserSelection: { + self.usersView.userInteractionEnabled = YES; [self.usersVC setActive:YES animated:animated]; if (_passwordsVC) { MPPasswordsSegue *segue = [[MPPasswordsSegue alloc] initWithIdentifier:@"passwords" source:_passwordsVC destination:self]; @@ -143,6 +143,7 @@ break; } case MPCombinedModePasswordSelection: { + self.usersView.userInteractionEnabled = NO; [self.usersVC setActive:NO animated:animated]; [self performSegueWithIdentifier:@"passwords" sender:@{ @"animated" : @(animated) }]; break; diff --git a/MasterPassword/ObjC/iOS/MPPasswordsSegue.m b/MasterPassword/ObjC/iOS/MPPasswordsSegue.m index 7e2f4b1f..5e3b0cb1 100644 --- a/MasterPassword/ObjC/iOS/MPPasswordsSegue.m +++ b/MasterPassword/ObjC/iOS/MPPasswordsSegue.m @@ -18,6 +18,7 @@ #import "MPPasswordsSegue.h" #import "MPPasswordsViewController.h" +#import "MPCombinedViewController.h" @implementation MPPasswordsSegue { } @@ -36,15 +37,16 @@ if ([self.destinationViewController isKindOfClass:[MPPasswordsViewController class]]) { __weak MPPasswordsViewController *passwordsVC = self.destinationViewController; + __weak MPCombinedViewController *combinedVC = self.sourceViewController; - [self.sourceViewController addChildViewController:passwordsVC]; - [[passwordsVC.parentViewController view] addSubview:passwordsVC.view]; + [combinedVC addChildViewController:passwordsVC]; + [combinedVC.view insertSubview:passwordsVC.view belowSubview:combinedVC.usersView]; passwordsVC.active = NO; [passwordsVC setActive:YES animated:self.animated completion:^(BOOL finished) { if (!finished) return; - [passwordsVC didMoveToParentViewController:passwordsVC.parentViewController]; + [passwordsVC didMoveToParentViewController:combinedVC]; }]; } else if ([self.sourceViewController isKindOfClass:[MPPasswordsViewController class]]) { __weak MPPasswordsViewController *passwordsVC = self.sourceViewController; diff --git a/MasterPassword/ObjC/iOS/MPPasswordsViewController.h b/MasterPassword/ObjC/iOS/MPPasswordsViewController.h index 7d964563..10c43afb 100644 --- a/MasterPassword/ObjC/iOS/MPPasswordsViewController.h +++ b/MasterPassword/ObjC/iOS/MPPasswordsViewController.h @@ -26,12 +26,9 @@ @property(strong, nonatomic) IBOutlet UISearchBar *passwordsSearchBar; @property(strong, nonatomic) IBOutlet NSLayoutConstraint *passwordsToBottomConstraint; @property(strong, nonatomic) IBOutlet NSLayoutConstraint *navigationBarToTopConstraint; -@property(strong, nonatomic) IBOutlet NSLayoutConstraint *navigationBarToPasswordsConstraint; @property(strong, nonatomic) IBOutlet NSLayoutConstraint *popdownToTopConstraint; -@property(strong, nonatomic) IBOutlet NSLayoutConstraint *popdownToNavigationBarConstraint; @property(strong, nonatomic) IBOutlet UIView *popdownView; @property(strong, nonatomic) IBOutlet UIView *popdownContainer; -@property (strong, nonatomic) IBOutlet UIBarButtonItem *actionBarButton; @property(assign, nonatomic) BOOL active; @@ -39,5 +36,6 @@ - (void)setActive:(BOOL)active animated:(BOOL)animated completion:(void (^)(BOOL finished))completion; - (IBAction)dismissPopdown:(id)sender; +- (IBAction)signOut:(id)sender; @end diff --git a/MasterPassword/ObjC/iOS/MPPasswordsViewController.m b/MasterPassword/ObjC/iOS/MPPasswordsViewController.m index 8bfa6708..7e45dc64 100644 --- a/MasterPassword/ObjC/iOS/MPPasswordsViewController.m +++ b/MasterPassword/ObjC/iOS/MPPasswordsViewController.m @@ -24,6 +24,7 @@ #import "MPPasswordSmallCell.h" #import "UIColor+Expanded.h" #import "MPPopdownSegue.h" +#import "MPAppDelegate_Key.h" @interface MPPasswordsViewController() @@ -52,12 +53,12 @@ [super viewDidLoad]; _fetchedUpdates = [NSMutableDictionary dictionaryWithCapacity:4]; - _darkenedBackgroundColor = [(_backgroundColor = [UIColor colorWithRGBHex:0x1F2124]) colorByMultiplyingBy:0.7f]; + _backgroundColor = [UIColor clearColor]; + _darkenedBackgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.6f]; self.view.backgroundColor = [UIColor clearColor]; + self.passwordCollectionView.contentInset = UIEdgeInsetsMake( 108, 0, 0, 0 ); [self.passwordCollectionView automaticallyAdjustInsetsForKeyboard]; - - [self.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault]; } - (void)viewWillAppear:(BOOL)animated { @@ -496,7 +497,10 @@ NSManagedObjectID *activeUserOID = [MPiOSAppDelegate get].activeUserOID; if (!activeUserOID) { self.passwordsSearchBar.text = nil; - PearlMainQueue( ^{ [self.passwordCollectionView reloadData]; } ); + PearlMainQueue( ^{ + [self.passwordCollectionView reloadData]; + [self.passwordCollectionView setContentOffset:CGPointMake( 0, -self.passwordCollectionView.contentInset.top ) animated:YES]; + } ); return; } @@ -534,7 +538,11 @@ [self.passwordCollectionView reloadSections:[NSIndexSet indexSetWithIndex:section]]; } } - } completion:nil]; + } completion:^(BOOL finished) { + if (finished) + [self.passwordCollectionView setContentOffset:CGPointMake( 0, -self.passwordCollectionView.contentInset.top ) + animated:YES]; + }]; } ); }]; } @@ -575,11 +583,9 @@ _active = active; [UIView animateWithDuration:animated? 0.4f: 0 animations:^{ - self.navigationBarToPasswordsConstraint.priority = active? UILayoutPriorityDefaultHigh: 1; self.navigationBarToTopConstraint.priority = active? 1: UILayoutPriorityDefaultHigh; self.passwordsToBottomConstraint.priority = active? 1: UILayoutPriorityDefaultHigh; - [self.navigationBarToPasswordsConstraint apply]; [self.navigationBarToTopConstraint apply]; [self.passwordsToBottomConstraint apply]; } completion:completion]; @@ -595,4 +601,9 @@ self.popdownToTopConstraint.priority = UILayoutPriorityDefaultHigh; } +- (IBAction)signOut:(id)sender { + + [[MPiOSAppDelegate get] signOutAnimated:YES]; +} + @end diff --git a/MasterPassword/ObjC/iOS/MPPopdownSegue.m b/MasterPassword/ObjC/iOS/MPPopdownSegue.m index 57d1f842..f5a007da 100644 --- a/MasterPassword/ObjC/iOS/MPPopdownSegue.m +++ b/MasterPassword/ObjC/iOS/MPPopdownSegue.m @@ -39,9 +39,6 @@ [UIView animateWithDuration:0.3f animations:^{ passwordsVC.popdownToTopConstraint.priority = 1; - passwordsVC.popdownToNavigationBarConstraint.priority = UILayoutPriorityDefaultHigh; - - [passwordsVC.popdownToNavigationBarConstraint apply]; [passwordsVC.popdownToTopConstraint apply]; } completion:^(BOOL finished) { if (finished) @@ -55,9 +52,6 @@ [popdownVC willMoveToParentViewController:nil]; [UIView animateWithDuration:0.3f delay:0 options:UIViewAnimationOptionOverrideInheritedDuration animations:^{ passwordsVC.popdownToTopConstraint.priority = UILayoutPriorityDefaultHigh; - passwordsVC.popdownToNavigationBarConstraint.priority = 1; - - [passwordsVC.popdownToNavigationBarConstraint apply]; [passwordsVC.popdownToTopConstraint apply]; } completion:^(BOOL finished) { if (finished) { diff --git a/MasterPassword/ObjC/iOS/MPUsersViewController.m b/MasterPassword/ObjC/iOS/MPUsersViewController.m index 28216e22..b96fc415 100644 --- a/MasterPassword/ObjC/iOS/MPUsersViewController.m +++ b/MasterPassword/ObjC/iOS/MPUsersViewController.m @@ -474,6 +474,8 @@ typedef NS_ENUM(NSUInteger, MPActiveUserState) { - (void)updateAvatars { + self.previousAvatarButton.alpha = 0; + self.nextAvatarButton.alpha = 0; for (NSIndexPath *indexPath in self.avatarCollectionView.indexPathsForVisibleItems) [self updateAvatarAtIndexPath:indexPath]; } diff --git a/MasterPassword/ObjC/iOS/Storyboard.storyboard b/MasterPassword/ObjC/iOS/Storyboard.storyboard index 2ccf8dfb..078aa9a9 100644 --- a/MasterPassword/ObjC/iOS/Storyboard.storyboard +++ b/MasterPassword/ObjC/iOS/Storyboard.storyboard @@ -27,19 +27,6 @@ - - - - - - - - - - - - - @@ -316,27 +303,20 @@ - - - - - - - @@ -347,7 +327,6 @@ - @@ -363,8 +342,6 @@ - - @@ -437,6 +414,7 @@ + @@ -749,7 +727,7 @@ - + @@ -762,47 +740,29 @@ - - - - - - - - - - - - - - - - - + - - - - - - - - + - + + - + - + @@ -1104,7 +1064,7 @@ - + @@ -1137,7 +1097,7 @@ - + @@ -1175,23 +1135,62 @@ + + + + + + + + + - + + - + + - + + + + + + + + + + + + + + + + + + + + - + - + @@ -1201,8 +1200,8 @@ - - + + @@ -1236,17 +1235,19 @@ - + + - + - + + @@ -1257,10 +1258,10 @@ + - @@ -1268,7 +1269,6 @@ - @@ -1748,7 +1748,6 @@ -