Skip to content

Commit

Permalink
create app folder and sub folders.
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmeturganci committed Dec 7, 2017
1 parent f05aa51 commit e33bc9b
Show file tree
Hide file tree
Showing 12 changed files with 158 additions and 43 deletions.
41 changes: 0 additions & 41 deletions App.js

This file was deleted.

Empty file added app/components/TestComponent.js
Empty file.
21 changes: 21 additions & 0 deletions app/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React, {Component} from 'react';
import {Router, Scene} from 'react-native-router-flux';
import MainPage from '../app/pages/MainPage'
import {AsyncStorage,Text,View} from 'react-native'

class App extends Component {

render() {


return (
<Router>
<Scene key="root">
<Scene key="testPage" component={MainPage} title={"Title- Test- Page"}/>
</Scene>
</Router>
);
}
}

export default App;
20 changes: 20 additions & 0 deletions app/pages/MainPage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React, { Component } from 'react';
import { Text, View, TouchableOpacity, StyleSheet, Image } from 'react-native';

class MainPage extends Component {
constructor(props) {
super(props);
this.state = {}
}

render() {
return (
<View>
<Text>Test </Text>

</View>
);
}
}

export default MainPage;
4 changes: 4 additions & 0 deletions app/resources/colors/colors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
var colors={

};
module.exports = colors;
4 changes: 4 additions & 0 deletions app/resources/images/images.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const images= {

}
module.export = images;
7 changes: 7 additions & 0 deletions app/resources/strings/strings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const strings = {
"GENARAL_TEXTS":{
"TITLE":"React-Native-Stack",
},
};

module.exports = strings;
58 changes: 58 additions & 0 deletions app/services/Http.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import axios from 'axios'
import PubSub from './PubSub'

import {SERVER_URL} from '../services/config'

var token = "";

function createAxios() {
return axios.create({
baseURL: SERVER_URL,
headers: {
"token": null
// 'Authorization':"Bearer "+token
},

validateStatus: function (status) {
return true
},
})
}

function request(method, url, data) {
PubSub.emit("ajax:started");
return createAxios()({
method: method,
url: url,
data: data
}).then(function (r) {
PubSub.emit("ajax:finished")
return r
})
}

const Http = {
post(url, data) {
return request('post', url, data);
},
get(url) {
return request('get', url)
},
put(url, data) {
return request('put', url, data)
},

delete(url, data) {
return request('delete', url, data)
},

patch(url, data) {
return request('patch', url, data)
},

getBaseUrl() {
return SERVER_URL
}
}

export default Http
34 changes: 34 additions & 0 deletions app/services/PubSub.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
export default {

events: {},

on: function (eventName, fn) {
this.events[eventName] = this.events[eventName] || []
this.events[eventName].push(fn)
},

off: function(eventName, fn) {
if (this.events[eventName]) {
for (var i = 0; i < this.events[eventName].length; i++) {

if (this.events[eventName][i] === fn) {
this.events[eventName].splice(i, 1)
break
}
}
}
},

emit: function (eventName, data, callback) {
if (this.events[eventName]) {
this.events[eventName].forEach(function(fn) {
fn(data)

if(callback) {
callback()
}

})
}
}
}
5 changes: 5 additions & 0 deletions app/services/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {

SERVER_URL: "my-api-link || localhost:8982"

};
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AppRegistry } from 'react-native';
import App from './App';
import App from './app/index';

AppRegistry.registerComponent('reactnativestack', () => App);
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@
"test": "jest"
},
"dependencies": {
"axios": "^0.17.1",
"eslint-plugin-react-native": "^3.2.0",
"react": "16.0.0",
"react-native": "^0.50.4"
"react-native": "^0.50.4",
"react-native-router-flux": "^4.0.0-beta.24"
},
"devDependencies": {
"babel-jest": "21.2.0",
Expand Down

0 comments on commit e33bc9b

Please sign in to comment.