No Description

App.tsx 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /**
  2. * Sample React Native App
  3. * https://github.com/facebook/react-native
  4. *
  5. * @format
  6. * @flow
  7. */
  8. import * as React from 'react';
  9. import { StyleSheet, ScrollView, View, Text, StatusBar } from 'react-native';
  10. import {
  11. Header,
  12. LearnMoreLinks,
  13. Colors,
  14. DebugInstructions,
  15. ReloadInstructions,
  16. } from 'react-native/Libraries/NewAppScreen';
  17. import { SafeAreaProvider, useSafeArea } from '..';
  18. type ForceInsets = 'always' | 'never';
  19. const CompatSafeAreaView = ({
  20. forceInsets = {},
  21. children,
  22. }: {
  23. forceInsets?: {
  24. top?: ForceInsets;
  25. right?: ForceInsets;
  26. bottom?: ForceInsets;
  27. left?: ForceInsets;
  28. };
  29. children?: React.ReactNode;
  30. }) => {
  31. const insets = useSafeArea();
  32. const top = forceInsets.top === 'never' ? 0 : insets.top;
  33. const right = forceInsets.right === 'never' ? 0 : insets.right;
  34. const bottom = forceInsets.bottom === 'never' ? 0 : insets.bottom;
  35. const left = forceInsets.left === 'never' ? 0 : insets.left;
  36. return (
  37. <View
  38. style={{
  39. paddingTop: top,
  40. paddingRight: right,
  41. paddingBottom: bottom,
  42. paddingLeft: left,
  43. }}
  44. >
  45. {children}
  46. </View>
  47. );
  48. };
  49. const App = () => {
  50. const insets = useSafeArea();
  51. return (
  52. <>
  53. <StatusBar
  54. barStyle="dark-content"
  55. translucent={false}
  56. backgroundColor="transparent"
  57. />
  58. <ScrollView
  59. contentInsetAdjustmentBehavior="never"
  60. style={styles.scrollView}
  61. >
  62. <CompatSafeAreaView>
  63. <Header />
  64. <View style={styles.body}>
  65. <View style={styles.sectionContainer}>
  66. <Text style={styles.sectionTitle}>Step One</Text>
  67. <Text style={styles.sectionDescription}>
  68. Edit <Text style={styles.highlight}>App.js</Text> to change this
  69. screen and then come back to see your edits.
  70. </Text>
  71. </View>
  72. <View style={styles.sectionContainer}>
  73. <Text style={styles.sectionTitle}>See Your Changes</Text>
  74. <Text style={styles.sectionDescription}>
  75. <ReloadInstructions />
  76. </Text>
  77. </View>
  78. <View style={styles.sectionContainer}>
  79. <Text style={styles.sectionTitle}>Debug</Text>
  80. <Text style={styles.sectionDescription}>
  81. <DebugInstructions />
  82. </Text>
  83. </View>
  84. <View style={styles.sectionContainer}>
  85. <Text style={styles.sectionTitle}>Learn More</Text>
  86. <Text style={styles.sectionDescription}>
  87. Read the docs to discover what to do next:
  88. </Text>
  89. </View>
  90. <LearnMoreLinks />
  91. </View>
  92. </CompatSafeAreaView>
  93. </ScrollView>
  94. <View
  95. style={{
  96. position: 'absolute',
  97. top: 0,
  98. right: 0,
  99. left: 0,
  100. height: insets.top,
  101. backgroundColor: 'rgba(0, 0, 0, 0.3)',
  102. }}
  103. />
  104. </>
  105. );
  106. };
  107. const styles = StyleSheet.create({
  108. scrollView: {
  109. backgroundColor: Colors.lighter,
  110. },
  111. engine: {
  112. position: 'absolute',
  113. right: 0,
  114. },
  115. body: {
  116. backgroundColor: Colors.white,
  117. },
  118. sectionContainer: {
  119. marginTop: 32,
  120. paddingHorizontal: 24,
  121. },
  122. sectionTitle: {
  123. fontSize: 24,
  124. fontWeight: '600',
  125. color: Colors.black,
  126. },
  127. sectionDescription: {
  128. marginTop: 8,
  129. fontSize: 18,
  130. fontWeight: '400',
  131. color: Colors.dark,
  132. },
  133. highlight: {
  134. fontWeight: '700',
  135. },
  136. footer: {
  137. color: Colors.dark,
  138. fontSize: 12,
  139. fontWeight: '600',
  140. padding: 4,
  141. paddingRight: 12,
  142. textAlign: 'right',
  143. },
  144. });
  145. export default () => (
  146. <SafeAreaProvider>
  147. <App />
  148. </SafeAreaProvider>
  149. );