App.tsx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /**
  2. * Sample React Native App
  3. * https://github.com/facebook/react-native
  4. *
  5. * Generated with the TypeScript template
  6. * https://github.com/react-native-community/react-native-template-typescript
  7. *
  8. * @format
  9. */
  10. import React, {useState} from 'react';
  11. import {
  12. SafeAreaView,
  13. ScrollView,
  14. StatusBar,
  15. StyleSheet,
  16. useColorScheme,
  17. Text,
  18. Button,
  19. } from 'react-native';
  20. import {Colors, Header} from 'react-native/Libraries/NewAppScreen';
  21. const App = () => {
  22. const [title, setTitle] = useState('this is test title');
  23. const isDarkMode = useColorScheme() === 'dark';
  24. const setTitles = () => {
  25. setTitle('a');
  26. };
  27. const backgroundStyle = {
  28. backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
  29. };
  30. return (
  31. <SafeAreaView style={backgroundStyle}>
  32. <StatusBar barStyle={isDarkMode ? 'light-content' : 'dark-content'} />
  33. <ScrollView
  34. contentInsetAdjustmentBehavior="automatic"
  35. style={backgroundStyle}>
  36. <Header />
  37. <Button onPress={setTitles} title={title} />
  38. </ScrollView>
  39. </SafeAreaView>
  40. );
  41. };
  42. const styles = StyleSheet.create({
  43. sectionContainer: {
  44. marginTop: 32,
  45. paddingHorizontal: 24,
  46. },
  47. sectionTitle: {
  48. fontSize: 24,
  49. fontWeight: '600',
  50. },
  51. sectionDescription: {
  52. marginTop: 8,
  53. fontSize: 18,
  54. fontWeight: '400',
  55. },
  56. highlight: {
  57. fontWeight: '700',
  58. },
  59. });
  60. export default App;