3
0
Nikatlas vor 5 Jahren
Ursprung
Commit
b6826b13bb

Datei-Diff unterdrückt, da er zu groß ist
+ 0 - 0
dist/lib/Module.js


Datei-Diff unterdrückt, da er zu groß ist
+ 0 - 0
dist/lib/Types.js


Datei-Diff unterdrückt, da er zu groß ist
+ 0 - 0
dist/lib/systems/ActionSystem.js


Datei-Diff unterdrückt, da er zu groß ist
+ 0 - 0
dist/lib/systems/CoreSystem.js


+ 1 - 1
dist/lib/systems/InjectionSystem.js

@@ -1 +1 @@
-var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));var _createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass"));var InjectionSystem=function(){function InjectionSystem(){(0,_classCallCheck2.default)(this,InjectionSystem);}(0,_createClass2.default)(InjectionSystem,[{key:"inject",value:function inject(component){}}]);return InjectionSystem;}();exports.default=InjectionSystem;
+var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));var _createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass"));var InjectionSystem=function(){function InjectionSystem(){(0,_classCallCheck2.default)(this,InjectionSystem);this.systems={};}(0,_createClass2.default)(InjectionSystem,[{key:"depend",value:function depend(SystemName,system){if(this.systems[SystemName])return false;this.systems[SystemName]=system;return true;}},{key:"inject",value:function inject(SystemName){if(!this.systems[SystemName]){console.warn("InjSys: A system was requested but not found: ",SystemName,new Error().stack);return false;}return this.systems[SystemName];}}]);return InjectionSystem;}();var _default=new InjectionSystem();exports.default=_default;

Datei-Diff unterdrückt, da er zu groß ist
+ 0 - 0
dist/lib/systems/ViewSystem.js


Datei-Diff unterdrückt, da er zu groß ist
+ 0 - 0
dist/modules/Image/index.js


Datei-Diff unterdrückt, da er zu groß ist
+ 0 - 0
dist/modules/NativeBase/index.js


+ 16 - 2
lib/Module.js

@@ -2,6 +2,7 @@ import React, {Fragment} from 'react';
 import { View } from 'react-native';
 
 import { Resolver } from './Types';
+import Injection from './systems/InjectionSystem';
 
 // EventSystem
 
@@ -9,6 +10,10 @@ export default class Module extends React.Component{
 
 	constructor(props) {
 		super(props);
+		this.Core = Injection.inject('Core');
+		this.Modules = Injection.inject('Modules');
+
+
 		let {
 			ModuleID,
 			EventSystem
@@ -23,6 +28,7 @@ export default class Module extends React.Component{
 			marginLeft: 24,
 			marginRight: 24
 		}
+		this.counter = 0;
 	}
 
 	getId() {
@@ -41,7 +47,7 @@ export default class Module extends React.Component{
 
 	createAction(action) {
 		if(!this.props.CoreSystem) {
-			console.warning("This module was constructed without a CoreSystem");
+			console.warn("This module was constructed without a CoreSystem");
 			return;
 		}
 		return this.props.CoreSystem.ActionSystem.createAction(action);
@@ -54,8 +60,16 @@ export default class Module extends React.Component{
 	display() {
 		throw new Error("You must extend this base Module and override display method!");
 	}
+
+	module(mod, props) {
+		return mod ? 
+		this.renderModule(mod.value, mod.namespace, props) : null;
+	}
+	moduleArray(modules, props) {
+		return modules ? modules.map((mod) => this.module(mod,props)) : null;
+	}
 	render() {
-		this.counter = 0;
+		this.counter = 10100;
 		return <View ModuleID={this.props.ModuleID} style={[{overflow:'hidden'}]} MY_WRAPPER_FROM_BASE_MODULE={true}>
 			{this.display()}
 		</View>

+ 10 - 4
lib/Types.js

@@ -169,13 +169,19 @@ class JSObject extends Type {
 
 
 class JSArray extends Type{
-	constructor(){
-		super(Types.Array)
+	constructor(Template){
+		super(Types.Array);
+		this.Template = Template;
 	}
 	resolve(value){
-		if(Array.isArray(value))
+		if(Array.isArray(value)) {
+			for(var i=0;i<value.length;i++) {
+				if(!this.Template.resolve(value[i])) {
+					return false;
+				}
+			}
 			return true;
-		else if ((value === undefined || value === null) && !this.isRequired)
+		} else if ((value === undefined || value === null) && !this.isRequired)
 			return true;
 		return false;
 	}

+ 1 - 1
lib/systems/ActionSystem.js

@@ -28,7 +28,7 @@ export default class ActionSystem {
 
 	disable() {this._disabled = true;}
 	enable() {this._disabled = false;}
-	toggle() {this._disabled = !this._disabled;}
+	toggle(value) {this._disabled = value || !this._disabled;}
 
 	createAction(action) {
 		if (!action.type) return;

+ 9 - 2
lib/systems/CoreSystem.js

@@ -4,16 +4,23 @@ import ModuleSystem from './ModuleSystem.js';
 import Modules from '../../modules';
 import EventSystem from './EventSystem';
 import ActionSystem from './ActionSystem';
+import InjectionSystem from './InjectionSystem';
 import * as Font from 'expo-font';
 export default class CoreSystem {
 	constructor(dev = false) {
 		// TODO -- Make correct Initialization
+		InjectionSystem.depend("Core", this);
+
 		this.Routing = new RoutingSystem();
+		InjectionSystem.depend("Routing", this.Routing);
 		this.ModuleSystem = new ModuleSystem();
-		this.EventSystem = new EventSystem();
+		InjectionSystem.depend("Modules", this.ModuleSystem);
 		this.ActionSystem = new ActionSystem(this);
+		InjectionSystem.depend("Actions", this.ActionSystem);
 		this.ActionSystem.onUpdate(() => this.forceUpdate());
+
 		this.ViewSystem    = new ViewSystem(this);
+		InjectionSystem.depend("Views", this.ViewSystem);
 		this.loadFonts()
 		this.__loadModules(Modules);
 		this._devMode = dev;
@@ -29,7 +36,7 @@ export default class CoreSystem {
 		this.ActionSystem.onUpdate(() => this.forceUpdate());
 		this.Routing = new RoutingSystem();
 		this.ModuleSystem = new ModuleSystem();
-		this.EventSystem = new EventSystem();
+		
 		this.ViewSystem    = new ViewSystem(this);
 		let HomeView = new View();
 		this.addPage('Home', HomeView, 'VSHome').setHome('Home');

+ 19 - 4
lib/systems/InjectionSystem.js

@@ -1,9 +1,24 @@
-export default class InjectionSystem {
+class InjectionSystem {
 	constructor(){
+		this.systems = {};
+	}
 
+	depend(SystemName, system) {
+		if(this.systems[SystemName])
+			return false;
+		this.systems[SystemName] = system;
+		return true;
 	}
 
-	inject(component){
-		
+	inject(SystemName) {
+		if(!this.systems[SystemName]) {
+			console.warn("InjSys: A system was requested but not found: ", SystemName, new Error().stack);
+			return false;
+		}
+		return this.systems[SystemName];		
 	}
-}
+
+
+}
+
+export default new InjectionSystem();

+ 4 - 0
lib/systems/ViewSystem.js

@@ -26,6 +26,10 @@ export class Node extends TreeNode {
 			this.content = content; // this is a viewNode
 		}
 	}
+	export() {
+		delete this.props.selected;
+		return super.export();
+	}
 }
 
 export default class ViewSystem {

+ 1 - 1
modules/Form/index.js

@@ -11,7 +11,7 @@ const Inp = [
 		{
 		textContentType :"password",
 		placeholder:"password"
-		}]
+}]
 
 
 export default class FormComp extends Module {

+ 1 - 1
modules/Image/index.js

@@ -21,7 +21,7 @@ export default class ImageComp extends Module {
 		} = this.props;
 		if(!width) width = "100%";
 		return 	<Image
-			          style={{borderRadius, width, height, paddingTop: height ? '0' : '56.25%'}}
+			          style={{borderRadius, width, height, paddingTop: height ? '0' : '56.25%', minHeight: 20, minWidth: 20}}
 			          resizeMode={resizeMode}
 			          source={source || image}
 			        />

+ 84 - 52
modules/NativeBase/index.js

@@ -11,7 +11,7 @@ import { Body as BodyCtor } from 'native-base';
 import { Button as ButtonCtor } from 'native-base';
 import { Card as CardCtor } from 'native-base';
 import { CardItem as CardItemCtor } from 'native-base';
-import { Checkbox as CheckboxCtor } from 'native-base';
+import { CheckBox as CheckboxCtor } from 'native-base';
 import { Container as ContainerCtor } from 'native-base';
 import { Content as ContentCtor } from 'native-base';
 import { DatePicker as DatePickerCtor } from 'native-base';
@@ -126,26 +126,29 @@ export class Card extends Module {
 			header,
 			body,
 			footer,
+			bodyModules,
 			...rest
 		} = this.props;
 
 		let item = this.renderModule('Button','NativeBase');
 		console.log("ITEM : ", item);
 		return  <CardCtor {...rest}>
-            <CardItemCtor header>
+            {header ? <CardItemCtor header>
               <TextCtor>{header}</TextCtor>
             </CardItemCtor>
+        	: null}
             <CardItemCtor>
               <BodyCtor>
                 <TextCtor>
                   {body}
-                  {item}
                 </TextCtor>
+                {this.moduleArray(bodyModules)}
               </BodyCtor>
             </CardItemCtor>
-            <CardItemCtor footer>
+            {footer ? <CardItemCtor footer>
               <TextCtor>{footer}</TextCtor>
             </CardItemCtor>
+        	: null}
         </CardCtor>;
 	}
 }
@@ -224,16 +227,41 @@ export class FooterTab extends Module {
 export class Form extends Module {
 	constructor(props) {
 		super(props);
+		this.state = {};
 	}
+	
+	submit() {
+		this.createAction(this.props.onSubmit);
+	}
+
+	change(item, value) {
+		this.setState({
+			[item]: value 
+		});
+	}
+
 	display() {
-		return <FormCtor {...this.props}>
-            <ItemCtor>
-              <InputCtor placeholder="Username" />
-            </ItemCtor>
-            <ItemCtor last>
-              <InputCtor placeholder="Password" />
-            </ItemCtor>
-          </FormCtor>
+		let {
+			inputs,
+			button,
+			onSubmit,
+			...rest
+		} = this.props;
+		return [
+		<FormCtor {...rest}>
+            {inputs ? inputs.map((item, index) => {
+        	return <ItemCtor key={index} last={index === inputs.length-1}>
+	              	<InputCtor placeholder={item} 
+	              		placeholderLabel={item} 
+	              		value={this.state[item && item.toLowerCase()] || ''}
+	              		onChangeText={(value) => this.change(item && item.toLowerCase(), value)}/>
+	            </ItemCtor>
+	        }) : null}
+        </FormCtor>,
+	    button ? <ButtonCtor onPress={() => this.submit()}>
+	    	<TextCtor>{button}</TextCtor>
+	    </ButtonCtor>: null
+	    ]
 	}
 }
 export class Gravatar extends Module {
@@ -339,7 +367,7 @@ export class Item extends Module {
 		console.log("RENDERMOD:", mod);
 		return <ContentCtor>
 		<ItemCtor {...rest}>
-			{mod ? this.renderModule(mod.value, mod.namespace) : null}
+			{this.module(mod)}
 		</ItemCtor>
 		</ContentCtor>;
 	}
@@ -591,6 +619,8 @@ Card.Inputs = {
 	header: new Types.Text().default("Header"),
 	body: new Types.Text().default("Lorem ipsum body bla la trapala"),
 	footer: new Types.Text().default("Add footer here"),
+	bodyModules: new Types.Array(new Types.Module()),
+	texts: new Types.Array(new Types.Text())
 }
 CardItem.Inputs = {
 	header: new Types.Bool(),
@@ -625,7 +655,9 @@ FooterTab.Inputs = {
 	
 }
 Form.Inputs = {
-	
+	inputs: new Types.Array(new Types.Text()),
+	button: new Types.Text().default('Submit'),
+	onSubmit: new Types.Action()
 }
 Gravatar.Inputs = {
 	email: new Types.Text().require(),
@@ -750,53 +782,53 @@ View.Inputs = {
 }
 
 export default { 
-	Accordion,
-	Actionsheet,
+	// Accordion,
+	// Actionsheet,
 	Badge,
-	Body,
+	// Body,
 	Button,
 	Card,
-	CardItem,
+	// CardItem,
 	Checkbox,
-	Container,
-	Content,
-	DatePicker,
-	DeckSwiper,
-	Fab,
-	Footer,
-	FooterTab,
+	// Container,
+	// Content,
+	// DatePicker,
+	// DeckSwiper,
+	// Fab,
+	// Footer,
+	// FooterTab,
 	Form,
-	Gravatar,
+	// Gravatar,
 	H1,
 	H2,
 	H3,
-	Header,
+	// Header,
 	IconNB,
 	Input,
-	InputGroup,
-	Item,
-	Label,
-	Left,
-	List,
-	ListItem,
-	PickerItem,
+	// InputGroup,
+	// Item,
+	// Label,
+	// Left,
+	// List,
+	// ListItem,
+	// PickerItem,
 	Radio,
-	Right,
-	Root,
-	Segment,
-	Separator,
-	Spinner,
-	Subtitle,
-	SwipeRow,
-	Switch,
-	Tab,
-	TabContainer,
-	TabHeading,
-	Text,
-	Textarea,
-	Thumbnail,
-	Title,
-	Toast,
-	ToastContainer,
-	View 
+	// Right,
+	// Root,
+	// Segment,
+	// Separator,
+	// Spinner,
+	// Subtitle,
+	// SwipeRow,
+	// Switch,
+	// Tab,
+	// TabContainer,
+	// TabHeading,
+	// Text,
+	// Textarea,
+	// Thumbnail,
+	// Title,
+	// Toast,
+	// ToastContainer,
+	// View 
 }

Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden.