no message

This commit is contained in:
Giuseppe Nucifora 2015-08-20 11:56:47 +02:00
parent 3dc7c75b58
commit 9d5fa8835c
7 changed files with 159 additions and 29 deletions

View File

@ -4,6 +4,7 @@ use_frameworks!
inhibit_all_warnings!
pod 'PureLayout'
pod 'pop', '~> 1.0'
pod 'UIView-Overlay'
pod 'UIActionSheet-Blocks'
pod 'UIAlertViewBlockExtension'

View File

@ -32,7 +32,7 @@
TabBarSubItem *subItem6 = [TabBarSubItem tabBarSubItemWithName:@"Peppe5" andValue:@"Peppe5"];
TabBarSubItem *subItem7 = [TabBarSubItem tabBarSubItemWithName:@"Peppe6" andValue:@"Peppe6"];
TabBarPickerSubItemsView *locationSubview = [[TabBarPickerSubItemsView alloc] initWithType:TabBarPickerSubItemsViewTypeButtons subItems:@[subItem1,subItem2,subItem3,subItem4,subItem5,subItem6,subItem7] needsLocalization:YES];
TabBarPickerSubItemsView *locationSubview = [[TabBarPickerSubItemsView alloc] initWithType:TabBarPickerSubItemsViewTypeDistance subItems:@[subItem1,subItem2,subItem3,subItem4,subItem5,subItem6,subItem7] needsLocalization:YES];
TabBarItem *location = [[TabBarItem alloc] initWithSubItemView:locationSubview];
[location setItemName:@"Location"];
@ -40,7 +40,7 @@
[location setSelectedImage:[UIImage imageNamed:@"location_selected"]];
[location setHighlightedImage:[UIImage imageNamed:@"location_highlighted"]];
TabBarPickerSubItemsView *locationSubview1 = [[TabBarPickerSubItemsView alloc] initWithType:TabBarPickerSubItemsViewTypeButtons subItems:@[subItem1,subItem2,subItem3,subItem4,subItem5,subItem6,subItem7] needsLocalization:NO];
TabBarPickerSubItemsView *locationSubview1 = [[TabBarPickerSubItemsView alloc] initWithType:TabBarPickerSubItemsViewTypeDateAndTime subItems:@[subItem1,subItem2,subItem3,subItem4,subItem5,subItem6,subItem7] needsLocalization:NO];
TabBarItem *location1 = [[TabBarItem alloc] initWithSubItemView:locationSubview1];
[location1 setItemName:@"Location2"];
@ -48,7 +48,7 @@
[location1 setSelectedImage:[UIImage imageNamed:@"location_selected"]];
[location1 setHighlightedImage:[UIImage imageNamed:@"location_highlighted"]];
TabBarPickerSubItemsView *locationSubview2 = [[TabBarPickerSubItemsView alloc] initWithType:TabBarPickerSubItemsViewTypeButtons subItems:@[subItem1,subItem2,subItem3,subItem4,subItem5,subItem6,subItem7] needsLocalization:NO];
TabBarPickerSubItemsView *locationSubview2 = [[TabBarPickerSubItemsView alloc] initWithType:TabBarPickerSubItemsViewTypeCheckBox subItems:@[subItem1,subItem2,subItem3,subItem4,subItem5,subItem6,subItem7] needsLocalization:NO];
TabBarItem *location2 = [[TabBarItem alloc] initWithSubItemView:locationSubview2];
[location2 setItemName:@"Location3"];
@ -56,7 +56,7 @@
[location2 setSelectedImage:[UIImage imageNamed:@"location_selected"]];
[location2 setHighlightedImage:[UIImage imageNamed:@"location_highlighted"]];
TabBarPickerSubItemsView *locationSubview3 = [[TabBarPickerSubItemsView alloc] initWithType:TabBarPickerSubItemsViewTypeButtons subItems:@[subItem1,subItem2,subItem3,subItem4,subItem5,subItem6,subItem7] needsLocalization:NO];
TabBarPickerSubItemsView *locationSubview3 = [[TabBarPickerSubItemsView alloc] initWithType:TabBarPickerSubItemsViewTypePrice subItems:@[subItem1,subItem2,subItem3,subItem4,subItem5,subItem6,subItem7] needsLocalization:NO];
TabBarItem *location3 = [[TabBarItem alloc] initWithSubItemView:locationSubview3];
[location3 setItemName:@"Location4"];
@ -64,7 +64,7 @@
[location3 setSelectedImage:[UIImage imageNamed:@"location_selected"]];
[location3 setHighlightedImage:[UIImage imageNamed:@"location_highlighted"]];
TabBarPickerSubItemsView *locationSubview4 = [[TabBarPickerSubItemsView alloc] initWithType:TabBarPickerSubItemsViewTypeButtons subItems:@[subItem1,subItem2,subItem3,subItem4,subItem5,subItem6,subItem7] needsLocalization:NO];
TabBarPickerSubItemsView *locationSubview4 = [[TabBarPickerSubItemsView alloc] initWithType:TabBarPickerSubItemsViewTypeButton subItems:@[subItem1,subItem2,subItem3,subItem4,subItem5,subItem6,subItem7] needsLocalization:NO];
TabBarItem *location4 = [[TabBarItem alloc] initWithSubItemView:locationSubview4];
[location4 setItemName:@"Location5"];

View File

@ -379,6 +379,12 @@
}
#pragma mark -
#pragma mark TabBarPickerSubItemsViewDataSource
#pragma mark -
#pragma mark TabBarItemDelegate

View File

@ -14,10 +14,11 @@
typedef NS_ENUM(NSInteger, TabBarPickerSubItemsViewType) {
// Informational
TabBarPickerSubItemsViewTypeData,
TabBarPickerSubItemsViewTypeString,
TabBarPickerSubItemsViewTypeButtons,
TabBarPickerSubItemsViewTypeCheckBox
TabBarPickerSubItemsViewTypeDistance,
TabBarPickerSubItemsViewTypeDateAndTime,
TabBarPickerSubItemsViewTypePrice,
TabBarPickerSubItemsViewTypeCheckBox,
TabBarPickerSubItemsViewTypeButton,
};
@protocol TabBarPickerSubItemsViewDelegate <NSObject>

View File

@ -13,7 +13,7 @@
#import "SharedLocationManager.h"
#import "UIAlertView+BlockExtension.h"
@interface TabBarPickerSubItemsView()
@interface TabBarPickerSubItemsView() <UIPickerViewDataSource,UIPickerViewDelegate>
@property (nonatomic, assign) BOOL didSetupConstraints;
@property (nonatomic) TabBarPickerSubItemsViewType type;
@ -25,6 +25,10 @@
@property (nonatomic, strong) UIView *contentView;
@property (nonatomic, strong) NSString *name;
@property (nonatomic, strong) UIView *HUD;
@property (nonatomic, strong) UIPickerView *pickerView;
@end
@implementation TabBarPickerSubItemsView
@ -39,6 +43,15 @@
if (self) {
[self setUserInteractionEnabled:YES];
_subItems = [[NSMutableArray alloc] init];
for (NSObject *subItem in subItems) {
if ([subItem isKindOfClass:[TabBarSubItem class]]) {
[_subItems addObject:subItem];
}
}
_type = type;
_needsLocalization = needsLocalization;
_switchBarView = [[UIView alloc] initForAutoLayout];
@ -62,6 +75,40 @@
[self addSubview:_contentView];
_HUD = [[UIView alloc] initForAutoLayout];
[_HUD setAlpha:0];
[_HUD setBackgroundColor:[[UIColor whiteColor] colorWithAlphaComponent:0.25]];
[_contentView addSubview:_HUD];
switch (_type) {
case TabBarPickerSubItemsViewTypeDateAndTime: {
break;
}
case TabBarPickerSubItemsViewTypeCheckBox: {
break;
}
case TabBarPickerSubItemsViewTypeDistance: {
_pickerView = [[UIPickerView alloc] initForAutoLayout];
[_pickerView setDelegate:self];
[_pickerView setDataSource:self];
[_contentView addSubview:_pickerView];
break;
}
case TabBarPickerSubItemsViewTypePrice: {
break;
}
default: {
break;
}
}
if (_needsLocalization) {
_localizationView = [[UIView alloc] initForAutoLayout];
@ -96,11 +143,21 @@
- (void) layoutSubviews {
[UIView animateWithDuration:0.5 animations:^{
[_localizationView setAlpha:[[NSNumber numberWithBool:[[SharedLocationManager sharedManager] localizationIsAuthorized]] floatValue]];
[_itemSwich setUserInteractionEnabled:NO];
[_itemSwich setOn:NO];
}];
//NSAssert(_dataSource, @"TabBarPickerSubItemsView needs datasource");
if (_needsLocalization) {
[UIView animateWithDuration:0.5 animations:^{
[_localizationView setAlpha:[[NSNumber numberWithBool:![[SharedLocationManager sharedManager] localizationIsAuthorized]] floatValue]];
if ([[SharedLocationManager sharedManager] localizationIsAuthorized]) {
[_itemSwich setUserInteractionEnabled:[[SharedLocationManager sharedManager] localizationIsAuthorized]];
}
else {
[_itemSwich setUserInteractionEnabled:[[SharedLocationManager sharedManager] localizationIsAuthorized]];
[_itemSwich setOn:[[SharedLocationManager sharedManager] localizationIsAuthorized]];
}
}];
}
if (!_didSetupConstraints) {
@ -123,6 +180,11 @@
[_contentView autoPinEdge:ALEdgeBottom toEdge:ALEdgeBottom ofView:self];
[_contentView autoAlignAxisToSuperviewAxis:ALAxisVertical];
[_HUD autoMatchDimension:ALDimensionWidth toDimension:ALDimensionWidth ofView:_contentView];
[_HUD autoMatchDimension:ALDimensionHeight toDimension:ALDimensionHeight ofView:_contentView];
[_HUD autoAlignAxisToSuperviewAxis:ALAxisVertical];
[_HUD autoPinEdge:ALEdgeTop toEdge:ALEdgeTop ofView:_contentView];
if (_needsLocalization) {
[_localizationView autoPinEdge:ALEdgeTop toEdge:ALEdgeTop ofView:_contentView];
@ -136,6 +198,7 @@
[_localizationButton autoSetDimension:ALDimensionHeight toSize:44 relation:NSLayoutRelationLessThanOrEqual];
[_localizationButton autoMatchDimension:ALDimensionWidth toDimension:ALDimensionWidth ofView:self withMultiplier:0.8];
}
_didSetupConstraints = YES;
}
@ -172,12 +235,13 @@
- (void)changeSwitch:(UISwitch*)sender{
[_HUD setAlpha:[[NSNumber numberWithBool:![sender isOn]] floatValue]];
if([sender isOn]){
NSLog(@"Switch is ON");
} else{
NSLog(@"Switch is OFF");
}
}
- (void) touchesEnded: (NSSet *) touches withEvent: (UIEvent *) event
@ -191,7 +255,52 @@
}
- (void) setItemName:(NSString *) itemName {
[_switchBarLabel setText:itemName];
[_switchBarLabel setText:itemName];
}
#pragma mark UIPickerViewDataSource
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {
if ([_subItems count] > 0) {
[(TabBarSubItem*)[_subItems firstObject] numberOfValues];
}
return 0;
}
// returns the # of rows in each component..
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
}
#pragma mark -
#pragma mark UIPickerViewDelegate
/*
- (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component {
}
- (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component {
}
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
}
- (NSAttributedString *)pickerView:(UIPickerView *)pickerView attributedTitleForRow:(NSInteger)row forComponent:(NSInteger)component {
}
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view {
}
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
}
*/
#pragma mark -
@end

View File

@ -12,8 +12,12 @@
@property (nonatomic, strong) NSString *name;
@property (nonatomic, strong) UIButton *subItemButton;
@property (nonatomic, strong) id value;
@property (nonatomic, strong) id firstValue;
@property (nonatomic, strong) id secondValue;
+ (instancetype) tabBarSubItemWithName:(NSString*)name andValue:(id) value;;
+ (instancetype) tabBarSubItemWithName:(NSString*)name andValue:(id) value;
+ (instancetype) tabBarSubItemWithName:(NSString*)name firstValue:(id) firstValue secondValue:(id) secondValue;
- (NSUInteger) numberOfValues;
@end

View File

@ -19,23 +19,26 @@
@implementation TabBarSubItem
- (instancetype) initWithName:(NSString *) name andValue:(id)value {
- (instancetype) initWithName:(NSString *) name firstValue:(id)firstValue secondValue:(id) secondValue {
self = [self initForAutoLayout];
if (self) {
//[[NSNotificationCenter defaultCenter] addObserver: self selector:@selector(deviceOrientationDidChange:) name: UIDeviceOrientationDidChangeNotification object: nil];
_name = name;
_subItemButton = [[UIButton alloc] initForAutoLayout];
[_subItemButton setTitle:_name forState:UIControlStateNormal];
_value = value;
_firstValue = ( firstValue ? firstValue : @"");
_secondValue = ( secondValue ? secondValue : @"");
}
return self;
}
+ (instancetype) tabBarSubItemWithName:(NSString*)name andValue:(id)value {
return [[self alloc] initWithName:name andValue:value];
return [[self alloc] initWithName:name firstValue:value secondValue:nil];
}
+ (instancetype) initWithName:(NSString *) name firstValue:(id)firstValue secondValue:(id) secondValue {
return [[self alloc] initWithName:name firstValue:firstValue secondValue:secondValue];
}
- (void) setName:(NSString *)name {
@ -43,12 +46,18 @@
[_subItemButton setTitle:_name forState:UIControlStateNormal];
}
- (void)deviceOrientationDidChange:(NSNotification *)notification {
//Obtain current device orientation
_orientation = [[UIDevice currentDevice] orientation];
- (NSUInteger) numberOfValues {
NSUInteger response = 0;
[self layoutSubviews];
if (_firstValue) {
response++;
}
if (_secondValue) {
response++;
}
return response;
}
- (void) layoutSubviews {