Skip to content

Commit

Permalink
Implement ScrollView.keyboardDismissMode
Browse files Browse the repository at this point in the history
Summary: Changelog: [internal]

Reviewed By: shergin

Differential Revision: D24648120

fbshipit-source-id: 718be95dc87217fa6745535a3760ec23cc390444
  • Loading branch information
sammy-SC authored and facebook-github-bot committed Oct 30, 2020
1 parent 96ecad4 commit 0217c14
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@

static CGFloat const kClippingLeeway = 44.0;

static UIScrollViewKeyboardDismissMode RCTUIKeyboardDismissModeFromProps(ScrollViewProps const &props)
{
switch (props.keyboardDismissMode) {
case ScrollViewKeyboardDismissMode::None:
return UIScrollViewKeyboardDismissModeNone;
case ScrollViewKeyboardDismissMode::OnDrag:
return UIScrollViewKeyboardDismissModeOnDrag;
case ScrollViewKeyboardDismissMode::Interactive:
return UIScrollViewKeyboardDismissModeInteractive;
}
}

static void RCTSendPaperScrollEvent_DEPRECATED(UIScrollView *scrollView, NSInteger tag)
{
static uint16_t coalescingKey = 0;
Expand Down Expand Up @@ -150,7 +162,6 @@ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &
MAP_SCROLL_VIEW_PROP(decelerationRate);
MAP_SCROLL_VIEW_PROP(directionalLockEnabled);
// MAP_SCROLL_VIEW_PROP(indicatorStyle);
// MAP_SCROLL_VIEW_PROP(keyboardDismissMode);
MAP_SCROLL_VIEW_PROP(maximumZoomScale);
MAP_SCROLL_VIEW_PROP(minimumZoomScale);
MAP_SCROLL_VIEW_PROP(scrollEnabled);
Expand Down Expand Up @@ -219,6 +230,10 @@ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &
MAP_SCROLL_VIEW_PROP(disableIntervalMomentum);
MAP_SCROLL_VIEW_PROP(snapToInterval);

if (oldScrollViewProps.keyboardDismissMode != newScrollViewProps.keyboardDismissMode) {
scrollView.keyboardDismissMode = RCTUIKeyboardDismissModeFromProps(newScrollViewProps);
}

// MAP_SCROLL_VIEW_PROP(scrollIndicatorInsets);

[super updateProps:props oldProps:oldProps];
Expand Down

0 comments on commit 0217c14

Please sign in to comment.