Code Monkey home page Code Monkey logo

uxengineerlab / rnn-starter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kanzitelli/rnn-starter

0.0 1.0 0.0 4.58 MB

๐Ÿคน Production-ready starter for React Native App! Powered by cli-rn, React Native Navigation, RN UI lib, MMKV, Mobx, Reanimated 2, Dark Mode, Localization, Notifications, Permissions, and much more.

Home Page: https://cli-rn.batyr.io

License: MIT License

JavaScript 1.88% Java 15.59% Ruby 1.75% Objective-C 8.93% TypeScript 70.53% Starlark 1.32%

rnn-starter's Introduction

This starter is a collection of libraries and approaches from my personal experience. No hard judgements โœŒ๏ธ

For more information, check out Why section.

Getting Started

Quick start with cli-rn

> npx cli-rn new App -t rnn

If you have any troubles running the app with yarn ios or yarn android, open XCode or Android Studio and run the project from there.

Manual setup
  1. Clone the repo
> git clone https://github.com/kanzitelli/rnn-starter.git App && cd App
  1. Remove .git file (if not planning to contribute)
> rm -rf .git
  1. Install packages and pods
> yarn && yarn ios:pods
  1. Run it!

Open XCode or Android Studio to run the project (recommended) or do

> yarn ios
> yarn android

If you need to rename the app, do the following (based on react-native-rename):

> yarn rename NewAppName
> yarn ios:pods

What's inside

  • React Native Navigation - truly native navigation experience for iOS and Android.
  • RN UI lib - amazing Design System, UI toolset & components library for React Native. Dark Mode is implemented using this library.
  • Reanimated 2 - React Native's Animated library reimplemented.
  • MobX - simple, scalable state management, with mobx-persist-store for persisting your stores.
  • AsyncStorage MMKV - efficient, small mobile key-value storage framework developed by WeChat. ~30x faster than AsyncStorage!
  • Expo SDK 43. Integration with Expo Modules could be found under rnn-starter@expo-modules branch.

Extra helpful libraries

Useful services/methods

  • navigation - a service where all navigation configuration takes place in (such as default options, listeners, etc.).
  • translate - a service that brings easy integration of localization for an app by using i18n-js and react-native-localize. You can see an example of en and ru localizations in Example screen.
  • onStart - a service where you can write your own logic when app is launched. For example, you can increment number of appLaunches there.
  • configureDesignSystem() - a method where all settings for an app's design system is taking place. You can customize there colors, schemes, typegraphy, spacings, etc. Now you can add as much theme modes as you want.
rnn-starter.mp4

Advantages

Describe app screens in one place

All setup for your screens takes place in one file src/screens/index.ts:

import {generateRNNScreens} from 'rnn-screens';

export const screens = generateRNNScreens(
  {
    Main: {
      component: Main,
      options: {
        topBar: {
          ...withTitle(services.t.do('home.title')),
          ...withRightButtons('inc', 'dec'),
        },
        ...withBottomTab('Main', 'newspaper'),
      },
    },
    // ...
  },
  [withGestureHandler, withStores, withServices, withAnotherProvider],
);

Navigate to other screens with predictability

import {screens} from '.';

const Screen = ({componentId}) => {
  const {nav} = useServices();

  return (
    <View>
      <Button
        label="Open Settings"
        onPress={() => screens.push(componentId, 'Settings')}
      />
    </View>
  )
}

Build layouts with ease

One screen app:

screens.N.setRoot(Root(Stack(Component(screens.get('Main')))));

Three tabs app:

screens.N.setRoot(
  Root(
    BottomTabs([
      Stack(Component(screens.get('Main'))),
      Stack(Component(screens.get('Example'))),
      Stack(Component(screens.get('Settings'))),
    ]),
  ),
);

Simplified API for Shared Transitions

screens.push<ExampleScreenProps>(
  componentId,
  'Example',
  { value: randomNum() },
  withSharedTransitions([{ id: 'reanimated2', pop: true }]),
)

Correct Dark mode implementation

You can define modes in utils/designSystem.tsx.

Samples for new screens, services, stores and components.

So you have one structure within the project. You can find them in corresponding folders. Just copy&paste it and make the necessary changes.

Enhancements

There are still some things I would like to add to the starter:

General

  • Shared transitions example
  • Passing props to a screen example
  • Constants: add Dimensions, Navigation (nav service)
  • AsyncStorage stores persisting example
  • API example + useEffect and start logic on a screen
  • Example with theme modes change
  • Move some services/scripts to separate libraries, e.g., rnn-screens. Done - kanzitelli/rnn-screens
  • Better documentation/exlanation for project structure, stores, services, etc.

Production

Feel free to open an issue for suggestions.

Known issues (warnings)

  • Large title is not shown on 2nd+ tab. This issue exists. So you can find the patch file for fixing that in patches/react-native+0.65.1.patch. It will be autorun when you do yarn add/remove/etc.
  • Over-The-Air Updates. They have been removed from the current version as I had some problems publishing one of the apps to AppStore. Check out my tweet and be aware of the issue if you'd like to use them anyways.

Worth checking

Other starters

  • expo-starter - ๐Ÿฆฅ Production-ready starter for Expo (React Native) App! Powered by cli-rn, React Navigation (v6), RN UI lib, Mobx, Reanimated 2, Dark Mode, Localization, and much more.
  • rn-starter - ๐Ÿฆ„ Production-ready starter for React Native App! Powered by cli-rn, React Navigation (v6), RN UI lib, Mobx, Reanimated 2, Dark Mode, Localization, Notifications, Permissions, and much more.

Articles

  • Expo + React Native Navigation? Yes! - Medium, Dev.to
  • cli-rn โ€” making RN app developing experience as smooth as possible - Medium, Dev.to

Apps in production

Why

...do we need yet another starter/boilerplate? Well, I work with React Native for more than 3 years and during the time I started having my own project structure which was a good fit for almost all of the delivered apps. Also, I have come up with some custom useful services/methods which simplify usage of React Native Navigation and other libraries. Check out Advantages section.

License

This project is MIT licensed

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.