App.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import React , { useState } from 'react';
  2. import { StyleSheet, Text, View, TextInput, Button } from 'react-native';
  3. import RoutingSystem from './lib/systems/RoutingSystem.js'
  4. import ViewSystem from './lib/systems/ViewSystem.js'
  5. let VS = new ViewSystem();
  6. VS.print();
  7. let RS = new RoutingSystem();
  8. RS.addRoute("test", "test")
  9. .addRoute("test.info.skata", "skata")
  10. .setView("test.info.skata", <Text>HAHAHHA</Text>)
  11. .addRoute("test.info.avga", "avga")
  12. .setHome('test')
  13. .print();
  14. // RS.removeRoute("test.info.skata")
  15. const useForceUpdate = () => useState()[1];
  16. export default function App() {
  17. let [text, setText] = useState('');
  18. let forceUpdate = useForceUpdate();
  19. let CurrentView = RS.getCurrentView();
  20. console.log("RENDER");
  21. return (
  22. <View style={styles.container}>
  23. <TextInput
  24. style={{height: 40, borderColor: 'gray', borderWidth: 1}}
  25. onChangeText={(txt) => setText(txt)}
  26. value={text}
  27. />
  28. <Button title={'Change Route'} onPress={() => {
  29. RS.goTo(text);
  30. forceUpdate();
  31. }}></Button>
  32. <Text>Open up App.js to start working on your app!</Text>
  33. {CurrentView}
  34. </View>
  35. );
  36. }
  37. const styles = StyleSheet.create({
  38. container: {
  39. flex: 1,
  40. backgroundColor: '#fff',
  41. alignItems: 'center',
  42. justifyContent: 'center',
  43. },
  44. });