react-native-collapsible close collapsible from any press - react-native

I am using react-native-collapsible for a project. Everything working well but I would like the user to be able to close the collapsible by clicking anywhere on the screen when it is opened. On a desktop it would be easy with a !event.target match but since I am new to React Native (expo) I am a bit out of solution.
Thanks a lot, I pasted no code because I am currently using the Lorem example from the lib so won't be much useful.

You can Make one useState variable and pass it into the property of
collapsed={Your useState Veriable} react-native-collapsible .
also make all the Design wrap into TouchableOpacity and it's onPress event to make it true.

Related

Components for only tabs in React-Native

I want to achieve this in react-native,
Is there a component that have this tab switching animation with also capability off adding an icon next to tabName if possible.
P.S: I found a component react-native-material-tabs but without the ability to an icon. Also found components that requires container component, where I just need one for tabs for my use case.

How to deal with react-native-multiple-select getSelectedItemsExt() function?

I'm building a react native application and found out the react-native-multiple-select library which i emplemented following the documentation https://www.npmjs.com/package/react-native-multiple-select . The view is being displayed but the selected items are not showing up, only the counter of selected items works. I think it's because I don't have the control over how its function getSelectedItemsExt() works and from my researchs on internet like React-native-multiple-select: Cannot read the property 'getSelectedItemsExt' of undefined I only found that I should be doing
<View>
{ this.multiselect
?
this.multiselect.getSelectedItemsExt()
:
null}
</View>
.
Though it helped get rid of the red screen, it doesn't display the items.
So can you please tell me how I can manage
this.multiselect.getSelectedItemsExt()
and get my items displayed.
Any help is much appreciated. Thanks in advance.
I can guess throughout the question that you are passing the hideTags props to the MultiSelect component i.e you are having inside the component <MultiSelect hideTags>. This hideTags was your problem because It does what it's name sounds, i.e it doesn't display the values you set in your FlatList or whatever component. If you want the values to be displayed then remove hideTags from inside the component and you should have your items displayed. Well you want also to customize the output of this library, it's colors and InputField style then head up to the root of your react native application, then go to node-module -> react-native-multiple-select -> Library there you will find the core file that you can customize at your leisure.

Quora-like expandable component in React Native

I'm trying to build a React Native app and would like to implement a component just like in Quora where upon clicking the question, the component expands and shows the remaining details (text/images of the question).
I tried using react-native-panel from https://github.com/dwicao/react-native-panel#readme, but it can only handle text in the panel before expanding. I'd like to implement a panel that has an image in it even before I press on the panel to expand. Would love it if anyone could refer me to any npm packages that use components to achieve this. Thank you!
Use this tutorial https://blog.theodo.com/2020/06/build-accordion-list-react-native/. Stick the desired image somewhere there in the code.

Adding a link to react-native checkbox value

I'm a brand new junior dev working on a react-native app for the first time. I have been searching for quite a while for a way to add a link to the text of a react-native checkbox's value text. If anyone has a link to documentation that might explain what I want to do, I would be super appreciative since I haven't found anything helpful yet. I saw that you can not add html elements into native after I tried a number of variations of anchors. I've tried adding Link to variations and attempted to add an onPress function to the label. I'm grasping at straws here... is this even possible to do?
To be clear, I want a user to be able to press the words "Terms of Service" and have it link to the page that has the terms
{this.props.isUser &&
<CheckBox
containerStyle={styles.checkbox}
onChange={(event, checked) => this.updateAttr('terms', checked)}
value={this.props.program.terms}
label="I have read and understand the Terms of Service"
labelLines={2}
/>
}
Instead of adding the "I accept...." as a label to checkbox, put the Check box without any label and the text 'I have read' as separate Text elements inside a view element and align them accordingly. Then inside the view, put the terms and conditions part inside a touchable and use React Native Linking to link the touchable to open a URL when touched.
https://facebook.github.io/react-native/docs/linking.html
React-Native Open Url in default web browser

'Global' modal in React Native

I'm building an app in React native, and basically, I need a modal(which will have the same content every time) to be available globally (in all components of app), so that I can be able to open it from anywhere in my app.
Obviously copy/pasting the same modal in all the components is not a good solution
Right now I'm having tons of trouble implementing it, so I would like to know what would be the best way to accomplish something like that
Use a Navigator and place your modal below it. Make it visible only when the state changes. The state can be changed from each component inside the Navigator via props.navigator.
You can see the full code with explanation here http://browniefed.com/blog/react-native-easy-overlay-modal-with-navigator/