digitalfabrik/integreat-app

View on GitHub
native/src/components/LayoutedScrollView.tsx

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
import React, { ReactElement } from 'react'
import { RefreshControlProps, ScrollView, StyleProp, ViewStyle } from 'react-native'

import Layout from './Layout'

type LayoutedScrollViewProps = {
  children?: React.ReactNode
  refreshControl?: React.ReactElement<RefreshControlProps>
  style?: StyleProp<ViewStyle>
}

const LayoutedScrollView = ({ children, refreshControl, style }: LayoutedScrollViewProps): ReactElement => (
  <Layout>
    <ScrollView
      keyboardShouldPersistTaps='always'
      // Fixes VirtualizedLists nesting error
      // See https://github.com/facebook/react-native/issues/31697#issuecomment-1742437232
      nestedScrollEnabled
      refreshControl={refreshControl}
      contentContainerStyle={[
        {
          flexGrow: 1,
        },
        style,
      ]}>
      {children}
    </ScrollView>
  </Layout>
)

export default LayoutedScrollView