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
15 changes: 15 additions & 0 deletions ios/fabric/RNDateTimePickerComponentView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,21 @@ - (void) updateMeasurements {
}
CGSize size = [_dummyPicker sizeThatFits:UILayoutFittingCompressedSize];
size.width += 10;

// Workaround: sizeThatFits: returns incorrect height for
// UIDatePickerModeDateAndTime + UIDatePickerStyleInline (Apple bug).
// The returned height only accounts for the calendar, missing the time row.
if (@available(iOS 14.0, *)) {
if (_dummyPicker.datePickerMode == UIDatePickerModeDateAndTime &&
_dummyPicker.preferredDatePickerStyle == UIDatePickerStyleInline) {
UIDatePicker *timePicker = [UIDatePicker new];
timePicker.datePickerMode = UIDatePickerModeTime;
timePicker.preferredDatePickerStyle = UIDatePickerStyleInline;
CGSize timeSize = [timePicker sizeThatFits:UILayoutFittingCompressedSize];
size.height += timeSize.height;
}
}

auto newState = RNDateTimePickerState{RCTSizeFromCGSize(size)};
_state->updateState(std::move(newState));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@ class RNDateTimePickerComponentDescriptor final : public ConcreteComponentDescri

void adopt(ShadowNode& shadowNode) const override {
auto& pickerShadowNode = static_cast<RNDateTimePickerShadowNode&>(shadowNode);
auto& layoutableShadowNode = static_cast<YogaLayoutableShadowNode&>(pickerShadowNode);

auto state = std::static_pointer_cast<const RNDateTimePickerShadowNode::ConcreteState>(shadowNode.getState());
auto stateData = state->getData();

if(stateData.frameSize.width != 0 && stateData.frameSize.height != 0) {
layoutableShadowNode.setSize(Size{stateData.frameSize.width, stateData.frameSize.height});
if(stateData.frameSize.height != 0) {
pickerShadowNode.setMeasuredHeight(stateData.frameSize.height);
}

ConcreteComponentDescriptor::adopt(shadowNode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ class JSI_EXPORT RNDateTimePickerShadowNode final : public ConcreteViewShadowNod
traits.set(ShadowNodeTraits::Trait::LeafYogaNode);
return traits;
}

void setMeasuredHeight(float height) const {
auto style = yogaNode_.style();
style.setDimension(yoga::Dimension::Height, yoga::StyleSizeLength::points(height));
yogaNode_.setStyle(style);
yogaNode_.setDirty(true);
}
};

} // namespace react
Expand Down