index.js 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. import React from 'react';
  2. import Module from '../../lib/Module';
  3. import { View , StyleSheet , Text} from 'react-native';
  4. import Types from '../../lib/Types';
  5. import BaseContainer from '../BaseContainer/index';
  6. import ImageComp from '../Image/index';
  7. import TextComp from '../Text/index';
  8. import { ViewNode, Node } from '../../lib/systems/ViewSystem';
  9. /*let base1 = new Node("SS"+ Math.random(), {},new ViewNode("S"+Math.random(), "BaseContainer", {width:320,height:209}))
  10. let base2 = new Node("SS"+ Math.random(), {},new ViewNode("S"+Math.random(), "BaseContainer", {width:320,height:209}))
  11. let Image1 = new Node("SS"+ Math.random(), {},new ViewNode("S"+Math.random(), "Image", {width:320,height:209}))
  12. let Text1 = new Node("SS"+ Math.random(), {},new ViewNode("S"+Math.random(), "Text", {text:"hi there"}))*/
  13. const defaultText = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla eget sapien justo. Nunc justo nunc, tristique sollicitudin sodales et, rhoncus vel augue. Mauris vel elit turpis. Vivamus hendrerit faucibus tortor, eget molestie turpis mattis vel. Cras maximus nibh vitae euismod lobortis. Sed iaculis quis lectus non rhoncus. Quisque non purus vel risus venenatis convallis eu at turpis. Cras accumsan quam eu dolor dignissim accumsan. Vestibulum sed orci facilisis, lacinia nibh vitae, egestas massa. Integer sit amet dui velit. Suspendisse ut nibh massa. Fusce condimentum semper odio, et hendrerit nisi venenatis consequat. Nam sed nibh eros. Nulla facilisi."
  14. export default class BlogPost extends Module {
  15. constructor(props){
  16. super(props)
  17. this.isTemplate = true;
  18. this.id = props.ModuleID;
  19. this.nextNumber = (function* () {
  20. let i = 0;
  21. do{
  22. i++;
  23. yield i;
  24. }while(true);
  25. })();
  26. this.NodeFactory = NodeFactory.bind(this);
  27. this.configure();
  28. }
  29. configure(){
  30. if(this.props.CoreSystem){
  31. let CurrentView = this.props.View; // this.props.CoreSystem.getCurrentView();
  32. let node = CurrentView.getNode(this.props.NodeID)
  33. let children = CurrentView.getChildren(node);
  34. // let NavContainer = NodeFactory({flexDirection:"row",justifyContent:"space-between",alignItems:'center'},'BaseContainer',{height:64,width:375,backgroundColor:'rgba(0, 84, 230, 1)'});
  35. //NavContainer Inputs
  36. // let navIcon = NodeFactory({},'Icon',{name:"reorder",color:'rgba(255, 255, 255, 1)'})
  37. // let navTitle = NodeFactory({},'Text',{text:"XDi",color:'rgba(255, 255, 255, 1)',fontSize:25})
  38. // let navProfile = NodeFactory({},'Icon',{name:"perm-identity",color:'rgba(255, 255, 255, 1)'})
  39. /////////////////////////
  40. let BackIcon = this.NodeFactory({},'Icon',{name:"keyboard-backspace",color:'rgba(255, 255, 255, 1)'});
  41. let IconContainer = this.NodeFactory({justifyContent:'flex-end', height: 48, width: 58},'BaseContainer',{});
  42. let base1 = new Node("SS"+ this.nextNumber.next().value, {})
  43. let base2 = new Node("SS"+ this.nextNumber.next().value, {flex: 1})
  44. let Image1 = new Node("SS"+ this.nextNumber.next().value, {alignItems:'flex-start'},new ViewNode("S"+this.nextNumber.next().value, "Image"))
  45. let wrapper = new Node("SS"+ this.nextNumber.next().value, { marginLeft:24, marginRight:24,flexDirection:"row",justifyContent:"space-between",alignItems:"flex-end", paddingBottom: 4, paddingTop: 24})
  46. let Title = new Node("SS"+ this.nextNumber.next().value, {},new ViewNode("S"+this.nextNumber.next().value, "Text", {text:"This is the post Title",color:"rgba(112, 112, 112, 1)",fontSize:24,fontFamily:"roboto-regular"}))
  47. let BookMark = new Node("SS"+ this.nextNumber.next().value, {},new ViewNode("S"+this.nextNumber.next().value, "Icon", {}))
  48. let subtitle = new Node("SS"+ this.nextNumber.next().value, {marginLeft:24, marginRight:24},new ViewNode("S"+this.nextNumber.next().value, "Text", {text:"This is the subtitle",color:"rgba(193,193,193,1)", fontSize:14,fontFamily:"roboto-medium"}))
  49. let MainText = new Node("SS"+ this.nextNumber.next().value, {marginLeft:24, marginRight:24},new ViewNode("S"+this.nextNumber.next().value, "Text", {text:defaultText, color:"rgba(112, 112, 112, 1)", fontSize:14, fontFamily: 'roboto-regular'}))
  50. let wrapperProfile = new Node("SS"+ this.nextNumber.next().value, {marginLeft:24, marginRight:24, flexDirection:"row", paddingTop:24, paddingBottom: 24})
  51. let ImageWrapper = new Node("SS"+ this.nextNumber.next().value, {flexDirection:"row",justifyContent:"flex-end"}, new ViewNode("S"+this.nextNumber.next().value, "BaseContainer", {width:34}))
  52. let ImageProfile = new Node("SS"+ this.nextNumber.next().value, {},new ViewNode("S"+this.nextNumber.next().value, "Image",{source:require('../Image/assets/profile.png'),width:32,height:32}))
  53. let UserWrapper = new Node("SS"+ this.nextNumber.next().value, {marginLeft:4,flexDirection:"column",height:40,flexGrow:1})
  54. let user = new Node("SS"+ this.nextNumber.next().value, {height:20},new ViewNode("S"+this.nextNumber.next().value, "Text", {text:"Alexandra papadopoulou ",color:"rgba(112, 112, 112, 1)",fontSize:12,fontFamily:"roboto-regular"}))
  55. let userjob = new Node("SS"+ this.nextNumber.next().value, {height:20},new ViewNode("S"+this.nextNumber.next().value, "Text", {text:"MARKET ANALYST",color:"rgba(112, 112, 112, 1)",fontSize:10,fontFamily:"roboto-light", letterSpacing: 1.5}))
  56. // if(!CurrentView.has(NavContainer)) CurrentView.addViewNode(NavContainer,node);
  57. // //adding Children To NavContainer
  58. // if(!CurrentView.has(navIcon)) CurrentView.addViewNode(navIcon,NavContainer)
  59. // if(!CurrentView.has(navTitle)) CurrentView.addViewNode(navTitle,NavContainer)
  60. // if(!CurrentView.has(navProfile)) CurrentView.addViewNode(navProfile,NavContainer)
  61. // --------------------- This is the end of Top Nav -------------
  62. console.log("MATCHCHECK ", CurrentView.has(base1))
  63. if(!CurrentView.has(base1)) CurrentView.addViewNode(base1, node);
  64. if(!CurrentView.has(base2.id)) CurrentView.addViewNode(base2, node);
  65. if(!CurrentView.has(Image1.id)) CurrentView.addViewNode(Image1, base1);
  66. if(!CurrentView.has(IconContainer.id)) CurrentView.addViewNode(IconContainer, Image1)
  67. if(!CurrentView.has(BackIcon.id)) CurrentView.addViewNode(BackIcon, IconContainer)
  68. if(!CurrentView.has(wrapper.id)) CurrentView.addViewNode(wrapper, base2);
  69. if(!CurrentView.has(Title.id)) CurrentView.addViewNode(Title, wrapper);
  70. if(!CurrentView.has(BookMark.id)) CurrentView.addViewNode(BookMark, wrapper);
  71. if(!CurrentView.has(subtitle.id)) {
  72. CurrentView.addViewNode(subtitle , base2);
  73. }
  74. // #######################
  75. if(!CurrentView.has(wrapperProfile.id)){
  76. CurrentView.addViewNode(wrapperProfile,base2);
  77. }
  78. if(!CurrentView.has(ImageWrapper)) CurrentView.addViewNode(ImageWrapper,wrapperProfile);
  79. if(!CurrentView.has(ImageProfile)) CurrentView.addViewNode(ImageProfile,ImageWrapper);
  80. if(!CurrentView.has(UserWrapper)) CurrentView.addViewNode(UserWrapper,wrapperProfile);
  81. if(!CurrentView.has(user)) CurrentView.addViewNode(user,UserWrapper)
  82. if(!CurrentView.has(userjob)) {
  83. CurrentView.addViewNode(userjob,UserWrapper)
  84. this.props.CoreSystem.forceUpdate();
  85. };
  86. if(!CurrentView.has(MainText.id)){
  87. CurrentView.addViewNode(MainText , base2);
  88. this.props.CoreSystem.forceUpdate();
  89. }
  90. }
  91. }
  92. display(){
  93. return(
  94. <View>
  95. </View>
  96. )
  97. }
  98. }
  99. BlogPost.Inputs = {
  100. }
  101. var NodeFactory = function(containerStyle = {}, component, componentStyle = {}){
  102. return new Node("SS"+ this.nextNumber.next().value, containerStyle,new ViewNode("S"+this.nextNumber.next().value, component, componentStyle));
  103. }