Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions ios/RNDateTimePicker.m
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,21 @@ - (void)setDate:(NSDate *)date {
}
}

- (CGSize)intrinsicContentSize {
CGSize size = [super intrinsicContentSize];
// iOS DatePicker requires a minimum width of 280 points for proper display
// See: https://github.com/react-native-datetimepicker/datetimepicker/issues/1014
size.width = MAX(size.width, 280);

// For inline (calendar) display style, suggest a larger width
// This helps the calendar expand to fill available width
if (@available(iOS 14.0, *)) {
if (self.preferredDatePickerStyle == UIDatePickerStyleInline) {
size.width = MAX(size.width, 375); // Standard iPhone width
}
}

return size;
}

@end
25 changes: 24 additions & 1 deletion ios/RNDateTimePickerShadowView.m
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,30 @@ static YGSize RNDateTimePickerShadowViewMeasure(YGNodeConstRef node, float width
}

size = [shadowPickerView.picker sizeThatFits:UILayoutFittingCompressedSize];
size.width += 10;
// iOS DatePicker requires a minimum width of 280 points for proper display
// See: https://github.com/react-native-datetimepicker/datetimepicker/issues/1014
size.width = MAX(size.width, 280);

// Respect the provided width constraint to allow the picker to expand to full width
// when a specific width is provided or when measuring at-most mode
if (widthMode == YGMeasureModeExactly) {
size.width = width;
} else if (widthMode == YGMeasureModeAtMost) {
// For inline/calendar style, try to use the full available width
// For other styles, use the minimum width needed
if (@available(iOS 14.0, *)) {
if (shadowPickerView.picker.preferredDatePickerStyle == UIDatePickerStyleInline) {
size.width = width; // Use full available width for calendar
} else {
size.width = MIN(size.width + 10, width);
}
} else {
size.width = MIN(size.width + 10, width);
}
} else {
// For undefined mode, add small padding
size.width += 10;
}
});

return (YGSize){
Expand Down
19 changes: 18 additions & 1 deletion ios/fabric/RNDateTimePickerComponentView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,24 @@ - (void) updateMeasurements {
return;
}
CGSize size = [_dummyPicker sizeThatFits:UILayoutFittingCompressedSize];
size.width += 10;
// iOS DatePicker requires a minimum width of 280 points for proper display
// See: https://github.com/react-native-datetimepicker/datetimepicker/issues/1014
size.width = MAX(size.width, 280);

// For inline (calendar) display style, use a larger default width to fill the container
// The actual width will be constrained by the parent container's layout
if (@available(iOS 14.0, *)) {
if (_dummyPicker.preferredDatePickerStyle == UIDatePickerStyleInline) {
// Use a large width that will be constrained by the parent
// This allows the calendar to expand to full width of its container
size.width = 375; // Standard iPhone width, will be constrained by parent if smaller
} else {
size.width += 10;
}
} else {
size.width += 10;
}

auto newState = RNDateTimePickerState{RCTSizeFromCGSize(size)};
_state->updateState(std::move(newState));
}
Expand Down