Animate the height of ListFooterComponent in React-Native's flatlist - react-native

I am working on gradually increasing the height of list footer component so that whatever is there is my footer be shown gradually to the user and on swipe up. Also keeping in mind that the list items doesn't get hidden by footer's view.
I have made a animated.view in the footer's component and used animated.timing to gradually increase the height but it is not working correctly.

Related

React Native pushing component in and out of screen dynamically

As shown in the attached gif, the navigation bar at the bottom and the URL bar at the top are pushed in and out(not just show/hide at once) of view as user scrolls. How can I achieve this 'hiding' effect in React Native? The key point is that the hiding speed of the component should correspond to the scrolling speed.
I have tried giving negative values to the top and bottom, like so:
style={{bottom:dynamicallyChangingScrolledValue()}}
although it does push the view out of the screen, space where the component used to remain in the blank, occupied.
Are they using animations here? or changing some offset value dynamically by incrementing a small amount?

How to know a ScrollView content is scrollable or not react native?

I have some dynamic content which I have placed inside a ScrollView.
As per the content's height it makes scroll. Some times because of the content height there is no scroll. I just want to know is there any way to detect programmatically ScrollView container is scrollable or not depending on the content's height ?
If for a given height to the scrollview, the content is not fitting to
that height then automatically the scrollview is scrollable, otherwise
its just a normal view. It Depends mostly on the device height, Let
say for a small device the view is scrollable and for long devices,
that view is not scrollable.
It purely depends on the content, you are not able to figure out when it should be scrollable and when not.
Hope this helps...Thanks :)

Getting visible area of Image in React Native ScrollView

I have a scrollView with a single Image in it. Initially the Image has the same width & heigth as the ScrollView.
I am trying to crop this image based on how the user have zoomed and moved the image. Basically, I want to know what part of the image is visible, so that I can crop it accordingly.
Im using expo's ImageManipulator to crop it, so I have that part covered. But to get the dimensions of what part of the Image is visible after zoom/drag is whats bugging me.
Much appreciated!
The logic here is to first fill the Image component inside the size of the ScrollView. This way, the size of the image will be equal to the size of the ScrollView.
First, you need to set directionalLockEnabled prop to false and horizontal prop to true to make the ScrollView scroll horizontally.
Then, set maximumZoomScale and minimumZoomScale props to make your ScrollView zoomable. Now, every time you zoom and scroll in your ScrollView it will fire onMomentumScrollEnd and onScrollEndDrag with the event parameter from which you can get the visible part of your ScrollView which is usually,
event.nativeEvent.contentOffset
event.nativeEvent.contentSize
event.nativeEvent.layoutMeasurement
Since your Image Component size is same as that of the ScrollView Component, it will give you the exact visible area of the image in the ScrollView.
For Detailed implementation example, you can refer to this file of the react-native-community/react-native-image-editor repository

React Native: How to make ScrollView scroll for just one item in it?

I have an image rendered inside a scrollview component and the dimensions of the image are fixed as (height: 200, and width from device dimension).
Also the style of the scrollview is set as (flex: 1 not contentContainerStyle).
But the image doesn't scroll properly and snaps back when I scroll.
I understand that this is because there is only one item in the scrollView.
How to force scroll the content inside the scrollView even if there is only one item in it?
Try wrapping your ScrollView within a an enclosing

Have a ScrollView inside a KeyboardAvoidingView that takes at least 100% height to layout children with flexbox

I'm trying to implement a login form that layouts its children with flexbox. It contains two components, the app logo and the login form. The logo should take 33% of the viewports height, the form should take 66%.
This is relatively easy with flexbox. Just set flex: 1 on the logo and flex: 2 on the form.
Wrapping the whole screen in KeyboardAvoidingView works fine – the flex layout shrinks as soon as the keyboard appears, but the user now can't see the bottom elements of the form, since they can't fit in the area above the keyboard.
The obvious solution would be to wrap the form in a ScrollView and wrap that in a KeyboardAvoidingView, but then the whole form flexbox layout stops working. The content container of the ScrollView will only be as tall as the children, it won't take the full viewport height.
I made an expo Snack showing my layout: https://snack.expo.io/rydF0b4O-
I need the layout to be scrollable when it can't show all children, but it seems to be impossible to do that with a ScrollView. (Click the second button to toggle the ScrollView in the layout)