Skip to content

Instantly share code, notes, and snippets.

@raulriera
Created October 9, 2014 14:16
Show Gist options
  • Save raulriera/efd82adad25f135f78c1 to your computer and use it in GitHub Desktop.
Save raulriera/efd82adad25f135f78c1 to your computer and use it in GitHub Desktop.
- (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