no message

This commit is contained in:
giuseppenuc committed 2015-08-20 11:56:47 +02:00
1 parent 3dc7c75b58
commit 9d5fa8835c
7 files changed
+159 -29

No files matched your search

+6
View File
@@ -379,6 +379,12 @@
}
#pragma mark -
#pragma mark TabBarPickerSubItemsViewDataSource
#pragma mark -
#pragma mark TabBarItemDelegate
+5 -4
View File
@@ -14,10 +14,11 @@
typedef NS_ENUM(NSInteger, TabBarPickerSubItemsViewType) {
// Informational
TabBarPickerSubItemsViewTypeData,
TabBarPickerSubItemsViewTypeString,
TabBarPickerSubItemsViewTypeButtons,
TabBarPickerSubItemsViewTypeCheckBox
TabBarPickerSubItemsViewTypeDistance,
TabBarPickerSubItemsViewTypeDateAndTime,
TabBarPickerSubItemsViewTypePrice,
TabBarPickerSubItemsViewTypeCheckBox,
TabBarPickerSubItemsViewTypeButton,
};
@protocol TabBarPickerSubItemsViewDelegate <NSObject>
+117 -8
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
+6 -2
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
+19 -10
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 {