Created
October 9, 2014 14:16
-
-
Save raulriera/efd82adad25f135f78c1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)tableViewEnabled:(BOOL)enabled withBlock:(void (^)(void))block | |
{ | |
if (enabled) { | |
[self transitionView:^{ | |
self.tableView.alpha = 1; | |
_minMaxNightsHeightConstraint.constant = 0; | |
[_minMaxStayLabel resetStyle]; | |
_minMaxStayLabel.text = @""; | |
if (block) { | |
block(); | |
} | |
}]; | |
} | |
else { | |
[self transitionView:^{ | |
_minMaxStayLabel.hidden = NO; | |
if (self.availability.stayRuleViolations.count > 0) { | |
_minMaxStayLabel.text = self.availability.stayRuleViolations[0][@"description"]; | |
} | |
if (self.availability.availableRooms.count == 0) { | |
_minMaxStayLabel.text = [NSString stringWithFormat:NSLocalizedString(@"NO_AVAILABLE_ROOMS", nil)]; | |
} | |
_minMaxNightsHeightConstraint.constant = 30; | |
self.tableView.alpha = 0.3; | |
[_minMaxStayLabel emphasiseStyle]; | |
if (block) { | |
block(); | |
} | |
}]; | |
} | |
self.tableView.userInteractionEnabled = enabled; | |
} | |
- (void)transitionView:(void (^)(void))block | |
{ | |
[UIView animateWithDuration:0.2f delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{ | |
if (block) { | |
block(); | |
} | |
[self.view layoutIfNeeded]; | |
} completion:nil]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment