diff --git a/App.js b/App.js deleted file mode 100644 index 51dcb4c..0000000 --- a/App.js +++ /dev/null @@ -1,41 +0,0 @@ -import React, { Component } from 'react'; -import { - Platform, - StyleSheet, - Text, - View, - TextInput, - Alert, - TouchableOpacity -} from 'react-native'; - - -export default class App extends React.Component { - constructor(props) { - super(props); - this.state = { - TestValue: "Ahmet" - } - } - test() { - Alert.alert("A Message", "Test Contetn title"); - } - render() { - return ( - - Init commit - - ) - } -} - -const styles = StyleSheet.create({ - container: { - flex: 1, - justifyContent: 'center', - alignItems: 'center', - backgroundColor: '#F5FCFF', - }, - - -}); diff --git a/app/components/TestComponent.js b/app/components/TestComponent.js new file mode 100644 index 0000000..e69de29 diff --git a/app/index.js b/app/index.js new file mode 100644 index 0000000..3b459d2 --- /dev/null +++ b/app/index.js @@ -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 ( + + + + + + ); + } +} + +export default App; \ No newline at end of file diff --git a/app/pages/MainPage.js b/app/pages/MainPage.js new file mode 100644 index 0000000..61000f4 --- /dev/null +++ b/app/pages/MainPage.js @@ -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 ( + + Test + + + ); + } +} + +export default MainPage; \ No newline at end of file diff --git a/app/resources/colors/colors.js b/app/resources/colors/colors.js new file mode 100644 index 0000000..b1f088b --- /dev/null +++ b/app/resources/colors/colors.js @@ -0,0 +1,4 @@ +var colors={ + +}; +module.exports = colors; \ No newline at end of file diff --git a/app/resources/images/images.js b/app/resources/images/images.js new file mode 100644 index 0000000..b33b923 --- /dev/null +++ b/app/resources/images/images.js @@ -0,0 +1,4 @@ +const images= { + + } + module.export = images; \ No newline at end of file diff --git a/app/resources/strings/strings.js b/app/resources/strings/strings.js new file mode 100644 index 0000000..ee9862f --- /dev/null +++ b/app/resources/strings/strings.js @@ -0,0 +1,7 @@ +const strings = { + "GENARAL_TEXTS":{ + "TITLE":"React-Native-Stack", + }, +}; + +module.exports = strings; \ No newline at end of file diff --git a/app/services/Http.js b/app/services/Http.js new file mode 100644 index 0000000..88e0c5d --- /dev/null +++ b/app/services/Http.js @@ -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 \ No newline at end of file diff --git a/app/services/PubSub.js b/app/services/PubSub.js new file mode 100644 index 0000000..dc20b4d --- /dev/null +++ b/app/services/PubSub.js @@ -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() + } + + }) + } + } + } \ No newline at end of file diff --git a/app/services/config.js b/app/services/config.js new file mode 100644 index 0000000..31b7e96 --- /dev/null +++ b/app/services/config.js @@ -0,0 +1,5 @@ +module.exports = { + + SERVER_URL: "my-api-link || localhost:8982" + + }; \ No newline at end of file diff --git a/index.js b/index.js index b1c1d3d..84c5519 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,4 @@ import { AppRegistry } from 'react-native'; -import App from './App'; +import App from './app/index'; AppRegistry.registerComponent('reactnativestack', () => App); diff --git a/package.json b/package.json index cbcc5b8..bbfa85d 100644 --- a/package.json +++ b/package.json @@ -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",