3
0

App.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. import React , { useState } from 'react';
  2. import { StyleSheet, Text, View as Div, TextInput, Button } from 'react-native';
  3. import RoutingSystem from './lib/systems/RoutingSystem.js';
  4. import ViewSystem, { View, Node, ViewNode, RowNode, ColNode } from './lib/systems/ViewSystem.js';
  5. import CoreSystem from './lib/systems/CoreSystem.js';
  6. /*********** Custom View Tree ****/
  7. import { Tree } from './lib/helpers/tree';
  8. import FormComp from './modules/Form';
  9. import TextComp from './modules/Text';
  10. import RootComp from './modules/RootComp';
  11. import ImageComp from './modules/Image';
  12. import ButtonComp from './modules/Button';
  13. import Environment from './environment';
  14. import * as Font from 'expo-font';
  15. import Module from './modules';
  16. import BlogFeed from './modules/BlogFeed';
  17. console.log("@@@@@@@@@@@@@@")
  18. console.log(Module)
  19. const CustomStyle = StyleSheet.create({
  20. container:{
  21. flex:1,
  22. backgroundColor:'red'
  23. },
  24. text:{
  25. color:'blue'
  26. }
  27. })
  28. const RootStyle = StyleSheet.create({
  29. container:{
  30. flex:1,
  31. backgroundColor:'blue'
  32. },
  33. text:{
  34. color:'black'
  35. }
  36. })
  37. let RootNode = new ViewNode("A","RootComp",{text:"This is the asd asd asd asd asd asd sda asdaasdasd asd asdasd asd asd dasasdasd asd adsasd asd asd asdasd asd asd asd asd asd asd asd asd sda asdaasdasd asd asdasd asd asd dasasdasd asd adsasd asd asd asdasd asd asd asd asd asd asd asd asd sda asdaasdasd asd asdasd asd asd dasasdasd asd adsasd asd asd asdasd asd asd asd asd asd asd asd asd sda asdStarting point!!!Try add on me ",style:RootStyle});
  38. let TestNode = new ViewNode("H","Text",{style:CustomStyle,text:"Edited Text Node Will be here"})
  39. let ImageNode = new ViewNode("asdasd","Image");
  40. // let Row1 = new RowNode("RootRow");
  41. // let Col11 = new ColNode("Col11");
  42. // let Col12 = new ColNode("Col12");
  43. // let Row2 = new RowNode("RootRow2");
  44. // let Col21 = new ColNode("Col21");
  45. // let Col22 = new ColNode("Col22");
  46. // Col21.content = RootNode;
  47. // Col12.content = TestNode;
  48. let nodeA = new Node("A", {justifyContent: 'flex-end', stretchContainer: true, selected: true});
  49. let nodeB = new Node("B", {justifyContent: 'flex-end' , selected: true}, ImageNode);
  50. let nodeC = new Node("C", {alignSelf: 'flex-end' , selected: true}, ImageNode);
  51. let nodeD = new Node("D");
  52. let nodeE = new Node("E", {alignSelf: 'flex-end' , selected: true}, ImageNode);
  53. let VS = new View();
  54. let root = VS.defaultContainer;
  55. VS
  56. .addViewNode(nodeA, root)
  57. .addViewNode(nodeB, nodeA)
  58. .addViewNode(nodeC, nodeA)
  59. .addViewNode(nodeD, nodeA);
  60. let datata = VS.export();
  61. let VS2 = new View();
  62. VS2
  63. .addViewNode(nodeE, VS2.defaultContainer)
  64. .import(datata, nodeE.id);
  65. // let rowss = VS.setRows(root, 1)[0];
  66. // VS.setColumns(rowss, 2);
  67. // root.props.selected = true;
  68. // let cols = VS.getChildren(rowss);
  69. // VS.setRows(cols[0], 3);
  70. // VS.setRows(cols[1], 2);
  71. // VS.setRows(cols[2], 2);
  72. // cols.forEach((col) => col.props.selected = true);
  73. // cols.forEach((col) => VS.getRows(col).forEach((r) => {VS.setColumns(r,1);r.props.selected = true}));
  74. // cols.forEach((col) => VS.getRows(col).forEach((r) => VS.getColumns(r).forEach((c) => c.props.selected = true)));
  75. // let ee = VS.getRows(cols[1]);
  76. // VS.setColumns(ee[0], 1);
  77. // let cc = VS.getColumns(ee[0]);
  78. // cc[0].content = ImageNode;
  79. // cols[0].content = RootNode;
  80. // cols[1].content = RootNode;
  81. // cols[2].content = ImageNode;
  82. // console.log("ASDASDASDA -> ", cols);
  83. // VS.addViewNode(Row1);
  84. // VS.addViewNode(Col11,Row1);
  85. // VS.addViewNode(Col12,Row1);
  86. // VS.addViewNode(Row2,Col11);
  87. // VS.addViewNode(Col21,Row2);
  88. // VS.addViewNode(Col22,Row2);
  89. // VS.addViewNode(RootNode);
  90. /*VS.addViewNode(NodeB,RootNode)
  91. VS.addViewNode(NodeE,RootNode)
  92. VS.addViewNode(NodeD,NodeB)
  93. VS.addViewNode(NodeK,NodeB)
  94. console.log("@@@@@@@@@@@@@@@@@@@@@@@@@@")
  95. console.log(VS)
  96. //VS.replace(NodeB,TestNode)
  97. VS.replace(NodeK,EditNode)
  98. */
  99. //***************//
  100. /*********************** Custom View tree Ends ************/
  101. //************************************** Routing Ends
  102. let CS = new CoreSystem()
  103. // .addPage('test', VS2, 'VS1')
  104. // .setHome('test');
  105. CS.import(Environment);
  106. // let data = CS.export();
  107. // console.log("Original");
  108. // console.log(data);
  109. // let js = JSON.stringify(data);
  110. // console.log("String");
  111. // console.log(js);
  112. // let NCS = new CoreSystem()
  113. // let againdata = JSON.parse(js);
  114. // console.log("Again");
  115. // console.log(againdata)
  116. // NCS.import(againdata);
  117. // window.onclick = (event) => {
  118. // console.log("Mouse event --- ", event);
  119. // let res = NCS.ray({event}); // returns ViewNode
  120. // console.log(res);
  121. // }
  122. const useForceUpdate = (text) => useState(text)[1];
  123. export default class App extends React.Component {
  124. constructor(){
  125. super()
  126. }
  127. /*let [text, setText] = useState('');
  128. let forceUpdate = useForceUpdate(text);
  129. */
  130. componentDidMount() {
  131. Font.loadAsync({
  132. 'black': require('./assets/fonts/SFCompactDisplay-Black_0.otf'),
  133. 'bold': require('./assets/fonts/SFCompactDisplay-Bold_0.otf'),
  134. 'heavy': require('./assets/fonts/SFCompactDisplay-Heavy_0.otf'),
  135. 'light': require('./assets/fonts/SFCompactDisplay-Light_0.otf'),
  136. 'medium': require('./assets/fonts/SFCompactDisplay-Medium_0.otf'),
  137. 'regular': require('./assets/fonts/SFCompactDisplay-Regular_0.otf'),
  138. 'semibold': require('./assets/fonts/SFCompactDisplay-Semibold_0.otf'),
  139. 'thin': require('./assets/fonts/SFCompactDisplay-Thin_0.otf'),
  140. 'ultralight': require('./assets/fonts/SFCompactDisplay-Ultralight_0.otf')
  141. });
  142. }
  143. render(){
  144. let currentView2 = CS.render();
  145. return (
  146. <Div>
  147. <Div>{CS.ModuleSystem.createElementCtor(BlogFeed)}</Div>
  148. <Div>{currentView2}</Div>
  149. </Div>)
  150. }
  151. }
  152. const ImageStyle = StyleSheet.create({
  153. ImageCont:{
  154. width:250,
  155. height:250
  156. }
  157. })
  158. const styles = StyleSheet.create({
  159. container: {
  160. flex: 1,
  161. backgroundColor: '#fff',
  162. alignItems: 'center',
  163. justifyContent: 'center',
  164. },
  165. });