Skip to content

Commit fda11f9

Browse files
hellomalithhenninghall
authored andcommitted
fix(accessibility): adapt font size on iOS modal
1 parent 94ccd9d commit fda11f9

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

ios/RNDatePickerManager.mm

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,25 @@ - (UIView *)view
7575

7676
CGRect pickerBounds = picker.bounds;
7777

78+
79+
// Detect the content size category
80+
UIContentSizeCategory contentSize = UIApplication.sharedApplication.preferredContentSizeCategory;
81+
int heightIncrement = 0;
82+
83+
// Adjust height based on content size category
84+
if ([contentSize isEqualToString:UIContentSizeCategoryAccessibilityLarge]) {
85+
heightIncrement = 15;
86+
} else if ([contentSize isEqualToString:UIContentSizeCategoryAccessibilityExtraLarge]) {
87+
heightIncrement = 40;
88+
} else if ([contentSize isEqualToString:UIContentSizeCategoryAccessibilityExtraExtraLarge]) {
89+
heightIncrement = 70;
90+
} else if ([contentSize isEqualToString:UIContentSizeCategoryAccessibilityExtraExtraExtraLarge]) {
91+
heightIncrement = 90;
92+
}
93+
7894
// height
7995
double pickerHeight = [self getPickerHeight:alertView];
80-
int alertHeightPx = iPad ? (title ? 300 : 260) : (title ? 370 : 340);
96+
int alertHeightPx = iPad ? (title ? 300 : 260) : (title ? 370 + heightIncrement : 340 + heightIncrement);
8197
NSLayoutConstraint *height = [NSLayoutConstraint constraintWithItem:alertView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1 constant:alertHeightPx];
8298
[alertView addConstraint:height];
8399
pickerBounds.size.height = pickerHeight;

0 commit comments

Comments
 (0)