- Update images
- Implement SubItemsView (NOT COMPLETED)
This commit is contained in:
1 parent
61604557dd
commit
967bf95336
37 files changed
+122
-17
No files matched your search
@@ -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;
|
||||
@@ -48,7 +49,7 @@ typedef NS_ENUM(NSInteger, TabBarPickerPosition) {
|
||||
*
|
||||
* @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.
|
||||
@@ -68,7 +69,7 @@ typedef NS_ENUM(NSInteger, TabBarPickerPosition) {
|
||||
*
|
||||
* @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.
|
||||
@@ -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,30 +10,41 @@
|
||||
#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
|
||||
|
||||
@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];
|
||||
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
|
||||
Reference in new issue
Block a user