From 3bbd54957cbd122e71277572b68f7a2b0630826c Mon Sep 17 00:00:00 2001 From: Pavlo Aksonov Date: Wed, 30 Dec 2015 09:11:39 +0100 Subject: [PATCH] remove unneeded files --- addActions.js | 73 ------------------------------------------------- createRouter.js | 9 ------ 2 files changed, 82 deletions(-) delete mode 100644 addActions.js delete mode 100644 createRouter.js diff --git a/addActions.js b/addActions.js deleted file mode 100644 index ca555ddb2..000000000 --- a/addActions.js +++ /dev/null @@ -1,73 +0,0 @@ -import React from 'react-native'; -import Actions from './Actions'; -import Router from './Router'; -import defaultCreateRouter from './createRouter'; -import {ExRoute} from './ExRouter'; - -function isNumeric(n){ - return !isNaN(parseFloat(n)) && isFinite(n); -} - -function filterParam(data){ - if (data.toString()!='[object Object]') - return data; - if (!data){ - return; - } - var proto = (data||{}).constructor.name; - // avoid passing React Native parameters - if (proto != 'Object'){ - data = {}; - } - if (data.data){ - data.data = filterParam(data.data); - } - return data; -} - -Actions.push = function(route: ExRoute){ - if (!route.route.parent.previousRoute.navigator){ - throw new Error("No navigator is set for route="+route.route.parent.previousRoute.name); - } - route.route.parent.previousRoute.navigator.push(route); - Actions.currentRoute = route.route; - console.log("CURRENT ROUTE:"+route.route.name); -}; - -Actions.pop = function(data){ - if (!Actions.currentRoute.navigator){ - throw new Error("No navigator is set for route="+Actions.currentRoute.name); - } - if (!Actions.currentRoute.parent.pop(data)){ - console.log("CANNOT DO POP, POP PARENT!"+Actions.currentRoute.parent.parentRoute); - Actions.currentRoute = Actions.currentRoute.parent.parentRoute; - Actions.currentRoute.parent.pop(data); - } - Actions.currentRoute.navigator.pop(); - Actions.currentRoute = Actions.currentRoute.parent.currentRoute; - console.log("CURRENT ROUTE:"+Actions.currentRoute.name); -}; - -export default function addActions(props:{ [key: string]: any}, router:Router, createRoute) { - React.Children.forEach(props.children, function (child, index) { - if (child.type.prototype.className() === "Route") { - const name = child.props.name; - if (!router.routes[name]){ - throw new Error("No route="+name+" is defined" ); - } - const type = router.routes[name].type; - Actions[name] = function (data){ - if (data.toString()!=='[object Object]'){ - data = {data: data}; - } - data = filterParam(data); - if (router.route(name, data)){ - const route = router.routes[name]; - Actions[type](createRoute(route, {data})); - } - - } - } - }); -} - diff --git a/createRouter.js b/createRouter.js deleted file mode 100644 index 3e708540a..000000000 --- a/createRouter.js +++ /dev/null @@ -1,9 +0,0 @@ -import Router from './Router'; -import React from 'react-native'; - -export default function createRouter(props:{ [key: string]: any}):Router { - console.log("CREATE ROUTER"+props.name+" PARENT:"+(props.route && props.route.parent.name)); - const schemas = React.Children.map(props.children, child=>child).filter(child=>child.type.prototype.className() === "Schema").map(child=>child.props); - const routes = React.Children.map(props.children, child=>child).filter(child=>child.type.prototype.className() === "Route").map(child=>child.props); - return new Router(routes, schemas, props['initialRoutes'], props); -} \ No newline at end of file