App.tsx 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /**
  2. * Sample React Native App
  3. * https://github.com/facebook/react-native
  4. *
  5. * @format
  6. */
  7. import React from 'react';
  8. import type {PropsWithChildren} from 'react';
  9. import {
  10. SafeAreaView,
  11. ScrollView,
  12. StatusBar,
  13. StyleSheet,
  14. Text,
  15. useColorScheme,
  16. View,
  17. } from 'react-native';
  18. import {
  19. Colors,
  20. DebugInstructions,
  21. Header,
  22. LearnMoreLinks,
  23. ReloadInstructions,
  24. } from 'react-native/Libraries/NewAppScreen';
  25. type SectionProps = PropsWithChildren<{
  26. title: string;
  27. }>;
  28. function Section({children, title}: SectionProps): React.JSX.Element {
  29. const isDarkMode = useColorScheme() === 'dark';
  30. return (
  31. <View style={styles.sectionContainer}>
  32. <Text
  33. style={[
  34. styles.sectionTitle,
  35. {
  36. color: isDarkMode ? Colors.white : Colors.black,
  37. },
  38. ]}>
  39. {title}
  40. </Text>
  41. <Text
  42. style={[
  43. styles.sectionDescription,
  44. {
  45. color: isDarkMode ? Colors.light : Colors.dark,
  46. },
  47. ]}>
  48. {children}
  49. </Text>
  50. </View>
  51. );
  52. }
  53. function App(): React.JSX.Element {
  54. const isDarkMode = useColorScheme() === 'dark';
  55. const backgroundStyle = {
  56. backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
  57. };
  58. return (
  59. <SafeAreaView style={backgroundStyle}>
  60. <StatusBar
  61. barStyle={isDarkMode ? 'light-content' : 'dark-content'}
  62. backgroundColor={backgroundStyle.backgroundColor}
  63. />
  64. <ScrollView
  65. contentInsetAdjustmentBehavior="automatic"
  66. style={backgroundStyle}>
  67. <Header />
  68. <View
  69. style={{
  70. backgroundColor: isDarkMode ? Colors.black : Colors.white,
  71. }}>
  72. <Section title="Step One">
  73. Edit <Text style={styles.highlight}>App.tsx</Text> to change this
  74. screen and then come back to see your edits.
  75. </Section>
  76. <Section title="See Your Changes">
  77. <ReloadInstructions />
  78. </Section>
  79. <Section title="Debug">
  80. <DebugInstructions />
  81. </Section>
  82. <Section title="Learn More">
  83. Read the docs to discover what to do next:
  84. </Section>
  85. <LearnMoreLinks />
  86. </View>
  87. </ScrollView>
  88. </SafeAreaView>
  89. );
  90. }
  91. const styles = StyleSheet.create({
  92. sectionContainer: {
  93. marginTop: 32,
  94. paddingHorizontal: 24,
  95. },
  96. sectionTitle: {
  97. fontSize: 24,
  98. fontWeight: '600',
  99. },
  100. sectionDescription: {
  101. marginTop: 8,
  102. fontSize: 18,
  103. fontWeight: '400',
  104. },
  105. highlight: {
  106. fontWeight: '700',
  107. },
  108. });
  109. export default App;