How to stop two finger touches on Screen - reactjs

i had used this library for the draggable view for items
react-native-draggable-gridview
in that library i don't know how to stop two finger touches on the screen ,
i tried so many stuff but i didn't succeed.
here is the my code for gridView :-
<GridView
keyExtractor={(item) => item.id}
contentContainerStyle={styles.dragContainer}
showsVerticalScrollIndicator={false}
data={dragdata}
numColumns={2}
renderItem={renderItem}
onReleaseCell={onReleaseCell}
disableIntervalMomentum={true}
/>
below i shred the errors of the code when user touch the screen with two finger.

Related

how to know when flatlist goes out of viewport in react native?

I have a screen which contains a list of items that is being shown using flatlist, th flatlist is as below :
<FlatList
scrollEnabled
removeClippedSubviews
windowSize={21}
stickySectionHeadersEnabled={false}
showsVerticalScrollIndicator={false}
keyExtractor={keyExtractor}
getItemLayout={getItemLayoutFun}
ListHeaderComponent={listFTUEHeader}
contentContainerStyle={{ flexGrow: 1 }}
data={DISCOVERY_SECTION_LIST}
renderItem={renderItem}
onRefresh={onRefresh}
refreshing={false}
viewabilityConfig={viewabilityConfig}
ListFooterComponent={EndOfListText}
onScroll={onScroll}
/>
I want to detect when the ListHeaderComponent is out of viewport or item[1] is at the top of the screen, accordingly I want to add a state.
I have read the documentation but could not find a way, hopefully would get any leads from here.
Any leads would be helpful, thank you in advance.
I'm in the exact same situation, so far i only could find a solution to check, if a specific item is in the viewport, but nothing about the ListHeaderComponent.
FlatList has a prop called onViewableItemsChanged which you can easily implement. When you scroll a FlatList, the items showing on the FlatList change. Then, this function is called, telling you what current viewableItems are and what changed items are.
See also this article for further explanation.
Maybe this helps you to get closer to a solution which works for you?!
I'm working on this as well and this is the best option I've found so far:
Get the height of the header
If you know the height on all screen sizes, create a variable to reuse
If not, use the onLayout prop to get the height
Use the onScroll callback and get the y offtset via event.nativeEvent.contentOffset.y
Did you ever end up finding another solution for this?

React Native: Disabling ScrollView's scroll when pressing on a nested View element

I am using a ScrollView to enable multiple pages in my application. On one page, I am trying to implement a custom made slider. However, I am facing problems as any sliding motion triggers the ScrollView to start changing pages.
In pseudo-code, it is something like this:
<ScrollView horizontal={true}>
<View style={styles.page}><Text>First Page</Text></View>
<View style={styles.page}>
<View style={styles.slider}>
<View style={styles.sliderRange}>
</View>
</View>
</View>
</ScrollView>
How can I disable this scroll when touching my custom Slider Range? I could probably manually reverse the ScrollView's scrolling effect by calculating and reversing X, but that seems like unnecessary effort.
Thanks!

Button On press is working only on certain areas of the button in React Native

Hi Everyone,
I am fetching a few buttons from an API and displaying them in a view according to their names. Each of them is displayed as
<TouchableHighlight style={styles.button} onPress={this.onBtnClick.bind(this, item.apiurl)} >
<Text style={styles.Text}{item.displayName}</Text>
</TouchableHighlight>
The button click is not working all over the button except for the last one. It only works on specific areas. I have modified UI is several ways for the first few and checked. It still remains the same.
Any suggestions/Improvements are appreciated.
It's because you're binding the onBtnClick function everytime you click your button.
Simple fix would be onPress={() => this.onBtnClick(item.apiurl)

Combining tap to dismiss keyboard, keyboard avoiding view, and submit button

I have a screen that has a large image with a text input and a button at the bottom. This screen essentially has three requirements:
When the user taps into the input, the input and button should be visible above the keyboard
The user should be able to tap the button to submit the text input
If the user taps anywhere outside of the input (including the button) the keyboard should be dismissed.
I've tried various solutions including using react-native-keyboard-aware-scroll-view but none of them work quite right. This particular library seems to eat taps, so you can't submit on the button press. Otherwise it's good.
The closest I've been able to come is by surrounding various screen elements with <TouchableWithoutFeedback onPress={Keyboard.dismiss}>. When I try to wrap the entire screen contents in <TouchableWithoutFeedback>, <KeyboardAvoidingView> stops working.
<KeyboardAvoidingView behavior="padding">
<TouchableWithoutFeedback onPress={Keyboard.dismiss}>
<Image source={require('./img.png')} />
</TouchableWithoutFeedback>
<TouchableWithoutFeedback onPress={Keyboard.dismiss}>
<View>
{error}
<Text>Search</Text>
<TextInput
value={this.state.search}
onChange={this.handleChange}
/>
<TouchableHighlight onPress={this.handleSubmit}>
<Text>SEARCH</Text>
</TouchableHighlight>
</View>
</TouchableWithoutFeedback>
</KeyboardAvoidingView>
This is the closest to a working solution, but it still has several problems. First of all, there doesn't seem to be way to add any additional height to KeyboardAvoidingView, so in some cases the button doesn't show above the keyboard. Second, in some cases if the screen is too tall the area underneath the button won't dismiss the keyboard on tap because there's nowhere to put a <TouchableWithoutFeedback> to hide it.
Is there a better way to display things to the user while the keyboard is up while allowing them to tap to dismiss the keyboard and still interact with some controls?
well I was able to solve this by adding
<KeyboardAwareScrollView
ref="scroller"
keyboardShouldPersistTaps={true}
>

React Native Swiping vertical ScrollViews to the left and right

I am building a book application in which I use the ScrollView component to render a chapter, so that I can be able to scroll up and down when reading the chapter.
I want to add the ability to swipe left and right between the chapters. How can I implement that? I have checked the documentation but couldn't find a way to implement it.
Set horizontal props to true in ScrollView Component
When true, the scroll view's children are arranged horizontally in a row instead of vertically in a column. The default value is false.
<ScrollView
contentContainerStyle={styles.contentContainer}>
horizontal={true}
</ScrollView>

Resources