Last active
March 2, 2021 20:08
-
-
Save eightyfive/3260c0acc80ad39e77b0884ea321dfe5 to your computer and use it in GitHub Desktop.
RNNA App
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Platform } from 'react-native'; | |
import Env from '../env'; | |
export default { | |
url: `${Env.APP_URL}/${Env.API_PREFIX}`, | |
options: { | |
headers: { | |
Accept: 'application/json', | |
'Content-Type': 'application/json', | |
'X-Platform': Platform.OS, | |
}, | |
}, | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// import { schema } from 'normalizr'; | |
// const user = new schema.Entity('users'); | |
export default { | |
// users: user, | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Platform } from 'react-native'; | |
import AsyncStorage from '@react-native-community/async-storage'; | |
const isAndroid = Platform.OS === 'android'; | |
const config = { | |
middlewares: [], | |
persist: { | |
key: 'root', | |
storage: AsyncStorage, | |
// whitelist: [], | |
}, | |
}; | |
if (__DEV__) { | |
// Redux Flipper | |
const createDebugger = require('redux-flipper').default; | |
config.middlewares.push(createDebugger()); | |
// AsyncStorage Flipper | |
const asyncStorageFlipper = require('rn-async-storage-flipper').default; | |
asyncStorageFlipper(AsyncStorage); | |
if (isAndroid) { | |
// https://github.com/facebook/react-native/issues/14101 | |
// https://github.com/rt2zz/redux-persist/issues/717#issuecomment-437589374 | |
config.persist.timeout = 0; | |
} | |
} | |
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default Object.assign( | |
{ | |
APP_URL: 'https://example.org', | |
API_PREFIX: 'api', | |
}, | |
__DEV__ && { | |
APP_URL: 'http://127.0.0.1:8000', | |
}, | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { onAction } from 'rnna/events'; | |
export default function onAction(({ type, payload }, state, services) => { | |
switch (type) { | |
default: | |
break; | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import onBoot from 'rnna/events/boot'; | |
export default onBoot((state, services) => { | |
// | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import api from './api'; | |
import boot from './boot'; | |
import register from './register'; | |
export default [ | |
register, | |
boot, | |
api, | |
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import onRegister from 'rnna/events/register'; | |
export default onRegister((services) => { | |
// | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import createStore from 'rnna/store'; | |
import epics from './events'; | |
import reducers from './state'; | |
import * as services from './services'; | |
import storeConfig from './config/store'; | |
const store = createStore({ ...storeConfig, epics, reducers }, services); | |
// Boot services | |
services.router.addGlobalProp('dispatch', store.dispatch); | |
export default { | |
boot() { | |
return store.hydrate(); | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import View from '../views/scenes/home'; | |
View.options = {}; | |
View.controller = (state, services) => { | |
return {}; | |
}; | |
export default View; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// import Login from './login'; | |
import Home from './home'; | |
export default { | |
// auth: { | |
// Login, | |
// }, | |
main: { | |
Home, | |
}, | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import createApi from 'rnna/services/api'; | |
import apiConfig from '../config/api'; | |
export default createApi(apiConfig); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import createDb, { createSelector } from 'rnna/services/db'; | |
import dbConfig from '../config/db'; | |
const db = createDb(dbConfig); | |
// db.isGuest = createSelector('session.token', (token) => !token); | |
export default db; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export { default as api } from api; | |
export { default as db } from db; | |
export { default as router } from router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createRouter } from 'rnna/services'; | |
import db from './db'; | |
import routes from '../routes'; | |
export default createRouter(routes, { db }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createReducer, produceTables, produceTableOrder } from 'rnna/services/state'; | |
const initialState = { | |
tables: {}, | |
orders: {}, | |
}; | |
export default createReducer((draft, { type, payload = {}, meta }) => { | |
const { entities, result } = payload; | |
if (entities) { | |
produceTables(draft.tables, entities); | |
} | |
if (Array.isArray(result)) { | |
produceTableOrder(draft.orders, type, result); | |
} | |
}, initialState); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default { | |
// | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { Text } from 'react-native'; | |
import { Screen } from 'rnna/views'; | |
export default class Home extends Screen { | |
static displayName = 'Home'; | |
render() { | |
return <Text>Home</Text>; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Colors | |
https://www.materialpalette.com/indigo/red | |
const primary = '#3F51B5'; | |
const primaryDark = '#303F9F'; | |
const primaryLight = '#C5CAE9'; | |
const accent = '#FF5252'; | |
const black = '#212121'; | |
const white = '#FFFFFF'; | |
const grey = '#757575'; | |
const greyLight = '#BDBDBD'; | |
export const colors = { | |
primary, | |
primaryVariant: primaryDark, | |
accent, | |
background: primary, | |
surface: white, | |
error: 'red', | |
text: black, | |
textSecondary: grey, | |
divider: greyLight, | |
on: { | |
primary: white, | |
accent: white, | |
background: white, | |
surface: black, | |
error: white, | |
}, | |
}; | |
export const roundness = 15; | |
export default { | |
colors, | |
roundness: 10, | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import app from './app/register'; | |
app.boot(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"keywords": ["rnna", "react-native", "react-native-navigation"], | |
"dependencies": [ | |
"@react-native-community/async-storage", | |
"color", | |
"date-fns", | |
"react-native-flipper" | |
], | |
"devDependencies": [ | |
"redux-flipper", | |
"rn-async-storage-flipper" | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment