Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class EnrichedTextInputView : AppCompatEditText {
val parametrizedStyles: ParametrizedStyles? = ParametrizedStyles(this)
var isDuringTransaction: Boolean = false
var isRemovingMany: Boolean = false
var scrollEnabled: Boolean = true

val mentionHandler: MentionHandler? = MentionHandler(this)
var htmlStyle: HtmlStyle = HtmlStyle(this, null)
Expand Down Expand Up @@ -139,6 +140,14 @@ class EnrichedTextInputView : AppCompatEditText {
return super.onTouchEvent(ev)
}

override fun canScrollVertically(direction: Int): Boolean {
return scrollEnabled
}

override fun canScrollHorizontally(direction: Int): Boolean {
return scrollEnabled
}

override fun onSelectionChanged(selStart: Int, selEnd: Int) {
super.onSelectionChanged(selStart, selEnd)
selection?.onSelection(selStart, selEnd)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@ class EnrichedTextInputViewManager : SimpleViewManager<EnrichedTextInputView>(),
view?.setFontStyle(style)
}

@ReactProp(name = "scrollEnabled")
override fun setScrollEnabled(view: EnrichedTextInputView, scrollEnabled: Boolean) {
view.scrollEnabled = scrollEnabled
}

override fun onAfterUpdateTransaction(view: EnrichedTextInputView) {
super.onAfterUpdateTransaction(view)
view.afterUpdateTransaction()
Expand Down
4 changes: 4 additions & 0 deletions ios/EnrichedTextInputView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,10 @@ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &
stylePropChanged = YES;
}

if(newViewProps.scrollEnabled != oldViewProps.scrollEnabled || textView.scrollEnabled != newViewProps.scrollEnabled) {
[textView setScrollEnabled:newViewProps.scrollEnabled];
}

folly::dynamic oldMentionStyle = oldViewProps.htmlStyle.mention;
folly::dynamic newMentionStyle = newViewProps.htmlStyle.mention;
if(oldMentionStyle != newMentionStyle) {
Expand Down
3 changes: 3 additions & 0 deletions src/EnrichedTextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ export interface EnrichedTextInputProps extends Omit<ViewProps, 'children'> {
autoCapitalize?: 'none' | 'sentences' | 'words' | 'characters';
htmlStyle?: HtmlStyle;
style?: ViewStyle | TextStyle;
scrollEnabled?: boolean;
onFocus?: () => void;
onBlur?: () => void;
onChangeText?: (e: NativeSyntheticEvent<OnChangeTextEvent>) => void;
Expand Down Expand Up @@ -192,6 +193,7 @@ export const EnrichedTextInput = ({
onEndMention,
onChangeSelection,
androidExperimentalSynchronousEvents = false,
scrollEnabled = true,
...rest
}: EnrichedTextInputProps) => {
const nativeRef = useRef<ComponentType | null>(null);
Expand Down Expand Up @@ -352,6 +354,7 @@ export const EnrichedTextInput = ({
androidExperimentalSynchronousEvents={
androidExperimentalSynchronousEvents
}
scrollEnabled={scrollEnabled}
{...rest}
/>
);
Expand Down
1 change: 1 addition & 0 deletions src/EnrichedTextInputNativeComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ export interface NativeProps extends ViewProps {
selectionColor?: ColorValue;
autoCapitalize?: string;
htmlStyle?: HtmlStyleInternal;
scrollEnabled?: boolean;

// event callbacks
onInputFocus?: DirectEventHandler<null>;
Expand Down
Loading