Skip to content

Commit

Permalink
Increase alert height against larger accessibility text sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
hellomalith committed Aug 23, 2024
1 parent 94ccd9d commit cec6013
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion ios/RNDatePickerManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,25 @@ - (UIView *)view

CGRect pickerBounds = picker.bounds;


// Detect the content size category
UIContentSizeCategory contentSize = UIApplication.sharedApplication.preferredContentSizeCategory;
int heightIncrement = 0;

// Adjust height based on content size category
if ([contentSize isEqualToString:UIContentSizeCategoryAccessibilityLarge]) {
heightIncrement = 15;
} else if ([contentSize isEqualToString:UIContentSizeCategoryAccessibilityExtraLarge]) {
heightIncrement = 40;
} else if ([contentSize isEqualToString:UIContentSizeCategoryAccessibilityExtraExtraLarge]) {
heightIncrement = 70;
} else if ([contentSize isEqualToString:UIContentSizeCategoryAccessibilityExtraExtraExtraLarge]) {
heightIncrement = 90;
}

// height
double pickerHeight = [self getPickerHeight:alertView];
int alertHeightPx = iPad ? (title ? 300 : 260) : (title ? 370 : 340);
int alertHeightPx = iPad ? (title ? 300 : 260) : (title ? 370 + heightIncrement : 340 + heightIncrement);
NSLayoutConstraint *height = [NSLayoutConstraint constraintWithItem:alertView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1 constant:alertHeightPx];
[alertView addConstraint:height];
pickerBounds.size.height = pickerHeight;
Expand Down

0 comments on commit cec6013

Please sign in to comment.