Skip to content

Instantly share code, notes, and snippets.

@eightyfive
Last active September 29, 2021 08:42
Show Gist options
  • Save eightyfive/14dd7da76d609392230b03402703d187 to your computer and use it in GitHub Desktop.
Save eightyfive/14dd7da76d609392230b03402703d187 to your computer and use it in GitHub Desktop.
rnna app starter
$ npx yown @rnna/app-starter
import { onBoot } from 'rnna/events';
export default onBoot(({ router }) => {
router.go('main/Home');
});
function home({ db }) {
const actionCount = db.getActionCount();
return {
actionCount,
name: "World"
};
}
const routes = {
"main/Home": home,
};
export default routes;
import { Container } from "rnna";
import DbBundle from "@rnna/bundle-db";
import RouterBundle from "@rnna/bundle-router";
import routes from "../routes";
import screens from "../views/screens";
import * as selectors from "./selectors";
const container = new Container();
// DB
container.constant("db.selectors", selectors);
container.service("bundles.db", DbBundle);
// Router
container.constant("router.screens", screens);
container.constant("router.routes", routes);
container.service("bundles.router", RouterBundle);
export default container;
import { createSelector as $ } from "@rnna/db";
export const getActionCount = $('actionCount');
const reducers = {
actionCount: (count = 0, action) => count + 1,
};
export default reducers;
export { ActivityIndicator, Button, TextInput } from 'react-native';
export * from 'rnna/views/atoms';
import React from 'react';
import { Text, View } from 'react-native';
import { m, p } from '../theme';
export default function Home({ actionCount, name }) {
return (
<View style={p[3]}>
<Text style={m.b3}>Hello {name} !</Text>
<Text>{actionCount} actions executed so far</Text>
</View>
);
}
// import Login from './login';
import Home from './home';
export default {
// auth: {
// Login,
// },
main: {
Home,
},
};
import { createMargin, createPadding } from 'rnna/views';
// Spacing
const sizes = [0, 4, 8, 16, 32, 64];
export const m = createMargin(sizes);
export const p = createPadding(sizes);
// 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;
{
"dir": "app",
"keywords": ["rnna"],
"dependencies": ["immer"]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment