From fda11f9c00db7c7eeb2722709d69a32fa84cce21 Mon Sep 17 00:00:00 2001 From: Malith Thilakarathne <153902797+hellomalith@users.noreply.github.com> Date: Sun, 25 Aug 2024 18:04:37 +0200 Subject: [PATCH] fix(accessibility): adapt font size on iOS modal --- ios/RNDatePickerManager.mm | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/ios/RNDatePickerManager.mm b/ios/RNDatePickerManager.mm index d69f00e0..ec3d30e0 100644 --- a/ios/RNDatePickerManager.mm +++ b/ios/RNDatePickerManager.mm @@ -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;