Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

JitsiScreen.js 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. // @flow
  2. import React from 'react';
  3. import { ScrollView, View } from 'react-native';
  4. import { SafeAreaView } from 'react-native-safe-area-context';
  5. import { StyleType } from '../../styles';
  6. import JitsiKeyboardAvoidingView from './JitsiKeyboardAvoidingView';
  7. import styles from './styles';
  8. type Props = {
  9. /**
  10. * Additional style to be appended to the KeyboardAvoidingView content container.
  11. */
  12. contentContainerStyle?: StyleType,
  13. /**
  14. * The children component(s) of the Modal, to be rendered.
  15. */
  16. children: React$Node,
  17. /**
  18. * Disabled forced keyboard dismiss?
  19. */
  20. disableForcedKeyboardDismiss?: boolean,
  21. /**
  22. * Optional function that renders a footer component, if needed.
  23. */
  24. footerComponent?: Function,
  25. /**
  26. * Is a text input rendered at the bottom of the screen?
  27. */
  28. hasBottomTextInput?: boolean,
  29. /**
  30. * Is the screen rendering a tab navigator?
  31. */
  32. hasTabNavigator?: boolean,
  33. /**
  34. * Insets for the SafeAreaView.
  35. */
  36. safeAreaInsets?: Array,
  37. /**
  38. * Enable scroll for JitsiScreen.
  39. */
  40. scrollEnabled?: boolean,
  41. /**
  42. * Additional style to be appended to the KeyboardAvoidingView containing the content of the modal.
  43. */
  44. style?: StyleType
  45. }
  46. const JitsiScreen = ({
  47. contentContainerStyle,
  48. children,
  49. footerComponent,
  50. hasTabNavigator = false,
  51. hasBottomTextInput = false,
  52. disableForcedKeyboardDismiss = false,
  53. safeAreaInsets = [ 'left', 'right' ],
  54. scrollEnabled = false,
  55. style
  56. }: Props) => {
  57. const renderContent = () => (
  58. <JitsiKeyboardAvoidingView
  59. contentContainerStyle = { contentContainerStyle }
  60. disableForcedKeyboardDismiss = { disableForcedKeyboardDismiss }
  61. hasBottomTextInput = { hasBottomTextInput }
  62. hasTabNavigator = { hasTabNavigator }
  63. style = { style }>
  64. <SafeAreaView
  65. edges = { safeAreaInsets }
  66. style = { styles.safeArea }>
  67. { children }
  68. </SafeAreaView>
  69. { footerComponent && footerComponent() }
  70. </JitsiKeyboardAvoidingView>
  71. );
  72. if (scrollEnabled) {
  73. return (
  74. <ScrollView
  75. bounces = { false }
  76. style = { styles.jitsiScreenContainer }>
  77. { renderContent() }
  78. </ScrollView>
  79. );
  80. }
  81. return (
  82. <View style = { styles.jitsiScreenContainer }>
  83. { renderContent() }
  84. </View>
  85. );
  86. };
  87. export default JitsiScreen;