How to style only FlatList content when it has Header - react-native

I'm trying to make whole screen scrollable. So I need to make the area marked with red ListHeaderComponent and style the actual content area (add a bacgroundColor and shadow to it).
columnWrapperStyle is exactly what I need to use to accomplish the task. But it only works if numColums > 1.
Separating FlatList and Header, and wrapping them into a ScrollView is another option but VirtualizedLists should never be nested inside plain ScrollViews with the same orientation.
There are props to style Header and Footer but there is no way to style only the actual content.
So, How can I style only the content area?

Related

Make only part of flatlist header sticky

I have a flatlist with two components on top of it that need to scroll the flatlist. The obvious fix is to make a header component which includes both components. The problem is i only want the second component to be sticky. I can make both headers sticky with
stickyHeaderIndices={[0]}
however since both components are wrapped to make them the header i cant use stickyHeaderIndices to make it sticky.

How do to use RefreshControl on a view that does not require ScrollView?

I have a React Native View, that I would like to allow the user to refresh by pulling down, this View contains fixed content that fits on one screen without the need to scroll, and I have used flex to position the elements to utilised the hold screen.
A quick google tells me I need a RefreshControl, but it seems this must be used in conjunction with a ScrollView.
When I try to apply these two controls to my View I get undesired effects:
Scrolls bars that I don't need, although these can be disabled via props
Flex now responds in a different way, the flex items dont expand to the container, which makes sense because its a scrollable container.
Help :)
I would indeed reuse RefreshControl in ScrollView, instead creating a RefreshControl behavior yourself.
As you mentioned, scroll indicators can be hidden by setting the correct props. In addition it is possible to disable scrolling with the scrollEnabled flag.
A ScrollView uses a built-in content container that wraps all the views inside. You can set flex style props for this view as well.
<ScrollView contentContainerStyle={{flex: 1}}>
{/* child views */}
</ScrollView>

React Native Flatlist inside ScrollView

I am trying to develop a profile screen which has the persons profile pic, name, etc in the header as well as tabs that determines which data gets displayed in the FlatList below. I want the header component to be scrollable with the FlatList so that the header does not take up screen space while scrolling the FlatList. Also, the header's tabs will change the data that gets render in the list. I have tried two approaches but neither one has worked. Including the header and flatlist inside of a scrollview causes the flatlist to continually call onEndReach until all of the data is returned, but I also read that this is not recommended. The second approach was setting the ListHeaderComponent on the flatlist to the header component, but every time a tab is change the entire screen reloads. I am looking to have the header scrollable as if it were part of the flatlist, and only the flatlist re-render when a tab is pressed. Similar to what Instagram has with their profile screen. Any help with this issue would be much appreciated.

Sectionlist Horizontal with sticky header in React Native?

I've been able to render the Sectionlist in React Native with horizontal={true}, but when I have two problems with the section header.
The header appears as a part of the list, and not above it.
Even with stickySectionHeadersEnabled={true}, the header does not stick and scrolls along with the list.
Expected
How it actually appears
horizontal is a prop of ScrollView. Setting horizontal={true} will render every child component of a ScrollView to be horizontally rendered, be it the header or footer or empty component. If you need a layout as what you have drawn under "Expected", you have to make separate View for that.
It makes sense to make everything horizontally in-line, if you are setting horizontal to true. If a SectionList is rendered horizontal, its sections should come up horizontally. If you don't give section headers in between two sections, how will user differentiate between two sections? If you want to have a section header to start at the top of a new section, that's specific to you and you may have to write your own implementation of that.
That's behaving as intended. horizontal={true} means headers will also be rendered horizontally.
If you want headers to be above the items, you could likely hack it by setting the width of the section header to 0, and place a horizontal header within that element, positioned at the very top, so it overlays over the next element.
According to the ListView documentation, the stickySectionHeadersEnabled prop is not supported when horizontal is set to true. While it doesn't currently say this on the SectionList documentation, I assume it's also true for SectionList.
stickyHeaderIndices
(...) This property is not supported in conjunction with horizontal={true}.

How do I make the navigationBar appear on top in React Native

I was testing out the Navigator component and I was trying to use its navigationBar property. I want it to appear on top of the "content" instead of below it, the only way I found to do that is by using position absolute, but that way I need to set the top of the "content" as well (requiring me to make a fixed height navigationBar plus unnecessary boilerplate code). Is there any other way to do this?