- Update images

- Implement SubItemsView (NOT COMPLETED)
This commit is contained in:
Giuseppe Nucifora 2015-07-21 15:43:02 +02:00
parent 61604557dd
commit 967bf95336
37 changed files with 122 additions and 17 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 927 B

After

Width:  |  Height:  |  Size: 686 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 927 B

After

Width:  |  Height:  |  Size: 688 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 845 B

After

Width:  |  Height:  |  Size: 735 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 859 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 845 B

After

Width:  |  Height:  |  Size: 747 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 886 B

View File

@ -58,16 +58,16 @@
[allergen setImage:[UIImage imageNamed:@"allergen_off"]]; [allergen setImage:[UIImage imageNamed:@"allergen_off"]];
[allergen setSelectedImage:[UIImage imageNamed:@"allergen_on"]]; [allergen setSelectedImage:[UIImage imageNamed:@"allergen_on"]];
TabBarItem *allergen2 = [[TabBarItem alloc] initWithSubItems:@[subItem1,subItem2,subItem3,subItem4,subItem5,subItem6,subItem7]]; /*TabBarItem *allergen2 = [[TabBarItem alloc] initWithSubItems:@[subItem1,subItem2,subItem3,subItem4,subItem5,subItem6,subItem7]];
[allergen2 setItemName:@"Allergen"]; [allergen2 setItemName:@"Allergen"];
[allergen2 setImage:[UIImage imageNamed:@"allergen_off"]]; [allergen2 setImage:[UIImage imageNamed:@"allergen_off"]];
[allergen2 setSelectedImage:[UIImage imageNamed:@"allergen_on"]]; [allergen2 setSelectedImage:[UIImage imageNamed:@"allergen_on"]];
*/
tabbar = [[TabBarPicker alloc] initWithTabBarItems:@[location,calendar,type,price,allergen] forPosition:TabBarPickerPositionRight]; tabbar = [[TabBarPicker alloc] initWithTabBarItems:@[location,calendar,type,price,allergen] forPosition:TabBarPickerPositionBottom];
[tabbar setItemSpacing:2]; [tabbar setItemSpacing:2];
[tabbar setBackgroundColor:[UIColor whiteColor]]; [tabbar setBackgroundColor:[UIColor whiteColor]];
[tabbar addItem:allergen2]; //[tabbar addItem:allergen2];
} }
return self; return self;
} }
@ -93,7 +93,7 @@
- (void) viewDidAppear:(BOOL)animated { - (void) viewDidAppear:(BOOL)animated {
TabBarSubItem *subItem1 = [TabBarSubItem tabBarSubItemWithName:@"Peppe"]; /*TabBarSubItem *subItem1 = [TabBarSubItem tabBarSubItemWithName:@"Peppe"];
TabBarSubItem *subItem2 = [TabBarSubItem tabBarSubItemWithName:@"Peppe1"]; TabBarSubItem *subItem2 = [TabBarSubItem tabBarSubItemWithName:@"Peppe1"];
TabBarSubItem *subItem3 = [TabBarSubItem tabBarSubItemWithName:@"Peppe2"]; TabBarSubItem *subItem3 = [TabBarSubItem tabBarSubItemWithName:@"Peppe2"];
TabBarSubItem *subItem4 = [TabBarSubItem tabBarSubItemWithName:@"Peppe3"]; TabBarSubItem *subItem4 = [TabBarSubItem tabBarSubItemWithName:@"Peppe3"];
@ -108,7 +108,7 @@
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(4 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(4 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[tabbar addItem:allergen]; [tabbar addItem:allergen];
}); });*/
} }
- (void)didReceiveMemoryWarning - (void)didReceiveMemoryWarning

View File

@ -28,7 +28,6 @@
_orientation = [[UIDevice currentDevice] orientation]; _orientation = [[UIDevice currentDevice] orientation];
_itemButton = [[UIButton alloc] initForAutoLayout]; _itemButton = [[UIButton alloc] initForAutoLayout];
[_itemButton setBackgroundColor:[UIColor whiteColor]];
[self addSubview:_itemButton]; [self addSubview:_itemButton];
@ -47,6 +46,8 @@
//[_itemButton autoPinEdgesToSuperviewMargins]; //[_itemButton autoPinEdgesToSuperviewMargins];
[_itemButton autoCenterInSuperview]; [_itemButton autoCenterInSuperview];
[_itemButton autoMatchDimension:ALDimensionHeight toDimension:ALDimensionHeight ofView:self];
[_itemButton autoMatchDimension:ALDimensionWidth toDimension:ALDimensionWidth ofView:self];
} }

View File

@ -25,6 +25,7 @@ typedef NS_ENUM(NSInteger, TabBarPickerPosition) {
@property (nonatomic, readonly) CGSize tabBarSize; @property (nonatomic, readonly) CGSize tabBarSize;
@property (nonatomic, readonly) TabBarPickerPosition position; @property (nonatomic, readonly) TabBarPickerPosition position;
@property (nonatomic, readonly) NSLayoutRelation layoutRelation; @property (nonatomic, readonly) NSLayoutRelation layoutRelation;
@property (nonatomic) NSUInteger subItemPerRow;
@property (nonatomic) CGFloat paddingLeft; @property (nonatomic) CGFloat paddingLeft;
@property (nonatomic) CGFloat paddingRight; @property (nonatomic) CGFloat paddingRight;
@property (nonatomic) CGFloat paddingTop; @property (nonatomic) CGFloat paddingTop;
@ -48,7 +49,7 @@ typedef NS_ENUM(NSInteger, TabBarPickerPosition) {
* *
* @return raturn instance of TabBarPicker object. * @return raturn instance of TabBarPicker object.
*/ */
- (instancetype) initWithTabBarItems:(NSArray *)items forPosition:(TabBarPickerPosition)position; - (instancetype) initWithTabBarItems:(NSArray *) items forPosition:(TabBarPickerPosition) position;
/** /**
* Init TabBarPicker with items. When is selected an item the picher show down subitems. * Init TabBarPicker with items. When is selected an item the picher show down subitems.
@ -68,7 +69,7 @@ typedef NS_ENUM(NSInteger, TabBarPickerPosition) {
* *
* @return raturn instance of TabBarPicker object. * @return raturn instance of TabBarPicker object.
*/ */
- (instancetype) initWithTabBarItems:(NSArray *)items forPosition:(TabBarPickerPosition)position andNSLayoutRelation:(NSLayoutRelation) relation; - (instancetype) initWithTabBarItems:(NSArray *) items forPosition:(TabBarPickerPosition) position andNSLayoutRelation:(NSLayoutRelation) relation;
/** /**
* Init TabBarPicker with items. When is selected an item the picher show down subitems. * Init TabBarPicker with items. When is selected an item the picher show down subitems.
@ -91,6 +92,29 @@ typedef NS_ENUM(NSInteger, TabBarPickerPosition) {
*/ */
- (instancetype) initWithTabBarItems:(NSArray*) items withTabBarSize:(CGSize) size forPosition:(TabBarPickerPosition) position andNSLayoutRelation:(NSLayoutRelation) relation; - (instancetype) initWithTabBarItems:(NSArray*) items withTabBarSize:(CGSize) size forPosition:(TabBarPickerPosition) position andNSLayoutRelation:(NSLayoutRelation) relation;
/**
* Init TabBarPicker with items. When is selected an item the picher show down subitems.
* By default when one of more subItems are selected the selected item become selected.
* The picker size is dinamically based the max subitems of items
*
* @param items Represents tab bar items. That array cannot be nil.
*
* @param size Represents the tabbar size
*
* @param position Represents the posizion in the Screen:
* - TabBarPickerPositionLeft : Is positioned in vertical on left of the screen and shows the picker at its right
* - TabBarPickerPositionRight : Is positioned in vertical on right of the screen and shows the picker at its left
* - TabBarPickerPositionBottom : Is positioned in horizontal on bottom of the screen and shows the picker at its top
* - TabBarPickerPositionTop : Is positioned in horizontal on top of the screen and shows the picker at its bottom
*
* @param relation Represents NSLayoutRelation for TabBar layout.
*
* @param subItemsPerRow Represents the number of subItems per single row of subitem picker
*
* @return <#return value description#>
*/
- (instancetype) initWithTabBarItems:(NSArray*) items withTabBarSize:(CGSize) size forPosition:(TabBarPickerPosition) position andNSLayoutRelation:(NSLayoutRelation) relation subItemsPerRow:(NSUInteger) subItemsPerRow;
/** /**
* <#Description#> * <#Description#>
* *

View File

@ -10,30 +10,41 @@
#import <PureLayout/PureLayout.h> #import <PureLayout/PureLayout.h>
#import "TabBarPickerSubItemsView.h" #import "TabBarPickerSubItemsView.h"
#define DEFAULT_SUB_ITEMS_PER_ROW 2
@interface TabBarPicker() <TabBarItemDelegate> @interface TabBarPicker() <TabBarItemDelegate>
@property (nonatomic) UIDeviceOrientation orientation; @property (nonatomic) UIDeviceOrientation orientation;
@property (nonatomic) NSUInteger subItemRows;
@property (nonatomic, strong) TabBarPickerSubItemsView *subItemSelector;
@end @end
@implementation TabBarPicker @implementation TabBarPicker
- (instancetype) initWithTabBarItems:(NSArray *)items forPosition:(TabBarPickerPosition)position { - (instancetype) initWithTabBarItems:(NSArray *) items forPosition:(TabBarPickerPosition) position {
return [self initWithTabBarItems:items withTabBarSize:CGSizeZero forPosition:position andNSLayoutRelation:NSLayoutRelationEqual]; return [self initWithTabBarItems:items withTabBarSize:CGSizeZero forPosition:position andNSLayoutRelation:NSLayoutRelationEqual subItemsPerRow:DEFAULT_SUB_ITEMS_PER_ROW];
} }
- (instancetype) initWithTabBarItems:(NSArray *)items forPosition:(TabBarPickerPosition)position andNSLayoutRelation:(NSLayoutRelation)relation { - (instancetype) initWithTabBarItems:(NSArray *) items forPosition:(TabBarPickerPosition) position andNSLayoutRelation:(NSLayoutRelation) relation {
return [self initWithTabBarItems:items withTabBarSize:CGSizeZero forPosition:position andNSLayoutRelation:relation]; return [self initWithTabBarItems:items withTabBarSize:CGSizeZero forPosition:position andNSLayoutRelation:relation subItemsPerRow:DEFAULT_SUB_ITEMS_PER_ROW];
} }
- (instancetype) initWithTabBarItems:(NSArray*) items withTabBarSize:(CGSize) size forPosition:(TabBarPickerPosition) position andNSLayoutRelation:(NSLayoutRelation)relation { - (instancetype) initWithTabBarItems:(NSArray *) items withTabBarSize:(CGSize) size forPosition:(TabBarPickerPosition) position andNSLayoutRelation:(NSLayoutRelation) relation {
return [self initWithTabBarItems:items withTabBarSize:size forPosition:position andNSLayoutRelation:relation subItemsPerRow:DEFAULT_SUB_ITEMS_PER_ROW];
}
- (instancetype) initWithTabBarItems:(NSArray*) items withTabBarSize:(CGSize) size forPosition:(TabBarPickerPosition) position andNSLayoutRelation:(NSLayoutRelation) relation subItemsPerRow:(NSUInteger) subItemsPerRow {
self = [self initForAutoLayout]; self = [self initForAutoLayout];
if (self) { if (self) {
_subItemPerRow = subItemsPerRow;
_itemSpacing = 10; _itemSpacing = 10;
_paddingLeft = 0; _paddingLeft = 0;
_paddingRight = 0; _paddingRight = 0;
@ -58,6 +69,13 @@
for (NSObject *item in items) { for (NSObject *item in items) {
[self addItem:item]; [self addItem:item];
} }
if ([_tabBarItems count] > 0) {
_subItemSelector = [[TabBarPickerSubItemsView alloc] initWithTabBarItems:_tabBarItems];
[self addSubview:_subItemSelector];
}
} }
[self updateConstraintsIfNeeded]; [self updateConstraintsIfNeeded];
@ -136,6 +154,8 @@
} }
[self updateConstraintsIfNeeded]; [self updateConstraintsIfNeeded];
[_subItemSelector layoutSubviews];
} }
- (void) setPosition:(TabBarPickerPosition)position { - (void) setPosition:(TabBarPickerPosition)position {
@ -155,7 +175,6 @@
if (item && [item isKindOfClass:[TabBarItem class]]) { if (item && [item isKindOfClass:[TabBarItem class]]) {
[_tabBarItems addObject:item]; [_tabBarItems addObject:item];
[item setBackgroundColor:[UIColor lightGrayColor]];
[item setDelegate:self]; [item setDelegate:self];
[self addSubview:item]; [self addSubview:item];

View File

@ -7,8 +7,37 @@
// //
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import "TabBarItem.h"
@class TabBarPickerSubItemsView;
@protocol TabBarPickerSubItemsViewDelegate <NSObject>
@required
- (void) tabarPickerSubItemsView:(TabBarPickerSubItemsView*) tabarPickerSubItemsView didSelect:(TabBarItem*) item;
@end
@interface TabBarPickerSubItemsView : UIView @interface TabBarPickerSubItemsView : UIView
/**
* <#Description#>
*/
@property (nonatomic, strong) NSMutableArray *itemsArray;
/**
* <#Description#>
*/
@property (nonatomic, assign) id<TabBarItemDelegate> delegate;
/**
* <#Description#>
*
* @param items <#items description#>
*
* @return <#return value description#>
*/
- (instancetype) initWithTabBarItems:(NSArray *) items;
@end @end

View File

@ -11,13 +11,36 @@
@implementation TabBarPickerSubItemsView @implementation TabBarPickerSubItemsView
- (instancetype) init { - (instancetype) initWithTabBarItems:(NSArray *) items {
self = [self initForAutoLayout]; self = [self initForAutoLayout];
if (self) { if (self) {
_itemsArray = [[NSMutableArray alloc] initWithArray:items];
} }
[self updateConstraintsIfNeeded];
return self; return self;
} }
- (void) layoutSubviews {
if ([self.constraints count] > 0) {
[NSLayoutConstraint deactivateConstraints:self.constraints];
for (TabBarItem *item in _itemsArray) {
for (TabBarSubItem *subItem in item.subItems) {
[subItem.constraints autoRemoveConstraints];
}
}
}
[self autoMatchDimension:ALDimensionWidth toDimension:ALDimensionWidth ofView:self.superview withOffset:0 relation:NSLayoutRelationEqual];
[self autoSetDimension:ALDimensionHeight toSize:44];
[self autoConstrainAttribute:ALEdgeTop toAttribute:ALMarginTop ofView:self.superview withOffset:self.superview.frame.size.height];
}
@end @end

View File

@ -42,5 +42,14 @@
[self layoutSubviews]; [self layoutSubviews];
} }
- (void) layoutSubviews {
if ([self.constraints count] > 0) {
[NSLayoutConstraint deactivateConstraints:self.constraints];
}
}
@end @end