- Update images
- Implement SubItemsView (NOT COMPLETED)
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.2 KiB |
|
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 3.7 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 927 B After Width: | Height: | Size: 686 B |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 927 B After Width: | Height: | Size: 688 B |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.4 KiB |
|
Before Width: | Height: | Size: 845 B After Width: | Height: | Size: 735 B |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 859 B |
BIN
Example/Media.xcassets/type_on.imageset/type_on.png
vendored
|
Before Width: | Height: | Size: 845 B After Width: | Height: | Size: 747 B |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 886 B |
@ -58,16 +58,16 @@
|
||||
[allergen setImage:[UIImage imageNamed:@"allergen_off"]];
|
||||
[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 setImage:[UIImage imageNamed:@"allergen_off"]];
|
||||
[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 setBackgroundColor:[UIColor whiteColor]];
|
||||
|
||||
[tabbar addItem:allergen2];
|
||||
//[tabbar addItem:allergen2];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@ -93,7 +93,7 @@
|
||||
|
||||
- (void) viewDidAppear:(BOOL)animated {
|
||||
|
||||
TabBarSubItem *subItem1 = [TabBarSubItem tabBarSubItemWithName:@"Peppe"];
|
||||
/*TabBarSubItem *subItem1 = [TabBarSubItem tabBarSubItemWithName:@"Peppe"];
|
||||
TabBarSubItem *subItem2 = [TabBarSubItem tabBarSubItemWithName:@"Peppe1"];
|
||||
TabBarSubItem *subItem3 = [TabBarSubItem tabBarSubItemWithName:@"Peppe2"];
|
||||
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(), ^{
|
||||
[tabbar addItem:allergen];
|
||||
});
|
||||
});*/
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning
|
||||
|
||||
@ -28,7 +28,6 @@
|
||||
_orientation = [[UIDevice currentDevice] orientation];
|
||||
|
||||
_itemButton = [[UIButton alloc] initForAutoLayout];
|
||||
[_itemButton setBackgroundColor:[UIColor whiteColor]];
|
||||
|
||||
[self addSubview:_itemButton];
|
||||
|
||||
@ -47,6 +46,8 @@
|
||||
|
||||
//[_itemButton autoPinEdgesToSuperviewMargins];
|
||||
[_itemButton autoCenterInSuperview];
|
||||
[_itemButton autoMatchDimension:ALDimensionHeight toDimension:ALDimensionHeight ofView:self];
|
||||
[_itemButton autoMatchDimension:ALDimensionWidth toDimension:ALDimensionWidth ofView:self];
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -25,6 +25,7 @@ typedef NS_ENUM(NSInteger, TabBarPickerPosition) {
|
||||
@property (nonatomic, readonly) CGSize tabBarSize;
|
||||
@property (nonatomic, readonly) TabBarPickerPosition position;
|
||||
@property (nonatomic, readonly) NSLayoutRelation layoutRelation;
|
||||
@property (nonatomic) NSUInteger subItemPerRow;
|
||||
@property (nonatomic) CGFloat paddingLeft;
|
||||
@property (nonatomic) CGFloat paddingRight;
|
||||
@property (nonatomic) CGFloat paddingTop;
|
||||
@ -91,6 +92,29 @@ typedef NS_ENUM(NSInteger, TabBarPickerPosition) {
|
||||
*/
|
||||
- (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#>
|
||||
*
|
||||
|
||||
@ -10,9 +10,13 @@
|
||||
#import <PureLayout/PureLayout.h>
|
||||
#import "TabBarPickerSubItemsView.h"
|
||||
|
||||
#define DEFAULT_SUB_ITEMS_PER_ROW 2
|
||||
|
||||
@interface TabBarPicker() <TabBarItemDelegate>
|
||||
|
||||
@property (nonatomic) UIDeviceOrientation orientation;
|
||||
@property (nonatomic) NSUInteger subItemRows;
|
||||
@property (nonatomic, strong) TabBarPickerSubItemsView *subItemSelector;
|
||||
|
||||
@end
|
||||
|
||||
@ -20,20 +24,27 @@
|
||||
|
||||
- (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 {
|
||||
|
||||
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 {
|
||||
|
||||
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];
|
||||
if (self) {
|
||||
_subItemPerRow = subItemsPerRow;
|
||||
_itemSpacing = 10;
|
||||
_paddingLeft = 0;
|
||||
_paddingRight = 0;
|
||||
@ -58,6 +69,13 @@
|
||||
for (NSObject *item in items) {
|
||||
[self addItem:item];
|
||||
}
|
||||
|
||||
if ([_tabBarItems count] > 0) {
|
||||
|
||||
_subItemSelector = [[TabBarPickerSubItemsView alloc] initWithTabBarItems:_tabBarItems];
|
||||
|
||||
[self addSubview:_subItemSelector];
|
||||
}
|
||||
}
|
||||
|
||||
[self updateConstraintsIfNeeded];
|
||||
@ -136,6 +154,8 @@
|
||||
}
|
||||
|
||||
[self updateConstraintsIfNeeded];
|
||||
|
||||
[_subItemSelector layoutSubviews];
|
||||
}
|
||||
|
||||
- (void) setPosition:(TabBarPickerPosition)position {
|
||||
@ -155,7 +175,6 @@
|
||||
if (item && [item isKindOfClass:[TabBarItem class]]) {
|
||||
|
||||
[_tabBarItems addObject:item];
|
||||
[item setBackgroundColor:[UIColor lightGrayColor]];
|
||||
[item setDelegate:self];
|
||||
[self addSubview:item];
|
||||
|
||||
|
||||
@ -7,8 +7,37 @@
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TabBarItem.h"
|
||||
|
||||
@class TabBarPickerSubItemsView;
|
||||
|
||||
@protocol TabBarPickerSubItemsViewDelegate <NSObject>
|
||||
|
||||
@required
|
||||
|
||||
- (void) tabarPickerSubItemsView:(TabBarPickerSubItemsView*) tabarPickerSubItemsView didSelect:(TabBarItem*) item;
|
||||
|
||||
@end
|
||||
|
||||
@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
|
||||
|
||||
@ -11,13 +11,36 @@
|
||||
|
||||
@implementation TabBarPickerSubItemsView
|
||||
|
||||
- (instancetype) init {
|
||||
- (instancetype) initWithTabBarItems:(NSArray *) items {
|
||||
self = [self initForAutoLayout];
|
||||
|
||||
if (self) {
|
||||
|
||||
_itemsArray = [[NSMutableArray alloc] initWithArray:items];
|
||||
}
|
||||
|
||||
[self updateConstraintsIfNeeded];
|
||||
|
||||
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
|
||||
|
||||
@ -42,5 +42,14 @@
|
||||
[self layoutSubviews];
|
||||
}
|
||||
|
||||
- (void) layoutSubviews {
|
||||
|
||||
if ([self.constraints count] > 0) {
|
||||
|
||||
[NSLayoutConstraint deactivateConstraints:self.constraints];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||