Permalink
Browse files

Add panels interface for phone idiom, adapt pad idiom

  • Loading branch information...
1 parent 4fae38f commit dc7c28183a4a6366ca7a7575c4fce18934c37a03 @vtourraine vtourraine committed Jan 15, 2013
Showing with 520 additions and 161 deletions.
  1. +3 −0 .gitmodules
  2. +1 −0 client-ios/Libraries/KSCustomUIPopover
  3. +2 −15 client-ios/MyTee/Classes/MTEAppDelegate.m
  4. +3 −11 client-ios/MyTee/Classes/MTELoginViewController.m
  5. +4 −2 client-ios/MyTee/Classes/MTESettingsViewController.m
  6. +2 −0 client-ios/MyTee/Classes/MTETShirt.h
  7. +25 −16 client-ios/MyTee/Classes/MTETShirt.m
  8. +1 −0 client-ios/MyTee/Classes/MTETShirtExplorer.h
  9. +19 −7 client-ios/MyTee/Classes/MTETShirtExplorer.m
  10. +0 −16 client-ios/MyTee/Classes/MTETShirtsFilterCell.h
  11. +0 −13 client-ios/MyTee/Classes/MTETShirtsFilterCell.m
  12. +1 −1 client-ios/MyTee/Classes/MTETShirtsFilterViewController.h
  13. +43 −41 client-ios/MyTee/Classes/MTETShirtsFilterViewController.m
  14. +3 −0 client-ios/MyTee/Classes/MTETShirtsViewController.h
  15. +51 −4 client-ios/MyTee/Classes/MTETShirtsViewController.m
  16. BIN client-ios/MyTee/Resources/Images/33-cabinet-b.png
  17. BIN client-ios/MyTee/Resources/Images/33-cabinet-b@2x.png
  18. BIN client-ios/MyTee/Resources/Images/33-cabinet-w.png
  19. BIN client-ios/MyTee/Resources/Images/33-cabinet-w@2x.png
  20. BIN client-ios/MyTee/Resources/Images/67-tshirt-b.png
  21. BIN client-ios/MyTee/Resources/Images/67-tshirt-b@2x.png
  22. BIN client-ios/MyTee/Resources/Images/67-tshirt-w.png
  23. BIN client-ios/MyTee/Resources/Images/67-tshirt-w@2x.png
  24. BIN client-ios/MyTee/Resources/Images/gear-mini-w.png
  25. BIN client-ios/MyTee/Resources/Images/gear-mini-w@2x.png
  26. BIN client-ios/MyTee/Resources/Images/linen-darker-bar-landscape.png
  27. BIN client-ios/MyTee/Resources/Images/linen-darker-bar-landscape@2x.png
  28. BIN client-ios/MyTee/Resources/Images/linen-darker-bar.png
  29. BIN client-ios/MyTee/Resources/Images/linen-darker-bar@2x.png
  30. BIN client-ios/MyTee/Resources/Images/lines-b.png
  31. BIN client-ios/MyTee/Resources/Images/lines-b@2x.png
  32. BIN client-ios/MyTee/Resources/Images/lines-w.png
  33. BIN client-ios/MyTee/Resources/Images/lines-w@2x.png
  34. BIN client-ios/MyTee/Resources/Images/wash-w.png
  35. BIN client-ios/MyTee/Resources/Images/wash-w@2x.png
  36. +188 −8 client-ios/MyTee/Resources/Storyboards/Storyboard_iPad.storyboard
  37. +52 −17 client-ios/MyTee/Resources/Storyboards/Storyboard_iPhone.storyboard
  38. +122 −10 client-ios/mytee.xcodeproj/project.pbxproj
View
@@ -13,3 +13,6 @@
[submodule "client-ios/Libraries/ECSlidingViewController"]
path = client-ios/Libraries/ECSlidingViewController
url = git://github.com/edgecase/ECSlidingViewController.git
+[submodule "client-ios/Libraries/KSCustomUIPopover"]
+ path = client-ios/Libraries/KSCustomUIPopover
+ url = git@github.com:Scianski/KSCustomUIPopover.git
@@ -30,6 +30,8 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"linen-nav-bar"] forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"linen-nav-bar-landscape"] forBarMetrics:UIBarMetricsLandscapePhone];
[[UINavigationBar appearance] setTitleTextAttributes:@{UITextAttributeTextColor : [UIColor whiteColor], UITextAttributeTextShadowColor : [UIColor blackColor]}];
+ [[UINavigationBar appearanceWhenContainedIn:[UIPopoverController class], nil] setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
+ [[UINavigationBar appearanceWhenContainedIn:[UIPopoverController class], nil] setBackgroundImage:nil forBarMetrics:UIBarMetricsLandscapePhone];
[[UIBarButtonItem appearance] setTintColor:[UIColor darkGrayColor]];
@@ -56,22 +58,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
MTETShirtsViewController * tshirtsViewController = (MTETShirtsViewController *)tshirtsNavController.topViewController;
slidingViewController.topViewController = tshirtsNavController;
-// UITabBarController * tabBarController = (UITabBarController*)self.window.rootViewController;
-// UINavigationController * navController0 = [tabBarController.viewControllers objectAtIndex:0];
-// MTETodayTShirtViewController * todayViewController = (MTETodayTShirtViewController*)navController0.topViewController;
-// UINavigationController * navController1 = [tabBarController.viewControllers objectAtIndex:1];
-// MTETShirtsViewController * tshirtsViewController = (MTETShirtsViewController*)navController1.topViewController;
-// UINavigationController * navController2 = [tabBarController.viewControllers objectAtIndex:2];
-// MTESettingsViewController * settingsViewController = (MTESettingsViewController*)navController2.topViewController;
-
-// UILocalNotification * localNotif = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
-// if (localNotif)
-// tabBarController.selectedIndex = [tabBarController.viewControllers indexOfObject:navController1];
-
tshirtsViewController.syncManager = self.syncManager;
-// settingsViewController.syncManager = syncManager;
-
-// todayViewController.managedObjectContext = self.managedObjectContext;
}
return YES;
@@ -20,27 +20,19 @@ - (void)viewDidLoad
{
[super viewDidLoad];
+ self.tableView.backgroundView = nil;
+ self.tableView.backgroundColor = [UIColor colorWithWhite:0.85 alpha:1];
+
self.emailTextField.text = [MTESyncManager emailFromKeychain];
self.passwordTextField.text = [MTESyncManager passwordFromKeychain];
}
-- (void)viewDidUnload
-{
- [super viewDidUnload];
-
- [self setEmailTextField:nil];
- [self setPasswordTextField:nil];
-}
-
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
-
[self.emailTextField becomeFirstResponder];
}
-#pragma mark - Table view data source
-
#pragma mark - Table view delegate
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
@@ -36,9 +36,11 @@ - (void)viewDidLoad
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
- UIBarButtonItem *spaceBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
- spaceBarButtonItem.width = 40;
+ UIBarButtonItem *spaceBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:[[UIView alloc] initWithFrame:CGRectMake(0, 0, 128, 1)]];
self.navigationItem.leftBarButtonItems = @[spaceBarButtonItem];
+
+ [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"linen-darker-bar"] forBarMetrics:UIBarMetricsDefault];
+ [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"linen-darker-bar-landscape"] forBarMetrics:UIBarMetricsLandscapePhone];
}
NSString * email = [MTESyncManager emailFromKeychain];
@@ -38,4 +38,6 @@
- (NSArray*)washsSortedByDate;
- (MTEWash*)mostRecentWash;
+- (NSUInteger)numberOfWearsSinceLastWash;
+
@end
@@ -30,42 +30,51 @@ @implementation MTETShirt
#pragma mark - Image paths
-+ (NSString*)pathToLocalImageWithIdentifier:(NSString*)identifier
++ (NSString *)pathToLocalImageDirectory
{
- NSString * directory = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject];
- return [directory stringByAppendingPathComponent:[NSString stringWithFormat:@"MTE_%@.jpg", identifier]];
+ return [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject];
}
-+ (NSString*)pathToMiniatureLocalImageWithIdentifier:(NSString*)identifier
++ (NSString *)pathToLocalImageWithIdentifier:(NSString*)identifier
{
- NSString * directory = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject];
- return [directory stringByAppendingPathComponent:[NSString stringWithFormat:@"MTE_%@_mini.jpg", identifier]];
+ return [[self pathToLocalImageDirectory] stringByAppendingPathComponent:[NSString stringWithFormat:@"MTE_%@.jpg", identifier]];
+}
+
++ (NSString *)pathToMiniatureLocalImageWithIdentifier:(NSString*)identifier
+{
+ return [[self pathToLocalImageDirectory] stringByAppendingPathComponent:[NSString stringWithFormat:@"MTE_%@_mini.jpg", identifier]];
}
#pragma mark - Wear/Wash
-- (NSArray*)wearsSortedByDate
+- (NSArray *)wearsSortedByDate
{
- NSSortDescriptor * sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"date" ascending:NO];
- return [self.wears sortedArrayUsingDescriptors:[NSArray arrayWithObject:sortDescriptor]];
+ return [self.wears sortedArrayUsingDescriptors:@[[NSSortDescriptor sortDescriptorWithKey:@"date" ascending:NO]]];
}
-- (MTEWear*)mostRecentWear
+- (MTEWear *)mostRecentWear
{
NSArray * wears = [self wearsSortedByDate];
- return ([wears count] == 0) ? nil : [wears objectAtIndex:0];
+ return ([wears count] == 0) ? nil : wears[0];
}
-- (NSArray*)washsSortedByDate
+- (NSArray *)washsSortedByDate
{
- NSSortDescriptor * sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"date" ascending:NO];
- return [self.washs sortedArrayUsingDescriptors:[NSArray arrayWithObject:sortDescriptor]];
+ return [self.washs sortedArrayUsingDescriptors:@[[NSSortDescriptor sortDescriptorWithKey:@"date" ascending:NO]]];
}
-- (MTEWash*)mostRecentWash
+- (MTEWash *)mostRecentWash
{
NSArray * washs = [self washsSortedByDate];
- return ([washs count] == 0) ? nil : [washs objectAtIndex:0];
+ return ([washs count] == 0) ? nil : washs[0];
+}
+
+- (NSUInteger)numberOfWearsSinceLastWash
+{
+ NSDate *mostRecentWashDate = [self mostRecentWash].date;
+ return [[[NSSet setWithArray:[self wearsSortedByDate]] objectsPassingTest:^BOOL(MTEWear *wear, BOOL *stop) {
+ return [wear.date compare:mostRecentWashDate];
+ }] count];
}
@end
@@ -12,6 +12,7 @@ FOUNDATION_EXPORT NSString *const kMTETShirtsFilterParameter;
typedef enum
{
MTETShirtsFilterAll = 0,
+ MTETShirtsFilterWear,
MTETShirtsFilterWash
} MTETShirtsFilterType;
@@ -9,6 +9,7 @@
#import "MTETShirtExplorer.h"
#import "MTETShirt.h"
+#import "MTEWear.h"
NSString *const kMTETShirtsFilterType = @"kMTETShirtsFilterType";
NSString *const kMTETShirtsFilterParameter = @"kMTETShirtsFilterParameter";
@@ -51,14 +52,25 @@ - (BOOL)updateData
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
NSUInteger filterType = [userDefaults integerForKey:kMTETShirtsFilterType];
- NSUInteger filterParameter = [userDefaults integerForKey:kMTETShirtsFilterParameter];
+ NSLog(@"%d", filterType);
if (filterType == MTETShirtsFilterWash)
- self.fetchedTShirts = [self.fetchedResultsController.fetchedObjects filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(MTETShirt *evaluatedObject, NSDictionary *bindings) {
- NSArray *orderedWashs = evaluatedObject.washsSortedByDate;
- NSDate *latestWash = ([orderedWashs count] > 0) ? [[orderedWashs objectAtIndex:0] date] : [NSDate dateWithTimeIntervalSince1970:0];
- NSSet *newerWears = [evaluatedObject.wears filteredSetUsingPredicate:[NSPredicate predicateWithFormat:@"date > %@", latestWash]];
- return [newerWears count] >= filterParameter;
- }]];
+ {
+ self.fetchedTShirts = [self.fetchedResultsController.fetchedObjects sortedArrayWithOptions:kNilOptions usingComparator:^NSComparisonResult(MTETShirt *tshirt1, MTETShirt *tshirt2) {
+ return [@([tshirt1 numberOfWearsSinceLastWash]) compare:@([tshirt2 numberOfWearsSinceLastWash])];
+ }];
+ }
+ else if (filterType == MTETShirtsFilterWear)
+ {
+ self.fetchedTShirts = [self.fetchedResultsController.fetchedObjects sortedArrayWithOptions:kNilOptions usingComparator:^NSComparisonResult(MTETShirt *tshirt1, MTETShirt *tshirt2) {
+ NSDate *tshirt1MostRecentWearDate = tshirt1.mostRecentWear.date;
+ if (!tshirt1MostRecentWearDate)
+ tshirt1MostRecentWearDate = [NSDate dateWithTimeIntervalSince1970:0];
+ NSDate *tshirt2MostRecentWearDate = tshirt2.mostRecentWear.date;
+ if (!tshirt2MostRecentWearDate)
+ tshirt2MostRecentWearDate = [NSDate dateWithTimeIntervalSince1970:0];
+ return [tshirt1MostRecentWearDate compare:tshirt2MostRecentWearDate];
+ }];
+ }
else
self.fetchedTShirts = self.fetchedResultsController.fetchedObjects;
@@ -1,16 +0,0 @@
-//
-// MTETShirtsFilterCell.h
-// mytee
-//
-// Created by Terenn on 9/17/12.
-// Copyright (c) 2012 Studio AMANgA. All rights reserved.
-//
-
-#import "MTESettingCell.h"
-
-@interface MTETShirtsFilterCell : MTESettingCell
-
-@property (nonatomic, weak) IBOutlet UIStepper *stepper;
-@property (nonatomic, weak) IBOutlet UILabel *label;
-
-@end
@@ -1,13 +0,0 @@
-//
-// MTETShirtsFilterCell.m
-// mytee
-//
-// Created by Terenn on 9/17/12.
-// Copyright (c) 2012 Studio AMANgA. All rights reserved.
-//
-
-#import "MTETShirtsFilterCell.h"
-
-@implementation MTETShirtsFilterCell
-
-@end
@@ -10,7 +10,7 @@
@protocol MTETShirtsFilterViewDelegate;
-@interface MTETShirtsFilterViewController : UITableViewController
+@interface MTETShirtsFilterViewController : UIViewController <UITableViewDataSource, UITableViewDelegate>
@property (nonatomic, weak) id <MTETShirtsFilterViewDelegate> delegate;
@@ -8,17 +8,14 @@
#import "MTETShirtsFilterViewController.h"
-#import "MTETShirtsFilterCell.h"
+#import "ECSlidingViewController.h"
#import "MTETShirtExplorer.h"
@interface MTETShirtsFilterViewController ()
+@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (assign, nonatomic) MTETShirtsFilterType filterType;
@property (assign, nonatomic) NSUInteger filterWashParameter;
-@property (strong, nonatomic) IBOutlet UIStepper *washParameterStepper;
-
-- (IBAction)dismiss:(id)sender;
-- (IBAction)washParameterStepperValueChanged:(UIStepper *)sender;
@end
@@ -28,69 +25,74 @@ - (void)viewDidLoad
{
[super viewDidLoad];
+ UIBarButtonItem *spaceBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:[[UIView alloc] initWithFrame:CGRectMake(0, 0, 110, 1)]];
+ self.navigationItem.rightBarButtonItems = @[spaceBarButtonItem];
+
+ if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
+ {
+ [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"linen-darker-bar"] forBarMetrics:UIBarMetricsDefault];
+ [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"linen-darker-bar-landscape"] forBarMetrics:UIBarMetricsLandscapePhone];
+ }
+
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
self.filterType = [userDefaults integerForKey:kMTETShirtsFilterType];
self.filterWashParameter = [userDefaults integerForKey:kMTETShirtsFilterParameter];
- self.tableView.backgroundView = [UIView new];
- UIImage * woodTexture = [UIImage imageNamed:(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) ? @"shelves-free-form" : @"shelves-free"];
- UIColor * woodColor = [UIColor colorWithPatternImage:woodTexture];
- [self.view setBackgroundColor:woodColor];
+ [self.tableView selectRowAtIndexPath:[NSIndexPath indexPathForItem:self.filterType inSection:0] animated:NO scrollPosition:UITableViewScrollPositionNone];
}
-- (void)viewWillAppear:(BOOL)animated
+#pragma mark - Table data source
+
+- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
- [super viewWillAppear:animated];
-
- MTETShirtsFilterCell *cell = (MTETShirtsFilterCell *)[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:MTETShirtsFilterWash]];
- cell.label.text = [NSString stringWithFormat:@"Wash (%d)", self.filterWashParameter];
- cell.stepper.value = self.filterWashParameter;
+ return 1;
+}
+
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
+{
+ return 3;
}
#pragma mark - Table view delegate
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
- MTETShirtsFilterCell *cell = (MTETShirtsFilterCell *)[super tableView:tableView cellForRowAtIndexPath:indexPath];
-
- if (self.filterType == indexPath.section)
- cell.accessoryType = UITableViewCellAccessoryCheckmark;
- else
- cell.accessoryType = UITableViewCellAccessoryNone;
+ UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MTEFilterCell"];
- if (indexPath.section == MTETShirtsFilterWash)
- cell.label.text = [NSString stringWithFormat:@"Wash (%d)", self.filterWashParameter];
+ switch (indexPath.row)
+ {
+ case MTETShirtsFilterAll:
+ cell.textLabel.text = @"All My T-Shirts";
+ cell.imageView.image = [UIImage imageNamed:@"33-cabinet-w"];
+ cell.imageView.highlightedImage = [UIImage imageNamed:@"33-cabinet-b"];
+ break;
+ case MTETShirtsFilterWear:
+ cell.textLabel.text = @"Wear";
+ cell.imageView.image = [UIImage imageNamed:@"67-tshirt-w"];
+ cell.imageView.highlightedImage = [UIImage imageNamed:@"67-tshirt-b"];
+ break;
+ case MTETShirtsFilterWash:
+ cell.textLabel.text = @"Wash";
+ cell.imageView.image = [UIImage imageNamed:@"wash-w"];
+ cell.imageView.highlightedImage = [UIImage imageNamed:@"wash-b"];
+ break;
+ }
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
- [tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:self.filterType]].accessoryType = UITableViewCellAccessoryNone;
- self.filterType = indexPath.section;
- [tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:self.filterType]].accessoryType = UITableViewCellAccessoryCheckmark;
-
- [tableView deselectRowAtIndexPath:indexPath animated:YES];
-}
-
-#pragma mark - Actions
-
-- (IBAction)dismiss:(id)sender
-{
+ self.filterType = indexPath.row;
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults setInteger:self.filterType forKey:kMTETShirtsFilterType];
- [userDefaults setInteger:self.filterWashParameter forKey:kMTETShirtsFilterParameter];
[userDefaults synchronize];
[self.delegate tshirtsFilterViewControllerDidChangeFilter:self];
- [self dismissViewControllerAnimated:YES completion:nil];
+ [self.slidingViewController resetTopView];
}
-- (IBAction)washParameterStepperValueChanged:(UIStepper *)sender
-{
- self.filterWashParameter = sender.value;
- ((MTETShirtsFilterCell *)[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:MTETShirtsFilterWash]]).label.text = [NSString stringWithFormat:@"Wash (%d)", self.filterWashParameter];
-}
+#pragma mark - Actions
@end
@@ -31,4 +31,7 @@
- (void)startSpinningAnimation;
- (IBAction)didPressSettingsBarButtonItem:(id)sender;
+- (IBAction)showFilterViewController:(id)sender;
+- (IBAction)showSettingsViewController:(id)sender;
+
@end
Oops, something went wrong.

0 comments on commit dc7c281

Please sign in to comment.